Example #1
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);
     }
 }