Ejemplo n.º 1
0
 public function ajaxUpdateSpotAvailabilitiesAction()
 {
     /**
      * @var \DDD\Service\Parking\Spot\Inventory $spotInventoryService
      * @var \DDD\Dao\Parking\Spot\Inventory $inventoryDao
      */
     $inventoryDao = $this->getServiceLocator()->get('dao_parking_spot_inventory');
     $request = $this->getRequest();
     $output = ['bo' => ['status' => 'success', 'msg' => TextConstants::SUCCESS_UPDATE]];
     try {
         $date = $request->getPost('date', null);
         $availability = $request->getPost('availability', null);
         if ($date) {
             $date = current(explode(' ', $date));
         }
         if ($request->isPost() && $request->isXmlHttpRequest()) {
             if (strtotime($date) !== false && is_array($availability)) {
                 foreach ($availability as $spotId => $spotAvailability) {
                     $inventoryDao->save(['availability' => (int) $spotAvailability], ['spot_id' => $spotId, 'date' => $date]);
                     $message = ['success' => TextConstants::SUCCESS_UPDATE];
                     Helper::setFlashMessage($message);
                 }
             } else {
                 $output['bo']['msg'] = 'Bad parameters.';
             }
         } else {
             $output['bo']['msg'] = 'Bad request.';
         }
     } catch (\Exception $ex) {
         $output['bo']['msg'] = $ex->getMessage();
     }
     return new JsonModel($output);
 }
Ejemplo n.º 2
0
 public function ajaxSaveAction()
 {
     $result = ['status' => 'error', 'msg' => TextConstants::SERVER_ERROR];
     try {
         if (!$this->getRequest()->isXmlHttpRequest()) {
             throw new \Exception(TextConstants::AJAX_ONLY_POST_ERROR);
         }
         $postData = $this->params()->fromPost();
         $venueId = isset($postData['venue_id']) ? $postData['venue_id'] : 0;
         /**
          * @var \DDD\Dao\Venue\Venue $venueDao
          */
         $venueDao = $this->getServiceLocator()->get('dao_venue_venue');
         $venueData = $venueDao->getVenueById($venueId);
         if ($venueData === false) {
             throw new \Exception('It is impossible to create a charge for a non-existent venue');
         }
         /**
          * @var \DDD\Service\Venue\Items $itemsService
          */
         $itemsService = $this->getServiceLocator()->get('service_venue_items');
         $saveResult = $itemsService->saveItems($venueId, $postData);
         if ($saveResult) {
             Helper::setFlashMessage(['success' => TextConstants::SUCCESS_UPDATE]);
             $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_UPDATE, 'url' => $this->url()->fromRoute('venue', ['action' => 'edit', 'id' => $venueId]) . '#items'];
         }
     } catch (\Exception $e) {
         $this->gr2logException($e);
         $result = ['status' => 'error', 'msg' => TextConstants::SERVER_ERROR . PHP_EOL . $e->getMessage()];
     }
     return new JsonModel($result);
 }
Ejemplo n.º 3
0
 public function downloadDatabaseBackupAction()
 {
     try {
         $fileString = $this->params()->fromQuery('file');
         if (strstr($fileString, '..')) {
             return new JsonModel(['status' => 'error', 'msg' => TextConstants::ERROR]);
         }
         $filePath = DirectoryStructure::FS_GINOSI_ROOT . DirectoryStructure::FS_DATABASE_BACKUP . $fileString;
         if (file_exists($filePath)) {
             ini_set('memory_limit', '512M');
             /**
              * @var \FileManager\Service\GenericDownloader $genericDownloader
              */
             $genericDownloader = $this->getServiceLocator()->get('fm_generic_downloader');
             $genericDownloader->setFileSystemMode(GenericDownloader::FS_MODE_DB_BACKUP);
             $genericDownloader->downloadAttachment($fileString);
             if ($genericDownloader->hasError()) {
                 Helper::setFlashMessage(['error' => $genericDownloader->getErrorMessages(true)]);
                 if ($this->getRequest()->getHeader('Referer')) {
                     $url = $this->getRequest()->getHeader('Referer')->getUri();
                     $this->redirect()->toUrl($url);
                 }
             }
             return true;
         }
     } catch (\Exception $e) {
         return new JsonModel(['status' => 'error', 'msg' => $e->getMessage()]);
     }
 }
Ejemplo n.º 4
0
 public function ajaxSaveMovesAction()
 {
     $return = ['status' => 'error', 'msg' => 'Moving apartments is not possible.'];
     try {
         $request = $this->getRequest();
         /**
          * @var \DDD\Service\Booking $bookingService
          */
         $bookingService = $this->getServiceLocator()->get('service_booking');
         if ($request->isXmlHttpRequest()) {
             $moves = $request->getPost('moves');
             $movesMapping = [];
             foreach ($moves as $move) {
                 $movesMapping[$move['resNumber']] = $move['moveTo'];
             }
             $return = $bookingService->simultaneouslyMoveReservations($movesMapping);
             if ($return['status'] == 'success') {
                 Helper::setFlashMessage(['success' => $return['msg']]);
             }
         }
     } catch (\Exception $e) {
         $return['msg'] = $e->getMessage();
     }
     return new JsonModel($return);
 }
