示例#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);
     }
 }
示例#2
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);
 }
 public function actionEdit($id, $day)
 {
     $this->listingResult = $this->getListingByID($id);
     $this->listing = $this->listingResult->getListing();
     $date = TimeUtils::getDateTimeFromParameters($this->listing->year, $this->listing->month, $day);
     if ($date === false) {
         $this->redirect('Listing:detail', ['id' => $this->listing->getId()]);
     }
 }
 protected function createComponentForm()
 {
     $comp = $this->listingFormFactory->create();
     $monthNumber = $this->listing->getMonth();
     $comp['month']->setItems([$monthNumber => TimeUtils::getMonthName($monthNumber)]);
     $comp['year']->setItems([$this->listing->getYear() => $this->listing->getYear()]);
     $comp['save']->caption = 'Vytvořit kopii';
     $comp->onSuccess[] = [$this, 'processForm'];
     return $comp;
 }
示例#5
0
 protected function createComponentForm()
 {
     $form = new Form();
     $form->addSelect('year', '', TimeUtils::generateYearsForSelect());
     $form->addSelect('month', '', TimeUtils::getMonths())->setPrompt('Celý rok');
     $form->addSubmit('filter', 'Zobraz výčetky')->setOmitted();
     $form->getElementPrototype()->id = 'form-filter';
     $form->onSuccess[] = $this->processFilter;
     return $form;
 }
示例#6
0
 public function create()
 {
     $form = new Form();
     $form->addText('description', 'Popis výčetky:', 25, 40);
     $form->addText('hourlyWage', 'Základní mzda:', null, 4)->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Do pole "základní mzda" lze vyplnit pouze kladná celá čísla.', '\\d+');
     $form->addSelect('month', 'Měsíc:', TimeUtils::getMonths());
     $form->addSelect('year', 'Rok:', TimeUtils::generateYearsForSelect());
     $form->addSubmit('save', 'Vytvořit výčetku')->setOmitted();
     $form->addProtection();
     return $form;
 }
