public function render()
 {
     $template = $this->getTemplate();
     $template->setFile(__DIR__ . '/template.latte');
     $template->listing = $this->listing;
     $template->workedDays = $this->listingResult->getWorkedDays();
     $template->render();
 }
 public function generatePdf(SubmitButton $button)
 {
     $values = $button->getForm()->getValues(true);
     $items = $this->listingItemsReader->findListingsItems([$this->listingResult->getListingId()]);
     $listing = $this->listingResult->getListing();
     $listingData = ['l_id' => $listing->id, 'l_year' => $listing->year, 'l_month' => $listing->month, 'l_description' => $listing->description, 'l_hourlyWage' => $listing->hourlyWage, 'u_id' => $listing->user->id, 'u_name' => $listing->user->name, 'worked_days' => $this->listingResult->getWorkedDays(), 'worked_hours' => $this->listingResult->getWorkedHours(), 'total_worked_hours_in_sec' => $this->listingResult->getTotalWorkedHours()->toSeconds(), 'lunch_hours' => $this->listingResult->getLunchHours(), 'other_hours' => $this->listingResult->getOtherHours()];
     /** @var IListingPdfFile $pdf */
     $pdf = $this->listingPDFGenerator->generate($listingData, $items, $values);
     $response = new Nette\Application\Responses\FileResponse($pdf->getStoragePath(), $pdf->getFileName());
     $this->presenter->sendResponse($response);
 }
 public function processListingSharing(Form $form, $values)
 {
     $ignoredDays = $form->getHttpData(Form::DATA_TEXT, 'items[]');
     if (count($ignoredDays) == $this->listingResult->getWorkedDays()) {
         $form->addError('Nelze odeslat prázdnou výčetku!
              Nezapomeňte, zaškrtnutím se řádek výčetky nebude sdílet.');
         return;
     }
     try {
         $resultObject = $this->listingFacade->shareListing($this->listing, $values['recipient'], $values['description'], $ignoredDays);
         $this->presenter->flashMessage('Výčetka byla úspěšně sdílena.', 'success');
         if (!$resultObject->hasNoErrors()) {
             $err = $resultObject->getFirstError();
             $this->flashMessage($err['message'], $err['type']);
         }
     } catch (RecipientsNotFoundException $rnf) {
         $form->addError('Nelze zaslat výčetku vybranému uživateli.');
         return;
     } catch (DBALException $e) {
         $form->addError('Nastala chyba při pokusu o sdílení výčetky.
              Zkuste akci opakovat později.');
     }
     $this->redirect('this');
 }