Example #1
0
 public function renderEdit($id, $day)
 {
     $this->template->_form = $this['itemForm'];
     $workedHours = null;
     if ($this->listingItem instanceof Entities\ListingItem and !$this->listing->isDetached()) {
         $workedHours = $this->listingItem->workedHours->getHours();
     }
     $this->template->itemDate = $this->date;
     $this->template->listing = $this->listing;
     $this->template->workedHours = $workedHours;
     $this->template->defaultWorkedHours = $this->itemUpdateFormFactory->getDefaultTimeValue('workedHours');
 }
Example #2
0
 /**
  * @param Entities\ListingItem[] $listingItems
  * @param Entities\Listing $listing
  * @return array
  */
 public function setListingForGivenItems(array $listingItems, Entities\Listing $listing)
 {
     if ($listing->isDetached()) {
         throw new InvalidArgumentException('Only attached(not detached) ' . Entities\Listing::class . ' entity can pass!');
     }
     $newItemsCollection = [];
     foreach ($listingItems as $listingItem) {
         if (!$listingItem instanceof Entities\ListingItem) {
             throw new InvalidArgumentException('Only instances of ' . Entities\ListingItem::class . ' can pass.');
         }
         $listingItem->setListing($listing);
         $newItemsCollection[] = $listingItem;
     }
     return $newItemsCollection;
 }
Example #3
0
 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();
 }
Example #4
0
 /**
  * @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);
     }
 }
Example #5
0
 /**
  * @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');
 }
Example #6
0
 /**
  * @param Listing $listing
  * @return ListingItemDecorator[]
  */
 public function generateEntireTable(Listing $listing)
 {
     $listing->checkEntityState();
     $collectionOfDecorators = $this->createListingItemDecoratorsCollection($listing->listingItems);
     return $this->itemService->generateListingItemDecoratorsForEntireTable($collectionOfDecorators, $listing->getPeriod());
 }
Example #7
0
 /**
  * @param Listing $listing
  * @throws InvalidArgumentException
  */
 private function checkListingValidity(Listing $listing)
 {
     if ($listing->isDetached()) {
         throw new InvalidArgumentException('Argument $listing must be attached instance of ' . Listing::class);
     }
 }