Ejemplo n.º 5
0
 /**
  * @return JsonModel
  */
 public function deactivateAction()
 {
     $apartmentGroupId = $this->params()->fromRoute('id', 0);
     if ($apartmentGroupId) {
         /**
          * @var \DDD\Service\ApartmentGroup\Main $apartmentGroupMainService
          */
         $apartmentGroupMainService = $this->getServiceLocator()->get('service_apartment_group_main');
         $accGroupsManagementDao = $this->getServiceLocator()->get('dao_apartment_group_apartment_group');
         /* @var $apartmentGroupCurrentState \DDD\Domain\ApartmentGroup\ApartmentGroup */
         $apartmentGroupCurrentState = $accGroupsManagementDao->getRowById($apartmentGroupId);
         /* @var $apartmentGroupService \DDD\Service\ApartmentGroup */
         $apartmentGroupService = $this->getServiceLocator()->get('service_apartment_group');
         $currentAccommodations = $apartmentGroupService->getApartmentGroupItems($apartmentGroupId);
         if ($apartmentGroupCurrentState->isBuilding() && $currentAccommodations) {
             Helper::setFlashMessage(['error' => TextConstants::SERVER_ERROR]);
             return new JsonModel(['status' => 'error', 'msg' => 'Please move all apartments of this  building group to another building before deactivation group']);
         }
         // Deactivation
         $result = $apartmentGroupMainService->deactivate($apartmentGroupId);
         if ($result) {
             Helper::setFlashMessage(['success' => TextConstants::SUCCESS_DEACTIVATE]);
             return new JsonModel(['status' => 'success', 'msg' => 'Successful']);
         } else {
             Helper::setFlashMessage(['error' => TextConstants::SERVER_ERROR]);
             return new JsonModel(['status' => 'error', 'msg' => 'Something went wrong while trying to deactivate apartment group.']);
         }
     } else {
         Helper::setFlashMessage(['error' => 'Wrong Apartment Group ID']);
         return new JsonModel(['status' => 'error', 'msg' => 'Wrong Apartment Group ID']);
     }
 }
Ejemplo n.º 6
0
 public function saveAction()
 {
     $request = $this->getRequest();
     $result = array("status" => "error", "msg" => "Something went wrong. Cannot save video links.");
     if ($request->isXmlHttpRequest() or $request->isPost()) {
         $postData = $request->getPost();
         if (count($postData)) {
             $form = new MediaForm('apartment_media');
             $form->setData($postData);
             $form->prepare();
             if ($form->isValid()) {
                 $data = $form->getData();
                 unset($data['save_button']);
                 /**
                  * @var \DDD\Service\Apartment\Media $apartmentMediaService
                  */
                 $apartmentMediaService = $this->getServiceLocator()->get('service_apartment_media');
                 $apartmentMediaService->saveVideos($this->apartmentId, $data);
                 $result = ["status" => "success", "msg" => "Video links successfully updated"];
             } else {
                 $result = ["status" => "error", "msg" => $form->getMessages()];
             }
         }
     }
     Helper::setFlashMessage([$result['status'] => $result['msg']]);
     return new JsonModel($result);
 }
Ejemplo n.º 7
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];
 }
