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 DocumentRepository 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, $ids = array()) {
15:         $selection = $this->getTable()->select('document.id, document.name, documenttype.name AS documenttype, document.lastmod');
16: 
17:         if (isset($order[0]))
18:             $selection->order(implode(' ', $order));
19: 
20:         $selection->page($page, $limit);
21: 
22:         return $this->addGridFilter($selection, $filter, $ids);
23:     }
24: 
25:     /**
26:      * Vrati pocet zaznamu pro datagrid
27:      *
28:      * @param array $filter
29:      * @param array $ids
30:      * @return int
31:      */
32:     function getGridCount($filter, $ids = array()) {
33:         $selection = $this->getTable()->select('COUNT(*) AS cnt');
34: 
35:         $result = $this->addGridFilter($selection, $filter, $ids)->fetch();
36: 
37:         return $result->cnt;
38:     }
39: 
40:     /**
41:      * Omezi selection na zaklade filtru pro datagrid
42:      *
43:      * @param Selection $selection
44:      * @param Array $filter
45:      * @param Array $ids
46:      * @return \Nette\Database\Table\Selection
47:      */
48:     private function addGridFilter(\Nette\Database\Table\Selection $selection, $filter, $ids) {
49:         $filters = array();
50: 
51:         foreach ($filter as $k => $v) {
52:             if ($k == 'documenttype')
53:                 $filters['document.id_documenttype=?'] = $v;
54:             else if ($k == 'lastmod')
55:                 $filters['DATE(`document`.`lastmod`)=?'] = $v;
56:             else if ($k == 'assigned') {
57:                 if ($v == 1)
58:                     $filters['document.id IN ?'] = $ids;
59:                 else if ($v == 0)
60:                     $filters['document.id NOT IN ?'] = $ids;
61:             } else
62:                 $filters['`document`.'. $k . ' LIKE ?'] = "%$v%";
63:         }
64: 
65:         return $selection->where($filters);
66:     }
67: 
68:     /**
69:      * Vraci META informace pro dokument
70:      *
71:      * @param int $id_document ID dokumentu
72:      * @return mixed
73:      */
74:     function getDocumentsMeta($id_document) {
75:         return $this->getTable()->select('OCTET_LENGTH(data) AS size, mime, lastmod, name, filename')->where(array('id' => $id_document))->fetch();
76:     }
77: 
78:     /**
79:      * Vraci selection dokumentu
80:      *
81:      * @return \Nette\Database\Table\Selection
82:      */
83:     function getDocuments() {
84:         return $this->getTable()->select('document.id, document.name, document.lastmod, type.name AS type');
85:     }
86: }
API documentation generated by ApiGen 2.8.0