/**
  * @param mixed $value  array with keys issueStartDay and issueEndDay
  */
 public function isValid($value)
 {
     $valid = true;
     if (!$this->checkDate($value['issueStartDay'])) {
         $valid = false;
         $this->addError('Sie müssen ein gültiges Anfangsdatum eingeben', 1416308406);
     }
     if (!$this->checkDate($value['issueEndDay'])) {
         $valid = false;
         $this->addError('Sie müssen ein gültiges Endedatum eingeben', 1416308476);
     }
     if ($valid) {
         //start day not in past
         if ($this->dayNotInPast($value['issueStartDay'])) {
             if (!$this->startBeforeEnd($value['issueStartDay'], $value['issueEndDay'])) {
                 $valid = false;
                 $this->addError('Das Endedatum muss größer als das Startdatum sein.', 1416309162);
             }
         } else {
             $valid = false;
             $this->addError('Das Startdatum muss mindestens einen Tag in der Zukunft sein.', 1416309162);
         }
     }
     $period = array($this->toUnixTimestamp($value['issueStartDay']), $this->toUnixTimestamp($value['issueEndDay']));
     $result = $this->reservationRepository->checkPeriodForArticle($this->article, $period);
     if ($result->count() > 0) {
         $valid = false;
         $this->addError('Es liegt bereits eine Reservierung in dem Zeitraum vor.', 1416316079);
     }
     return $valid;
 }
예제 #2
0
 /**
  * @param $params array
  */
 public function labelForReservation(&$params)
 {
     $row = $params['row'];
     /* in der Row ist die UId, pid, date_from und die standardfelder starttime, endtime, t3ver, ... */
     /* @var $reservation \Bjr\BjrLend\Domain\Model\Reservation */
     $reservation = $this->reservationRepository->findByUid($row['uid']);
     $params['title'] = date('d.m.y', $reservation->getIssueStart()) . ' - ' . date('d.m.y', $reservation->getIssueEnd());
     if (strlen($params['title']) == 3) {
         $params['title'] = 'kein Datum vorhanden';
     }
 }
 /**
  * @param \Bjr\BjrLend\Domain\Model\Article $article
  * @return array
  */
 private function findReservedDates(\Bjr\BjrLend\Domain\Model\Article $article)
 {
     $reservations = $this->reservationRepository->findByArticle($article);
     $reservedDates = array();
     /* @var $reservation \Bjr\BjrLend\Domain\Model\Reservation */
     foreach ($reservations as $reservation) {
         $list = $reservation->listIssueDays();
         foreach ($list as $dateTime) {
             $month = date('n', $dateTime);
             $day = date('j', $dateTime);
             $year = date('Y', $dateTime);
             $reservedDates[] = array('month' => $month, 'day' => $day, 'year' => $year);
         }
     }
     return array($reservations, $reservedDates);
 }