private function getListingByID($listingID) { try { return $this->listingFacade->getListingByID($listingID); } catch (ListingNotFoundException $e) { $this->flashMessage('Výčetka nebyla nalezena.', 'error'); $this->redirect('Listing:overview'); } }
public function processListingSharing(Form $form, $values) { $ignoredItems = $form->getHttpData(Form::DATA_TEXT, 'items[]'); try { $this->newListings = $this->listingFacade->shareListing($this->listing, $values['description'], $values['recipients'], $ignoredItems); } catch (\DibiException $e) { $this->presenter->flashMessage('Nastala chyba při pokusu o sdílení výčetky. Zkuste akci opakovat později.', 'error'); $this->redirect('this'); } $this->presenter->flashMessage('Výčetka byla úspěšně sdílena.', 'success'); }
public function processForm(Form $form, $values) { if ($this->listing === null) { $this->listing = new Listing($values['year'], $values['month'], $this->user->id); } $this->listing->description = $values['description']; $this->listing->hourlyWage = $values['hourlyWage']; $this->listingFacade->saveListing($this->listing); $this->presenter->flashMessage('Výčetka pro ' . TimeUtils::getMonthName($values['month']) . ' ' . $values['year'] . ' byla uložena.', 'success'); if (isset($this->presenter->backlink)) { $this->presenter->restoreRequest($this->presenter->backlink); } $this->presenter->redirect('Listing:overview', array('month' => $values['month'], 'year' => $values['year'])); }
public function processMassItemsChange(Form $form, $values) { $selectedItems = $form->getHttpData(Form::DATA_TEXT, 'items[]'); if (empty($selectedItems)) { $this->flashMessage('Označte řádky, které chcete změnit.', 'warning'); if ($this->presenter->isAjax()) { $this->redrawControl('flashMessage'); return; } else { $this->redirect('this'); } } try { $workedHours = new WorkedHours($values['workStart'], $values['workEnd'], $values['lunch'], $values['otherHours']); $data = $this->listingFacade->changeItemsInListing($this->listing, $workedHours, $values['newListing'], $selectedItems); } catch (ShiftEndBeforeStartException $s) { $form->addError('Nelze skončit směnu dříve, než začala. Zkontrolujte hodnoty v polích Začátek a Konec'); return; } catch (NegativeResultOfTimeCalcException $e) { $form->addError('Položku nelze uložit. Musíte mít odpracováno více hodin, než kolik strávíte obědem.'); return; } if ($values['newListing'] === true) { $this->presenter->redirect('Listing:detail', ['id' => $data['listing']->listingID]); } else { if ($this->presenter->isAjax()) { $this->listing = $this->listingFacade->getEntireListingByID($this->listing->listingID); $this->itemsCollection = $data['changedItems']; $this->flashMessage('Hodnoty byly úspěšně hromadně změneny.', 'success'); $this->redrawControl('flashMessage'); $this->redrawControl('formErrors'); $this['itemsTable']->redrawControl(); } else { $this->redirect('this'); } } }
/** * @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); } }