protected function createComponentItemsTable() { $comp = $this->itemsTableControlFactory->create($this->listingResult); $comp->showTableCaption('Front:Listing:detail', ['id' => $this->listing->getId()]); $comp->showCheckBoxes(); return $comp; }
public function actionEdit($id, $day) { $this->listingResult = $this->getListingByID($id); $this->listing = $this->listingResult->getListing(); $date = TimeUtils::getDateTimeFromParameters($this->listing->year, $this->listing->month, $day); if ($date === false) { $this->redirect('Listing:detail', ['id' => $this->listing->getId()]); } }
protected function createComponentForm() { $comp = $this->listingFormFactory->create(); $monthNumber = $this->listing->getMonth(); $comp['month']->setItems([$monthNumber => TimeUtils::getMonthName($monthNumber)]); $comp['year']->setItems([$this->listing->getYear() => $this->listing->getYear()]); $comp['save']->caption = 'Vytvořit kopii'; $comp->onSuccess[] = [$this, 'processForm']; return $comp; }
private function handleInvalidation(Listing $listing) { $cache = $this->cacheFactory->getCache($listing->user->id, $listing->year); // removal of all generated pdf files of given Listing $generatedFiles = $cache->load('generatedPdfFilesByListing/' . $listing->getId()); if ($generatedFiles !== null) { foreach ($generatedFiles as $key => $filePath) { if (!is_dir($filePath) and file_exists($filePath)) { FileSystem::delete($filePath); } } } $cache->clean([Cache::TAGS => 'listing/' . $listing->id]); }
public function processSaveItem(Form $form, $values) { $values['day'] = $this->day; $values['listing'] = $this->listing; $values['user'] = $this->listing->getUser(); $this->listingItem = $this->itemsFacade->getByDay($this->day, $this->listing); try { $this->listingItem = $this->itemsFacade->saveListingItem((array) $values, $this->listingItem); } catch (OtherHoursZeroTimeException $zt) { $form->addError(ItemUpdateFormFactory::OTHER_HOURS_ZERO_TIME_ERROR_MSG); return; } catch (NegativeResultOfTimeCalcException $b) { $form->addError('Položku nelze uložit. Musíte mít odpracováno více hodin, než kolik strávíte obědem.'); return; } catch (ShiftEndBeforeStartException $c) { $form->addError('Nelze skončit směnu dřív než začne. Zkontrolujte si začátek a konec směny.'); return; } catch (ListingItemDayAlreadyExistsException $d) { $form->addError('Položku nelze uložit, protože výčetka již obsahuje záznam z tohoto dne.'); return; } catch (\Exception $e) { $form->addError('Položka nebyla uložena. Zkuste akci opakovat později.'); return; } $this->onSuccessItemPersist($this->listingItem); }
/** * @secured */ public function handleRemoveItem($day) { $this->checkDayValue($day); try { $this->itemFacade->removeListingItem($day, $this->listing); if ($this->presenter->isAjax()) { $item = new FillingItem(DateTime::createFromFormat('d.m.Y', $day . '.' . $this->listing->getMonth() . '.' . $this->listing->getYear())); $this['itemsTable']->refreshTable([$item]); } else { $this->flashMessage('Řádek byl vymazán.', 'success'); $this->redirect('this'); } } catch (ListingNotFoundException $lnf) { $this->flashMessage('Výčetka, kterou se snažíte upravit, nebyla nalezena.'); $this->redirect('Listing:overview'); } }
public function render() { $template = $this->getTemplate(); $template->setFile(__DIR__ . '/templates/table.latte'); if (!$this->presenter->isAjax()) { $this->items = $this->itemFacade->generateEntireTable($this->listing); } else { $this->items = $this->itemFacade->prepareDisplayableItemsCollection($this->items); } $template->itemsCollection = $this->items; $template->workedDays = $this->workedDays; $template->totalWorkedHours = $this->totalWorkedHours; $template->isTableCaptionVisible = $this->isTableCaptionVisible; $template->showCheckBoxes = $this->showCheckBoxes; $template->showActions = $this->showActions; $template->parameters = $this->parameters; $template->listing = $this->listing; $template->numberOfDaysInMonth = $this->listing->getNumberOfDaysInMonth(); $template->render(); }
protected function createComponentListingDescription() { $comp = $this->listingDescriptionControlFactory->create($this->listing); $comp->setAsClickable('Front:Listing:detail', ['id' => $this->listing->getId()]); return $comp; }
public function getNotificationMessage(Listing $newListing, User $sender) { $period = TimeUtils::getMonthName($newListing->month) . ' ' . $newListing->year; $m = new SentMessage($this->constructSubject($sender->username, $period), $this->constructMessage($sender->username, $newListing->getUser()->username, $period, $this->linkGenerator->link('Front:Listing:detail', ['id' => $newListing->getId()])), $sender); return $m; }
public function onListingCopySuccess(Listing $listing) { $this->flashMessage('Byla založena kopie výčetky.', 'success'); $this->redirect('Listing:overview', array('year' => $listing->getYear(), 'month' => $listing->getMonth())); }
public function processCancel() { $this->onCancelClick($this->listing->getYear(), $this->listing->getMonth()); }
/** * @return int */ public function getListingId() { return $this->listing->getId(); }
/** * @param Listing $listing */ public function setListing(Listing $listing) { $listingDaysInMonth = $listing->getNumberOfDaysInMonth(); if (isset($this->day) and $this->day > $listingDaysInMonth) { throw new InvalidArgumentException('Day of ListingItem exceed last day in Listing period.'); } $this->listing = $listing; }
/** * @param Listing $listing * @param User $recipient * @param $description * @param array $ignoredListingDays * @return Listing * @throws \Exception */ public function shareListing(Listing $listing, User $recipient, $description, array $ignoredListingDays = []) { Validators::assert($description, 'unicode'); try { $this->em->beginTransaction(); /** @var ListingItem[] $listingItems */ $listingItems = $this->listingItemsReader->findListingItems($listing->getId(), $ignoredListingDays, true); $newListing = clone $listing; $newListing->setUser($recipient); $newListing->setDescription($description); $newListing->setHourlyWage(null); $this->em->persist($newListing); foreach ($listingItems as $item) { $newItem = clone $item; $newItem->setListing($newListing); $newItem->setDescription(null); $newItem->removeDescOtherHours(); $this->em->persist($newItem); } $this->em->flush(); $this->em->commit(); return $newListing; } catch (\Exception $e) { $this->em->rollback(); $this->em->close(); $this->onError('shareListing', $e, self::class); throw $e; } }