/** * @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']); } }
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); }
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); }
public function avatarAction() { try { /** * @var \DDD\Service\Upload $uploadService */ $uploadService = $this->getServiceLocator()->get('service_upload'); $request = $this->getRequest(); // check request method if ($request->getMethod() !== 'POST') { throw new \Exception(TextConstants::AJAX_NO_POST_ERROR); } // take avatar file and user id from POST $avatarFile = $request->getFiles(); $profileId = $request->getPost('userId'); // send resoult to service $newAvatar = $uploadService->updateAvatar((int) $profileId, [$avatarFile['file']]); if (is_array($newAvatar) && $newAvatar['status'] === 'error') { return new JsonModel($newAvatar); } $session = Helper::getSession('Zend_Auth'); $session['storage']->avatar = $newAvatar; $result['status'] = 'success'; $result['msg'] = TextConstants::SUCCESS_UPDATE; $result['src'] = $profileId . '/' . $newAvatar; return new JsonModel($result); } catch (Exception $e) { throw new \Exception($e->getMessage()); } }
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()]); } }
/** * Test booking process */ public function testBookingProcess() { $bookingTicketService = $this->getApplicationServiceLocator()->get('service_booking_booking_ticket'); $channelManagerService = $this->getApplicationServiceLocator()->get('service_channel_manager'); $apartmentGroupService = $this->getApplicationServiceLocator()->get('service_apartment_group'); $reservationService = $this->getApplicationServiceLocator()->get('service_reservation_main'); $partnerService = $this->getApplicationServiceLocator()->get('service_partners'); $syncService = $this->getApplicationServiceLocator()->get('service_queue_inventory_synchronization_queue'); $currencyService = $this->getApplicationServiceLocator()->get('service_currency_currency'); $this->assertInstanceOf('\\DDD\\Service\\Booking\\BookingTicket', $bookingTicketService); $this->assertInstanceOf('\\DDD\\Service\\ChannelManager', $channelManagerService); $this->assertInstanceOf('\\DDD\\Service\\ApartmentGroup', $apartmentGroupService); $this->assertInstanceOf('\\DDD\\Service\\Reservation\\Main', $reservationService); $this->assertInstanceOf('\\DDD\\Service\\Partners', $partnerService); $this->assertInstanceOf('\\DDD\\Service\\Queue\\InventorySynchronizationQueue', $syncService); $this->assertInstanceOf('\\DDD\\Service\\Currency\\Currency', $currencyService); // dummy data $resNumber = $bookingTicketService->generateResNumber(); $timeStamp = date('Y-m-d H:i:s'); $reservationData = ["apartment_id_assigned" => 662, "apartment_id_origin" => 662, "room_id" => 1366, "acc_name" => "Hollywood Al Pacino", "acc_country_id" => 213, "acc_province_id" => 19, "acc_city_id" => 48, "acc_province_name" => "California", "acc_city_name" => "Hollywood Los Angeles", "acc_address" => "1714 N McCadden Pl", "building_name" => $apartmentGroupService->getBuildingName(662), "date_from" => date('Y-m-d'), "date_to" => date('Y-m-d', strtotime(' +1 day')), "currency_rate" => $currencyService->getCurrencyConversionRate(Helper::getCurrency(), "USD"), "currency_rate_usd" => $currencyService->getCurrencyConversionRate('USD', 'USD'), "booker_price" => "249.00", "guest_currency_code" => Helper::getCurrency(), "occupancy" => 2, "res_number" => $resNumber, "timestamp" => $timeStamp, "apartment_currency_code" => 'USD', "rateId" => "3536", "ki_page_status" => BookingTicket::NOT_SEND_KI_PAGE_STATUS, "ki_page_hash" => $bookingTicketService->generatePageHash($resNumber, $timeStamp), "review_page_hash" => $bookingTicketService->generatePageHash($resNumber, 662), "remarks" => "", "guest_first_name" => "Test", "guest_last_name" => "PhpUnit", "guest_email" => "*****@*****.**", "guest_address" => "Test Street 2", "guest_city_name" => "Yerevan", "guest_country_id" => 2, "guest_language_iso" => 'en', "guest_zip_code" => "12121", "guest_phone" => "37499000000", "partner_ref" => "", "partner_id" => 5, "partner_name" => "Staff", "partner_commission" => 0, "model" => 2]; $customerData['email'] = $reservationData['guest_email']; $reservationData['customer_data'] = $customerData; $otherInfo = ['cc_provided' => false, 'availability' => 0, 'no_send_guest_mail' => true, 'ratesData' => $reservationService->getRateDataByRateIdDates($reservationData['rateId'], $reservationData['date_from'], $reservationData['date_to'])]; unset($reservationData['rateId']); $reservationId = $reservationService->registerReservation($reservationData, $otherInfo, true); $this->assertLessThan($reservationId, 0, 'Reservation is not correct or not available - [Apartment ID: 662]'); $syncOutput = $syncService->push($reservationData['apartment_id_origin'], $reservationData['date_from'], $reservationData['date_to']); $this->assertTrue($syncOutput, 'Synchronization Queue is not correct'); }
/** * @param $data * @param $budgetId * @return int */ public function saveBudget($data, $budgetId) { /** @var \DDD\Dao\Finance\Budget\Budget $budgetDao */ $budgetDao = $this->getServiceLocator()->get('dao_finance_budget_budget'); $dateRange = Helper::refactorDateRange($data['period']); if ($budgetId) { // Apply amount changes to balance $oldData = $budgetDao->getBudgetData($budgetId); $balance = $oldData['balance'] + $data['amount'] - $oldData['amount']; } else { // Starting balance is the same as amount $balance = $data['amount']; } $params = ['name' => $data['name'], 'status' => $data['status'], 'from' => $dateRange['date_from'], 'to' => $dateRange['date_to'], 'amount' => $data['amount'], 'balance' => $balance, 'description' => $data['description'], 'department_id' => $data['is_global'] ? null : $data['department_id'], 'is_global' => $data['is_global']]; if ($data['country_id'] > 0) { $params['country_id'] = $data['country_id']; } else { $params['country_id'] = null; } if ($budgetId) { $budgetDao->save($params, ['id' => $budgetId]); } else { $auth = $this->getServiceLocator()->get('library_backoffice_auth'); $userId = $auth->getIdentity()->id; $params['user_id'] = $userId; $budgetId = $budgetDao->save($params); } return $budgetId; }
public function sendApplicantRejectionsAction() { /** * @var \DDD\Service\Queue\EmailQueue $emailQueueService * @var \Mailer\Service\Email $mailer */ $emailQueueService = $this->getServiceLocator()->get('service_queue_email_queue'); $list = $emailQueueService->fetch(EmailQueue::TYPE_APPLICANT_REJECTION); if ($list && $list->count()) { /** * @var \DDD\Service\Textline $textlineService */ $textlineService = $this->getServiceLocator()->get('service_textline'); foreach ($list as $item) { //Don't send an email if applicant is not rejected anymore if (Applicant::APPLICANT_STATUS_REJECT != $item['status']) { $emailQueueService->delete($item['id']); continue; } $mailer = $this->getServiceLocator()->get('Mailer\\Email'); $emailValidator = new EmailAddress(); if (!$emailValidator->isValid($item['email'])) { $this->outputMessage('[error] Applicant email is not valid: ' . $item['email'] . ' Removing from queue.'); $this->gr2err("Applicant rejection mail wasn't sent", ['applicant_id' => $item['entity_id'], 'applicant_name' => $item['applicant_name']]); continue; } $mailer->send('applicant-rejection', ['to' => $item['email'], 'bcc' => EmailAliases::HR_EMAIL, 'to_name' => $item['applicant_name'], 'replyTo' => EmailAliases::HR_EMAIL, 'from_address' => EmailAliases::HR_EMAIL, 'from_name' => 'Ginosi Apartments', 'subject' => $textlineService->getUniversalTextline(1608, true), 'msg' => Helper::evaluateTextline($textlineService->getUniversalTextline(1607), ['{{APPLICANT_NAME}}' => $item['applicant_name'], '{{POSITION_TITLE}}' => $item['position_title']])]); $emailQueueService->delete($item['id']); $this->outputMessage("[1;32mRejection email to {$item['applicant_name']} sent. [0m"); } } else { $this->outputMessage("[1;32mQueue is empty. [0m"); } $this->outputMessage("[1;32mDone. [0m"); }
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); }
public function downloadCsvAction() { $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general'); $currency = $apartmentGeneralService->getCurrencySymbol($this->apartmentId); $expenseDao = new ExpenseCost($this->getServiceLocator(), '\\ArrayObject'); $costs = $expenseDao->getApartmentCosts($this->apartmentId); $costArray = []; foreach ($costs as $cost) { $costArray[] = ["ID" => $cost['id'], "Category" => $cost['category'], "Date" => date(Constants::GLOBAL_DATE_FORMAT, strtotime($cost['date'])), "Amount ({$currency})" => $cost['amount'], "Purpose" => $cost['purpose']]; } if (!empty($costArray)) { $response = $this->getResponse(); $headers = $response->getHeaders(); $utilityCsvGenerator = new CsvGenerator(); $filename = 'costs_apartment_' . str_replace(' ', '_', date('Y-m-d')) . '.csv'; $utilityCsvGenerator->setDownloadHeaders($headers, $filename); $csv = $utilityCsvGenerator->generateCsv($costArray); $response->setContent($csv); return $response; } else { $flash_session = Helper::getSessionContainer('use_zf2'); $flash_session->flash = ['notice' => 'There are empty data, nothing to download.']; $url = $this->getRequest()->getHeader('Referer')->getUri(); $this->redirect()->toUrl($url); } }
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); }
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]; }
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; }
/** * @param $params * @param $userId * @return array */ public function getAllBudgets($params, $userId) { $this->resultSetPrototype->setArrayObjectPrototype(new \ArrayObject()); $where = new Where(); if (isset($params['name']) && $params['name']) { $where->like($this->getTable() . '.name', $params['name'] . '%'); } if (isset($params['status']) && $params['status']) { $where->equalTo($this->getTable() . '.status', $params['status']); } if (isset($params['user']) && $params['user']) { $where->equalTo($this->getTable() . '.user_id', $params['user']); } if (isset($params['period']) && $params['period']) { $dateRange = Helper::refactorDateRange($params['period']); $where->greaterThanOrEqualTo($this->getTable() . '.to', $dateRange['date_from']); $where->lessThanOrEqualTo($this->getTable() . '.from', $dateRange['date_to']); } if (isset($params['frozen']) && $params['frozen'] >= 0) { $where->equalTo($this->getTable() . '.frozen', $params['frozen']); } if (isset($params['archived']) && $params['archived'] >= 0) { $where->equalTo($this->getTable() . '.archived', $params['archived']); } if ($userId) { $where->equalTo($this->getTable() . '.user_id', $userId); } if (isset($params['department']) && $params['department'] >= 0) { $where->equalTo($this->getTable() . '.department_id', $params['department']); } if (isset($params['country']) && $params['country'] >= 0) { $where->equalTo($this->getTable() . '.country_id', $params['country']); } if (isset($params['global']) && $params['global'] >= 0) { $where->equalTo($this->getTable() . '.is_global', $params['global']); } $offset = $params['iDisplayStart']; $limit = $params['iDisplayLength']; $sortCol = $params['iSortCol_0']; $sortDir = $params['sSortDir_0']; $result = $this->fetchAll(function (Select $select) use($offset, $limit, $sortCol, $sortDir, $where) { $sortColumns = ['status', 'name', 'department_name', 'from', 'amount', 'balance', 'user_name']; $select->columns(['id', 'name', 'from', 'to', 'amount', 'description', 'status', 'user_id', 'department_id', 'country_id', 'is_global', 'balance']); $select->join(['users' => DbTables::TBL_BACKOFFICE_USERS], $this->getTable() . '.user_id = users.id', ['user_name' => new Expression('CONCAT(firstname, " ", lastname)')], Select::JOIN_LEFT); $select->join(['teams' => DbTables::TBL_TEAMS], $this->getTable() . '.department_id = teams.id', ['department_name' => 'name'], Select::JOIN_LEFT); $select->where($where); $select->group($this->getTable() . '.id')->order($sortColumns[$sortCol] . ' ' . $sortDir)->offset((int) $offset)->limit((int) $limit); $select->quantifier(new Expression('SQL_CALC_FOUND_ROWS')); }); $statement = $this->adapter->query('SELECT FOUND_ROWS() as total'); $resultCount = $statement->execute(); $row = $resultCount->current(); $total = $row['total']; return ['result' => $result, 'total' => $total]; }
/** * * @return array */ public function getOptions() { //search options $searchService = $this->getServiceLocator()->get('service_website_search'); $options = $searchService->getOptionsForSearch(); //location options $cacheService = $this->getServiceLocator()->get('service_website_cache'); $keyLocationsCache = 'locations_for_home_en'; $router = $this->getServiceLocator()->get('router'); if ($rowsLocations = $cacheService->get($keyLocationsCache)) { $options['locations'] = $rowsLocations; } else { $cityDao = new CityDao($this->getServiceLocator(), 'ArrayObject'); $citiesList = $cityDao->getCityListForIndex(); $cities = []; foreach ($citiesList as $city) { $cityProvince = $city['city_slug'] . '--' . $city['province_slug']; $img = Helper::getImgByWith('/locations/' . $city['detail_id'] . '/' . $city['cover_image'], WebSite::IMG_WIDTH_LOCATION_MEDIUM); $cities[$city['ordering']] = ['city_id' => $city['city_id'], 'country_id' => $city['country_id'], 'capacity' => $city['capacity'], 'spent_nights' => $city['spent_nights'], 'sold_future_nights' => $city['sold_future_nights'], 'img' => $img, 'url' => $router->assemble(['action' => 'location', 'cityProvince' => $cityProvince], ['name' => 'location/child'])]; } ksort($cities); $options['locations'] = $cities; $cacheService->set($keyLocationsCache, $cities); } //country count $keyCountryCashe = 'country_count_for_home'; if ($countryCount = $cacheService->get($keyCountryCashe)) { $options['countryCount'] = $countryCount; } else { $bookingDao = $this->getBookingWebDao(); $countries = $bookingDao->getBookingCountryEmailCount('guest_country_id'); $options['countryCount'] = $countries ? $countries['count'] : 0; $cacheService->set($keyCountryCashe, $options['countryCount']); } //people count $keyPeopleCache = 'people_count_for_home'; if ($peopleCount = $cacheService->get($keyPeopleCache)) { $options['peopleCount'] = $peopleCount; } else { $bookingDao = $this->getBookingWebDao(); $peoples = $bookingDao->getBookingCountryEmailCount('guest_email'); $options['peopleCount'] = $peoples ? $peoples['count'] : 0; $cacheService->set($keyPeopleCache, $options['peopleCount']); } //blog list $blogDao = new Blog($this->getServiceLocator(), 'ArrayObject'); $bloges = $blogDao->getBlogForWebIndex(); $options['bloges'] = $bloges; $router = $this->getServiceLocator()->get('router'); $url = $router->assemble([], ['name' => 'search']); $options['action'] = $url; return $options; }
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]); }
/** * @return array|\Zend\Http\Response|ViewModel */ public function indexAction() { /** * @var ReservationsDAO $reservationsDao */ $reservationsDao = $this->getServiceLocator()->get('dao_booking_booking'); $pageToken = $this->params()->fromQuery('token'); if ($pageToken) { $reservationData = $reservationsDao->getReservationDataForChargeAuthorizationPage($pageToken); if ($reservationData) { $now3d = new \DateTime(null, new \DateTimeZone($reservationData->getTimezone())); $now3d = strtotime($now3d->modify('-3 day')->format('Y-m-d')); if ($now3d > strtotime($reservationData->getReservationDateTo()) && $now3d > strtotime($reservationData->getCccaCreationDate())) { return $this->redirect()->toRoute('home')->setStatusCode('301'); } } else { return $this->redirect()->toRoute('home')->setStatusCode('301'); } } else { return $this->redirect()->toRoute('home')->setStatusCode('301'); } /** * @var ChargeAuthorizationService $chargeAuthorizationService */ $chargeAuthorizationService = $this->getServiceLocator()->get('service_reservation_charge_authorization'); $info = $chargeAuthorizationService->getInfoForCCCAPage($pageToken); $amount = $info->getAmount(); $chargeAuthorizationService->changeChargeAuthorizationPageStatus($reservationData->getReservationId(), $pageToken, ChargeAuthorization::CHARGE_AUTHORIZATION_PAGE_STATUS_VIEWED); $cccaForm = new ChargeAuthorizationForm(); $cccaForm->prepare(); /** * @var ChargeDAO $chargesDao */ $chargesDao = $this->getServiceLocator()->get('dao_booking_charge'); $chargesSummary = $chargesDao->calculateChargesSummary($reservationData->getReservationId(), \DDD\Service\Booking\Charge::CHARGE_MONEY_DIRECTION_GINOSI_COLLECT); $cancellationPolicyData = ['is_refundable' => $reservationData->getIsRefundable(), 'refundable_before_hours' => $reservationData->getRefundableBeforeHours(), 'penalty_type' => $reservationData->getPenaltyType(), 'penalty_percent' => $reservationData->getPenaltyValue(), 'penalty_fixed_amount' => $reservationData->getPenaltyValue(), 'penalty_nights' => $reservationData->getPenaltyValue(), 'night_count' => \Library\Utility\Helper::getDaysFromTwoDate($reservationData->getReservationDateFrom(), $reservationData->getReservationDateTo()), 'code' => $reservationData->getCustomerCurrency()]; /** * @var WebsiteApartmentService $websiteApartmentService */ $websiteApartmentService = $this->getServiceLocator()->get('service_website_apartment'); $cancellationPolicyDescriptionArray = $websiteApartmentService->cancelationPolicy($cancellationPolicyData); $cancellationPolicyDescription = $cancellationPolicyDescriptionArray['description']; $reservationData->setCancellationPolicy($cancellationPolicyDescription); $creditCardData = $chargeAuthorizationService->getCreditCardDataForAuthorizationPage($reservationData->getCreditCardId()); if (is_null($amount)) { //for backup compatibility $amount = $chargesSummary->getSummaryInApartmentCurrency(); } $this->layout()->userTrackingInfo = ['res_number' => $reservationData->getReservationNumber(), 'partner_id' => $reservationData->getPartnerId()]; return new ViewModel(['cccaForm' => $cccaForm, 'reservationData' => $reservationData, 'creditCardData' => $creditCardData, 'chargesSummary' => $chargesSummary, 'amount' => $amount]); }
public function indexAction() { /** * @var Apartment $apartmentService */ try { if (!($pageSlug = $this->params()->fromRoute('apartmentTitle')) || !ClassicValidator::checkApartmentTitle($pageSlug)) { $viewModel = new ViewModel(); $this->getResponse()->setStatusCode(404); return $viewModel->setTemplate('error/404'); } /* @var $apartmentService \DDD\Service\Website\Apartment */ $apartmentService = $this->getApartmentService(); $apartment = $apartmentService->getApartment($pageSlug); if (!$apartment) { $this->getResponse()->setStatusCode(404); $viewModel = new ViewModel(); return $viewModel->setTemplate('error/404'); } $request = $this->getRequest(); $data = $request->getQuery(); $data['slug'] = $pageSlug; $filtreData = $apartmentService->filterQueryData($data); $reviewCount = false; if ($filtreData) { $apartment['otherParams']['arrival'] = Helper::dateForSearch($data['arrival']); $apartment['otherParams']['departure'] = Helper::dateForSearch($data['departure']); } if (isset($apartment['general']['aprtment_id'])) { $reviewCount = $apartmentService->apartmentReviewCount($apartment['general']['aprtment_id']); } $show_reviews = false; $reviews = []; $apartment['otherParams']['guest'] = (int) $data['guest']; if (isset($data['show']) && $data['show'] == 'reviews' && isset($apartment['general']['aprtment_id']) && $apartment['general']['aprtment_id'] > 0) { $show_reviews = true; $reviewsResult = $apartmentService->apartmentReviewList(['apartment_id' => $apartment['general']['aprtment_id']], true); if ($reviewsResult && $reviewsResult['result']->count() > 0) { $reviews = $reviewsResult['result']; } } } catch (\Exception $e) { $this->gr2logException($e, 'Website: Apartment Page Failed'); return $this->redirect()->toRoute('home'); } $this->layout()->setVariable('view_currency', 'yes'); return new ViewModel(['general' => $apartment['general'], 'amenities' => $apartment['amenities'], 'facilities' => $apartment['facilities'], 'otherParams' => $apartment['otherParams'], 'secure_url_booking' => 'https://' . DomainConstants::WS_SECURE_DOMAIN_NAME . '/booking', 'show_reviews' => $show_reviews, 'reviews' => $reviews, 'reviewCount' => $reviewCount, 'sl' => $this->getServiceLocator(), 'apartelId' => (int) $data['apartel_id'] > 0 ? (int) $data['apartel_id'] : 0]); }
public function __invoke($data = []) { /** * @var UserManager $userDao */ $userId = false; $result = ['boUser' => 'no']; if (isset($_COOKIE['backoffice_user'])) { $userId = (int) $_COOKIE['backoffice_user']; } if ($userId) { $userDao = $this->serviceLocator->get('dao_user_user_manager'); $userInfo = $userDao->getUserTrackingInfo($userId); if ($userInfo) { $result = ['boUser' => 'yes', 'uid' => strval($userId), 'userCity' => $userInfo['city'], 'userDept' => $userInfo['department']]; } } $router = $this->getServiceLocator()->get('application')->getMvcEvent()->getRouteMatch(); if ($router) { $action = $router->getParam('action', 'index'); $controller = $router->getParam('controller', 'index'); $controllerArray = explode("\\", $controller); $controller = strtolower(array_pop($controllerArray)); if ($controller == 'booking' && $action == 'thank-you') { $session_booking = Helper::getSessionContainer('booking'); if ($session_booking->offsetExists('reservation') && $session_booking->offsetExists('tankyou') && isset($_SERVER['HTTPS'])) { $reservation = $session_booking->reservation; $thankYou = $session_booking->tankyou; $variant = $reservation['bedroom_count'] > 0 ? $reservation['bedroom_count'] . ' ' . $this->getTextline(1446) : $this->getTextline(1190); $cityName = $this->getServiceLocator()->get('service_textline')->getCityName($reservation['city_id']); $result['page_httpResponseCode'] = "200"; $result['transactionAffiliation'] = $thankYou['partner']; $result['transaction_currency'] = "USD"; $result['transaction_subtotal_include_tax'] = "no"; $result['transactionId'] = $thankYou['res_number']; $result['transactionTotal'] = $thankYou['totalWithoutTax']; $result['transactionProducts'] = ['sku' => $reservation['prod_id'], 'name' => $reservation['prod_name'], 'category' => $cityName, 'variant' => $variant, 'price' => $thankYou['totalWithoutTax'], 'quantity' => "1"]; $result['ticketID'] = $thankYou['res_number']; $result['PartnerID'] = $data['partner_id']; } } elseif ($controller == 'key' && $action == 'index' || $controller == 'booking' && $action == 'update-cc-details' || $controller == 'review' && $action == 'index' || $controller == 'chargeauthorization' && $action == 'index') { $result['ticketID'] = $data['res_number']; $result['PartnerID'] = $data['partner_id']; } } return '<script>dataLayer = [' . json_encode($result) . '];</script>'; }
/** * @param Ticket $expenseTicket * @throws NotFoundException */ public function save(Ticket $expenseTicket) { if (!$this->getServiceLocator() instanceof ServiceLocatorInterface) { throw new NotFoundException('Service locator not defined for expense item.'); } $itemDao = $this->getItemDao(); $costDao = $this->getCostDao(); // Normalize values $this->prepare(); $data = $this->getData(); $itemAmount = null; $costCenters = []; $itemData = []; if ($this->getMode() == self::MODE_ADD) { $costCenters = $data['costCenters']; $itemAmount = $data['amount']; $itemData = ['transaction_id' => $data['transactionId'], 'account_id' => $data['accountId'], 'account_reference' => $data['accountReference'], 'sub_category_id' => $data['subCategoryId'], 'currency_id' => $data['currencyId'], 'amount' => Helper::formatAmount($itemAmount), 'is_startup' => $data['isStartup'], 'is_deposit' => $data['isDeposit'], 'is_refund' => $data['isRefund'], 'comment' => $data['accountComment'], 'type' => $data['type'], 'status' => $data['status']]; if ($data['period']['from']) { $itemData['period_from'] = $data['period']['from']; $itemData['period_to'] = $data['period']['to']; } } switch ($this->getMode()) { case self::MODE_ADD: $itemData['expense_id'] = $expenseTicket->getExpenseId(); $itemData['creator_id'] = $expenseTicket->getCreatorId(); $itemData['date_created'] = date('Y-m-d H:i:s'); if (!$data['period']['from']) { $itemData['period_from'] = $itemData['period_to'] = date('Y-m-d'); } $expenseItemId = $itemDao->save($itemData); $this->setId($expenseItemId); if (count($costCenters)) { $costCenterAmount = $itemAmount / count($costCenters); foreach ($costCenters as $costCenter) { $costDao->save(['expense_item_id' => $expenseItemId, 'cost_center_id' => $costCenter['id'], 'cost_center_type' => $this->translateCCT($costCenter['type']), 'amount' => $this->calculateCostAmount($costCenterAmount, $data['currencyId'], $costCenter['currencyId'], $data['isRefund'])]); } } break; case self::MODE_DELETE: $costDao->delete(['expense_item_id' => $this->getId()]); $itemDao->delete(['id' => $this->getId()]); break; } }
public function __construct($data, $postalCodeStatus) { $this->add(array('name' => 'first-name', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 250, 'messages' => array(StringLength::TOO_LONG => 'maximum symbols 250')))))); $this->add(array('name' => 'last-name', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 250, 'messages' => array(StringLength::TOO_LONG => 'maximum symbols 250')))))); $this->add(array('name' => 'email', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'EmailAddress', 'options' => array('useDomainCheck' => false, 'messages' => array(EmailAddress::INVALID => 'Please provide correct email address', EmailAddress::INVALID_FORMAT => 'Please provide correct formated email address')))))); if (Helper::isBackofficeUser()) { $requiredPhone = false; } else { $requiredPhone = true; // Has filtered in booking process } $this->add(array('name' => 'phone', 'required' => $requiredPhone, 'filters' => array(array('name' => 'StringTrim')))); $this->add(array('name' => 'remarks', 'required' => false, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 1000, 'messages' => array(StringLength::TOO_LONG => 'maximum symbols 1000')))))); $this->add(array('name' => 'aff-id', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'Digits', 'options' => array('messages' => array(Digits::NOT_DIGITS => 'Can contain only digits.')))))); $this->add(array('name' => 'aff-ref', 'required' => false, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 200, 'messages' => array(StringLength::TOO_LONG => 'maximum symbols 200')))))); $this->add(array('name' => 'address', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 400, 'min' => 2, 'messages' => array(StringLength::TOO_LONG => 'maximum symbols 400')))))); $this->add(array('name' => 'country', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'Digits', 'options' => array('messages' => array(Digits::NOT_DIGITS => 'Can contain only digits.')))))); $this->add(array('name' => 'city', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 100, 'messages' => array(StringLength::TOO_LONG => 'maximum symbols 100')))))); $this->add(array('name' => 'zip', 'required' => $postalCodeStatus == Location::POSTAL_CODE_REQUIRED ? true : false, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 50, 'min' => 3, 'messages' => array(StringLength::TOO_LONG => 'maximum symbols 50')))))); $isBackofficeUser = Helper::isBackofficeUser() && isset($data['noCreditCard']) ? true : false; $this->add(array('name' => 'number', 'required' => !$isBackofficeUser, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'CreditCard', 'options' => array('type' => array(CreditCard::AMERICAN_EXPRESS, CreditCard::VISA, CreditCard::MASTERCARD, CreditCard::DISCOVER, CreditCard::JCB, CreditCard::DINERS_CLUB), 'messages' => array(CreditCard::CHECKSUM => "Invalid CreditCard", CreditCard::CONTENT => "Invalid CreditCard", CreditCard::INVALID => "Invalid CreditCard", CreditCard::LENGTH => "Invalid CreditCard", CreditCard::PREFIX => "Invalid CreditCard", CreditCard::SERVICE => "Invalid CreditCard", CreditCard::SERVICEFAILURE => "Invalid CreditCard")))))); $this->add(array('name' => 'credit_card_type', 'required' => !$isBackofficeUser, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'Digits', 'options' => array('messages' => array(Digits::NOT_DIGITS => 'Can contain only digits.')))))); $this->add(array('name' => 'holder', 'required' => !$isBackofficeUser, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 300, 'messages' => array(StringLength::TOO_LONG => 'maximum symbols 300')))))); $this->add(array('name' => 'cvc', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'Digits', 'options' => array('messages' => array(Digits::NOT_DIGITS => 'Can contain only digits.'))), array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 4, 'min' => 3, 'messages' => array(StringLength::TOO_LONG => 'maximum symbols 10', StringLength::TOO_SHORT => 'minimum symbols 3')))))); $validatorYear = array('name' => 'Date', 'options' => array('format' => 'Y', 'messages' => array(Date::INVALID => 'Invalid data', Date::INVALID_DATE => 'Invalid data', Date::FALSEFORMAT => 'Invalid data'))); $validatorMonth = array('name' => 'Date', 'options' => array('format' => 'm', 'messages' => array(Date::INVALID => 'Invalid data', Date::INVALID_DATE => 'Invalid data', Date::FALSEFORMAT => 'Invalid data'))); if (!$isBackofficeUser) { $validatorYear[] = array('name' => 'Callback', 'options' => array('messages' => array(Callback::INVALID_VALUE => 'Invalid data', Callback::INVALID_CALLBACK => 'Invalid data'), 'callback' => function ($value, $context = array()) { $current = date('Y'); return $value >= $current; })); $validatorMonth[] = array('name' => 'Callback', 'options' => array('messages' => array(Callback::INVALID_VALUE => 'Invalid data', Callback::INVALID_CALLBACK => 'Invalid data'), 'callback' => function ($value, $context = array()) { if ($context['year'] == date('Y') && $value < date('m')) { return false; } return true; })); } $this->add(array('name' => 'year', 'required' => $isBackofficeUser, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array($validatorYear))); $this->add(array('name' => 'month', 'required' => $isBackofficeUser, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array($validatorMonth))); $this->add(['name' => 'apartel', 'required' => false, 'filters' => [array('name' => 'StringTrim')], 'validators' => [['name' => 'Digits', 'options' => ['messages' => [Digits::NOT_DIGITS => 'Can contain only digits.']]]]]); $this->add(array('name' => 'not_send_mail', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'Digits', 'options' => array('messages' => array(Digits::NOT_DIGITS => 'Can contain only digits.')))))); $this->add(array('name' => 'noCreditCard', 'required' => false)); }
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('/'); } }
public function feedAction() { /** * @var NewsDao $newsDao */ $newsDao = $this->getServiceLocator()->get('dao_news_news'); $newsList = $newsDao->getNewsListForFeed(); $feed = new Feed(); $feed->setTitle('Ginosi\'s News'); $feed->setLink('//www.ginosi.com'); $feed->setFeedLink('//www.ginosi.com/news/feed', 'rss'); $feed->setDateModified(time()); $feed->addHub('//pubsubhubbub.appspot.com/'); $feed->setDescription('Ginosi\'s News'); foreach ($newsList as $row) { preg_match('/<p>(.*)<\\/p>/', $row->getEn(), $matches); if (isset($matches[1]) && !is_null($matches[1])) { $desc = $matches[1]; } else { $contents = preg_split('/\\n/', $row->getEn()); $desc = $contents[0]; } $entry = $feed->createEntry(); $entry->setTitle($row->getEn_title()); $entry->setLink("//" . DomainConstants::WS_DOMAIN_NAME . "/news/" . Helper::urlForSite($row->getEn_title())); $entry->setDateModified(strtotime($row->getDate())); $entry->setDateCreated(strtotime($row->getDate())); $entry->setDescription($desc); $entry->setContent($row->getEn()); $feed->addEntry($entry); } /** * Render the resulting feed to Atom 1.0 and assign to $out. * You can substitute "atom" with "rss" to generate an RSS 2.0 feed. */ $this->getServiceLocator()->get('Application')->getEventManager()->attach(\Zend\Mvc\MvcEvent::EVENT_RENDER, function ($event) { $event->getResponse()->getHeaders()->addHeaderLine('Content-Type', 'text/xml; charset=UTF-8'); }, -10000); $feed->export('rss'); return (new FeedModel())->setFeed($feed); }
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 __invoke($options = array()) { $render = array_key_exists('render', $options) ? $options['render'] : true; $searchService = $this->getServiceLocator()->get('service_website_search'); $options = $searchService->getOptions(); $request = $this->getServiceLocator()->get('request'); $getParams = $request->getQuery(); $setParams = []; if (isset($getParams['city']) && ClassicValidator::checkCityName($getParams['city'])) { $setParams['city_url'] = $getParams['city']; $city = Helper::urlForSearch($getParams['city']); // $setParams['city'] = ; if (isset($getParams['guest'])) { $setParams['guest'] = $getParams['guest']; } $date = $searchService->getFixedDate($getParams); $setParams['arrival'] = $date['arrival']; $setParams['departure'] = $date['departure']; } $vm = new ViewModel(['options' => $options, 'setParams' => $setParams]); $vm->setTemplate($this->viewTemplate); return $render ? $this->getView()->render($vm) : $vm; }
/** * @todo: in thin method we can get also a files, that doesn't written in DB if any exists * * @param array $itemIdList * @return array */ public function getItemAttachmentListForPreview($itemIdList) { /** * @var ExpenseItemAttachments $attachmentsDao * @var \DDD\Domain\Finance\Expense\ExpenseItemAttachments $attachment */ $attachmentsDao = $this->getServiceLocator()->get('dao_finance_expense_expense_item_attachments'); $attachmentList = []; if (count($itemIdList)) { $attachmentsDomain = $attachmentsDao->getAttachmentsForPreview($itemIdList); if ($attachmentsDomain->count()) { foreach ($attachmentsDomain as $attachment) { $filePath = $this->getExpenseItemImagePath($attachment->getExpenseId(), $attachment->getItemId(), $attachment->getFilename(), $attachment->getDateCreatedNeededFormat()); if (is_readable($filePath)) { $filesize = Helper::humanFilesize(filesize($filePath)); $extension = pathinfo($attachment->getFilename(), PATHINFO_EXTENSION); $attachmentList[$attachment->getItemId()] = ['id' => $attachment->getId(), 'name' => $attachment->getFilename(), 'size' => $filesize, 'path' => $filePath, 'extension' => $extension, 'isImage' => in_array(strtolower($extension), ['png', 'jpg', 'jpeg', 'gif']) ? 1 : 0]; } } } } return $attachmentList; }
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); }
public function pullAction() { try { if (!$this->getRequest()->isXmlHttpRequest()) { return $this->redirect()->toRoute('home'); } /** * @var \DDD\Service\Notifications $notificationsService */ $notificationsService = $this->getServiceLocator()->get('service_notifications'); $auth = $this->getServiceLocator()->get('library_backoffice_auth'); $userId = $auth->getIdentity()->id; $notifications = $notificationsService->getUserNotifications($userId, false, false); $notifications = $notifications['result']; $notificationData = []; foreach ($notifications as $notification) { array_push($notificationData, ['message' => Helper::truncateNotBreakingHtmlTags($notification->getMessage()), 'url' => !is_null($notification->getUrl()) ? $notification->getUrl() : '', 'type' => $notification->getType(), 'sender' => $notification->getSender(), 'id' => $notification->getId()]); } return new JsonModel(['status' => 'success', 'data' => $notificationData]); } catch (\Exception $e) { return new JsonModel(['status' => 'success', 'msg' => TextConstants::ERROR]); } }
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]); }