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 UnitRepository extends Repository {
  5:     /**
  6:      * Vraci data v poli ID => nazev
  7:      *
  8:      * @return array
  9:      */
 10:     function getPairData() {
 11:         return $this->getTable()->select('unit.id, CONCAT(place.name, \' - \', unit.name) AS name')->order('place.name ASC, unit.name ASC')->fetchPairs('id', 'name');
 12:     }
 13: 
 14:     /**
 15:      * Vrací řádek podle primárního klíče.
 16:      *
 17:      * @return \Nette\Database\Table\ActiveRow
 18:      */
 19: 
 20:     public function findById($id) {
 21:         return $this->getTable()->select('unit.*, place.name AS place')->wherePrimary($id)->fetch();
 22:     }
 23: 
 24:     /**
 25:      * Vrati selection pro datagrid
 26:      *
 27:      * @param array $filter
 28:      * @param array $order
 29:      * @param int $page
 30:      * @param int $limit
 31:      * @return \Nette\Database\Table\Selection
 32:      */
 33:     function getGridSelection($filter, $order, $page, $limit) {
 34:         $selection = $this->getTable()->select('unit.*, place.name AS place');
 35: 
 36:         if (isset($order[0]))
 37:             $selection->order(implode(' ', $order));
 38: 
 39:         $selection->page($page, $limit);
 40: 
 41:         return $this->addGridFilter($selection, $filter);
 42:     }
 43: 
 44:     /**
 45:      * Vrati pocet zaznamu pro datagrid
 46:      *
 47:      * @param array $filter
 48:      * @return int
 49:      */
 50:     function getGridCount($filter) {
 51:         $selection = $this->getTable()->select('COUNT(*) AS cnt');
 52: 
 53:         $result = $this->addGridFilter($selection, $filter)->fetch();
 54: 
 55:         return $result->cnt;
 56:     }
 57: 
 58:     /**
 59:      * Omezi selection na zaklade filtru pro datagrid
 60:      *
 61:      * @param Selection $selection
 62:      * @param Array $filter
 63:      * @return \Nette\Database\Table\Selection
 64:      */
 65:     private function addGridFilter(\Nette\Database\Table\Selection $selection, $filter) {
 66:         $filters = array();
 67: 
 68:         foreach ($filter as $k => $v) {
 69:             if ($k == 'place')
 70:                 $filters['id_place=?'] = $v;
 71:             else
 72:                 $filters[$k . ' LIKE ?'] = "%$v%";
 73:         }
 74: 
 75:         return $selection->where($filters);
 76:     }
 77: 
 78:     /**
 79:      * Vraci dokumenty prirazene k jednotce
 80:      *
 81:      * @param int $id_unit ID jednotky
 82:      * @return \Nette\Database\Table\Selection
 83:      */
 84:     function getAssignedDocuments($id_unit) {
 85:         return $this->getTable()->select(':unit_document.document.id')->where('unit.id', $id_unit)->where(':unit_document.document.id IS NOT NULL');
 86:     }
 87: 
 88:     /**
 89:      * Priradi dokument
 90:      *
 91:      * @param int $id_unit ID jednotky
 92:      * @param int $id_document ID dokumentu
 93:      */
 94:     function assignDocument($id_unit, $id_document) {
 95:         $this->connection->table('unit_document')->insert(array('id_unit' => $id_unit, 'id_document' => $id_document));
 96:     }
 97: 
 98:     /**
 99:      * Odradi prirazeny dokument
100:      *
101:      * @param int $id_unit ID jednotky
102:      * @param int $id_document ID dokumentu
103:      */
104:     function removeAssignedDocument($id_unit, $id_document) {
105:         $this->connection->table('unit_document')->where(array('id_unit' => $id_unit, 'id_document' => $id_document))->delete();
106:     }
107: }
API documentation generated by ApiGen 2.8.0