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->createListingItemDecoratorsCollection($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(); }
/** * @param int $day Numeric representation of the day of the month * @secured */ public function handleCopyItem($day) { $noDays = $this->listing->getNumberOfDaysInMonth(); if (!is_numeric($day) or !($day >= 1 and $day <= $noDays)) { $this->redirect('this'); } $err = 0; try { $newListingItem = $this->itemFacade->shiftCopyOfListingItemDown($day, $this->listing); } catch (ListingItemNotFoundException $is) { $this->presenter->flashMessage('Řádek výčetky nemohl být zkopírován, protože nebyl nalezen.', 'error'); $err++; } catch (DayExceedCurrentMonthException $is) { $this->presenter->flashMessage('Nelze vytvořit kopii poslední položky ve výčetce.', 'error'); $err++; } catch (\DibiException $e) { $this->presenter->flashMessage('Kopie položky nemohla být založena. Zkuste akci opakovat později.', 'error'); $err++; } if ($err !== 0) { if ($this->presenter->isAjax()) { $this->presenter->redrawControl('flashMessages'); } else { $this->redirect('this'); } } if ($this->presenter->isAjax()) { $this->listing = $this->listingFacade->getEntireListingByID($this->listing->listingID); $this->itemsCollection = [$newListingItem]; $this['itemsTable']->redrawControl(); } else { $this->flashMessage('Řádek byl zkopírován.', 'success'); $this->redirect('this#' . $newListingItem->listingItemID); } }
/** * @param Listing $listing */ public function setListing(Listing $listing) { $listing->checkEntityState(); $listingDaysInMonth = $listing->getNumberOfDaysInMonth(); if (isset($this->day) and $this->day > $listingDaysInMonth) { throw new InvalidArgumentException('Day of ListingItem exceed last day in Listing period.'); } $this->assignEntityToProperty($listing, 'listing'); }
/** * @param int $day * @param Listing $listing * @return mixed * @throws \DibiException * @throws DayExceedCurrentMonthException * @throws ListingItemNotFoundException */ public function shiftCopyOfListingItemDown($day, Listing $listing) { // we do NOT want to shift the last item if ($day >= $listing->getNumberOfDaysInMonth()) { throw new DayExceedCurrentMonthException(); } return $this->listingItemRepository->shiftCopyOfListingItemDown($day, $listing->listingID); }