コード例 #1
0
    public function getPendingCancellationReservationsAction()
    {
        $auth = $this->getServiceLocator()->get('library_backoffice_auth');
        if (!$auth->checkUniversalDashboardPermission(UserService::DASHBOARD_PENDING_CANCELLATION)) {
            return $this->redirect()->toRoute('home');
        }
        /* @var $row \DDD\Domain\UniversalDashboard\Widget\PendingCancelation */
        /* @var $pendingCancelationWidgetService \DDD\Service\UniversalDashboard\Widget\PendingCancelation */
        $pendingCancelationWidgetService = $this->getServiceLocator()->get('service_universal_dashboard_widget_pending_cancellation');
        $dataSet = $pendingCancelationWidgetService->getPendingCancelationReservations();
        $bookingStatusesDao = new Statuses($this->getServiceLocator(), '\\ArrayObject');
        $bookingStatuses = $bookingStatusesDao->getAllList();
        $preparedData = [];
        if ($dataSet && count($dataSet)) {
            $dontShow = [Booking::BOOKING_STATUS_BOOKED, Booking::BOOKING_STATUS_CANCELLED_PENDING, Booking::BOOKING_STATUS_CANCELLED_MOVED, Booking::BOOKING_STATUS_CANCELLED_TEST_BOOKING];
            foreach ($dataSet as $row) {
                $strStatuses = '';
                foreach ($bookingStatuses as $item) {
                    if (in_array($item['id'], $dontShow)) {
                        continue;
                    }
                    $strStatuses .= "<li><a href='javascript:void(0)' " . "onClick='applyCancellation(this)' data-booking-status=" . "'{$item['id']}' data-booking-id=" . $row->getId() . ">{$item['name']}</a></li>";
                }
                $actionsColumn = '
					<a href="//' . DomainConstants::BO_DOMAIN_NAME . '/booking/edit/' . $row->getResNumber() . '" class="btn btn-xs btn-primary" target="_blank" data-html-content="View"></a>
                    <div class="btn-group" id="' . $row->getResNumber() . '">
						<button type="button" class="btn btn-xs btn-success ' . 'dropdown-toggle" data-toggle="dropdown">
                        Select Type <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
            ' . $strStatuses . '
						</ul>
					</div>
				';
                $preparedData[] = ["0" => $row->getResNumber(), "1" => date(Constants::GLOBAL_DATE_TIME_FORMAT, strtotime($row->getCancelationDate())), "2" => $row->getAffName(), "3" => $row->getPartnerRef(), "4" => $row->getApartmentName(), "5" => $row->getApartel(), "6" => $row->getGuestBalance() . ' ' . $row->getSymbol(), "7" => $actionsColumn];
            }
            return new JsonModel(["aaData" => $preparedData]);
        } else {
            return new JsonModel(["aaData" => []]);
        }
    }
コード例 #2
0
 public function ajaxApplyCancelationAction()
 {
     /**
      * @var \DDD\Service\UniversalDashboard\Widget\PendingCancelation $pendingCancelationWidgetService
      */
     $pendingCancelationWidgetService = $this->getServiceLocator()->get('service_universal_dashboard_widget_pending_cancellation');
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $request = $this->getRequest();
     $result = ['status' => 'error', 'msg' => TextConstants::SERVER_ERROR];
     if (!$auth->checkUniversalDashboardPermission(UserService::DASHBOARD_PENDING_CANCELLATION)) {
         return $this->redirect()->toRoute('home');
     }
     $logger = $this->getServiceLocator()->get('ActionLogger');
     try {
         if ($request->isPost() && $request->isXmlHttpRequest()) {
             $params = $this->params()->fromPost();
             $resNumber = $params['res_number'];
             $bookingStatus = $params['booking_status'];
             $bookingId = $params['booking_id'];
             $resolveResult = $pendingCancelationWidgetService->applyCancelation($resNumber, $bookingStatus);
             if ($resolveResult) {
                 $bookingStatusesDao = new Statuses($this->getServiceLocator(), '\\ArrayObject');
                 $bookingStatuses = $bookingStatusesDao->getAllList();
                 $result['status'] = 'success';
                 $statusName = '';
                 foreach ($bookingStatuses as $status) {
                     if ($bookingStatus == $status['id']) {
                         $statusName = $status['name'];
                     }
                 }
                 $result['msg'] = 'Reservation with R# ' . $resNumber . ' marked as ' . $statusName;
                 $logger->save(Logger::MODULE_BOOKING, $bookingId, Logger::ACTION_BOOKING_STATUSES, Objects::getBookingStatusMapping()[$bookingStatus]);
             } else {
                 $result['msg'] = 'Problem during requested operation for R# ' . $resNumber;
             }
         }
     } catch (\Exception $e) {
         $result['msg'] = $e->getMessage();
     }
     return new JsonModel($result);
 }