Ejemplo n.º 8
0
 public function ajaxGeneratePageAction()
 {
     /**
      * @var BackofficeAuthenticationService $authenticationService
      * @var BookingDao $reservationDao
      */
     $authenticationService = $this->getServiceLocator()->get('library_backoffice_auth');
     $reservationDao = $this->getServiceLocator()->get('dao_booking_booking');
     $result = ['status' => 'error', 'msg' => TextConstants::ERROR];
     if (!$authenticationService->hasRole(Roles::ROLE_CREDIT_CARD)) {
         $result['msg'] = 'You have no permission for this operation';
         return new JsonModel($result);
     }
     $result = ['success' => TextConstants::SUCCESS_UPDATE];
     try {
         /**
          * @var ChargeAuthorizationService $chargeAuthorizationService
          * @var Logger $logger
          */
         $chargeAuthorizationService = $this->getServiceLocator()->get('service_reservation_charge_authorization');
         $logger = $this->getServiceLocator()->get('ActionLogger');
         $request = $this->getRequest();
         if ($request->isXmlHttpRequest()) {
             $reservationId = (int) $request->getPost('reservation_id');
             $ccId = (int) $request->getPost('cc_id');
             $customEmail = $request->getPost('custom_email');
             $amount = $request->getPost('amount');
             $emailSection = '';
             if (!empty($customEmail)) {
                 $emailSection = ' --email=' . $customEmail;
             }
             $cccaResponse = $chargeAuthorizationService->generateChargeAuthorizationPageLink($reservationId, $ccId, $amount);
             $cmd = 'ginosole reservation-email send-ccca --id=' . escapeshellarg($reservationId) . ' --ccca_id=' . $cccaResponse['cccaId'] . $emailSection;
             $output = shell_exec($cmd);
             if (strstr(strtolower($output), 'error')) {
                 $result['status'] = 'error';
                 $result['msg'] = TextConstants::ERROR_SEND_MAIL;
                 return new JsonModel($result);
             }
             // log
             $logger->save(Logger::MODULE_BOOKING, $reservationId, Logger::ACTION_RESERVATION_CCCA_FORM_GENERATED_AND_SENT, ChargeAuthorization::CHARGE_AUTHORIZATION_PAGE_STATUS_GENERATED);
             // create auto task
             /**
              * @var TaskService $taskService
              */
             $taskService = $this->getServiceLocator()->get('service_task');
             $taskService->createAutoTaskReceiveCccaForm($reservationId);
             $reservationDao->save(['ccca_verified' => BookingService::CCCA_NOT_VERIFIED], ['id' => $reservationId]);
             $result['success'] .= "<br>" . TextConstants::SUCCESS_SEND_MAIL;
             Helper::setFlashMessage($result);
         }
     } catch (\Exception $e) {
         $result['status'] = 'error';
         $result['msg'] = TextConstants::ERROR;
         Helper::setFlashMessage($result);
     }
     return new JsonModel($result);
 }
 public function indexAction()
 {
     /**
      * @var \Library\Authentication\BackofficeAuthenticationService $auth
      * @var \DDD\Service\ApartmentGroup\Facilities $facilitiesService
      * @var \DDD\Service\ApartmentGroup\FacilityItems $facilitiyItemsService
      * @var ApartmentGroup $conciergeService
      * */
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $id = (int) $this->params()->fromRoute('id', 0);
     if ($id && !$this->getServiceLocator()->get('dao_apartment_group_apartment_group')->checkRowExist(DbTables::TBL_APARTMENT_GROUPS, 'id', $id)) {
         Helper::setFlashMessage(['error' => TextConstants::ERROR_NO_ITEM]);
         return $this->redirect()->toRoute('backoffice/default', ['controller' => 'apartment-group']);
     }
     $form = $this->getForm($id);
     $global = false;
     /**
      * @var \DDD\Service\ApartmentGroup $apartmentGroupService
      */
     $apartmentGroupService = $this->getServiceLocator()->get('service_apartment_group');
     if ($auth->hasRole(Roles::ROLE_GLOBAL_APARTMENT_GROUP_MANAGER)) {
         $global = true;
     } else {
         $manageableList = $apartmentGroupService->getManageableList();
         if (!in_array($id, $manageableList)) {
             $this->redirect()->toRoute('home');
         }
     }
     $apartmentGroupName = '';
     $logsAaData = [];
     if ($id > 0) {
         $apartmentGroupName = $apartmentGroupService->getApartmentGroupNameById($id);
         $apartmentGroupLogs = $apartmentGroupService->getApartmentGroupLogs($id);
         if (count($apartmentGroupLogs) > 0) {
             foreach ($apartmentGroupLogs as $log) {
                 $rowClass = '';
                 if ($log['user_name'] == TextConstants::SYSTEM_USER) {
                     $rowClass = "warning";
                 }
                 $apartmentGroupLogsArray[] = [date(Constants::GLOBAL_DATE_TIME_FORMAT, strtotime($log['timestamp'])), $log['user_name'], $this->identifyApartmentGroupAction($log['action_id']), $log['value'], "DT_RowClass" => $rowClass];
             }
         } else {
             $apartmentGroupLogsArray = [];
         }
         $logsAaData = $apartmentGroupLogsArray;
     }
     $logsAaData = json_encode($logsAaData);
     $viewModel = new ViewModel();
     $viewModel->setVariables(['apartmentGroupName' => $apartmentGroupName, 'id' => $id, 'global' => $global, 'historyAaData' => $logsAaData]);
     $resolver = new TemplateMapResolver(['backoffice/apartment-group/usages/history' => '/ginosi/backoffice/module/Backoffice/view/backoffice/apartment-group/usages/history.phtml']);
     $renderer = new PhpRenderer();
     $renderer->setResolver($resolver);
     $viewModel->setTemplate('backoffice/apartment-group/usages/history');
     return $viewModel;
 }
Ejemplo n.º 10
0
 public function statusAction()
 {
     $reviewID = (int) $this->params()->fromRoute('review_id', 0);
     $status = $this->params()->fromRoute('status', '0');
     if ($reviewID > 0) {
         $service = $this->getServiceLocator()->get('service_apartment_review');
         $service->updateReview($reviewID, $status, $this->apartmentId);
         Helper::setFlashMessage(['success' => TextConstants::SUCCESS_UPDATE]);
     } else {
         Helper::setFlashMessage(['success' => TextConstants::SERVER_ERROR]);
     }
     return $this->redirect()->toRoute('apartment/review', ['apartment_id' => $this->apartmentId]);
 }
