Overview

Namespaces

  • Budovy
  • Kdyby
    • BootstrapFormRenderer
      • DI
      • Latte
  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Diagnostics
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
      • Diagnostics
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • PhpGenerator
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
  • NetteModule
  • Nextras
    • Datagrid
  • None
  • PHP
  • Tester
    • CodeCoverage
    • Runner
      • Output
  • Vodacek
    • Forms
      • Controls
  • WebLoader
    • Filter
    • Nette

Classes

  • AuthorizeScheduledTaskFactory
  • AuthorizeScheduledTaskPresenter
  • BasePresenter
  • BreakdownFactory
  • BreakdownPresenter
  • BreakdownRepository
  • BreakdownStatisticFactory
  • BreakdownStatisticPresenter
  • ContactBindingFactory
  • ContactbindingPresenter
  • ContactBindingRepository
  • ContactFactory
  • ContactPresenter
  • ContactRepository
  • DocumentFactory
  • DocumentPresenter
  • DocumentRepository
  • DocumentsDatagrid
  • DocumenttypeFactory
  • DocumenttypePresenter
  • DocumenttypeRepository
  • DownloadPresenter
  • EmailPresenter
  • ErrorPresenter
  • HomepagePresenter
  • OperationFactory
  • OperationPresenter
  • OperationRepository
  • PeriodicTaskFactory
  • PeriodicTaskPresenter
  • PeriodicTaskRealizationFactory
  • PeriodicTaskRealizationPresenter
  • PeriodicTaskRealizationRepository
  • PeriodicTaskRepository
  • PeriodicTaskStatisticFactory
  • PeriodicTaskStatisticPresenter
  • PlaceFactory
  • PlacePresenter
  • PlaceRepository
  • PriorityFactory
  • PriorityPresenter
  • PriorityRepository
  • Repository
  • RoleRepository
  • RouterFactory
  • ScheduledTaskFactory
  • ScheduledTaskPresenter
  • ScheduledTaskRealizationFactory
  • ScheduledTaskRealizationPresenter
  • ScheduledTaskRealizationRepository
  • ScheduledTaskRepository
  • ScheduledTaskStatisticFactory
  • ScheduledTaskStatisticPresenter
  • SignPresenter
  • UnitFactory
  • UnitPresenter
  • UnitRepository
  • UserFactory
  • UserManager
  • UserPresenter
  • UserRepository
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: namespace Budovy;
 3: 
 4: class ContactBindingRepository extends Repository {
 5:     /**
 6:      * Vrati selection pro datagrid
 7:      *
 8:      * @param array $filter
 9:      * @param array $order
10:      * @param int $page
11:      * @param int $limit
12:      * @return \Nette\Database\Table\Selection
13:      */
14:     function getGridSelection($filter, $order, $page, $limit) {
15:         $selection = $this->getTable()
16:             ->select('id_contact, id_unit, id_operation, unit.name AS unit, operation.name AS operation, CONCAT(contact.firstname, \' \', contact.lastname) AS contact')
17:             ->select('unit.place.name AS place');
18: 
19:         if (isset($order[0])) {
20:             $selection->order(implode(' ', $order));
21:         }
22: 
23:         $selection->page($page, $limit);
24: 
25:         return $this->addGridFilter($selection, $filter);
26:     }
27: 
28:     /**
29:      * Vrati pocet zaznamu pro datagrid
30:      *
31:      * @param array $filter
32:      * @return int
33:      */
34:     function getGridCount($filter) {
35:         $selection = $this->getTable()->select('COUNT(*) AS cnt');
36: 
37:         $result = $this->addGridFilter($selection, $filter)->fetch();
38: 
39:         return $result->cnt;
40:     }
41: 
42:     /**
43:      * Omezi selection na zaklade filtru pro datagrid
44:      *
45:      * @param Selection $selection
46:      * @param Array $filter
47:      * @return \Nette\Database\Table\Selection
48:      */
49:     private function addGridFilter($selection, $filter) {
50:         $filters = array();
51: 
52:         foreach ($filter as $k => $v) {
53:             if ($k == 'contact') {
54:                 $filters['id_contact=?'] = $v;
55:             } else if ($k == 'unit') {
56:                 $filters['id_unit=?'] = $v;
57:             } else if ($k == 'place') {
58:                 $filters['unit.id_place=?'] = $v;
59:             } else if ($k == 'operation') {
60:                 $filters['id_operation=?'] = $v;
61:             }
62:         }
63: 
64:         return $selection->where($filters);
65:     }
66: 
67:     /**
68:      * Vraci kontakt odpovidajici jednotce a operaci
69:      *
70:      * @param unknown $id_unit ID jednotky
71:      * @param unknown $id_operation ID operace
72:      * @return mixed
73:      */
74:     function getContact($id_unit, $id_operation) {
75:         return $this->getTable()->select('contact.*')->where(array('id_unit' => $id_unit, 'id_operation' => $id_operation))->fetch();
76:     }
77: 
78:     /**
79:      * Smaze zaznam
80:      *
81:      * @param int $id_contact ID kontaktu
82:      * @param int $id_unit ID jednotky
83:      * @param int $id_operation ID operace
84:      */
85:     public function delete($id_contact, $id_unit, $id_operation) {
86:         $this->getTable()->where(array('id_unit' => $id_unit, 'id_operation' => $id_operation, 'id_contact' => $id_contact))->delete();
87:     }
88: }
API documentation generated by ApiGen 2.8.0