作者:arb
项目:MyCod
/**
* @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']);
}
}
作者:arb
项目:MyCod
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);
}
作者:arb
项目:MyCod
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);
}
作者:arb
项目:MyCod
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());
}
}
作者:arb
项目:MyCod
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()]);
}
}
作者:arb
项目:MyCod
/**
* 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" => "test@ginosi.com", "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');
}
作者:arb
项目:MyCod
/**
* @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;
}
作者:arb
项目:MyCod
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");
}
作者:arb
项目:MyCod
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);
}
作者:arb
项目:MyCod
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);
}
}
作者:arb
项目:MyCod
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);
}
作者:arb
项目:MyCod
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];
}
作者:arb
项目:MyCod
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);
}
作者:arb
项目:MyCod
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;
}
作者:arb
项目:MyCod
/**
* @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];
}
作者:arb
项目:MyCod
/**
*
* @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;
}
作者:arb
项目:MyCod
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]);
}
作者:arb
项目:MyCod
/**
* @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]);
}
作者:arb
项目:MyCod
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]);
}
作者:arb
项目:MyCod
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>';
}