예제 #1
0
 public function cardsAction()
 {
     /**
      * @var Request $request
      * @var \DDD\Service\Frontier $frontierService
      * @var \DDD\Service\Task $taskService
      */
     $request = $this->getRequest();
     $frontierService = $this->getServiceLocator()->get('service_frontier');
     $taskService = $this->getServiceLocator()->get('service_task');
     $query = $request->getQuery('id', false);
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $bookingDao = $this->getServiceLocator()->get('dao_booking_booking');
     $userId = $auth->getIdentity()->id;
     preg_match('/(?P<entityType>\\d)_(?P<entityId>\\d+)/', $query, $params);
     $result = ['entityType' => 0, 'entityId' => 0, 'card' => [], 'tasks' => []];
     if (isset($params['entityId']) && $params['entityId'] && !$auth->hasRole(Roles::ROLE_FRONTIER_MANAGEMENT)) {
         $hasAccess = $bookingDao->checkFrontierPermission($userId, $params['entityId']);
         if (!$hasAccess) {
             return $this->redirect()->toUrl('/');
         }
     }
     if (count($params)) {
         $card = $frontierService->getTheCard($params['entityId'], $params['entityType'], $this);
         if ($card) {
             $tasks = $frontierService->getEntityTasks($params['entityId'], $params['entityType']);
             $result = ['entityType' => $params['entityType'], 'entityId' => $params['entityId'], 'card' => $card, 'tasks' => $tasks];
         }
     }
     $taskTypes = $taskService->getTaskTypesForSelect(['group' => Task::TASK_GROUP_FRONTIER]);
     $result['taskTypes'] = $taskTypes;
     // get bad email list
     $getBadEmail = BookingTicket::getBadEmail();
     $result['getBadEmail'] = json_encode($getBadEmail);
     return new ViewModel($result);
 }
예제 #2
0
 public function itemAction()
 {
     /**
      * @var $auth \Library\Authentication\BackofficeAuthenticationService
      */
     $id = (int) $this->params()->fromRoute('id', 0);
     $service = $this->getConcierge();
     if (!$id || !($rowObj = $service->getConciergeByGroupId($id))) {
         Helper::setFlashMessage(['error' => TextConstants::ERROR_NO_ITEM]);
         return $this->redirect()->toRoute('backoffice/default', ['controller' => 'concierge', 'action' => 'view']);
     }
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $authId = (int) $auth->getIdentity()->id;
     $external = (int) $auth->getIdentity()->external;
     $usermanagerDao = $this->getServiceLocator()->get('dao_user_user_manager');
     $userInfo = $usermanagerDao->fetchOne(['id' => $authId]);
     $currentDate = time();
     if (!is_null($userInfo->getTimezone())) {
         $currentDate = Helper::getCurrenctDateByTimezone($userInfo->getTimezone());
     }
     if ($auth->hasRole(Roles::ROLE_GLOBAL_APARTMENT_GROUP_MANAGER)) {
         $userId = false;
     } elseif ($auth->hasRole(Roles::ROLE_CONCIERGE_DASHBOARD) || $auth->hasRole(Roles::ROLE_APARTMENT_GROUP_MANAGEMENT)) {
         $userId = $authId;
     } else {
         return ['errorPage' => 'error'];
     }
     $isBookingManager = false;
     if ($auth->hasRole(Roles::ROLE_BOOKING_MANAGEMENT)) {
         $isBookingManager = true;
     }
     $hasFronterCharg = false;
     if ($auth->hasRole(Roles::ROLE_FRONTIER_CHARGE)) {
         $hasFronterCharg = true;
     }
     $hasFrontierCard = false;
     if ($auth->hasRole(Roles::ROLE_FRONTIER_MANAGEMENT)) {
         $hasFrontierCard = true;
     }
     $hasCurrentStayView = false;
     if ($auth->hasRole(Roles::ROLE_CONCIERGE_CURRENT_STAYS)) {
         $hasCurrentStayView = true;
     }
     $checkID = $service->checkGroupForUser($id, $userId);
     if (!$checkID) {
         return ['errorPage' => 'error'];
     }
     $timezone = 'UTC';
     $group_name = '';
     $accommodationList = $service->getApartmentGroupItems($id);
     if (is_object($rowObj)) {
         $timezone = $rowObj->getTimezone();
         $group_name = $rowObj->getName();
     }
     $conciergeView = $service->getConciergeView($accommodationList, $timezone);
     // get bad email list
     $getBadEmail = BookingTicket::getBadEmail();
     return ['currentStays' => $conciergeView['currentStays'], 'arrivalsYesterday' => $conciergeView['arrivalsYesterday'], 'arrivalsToday' => $conciergeView['arrivalsToday'], 'arrivalsTomorrow' => $conciergeView['arrivalsTomorrow'], 'checkoutsToday' => $conciergeView['checkoutsToday'], 'checkoutsTomorrow' => $conciergeView['checkoutsTomorrow'], 'checkoutsYesterday' => $conciergeView['checkoutsYesterday'], 'dateInTimezone' => $conciergeView['dateInTimezone'], 'groupId' => $id, 'groupName' => $group_name, 'isBookingManager' => $isBookingManager, 'hasFronterCharg' => $hasFronterCharg, 'hasCurrentStayView' => $hasCurrentStayView, 'currentDate' => $currentDate, 'hasFrontierCard' => $hasFrontierCard, 'getBadEmail' => json_encode($getBadEmail), 'userIsExternal' => $external];
 }