Esempio n. 1
0
 public function __invoke(array $reservations, array $cellLinkParams, Square $square)
 {
     $view = $this->getView();
     $reservationsCount = count($reservations);
     if ($reservationsCount > 1) {
         return $view->calendarCellLink('Occupied', $view->url('square', [], $cellLinkParams), 'cc-single');
     } else {
         $reservation = current($reservations);
         $booking = $reservation->needExtra('booking');
         if ($square->getMeta('public_names', 'false') == 'true') {
             $cellLabel = $booking->needExtra('user')->need('alias');
         } else {
             $cellLabel = null;
         }
         $cellGroup = ' cc-group-' . $booking->need('bid');
         switch ($booking->need('status')) {
             case 'single':
                 if (!$cellLabel) {
                     $cellLabel = 'Occupied';
                 }
                 return $view->calendarCellLink($cellLabel, $view->url('square', [], $cellLinkParams), 'cc-single' . $cellGroup);
             case 'subscription':
                 if (!$cellLabel) {
                     $cellLabel = 'Subscription';
                 }
                 return $view->calendarCellLink($cellLabel, $view->url('square', [], $cellLinkParams), 'cc-multiple' . $cellGroup);
         }
     }
 }
Esempio n. 2
0
 public function __invoke(array $reservations, array $cellLinkParams, Square $square)
 {
     $view = $this->getView();
     $reservationsCount = count($reservations);
     if ($reservationsCount == 0) {
         $labelFree = $square->getMeta('label.free', 'Free');
         return $view->calendarCellLink($labelFree, $view->url('backend/booking/edit', [], $cellLinkParams), 'cc-free');
     } else {
         if ($reservationsCount == 1) {
             $reservation = current($reservations);
             $booking = $reservation->needExtra('booking');
             $cellLabel = $booking->needExtra('user')->need('alias');
             $cellGroup = ' cc-group-' . $booking->need('bid');
             return $view->calendarCellLink($cellLabel, $view->url('backend/booking/edit', [], $cellLinkParams), 'cc-free cc-free-partially' . $cellGroup);
         } else {
             $labelFree = $square->getMeta('label.free', 'Still free');
             return $view->calendarCellLink($labelFree, $view->url('backend/booking/edit', [], $cellLinkParams), 'cc-free cc-free-partially');
         }
     }
 }
Esempio n. 3
0
 public function __invoke(Square $square, $quantity, $wrap = 'p')
 {
     $squareCapacity = $square->need('capacity');
     $squareCapacityInfo = $square->getMeta('info.capacity');
     if (!$squareCapacityInfo) {
         if ($squareCapacity == 1) {
             $squareCapacityInfo = 'false';
         } else {
             $squareCapacityInfo = 'true';
         }
     }
     if ($squareCapacityInfo == 'true') {
         if ($quantity > 0) {
             return sprintf('<%s><span class="yellow">' . $this->getView()->t('%s/%s already occupied') . '</span></%s>', $wrap, $quantity, $squareCapacity, $wrap);
         }
     }
     return null;
 }
Esempio n. 4
0
 public function __invoke($user, $userBooking, array $reservations, array $cellLinkParams, Square $square)
 {
     $view = $this->getView();
     $labelFree = $square->getMeta('label.free', 'Free');
     if ($user && $user->can('calendar.see-data, calendar.create-single-bookings, calendar.create-subscription-bookings')) {
         return $view->calendarCellRenderFreeForPrivileged($reservations, $cellLinkParams, $square);
     } else {
         if ($user) {
             if ($userBooking) {
                 $cellLabel = $view->t('Your Booking');
                 $cellGroup = ' cc-group-' . $userBooking->need('bid');
                 return $view->calendarCellLink($cellLabel, $view->url('square', [], $cellLinkParams), 'cc-own' . $cellGroup);
             } else {
                 return $view->calendarCellLink($labelFree, $view->url('square', [], $cellLinkParams), 'cc-free');
             }
         } else {
             return $view->calendarCellLink($labelFree, $view->url('square', [], $cellLinkParams), 'cc-free');
         }
     }
 }