Example #1
0
 public function actionEdit($id, $day)
 {
     try {
         $this->listing = $this->listingFacade->getListingByID($id);
         $this->date = TimeUtils::getDateTimeFromParameters($this->listing->year, $this->listing->month, $day);
         if ($this->date === false) {
             $this->redirect('Listing:detail', ['id' => $this->listing->listingID]);
         }
         $this->listingItem = $this->itemFacade->getListingItemByDay($day, $this->listing);
     } catch (Runtime\ListingNotFoundException $l) {
         $this->flashMessage('Výčetka nebyla nalezena.', 'error');
         $this->redirect('Listing:overview', ['year' => $this->currentDate->format('Y'), 'month' => $this->currentDate->format('n')]);
     } catch (Runtime\ListingItemNotFoundException $li) {
         $this->listingItem = null;
     }
     if ($this->listingItem instanceof Entities\ListingItem and !$this->listing->isDetached()) {
         $formData['lunch'] = $this->listingItem->workedHours->lunch->toTimeWithComma();
         $formData['workEnd'] = $this->listingItem->workedHours->workEnd->toHoursAndMinutes(true);
         $formData['workStart'] = $this->listingItem->workedHours->workStart->toHoursAndMinutes(true);
         $formData['otherHours'] = $this->listingItem->workedHours->otherHours->toTimeWithComma();
         $formData['locality'] = $this->listingItem->locality->name;
         $formData['description'] = $this->listingItem->description;
         $formData['descOtherHours'] = $this->listingItem->descOtherHours;
         $this['itemForm']->setDefaults($formData);
     }
 }