Ejemplo n.º 11
0
 public function indexAction()
 {
     try {
         if ($this->apartelId > 0) {
             /** @var \DDD\Dao\Apartel\Details $apartelDetailsDao */
             $apartelDetailsDao = $this->getServiceLocator()->get('dao_apartel_details');
             $apartelCurrentData = $apartelDetailsDao->getApartelDetailsById($this->apartelId);
             /** @var Logger $logger */
             $logger = $this->getServiceLocator()->get('ActionLogger');
             $logger->setOutputFormat(Logger::OUTPUT_HTML);
             $apartelLogsArray = $logger->getDatatableData(Logger::MODULE_APARTEL, $this->apartelId);
             return new ViewModel(['historyAaData' => $apartelLogsArray, 'apartelId' => $this->apartelId, 'apartelName' => $apartelCurrentData->getName()]);
         } else {
             throw new \Exception('Apartel not found');
         }
     } catch (\Exception $e) {
         Helper::setFlashMessage(['error' => $e->getMessage()]);
         return $this->redirect()->toUrl('/');
     }
 }
Ejemplo n.º 12
0
 public function ajaxOrderItemsAction()
 {
     $result = ['status' => 'error', 'msg' => TextConstants::ERROR];
     $request = $this->getRequest();
     if ($request->isPost() && $request->isXmlHttpRequest()) {
         try {
             /**
              * @var \DDD\Service\Venue\Charges $venueChargeService
              */
             $venueChargeService = $this->getServiceLocator()->get('service_venue_charges');
             $post = $request->getPost();
             if ($venueChargeService->createChargeForLunchroom(iterator_to_array($post))) {
                 Helper::setFlashMessage(["success" => "Your order is accepted"]);
                 $result = ['status' => 'success'];
             }
         } catch (\Exception $ex) {
         }
     } else {
         $result['msg'] = TextConstants::ERROR_BAD_REQUEST;
     }
     return new JsonModel($result);
 }
 public function deleteAction()
 {
     $request = $this->getRequest();
     $response = ['status' => 'success', 'msg' => TextConstants::SUCCESS_UPDATE];
     if ($request->isXmlHttpRequest()) {
         $categoryId = (int) $request->getPost('id');
         /**
          * @var ReviewCategoryService $reviewCategoryService
          */
         $reviewCategoryService = $this->getServiceLocator()->get('service_apartment_review_category');
         $result = $reviewCategoryService->delete($categoryId);
         if ($result) {
             Helper::setFlashMessage(['success' => 'Review Category Was Successfully Removed.']);
         } else {
             $response['status'] = 'error';
             $response['msg'] = 'Problem Caused While Trying To Remove.';
         }
     } else {
         $response['status'] = 'error';
         $response['msg'] = 'Problem Caused While Trying To Remove.';
     }
     return new JsonModel($response);
 }
Ejemplo n.º 14
0
 public function ajaxChangeTransactionStatusAction()
 {
     try {
         /**
          * @var \DDD\Service\Booking\BankTransaction $service
          * @var \DDD\Service\Booking\BookingTicket $ticketService
          */
         $request = $this->getRequest();
         $auth = $this->getServiceLocator()->get('library_backoffice_auth');
         $message = TextConstants::ERROR;
         $status = 'error';
         if (!$auth->hasRole(Roles::ROLE_BOOKING_TRANSACTION_VERIFIER) && !$auth->hasDashboard(UserService::DASHBOARD_CASH_PAYMENTS) && !$auth->hasDashboard(UserService::DASHBOARD_TRANSACTION_PENDING) && !$auth->hasDashboard(UserService::DASHBOARD_FRONTIER_CHARGE_REVIEWED)) {
             throw new \Exception('No has permission');
         }
         if ($request->isPost() && $request->isXmlHttpRequest()) {
             $service = $this->getServiceLocator()->get('service_booking_bank_transaction');
             $transactionStatus = (int) $request->getPost('transaction_status');
             $transactionId = (int) $request->getPost('transaction_id');
             $transactionType = (int) $request->getPost('transaction_type');
             $reservationId = (int) $request->getPost('reservation_id');
             $responseData = $service->changeTransactionState($transactionId, $transactionStatus, $transactionType);
             $status = $responseData['status'];
             $message = $responseData['msg'];
             if ($transactionStatus !== BankTransaction::BANK_TRANSACTION_STATUS_APPROVED) {
                 $ticketService = $this->getServiceLocator()->get('service_booking_booking_ticket');
                 $ticketService->markAsUnsettledReservationById($reservationId);
             }
         } else {
             $message = TextConstants::BAD_REQUEST;
         }
     } catch (\Exception $e) {
         $this->gr2logException($e, 'Change Transaction Status Failed');
         $status = 'error';
     }
     Helper::setFlashMessage([$status => $message]);
     return new JsonModel(['status' => $status, 'msg' => $message]);
 }
