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