public function render()
 {
     $template = $this->getTemplate();
     $template->setFile(__DIR__ . '/template.latte');
     $template->listing = $this->listing;
     $template->workedDays = $this->listingResult->getWorkedDays();
     $template->render();
 }
 public function __construct(ListingResult $listingResult, IItemsTableControlFactory $itemsTableControlFactory, ListingsFacade $listingFacade, ItemsFacade $itemFacade)
 {
     $this->listingResult = $listingResult;
     $this->listing = $listingResult->getListing();
     $this->itemsTableControlFactory = $itemsTableControlFactory;
     $this->listingFacade = $listingFacade;
     $this->itemFacade = $itemFacade;
 }
 public function __construct(ListingResult $listingResult, IListingDescriptionControlFactory $listingDescriptionControlFactory, IItemsTableControlFactory $itemsTableControlFactory, ItemUpdateFormFactory $itemUpdateFormFactory, ListingsFacade $listingsFacade)
 {
     $this->listingResult = $listingResult;
     $this->listing = $listingResult->getListing();
     $this->listingDescriptionControlFactory = $listingDescriptionControlFactory;
     $this->itemsTableControlFactory = $itemsTableControlFactory;
     $this->itemUpdateFormFactory = $itemUpdateFormFactory;
     $this->listingsFacade = $listingsFacade;
 }
 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 processMergeListings(Form $form, $values)
 {
     $selectedCollisionItems = $form->getHttpData(Form::DATA_TEXT, 'itm[]');
     try {
         $listing = $this->listingsFacade->mergeListings($this->listingResult->getListing(), $this->listingToMergeResult->getListing(), $selectedCollisionItems, $this->listingResult->getListing()->getUser());
         $this->flashMessage('Výčetky byli úspěšně spojeny.', 'success');
         $this->redirect('Listing:overview', ['year' => $listing->year, 'month' => $listing->month]);
     } catch (NoCollisionListingItemSelectedException $ncis) {
         $form->addError('Ve výčetce se stále nachází kolizní řádek/řádky.');
         return;
     } catch (DBALException $e) {
         $this->flashMessage('Při spojování výčetek došlo k chybě. Zkuste akci opakovat později.', 'error');
         $this->redirect('Listing:detail', ['id' => $this->listingResult->getListingId()]);
     }
 }
 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');
 }
Beispiel #7
0
 protected function createComponentListingDescription()
 {
     $desc = $this->listingDescriptionFactory->create($this->listingResult->getListing());
     $desc->setAsClickable('Front:Listing:detail', ['id' => $this->listingResult->getListingId()]);
     return $desc;
 }