Ejemplo n.º 15
0
 public function ajaxGenerateResetAction()
 {
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $request = $this->getRequest();
     $result = ['status' => 'error', 'msg' => TextConstants::ERROR];
     if (!$auth->hasRole(Roles::ROLE_CREDIT_CARD) && !$auth->hasRole(Roles::ROLE_FRONTIER_CHARGE)) {
         return new JsonModel($result);
     }
     $result = ['success' => TextConstants::SUCCESS_UPDATE];
     try {
         if ($request->isXmlHttpRequest()) {
             $booking_id = (int) $request->getPost('id');
             /**
              * @var \DDD\Service\Booking $bookingService
              */
             $bookingService = $this->getServiceLocator()->get('service_booking');
             $bookingService->generateCcDataUpdatePage($booking_id, 0);
             Helper::setFlashMessage($result);
         }
     } catch (\Exception $e) {
         $result['error'] = TextConstants::ERROR;
     }
     return new JsonModel($result);
 }
Ejemplo n.º 16
0
 public function downloadAttachmentAction()
 {
     $attachmentId = (int) $this->params()->fromRoute('attachment_id', false);
     if ($attachmentId) {
         /** @var \DDD\Dao\Task\Attachments $taskAttachmentsDao */
         $taskAttachmentsDao = $this->getServiceLocator()->get('dao_task_attachments');
         /** @var \DDD\Domain\Task\Attachments $file */
         $file = $taskAttachmentsDao->getAttachmentById($attachmentId);
         $filePath = DirectoryStructure::FS_UPLOADS_TASK_ATTACHMENTS . $file->getPath() . '/' . $file->getTaskId() . '/' . $file->getFile();
         /**
          * @var \FileManager\Service\GenericDownloader $genericDownloader
          */
         $genericDownloader = $this->getServiceLocator()->get('fm_generic_downloader');
         $genericDownloader->downloadAttachment($filePath);
         if ($genericDownloader->hasError()) {
             Helper::setFlashMessage(['error' => $genericDownloader->getErrorMessages(true)]);
             $url = $this->getRequest()->getHeader('Referer')->getUri();
             $this->redirect()->toUrl($url);
         }
         return true;
     }
 }
Ejemplo n.º 17
0
 public function changeStatusAction()
 {
     /**
      * @var \DDD\Service\Finance\Budget $service
      */
     $service = $this->getServiceLocator()->get('service_finance_budget');
     $request = $this->getRequest();
     $result = ['status' => 'error', 'msg' => TextConstants::SERVER_ERROR];
     try {
         if ($request->isPost() && $request->isXmlHttpRequest()) {
             $id = $request->getPost('id', 0);
             $status = $request->getPost('status', 0);
             if ($id && $status) {
                 $service->changeStatus($id, $status);
                 Helper::setFlashMessage(['success' => TextConstants::SUCCESS_UPDATE]);
                 $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_UPDATE];
             }
         }
     } catch (\Exception $ex) {
         // do nothing
     }
     return new JsonModel($result);
 }
Ejemplo n.º 18
0
 /**
  * @return JsonModel
  */
 public function ajaxDeleteContactAction()
 {
     $result = ['status' => 'error', 'msg' => TextConstants::SERVER_ERROR];
     $request = $this->getRequest();
     try {
         if ($request->isXmlHttpRequest()) {
             $contactId = $this->params()->fromRoute('contact_id', 0);
             if (!is_numeric($contactId) || $contactId == 0) {
                 throw new \Exception('Wrong Contact ID');
             }
             /**
              * @var \DDD\Service\Contacts\Contact $contactService
              */
             $contactService = $this->getServiceLocator()->get('service_contact_contact');
             $contactData = $contactService->getContactById($contactId);
             if ($contactData) {
                 $deleteStatus = $contactService->deleteContact($contactId);
                 if ($deleteStatus === null) {
                     Helper::setFlashMessage(['success' => 'Contact ' . TextConstants::SUCCESS_DELETE]);
                     $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_DELETE];
                 }
             }
         }
     } catch (\Exception $e) {
         $this->gr2logException($e, 'Cannot delete contact');
     }
     return new JsonModel($result);
 }
Ejemplo n.º 19
0
 public function editSaveConsumableAction()
 {
     /**
      * @var AssetService $assetService
      */
     $request = $this->getRequest();
     $result = ['status' => 'error', 'msg' => TextConstants::SERVER_ERROR];
     if ($request->isPost() && $request->isXmlHttpRequest()) {
         try {
             $assetService = $this->getServiceLocator()->get('service_warehouse_asset');
             $location = $request->getPost('location');
             $locationArray = explode('_', $location);
             $locationEntityType = $locationArray[0];
             $locationEntityId = $locationArray[1];
             if (FALSE !== $assetService->checkIfCategoryLocationIdLocationEntityIsUnique($request->getPost('category'), $locationEntityType, $locationEntityId, $request->getPost('id'))) {
                 $result['msg'] = '<ul><li>This category already exists in this storage.</li><li>The right approach is to change the quantities</li>';
                 throw new \Exception();
             }
             $assetService->updateConsumableAsset($request);
             Helper::setFlashMessage(['success' => TextConstants::SUCCESS_UPDATE]);
             $result = ['status' => 'success', 'msg' => 'OK'];
         } catch (\Exception $ex) {
         }
     } else {
     }
     return new JsonModel($result);
 }
