/**
  * @secured
  */
 public function handleCopyItem($day)
 {
     $this->checkDayValue($day);
     $err = 0;
     try {
         $newListingItem = $this->itemFacade->copyListingItemDown($day, $this->listing);
     } catch (ShiftItemDownException $sd) {
         $this->presenter->flashMessage('Nelze vytvořit kopii poslední položky ve výčetce.', 'error');
         $err++;
     } catch (DBALException $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['itemsTable']->refreshTable([$newListingItem]);
     } else {
         $this->flashMessage('Řádek byl zkopírován.', 'success');
         $this->redirect('this#' . $newListingItem->getDay());
     }
 }
예제 #2
0
 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);
 }
 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();
 }