示例#7
0
 public function actionSearch($id)
 {
     $this->listing = $this->getEntireListingByID($id);
     $listings = $this->listingFacade->findPartialListingsDataForSelect($this->listing->year, $this->listing->month);
     unset($listings[$this->listing->listingID]);
     if (empty($listings)) {
         $this->flashMessage('Váš účet neobsahuje další výčetky za ' . TimeUtils::getMonthName($this->listing->month) . ' ' . $this->listing->year . ' a proto není možné
             využít Vámi požadovanou funkcionalitu.', 'warning');
         $this->redirect('Listing:detail', ['id' => $this->listing->listingID]);
     }
     $this->listings = $listings;
 }
 public function actionSearch($id)
 {
     $this->listingResult = $this->getListingByID($id);
     $listing = $this->listingResult->getListing();
     $listings = $this->listingsFacade->findListingsToMerge($listing->getUser(), $listing->getYear(), $listing->getMonth());
     unset($listings[$listing->getId()]);
     if (empty($listings)) {
         $this->flashMessage('Váš účet neobsahuje další výčetky za ' . TimeUtils::getMonthName($listing->getMonth()) . ' ' . $listing->getYear() . ' a proto není možné
             využít Vámi požadovanou funkcionalitu.', 'warning');
         $this->redirect('Listing:detail', ['id' => $listing->getId()]);
     }
     $this->listings = $this->prepareListingsForSearchSelect($listings);
 }
 public function processForm(Form $form, $values)
 {
     if ($this->listing === null) {
         $this->listing = new Listing($values['year'], $values['month'], $this->owner);
     }
     $this->listing->description = $values['description'];
     $this->listing->hourlyWage = $values['hourlyWage'];
     $this->listingFacade->saveListing($this->listing);
     $this->presenter->flashMessage('Výčetka pro ' . TimeUtils::getMonthName($values['month']) . ' ' . $values['year'] . ' byla uložena.', 'success');
     if (isset($this->presenter->backlink)) {
         $this->presenter->restoreRequest($this->presenter->backlink);
     }
     $this->presenter->redirect('Listing:overview', array('month' => $values['month'], 'year' => $values['year']));
 }
示例#10
0
 /**
  * @return string
  */
 public function entireDescription()
 {
     $desc = TimeUtils::getMonthName($this->month) . ' ' . $this->year;
     if (isset($this->description)) {
         $desc .= ' - ' . $this->description;
     }
     /* else {
            $desc .= ' - Bez popisu';
        }*/
     return $desc;
 }
示例#11
0
 public function monthNameByNumber($number)
 {
     return TimeUtils::getMonthName($number);
 }
 public function getPdfTitle()
 {
     // {listingId}i-{monthName}-{year}[-{description}]
     $description = $this->listingPdfDataAdapter->getListingDescription() != '' ? '-' . Strings::webalize($this->listingPdfDataAdapter->getListingDescription()) : null;
     return Strings::webalize($this->listingPdfDataAdapter->getListingId() . 'i-' . TimeUtils::getMonthName($this->listingPdfDataAdapter->getListingMonth()) . '-' . $this->listingPdfDataAdapter->getListingYear()) . $description;
 }
 public function getNotificationMessage(Listing $newListing, User $sender)
 {
     $period = TimeUtils::getMonthName($newListing->month) . ' ' . $newListing->year;
     $m = new SentMessage($this->constructSubject($sender->username, $period), $this->constructMessage($sender->username, $newListing->getUser()->username, $period, $this->linkGenerator->link('Front:Listing:detail', ['id' => $newListing->getId()])), $sender);
     return $m;
 }
 /**
  * @param Listing $listing
  * @param int $day
  * @return bool|\DateTime
  */
 private function prepareDateTime(Listing $listing, $day)
 {
     return TimeUtils::getDateTimeFromParameters($listing->year, $listing->month, $day);
 }
示例#15
0
 public function actionCopy($id)
 {
     $this->listing = $this->getListingByID($id);
     $this['simpleCopyForm']['month']->setDefaultValue(TimeUtils::getMonthName($this->listing->month));
     $this['simpleCopyForm']['year']->setDefaultValue($this->listing->year);
     $this['simpleCopyForm']['description']->setDefaultValue($this->listing->description == null ? 'Popis nebyl zadán' : $this->listing->description);
 }
示例#16
0
 /**
  * @param ListingItemDecorator[] $listingItemsDecorators
  * @param \DateTime $period
  * @return array
  */
 public function generateListingItemDecoratorsForEntireTable(array $listingItemsDecorators, \DateTime $period)
 {
     $year = $period->format('Y');
     $month = $period->format('n');
     $daysInMonth = TimeUtils::getNumberOfDaysInMonth($year, $month);
     $list = [];
     for ($day = 1; $day <= $daysInMonth; $day++) {
         if (array_key_exists($day, $listingItemsDecorators)) {
             if (!$listingItemsDecorators[$day] instanceof IDisplayableItem) {
                 throw new InvalidArgumentException('Only instances of ' . ListingItemDecorator::class . ' can pass.');
             }
             $list[$day] = $listingItemsDecorators[$day];
         } else {
             $list[$day] = new FillingItem(TimeUtils::getDateTimeFromParameters($year, $month, $day));
         }
     }
     return $list;
 }
 public function getNotificationMessage(Listing $listing, $senderName, $recipientName)
 {
     $period = TimeUtils::getMonthName($listing->month) . ' ' . $listing->year;
     $m = new Message($this->constructSubject($senderName, $period), $this->constructMessage($senderName, $recipientName, $period, $this->linkGenerator->link('Front:Listing:detail', ['id' => $listing->listingID])), 0);
     return $m;
 }
示例#18
0
 public function getDate()
 {
     if ($this->date === null) {
         $this->date = TimeUtils::getDateTimeFromParameters($this->listing->year, $this->listing->month, $this->day);
     }
     return $this->date;
 }