Ejemplo n.º 20
0
 public function changeItemManagerAction()
 {
     /**
      * @var ExpenseTicket $expenseService
      */
     $expenseService = $this->getServiceLocator()->get('service_finance_expense_expense_ticket');
     $request = $this->getRequest();
     $id = $this->params()->fromRoute('id');
     $result = ['status' => 'error', 'msg' => TextConstants::SERVER_ERROR];
     if ($request->isPost() && $request->isXmlHttpRequest()) {
         try {
             $newManagerId = (int) $request->getPost('newManagerId');
             if ($expenseService->changeManager($id, $newManagerId)) {
                 $result = ['status' => 'success'];
                 Helper::setFlashMessage(['success' => TextConstants::SUCCESS_UPDATE]);
             }
         } catch (\RuntimeException $ex) {
             $result['msg'] = $ex->getMessage();
         } catch (\Exception $ex) {
             // do nothing
         }
     } else {
         $result['msg'] = TextConstants::BAD_REQUEST;
     }
     return new JsonModel($result);
 }
Ejemplo n.º 21
0
 public function ajaxactiveofficeAction()
 {
     $request = $this->getRequest();
     $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_UPDATE];
     try {
         if ($request->isPost() && $request->isXmlHttpRequest()) {
             $id = (int) $request->getPost('id');
             $officeService = $this->getOfficeService();
             $officeService->changeOfficeStatus($id, 0);
             Helper::setFlashMessage(['success' => TextConstants::SUCCESS_ACTIVATE]);
         } else {
             $result['msg'] = TextConstants::BAD_REQUEST;
         }
     } catch (\Exception $e) {
         $result['status'] = 'error';
         $result['msg'] = TextConstants::SERVER_ERROR;
     }
     return new JsonModel($result);
 }
Ejemplo n.º 22
0
 public function ajaxCheckOtaAction()
 {
     /**
      * @var Request $request
      */
     $request = $this->getRequest();
     $apartelId = $this->apartelId;
     $otaId = $this->params()->fromRoute('ota_id');
     $result = ['status' => 'error', 'msg' => TextConstants::SERVER_ERROR];
     if ($request->isPost() && $request->isXmlHttpRequest()) {
         try {
             $apartel = new Apartelle($apartelId);
             $crawler = new OTACrawler($apartel, [$otaId]);
             $crawler->setServiceLocator($this->getServiceLocator());
             $crawler->update();
             Helper::setFlashMessage(['success' => TextConstants::SUCCESS_UPDATE]);
             $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_UPDATE];
         } catch (\Exception $ex) {
             $result['msg'] = $ex->getMessage();
         }
     }
     return new JsonModel($result);
 }
Ejemplo n.º 23
0
 public function saveAction()
 {
     /**
      * @var \DDD\Service\Apartment\Location $locationService
      */
     $inputFilter = new LocationFilter();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $postData = $request->getPost();
         $form = new LocationForm('apartment_location');
         $form->setInputFilter($inputFilter->getInputFilter());
         $form->setData($postData);
         $form->prepare();
         if ($form->isValid()) {
             $data = $form->getData();
             $locationService = $this->getServiceLocator()->get('service_apartment_location');
             $locationService->saveApartmentLocation($this->apartmentId, $data);
             $flash['success'] = 'Location was successfully updated.';
         } else {
             $messages = '';
             $errors = $form->getMessages();
             foreach ($errors as $key => $row) {
                 if (!empty($row)) {
                     $messages .= ucfirst($key) . ' ';
                     $messages_sub = '';
                     foreach ($row as $keyer => $rower) {
                         $messages_sub .= $rower;
                     }
                     $messages .= $messages_sub . '<br>';
                 }
             }
             $result['status'] = 'error';
             $result['msg'] = $messages;
             $flash['error'] = $messages;
         }
         Helper::setFlashMessage($flash);
     }
     $this->redirect()->toRoute('apartment/location', ['apartment_id' => $this->apartmentId, 'action' => 'save']);
 }
