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 UnitPresenter extends BasePresenter {
  5:     /** @var UnitRepository @inject */
  6:     public $unitRepository;
  7: 
  8:     /** @var DocumentRepository @inject */
  9:     public $documentRepository;
 10: 
 11:     /** @var ScheduledTaskRepository @inject */
 12:     public $scheduledTaskRepository;
 13: 
 14:     /** @var BreakdownRepository @inject */
 15:     public $breakdownRepository;
 16: 
 17:     /** @var PeriodicTaskRepository @inject */
 18:     public $periodicTaskRepository;
 19: 
 20:     /** @var UnitFactory @inject */
 21:     public $unitFactory;
 22: 
 23:     /** @var DocumentFactory @inject */
 24:     public $documentFactory;
 25: 
 26:     /** @var \Nette\Http\IRequest @inject */
 27:     public $httpRequest;
 28: 
 29:     function renderEdit($id) {
 30:         $assigned = array();
 31: 
 32:         foreach ($this->unitRepository->getAssignedDocuments($id) as $row) {
 33:             $assigned[] = $row->id;
 34:         }
 35: 
 36:         $this->template->assigned = $assigned;
 37:         $this->template->data = $this->documentRepository->getDocuments();
 38:     }
 39: 
 40:     public function renderPreview($id) {
 41:         $item = $this->unitRepository->findById($id);
 42: 
 43:         if ($item === false) {
 44:             $this->redirect('default');
 45:         }
 46: 
 47:         $this->template->periodicTaskRepository = $this->periodicTaskRepository;
 48:         $this->template->documentRepository = $this->documentRepository;
 49:         $this->template->scheduledtasks = $this->scheduledTaskRepository->findBy(array('id_unit' => $item->id));
 50:         $this->template->periodictasks = $this->periodicTaskRepository->findBy(array('id_unit' => $item->id));
 51:         $this->template->breakdowns = $this->breakdownRepository->findBy(array('id_unit' => $item->id));
 52:         $this->template->documents = $this->unitRepository->getAssignedDocuments($item->id);
 53:         $this->template->data = $item;
 54:     }
 55: 
 56:     protected function createComponentGrid() {
 57:         $session = $this->getSession()->getSection('history');
 58:         $session->secunit = (string)$this->getHttpRequest()->getUrl();
 59: 
 60:         return $this->unitFactory->createDataGrid();
 61:     }
 62: 
 63:     protected function createComponentDocumentsGrid() {
 64:         return $this->documentFactory->createDocumentsDataGrid();
 65:     }
 66: 
 67:     public function actionEdit($id) {
 68:         $item = $this->unitRepository->findById($id);
 69: 
 70:         if ($id > 0 && $item === false) {
 71:             $this->redirect('default');
 72:         }
 73: 
 74:         if ($id > 0) {
 75:             $this['editForm']['base']->setDefaults($item);
 76:         }
 77: 
 78:         $this->template->id = $id;
 79:     }
 80: 
 81:     protected function createComponentEditForm() {
 82:         $session = $this->getSession()->getSection('history');
 83: 
 84:         if (isset($session->secunit)) {
 85:             $backlink = $session->secunit;
 86:         } else {
 87:             $backlink = $this->link('default');
 88:         }
 89: 
 90:         $form = $this->unitFactory->createEditForm($backlink);
 91:         $form->onSuccess[] = $this->editFormSubmitted;
 92: 
 93:         return $form;
 94:     }
 95: 
 96:     public function actionDocuments($id)    {
 97:         $item = $this->unitRepository->findById($id);
 98: 
 99:         if ($item === false) {
100:             $this->redirect('default');
101:         }
102: 
103:         $assigned = array();
104: 
105:         foreach ($this->unitRepository->getAssignedDocuments($item->id) as $row) {
106:             $assigned[] = $row->id;
107:         }
108: 
109:         $this['documentsGrid']->setId($item->id);
110:         $this['documentsGrid']->setAssigned($assigned);
111: 
112:         $session = $this->getSession()->getSection('history');
113: 
114:         if (isset($session->secunit)) {
115:             $this->template->backlink = $session->secunit;
116:         } else {
117:             $this->template->backlink = $this->link('default');
118:         }
119: 
120:         $this->template->id = $item->id;
121:         $this->template->name = $item->name;
122:     }
123: 
124:     public function editFormSubmitted($form) {
125:         $fdata = $form['base']->getValues();
126: 
127:         $id = $this->getParameter('id');
128: 
129:         if ($id > 0) {
130:             $this->unitRepository->updateById($id, $fdata);
131: 
132:             $this->flashMessage("Záznam byl upraven.", "success");
133:         } else {
134:             $data = $this->unitRepository->insertData($fdata);
135: 
136:             $id = $data->id;
137: 
138:             $this->flashMessage("Záznam byl vložen.", "success");
139:         }
140: 
141:         /*
142:          * Zpracovani dokumentu
143:          */
144:         $filedatas = $form['document']->getValues();
145: 
146:         foreach ($filedatas->files as $file) {
147:             if ($file->isOk()) {
148:                 $data = new \Nette\ArrayHash;
149:                 $data->name = $file->getName();
150:                 $data->filename = $file->getName();
151:                 $data->id_documenttype = $filedatas->id_documenttype;
152:                 $data->mime = $file->getContentType();
153:                 $data->data = $file->getContents();
154:                 $data->lastmod = date('Y-m-d H:i:s');
155: 
156:                 $document = $this->documentRepository->insertData($data);
157: 
158:                 $this->unitRepository->assignDocument($id, $document->id);
159:             }
160:         }
161: 
162:         $session = $this->getSession()->getSection('history');
163: 
164:         if (isset($session->secunit)) {
165:             $backlink = $session->secunit;
166:         } else {
167:             $backlink = $this->link('default');
168:         }
169: 
170:         $this->redirectUrl($backlink);
171:     }
172: 
173:     public function handleDelete($id) {
174:         try {
175:             $this->unitRepository->deleteById($id);
176:             $this->flashMessage("Záznam byl smazán.", "success");
177:         } catch (\PDOException $e) {
178:             $this->flashMessage("Záznam nelze smazat!", "error");
179:         }
180: 
181:         $this->redirect('this');
182:     }
183: 
184:     public function handleAssign($id, $document) {
185:         $this->unitRepository->assignDocument($id, $document);
186: 
187:         $this->redirect('this');
188:     }
189: 
190:     public function handleUnassign($id, $document) {
191:         $this->unitRepository->removeAssignedDocument($id, $document);
192: 
193:         $this->redirect('this');
194:     }
195: }
API documentation generated by ApiGen 2.8.0