Merge branch 'develop' into gli-2939
This commit is contained in:
@@ -90,6 +90,14 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs'
|
||||
),
|
||||
'id_order' => array(
|
||||
'title' => $this->l('ID Order'),
|
||||
'filter_key' => 'a!id_order',
|
||||
'align' => 'center',
|
||||
'optional' => true,
|
||||
'callback' => 'getOrderLink',
|
||||
'visible_default' => true,
|
||||
),
|
||||
'customer' => array(
|
||||
'title' => $this->l('Customer'),
|
||||
'filter_key' => 'customer',
|
||||
@@ -172,13 +180,6 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
'type' => 'datetime',
|
||||
'optional' => true,
|
||||
),
|
||||
'id_order' => array(
|
||||
'title' => $this->l('ID Order'),
|
||||
'filter_key' => 'a!id_order',
|
||||
'optional' => false,
|
||||
'visible_default' => false,
|
||||
'displayed' => false,
|
||||
),
|
||||
);
|
||||
|
||||
$this->bulk_actions = array(
|
||||
@@ -346,6 +347,14 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
|
||||
return $customer;
|
||||
}
|
||||
public function getOrderLink($order, $tr)
|
||||
{
|
||||
if ($tr['id_order']) {
|
||||
return '<a href="'.$this->context->link->getAdminLink('AdminOrders').'&vieworder&id_order='.$tr['id_order'].'">'.'#'.$order.'</a>';
|
||||
}else{
|
||||
return '--';
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
@@ -976,6 +985,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
'count_ok' => isset($orders_ok) ? count($orders_ok) : false,
|
||||
'PS_CUSTOMER_SERVICE_SIGNATURE' => str_replace('\r\n', "\n", Configuration::get('PS_CUSTOMER_SERVICE_SIGNATURE', (int)$thread->id_lang)),
|
||||
'timeline_items' => $timeline_items,
|
||||
'can_edit' => $this->tabAccess['edit'],
|
||||
);
|
||||
|
||||
return parent::renderView();
|
||||
|
||||
@@ -2835,7 +2835,8 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $customer);
|
||||
if ($customer->passwd) {
|
||||
$customer->passwd = Tools::encrypt($customer->passwd);
|
||||
$objHash = new PasswordHashing();
|
||||
$customer->passwd = $objHash->passwordHash($customer->passwd);
|
||||
}
|
||||
|
||||
$customers_shop = array();
|
||||
@@ -3223,7 +3224,25 @@ class AdminImportControllerCore extends AdminController
|
||||
|
||||
public function utf8EncodeArray($array)
|
||||
{
|
||||
return (is_array($array) ? array_map('utf8_encode', $array) : mb_convert_encoding($array, 'UTF-8', 'ISO-8859-1'));
|
||||
if (is_array($array)) {
|
||||
return array_map(function ($value) {
|
||||
if (is_array($value)) {
|
||||
return $this->utf8EncodeArray($value);
|
||||
}
|
||||
|
||||
if (!is_string($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return mb_convert_encoding($value, 'UTF-8', 'ISO-8859-1');
|
||||
}, $array);
|
||||
}
|
||||
|
||||
if (!is_string($array)) {
|
||||
return $array;
|
||||
}
|
||||
|
||||
return mb_convert_encoding($array, 'UTF-8', 'ISO-8859-1');
|
||||
}
|
||||
|
||||
protected function getNbrColumn($handle, $glue)
|
||||
|
||||
@@ -263,7 +263,8 @@ class AdminLoginControllerCore extends AdminController
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$pwd = Tools::passwdGen(10, 'RANDOM');
|
||||
$employee->passwd = Tools::encrypt($pwd);
|
||||
$objHash = new PasswordHashing();
|
||||
$employee->passwd = $objHash->passwordHash($pwd);
|
||||
$employee->last_passwd_gen = date('Y-m-d H:i:s', time());
|
||||
|
||||
$params = array(
|
||||
|
||||
@@ -51,25 +51,31 @@ class AdminModulesCatalogControllerCore extends AdminController
|
||||
parent::initContent();
|
||||
|
||||
$suggestedModules = Module::getSuggestedModules();
|
||||
$modulesDirOnDisk = Module::getModulesDirOnDisk();
|
||||
$localModuleNames = array();
|
||||
|
||||
$modulesToAdd = array();
|
||||
$dirModules = ModuleCore::getModulesOnDisk();
|
||||
$modules_name = array_column($suggestedModules, 'name');
|
||||
foreach ($dirModules as $mod) {
|
||||
if (($id = array_search($mod->name, $modules_name)) !== false) {
|
||||
if ($mod->installed) {
|
||||
unset($suggestedModules[$id]);
|
||||
} else {
|
||||
$suggestedModules[$id]->not_on_disk = false;
|
||||
}
|
||||
} else {
|
||||
if (!$mod->installed) {
|
||||
$modulesToAdd[] = $mod;
|
||||
}
|
||||
}
|
||||
foreach ($modulesDirOnDisk as $moduleName) {
|
||||
$localModuleNames[Tools::strtolower($moduleName)] = true;
|
||||
}
|
||||
|
||||
$modules = array_merge($suggestedModules, $modulesToAdd);
|
||||
$modules = array();
|
||||
|
||||
foreach ($suggestedModules as $suggestedModule) {
|
||||
$moduleName = Tools::strtolower($suggestedModule->name);
|
||||
if (isset($localModuleNames[$moduleName])) {
|
||||
continue;
|
||||
}
|
||||
if (!empty($suggestedModule->compatibility)) {
|
||||
$minVersion = isset($suggestedModule->compatibility['from']) ? $suggestedModule->compatibility['from'] : null;
|
||||
$maxVersion = isset($suggestedModule->compatibility['to']) ? $suggestedModule->compatibility['to'] : null;
|
||||
|
||||
if (($minVersion && version_compare(_QLOAPPS_VERSION_, $minVersion, '<')) || ($maxVersion && version_compare(_QLOAPPS_VERSION_, $maxVersion, '>'))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$modules[] = $suggestedModule;
|
||||
}
|
||||
|
||||
$link_admin_modules = $this->context->link->getAdminLink('AdminModules', true);
|
||||
foreach ($modules as $key => $module) {
|
||||
|
||||
@@ -624,21 +624,57 @@ class AdminModulesControllerCore extends AdminController
|
||||
public function postProcessEnable()
|
||||
{
|
||||
if ($this->tabAccess['edit'] === 1) {
|
||||
$module = Module::getInstanceByName(Tools::getValue('module_name'));
|
||||
if (Validate::isLoadedObject($module)) {
|
||||
|
||||
$moduleNames = array_unique(array_filter(
|
||||
explode('|', strip_tags((string) Tools::getValue('module_name')))
|
||||
));
|
||||
|
||||
$enable = Tools::getValue('enable');
|
||||
|
||||
if (empty($moduleNames)) {
|
||||
$this->errors[] = Tools::displayError('You must select at least one module.');
|
||||
return;
|
||||
}
|
||||
$modules = array();
|
||||
|
||||
foreach ($moduleNames as $moduleName) {
|
||||
if (!Validate::isModuleName($moduleName)) {
|
||||
$this->errors[] = Tools::displayError('Invalid module name ') . ': ' . $moduleName;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Module::isInstalled($moduleName)) {
|
||||
$this->errors[] = Tools::displayError('This module is not installed ') . ': ' . $moduleName;
|
||||
continue;
|
||||
}
|
||||
|
||||
$module = Module::getInstanceByName($moduleName);
|
||||
if (!Validate::isLoadedObject($module)) {
|
||||
$this->errors[] = Tools::displayError('Cannot load the module\'s object ') . ': ' . $moduleName;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$module->getPermission('configure')) {
|
||||
$this->errors[] = Tools::displayError('You do not have the permission to use this module.');
|
||||
} else {
|
||||
if (Tools::getValue('enable')) {
|
||||
$this->errors[] = Tools::displayError('You do not have the permission to use this module ') . ': ' . $module->displayName;
|
||||
continue;
|
||||
}
|
||||
|
||||
$modules[] = $module;
|
||||
}
|
||||
|
||||
if (empty($this->errors)) {
|
||||
foreach ($modules as $module) {
|
||||
if ($enable) {
|
||||
$module->enable();
|
||||
} else {
|
||||
$module->disable();
|
||||
}
|
||||
Tools::redirectAdmin($this->getCurrentUrl('enable'));
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Cannot load the module\'s object.');
|
||||
|
||||
|
||||
Tools::redirectAdmin($this->getCurrentUrl(array('enable','conf')).'&conf='.($enable ? 33 : 34));
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You do not have permission to add this.');
|
||||
}
|
||||
@@ -1449,8 +1485,8 @@ class AdminModulesControllerCore extends AdminController
|
||||
$modules_preferences[$v['module']] = $v;
|
||||
}
|
||||
|
||||
// Retrieve Modules List
|
||||
$modules = Module::getInstalledModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
|
||||
// Retrieve Modules List (installed + disabled + uninstalled)
|
||||
$modules = Module::getModulesOnDisk(true, $this->logged_on_addons, $this->id_employee);
|
||||
$this->initModulesList($modules);
|
||||
$this->nb_modules_total = count($modules);
|
||||
$module_errors = array();
|
||||
|
||||
@@ -368,6 +368,54 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'icon' => 'process-icon-new'
|
||||
);
|
||||
}
|
||||
if ($this->display == 'view') {
|
||||
/** @var Order $order */
|
||||
if (Validate::isLoadedObject($order = $this->loadObject())) {
|
||||
// hotel link in header
|
||||
if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id)) {
|
||||
$this->page_header_toolbar_btn['hotel'] = array(
|
||||
'href' => $this->context->link->getAdminLink('AdminAddHotel').'&id='.$idHotel.'&updatehtl_branch_info',
|
||||
'desc' => $this->l('View Hotel'),
|
||||
'class' => 'icon-building',
|
||||
'target' => true,
|
||||
);
|
||||
}
|
||||
|
||||
if (Configuration::get('PS_INVOICE') && $order->hasInvoice() && !$this->lite_display) {
|
||||
$this->page_header_toolbar_btn['file'] = array(
|
||||
'short' => $this->l('Invoice'),
|
||||
'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateInvoicePDF&id_order='.$order->id,
|
||||
'desc' => $this->l('View invoice'),
|
||||
'class' => 'icon-file-text',
|
||||
'target' => true,
|
||||
);
|
||||
}
|
||||
|
||||
$this->page_header_toolbar_btn['print'] = array(
|
||||
'short' => $this->l('Print'),
|
||||
'href' => 'javascript:window.print()',
|
||||
'desc' => $this->l('Print order'),
|
||||
'class' => 'icon-print',
|
||||
);
|
||||
|
||||
if ($this->tabAccess['edit'] === 1) {
|
||||
if (((int) $order->isReturnable())
|
||||
&& !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG, 0, 0)
|
||||
) {
|
||||
$orderTotalPaid = $order->getTotalPaid();
|
||||
$orderDiscounts = $order->getCartRules();
|
||||
$hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false;
|
||||
$this->page_header_toolbar_btn['cancel'] = array(
|
||||
'short' => ($hasOrderDiscountOrPayment) ? $this->l('Refund') : $this->l('Cancel'),
|
||||
'id' => 'desc-order-standard_refund',
|
||||
'desc' => ($hasOrderDiscountOrPayment) ? $this->l('Initiate refund') : $this->l('Cancel bookings'),
|
||||
'class' => 'icon-exchange',
|
||||
'target' => true,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent::initPageHeaderToolbar();
|
||||
}
|
||||
@@ -439,13 +487,13 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'advance_payment_amount_without_tax' => $cart->getOrderTotal(false, Cart::ADVANCE_PAYMENT),
|
||||
'advance_payment_amount_with_tax' => $cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT),
|
||||
'cart' => $cart,
|
||||
'customer' => $cart->id_customer ? new Customer($cart->id_customer): null ,
|
||||
'currencies' => Currency::getCurrenciesByIdShop(Context::getContext()->shop->id),
|
||||
'langs' => Language::getLanguages(true, Context::getContext()->shop->id),
|
||||
'payment_modules' => $payment_modules,
|
||||
'payment_types' => $paymentTypes,
|
||||
'PAYMENT_TYPE_PAY_AT_HOTEL' => OrderPayment::PAYMENT_TYPE_PAY_AT_HOTEL,
|
||||
'currency' => new Currency((int)$cart->id_currency),
|
||||
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
|
||||
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
|
||||
'occupancy_required_for_booking' => $occupancyRequiredForBooking,
|
||||
));
|
||||
@@ -478,55 +526,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
if ($this->display == 'view') {
|
||||
/** @var Order $order */
|
||||
if (Validate::isLoadedObject($order = $this->loadObject())) {
|
||||
// hotel link in header
|
||||
if ($idHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id)) {
|
||||
$this->toolbar_btn['hotel'] = array(
|
||||
'href' => $this->context->link->getAdminLink('AdminAddHotel').'&id='.$idHotel.'&updatehtl_branch_info',
|
||||
'desc' => $this->l('View Hotel'),
|
||||
'class' => 'icon-building',
|
||||
'target' => true,
|
||||
);
|
||||
}
|
||||
|
||||
if (Configuration::get('PS_INVOICE') && $order->hasInvoice() && !$this->lite_display) {
|
||||
$this->toolbar_btn['file'] = array(
|
||||
'short' => $this->l('Invoice'),
|
||||
'href' => $this->context->link->getAdminLink('AdminPdf').'&submitAction=generateInvoicePDF&id_order='.$order->id,
|
||||
'desc' => $this->l('View invoice'),
|
||||
'class' => 'icon-file-text',
|
||||
'target' => true,
|
||||
);
|
||||
}
|
||||
|
||||
$this->toolbar_btn['print'] = array(
|
||||
'short' => $this->l('Print'),
|
||||
'href' => 'javascript:window.print()',
|
||||
'desc' => $this->l('Print order'),
|
||||
'class' => 'icon-print',
|
||||
);
|
||||
|
||||
if ($this->tabAccess['edit'] === 1) {
|
||||
if (((int) $order->isReturnable())
|
||||
&& !$order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG, 0, 0)
|
||||
) {
|
||||
$orderTotalPaid = $order->getTotalPaid();
|
||||
$orderDiscounts = $order->getCartRules();
|
||||
$hasOrderDiscountOrPayment = ((float)$orderTotalPaid > 0 || $orderDiscounts) ? true : false;
|
||||
$this->toolbar_btn['cancel'] = array(
|
||||
'short' => ($hasOrderDiscountOrPayment) ? $this->l('Refund') : $this->l('Cancel'),
|
||||
'id' => 'desc-order-standard_refund',
|
||||
'desc' => ($hasOrderDiscountOrPayment) ? $this->l('Initiate refund') : $this->l('Cancel bookings'),
|
||||
'class' => 'icon-exchange',
|
||||
'target' => true,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$res = parent::initToolbar();
|
||||
if (Context::getContext()->shop->getContext() != Shop::CONTEXT_SHOP && isset($this->toolbar_btn['new']) && Shop::isFeatureActive()) {
|
||||
unset($this->toolbar_btn['new']);
|
||||
@@ -788,6 +787,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'order' => $objOrder,
|
||||
'current_index' => self::$currentIndex,
|
||||
'hotel_order_status' => $htlOrderStatus,
|
||||
'ROOM_STATUS_ALLOTED' => HotelBookingDetail::STATUS_ALLOTED,
|
||||
'current_room_status' => Tools::getValue('current_room_status')
|
||||
)
|
||||
);
|
||||
$modal = array(
|
||||
@@ -1277,6 +1278,68 @@ class AdminOrdersControllerCore extends AdminController
|
||||
die(Tools::jsonEncode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessInitDeleteRoomBookingModal()
|
||||
{
|
||||
if ($this->tabAccess['edit'] !== 1) {
|
||||
die(Tools::jsonEncode(array(
|
||||
'hasError' => 1,
|
||||
'error' => Tools::displayError('You do not have permission to edit this order.')
|
||||
)));
|
||||
}
|
||||
|
||||
// set modal details
|
||||
$response['hasError'] = 1;
|
||||
$id_order = (int) Tools::getValue('id_order');
|
||||
$idProduct = (int) Tools::getValue('id_product');
|
||||
$idOrderDetail = (int) Tools::getValue('id_order_detail');
|
||||
$idRoom = (int) Tools::getValue('id_room');
|
||||
$idHtlBooking = (int) Tools::getValue('id_htl_booking');
|
||||
$idHotel = (int) Tools::getValue('id_hotel');
|
||||
$dateFrom = (string) Tools::getValue('date_from');
|
||||
$dateTo = (string) Tools::getValue('date_to');
|
||||
|
||||
if ($id_order
|
||||
&& $idProduct
|
||||
&& $idOrderDetail
|
||||
&& $idRoom
|
||||
&& $idHtlBooking
|
||||
&& $idHotel
|
||||
&& $dateFrom
|
||||
&& $dateTo
|
||||
) {
|
||||
if (!Validate::isDate($dateFrom) || !Validate::isDate($dateTo)) {
|
||||
die(Tools::jsonEncode(array(
|
||||
'hasError' => 1,
|
||||
'error' => Tools::displayError('Invalid date range.')
|
||||
)));
|
||||
}
|
||||
|
||||
$smartyVars = array(
|
||||
'id_product' => $idProduct,
|
||||
'id_order_detail' => $idOrderDetail,
|
||||
'id_room' => $idRoom,
|
||||
'date_from' => $dateFrom,
|
||||
'date_to' => $dateTo,
|
||||
'id_htl_booking' => $idHtlBooking,
|
||||
'id_hotel' => $idHotel,
|
||||
'id_order' => $id_order,
|
||||
);
|
||||
$this->context->smarty->assign($smartyVars);
|
||||
$modal = array(
|
||||
'modal_id' => 'delete-room-booking-modal',
|
||||
'modal_class' => 'modal-md order_detail_modal',
|
||||
'modal_title' => '<i class="icon icon-bed"></i>  '.$this->l('Delete Room'),
|
||||
'modal_content' => $this->context->smarty->fetch('controllers/orders/modals/_delete_room_booking.tpl'),
|
||||
);
|
||||
$this->context->smarty->assign($modal);
|
||||
$response['hasError'] = 0;
|
||||
$response['modalHtml'] = $this->context->smarty->fetch('modal.tpl');
|
||||
} else {
|
||||
$response['error'] = Tools::displayError('Invalid data.');
|
||||
}
|
||||
die(Tools::jsonEncode($response));
|
||||
}
|
||||
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
@@ -1559,7 +1622,23 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
if (!count($this->errors)) {
|
||||
// Finally, reallocate the room
|
||||
if ($objBookingDetail->reallocateBooking($idHtlBookingFrom, $idRoomToReallocate, $priceDiff)) {
|
||||
if ($objBookingDetail->reallocateBooking($idHtlBookingFrom, $idRoomToReallocate, $priceDiff)) {
|
||||
$order = new Order((int) $idOrder);
|
||||
$fromRoomType = Product::getProductName($objHotelBooking->id_product, null, $this->context->language->id);
|
||||
$toRoomType = Product::getProductName($objRoomInfo->id_product, null, $this->context->language->id);
|
||||
$dateFrom = date('d/m/Y', strtotime($objHotelBooking->date_from));
|
||||
$dateTo = date('d/m/Y', strtotime($objHotelBooking->date_to));
|
||||
$autoMsg = $this->l('Room Reallocate').': '.$objHotelBooking->room_num.' - '.$fromRoomType.' '.$this->l('to').' '.$objRoomInfo->room_num.' - '.$toRoomType.': ('.$dateFrom.' - '.$dateTo.')';
|
||||
$userRemark = Tools::getValue('message');
|
||||
$noteMessage = $autoMsg.($userRemark && Validate::isMessage($userRemark) ? ' | '.$this->l('Remark').': '.$userRemark : '');
|
||||
$message = new Message();
|
||||
$message->message = $noteMessage;
|
||||
$message->id_cart = (int)$order->id_cart;
|
||||
$message->id_customer = (int)$order->id_customer;
|
||||
$message->id_order = (int)$idOrder;
|
||||
$message->id_employee = (int)$this->context->employee->id;
|
||||
$message->private = 1;
|
||||
$message->save();
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $idOrder.'&vieworder&conf=52&token='.$this->token);
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some error occured. Please try again.');
|
||||
@@ -1601,7 +1680,22 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
if ($objBookingDetail->swapBooking($idHtlBookingFrom, $idHtlBookingToSwap)) {
|
||||
if ($objBookingDetail->swapBooking($idHtlBookingFrom, $idHtlBookingToSwap)) {
|
||||
$order = new Order((int) $idOrder);
|
||||
$room1Type = Product::getProductName($objHotelBooking->id_product, null, $this->context->language->id);
|
||||
$dateFrom = date('d/m/Y', strtotime($objHotelBooking->date_from));
|
||||
$dateTo = date('d/m/Y', strtotime($objHotelBooking->date_to));
|
||||
$autoMsg = $this->l('Room Swap').': ('.$room1Type.') '.$objHotelBooking->room_num.' '.$this->l('with').' '.$objHotelBookingTo->room_num.': ('.$dateFrom.' - '.$dateTo.')';
|
||||
$userRemark = Tools::getValue('message');
|
||||
$noteMessage = $autoMsg.($userRemark && Validate::isMessage($userRemark) ? ' | '.$this->l('Remark').': '.$userRemark : '');
|
||||
$message = new Message();
|
||||
$message->message = $noteMessage;
|
||||
$message->id_cart = (int)$order->id_cart;
|
||||
$message->id_customer = (int)$order->id_customer;
|
||||
$message->id_order = (int)$idOrder;
|
||||
$message->id_employee = (int)$this->context->employee->id;
|
||||
$message->private = 1;
|
||||
$message->save();
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int)$idOrder.'&vieworder&conf=53&token='.$this->token);
|
||||
} else {
|
||||
$this->errors[] = $this->l('Some error occured. Please try again.');
|
||||
@@ -1747,7 +1841,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($customer->email, $order->id);
|
||||
if (!$id_customer_thread) {
|
||||
$customer_thread = new CustomerThread();
|
||||
$customer_thread->id_contact = (int)Configuration::get('PS_MAIL_EMAIL_MESSAGE');
|
||||
$customer_thread->id_contact = (int)Configuration::get('PS_CUSTOMER_SERVICE_CONTACT');
|
||||
$customer_thread->id_customer = (int)$order->id_customer;
|
||||
$customer_thread->user_name = $customer->firstname.' '.$customer->lastname;
|
||||
$customer_thread->phone = $customer->phone;
|
||||
@@ -1763,7 +1857,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
} else {
|
||||
$customer_thread = new CustomerThread((int)$id_customer_thread);
|
||||
}
|
||||
|
||||
$customer_message = new CustomerMessage();
|
||||
$customer_message->id_customer_thread = $customer_thread->id;
|
||||
$customer_message->id_employee = (int)$this->context->employee->id;
|
||||
@@ -1787,7 +1880,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'{order_name}' => $order->getUniqReference(),
|
||||
'{message}' => $message
|
||||
);
|
||||
if (@Mail::Send(
|
||||
Mail::Send(
|
||||
(int)$order->id_lang,
|
||||
'order_merchant_comment',
|
||||
Mail::l('New message regarding your booking', (int)$order->id_lang),
|
||||
@@ -1801,11 +1894,10 @@ class AdminOrdersControllerCore extends AdminController
|
||||
_PS_MAIL_DIR_,
|
||||
true,
|
||||
(int)$order->id_shop
|
||||
)) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=11'.'&token='.$this->token);
|
||||
}
|
||||
);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int)$order->id.'&vieworder&conf=11&token='.$this->token);
|
||||
}
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
|
||||
Tools::dieOrLog(Tools::displayError('An error occurred while sending an email to the customer.'),false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -3114,9 +3206,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$this->kpis[] = $helper;
|
||||
}
|
||||
|
||||
Hook::exec('action'.$this->controller_name.'KPIListingModifier', array(
|
||||
'kpis' => &$kpis,
|
||||
));
|
||||
|
||||
return parent::renderKpis();
|
||||
}
|
||||
@@ -3584,7 +3673,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$objCustomerThread = new CustomerThread();
|
||||
$messages = Message::getMessagesByOrderId($order->id, true);
|
||||
$messages = Message::getMessagesByOrderId($order->id, null);
|
||||
if ($customerMessages = CustomerMessage::getMessagesByOrderId($order->id, true)) {
|
||||
foreach ($messages as $messageKey => $message) {
|
||||
foreach ($customerMessages as $customerMessageKey => $customerMessage) {
|
||||
@@ -3594,10 +3683,11 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
$messages = array_merge($customerMessages, $messages);
|
||||
usort($messages, function ($a, $b) {
|
||||
return strtotime($a['date_add']) < strtotime($b['date_add']);
|
||||
});
|
||||
if($messages = array_merge($customerMessages, $messages)){
|
||||
usort($messages, function ($a, $b) {
|
||||
return (strtotime($a['date_add']) < strtotime($b['date_add'])) ? 1 : -1;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// send hotel standalone and standalone products
|
||||
@@ -3628,7 +3718,6 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'htl_booking_order_data' => $bookingOrderInfo,
|
||||
'hotel_order_status' => $htlOrderStatus,
|
||||
'order_detail_data' => $order_detail_data,
|
||||
'max_child_in_room' => Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'),
|
||||
'max_child_age' => Configuration::get('WK_GLOBAL_CHILD_MAX_AGE'),
|
||||
'hotel_service_products' => $orderHotelServiceProducts,
|
||||
'standalone_service_products' => $orderStandaloneServiceProducts,
|
||||
@@ -3713,6 +3802,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'ROOM_STATUS_CHECKED_OUT' => HotelBookingDetail::STATUS_CHECKED_OUT,
|
||||
'ALLOTMENT_MANUAL' => HotelBookingDetail::ALLOTMENT_MANUAL,
|
||||
'order_convenience_fee_services' => $orderConvenienceFeeServices,
|
||||
'page_header_toolbar_btn' => $this->page_header_toolbar_btn,
|
||||
);
|
||||
|
||||
return parent::renderView();
|
||||
@@ -5140,7 +5230,22 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order->total_discounts_tax_incl += (float)abs($cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS));
|
||||
|
||||
// Save changes of order
|
||||
$order->update();
|
||||
if($order->update()){
|
||||
$roomType = Product::getProductName($product->id, null, $this->context->language->id);
|
||||
$dateFromFormatted = date('d/m/Y', strtotime($date_from));
|
||||
$dateToFormatted = date('d/m/Y', strtotime($date_to));
|
||||
$autoMsg = $this->l('Room Add').': '.$roomType.': ('.$dateFromFormatted.' - '.$dateToFormatted.')';
|
||||
$userRemark = Tools::getValue('message');
|
||||
$noteMessage = $autoMsg.($userRemark && Validate::isMessage($userRemark) ? ' | '.$this->l('Remark').': '.$userRemark : '');
|
||||
$message = new Message();
|
||||
$message->message = $noteMessage;
|
||||
$message->id_cart = (int)$this->context->cart->id;
|
||||
$message->id_customer = (int)$this->context->cart->id_customer;
|
||||
$message->id_order = (int)$order->id;
|
||||
$message->id_employee = (int)$this->context->employee->id;
|
||||
$message->private = 1;
|
||||
$message->save();
|
||||
}
|
||||
|
||||
// Update weight SUM
|
||||
$order_carrier = new OrderCarrier((int)$order->getIdOrderCarrier());
|
||||
@@ -6200,7 +6305,24 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$order->total_paid = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_incl = Tools::ps_round($order->getOrderTotal(), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->total_paid_tax_excl = Tools::ps_round($order->getOrderTotal(false), _PS_PRICE_COMPUTE_PRECISION_);
|
||||
$order->save();
|
||||
if($order->save()){
|
||||
$roomType = Product::getProductName($id_product, null, $this->context->language->id);
|
||||
$oldDateFromFormatted = date('d/m/Y', strtotime($old_date_from));
|
||||
$oldDateToFormatted = date('d/m/Y', strtotime($old_date_to));
|
||||
$newDateFromFormatted = date('d/m/Y', strtotime($new_date_from));
|
||||
$newDateToFormatted = date('d/m/Y', strtotime($new_date_to));
|
||||
$autoMsg = $this->l('Room Edit').': '.$obj_booking_detail->room_num.' - '.$roomType.': ('.$oldDateFromFormatted.' - '.$oldDateToFormatted.')';
|
||||
$userRemark = Tools::getValue('message');
|
||||
$noteMessage = $autoMsg.($userRemark && Validate::isMessage($userRemark) ? ' | '.$this->l('Remark').': '.$userRemark : '');
|
||||
$message = new Message();
|
||||
$message->message = $noteMessage;
|
||||
$message->id_cart = (int)$this->context->cart->id;
|
||||
$message->id_customer = (int)$this->context->cart->id_customer;
|
||||
$message->id_order = (int)$order->id;
|
||||
$message->id_employee = (int)$this->context->employee->id;
|
||||
$message->private = 1;
|
||||
$message->save();
|
||||
}
|
||||
|
||||
// Save order invoice
|
||||
if (isset($order_invoice) && $order_invoice instanceof OrderInvoice) {
|
||||
@@ -6360,7 +6482,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
public function ajaxProcessDeleteRoomLine()
|
||||
{
|
||||
// Check tab access is allowed to edit
|
||||
if (!$this->tabAccess['edit'] === 1) {
|
||||
if ($this->tabAccess['edit'] !== 1) {
|
||||
die(json_encode(array(
|
||||
'result' => false,
|
||||
'error' => Tools::displayError('You do not have permission to edit this order.')
|
||||
@@ -6639,7 +6761,22 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$objBookingDetail->id_order
|
||||
);
|
||||
|
||||
$objBookingDetail->delete();
|
||||
if($objBookingDetail->delete()){
|
||||
$roomType = Product::getProductName($objBookingDetail->id_product, null, $this->context->language->id);
|
||||
$dateFrom = date('d/m/Y', strtotime($objBookingDetail->date_from));
|
||||
$dateTo = date('d/m/Y', strtotime($objBookingDetail->date_to));
|
||||
$autoMsg = $this->l('Room Delete').': '.$objBookingDetail->room_num.' - '.$roomType.': ('.$dateFrom.' - '.$dateTo.')';
|
||||
$userRemark = Tools::getValue('message');
|
||||
$noteMessage = $autoMsg.($userRemark && Validate::isMessage($userRemark) ? ' | '.$this->l('Remark').': '.$userRemark : '');
|
||||
$message = new Message();
|
||||
$message->message = $noteMessage;
|
||||
$message->id_cart = (int)$objBookingDetail->id_cart;
|
||||
$message->id_customer = (int)$order->id_customer;
|
||||
$message->id_order = (int)$order->id;
|
||||
$message->id_employee = (int)$this->context->employee->id;
|
||||
$message->private = 1;
|
||||
$message->save();
|
||||
}
|
||||
|
||||
// delete refund request of the room if exists.
|
||||
OrderReturnDetail::deleteReturnDetailByIdBookingDetail($id_order, $idHotelBooking);
|
||||
@@ -7470,7 +7607,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = Tools::displayError('Invalid quantity provided for service').': '.$objServiceProductOrderDetail->name;
|
||||
}
|
||||
} elseif ($serviceQuantities[$idRoomTypeServiceProductOrderDetail] > 1) {
|
||||
} elseif (is_array($serviceQuantities) && isset($serviceQuantities[$idRoomTypeServiceProductOrderDetail]) && $serviceQuantities[$idRoomTypeServiceProductOrderDetail] > 1) {
|
||||
$response['hasError'] = true;
|
||||
$response['errors'][] = Tools::displayError('Can not order multiple quanitity for service').': '.$objServiceProductOrderDetail->name;
|
||||
}
|
||||
@@ -7491,7 +7628,11 @@ class AdminOrdersControllerCore extends AdminController
|
||||
$result = true;
|
||||
foreach ($selectedServicesOrderDetails as $idRoomTypeServiceProductOrderDetail) {
|
||||
$objServiceProductOrderDetail = new ServiceProductOrderDetail($idRoomTypeServiceProductOrderDetail);
|
||||
$quantity = $serviceQuantities[$idRoomTypeServiceProductOrderDetail];
|
||||
if(is_array($serviceQuantities) && isset($serviceQuantities[$idRoomTypeServiceProductOrderDetail])) {
|
||||
$quantity = (int)$serviceQuantities[$idRoomTypeServiceProductOrderDetail];
|
||||
} else {
|
||||
$quantity = 1;
|
||||
}
|
||||
$unitPrice = $serviceUnitPrices[$idRoomTypeServiceProductOrderDetail];
|
||||
|
||||
$objHotelBookingDetail = new HotelBookingDetail($objServiceProductOrderDetail->id_htl_booking_detail);
|
||||
@@ -8698,30 +8839,49 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
|
||||
if (empty($this->errors)) {
|
||||
$objHotelBookingDetail->id_status = $newStatus;
|
||||
if ($newStatus == HotelBookingDetail::STATUS_CHECKED_IN) {
|
||||
$objHotelBookingDetail->check_in = $statusDate;
|
||||
} elseif ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT) {
|
||||
$objHotelBookingDetail->check_out = $statusDate;
|
||||
} else {
|
||||
$objHotelBookingDetail->check_in = '';
|
||||
$objHotelBookingDetail->check_out = '';
|
||||
}
|
||||
if ($objHotelBookingDetail->save()) {
|
||||
Hook::exec(
|
||||
'actionRoomBookingStatusUpdateAfter',
|
||||
array(
|
||||
'id_hotel_booking_detail' => $objHotelBookingDetail->id,
|
||||
'id_order' => $objHotelBookingDetail->id_order,
|
||||
'id_room' => $objHotelBookingDetail->id_room,
|
||||
'date_from' => $objHotelBookingDetail->date_from,
|
||||
'date_to' => $objHotelBookingDetail->date_to
|
||||
)
|
||||
);
|
||||
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_order='.(int) $objHotelBookingDetail->id_order.'&vieworder&token='.$this->token.'&conf=4');
|
||||
$id_order = $objHotelBookingDetail->id_order;
|
||||
$order = new Order($id_order);
|
||||
$remainingCheckoutRooms = 0;
|
||||
if ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT) {
|
||||
$orderBookings = $objHotelBookingDetail->getOrderCurrentDataByOrderId(
|
||||
$id_order,
|
||||
array(HotelBookingDetail::STATUS_ALLOTED, HotelBookingDetail::STATUS_CHECKED_IN),
|
||||
0,
|
||||
0
|
||||
);
|
||||
$remainingCheckoutRooms = count($orderBookings);
|
||||
}
|
||||
$hasPendingBills = $order->getTotalPaid() < $order->getOrderTotal();
|
||||
|
||||
if ($remainingCheckoutRooms == 1 && $newStatus == HotelBookingDetail::STATUS_CHECKED_OUT && $hasPendingBills) {
|
||||
$this->errors[] = Tools::displayError('You cannot checkout the last room while there are pending bills for this order.');
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Some error occurred. Please try again.');
|
||||
$objHotelBookingDetail->id_status = $newStatus;
|
||||
if ($newStatus == HotelBookingDetail::STATUS_CHECKED_IN) {
|
||||
$objHotelBookingDetail->check_in = $statusDate;
|
||||
} elseif ($newStatus == HotelBookingDetail::STATUS_CHECKED_OUT) {
|
||||
$objHotelBookingDetail->check_out = $statusDate;
|
||||
} else {
|
||||
$objHotelBookingDetail->check_in = '';
|
||||
$objHotelBookingDetail->check_out = '';
|
||||
}
|
||||
if ($objHotelBookingDetail->save()) {
|
||||
Hook::exec(
|
||||
'actionRoomBookingStatusUpdateAfter',
|
||||
array(
|
||||
'id_hotel_booking_detail' => $objHotelBookingDetail->id,
|
||||
'id_order' => $objHotelBookingDetail->id_order,
|
||||
'id_room' => $objHotelBookingDetail->id_room,
|
||||
'date_from' => $objHotelBookingDetail->date_from,
|
||||
'date_to' => $objHotelBookingDetail->date_to
|
||||
)
|
||||
);
|
||||
|
||||
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . (int) $objHotelBookingDetail->id_order . '&vieworder&token=' . $this->token . '&conf=4');
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Some error occurred. Please try again.');
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -149,6 +149,24 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
'icon' => 'icon-bug'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Debug mode'),
|
||||
'name' => 'debug_mode',
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
'hint' => $this->l('Enable or disable debug mode. Debug mode will enable extended error reporting.')
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Disable non QloApps modules'),
|
||||
@@ -196,6 +214,7 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
);
|
||||
|
||||
$this->fields_value['native_module'] = Configuration::get('PS_DISABLE_NON_NATIVE_MODULE');
|
||||
$this->fields_value['debug_mode'] = _PS_MODE_DEV_;
|
||||
$this->fields_value['overrides'] = Configuration::get('PS_DISABLE_OVERRIDES');
|
||||
}
|
||||
|
||||
@@ -885,6 +904,12 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
if (Tools::isSubmit('submitAddconfiguration')) {
|
||||
Configuration::updateGlobalValue('PS_DISABLE_NON_NATIVE_MODULE', (int)Tools::getValue('native_module'));
|
||||
Configuration::updateGlobalValue('PS_DISABLE_OVERRIDES', (int)Tools::getValue('overrides'));
|
||||
|
||||
$debugValue = ((int) Tools::getValue('debug_mode') === 1) ? 'true' : 'false';
|
||||
if (!$this->updateDebugMode($debugValue)) {
|
||||
$this->errors[] = $this->l('Unable to update debug mode. Please check file permissions.');
|
||||
}
|
||||
|
||||
Tools::generateIndex();
|
||||
}
|
||||
|
||||
@@ -894,6 +919,26 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function updateDebugMode($value)
|
||||
{
|
||||
$filename = _PS_ROOT_DIR_ . '/config/defines.inc.php';
|
||||
|
||||
if (is_readable($filename)) {
|
||||
$cleanedFileContent = php_strip_whitespace($filename);
|
||||
if (preg_match('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', $cleanedFileContent)) {
|
||||
$fileContent = Tools::file_get_contents($filename);
|
||||
$fileContent = preg_replace('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', 'define(\'_PS_MODE_DEV_\', ' . $value . ');', $fileContent);
|
||||
if (@file_put_contents($filename, $fileContent)) {
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
@opcache_invalidate($filename);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function displayAjaxTestServer()
|
||||
{
|
||||
/* PrestaShop demo mode */
|
||||
|
||||
@@ -2024,6 +2024,16 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->errors[] = $error;
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
if ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($this->object->id)) {
|
||||
$objHotelBranchInformation = new HotelBranchInformation((int)$roomTypeInfo['id_hotel']);
|
||||
if (!$objHotelBranchInformation->active && !$this->object->active) {
|
||||
$this->errors[] = $this->l('Room type can not be active as long as hotel is disabled.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->errors)) {
|
||||
return false;
|
||||
}
|
||||
@@ -2041,6 +2051,61 @@ class AdminProductsControllerCore extends AdminController
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function processBulkStatusSelection($status)
|
||||
{
|
||||
if (!is_array($this->boxes) || empty($this->boxes)) {
|
||||
return parent::processBulkStatusSelection($status);
|
||||
}
|
||||
|
||||
$disabledHotelRoomTypes = array();
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$result = true;
|
||||
$hasSuccessfulUpdate = false;
|
||||
|
||||
foreach ($this->boxes as $id) {
|
||||
$id = (int) $id;
|
||||
$object = new $this->className($id);
|
||||
if (!Validate::isLoadedObject($object)) {
|
||||
$this->errors[] = sprintf($this->l('Invalid room type ID %d.'), $id);
|
||||
$result = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($status && ($roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($id))) {
|
||||
$objHotelBranchInformation = new HotelBranchInformation((int) $roomTypeInfo['id_hotel']);
|
||||
if (!$objHotelBranchInformation->active) {
|
||||
$disabledHotelRoomTypes[] = Product::getProductName($id, null, (int)$this->context->language->id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$object->setFieldsToUpdate(array('active' => true));
|
||||
$object->active = (int) $status;
|
||||
$isUpdated = (bool) $object->update();
|
||||
$result = $result && $isUpdated;
|
||||
$hasSuccessfulUpdate = $hasSuccessfulUpdate || $isUpdated;
|
||||
|
||||
if (!$isUpdated) {
|
||||
$this->errors[] = sprintf($this->l('Can\'t update #%d status.'), $id);
|
||||
}
|
||||
}
|
||||
|
||||
if ($disabledHotelRoomTypes) {
|
||||
$this->errors[] =
|
||||
$this->l('Room types linked to inactive hotels cannot be enabled.');
|
||||
}
|
||||
|
||||
if ($result && $hasSuccessfulUpdate && !$disabledHotelRoomTypes) {
|
||||
$this->redirect_after = self::$currentIndex.'&conf=5&token='.$this->token;
|
||||
} elseif ($result && $hasSuccessfulUpdate) {
|
||||
$this->confirmations[] = $this->l('The status has been updated for the room types linked to active hotels.');
|
||||
} elseif (!$result) {
|
||||
$this->errors[] = $this->l('An error occurred while updating the status.');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function processToggleShowAtFront()
|
||||
{
|
||||
if (!$this->loadObject()) {
|
||||
@@ -2366,6 +2431,10 @@ class AdminProductsControllerCore extends AdminController
|
||||
} else if (!Validate::isLoadedObject($objHotel = new HotelBranchInformation($id_hotel))) {
|
||||
$this->errors[] = Tools::displayError('Selected Hotel not found');
|
||||
} else {
|
||||
// Prevent enabling a room type when its hotel is disabled
|
||||
if ((int)Tools::getValue('active') === 1 && isset($objHotel) && !$objHotel->active) {
|
||||
$this->errors[] = Tools::displayError('Room type can not be active as long as hotel is disabled.');
|
||||
}
|
||||
$hotelIdCategory = $objHotel->id_category;
|
||||
if (Validate::isLoadedObject($objCategory = new Category($hotelIdCategory))) {
|
||||
foreach($objCategory->getParentsCategories() as $category) {
|
||||
@@ -3407,10 +3476,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
if ($baseChildren == '' || !Validate::isUnsignedInt($baseChildren)) {
|
||||
$this->errors[] = Tools::displayError('Invalid base children');
|
||||
} else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) {
|
||||
if ($baseChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Base children cannot be greater than max childern allowed in the room of this room type (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'));
|
||||
}
|
||||
}
|
||||
if (!$maxAdults || !Validate::isUnsignedInt($maxAdults)) {
|
||||
$this->errors[] = Tools::displayError('Invalid maximum number of adults');
|
||||
@@ -3425,10 +3490,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('Maximum number of children cannot be less than base children');
|
||||
} elseif ($maxChildren >= $maxGuests) {
|
||||
$this->errors[] = Tools::displayError('Maximum number of children cannot be more or equal than maximum number of guests.(1 adult is mandatory in a room)');
|
||||
} else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) {
|
||||
if ($maxChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Maximum number of children cannot be greater than max childern allowed in the room of this room type (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'));
|
||||
}
|
||||
}
|
||||
if (!$maxGuests || !Validate::isUnsignedInt($maxGuests)) {
|
||||
$this->errors[] = Tools::displayError('Invalid maximum number of guests');
|
||||
|
||||
@@ -1389,65 +1389,182 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
|
||||
$dtFrom = new DateTime($dateFrom);
|
||||
$dtTo = new DateTime($dateTo);
|
||||
$numNights = (int)$dtFrom->diff($dtTo)->days;
|
||||
if ($numNights <= 0) {
|
||||
$numNights = 1;
|
||||
}
|
||||
|
||||
$occupancyData = array('count_total' => 0, 'count_occupied' => 0, 'count_available' => 0, 'count_unavailable' => 0);
|
||||
|
||||
$countTotal = self::getTotalRooms($idsHotel, true);
|
||||
$occupancyData['count_total'] = $countTotal;
|
||||
$countRooms = (int)self::getTotalRooms($idsHotel, true);
|
||||
$countTotal = $countRooms * $numNights;
|
||||
$occupancyData['count_total'] = (int)$countTotal;
|
||||
|
||||
// Occupied rooms are booked rooms that are not refunded in the date range
|
||||
$countOccupied = 0;
|
||||
$occupiedRooms = Db::getInstance()->executeS(
|
||||
'SELECT DISTINCT hbd.`id_room`
|
||||
// Occupied are booked room-nights (non-refunded) in the date range.
|
||||
$countOccupied = (int)Db::getInstance()->getValue(
|
||||
'SELECT IFNULL(SUM(
|
||||
GREATEST(
|
||||
0,
|
||||
DATEDIFF(
|
||||
LEAST(
|
||||
IF(hbd.`id_status` = '.(int)HotelBookingDetail::STATUS_CHECKED_OUT.',
|
||||
DATE_FORMAT(hbd.`check_out`, "%Y-%m-%d"),
|
||||
hbd.`date_to`
|
||||
),
|
||||
"'.pSQL($dateTo).'"
|
||||
),
|
||||
GREATEST(hbd.`date_from`, "'.pSQL($dateFrom).'")
|
||||
)
|
||||
)
|
||||
), 0)
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_information` hri
|
||||
ON (hri.`id` = hbd.`id_room`)
|
||||
ON (hri.`id` = hbd.`id_room`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hri.`id_product`)
|
||||
ON (p.`id_product` = hri.`id_product`)
|
||||
WHERE p.`active` = 1
|
||||
AND p.`booking_product` = 1
|
||||
AND hbd.`is_refunded` = 0
|
||||
AND IF(hbd.`id_status` = '. HotelBookingDetail::STATUS_CHECKED_OUT .', hbd.`date_from` < DATE_FORMAT(hbd.`check_out`, "%Y-%m-%d") AND hbd.`date_from` < \''.pSQL($dateTo).'\' AND DATE_FORMAT(hbd.`check_out`, "%Y-%m-%d") > \''.pSQL($dateFrom).'\', hbd.`date_from` < \''.pSQL($dateTo).'\' AND hbd.`date_to` > \''.pSQL($dateFrom).'\')'.
|
||||
AND hbd.`date_from` < "'.pSQL($dateTo).'"
|
||||
AND IF(hbd.`id_status` = '.(int)HotelBookingDetail::STATUS_CHECKED_OUT.',
|
||||
DATE_FORMAT(hbd.`check_out`, "%Y-%m-%d"),
|
||||
hbd.`date_to`
|
||||
) > "'.pSQL($dateFrom).'"'.
|
||||
HotelBranchInformation::addHotelRestriction($idsHotel, 'hbd')
|
||||
);
|
||||
$occupancyData['count_occupied'] = $countOccupied;
|
||||
|
||||
// Unavailable are:
|
||||
// - inactive rooms (unavailable for all nights in the range)
|
||||
// - temporarily inactive rooms for overlapping disabled date ranges (night-wise)
|
||||
$countInactiveRooms = (int)Db::getInstance()->getValue(
|
||||
'SELECT IFNULL(COUNT(hri.`id`), 0)
|
||||
FROM `'._DB_PREFIX_.'htl_room_information` hri
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hri.`id_product`)
|
||||
WHERE hri.`id_status` = '.(int)HotelRoomInformation::STATUS_INACTIVE.'
|
||||
AND p.`active` = 1
|
||||
AND p.`booking_product` = 1'.
|
||||
(!is_null($idsHotel) ? HotelBranchInformation::addHotelRestriction($idsHotel, 'hri') : '')
|
||||
);
|
||||
|
||||
// Booked nights for rooms that are currently inactive should not be counted as unavailable.
|
||||
$countOccupiedInactiveNights = (int)Db::getInstance()->getValue(
|
||||
'SELECT IFNULL(SUM(
|
||||
GREATEST(
|
||||
0,
|
||||
DATEDIFF(
|
||||
LEAST(
|
||||
IF(hbd.`id_status` = '.(int)HotelBookingDetail::STATUS_CHECKED_OUT.',
|
||||
DATE_FORMAT(hbd.`check_out`, "%Y-%m-%d"),
|
||||
hbd.`date_to`
|
||||
),
|
||||
"'.pSQL($dateTo).'"
|
||||
),
|
||||
GREATEST(hbd.`date_from`, "'.pSQL($dateFrom).'")
|
||||
)
|
||||
)
|
||||
), 0)
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_information` hri
|
||||
ON (hri.`id` = hbd.`id_room`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hri.`id_product`)
|
||||
WHERE hri.`id_status` = '.(int)HotelRoomInformation::STATUS_INACTIVE.'
|
||||
AND p.`active` = 1
|
||||
AND p.`booking_product` = 1
|
||||
AND hbd.`is_refunded` = 0
|
||||
AND hbd.`date_from` < "'.pSQL($dateTo).'"
|
||||
AND IF(hbd.`id_status` = '.(int)HotelBookingDetail::STATUS_CHECKED_OUT.',
|
||||
DATE_FORMAT(hbd.`check_out`, "%Y-%m-%d"),
|
||||
hbd.`date_to`
|
||||
) > "'.pSQL($dateFrom).'"'.
|
||||
HotelBranchInformation::addHotelRestriction($idsHotel, 'hbd')
|
||||
);
|
||||
|
||||
if ($occupiedRooms) {
|
||||
$occupiedRooms = array_column($occupiedRooms, 'id_room');
|
||||
$occupancyData['count_occupied'] = count($occupiedRooms);
|
||||
} else {
|
||||
$occupancyData['count_occupied'] = 0;
|
||||
}
|
||||
|
||||
// Unavailable rooms are rooms that are not booked for the date range and in the inactive status
|
||||
$countUnavailable = Db::getInstance()->getValue(
|
||||
'SELECT COUNT(hri.`id`)
|
||||
$countTemporarilyInactiveNights = (int)Db::getInstance()->getValue(
|
||||
'SELECT IFNULL(SUM(
|
||||
GREATEST(
|
||||
0,
|
||||
DATEDIFF(
|
||||
LEAST(hrdd.`date_to`, "'.pSQL($dateTo).'"),
|
||||
GREATEST(hrdd.`date_from`, "'.pSQL($dateFrom).'")
|
||||
)
|
||||
)
|
||||
), 0)
|
||||
FROM `'._DB_PREFIX_.'htl_room_information` hri
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info` hbi
|
||||
ON (hbi.`id` = hri.`id_hotel`)
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` hrdd
|
||||
ON (hrdd.`id_room` = hri.`id`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hri.`id_product`)
|
||||
WHERE p.`active` = 1 '.
|
||||
($occupiedRooms ? ' AND hri.`id` NOT IN ('.implode(',', $occupiedRooms).')' : '').
|
||||
' AND hri.`id_status` = '.(int) HotelRoomInformation::STATUS_INACTIVE.
|
||||
HotelBranchInformation::addHotelRestriction($idsHotel, 'hbi', 'id')
|
||||
);
|
||||
$occupancyData['count_unavailable'] = $countUnavailable;
|
||||
|
||||
// Available rooms are rooms that are not booked for the date range and in the temporary inactive for the date range
|
||||
$countDisabled = Db::getInstance()->getValue(
|
||||
'SELECT IFNULL(COUNT(hri.`id`), 0)
|
||||
FROM `'._DB_PREFIX_.'htl_room_information` hri
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_disable_dates` hrdd
|
||||
ON (hrdd.`id_room` = hri.`id`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hri.`id_product`)
|
||||
WHERE hri.`id_status` = '.(int) HotelRoomInformation::STATUS_TEMPORARY_INACTIVE.
|
||||
($occupiedRooms ? ' AND hri.`id` NOT IN ('.implode(',', $occupiedRooms).')' : '').
|
||||
' AND ("'.pSQL($dateTo).'" > hrdd.`date_from` AND "'.pSQL($dateFrom).'" < hrdd.`date_to`)
|
||||
AND p.`active` = 1'.
|
||||
ON (p.`id_product` = hri.`id_product`)
|
||||
WHERE hri.`id_status` = '.(int)HotelRoomInformation::STATUS_TEMPORARY_INACTIVE.'
|
||||
AND hrdd.`date_from` < "'.pSQL($dateTo).'"
|
||||
AND hrdd.`date_to` > "'.pSQL($dateFrom).'"
|
||||
AND p.`active` = 1
|
||||
AND p.`booking_product` = 1'.
|
||||
(!is_null($idsHotel) ? HotelBranchInformation::addHotelRestriction($idsHotel, 'hri') : '')
|
||||
);
|
||||
$occupancyData['count_unavailable'] += $countDisabled;
|
||||
|
||||
$occupancyData['count_available'] = $occupancyData['count_total'] - $occupancyData['count_occupied'] - $occupancyData['count_unavailable'];
|
||||
// Booked nights overlapping temporary disable ranges should not be counted as unavailable.
|
||||
$countOccupiedTemporaryInactiveNights = (int)Db::getInstance()->getValue(
|
||||
'SELECT IFNULL(SUM(
|
||||
GREATEST(
|
||||
0,
|
||||
DATEDIFF(
|
||||
LEAST(
|
||||
IF(hbd.`id_status` = '.(int)HotelBookingDetail::STATUS_CHECKED_OUT.',
|
||||
DATE_FORMAT(hbd.`check_out`, "%Y-%m-%d"),
|
||||
hbd.`date_to`
|
||||
),
|
||||
hrdd.`date_to`,
|
||||
"'.pSQL($dateTo).'"
|
||||
),
|
||||
GREATEST(
|
||||
hbd.`date_from`,
|
||||
hrdd.`date_from`,
|
||||
"'.pSQL($dateFrom).'"
|
||||
)
|
||||
)
|
||||
)
|
||||
), 0)
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_disable_dates` hrdd
|
||||
ON (hrdd.`id_room` = hbd.`id_room`)
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_room_information` hri
|
||||
ON (hri.`id` = hbd.`id_room`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hri.`id_product`)
|
||||
WHERE hri.`id_status` = '.(int)HotelRoomInformation::STATUS_TEMPORARY_INACTIVE.'
|
||||
AND p.`active` = 1
|
||||
AND p.`booking_product` = 1
|
||||
AND hbd.`is_refunded` = 0
|
||||
AND hrdd.`date_from` < "'.pSQL($dateTo).'"
|
||||
AND hrdd.`date_to` > "'.pSQL($dateFrom).'"
|
||||
AND hbd.`date_from` < "'.pSQL($dateTo).'"
|
||||
AND IF(hbd.`id_status` = '.(int)HotelBookingDetail::STATUS_CHECKED_OUT.',
|
||||
DATE_FORMAT(hbd.`check_out`, "%Y-%m-%d"),
|
||||
hbd.`date_to`
|
||||
) > "'.pSQL($dateFrom).'"'.
|
||||
HotelBranchInformation::addHotelRestriction($idsHotel, 'hbd')
|
||||
);
|
||||
|
||||
$inactiveUnavailable = ($countInactiveRooms * $numNights) - $countOccupiedInactiveNights;
|
||||
if ($inactiveUnavailable < 0) {
|
||||
$inactiveUnavailable = 0;
|
||||
}
|
||||
|
||||
$temporaryUnavailable = $countTemporarilyInactiveNights - $countOccupiedTemporaryInactiveNights;
|
||||
if ($temporaryUnavailable < 0) {
|
||||
$temporaryUnavailable = 0;
|
||||
}
|
||||
|
||||
$countUnavailable = $inactiveUnavailable + $temporaryUnavailable;
|
||||
$occupancyData['count_unavailable'] = (int)$countUnavailable;
|
||||
|
||||
$countAvailable = (int)$occupancyData['count_total'] - (int)$occupancyData['count_occupied'] - (int)$occupancyData['count_unavailable'];
|
||||
$occupancyData['count_available'] = $countAvailable > 0 ? $countAvailable : 0;
|
||||
|
||||
return $occupancyData;
|
||||
}
|
||||
|
||||
@@ -714,8 +714,11 @@ class AdminThemesControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$ids_themes = Tools::unSerialize(Configuration::get('PS_ADDONS_THEMES_IDS'));
|
||||
if (array_key_exists($obj->directory, $ids_themes)) {
|
||||
unset($ids_themes[$obj->directory]);
|
||||
|
||||
if(is_array($ids_themes)) {
|
||||
if (array_key_exists($obj->directory, $ids_themes)) {
|
||||
unset($ids_themes[$obj->directory]);
|
||||
}
|
||||
}
|
||||
|
||||
$obj->removeMetas();
|
||||
@@ -1206,7 +1209,9 @@ class AdminThemesControllerCore extends AdminController
|
||||
');
|
||||
|
||||
foreach ($hook_list as &$row) {
|
||||
$row['exceptions'] = trim(preg_replace('/(,,+)/', ',', $row['exceptions']), ',');
|
||||
if($row['exceptions']){
|
||||
$row['exceptions'] = trim(preg_replace('/(,,+)/', ',', $row['exceptions']), ',');
|
||||
}
|
||||
}
|
||||
|
||||
$native_modules = $this->getNativeModule();
|
||||
|
||||
@@ -748,26 +748,35 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$files_list = AdminTranslationsController::filterTranslationFiles($gz->listContent());
|
||||
$files_paths = AdminTranslationsController::filesListToPaths($files_list);
|
||||
|
||||
if (empty($files_list)) {
|
||||
$this->errors[] = Tools::displayError('No valid translation files found in the archive.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$uniqid = uniqid();
|
||||
$sandbox = _PS_CACHE_DIR_.'sandbox'.DIRECTORY_SEPARATOR.$uniqid.DIRECTORY_SEPARATOR;
|
||||
if ($gz->extractList($files_paths, $sandbox)) {
|
||||
foreach ($files_list as $file2check) {
|
||||
//don't validate index.php, will be overwrite when extract in translation directory
|
||||
if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match('@^[0-9a-z-_/\\\\]+\.php$@i', $file2check['filename'])) {
|
||||
if (!@filemtime($sandbox.$file2check['filename']) || !AdminTranslationsController::checkTranslationFile(file_get_contents($sandbox.$file2check['filename']))) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Validation failed for: %s'), $file2check['filename']);
|
||||
}
|
||||
} elseif (!preg_match('@mails[0-9a-z-_/\\\\]+\.(html|tpl|txt)$@i', $file2check['filename'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Unidentified file found: %s'), $file2check['filename']);
|
||||
}
|
||||
}
|
||||
if (!$gz->extractList($files_paths, $sandbox)) {
|
||||
$this->errors[] = Tools::displayError('The archive cannot be extracted.');
|
||||
Tools::deleteDirectory($sandbox, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($files_list as $file2check) {
|
||||
//don't validate index.php, will be overwrite when extract in translation directory
|
||||
if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match('@^[0-9a-z-_/\\\\]+\.php$@i', $file2check['filename'])) {
|
||||
if (!@filemtime($sandbox.$file2check['filename']) || !AdminTranslationsController::checkTranslationFile(file_get_contents($sandbox.$file2check['filename']))) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Validation failed for: %s'), $file2check['filename']);
|
||||
}
|
||||
} elseif (!preg_match('@mails[0-9a-z-_/\\\\]+\.(html|tpl|txt)$@i', $file2check['filename'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Unidentified file found: %s'), $file2check['filename']);
|
||||
}
|
||||
}
|
||||
Tools::deleteDirectory($sandbox, true);
|
||||
|
||||
$i = 0;
|
||||
$tmp_array = array();
|
||||
foreach ($files_paths as $files_path) {
|
||||
@@ -837,11 +846,26 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
public static function filterTranslationFiles($list)
|
||||
{
|
||||
$kept = array();
|
||||
$allowedExtensions = array('php', 'html', 'tpl', 'txt');
|
||||
foreach ($list as $file) {
|
||||
if ('index.php' == basename($file['filename'])) {
|
||||
$filename = $file['filename'];
|
||||
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
if (!in_array($extension, $allowedExtensions)) {
|
||||
continue;
|
||||
}
|
||||
if (preg_match('#^modules/([^/]+)/#', $file['filename'], $m)) {
|
||||
|
||||
if ('index.php' == basename($filename)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($extension === 'php'
|
||||
&& !preg_match('#^modules/([^/]+)/#', $filename)
|
||||
&& !preg_match('@^translations/[a-z]{2,3}/[a-z0-9_-]+\.php$@i', $filename)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (preg_match('#^modules/([^/]+)/#', $filename, $m)) {
|
||||
if (is_dir(_PS_MODULE_DIR_.$m[1])) {
|
||||
$kept[] = $file;
|
||||
}
|
||||
@@ -3045,8 +3069,13 @@ class AdminTranslationsControllerCore extends AdminController
|
||||
$email_file = _PS_ROOT_DIR_.$email;
|
||||
}
|
||||
|
||||
$email_html = file_get_contents($email_file);
|
||||
$sanitizedFilePath = realpath($email_file);
|
||||
$permittedMailDir = realpath(_PS_MAIL_DIR_) . DIRECTORY_SEPARATOR;
|
||||
|
||||
return $email_html;
|
||||
if ($sanitizedFilePath === false || $permittedMailDir === false || strpos($sanitizedFilePath, $permittedMailDir) !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return file_get_contents($sanitizedFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user