Ejemplo n.º 24
0
 /**
  * @return JsonModel
  */
 public function cancelAction()
 {
     /**
      * @var EvaluationService $evaluationService
      * @var \DDD\Dao\User\Evaluation\Evaluations $evaluationDao
      */
     $evaluationService = $this->getServiceLocator()->get('service_user_evaluations');
     $evaluationDao = $this->getServiceLocator()->get('dao_user_evaluation_evaluations');
     $evaluationId = (int) $this->params()->fromRoute('evaluation_id', 0);
     $result = [];
     if ($evaluationId) {
         /**
          * @var EvaluationExtended $evaluationDomain
          */
         $evaluationDomain = $evaluationDao->fetchOne(['id' => $evaluationId], ['type_id', 'status']);
         if ($evaluationDomain->getTypeId() == EvaluationService::USER_EVALUATION_TYPE_EVALUATION && $evaluationDomain->getStatus() == EvaluationService::USER_EVALUATION_STATUS_PLANNED) {
             $cancelResult = $evaluationService->cancelEvaluation($evaluationId);
             if ($cancelResult) {
                 $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_CANCELLED];
                 Helper::setFlashMessage(['success' => TextConstants::SUCCESS_CANCELLED]);
             } else {
                 $result = ['status' => 'error', 'msg' => TextConstants::USER_EVALUATION_CANNOT_CANCELLED];
             }
         } else {
             $result = ['status' => 'error', 'msg' => 'Only evaluations with "Evaluation" type and "Planned" status can be cancelled.'];
         }
     } else {
         $result = ['status' => 'error', 'msg' => TextConstants::USER_EVALUATION_NOT_FOUND];
     }
     return new JsonModel($result);
 }
Ejemplo n.º 25
0
 public function ajaxChangeActivationJobAction()
 {
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $jobService = $this->getServiceLocator()->get('service_recruitment_job');
     $request = $this->getRequest();
     $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_UPDATE];
     try {
         if ($request->isPost() && $request->isXmlHttpRequest()) {
             $id = (int) $request->getPost('id');
             $disabled = (int) $request->getPost('jobStatus');
             if ($id && !$auth->hasRole(Roles::ROLE_HIRING_MANAGER)) {
                 $jobInfo = $jobService->getJobById($id);
                 if ($jobInfo) {
                     if ($auth->getIdentity()->id != $jobInfo->getHiringManagerId()) {
                         return $this->redirect()->toUrl('/recruitment/jobs');
                     }
                 }
             }
             if ($disabled != 3) {
                 $disabled = 3;
             } elseif ($disabled == 3) {
                 $disabled = 1;
             }
             $data = ['status' => $disabled];
             $return = $jobService->changeActStatusJob($data, $id);
             if ($return) {
                 $msg = $disabled == 3 ? TextConstants::SUCCESS_DEACTIVATE : TextConstants::SUCCESS_ACTIVATE;
                 Helper::setFlashMessage(['success' => $msg]);
             }
         }
     } catch (\Exception $e) {
         $result['status'] = 'error';
         $result['msg'] = TextConstants::SERVER_ERROR;
     }
     return new JsonModel($result);
 }
Ejemplo n.º 26
0
 public function ajaxdeleteAction()
 {
     $result = ['status' => 'success', 'msg' => TextConstants::SUCCESS_DELETE];
     try {
         $request = $this->getRequest();
         $id = (int) $request->getPost('id');
         if ($request->isXmlHttpRequest() && $id > 0) {
             $service = $this->getBlogService();
             $response = $service->deleteBlog($id);
             if ($response) {
                 Helper::setFlashMessage(['success' => TextConstants::SUCCESS_DELETE]);
             } else {
                 $result['status'] = 'error';
                 $result['msg'] = TextConstants::SERVER_ERROR;
             }
         } else {
             throw new \Exception("Bad data");
         }
     } catch (Exception $e) {
         $result['status'] = 'error';
         $result['msg'] = TextConstants::SERVER_ERROR;
     }
     return new JsonModel($result);
 }
Ejemplo n.º 27
0
 /**
  * Inactive Supplier account
  *
  * @return JsonModel
  */
 public function ajaxSetSupplierAccountArchiveAction()
 {
     // get authentication module
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     if (!$auth->hasRole(Roles::ROLE_SUPPLIERS_MANAGEMENT)) {
         return new JsonModel(['status' => 'error', 'msg' => TextConstants::SUPPLIER_ACCOUNT_CANNOT_BE_MANAGE]);
     }
     $request = $this->getRequest();
     $result = ['status' => 'error', 'message' => TextConstants::SERVER_ERROR];
     if ($request->isPost() && $request->isXmlHttpRequest() && $request->getPost()->get('supplierId')) {
         $postData = $request->getPost();
         $supplierAccountId = $postData->get('id');
         $supplierId = $postData->get('supplierId');
         if ($supplierAccountId) {
             /**
              * @var \DDD\Dao\User\ExternalAccount $userAccountDao
              */
             $userAccountDao = $this->getServiceLocator()->get('dao_user_external_account');
             $userAccountDao->save(['status' => ExternalAccount::EXTERNAL_ACCOUNT_STATUS_ARCHIVED, 'is_default' => 0], ['id' => $supplierAccountId]);
             Helper::setFlashMessage(["success" => "Successfully Deactivated."]);
             return new JsonModel(["status" => "success", "message" => "Successfully updated.", "url" => $this->url()->fromRoute('finance/suppliers', ['controller' => 'suppliers', 'action' => 'edit', 'id' => $supplierId])]);
         }
     }
     return new JsonModel($result);
 }
