Esempio n. 1
0
 public function __construct(ListingItem $listingItem)
 {
     $listingItem->checkEntityState();
     $this->listingItem = $listingItem;
     $year = $listingItem->listing->year;
     $month = $listingItem->listing->month;
     $this->date = TimeUtils::getDateTimeFromParameters($year, $month, $listingItem->day);
 }
Esempio n. 2
0
 public function processSaveItem(Form $form, $values)
 {
     try {
         $workedHours = new Entities\WorkedHours($values['workStart'], $values['workEnd'], $values['lunch'], $values['otherHours']);
         $this->itemFacade->setupWorkedHoursEntity($workedHours);
         $locality = new Entities\Locality($values['locality']);
         $this->itemFacade->setupLocalityEntity($locality);
         if (is_null($this->listingItem)) {
             $this->listingItem = new Entities\ListingItem($this->date->format('j'), $this->listing, $workedHours, $locality, $values['description'], $values['descOtherHours']);
         } else {
             $this->listingItem->setWorkedTime($workedHours, $values['descOtherHours']);
             $this->listingItem->setLocality($locality);
         }
         $this->listingItem->description = $values['description'];
         $listingItem = $this->itemFacade->saveListingItem($this->listingItem);
     } catch (Runtime\OtherHoursZeroTimeException $zt) {
         $form->addError(ItemUpdateFormFactory::OTHER_HOURS_ZERO_TIME_ERROR_MSG);
         return;
     } catch (Runtime\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 (Runtime\ShiftEndBeforeStartException $c) {
         $form->addError('Nelze skončit směnu dřív než začne. Zkontrolujte si začátek
              a konec směny.');
         return;
     } catch (Runtime\ListingItemDayAlreadyExistsException $d) {
         $form->addError('Položku nelze uložit, protože výčetka již obsahuje záznam
              z tohoto dne.');
         return;
     } catch (\DibiException $e) {
         $form->addError('Položka nebyla uložena. Zkuste akci opakovat později.');
         return;
     }
     $this->flashMessage('Položka byla uložena.', 'success');
     $this->redirect('Listing:detail#' . $listingItem->listingItemID, ['id' => $this->listing->listingID]);
 }