Example #1
0
 /**
  * @secured
  */
 public function handleRemoveItem($day)
 {
     $noDays = $this->listing->getNumberOfDaysInMonth();
     if (!is_numeric($day) or !($day >= 1 and $day <= $noDays)) {
         $this->redirect('this');
     }
     try {
         $this->itemFacade->removeListingItem($day, $this->listing);
         if ($this->presenter->isAjax()) {
             $this->listing = $this->listingFacade->getEntireListingByID($this->listing->listingID);
             $item = new FillingItem(DateTime::createFromFormat('d.m.Y', $day . '.' . $this->listing->month . '.' . $this->listing->year));
             $this->itemsCollection = [$item];
             $this['itemsTable']->redrawControl();
         } else {
             $this->flashMessage('Řádek byl vymazán.', 'success');
             $this->redirect('this');
         }
     } catch (ListingNotFoundException $lnf) {
         $this->flashMessage('Výčetka, kterou se snažíte upravit, nebyla nalezena.');
         $this->redirect('Listing:overview');
     }
 }