Ejemplo n.º 28
0
 public function archiveAction()
 {
     /**
      * @var \DDD\Service\Finance\Espm $service
      * @var BackofficeAuthenticationService $auth
      */
     $service = $this->getServiceLocator()->get('service_finance_espm');
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     if (!$auth->hasRole(Roles::ROLE_ESPM_PAYMENT_MANAGER)) {
         Helper::setFlashMessage(['error' => TextConstants::NO_PERMISSION]);
         $this->redirect()->toRoute('finance/espm');
     }
     $espmId = $this->params()->fromRoute('id', 0);
     $archive = $this->params()->fromRoute('archive', 0);
     if ($espmId > 0) {
         $service->archive($espmId, $archive);
         Helper::setFlashMessage(['success' => $archive ? TextConstants::SUCCESS_ARCHIVE : TextConstants::SUCCESS_UNARCHIVE]);
     } else {
         Helper::setFlashMessage(['success' => TextConstants::BAD_REQUEST]);
     }
     $this->redirect()->toRoute('finance/espm/edit', ['controller' => 'edit', 'action' => 'edit', 'id' => $espmId]);
 }
Ejemplo n.º 29
0
 public function rateDeleteAction()
 {
     try {
         /**
          * @var \DDD\Service\Apartel\Rate $rateService
          * @var Request $request
          */
         $rateId = $this->params()->fromRoute('rate_id', 0);
         $rateService = $this->getServiceLocator()->get('service_apartel_rate');
         $deleteResponse = $rateService->deleteRate($rateId);
         $flesh = [$deleteResponse['status'] => $deleteResponse['msg']];
     } catch (\Exception $e) {
         $flesh = ['error' => TextConstants::ERROR];
     }
     Helper::setFlashMessage($flesh);
     return $this->redirect()->toRoute('apartel/type-rate/home', ['apartel_id' => $this->apartelId], [], true);
 }
Ejemplo n.º 30
0
 public function ajaxsaveAction()
 {
     $result = ['id' => 0, 'status' => 'success', 'msg' => TextConstants::SUCCESS_UPDATE];
     $request = $this->getRequest();
     try {
         if ($request->isXmlHttpRequest()) {
             $id = (int) $request->getPost('edit_id', 0);
             if (!$id) {
             }
             $params['tipe_id'] = $request->getPost('textline-type');
             $params['lng'] = strip_tags(trim($request->getPost('lang_code')));
             $params['type'] = strip_tags(trim($request->getPost('type_translation')));
             $params['locationOptions'] = strip_tags(trim($request->getPost('location_option')));
             $params['locationType'] = strip_tags(trim($request->getPost('locationType')));
             $params['id'] = (int) $request->getPost('edit_id');
             $getForm = $this->getForm($params, ['language' => $params['lng'], 'type_translation' => $params['type'], 'locationOption' => $params['locationOptions'], 'locationType' => $params['locationType']]);
             $form = $getForm['form'];
             $messages = '';
             $form->setInputFilter(new TranslationFilter());
             if ($request->isPost()) {
                 $service = $this->getTranslationService();
                 $filter = $form->getInputFilter();
                 $form->setInputFilter($filter);
                 $data = $request->getPost();
                 $form->setData($data);
                 if ($form->isValid()) {
                     $vData = $form->getData();
                     $respons_db = $service->translationSave($vData);
                     if ($id == 0) {
                         $result['id'] = $respons_db['id'];
                         Helper::setFlashMessage(['success' => TextConstants::SUCCESS_ADD]);
                     } else {
                         // RE-CACHE FOR WEBSITE
                         if ($params['type'] === 'u') {
                             $cache = $this->getServiceLocator()->get('service_website_cache');
                             $dataFromDb = $this->getForm($params, ['language' => $params['lng'], 'type_translation' => $params['type'], 'locationOption' => $params['locationOptions'], 'locationType' => $params['locationType']]);
                             $cache->set($id . '-' . $params['lng'], $dataFromDb['data']->getContent());
                         }
                         Helper::setFlashMessage(['success' => TextConstants::SUCCESS_PUBLISH]);
                     }
                 } else {
                     $errors = $form->getMessages();
                     foreach ($errors as $key => $row) {
                         if (!empty($row)) {
                             $messages .= ucfirst($key) . ' ';
                             $messages_sub = '';
                             foreach ($row as $keyer => $rower) {
                                 $messages_sub .= $rower;
                             }
                             $messages .= $messages_sub . '<br>';
                         }
                     }
                     $result['status'] = 'error';
                     $result['msg'] = $messages;
                 }
             }
         }
     } catch (\Exception $e) {
         $result['status'] = 'error';
         $result['msg'] = TextConstants::SERVER_ERROR;
     }
     return new JsonModel($result);
 }