Merge branch 'develop' into gli-1466
This commit is contained in:
@@ -74,16 +74,6 @@ class AdminAddressesControllerCore extends AdminController
|
||||
'city' => array('title' => $this->l('City')),
|
||||
'country' => array('title' => $this->l('Country'), 'type' => 'select', 'list' => $this->countries_array, 'filter_key' => 'cl!id_country'));
|
||||
|
||||
|
||||
// START send access query information to the admin controller
|
||||
$this->access_select = ' SELECT a.`id_address` FROM '._DB_PREFIX_.'address a';
|
||||
$this->access_join = ' INNER JOIN '._DB_PREFIX_.'customer cust ON (cust.id_customer = a.id_customer)';
|
||||
$this->access_join .= ' INNER JOIN '._DB_PREFIX_.'orders ord ON (cust.id_customer = ord.id_customer)';
|
||||
$this->access_join .= ' INNER JOIN '._DB_PREFIX_.'htl_booking_detail hbd ON (hbd.id_order = ord.id_order)';
|
||||
if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
|
||||
$this->access_where = ' WHERE hbd.id_hotel IN ('.implode(',', $acsHtls).')';
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->_select = 'cl.`name` as country';
|
||||
@@ -177,6 +167,18 @@ class AdminAddressesControllerCore extends AdminController
|
||||
)
|
||||
);
|
||||
|
||||
if (!Tools::getValue('liteDisplaying')) {
|
||||
$this->fields_form['buttons'] = array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->fields_value['address_type'] = (int)Tools::getValue('address_type', 1);
|
||||
|
||||
$id_customer = (int)Tools::getValue('id_customer');
|
||||
|
||||
@@ -768,7 +768,12 @@ class AdminCartRulesControllerCore extends AdminController
|
||||
public function displayAjaxSearchCartRuleVouchers()
|
||||
{
|
||||
$found = false;
|
||||
if ($vouchers = CartRule::getCartsRuleByCode(Tools::getValue('q'), (int)$this->context->language->id, true)) {
|
||||
if ($vouchers = CartRule::getCartsRuleByCode(
|
||||
Tools::getValue('q'),
|
||||
(int)$this->context->language->id,
|
||||
true,
|
||||
(int) Tools::getValue('id_customer')
|
||||
)) {
|
||||
$found = true;
|
||||
}
|
||||
echo json_encode(array('found' => $found, 'vouchers' => $vouchers));
|
||||
|
||||
@@ -54,7 +54,7 @@ class AdminCartsControllerCore extends AdminController
|
||||
LEFT JOIN `'._DB_PREFIX_.'connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF(\''.pSQL(date('Y-m-d H:i:00', time())).'\', co.`date_add`)) < 1800)';
|
||||
$this->_group = ' GROUP BY a.`id_cart`';
|
||||
|
||||
if (Tools::getValue('action') == 'filterAbandonedCarts') {
|
||||
if (Tools::getValue('action') == 'filterOnlyAbandonedCarts') {
|
||||
$this->_filterHaving = ' AND `ids_order` = 0 AND `time_diff` > 86400';
|
||||
}
|
||||
|
||||
@@ -333,6 +333,9 @@ class AdminCartsControllerCore extends AdminController
|
||||
}
|
||||
$this->context->cart = new Cart((int)$id_cart);
|
||||
|
||||
CartRule::autoRemoveFromCart($this->context);
|
||||
CartRule::autoAddToCart($this->context);
|
||||
|
||||
if (!$this->context->cart->id) {
|
||||
$this->context->cart->recyclable = 0;
|
||||
$this->context->cart->gift = 0;
|
||||
|
||||
@@ -105,7 +105,19 @@ class AdminCmsCategoriesControllerCore extends AdminController
|
||||
$object = parent::postProcess();
|
||||
$this->updateAssoShop((int)Tools::getValue('id_cms_category'));
|
||||
if ($object !== false) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=3&id_cms_category='.(int)$object->id.'&token='.Tools::getValue('token'));
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
if ($this->id_object) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&update'.$this->table.'&conf=4&id_cms_category='.(int)$object->id.'&token='.Tools::getValue('token'));
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&update'.$this->table.'&conf=3&id_cms_category='.(int)$object->id.'&token='.Tools::getValue('token'));
|
||||
}
|
||||
} else {
|
||||
if ($this->id_object) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&id_cms_category='.(int)$object->id.'&token='.Tools::getValue('token'));
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=3&id_cms_category='.(int)$object->id.'&token='.Tools::getValue('token'));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
@@ -289,7 +301,16 @@ class AdminCmsCategoriesControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (Shop::isFeatureActive()) {
|
||||
|
||||
@@ -218,6 +218,13 @@ class AdminCmsControllerCore extends AdminController
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
'save_and_preview' => array(
|
||||
'name' => 'viewcms',
|
||||
'type' => 'submit',
|
||||
|
||||
@@ -113,7 +113,16 @@ class AdminContactsControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (Shop::isFeatureActive()) {
|
||||
|
||||
@@ -54,20 +54,20 @@ class AdminCountriesControllerCore extends AdminController
|
||||
'dir' => 'st'
|
||||
);
|
||||
|
||||
$this->fields_options = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Country options'),
|
||||
'fields' => array(
|
||||
'PS_RESTRICT_DELIVERED_COUNTRIES' => array(
|
||||
'title' => $this->l('Restrict country selections in front office to those covered by active carriers'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool',
|
||||
'default' => '0'
|
||||
)
|
||||
),
|
||||
'submit' => array('title' => $this->l('Save'))
|
||||
)
|
||||
);
|
||||
// $this->fields_options = array(
|
||||
// 'general' => array(
|
||||
// 'title' => $this->l('Country options'),
|
||||
// 'fields' => array(
|
||||
// 'PS_RESTRICT_DELIVERED_COUNTRIES' => array(
|
||||
// 'title' => $this->l('Restrict country selections in front office to those covered by active carriers'),
|
||||
// 'cast' => 'intval',
|
||||
// 'type' => 'bool',
|
||||
// 'default' => '0'
|
||||
// )
|
||||
// ),
|
||||
// 'submit' => array('title' => $this->l('Save'))
|
||||
// )
|
||||
// );
|
||||
|
||||
$zones_array = array();
|
||||
$this->zones = Zone::getZones();
|
||||
@@ -368,6 +368,16 @@ class AdminCountriesControllerCore extends AdminController
|
||||
'title' => $this->l('Save')
|
||||
);
|
||||
|
||||
$this->fields_form['buttons'] = array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
)
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
|
||||
@@ -231,6 +231,16 @@ class AdminCurrenciesControllerCore extends AdminController
|
||||
'title' => $this->l('Save'),
|
||||
);
|
||||
|
||||
$this->fields_form['buttons'] = array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
)
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,13 @@ class AdminCustomerPreferencesControllerCore extends AdminController
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_CUSTOMER_BIRTHDATE' => array(
|
||||
'title' => $this->l('Enable date of birth'),
|
||||
'hint' => $this->l('Display or not the date of birth field.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_CUSTOMER_NWSL' => array(
|
||||
'title' => $this->l('Enable newsletter registration'),
|
||||
'hint' => $this->l('Display or not the newsletter registration tick box.'),
|
||||
@@ -108,7 +115,7 @@ class AdminCustomerPreferencesControllerCore extends AdminController
|
||||
),
|
||||
'PS_CUSTOMER_OPTIN' => array(
|
||||
'title' => $this->l('Enable opt-in'),
|
||||
'hint' => $this->l('Display or not the opt-in tick box, to receive offers from the store\'s partners.'),
|
||||
'hint' => $this->l('Display or not the opt-in tick box, to receive offers from your hotel partners.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
|
||||
@@ -62,6 +62,15 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
||||
$status_array[$k] = $v['alt'];
|
||||
}
|
||||
|
||||
// START send access query information to the admin controller
|
||||
$this->access_select = ' SELECT a.`id_customer_thread` FROM '._DB_PREFIX_.'customer_thread a';
|
||||
$this->access_join = ' LEFT JOIN '._DB_PREFIX_.'orders ord ON (a.id_order = ord.id_order)';
|
||||
$this->access_join .= ' LEFT JOIN '._DB_PREFIX_.'htl_booking_detail hbd ON (hbd.id_order = ord.id_order)';
|
||||
$this->access_where = ' WHERE 1 ';
|
||||
if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
|
||||
$this->access_where .= ' AND IF(a.`id_order`, hbd.`id_hotel` IN ('.implode(',', $acsHtls).'), 1)';
|
||||
}
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_customer_thread' => array(
|
||||
'title' => $this->l('ID'),
|
||||
|
||||
@@ -39,8 +39,8 @@ class AdminCustomersControllerCore extends AdminController
|
||||
public function __construct()
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
$this->required_database = true;
|
||||
$this->required_fields = array('newsletter','optin');
|
||||
// $this->required_database = true;
|
||||
// $this->required_fields = array('newsletter','optin');
|
||||
$this->table = 'customer';
|
||||
$this->className = 'Customer';
|
||||
$this->lang = false;
|
||||
@@ -152,16 +152,6 @@ class AdminCustomersControllerCore extends AdminController
|
||||
|
||||
$this->shopLinkType = 'shop';
|
||||
$this->shopShareDatas = Shop::SHARE_CUSTOMER;
|
||||
|
||||
|
||||
// START send access query information to the admin controller
|
||||
$this->access_select = ' SELECT a.`id_customer` FROM '._DB_PREFIX_.'customer a';
|
||||
$this->access_join = ' INNER JOIN '._DB_PREFIX_.'orders ord ON (a.id_customer = ord.id_customer)';
|
||||
$this->access_join .= ' INNER JOIN '._DB_PREFIX_.'htl_booking_detail hbd ON (hbd.id_order = ord.id_order)';
|
||||
if ($acsHtls = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1)) {
|
||||
$this->access_where = ' WHERE hbd.id_hotel IN ('.implode(',', $acsHtls).')';
|
||||
}
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->_select = '
|
||||
@@ -458,8 +448,9 @@ class AdminCustomersControllerCore extends AdminController
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
'disabled' => (bool)!Configuration::get('PS_CUSTOMER_NWSL'),
|
||||
'hint' => $this->l('This customer will receive your newsletter via email.')
|
||||
'disabled' => (bool)!Configuration::get('PS_CUSTOMER_NWSL'),
|
||||
'hint' => $this->l('This customer will receive your newsletter via email.'),
|
||||
'desc' => (bool)!Configuration::get('PS_CUSTOMER_NWSL') ? sprintf($this->l('This field is disabled as option \'Enable newsletter registration\' is disabled. You can change it from %sPreferences > Customers%s page.'), '<a href="'.$this->context->link->getAdminLink('AdminCustomerPreferences').'" target="_blank">', '</a>') : '',
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
@@ -597,6 +588,18 @@ class AdminCustomersControllerCore extends AdminController
|
||||
'title' => $this->l('Save'),
|
||||
);
|
||||
|
||||
if (!Tools::getValue('liteDisplaying')) {
|
||||
$this->fields_form['buttons'] = array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
|
||||
|
||||
$this->fields_value = array(
|
||||
@@ -630,6 +633,10 @@ class AdminCustomersControllerCore extends AdminController
|
||||
Tools::getValue('groupBox_'.$group['id_group'], in_array($group['id_group'], $customer_groups_ids));
|
||||
}
|
||||
|
||||
if ($back = Tools::getValue('back')) {
|
||||
$this->tpl_form_vars['back_url'] = Tools::htmlentitiesDecodeUTF8(Tools::safeOutput(urldecode($back)));
|
||||
}
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
@@ -866,6 +873,25 @@ class AdminCustomersControllerCore extends AdminController
|
||||
|
||||
public function processDelete()
|
||||
{
|
||||
// If customer is going to be deleted permanently then if customer has orders the change this customer as an anonymous customer
|
||||
if (Validate::isLoadedObject($objCustomer = $this->loadObject())) {
|
||||
if ($this->delete_mode == 'real' && Order::getCustomerOrders($objCustomer->id, true)) {
|
||||
$objCustomer->email = 'anonymous'.'-'.$objCustomer->id.'@'.Tools::getShopDomain();
|
||||
$objCustomer->deleted = 1;
|
||||
if (!$objCustomer->update()) {
|
||||
$this->errors[] = Tools::displayError('Some error ocurred while deleting the Customer');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Customer not found.');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_setDeletedMode();
|
||||
parent::processDelete();
|
||||
}
|
||||
@@ -884,6 +910,44 @@ class AdminCustomersControllerCore extends AdminController
|
||||
|
||||
protected function processBulkDelete()
|
||||
{
|
||||
// If customer is going to be deleted permanently then if customer has orders the change this customer as an anonymous customer
|
||||
if ($this->delete_mode == 'real') {
|
||||
if (is_array($this->boxes) && !empty($this->boxes)) {
|
||||
foreach ($this->boxes as $key => $idCustomer) {
|
||||
if (Validate::isLoadedObject($objCustomer = new Customer($idCustomer))) {
|
||||
// check if customer has orders for email change else customer will be deleted
|
||||
if (Order::getCustomerOrders($objCustomer->id, true)) {
|
||||
$objCustomer->email = 'anonymous'.'-'.$objCustomer->id.'@'.Tools::getShopDomain();
|
||||
$objCustomer->deleted = 1;
|
||||
if ($objCustomer->update()) {
|
||||
// unset the customer which is processed
|
||||
// not processed customers will be deleted with default process if no errors are there
|
||||
unset($this->boxes[$key]);
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Some error ocurred while deleting the Customer with id').': '.$idCustomer;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Customer id').': '.$idCustomer.' '.Tools::displayError('not found.');
|
||||
}
|
||||
}
|
||||
|
||||
// if all the customers are process above then redirect with success
|
||||
if (!count($this->boxes)) {
|
||||
$this->redirect_after = self::$currentIndex.'&conf=1&token='.$this->token;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Customers not found.');
|
||||
return;
|
||||
}
|
||||
|
||||
// if errors are there then do not proceed for default process
|
||||
if (count($this->errors)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_setDeletedMode();
|
||||
parent::processBulkDelete();
|
||||
}
|
||||
@@ -966,6 +1030,21 @@ class AdminCustomersControllerCore extends AdminController
|
||||
return parent::processSave();
|
||||
}
|
||||
|
||||
protected function copyFromPost(&$object, $table)
|
||||
{
|
||||
parent::copyFromPost($object, $table);
|
||||
|
||||
$years = Tools::getValue('years');
|
||||
$months = Tools::getValue('months');
|
||||
$days = Tools::getValue('days');
|
||||
|
||||
if ($years != '' && $months != '' && $days != '') {
|
||||
$object->birthday = (int) $years.'-'.(int) $months.'-'.(int) $days;
|
||||
} else {
|
||||
$object->birthday = '0000-00-00';
|
||||
}
|
||||
}
|
||||
|
||||
protected function afterDelete($object, $old_id)
|
||||
{
|
||||
$customer = new Customer($old_id);
|
||||
@@ -1080,10 +1159,11 @@ class AdminCustomersControllerCore extends AdminController
|
||||
public function ajaxProcessSearchCustomers()
|
||||
{
|
||||
$searches = explode(' ', Tools::getValue('customer_search'));
|
||||
$skip_deleted = Tools::getValue('skip_deleted');
|
||||
$customers = array();
|
||||
$searches = array_unique($searches);
|
||||
foreach ($searches as $search) {
|
||||
if (!empty($search) && $results = Customer::searchByName($search, 50)) {
|
||||
if (!empty($search) && $results = Customer::searchByName($search, 50, $skip_deleted)) {
|
||||
foreach ($results as $result) {
|
||||
if ($result['active']) {
|
||||
$customers[$result['id_customer']] = $result;
|
||||
|
||||
@@ -135,8 +135,8 @@ class AdminDashboardControllerCore extends AdminController
|
||||
}
|
||||
|
||||
$forms['net_profit']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array(
|
||||
'title' => $this->l('Average gross margin percentage'),
|
||||
'desc' => $this->l('You should calculate this percentage as follows: ((total sales revenue) - (total operating cost)) / (total sales revenue) * 100. This value is only used to calculate Dashboard approximate gross margin, if you do not specify operating cost for each room type.'),
|
||||
'title' => $this->l('Average gross operating cost percentage'),
|
||||
'desc' => $this->l('This value is only used to calculate Dashboard approximate gross operating cost, if you do not specify operating cost for each room type.'),
|
||||
'validation' => 'isPercentage',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text',
|
||||
@@ -386,7 +386,16 @@ class AdminDashboardControllerCore extends AdminController
|
||||
'extra' => Tools::getValue('extra')
|
||||
);
|
||||
|
||||
die(json_encode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push'))));
|
||||
// code to be added.
|
||||
$data = Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push'));
|
||||
Hook::exec('actionDashboardDataModifier', array(
|
||||
'data' => &$data,
|
||||
'params' => $params,
|
||||
'id_module' => $id_module,
|
||||
'dashboard_use_push' => (int)Tools::getValue('dashboard_use_push')
|
||||
));
|
||||
|
||||
$this->ajaxDie(json_encode($data));
|
||||
}
|
||||
|
||||
public function ajaxProcessSetSimulationMode()
|
||||
|
||||
@@ -403,6 +403,16 @@ class AdminEmployeesControllerCore extends AdminController
|
||||
'title' => $this->l('Save'),
|
||||
);
|
||||
|
||||
$this->fields_form['buttons'] = array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_value['passwd'] = false;
|
||||
$this->fields_value['bo_theme_css'] = $obj->bo_theme.'|'.$obj->bo_css;
|
||||
|
||||
|
||||
@@ -216,6 +216,16 @@ class AdminFeaturesControllerCore extends AdminController
|
||||
'title' => $this->l('Save'),
|
||||
);
|
||||
|
||||
$this->fields_form['buttons'] = array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
)
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
@@ -544,9 +554,9 @@ class AdminFeaturesControllerCore extends AdminController
|
||||
if ($this->table == 'feature_value' && ($this->display == 'edit' || $this->display == 'add')) {
|
||||
$this->redirect_after = self::$currentIndex.'&addfeature_value&id_feature='.(int)Tools::getValue('id_feature').'&token='.$this->token;
|
||||
} else {
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&conf=3&update'.$this->table.'&token='.$this->token;
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.(int) $object->id.'&conf=3&update'.$this->table.'&token='.$this->token;
|
||||
}
|
||||
} elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && count($this->errors)) {
|
||||
} elseif (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && count($this->errors) && $this->table == 'feature_value') { // enter only if feature is submitted
|
||||
$this->display = 'editFeatureValue';
|
||||
}
|
||||
|
||||
@@ -562,7 +572,7 @@ class AdminFeaturesControllerCore extends AdminController
|
||||
$object = parent::processUpdate();
|
||||
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && !count($this->errors)) {
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&conf=3&update'.$this->table.'&token='.$this->token;
|
||||
$this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.(int) Tools::getValue('id_feature').'&conf=4&update'.$this->table.'&token='.$this->token;
|
||||
}
|
||||
|
||||
return $object;
|
||||
|
||||
@@ -173,7 +173,16 @@ class AdminGendersControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/** @var Gender $obj */
|
||||
|
||||
@@ -126,7 +126,7 @@ class AdminGroupsControllerCore extends AdminController
|
||||
|
||||
public function initPageHeaderToolbar()
|
||||
{
|
||||
if (empty($this->display)) {
|
||||
if (empty($this->display) && Group::isFeatureActive()) {
|
||||
$this->page_header_toolbar_btn['new_group'] = array(
|
||||
'href' => self::$currentIndex.'&addgroup&token='.$this->token,
|
||||
'desc' => $this->l('Add new group', null, null, false),
|
||||
@@ -148,8 +148,32 @@ class AdminGroupsControllerCore extends AdminController
|
||||
parent::initProcess();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
if (!Group::isFeatureActive()) {
|
||||
parent::initContent();
|
||||
|
||||
$content = $this->displayWarning(sprintf(
|
||||
$this->l('The feature Customer Groups has been disabled. You can enable it from %s page.'),
|
||||
'<a href="'.$this->context->link->getAdminLink('AdminPerformance').'#fieldset_2_2" target="_blank">'.$this->l('Advanced Parameters > Performance').'</a>'
|
||||
));
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'content' => $content,
|
||||
));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!Group::isFeatureActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($_POST['submitResetcustomer_group'])) {
|
||||
$this->processResetFilters('customer_group');
|
||||
}
|
||||
@@ -175,13 +199,12 @@ class AdminGroupsControllerCore extends AdminController
|
||||
|
||||
protected function renderCustomersList($group)
|
||||
{
|
||||
$genders = array(0 => '?');
|
||||
$genders_icon = array('default' => 'unknown.gif');
|
||||
foreach (Gender::getGenders() as $gender) {
|
||||
/** @var Gender $gender */
|
||||
$genders_icon[$gender->id] = '../genders/'.(int)$gender->id.'.jpg';
|
||||
$genders[$gender->id] = $gender->name;
|
||||
$titles_array = array();
|
||||
$genders = Gender::getGenders($this->context->language->id);
|
||||
foreach ($genders as $gender) {
|
||||
$titles_array[$gender->id_gender] = $gender->name;
|
||||
}
|
||||
|
||||
$this->table = 'customer_group';
|
||||
$this->lang = false;
|
||||
$this->list_id = 'customer_group';
|
||||
@@ -194,7 +217,7 @@ class AdminGroupsControllerCore extends AdminController
|
||||
|
||||
$this->fields_list = (array(
|
||||
'id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'filter_key' => 'c!id_customer', 'class' => 'fixed-width-xs'),
|
||||
'id_gender' => array('title' => $this->l('Social title'), 'icon' => $genders_icon, 'list' => $genders),
|
||||
'title' => array('title' => $this->l('Social title'), 'filter_key' => 'c!id_gender', 'type' => 'select', 'list' => $titles_array),
|
||||
'firstname' => array('title' => $this->l('First name')),
|
||||
'lastname' => array('title' => $this->l('Last name')),
|
||||
'email' => array('title' => $this->l('Email address'), 'filter_key' => 'c!email', 'orderby' => true),
|
||||
@@ -202,8 +225,9 @@ class AdminGroupsControllerCore extends AdminController
|
||||
'date_add' => array('title' => $this->l('Registration date'), 'type' => 'date', 'class' => 'fixed-width-md', 'align' => 'center'),
|
||||
'active' => array('title' => $this->l('Enabled'), 'align' => 'center', 'class' => 'fixed-width-sm', 'type' => 'bool', 'search' => false, 'orderby' => false, 'filter_key' => 'c!active', 'callback' => 'printOptinIcon')
|
||||
));
|
||||
$this->_select = 'c.*, a.id_group';
|
||||
$this->_select = 'c.*, a.id_group, gl.`name` AS title';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (a.`id_customer` = c.`id_customer`)';
|
||||
$this->_join .= ' LEFT JOIN '._DB_PREFIX_.'gender_lang gl ON (gl.`id_gender` = c.`id_gender` AND gl.`id_lang` = '.(int) $this->context->language->id.')';
|
||||
$this->_where = 'AND a.`id_group` = '.(int)$group->id.' AND c.`deleted` != 1';
|
||||
$this->_where .= Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'c');
|
||||
self::$currentIndex = self::$currentIndex.'&id_group='.(int)$group->id.'&viewgroup';
|
||||
@@ -232,6 +256,15 @@ class AdminGroupsControllerCore extends AdminController
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
|
||||
@@ -403,7 +403,16 @@ class AdminImagesControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save')
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
|
||||
@@ -140,7 +140,6 @@ class AdminInformationControllerCore extends AdminController
|
||||
'upload_max_filesize' => $this->l('In PHP configuration set upload_max_filesize to minimum 16M.'),
|
||||
'max_execution_time' => $this->l('In PHP configuration set max_execution_time to minimum 500.'),
|
||||
'mbstring' => $this->l('PHP Mbstring extension is not enabled.'),
|
||||
'magicquotes' => $this->l('PHP magic quotes option is enabled.'),
|
||||
'dom' => $this->l('PHP DOM extension is not loaded.'),
|
||||
);
|
||||
|
||||
|
||||
@@ -195,10 +195,12 @@ class AdminInvoicesControllerCore extends AdminController
|
||||
);
|
||||
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT COUNT( o.id_order ) AS nbOrders, o.current_state as id_order_state
|
||||
SELECT COUNT(DISTINCT(o.id_order)) AS nbOrders, o.current_state as id_order_state
|
||||
FROM `'._DB_PREFIX_.'order_invoice` oi
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON oi.id_order = o.id_order
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (oi.id_order = hbd.id_order)
|
||||
WHERE o.id_shop IN('.implode(', ', Shop::getContextListShopID()).')
|
||||
'.HotelBranchInformation::addHotelRestriction(false, 'hbd').'
|
||||
AND oi.number > 0
|
||||
GROUP BY o.current_state
|
||||
');
|
||||
@@ -324,4 +326,11 @@ class AdminInvoicesControllerCore extends AdminController
|
||||
|
||||
return $templates;
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addJS(_PS_JS_DIR_.'admin/invoices.js');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -262,6 +262,16 @@ class AdminLanguagesControllerCore extends AdminController
|
||||
'title' => $this->l('Save'),
|
||||
);
|
||||
|
||||
$this->fields_form['buttons'] = array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
);
|
||||
|
||||
/** @var Language $obj */
|
||||
if (!($obj = $this->loadObject(true))) {
|
||||
return;
|
||||
|
||||
@@ -45,6 +45,17 @@ class AdminLoginControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
if ($this->ajax && Tools::getValue('action') == 'checkLoginStatus') {
|
||||
$this->ajaxDie(json_encode(array(
|
||||
'is_logged_in' => $this->context->employee->isLoggedBack(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
$this->addJquery();
|
||||
|
||||
@@ -97,6 +97,8 @@ class AdminLogsControllerCore extends AdminController
|
||||
$this->list_no_link = true;
|
||||
$this->_select .= 'CONCAT(e.firstname, \' \', e.lastname) employee';
|
||||
$this->_join .= ' LEFT JOIN '._DB_PREFIX_.'employee e ON (a.id_employee = e.id_employee)';
|
||||
$this->_orderBy = 'a.date_add';
|
||||
$this->_orderWay = 'DESC';
|
||||
$this->_use_found_rows = false;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -381,7 +381,16 @@ class AdminMetaControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save')
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ class AdminModulesCatalogControllerCore extends AdminController
|
||||
$this->page_header_toolbar_btn['addons'] = array(
|
||||
'href' => 'https://qloapps.com/addons/',
|
||||
'desc' => $this->l('Explore all Addons'),
|
||||
'imgclass' => 'modules-list',
|
||||
'imgclass' => 'puzzle-piece',
|
||||
'target' => true
|
||||
);
|
||||
}
|
||||
|
||||
@@ -444,8 +444,12 @@ class AdminModulesControllerCore extends AdminController
|
||||
@unlink($file);
|
||||
$this->recursiveDeleteOnDisk($tmp_folder);
|
||||
|
||||
if ($success && $redirect) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=8&anchor='.ucfirst($folder).'&token='.$this->token);
|
||||
if ($success) {
|
||||
if ($redirect) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=8&anchor='.ucfirst($folder).'&token='.$this->token);
|
||||
} else {
|
||||
$success = $folder;
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
@@ -610,7 +614,7 @@ class AdminModulesControllerCore extends AdminController
|
||||
} elseif (!move_uploaded_file($_FILES['file']['tmp_name'], _PS_MODULE_DIR_.$_FILES['file']['name'])) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while copying the archive to the module directory.');
|
||||
} else {
|
||||
$this->extractArchive(_PS_MODULE_DIR_.$_FILES['file']['name'], $redirect);
|
||||
return $this->extractArchive(_PS_MODULE_DIR_.$_FILES['file']['name'], $redirect);
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You do not have permission to add this.');
|
||||
@@ -1377,14 +1381,6 @@ class AdminModulesControllerCore extends AdminController
|
||||
'modal_title' => ($this->context->mode == Context::MODE_HOST) ? $this->l('This module cannot be installed') : $this->l('Important Notice'),
|
||||
'modal_content' => $modal_content
|
||||
);
|
||||
|
||||
$modal_content = $this->context->smarty->fetch('controllers/modules/modal_not_trusted_country.tpl');
|
||||
$this->modals[] = array(
|
||||
'modal_id' => 'moduleNotTrustedCountry',
|
||||
'modal_class' => 'modal-lg',
|
||||
'modal_title' => $this->l('This module is Untrusted for your country'),
|
||||
'modal_content' => $modal_content
|
||||
);
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
@@ -1677,11 +1673,9 @@ class AdminModulesControllerCore extends AdminController
|
||||
public function ajaxProcessUploadModule()
|
||||
{
|
||||
$response = array('success' => false);
|
||||
$this->postProcessDownload(false);
|
||||
$folder = $this->postProcessDownload(false);
|
||||
if (!count($this->errors)) {
|
||||
$filename = $_FILES['file']['name'];
|
||||
$filename = explode('.', $filename);
|
||||
if ($module = Module::getInstanceByName($filename[0])) {
|
||||
if ($folder && $module = Module::getInstanceByName($folder)) {
|
||||
$response['success'] = true;
|
||||
if (Module::isInstalled($module->name)) {
|
||||
$response['msg'] = $this->l('module already installed, update if available');
|
||||
@@ -1700,6 +1694,9 @@ class AdminModulesControllerCore extends AdminController
|
||||
'author' => $module->author,
|
||||
'image' => $module->image ? $module->image : ''
|
||||
);
|
||||
} else {
|
||||
$this->errors[] = $this->l('The uploaded file does not contain a valid module.');
|
||||
$response['errors'] = $this->errors;
|
||||
}
|
||||
} else {
|
||||
$response['errors'] = $this->errors;
|
||||
|
||||
@@ -1746,6 +1746,10 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
|
||||
$this->object = new $this->className();
|
||||
$this->_removeTaxFromEcotax();
|
||||
if (Tools::getValue('auto_add_to_cart')) {
|
||||
$_POST['allow_multiple_quantity'] = 0;
|
||||
}
|
||||
|
||||
$this->copyFromPost($this->object, $this->table);
|
||||
$this->object->service_product_type = Product::SERVICE_PRODUCT_WITH_ROOMTYPE;
|
||||
|
||||
@@ -1884,6 +1888,9 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
/** @var Product $object */
|
||||
$object = new $this->className((int)$id);
|
||||
$this->object = $object;
|
||||
if (Tools::getValue('auto_add_to_cart')) {
|
||||
$_POST['allow_multiple_quantity'] = 0;
|
||||
}
|
||||
|
||||
if (Validate::isLoadedObject($object)) {
|
||||
$this->_removeTaxFromEcotax();
|
||||
@@ -2791,18 +2798,53 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
public function updateLinkedHotelsAndRooms($product)
|
||||
{
|
||||
if (Validate::isLoadedObject($product)) {
|
||||
RoomTypeServiceProduct::deleteRoomProductLink($product->id);
|
||||
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$associatedRoomTypes = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($product->id)['room_types'];
|
||||
if (Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $product->service_product_type) {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
// add product link for room types
|
||||
if ($selectedRoomTypes = Tools::getValue('roomTypeBox')) {
|
||||
$selectedRoomTypes = Tools::getValue('roomTypeBox');
|
||||
|
||||
// Generate list of new associations
|
||||
$newRoomTypes = array();
|
||||
foreach ($selectedRoomTypes as $selectedRoomType) {
|
||||
if (!in_array($selectedRoomType, $associatedRoomTypes)) {
|
||||
$newRoomTypes[] = $selectedRoomType;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate list of associations to remove
|
||||
$removedRoomTypes = array();
|
||||
foreach ($associatedRoomTypes as $associatedRoomType) {
|
||||
if (!in_array($associatedRoomType, $selectedRoomTypes)) {
|
||||
$removedRoomTypes[] = $associatedRoomType;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove associations
|
||||
foreach ($removedRoomTypes as $removedRoomType) {
|
||||
RoomTypeServiceProduct::deleteRoomProductLink(
|
||||
$product->id,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE,
|
||||
$removedRoomType
|
||||
);
|
||||
}
|
||||
|
||||
// Save new associations
|
||||
if ($newRoomTypes) {
|
||||
$objRoomTypeServiceProduct->addRoomProductLink(
|
||||
$product->id,
|
||||
$selectedRoomTypes,
|
||||
$newRoomTypes,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Remove associations
|
||||
foreach ($associatedRoomTypes as $associatedRoomType) {
|
||||
RoomTypeServiceProduct::deleteRoomProductLink(
|
||||
$product->id,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE,
|
||||
$associatedRoomType
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,16 @@ class AdminOrderMessageControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
|
||||
@@ -58,6 +58,18 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
)
|
||||
);
|
||||
|
||||
// Options to display currency in order list
|
||||
$displayCurrencyOptions = array(
|
||||
array(
|
||||
'value' => Order::ORDER_LIST_PRICE_DISPLAY_IN_PAYMENT_CURRENCY,
|
||||
'name' => $this->l('Order currency')
|
||||
),
|
||||
array(
|
||||
'value' => Order::ORDER_LIST_PRICE_DISPLAY_IN_DEFAULT_CURRENCY,
|
||||
'name' => $this->l('Default currency')
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_options = array(
|
||||
'order_restrict' => array(
|
||||
'title' => $this->l('Order Restrict'),
|
||||
@@ -159,6 +171,16 @@ class AdminOrderPreferencesControllerCore extends AdminController
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_ORDER_LIST_PRICE_DISPLAY_CURRENCY' => array(
|
||||
'title' => $this->l('Display order list prices in'),
|
||||
'hint' => $this->l('Choose the currency in which you want the prices in the order list to be displayed.'),
|
||||
'desc' => $this->l('\'Order currency\' is the currency in which customer created the order and \'Default currency\' is the currency configured in localization.'),
|
||||
'validation' => 'isInt',
|
||||
'type' => 'select',
|
||||
'cast' => 'intval',
|
||||
'list' => $displayCurrencyOptions,
|
||||
'identifier' => 'value',
|
||||
),
|
||||
),
|
||||
'submit' => array('title' => $this->l('Save'))
|
||||
),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -194,10 +194,19 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
'required' => false,
|
||||
'type' => 'bool'
|
||||
),
|
||||
'WK_ROOM_LEFT_WARNING_NUMBER' => array(
|
||||
'title' => $this->l('Display remaining Number of rooms when the rooms are lower than or equal to'),
|
||||
'hint' => $this->l('Mention the minimum quantity of rooms after which alert message of remaining rooms will get displayed to users.'),
|
||||
'validation' => 'isInt',
|
||||
'cast' => 'intval',
|
||||
'type' => 'text',
|
||||
'class' => 'fixed-width-xxl',
|
||||
'visibility' => Shop::CONTEXT_ALL,
|
||||
),
|
||||
),
|
||||
'submit' => array('title' => $this->l('Save'))
|
||||
),
|
||||
'order_by_pagination' => array(
|
||||
/*'order_by_pagination' => array(
|
||||
'title' => $this->l('Pagination'),
|
||||
'fields' => array(
|
||||
'PS_PRODUCTS_PER_PAGE' => array(
|
||||
@@ -241,7 +250,7 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
)
|
||||
),
|
||||
'submit' => array('title' => $this->l('Save'))
|
||||
),
|
||||
),*/
|
||||
'fo_product_page' => array(
|
||||
'title' => $this->l('Room type page'),
|
||||
'fields' => array(
|
||||
@@ -391,29 +400,6 @@ class AdminPPreferencesControllerCore extends AdminController
|
||||
// 'bottom' => '<script type="text/javascript">stockManagementActivationAuthorization();advancedStockManagementActivationAuthorization();</script>',
|
||||
// 'submit' => array('title' => $this->l('Save'))
|
||||
// ),
|
||||
'fo_search_filters' => array(
|
||||
'title' => $this->l('Search Results Page Filters'),
|
||||
'icon' => 'icon-search',
|
||||
'fields' => array(
|
||||
'SHOW_AMENITIES_FILTER' => array(
|
||||
'title' => $this->l('Show Amenities filter'),
|
||||
'hint' => $this->l('Enable to display Amenities filter.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => false,
|
||||
'type' => 'bool',
|
||||
),
|
||||
'SHOW_PRICE_FILTER' => array(
|
||||
'title' => $this->l('Show Price filter'),
|
||||
'hint' => $this->l('Enable to display Price filter.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => false,
|
||||
'type' => 'bool',
|
||||
),
|
||||
),
|
||||
'submit' => array('title' => $this->l('Save'))
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -212,27 +212,27 @@ class AdminPerformanceControllerCore extends AdminController
|
||||
'type' => 'hidden',
|
||||
'name' => 'features_detachables_up'
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Combinations'),
|
||||
'name' => 'combination',
|
||||
'is_bool' => true,
|
||||
'disabled' => Combination::isCurrentlyUsed(),
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'combination_1',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Yes'),
|
||||
),
|
||||
array(
|
||||
'id' => 'combination_0',
|
||||
'value' => 0,
|
||||
'label' => $this->l('No')
|
||||
)
|
||||
),
|
||||
'hint' => $this->l('Choose "No" to disable Product Combinations.'),
|
||||
'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'switch',
|
||||
// 'label' => $this->l('Combinations'),
|
||||
// 'name' => 'combination',
|
||||
// 'is_bool' => true,
|
||||
// 'disabled' => Combination::isCurrentlyUsed(),
|
||||
// 'values' => array(
|
||||
// array(
|
||||
// 'id' => 'combination_1',
|
||||
// 'value' => 1,
|
||||
// 'label' => $this->l('Yes'),
|
||||
// ),
|
||||
// array(
|
||||
// 'id' => 'combination_0',
|
||||
// 'value' => 0,
|
||||
// 'label' => $this->l('No')
|
||||
// )
|
||||
// ),
|
||||
// 'hint' => $this->l('Choose "No" to disable Product Combinations.'),
|
||||
// 'desc' => Combination::isCurrentlyUsed() ? $this->l('You cannot set this parameter to No when combinations are already used by some of your products') : null
|
||||
// ),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Features'),
|
||||
|
||||
@@ -88,7 +88,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
parent::__construct();
|
||||
|
||||
$this->imageType = 'jpg';
|
||||
$this->_defaultOrderBy = 'position';
|
||||
$this->max_file_size = (int)(Configuration::get('PS_LIMIT_UPLOAD_FILE_VALUE') * 1000000);
|
||||
$this->max_image_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE');
|
||||
$this->allow_export = true;
|
||||
@@ -99,9 +98,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
'Seo' => $this->l('SEO'),
|
||||
'Images' => $this->l('Images'),
|
||||
'ServiceProduct' => $this->l('Service Products'),
|
||||
'Associations' => $this->l('Associations'),
|
||||
// 'Associations' => $this->l('Associations'),
|
||||
'Features' => $this->l('Features'),
|
||||
'Configuration' => $this->l('Configuration'),
|
||||
'Configuration' => $this->l('Rooms'),
|
||||
'Occupancy' => $this->l('Occupancy'),
|
||||
'LengthOfStay' => $this->l('Length of Stay'),
|
||||
'AdditionalFacilities' => $this->l('Additional Facilities'),
|
||||
@@ -112,7 +111,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
'Informations' => 0,
|
||||
'Prices' => 1,
|
||||
'Seo' => 2,
|
||||
'Associations' => 3,
|
||||
// 'Associations' => 3,
|
||||
'Images' => 4,
|
||||
'Features' => 5,
|
||||
'Configuration' => 6,
|
||||
@@ -144,32 +143,37 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::getValue('reset_filter_category')) {
|
||||
$this->context->cookie->id_category_products_filter = false;
|
||||
if (Tools::getValue('productFilter_a!id_category_default') === '') {
|
||||
$this->context->cookie->id_category_room_types_filter = false;
|
||||
}
|
||||
if (Shop::isFeatureActive() && $this->context->cookie->id_category_products_filter) {
|
||||
$category = new Category((int)$this->context->cookie->id_category_products_filter);
|
||||
|
||||
if (Shop::isFeatureActive() && $this->context->cookie->id_category_room_types_filter) {
|
||||
$category = new Category((int)$this->context->cookie->id_category_room_types_filter);
|
||||
if (!$category->inShop()) {
|
||||
$this->context->cookie->id_category_products_filter = false;
|
||||
$this->context->cookie->id_category_room_types_filter = false;
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminProducts'));
|
||||
}
|
||||
}
|
||||
/* Join categories table */
|
||||
if ($id_category = (int)Tools::getValue('productFilter_cl!name')) {
|
||||
$this->_category = new Category((int)$id_category);
|
||||
$_POST['productFilter_cl!name'] = $this->_category->name[$this->context->language->id];
|
||||
|
||||
// to support filter URLs with 'id_category' parameter
|
||||
if ($id_category = (int)Tools::getValue('id_category')) {
|
||||
$_POST['submitFilter'] = '1';
|
||||
$_POST['productFilter_a!id_category_default'] = $id_category;
|
||||
}
|
||||
|
||||
if (($id_category = (int)Tools::getValue('id_category'))
|
||||
|| ($id_category = (int) Tools::getValue('productFilter_a!id_category_default'))
|
||||
) {
|
||||
$this->id_current_category = $id_category;
|
||||
$this->context->cookie->id_category_room_types_filter = $id_category;
|
||||
} elseif ($id_category = $this->context->cookie->id_category_room_types_filter) {
|
||||
$this->id_current_category = $id_category;
|
||||
}
|
||||
if ($this->id_current_category) {
|
||||
$this->_category = new Category((int)$this->id_current_category);
|
||||
$this->position_group_identifier = (int) $this->id_current_category;
|
||||
} else {
|
||||
if ($id_category = (int)Tools::getValue('id_category')) {
|
||||
$this->id_current_category = $id_category;
|
||||
$this->context->cookie->id_category_products_filter = $id_category;
|
||||
} elseif ($id_category = $this->context->cookie->id_category_products_filter) {
|
||||
$this->id_current_category = $id_category;
|
||||
}
|
||||
if ($this->id_current_category) {
|
||||
$this->_category = new Category((int)$this->id_current_category);
|
||||
} else {
|
||||
$this->_category = new Category();
|
||||
}
|
||||
$this->_category = new Category();
|
||||
}
|
||||
|
||||
$join_category = false;
|
||||
@@ -194,12 +198,16 @@ class AdminProductsControllerCore extends AdminController
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_product` = a.`id_product` AND image_shop.`cover` = 1 AND image_shop.id_shop = '.$id_shop.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_image` = image_shop.`id_image`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_download` pd ON (pd.`id_product` = a.`id_product` AND pd.`active` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'address` aa ON (aa.`id_hotel` = hb.`id`)';
|
||||
LEFT JOIN `'._DB_PREFIX_.'address` aa ON (aa.`id_hotel` = hb.`id`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON (fp.`id_product` = a.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_demand` hrtd ON (hrtd.`id_product` = a.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product` hrtsp ON ((hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_HOTEL.' AND hrtsp.`id_element` = hrt.`id_hotel`) OR (hrtsp.`element_type` = '.(int) RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.' AND hrtsp.`id_element` = a.`id_product`))';
|
||||
|
||||
$this->_select .= ' (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, ';
|
||||
$this->_select .= 'hrt.`adults`, hrt.`children`, hb.`id` as id_hotel, aa.`city`, hbl.`hotel_name`, ';
|
||||
$this->_select .= 'hrt.`adults`, hrt.`children`, hrt.`max_guests`, hb.`id` as id_hotel, aa.`city`, hbl.`hotel_name`, ';
|
||||
$this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, ';
|
||||
$this->_select .= $alias_image.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`';
|
||||
$this->_select .= ', IFNULL((SELECT hap.`active` FROM `'._DB_PREFIX_.'htl_advance_payment` hap WHERE hap.`id_product` = a.`id_product`), 0) AS advance_payment';
|
||||
|
||||
if ($join_category) {
|
||||
$this->_join .= ' INNER JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product` AND cp.`id_category` = '.(int)$this->_category->id.') ';
|
||||
@@ -209,8 +217,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
// show the list of the product according to the booking or service products
|
||||
$this->_where .= ' AND a.`booking_product` = 1';
|
||||
|
||||
$this->_use_found_rows = false;
|
||||
$this->_group = '';
|
||||
$this->_group = ' GROUP BY a.`id_product`';
|
||||
|
||||
$this->fields_list = array();
|
||||
$this->fields_list['id_product'] = array(
|
||||
@@ -237,33 +244,51 @@ class AdminProductsControllerCore extends AdminController
|
||||
'filter_key' => 'shop!name',
|
||||
);
|
||||
} else {
|
||||
$hotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1);
|
||||
foreach ($hotels as $hotel) {
|
||||
$addressInfo = HotelBranchInformation::getAddress($hotel['id_hotel']);
|
||||
$this->hotelsArray[$hotel['id_hotel']] = $hotel['hotel_name'].', '.$addressInfo['city'];
|
||||
}
|
||||
|
||||
$this->fields_list['hotel_name'] = array(
|
||||
'title' => $this->l('Hotel'),
|
||||
'filter_key' => 'hbl!hotel_name',
|
||||
'callback' => 'getHotelName',
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'operator' => 'or',
|
||||
'filter_key' => 'hrt!id_hotel',
|
||||
'list' => $this->hotelsArray,
|
||||
'optional' => true,
|
||||
'class' => 'chosen',
|
||||
'remove_onchange' => true,
|
||||
'visible_default' => true,
|
||||
);
|
||||
}
|
||||
$this->fields_list['adults'] = array(
|
||||
'title' => $this->l('Adults'),
|
||||
'filter_key' => 'hrt!adults',
|
||||
'type' => 'range',
|
||||
'align' => 'center',
|
||||
);
|
||||
$this->fields_list['child'] = array(
|
||||
$this->fields_list['children'] = array(
|
||||
'title' => $this->l('Children'),
|
||||
'filter_key' => 'hrt!children',
|
||||
'type' => 'range',
|
||||
'align' => 'center',
|
||||
);
|
||||
// use it for total rooms
|
||||
$this->fields_list['num_rooms'] = array(
|
||||
'title' => $this->l('Total Rooms'),
|
||||
'align' => 'center',
|
||||
'type' => 'range',
|
||||
'havingFilter' => true,
|
||||
);
|
||||
$this->fields_list['price'] = array(
|
||||
'title' => $this->l('Base price'),
|
||||
'type' => 'price',
|
||||
'title' => $this->l('Base Price'),
|
||||
'type' => 'range',
|
||||
'validation' => 'isFloat',
|
||||
'align' => 'text-left',
|
||||
'filter_key' => 'a!price'
|
||||
'filter_key' => 'a!price',
|
||||
'callback' => 'displayBasePrice',
|
||||
);
|
||||
$this->fields_list['price_final'] = array(
|
||||
'title' => $this->l('Final price'),
|
||||
@@ -279,12 +304,126 @@ class AdminProductsControllerCore extends AdminController
|
||||
'active' => 'status',
|
||||
'filter_key' => $alias.'!active',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'class' => 'fixed-width-sm',
|
||||
'type' => 'select',
|
||||
'list' => array(1 => $this->l('Yes'), 0 => $this->l('No')),
|
||||
'optional' => true,
|
||||
'visible_default' => true,
|
||||
'remove_onchange' => true,
|
||||
'orderby' => false
|
||||
);
|
||||
|
||||
if ($join_category && (int)$this->id_current_category) {
|
||||
$this->fields_list['max_guests'] = array(
|
||||
'title' => $this->l('Maximum Occupancy'),
|
||||
'filter_key' => 'hrt!max_guests',
|
||||
'type' => 'range',
|
||||
'align' => 'center',
|
||||
'optional' => true,
|
||||
);
|
||||
|
||||
if (Configuration::get('WK_ALLOW_ADVANCED_PAYMENT')) {
|
||||
$this->fields_list['advance_payment'] = array(
|
||||
'title' => $this->l('Advance Payment'),
|
||||
'active' => 'advance_payment',
|
||||
'align' => 'text-center',
|
||||
'type' => 'bool',
|
||||
'optional' => true,
|
||||
'havingFilter' => true,
|
||||
'visible_default' => true,
|
||||
'orderby' => false,
|
||||
);
|
||||
}
|
||||
|
||||
$taxRulesGroups = array();
|
||||
foreach (TaxRulesGroup::getTaxRulesGroups(true) as $taxRulesGroup) {
|
||||
$taxRulesGroups[$taxRulesGroup['id_tax_rules_group']] = $taxRulesGroup['name'];
|
||||
}
|
||||
$this->fields_list['id_tax_rules_group'] = array(
|
||||
'title' => $this->l('Tax Rules'),
|
||||
'align' => 'text-center',
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'operator' => 'or',
|
||||
'filter_key' => 'a!id_tax_rules_group',
|
||||
'list' => $taxRulesGroups,
|
||||
'displayed' => false,
|
||||
);
|
||||
|
||||
$features = array();
|
||||
foreach (Feature::getFeatures($this->context->language->id) as $feature) {
|
||||
$features[$feature['id_feature']] = $feature['name'];
|
||||
}
|
||||
$this->fields_list['id_feature'] = array(
|
||||
'title' => $this->l('Features'),
|
||||
'align' => 'text-center',
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'operator' => 'and',
|
||||
'filter_key' => 'fp!id_feature',
|
||||
'list' => $features,
|
||||
'displayed' => false,
|
||||
);
|
||||
|
||||
$objProduct = new Product();
|
||||
$allServiceProducts = $objProduct->getServiceProducts();
|
||||
$serviceProducts = array();
|
||||
foreach ($allServiceProducts as $serviceProduct) {
|
||||
$serviceProducts[$serviceProduct['id_product']] = $serviceProduct['name'];
|
||||
}
|
||||
$this->fields_list['id_service_product'] = array(
|
||||
'title' => $this->l('Service Products'),
|
||||
'align' => 'text-center',
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'operator' => 'and',
|
||||
'filter_key' => 'hrtsp!id_product',
|
||||
'list' => $serviceProducts,
|
||||
'displayed' => false,
|
||||
);
|
||||
|
||||
$additionalFacilities = array();
|
||||
$objHotelRoomTypeGlobalDemand = new HotelRoomTypeGlobalDemand();
|
||||
$demands = $objHotelRoomTypeGlobalDemand->getAllDemands();
|
||||
foreach ($demands as $demand) {
|
||||
$additionalFacilities[$demand['id_global_demand']] = $demand['name'];
|
||||
}
|
||||
$this->fields_list['id_global_demand'] = array(
|
||||
'title' => $this->l('Additional Facilities'),
|
||||
'align' => 'text-center',
|
||||
'type' => 'select',
|
||||
'multiple' => true,
|
||||
'operator' => 'and',
|
||||
'filter_key' => 'hrtd!id_global_demand',
|
||||
'list' => $additionalFacilities,
|
||||
'displayed' => false,
|
||||
);
|
||||
|
||||
$this->locationsAndHotels = array();
|
||||
$idLocationsCategory = Configuration::get('PS_LOCATIONS_CATEGORY');
|
||||
$this->objLocationsCategory = new Category($idLocationsCategory, $this->context->language->id);
|
||||
$nestedCategories = Category::getNestedCategories($idLocationsCategory);
|
||||
if ($nestedCategories) {
|
||||
foreach ($nestedCategories[$idLocationsCategory]['children'] as $childCategory) {
|
||||
$this->buildCategoryOptions($childCategory);
|
||||
}
|
||||
}
|
||||
$this->fields_list['id_category_default'] = array(
|
||||
'title' => $this->l('Location/Hotel'),
|
||||
'align' => 'text-center',
|
||||
'type' => 'select',
|
||||
'list' => $this->locationsAndHotels,
|
||||
'filter_key' => 'a!id_category_default',
|
||||
'remove_onchange' => true,
|
||||
'displayed' => false,
|
||||
);
|
||||
|
||||
// display Position column only if it is a hotel category
|
||||
if ($join_category
|
||||
&& (int) $this->id_current_category
|
||||
&& HotelBranchInformation::getHotelIdByIdCategory($this->id_current_category)
|
||||
) {
|
||||
$this->_orderBy = 'position';
|
||||
$this->_orderWay = 'ASC';
|
||||
|
||||
$this->fields_list['position'] = array(
|
||||
'title' => $this->l('Position'),
|
||||
'filter_key' => 'cp!position',
|
||||
@@ -294,13 +433,21 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function getHotelName($hotelName, $row)
|
||||
private function buildCategoryOptions($category)
|
||||
{
|
||||
if ($hotelName && isset($row['city'])) {
|
||||
return $hotelName.' - '.$row['city'];
|
||||
}
|
||||
$space = str_repeat(' ', 5 * (($category['level_depth'] - $this->objLocationsCategory->level_depth) - 1));
|
||||
$this->locationsAndHotels[$category['id_category']] = $space.$category['name'];
|
||||
|
||||
return '--';
|
||||
if (isset($category['children']) && count($category['children'])) {
|
||||
foreach ($category['children'] as $childCategory) {
|
||||
$this->buildCategoryOptions($childCategory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function displayBasePrice($basePrice, $tr)
|
||||
{
|
||||
return Tools::displayPrice($basePrice, (int) Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
}
|
||||
|
||||
public static function getQuantities($hotelName, $tr)
|
||||
@@ -352,6 +499,23 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
protected function filterToField($key, $filter)
|
||||
{
|
||||
if ($key == 'a!id_category_default') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::filterToField($key, $filter);
|
||||
}
|
||||
|
||||
public function processResetFilters($list_id = null)
|
||||
{
|
||||
parent::processResetFilters($list_id);
|
||||
|
||||
// reset category filter
|
||||
$this->context->cookie->id_category_room_types_filter = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product|ObjectModel $object
|
||||
* @param string $table
|
||||
@@ -628,6 +792,10 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
// update `id_category_default`
|
||||
$objHotelBranchInformation = new HotelBranchInformation($id_hotel_new);
|
||||
$product->id_category_default = $objHotelBranchInformation->id_category;
|
||||
|
||||
// update lang fields
|
||||
foreach (Language::getLanguages(true) as $language) {
|
||||
$product->link_rewrite[$language['id_lang']] = Tools::str2url($product->name[$language['id_lang']]);
|
||||
@@ -1106,93 +1274,20 @@ class AdminProductsControllerCore extends AdminController
|
||||
$idElement = Tools::getValue('id_element');
|
||||
$idProduct = Tools::getValue('id_product');
|
||||
if ($idElement && $idProduct) {
|
||||
$position = Tools::getValue('position');
|
||||
$toRowIndex = Tools::getValue('to_row_index');
|
||||
if (RoomTypeServiceProduct:: changePositions($idProduct, $idElement, $toRowIndex, $position)) {
|
||||
$response['msg'] = $this->l('Updated Successfully');
|
||||
$newPosition = Tools::getValue('new_position');
|
||||
if (RoomTypeServiceProduct::updatePosition(
|
||||
$idProduct,
|
||||
$idElement,
|
||||
$newPosition,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
|
||||
)) {
|
||||
$response['msg'] = $this->l('Positions updated successfully.');
|
||||
$response['success'] = true;
|
||||
}
|
||||
}
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessUpdatedServiceProductPrice()
|
||||
{
|
||||
$response = array();
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
// process price update
|
||||
$idProduct = Tools::getValue('id_product');
|
||||
$idServiceProduct = Tools::getValue('service_product_id');
|
||||
$price = Tools::getValue('price');
|
||||
$id_tax_rules_group = Tools::getValue('id_tax_rules_group');
|
||||
|
||||
if (!$idProduct) {
|
||||
$error = $this->l('Invalid room type.');
|
||||
} else {
|
||||
$objRoomType = new HotelRoomType();
|
||||
if (!Product::isBookingProduct($idProduct)) {
|
||||
$error = $this->l('Room Type details not found. Save room type details before updating price.');
|
||||
}
|
||||
}
|
||||
if (!$idServiceProduct) {
|
||||
$error = $this->l('Service Product not found.');
|
||||
}
|
||||
|
||||
if (!$price) {
|
||||
$error = $this->l('Service product price must not be empty');
|
||||
} elseif (!Validate::isPrice($price)) {
|
||||
$error = $this->l('Service product price is invalid');
|
||||
}
|
||||
|
||||
if (!isset($error)) {
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
$priceExists = $objRoomTypeServiceProductPrice->getProductRoomTypeLinkPriceInfo(
|
||||
$idServiceProduct,
|
||||
$idProduct,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
|
||||
);
|
||||
|
||||
if ($priceExists) {
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice($priceExists['id_room_type_service_product_price']);
|
||||
} else {
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
$objRoomTypeServiceProductPrice->id_product = $idServiceProduct;
|
||||
$objRoomTypeServiceProductPrice->id_element = $idProduct;
|
||||
$objRoomTypeServiceProductPrice->element_type = RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE;
|
||||
}
|
||||
|
||||
$objRoomTypeServiceProductPrice->price = $price;
|
||||
$objRoomTypeServiceProductPrice->id_tax_rules_group = $id_tax_rules_group;
|
||||
|
||||
if (!$objRoomTypeServiceProductPrice->save()) {
|
||||
$error = $this->l('Unable to save price, please try again.');
|
||||
} else {
|
||||
$response['price'] = Tools::DisplayPrice($price);
|
||||
if (Validate::isLoadedObject($objTaxRuleGroup = new TaxRulesGroup(
|
||||
$objRoomTypeServiceProductPrice->id_tax_rules_group,
|
||||
$this->context->language->id
|
||||
))) {
|
||||
$response['tax_rules_group_name'] = $objTaxRuleGroup->name;
|
||||
} else {
|
||||
$response['tax_rules_group_name'] = $this->l('No tax');
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error = Tools::displayError('You do not have permission to edit this.');
|
||||
}
|
||||
|
||||
if (isset($error)) {
|
||||
$response['status'] = 'error';
|
||||
$response['message'] = $error;
|
||||
} else {
|
||||
$response['status'] = 'ok';
|
||||
$response['message'] = $this->l('Price Updated Successfully');
|
||||
}
|
||||
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
public function initProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitAddproductAndStay') || Tools::isSubmit('submitAddproduct')) {
|
||||
@@ -1241,6 +1336,14 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('You do not have permission to add this.');
|
||||
}
|
||||
}
|
||||
// Toggle Advance Payment
|
||||
elseif (Tools::getIsset('advance_payment'.$this->table)) {
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
$this->action = 'toggleAdvancePayment';
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
|
||||
}
|
||||
}
|
||||
// Product images management
|
||||
elseif (Tools::getValue('id_image') && Tools::getValue('ajax')) {
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
@@ -1793,6 +1896,41 @@ class AdminProductsControllerCore extends AdminController
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function processToggleAdvancePayment()
|
||||
{
|
||||
if (Configuration::get('WK_ALLOW_ADVANCED_PAYMENT')) {
|
||||
$this->loadObject(true);
|
||||
if (!Validate::isLoadedObject($this->object)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Product::isBookingProduct($this->object->id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$objHotelAdvancedPayment = new HotelAdvancedPayment();
|
||||
$roomTypeAdvancePaymentInfo = $objHotelAdvancedPayment->getIdAdvPaymentByIdProduct($this->object->id);
|
||||
if ($roomTypeAdvancePaymentInfo) {
|
||||
$objHotelAdvancedPayment = new HotelAdvancedPayment($roomTypeAdvancePaymentInfo['id']);
|
||||
$objHotelAdvancedPayment->active = !$objHotelAdvancedPayment->active;
|
||||
} else {
|
||||
$objHotelAdvancedPayment->id_product = $this->object->id;
|
||||
$objHotelAdvancedPayment->payment_type = '';
|
||||
$objHotelAdvancedPayment->value = '';
|
||||
$objHotelAdvancedPayment->id_currency = '';
|
||||
$objHotelAdvancedPayment->tax_include = '';
|
||||
$objHotelAdvancedPayment->calculate_from = 0;
|
||||
$objHotelAdvancedPayment->active = 1;
|
||||
}
|
||||
|
||||
if ($objHotelAdvancedPayment->save()) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&conf=4');
|
||||
} else {
|
||||
$this->errors[] = $this->l('Something went wrong while updating Advance payment status.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function processUpdate()
|
||||
{
|
||||
$existing_product = $this->object;
|
||||
@@ -1843,6 +1981,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
|
||||
if ($object->update()) {
|
||||
// update position in category
|
||||
$object->setPositionInCategory(Tools::getValue('category_position'));
|
||||
|
||||
// If the product doesn't exist in the current shop but exists in another shop
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP && !$existing_product->isAssociatedToShop($this->context->shop->id)) {
|
||||
$out_of_stock = StockAvailable::outOfStock($existing_product->id, $existing_product->id_shop_default);
|
||||
@@ -1885,6 +2026,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
if ($this->isTabSubmitted('Occupancy')) {
|
||||
$this->processOccupancy();
|
||||
}
|
||||
if ($this->isTabSubmitted('ServiceProduct')) {
|
||||
$this->processServiceProduct();
|
||||
}
|
||||
if ($this->isTabSubmitted('LengthOfStay')) {
|
||||
$this->processLengthOfStay();
|
||||
}
|
||||
@@ -2125,6 +2269,21 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Category Position
|
||||
if (Validate::isLoadedObject($this->object)) {
|
||||
$categoryPositon = Tools::getValue('category_position');
|
||||
if ($categoryPositon < 0) {
|
||||
$this->errors[] = $this->l('Position can not be less than 0.');
|
||||
}
|
||||
|
||||
if (isset($objHotel) && Validate::isLoadedObject($objHotel)) {
|
||||
$maxPosition = Product::getHighestPositionInCategory($objHotel->id_category);
|
||||
if ($categoryPositon > $maxPosition) {
|
||||
$this->errors[] = sprintf($this->l('Position can not be greater than %d.'), $maxPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2265,35 +2424,14 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->tpl_form_vars['product_tabs'] = $product_tabs;
|
||||
}
|
||||
} else {
|
||||
if ($id_category = (int)$this->id_current_category) {
|
||||
self::$currentIndex .= '&id_category='.(int)$this->id_current_category;
|
||||
}
|
||||
|
||||
// If products from all categories are displayed, we don't want to use sorting by position
|
||||
if (!$id_category) {
|
||||
if (!(int) $this->id_current_category) {
|
||||
$this->_defaultOrderBy = $this->identifier;
|
||||
if ($this->context->cookie->{$this->table.'Orderby'} == 'position') {
|
||||
unset($this->context->cookie->{$this->table.'Orderby'});
|
||||
unset($this->context->cookie->{$this->table.'Orderway'});
|
||||
}
|
||||
}
|
||||
if (!$id_category) {
|
||||
$id_category = Configuration::get('PS_ROOT_CATEGORY');
|
||||
}
|
||||
$this->tpl_list_vars['is_category_filter'] = (bool)$this->id_current_category;
|
||||
|
||||
// Generate category selection tree
|
||||
$catFilter = $this->l('Filter by Places');
|
||||
$tree = new HelperTreeCategories('categories-tree', $catFilter);
|
||||
$tree->setAttribute('is_category_filter', (bool)$this->id_current_category)
|
||||
->setAttribute('base_url', preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex).'&token='.$this->token)
|
||||
->setInputName('id-category')
|
||||
->setRootCategory((int)Configuration::get('PS_LOCATIONS_CATEGORY'))
|
||||
->setSelectedCategories(array((int)$id_category));
|
||||
$this->tpl_list_vars['category_tree'] = $tree->render();
|
||||
|
||||
// used to build the new url when changing category
|
||||
$this->tpl_list_vars['base_url'] = preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex).'&token='.$this->token;
|
||||
}
|
||||
|
||||
parent::initContent();
|
||||
@@ -2354,7 +2492,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$helper->source = $this->context->link->getAdminLink('AdminStats').'&ajax=1&action=getKpi&kpi=disabled_room_types';
|
||||
$helper->refresh = (bool)(ConfigurationKPI::get('DISABLED_ROOM_TYPES_EXPIRE') < $time);
|
||||
$helper->tooltip = $this->l('X% of your room types are disabled and not visible to your customers', null, null, false);
|
||||
$helper->href = Context::getContext()->link->getAdminLink('AdminProducts').'&productFilter_active=0&submitFilterproduct=1';
|
||||
$helper->href = Context::getContext()->link->getAdminLink('AdminProducts').'&productFilter_sa!active=0&submitFilterproduct=1';
|
||||
$kpis[] = $helper->generate();
|
||||
|
||||
$helper = new HelperKpiRow();
|
||||
@@ -2368,6 +2506,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->addRowAction('preview');
|
||||
$this->addRowAction('duplicate');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->tpl_list_vars['title'] = $this->l('Room Types');
|
||||
|
||||
return parent::renderList();
|
||||
}
|
||||
|
||||
@@ -2763,6 +2904,13 @@ class AdminProductsControllerCore extends AdminController
|
||||
$hotelRoomInfo = $objRoomInfo->getHotelRoomInfo($obj->id, $hotelRoomType['id_hotel']);
|
||||
if ($hotelRoomInfo) {
|
||||
foreach ($hotelRoomInfo as &$room) {
|
||||
$bookedDates = $objRoomInfo->getFutureBookings($room['id']);
|
||||
foreach($bookedDates as &$bookedDate) {
|
||||
$bookedDate['date_from_formatted'] = Tools::displayDate($bookedDate['date_from']);
|
||||
$bookedDate['date_to_formatted'] = Tools::displayDate($bookedDate['date_to']);
|
||||
}
|
||||
$room['booked_dates'] = json_encode($bookedDates);
|
||||
|
||||
if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
|
||||
$disabledDates = $objRoomDisableDates->getRoomDisableDates($room['id']);
|
||||
$room['disable_dates_json'] = json_encode($disabledDates);
|
||||
@@ -2796,7 +2944,6 @@ class AdminProductsControllerCore extends AdminController
|
||||
{
|
||||
$data = $this->createTemplate($this->tpl_form);
|
||||
if ($obj->id) {
|
||||
|
||||
$address = new Address();
|
||||
$address->id_country = (int)$this->context->country->id;
|
||||
$tax_rules_groups = TaxRulesGroup::getTaxRulesGroups(true);
|
||||
@@ -2828,53 +2975,89 @@ class AdminProductsControllerCore extends AdminController
|
||||
|
||||
$objRoomType = new HotelRoomType();
|
||||
if ($hotelRoomType = $objRoomType->getRoomTypeInfoByIdProduct($obj->id)) {
|
||||
$allServiceProducts = $obj->getServiceProducts();
|
||||
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
$serviceProducts = $objRoomTypeServiceProduct->getProductsForRoomType(
|
||||
$obj->id
|
||||
);
|
||||
foreach ($serviceProducts as &$serviceProduct) {
|
||||
$product = new Product($serviceProduct['id_product'], false, $this->context->language->id);
|
||||
$serviceProductPriceInfo = $objRoomTypeServiceProductPrice->getProductRoomTypeLinkPriceInfo(
|
||||
$product->id,
|
||||
$obj->id,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
|
||||
);
|
||||
$serviceProduct['id_product'] = $product->id;
|
||||
$serviceProduct['name'] = $product->name;
|
||||
$serviceProduct['auto_add_to_cart'] = $product->auto_add_to_cart;
|
||||
$serviceProduct['category'] = $product->category;
|
||||
$serviceProduct['default_price'] = $product->price;
|
||||
$serviceProduct['id_tax_rules_group'] = $product->id_tax_rules_group;
|
||||
if ($serviceProductPriceInfo) {
|
||||
$serviceProduct['custom_price'] = $serviceProductPriceInfo['price'];
|
||||
$serviceProduct['id_tax_rules_group'] = $serviceProductPriceInfo['id_tax_rules_group'];
|
||||
if ($serviceProductPriceInfo['id_tax_rules_group'] == 0) {
|
||||
$serviceProduct['tax_rules_group_name'] = 'No tax';
|
||||
|
||||
// change index of array to id_product for faster access
|
||||
$tmpServiceProducts = $objRoomTypeServiceProduct->getProductsForRoomType($obj->id);
|
||||
$roomTypeServiceProducts = array();
|
||||
foreach ($tmpServiceProducts as $serviceProduct) {
|
||||
$roomTypeServiceProducts[$serviceProduct['id_product']] = $serviceProduct;
|
||||
}
|
||||
|
||||
// classify all service products into associated and unassociated groups
|
||||
$associatedServiceProducts = array();
|
||||
$unassociatedServiceProducts = array();
|
||||
$idsRoomTypeServiceProduct = array_column($roomTypeServiceProducts, 'id_product');
|
||||
foreach ($allServiceProducts as &$serviceProduct) {
|
||||
if (in_array($serviceProduct['id_product'], $idsRoomTypeServiceProduct)) {
|
||||
$associationInfo = array();
|
||||
|
||||
$objProduct = new Product($serviceProduct['id_product'], false, $this->context->language->id);
|
||||
$serviceProductPriceInfo = $objRoomTypeServiceProductPrice->getProductRoomTypeLinkPriceInfo(
|
||||
$objProduct->id,
|
||||
$obj->id,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
|
||||
);
|
||||
|
||||
$associationInfo['id_room_type_service_product'] = $roomTypeServiceProducts[$serviceProduct['id_product']]['id_room_type_service_product'];
|
||||
$associationInfo['position'] = $roomTypeServiceProducts[$serviceProduct['id_product']]['position'];
|
||||
$associationInfo['id_product'] = $objProduct->id;
|
||||
$associationInfo['name'] = $objProduct->name;
|
||||
$associationInfo['auto_add_to_cart'] = $objProduct->auto_add_to_cart;
|
||||
$associationInfo['category'] = $objProduct->category;
|
||||
$associationInfo['default_price'] = $objProduct->price;
|
||||
$associationInfo['id_tax_rules_group'] = $objProduct->id_tax_rules_group;
|
||||
|
||||
// assign custom price only if it is saved for service product
|
||||
if ($serviceProductPriceInfo) {
|
||||
$associationInfo['custom_price'] = $serviceProductPriceInfo['price'];
|
||||
$associationInfo['id_tax_rules_group'] = $serviceProductPriceInfo['id_tax_rules_group'];
|
||||
if ($serviceProductPriceInfo['id_tax_rules_group'] == 0) {
|
||||
$associationInfo['tax_rules_group_name'] = $this->l('No tax');
|
||||
} else {
|
||||
$objTaxRuleGroup = new TaxRulesGroup(
|
||||
$serviceProductPriceInfo['id_tax_rules_group'],
|
||||
$this->context->language->id
|
||||
);
|
||||
$associationInfo['tax_rules_group_name'] = $objTaxRuleGroup->name;
|
||||
}
|
||||
$associationInfo['id_room_type_service_product_price'] = $serviceProductPriceInfo['id_room_type_service_product_price'];
|
||||
}
|
||||
|
||||
if ($objProduct->id_tax_rules_group == 0) {
|
||||
$associationInfo['default_tax_rules_group_name'] = $this->l('No tax');
|
||||
} else {
|
||||
$objTaxRuleGroup = new TaxRulesGroup(
|
||||
$serviceProductPriceInfo['id_tax_rules_group'],
|
||||
$objProduct->id_tax_rules_group,
|
||||
$this->context->language->id
|
||||
);
|
||||
$serviceProduct['tax_rules_group_name'] = $objTaxRuleGroup->name;
|
||||
$associationInfo['default_tax_rules_group_name'] = $objTaxRuleGroup->name;
|
||||
}
|
||||
$serviceProduct['id_room_type_service_product_price'] = $serviceProductPriceInfo['id_room_type_service_product_price'];
|
||||
}
|
||||
|
||||
if ($product->id_tax_rules_group == 0) {
|
||||
$serviceProduct['default_tax_rules_group_name'] = 'No tax';
|
||||
$serviceProduct['is_associated'] = true;
|
||||
$serviceProduct['association_info'] = $associationInfo;
|
||||
|
||||
$associatedServiceProducts[$associationInfo['position']] = $serviceProduct;
|
||||
} else {
|
||||
$objTaxRuleGroup = new TaxRulesGroup(
|
||||
$product->id_tax_rules_group,
|
||||
$this->context->language->id
|
||||
);
|
||||
$serviceProduct['default_tax_rules_group_name'] = $objTaxRuleGroup->name;
|
||||
$serviceProduct['is_associated'] = false;
|
||||
|
||||
$objTaxRulesGroup = new TaxRulesGroup($serviceProduct['id_tax_rules_group'], $this->context->language->id);
|
||||
$serviceProduct['tax_rules_group_name'] = $objTaxRulesGroup->name;
|
||||
|
||||
$unassociatedServiceProducts[] = $serviceProduct;
|
||||
}
|
||||
}
|
||||
|
||||
ksort($associatedServiceProducts);
|
||||
|
||||
$data->assign(array(
|
||||
'product' => $obj,
|
||||
'currency' => $this->context->currency,
|
||||
'service_products' => $serviceProducts,
|
||||
'associated_service_products' => $associatedServiceProducts,
|
||||
'unassociated_service_products' => $unassociatedServiceProducts,
|
||||
'tax_rules_groups' => $tax_rules_groups,
|
||||
'taxesRatesByGroup' => $tax_rates,
|
||||
));
|
||||
@@ -2886,6 +3069,115 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->tpl_form_vars['custom_form'] = $data->fetch();
|
||||
}
|
||||
|
||||
public function processServiceProduct()
|
||||
{
|
||||
$idProduct = Tools::getValue('id_product');
|
||||
|
||||
if (!$idProduct || !Validate::isUnsignedInt($idProduct) || !Product::isBookingProduct($idProduct)) {
|
||||
$this->errors[] = $this->l('Something went wrong while saving service products.');
|
||||
}
|
||||
|
||||
if (Validate::isLoadedObject($objProduct = new Product($idProduct))) {
|
||||
// validate submitted details
|
||||
$availableServiceProducts = Tools::getValue('available_service_products');
|
||||
$objServiceProducts = array();
|
||||
foreach ($availableServiceProducts as $idServiceProduct) {
|
||||
$prefix = 'service_product_'.$idServiceProduct.'_';
|
||||
|
||||
$isAssociated = in_array(Tools::getValue($prefix.'associated'), array('on', 'true', '1'));
|
||||
$price = Tools::getValue($prefix.'price');
|
||||
$idTaxRulesGroup = Tools::getValue($prefix.'id_tax_rules_group');
|
||||
|
||||
if ($isAssociated) {
|
||||
$objServiceProduct = new Product($idServiceProduct, false, $this->context->language->id);
|
||||
if (Validate::isLoadedObject($objServiceProduct)) {
|
||||
// cache for faster access in next foreach loop
|
||||
$objServiceProducts[$idServiceProduct] = $objServiceProduct;
|
||||
|
||||
if (!$price) {
|
||||
$this->errors[] = sprintf($this->l('Price for service product \'%s\' is empty.'), $objServiceProduct->name);
|
||||
} elseif (!Validate::isPrice($price)) {
|
||||
$this->errors[] = sprintf($this->l('Price for service product \'%s\' is invalid.'), $objServiceProduct->name);
|
||||
}
|
||||
} else{
|
||||
$this->errors[] = sprintf($this->l('Service product #%s is not available.'), $idServiceProduct);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
// save submitted details
|
||||
foreach ($availableServiceProducts as $idServiceProduct) {
|
||||
$prefix = 'service_product_'.$idServiceProduct.'_';
|
||||
|
||||
$isAssociated = in_array(Tools::getValue($prefix.'associated'), array('on', 'true', '1'));
|
||||
$price = Tools::getValue($prefix.'price');
|
||||
$idTaxRulesGroup = Tools::getValue($prefix.'id_tax_rules_group');
|
||||
|
||||
if ($isAssociated) {
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
|
||||
// if already associated
|
||||
if ($objRoomTypeServiceProduct->isRoomTypeLinkedWithProduct($idProduct, $idServiceProduct)) {
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
$priceInfo = $objRoomTypeServiceProductPrice->getProductRoomTypeLinkPriceInfo(
|
||||
$idServiceProduct,
|
||||
$idProduct,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
|
||||
);
|
||||
|
||||
$objRoomTypeServiceProductPrice = null;
|
||||
if ($priceInfo) {
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice($priceInfo['id_room_type_service_product_price']);
|
||||
} else {
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
$objRoomTypeServiceProductPrice->id_product = $idServiceProduct;
|
||||
$objRoomTypeServiceProductPrice->id_element = $idProduct;
|
||||
$objRoomTypeServiceProductPrice->element_type = RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE;
|
||||
}
|
||||
|
||||
$objRoomTypeServiceProductPrice->price = $price;
|
||||
$objRoomTypeServiceProductPrice->id_tax_rules_group = $idTaxRulesGroup;
|
||||
|
||||
$objRoomTypeServiceProductPrice->save();
|
||||
} else {
|
||||
// create new association
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
$objRoomTypeServiceProduct->addRoomProductLink(
|
||||
$idServiceProduct,
|
||||
$idProduct,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE
|
||||
);
|
||||
|
||||
$objRoomTypeServiceProductPrice = new RoomTypeServiceProductPrice();
|
||||
$objRoomTypeServiceProductPrice->id_product = $idServiceProduct;
|
||||
$objRoomTypeServiceProductPrice->id_element = $idProduct;
|
||||
$objRoomTypeServiceProductPrice->element_type = RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE;
|
||||
$objRoomTypeServiceProductPrice->price = $price;
|
||||
$objRoomTypeServiceProductPrice->id_tax_rules_group = $idTaxRulesGroup;
|
||||
$objRoomTypeServiceProductPrice->save();
|
||||
}
|
||||
} else {
|
||||
// remove association
|
||||
RoomTypeServiceProduct::deleteRoomProductLink(
|
||||
$idServiceProduct,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE,
|
||||
$idProduct
|
||||
);
|
||||
|
||||
RoomTypeServiceProductPrice::deleteRoomProductPrices(
|
||||
$idServiceProduct,
|
||||
RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE,
|
||||
$idProduct
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = $this->l('Please save room type details before saving service products.');
|
||||
}
|
||||
}
|
||||
|
||||
// send information for the occupancy tab
|
||||
public function initFormOccupancy($obj)
|
||||
{
|
||||
@@ -3205,6 +3497,14 @@ class AdminProductsControllerCore extends AdminController
|
||||
$objHotelRoomDisableDates->reason = $disableDate['reason'];
|
||||
$objHotelRoomDisableDates->add();
|
||||
}
|
||||
|
||||
Hook::exec(
|
||||
'actionRoomDisableDatesAddAfter',
|
||||
array(
|
||||
'room_info' => $roomInfo,
|
||||
'disable_dates' => $disableDates
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3243,10 +3543,15 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid floor for room %s.'), $roomIndex);
|
||||
}
|
||||
|
||||
if ($roomInfo['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
|
||||
if ($roomInfo['id_status'] == HotelRoomInformation::STATUS_INACTIVE) {
|
||||
$objHotelRoomInformation = new HotelRoomInformation();
|
||||
if (count($objHotelRoomInformation->getFutureBookings($roomInfo['id']))) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Cannot change room %s status to inactive as it already has some bookings, Please check the bookings and move those bookings to another room if you want make this room inactive'), $roomInfo['room_num']);
|
||||
}
|
||||
} elseif ($roomInfo['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
|
||||
$disableDates = json_decode($roomInfo['disable_dates_json'], true);
|
||||
if ($roomInfo['disable_dates_json'] !== 0) {
|
||||
$this->validateDisableDateRanges($disableDates, $roomIndex, $roomInfo['id']);
|
||||
$this->validateDisableDateRanges($disableDates, $roomInfo['room_num'], $roomInfo['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3257,14 +3562,28 @@ class AdminProductsControllerCore extends AdminController
|
||||
|
||||
public function ajaxProcessDeleteHotelRoom()
|
||||
{
|
||||
$response = array(
|
||||
'success' => false
|
||||
);
|
||||
if ($this->tabAccess['edit'] == 1) {
|
||||
$idRoom = Tools::getValue('id');
|
||||
$objRoomInfo = new HotelRoomInformation((int)$idRoom);
|
||||
if ($objRoomInfo->delete()) {
|
||||
die('1');
|
||||
$objHotelRoomInformation = new HotelRoomInformation();
|
||||
if ($objHotelRoomInformation->getFutureBookings($idRoom)) {
|
||||
$this->errors[] = $this->l('This room cannot be deleted as this room contains future booking.');
|
||||
}
|
||||
if (empty($this->errors)) {
|
||||
if ($objRoomInfo->delete()) {
|
||||
$response['success'] = true;
|
||||
} else {
|
||||
$this->errors[] = $this->l('Unable to delete room. Please try again!.');
|
||||
}
|
||||
}
|
||||
}
|
||||
die('0');
|
||||
if (!empty($this->errors)) {
|
||||
$response['errors'] = $this->errors;
|
||||
}
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
public function initFormAdditionalFacilities($obj)
|
||||
@@ -3410,7 +3729,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$product = $obj;
|
||||
// Prepare Categories tree for display in Associations tab
|
||||
$root = Category::getRootCategory();
|
||||
$default_category = $this->context->cookie->id_category_products_filter ? $this->context->cookie->id_category_products_filter : Context::getContext()->shop->id_category;
|
||||
$default_category = $this->context->cookie->id_category_room_types_filter ? $this->context->cookie->id_category_room_types_filter : Context::getContext()->shop->id_category;
|
||||
if (!$product->id || !$product->isAssociatedToShop()) {
|
||||
$selected_cat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->default_form_language);
|
||||
} else {
|
||||
@@ -4047,7 +4366,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
'token' => $this->token,
|
||||
'currency' => $currency,
|
||||
'link' => $this->context->link,
|
||||
'PS_PRODUCT_SHORT_DESC_LIMIT' => Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') ? Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') : 400
|
||||
'PS_PRODUCT_SHORT_DESC_LIMIT' => Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') ? Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') : 400,
|
||||
'category_position' => Tools::getValue('category_position', $product->getPositionInCategory()),
|
||||
));
|
||||
$data->assign($this->tpl_form_vars);
|
||||
|
||||
@@ -4573,7 +4893,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
if ($this->tabAccess['edit'] === '1') {
|
||||
$way = (int)(Tools::getValue('way'));
|
||||
$id_product = (int)Tools::getValue('id_product');
|
||||
$id_category = (int)Tools::getValue('id_category');
|
||||
$id_category = (int)Tools::getValue('id_category_hotel');
|
||||
$positions = Tools::getValue('product');
|
||||
$page = (int)Tools::getValue('page');
|
||||
$selected_pagination = (int)Tools::getValue('selected_pagination');
|
||||
@@ -4588,7 +4908,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
|
||||
if ($product = new Product((int)$pos[2])) {
|
||||
if (isset($position) && $product->updatePosition($way, $position)) {
|
||||
if (isset($position) && $product->updatePosition($way, $position, $id_category)) {
|
||||
$category = new Category((int)$id_category);
|
||||
if (Validate::isLoadedObject($category)) {
|
||||
hook::Exec('categoryUpdate', array('category' => $category));
|
||||
|
||||
@@ -76,7 +76,16 @@ class AdminProfilesControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$list_profile = array();
|
||||
|
||||
@@ -118,7 +118,16 @@ class AdminQuickAccessesControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
|
||||
@@ -60,6 +60,9 @@ class AdminReferrersControllerCore extends AdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// redirect to Dashboard for stats related to Referers
|
||||
Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminDashboard'));
|
||||
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'referrer';
|
||||
$this->className = 'Referrer';
|
||||
|
||||
@@ -30,6 +30,22 @@ class AdminSearchControllerCore extends AdminController
|
||||
{
|
||||
$this->bootstrap = true;
|
||||
parent::__construct();
|
||||
$this->controllerAccess = array(
|
||||
'AdminProducts' => 1,
|
||||
'AdminCategories' => 1,
|
||||
'AdminFeatures' => 1,
|
||||
'AdminOrders' => 1,
|
||||
'AdminOrderRefundRules' => 1,
|
||||
'AdminRoomTypeGlobalDemand' => 1,
|
||||
'AdminGroups' => 1,
|
||||
'AdminHotelFeatures' => 1,
|
||||
'AdminCustomers' => 1,
|
||||
'AdminAddHotel' => 1,
|
||||
'AdminNormalProducts' => 1,
|
||||
'AdminAddresses' => 1,
|
||||
'AdminCustomerThreads' => 1,
|
||||
'AdminModules' => 1
|
||||
);
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
@@ -39,16 +55,24 @@ class AdminSearchControllerCore extends AdminController
|
||||
$searchType = (int)Tools::getValue('bo_search_type');
|
||||
/* Handle empty search field */
|
||||
if (!empty($this->query)) {
|
||||
if ($this->context->employee->id_profile != _PS_ADMIN_PROFILE_) {
|
||||
$this->setControllerAccesses();
|
||||
}
|
||||
|
||||
if (!$searchType && strlen($this->query) > 1) {
|
||||
$this->searchFeatures();
|
||||
}
|
||||
|
||||
/* Product research */
|
||||
if (!$searchType || $searchType == 1) {
|
||||
if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_CATELOG) {
|
||||
/* Handle product ID */
|
||||
if ($searchType == 1 && (int)$this->query && Validate::isUnsignedInt((int)$this->query)) {
|
||||
if ($searchType == self::QLO_SEARCH_TYPE_CATELOG && (int)$this->query && Validate::isUnsignedInt((int)$this->query)) {
|
||||
if (($product = new Product($this->query)) && Validate::isLoadedObject($product)) {
|
||||
Tools::redirectAdmin('index.php?tab=AdminProducts&id_product='.(int)($product->id).'&token='.Tools::getAdminTokenLite('AdminProducts'));
|
||||
if ($product->booking_product) {
|
||||
Tools::redirectAdmin('index.php?tab=AdminProducts&id_product='.(int)($product->id).'&updateproduct&token='.Tools::getAdminTokenLite('AdminProducts'));
|
||||
} else {
|
||||
Tools::redirectAdmin('index.php?tab=AdminNormalProducts&id_product='.(int)($product->id).'&updateproduct&token='.Tools::getAdminTokenLite('AdminNormalProducts'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +81,8 @@ class AdminSearchControllerCore extends AdminController
|
||||
}
|
||||
|
||||
/* Customer */
|
||||
if (!$searchType || $searchType == 2 || $searchType == 6) {
|
||||
if (!$searchType || $searchType == 2) {
|
||||
if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_CUSTOMER_BY_NAME || $searchType == self::QLO_SEARCH_TYPE_CUSTOMER_BY_IP) {
|
||||
if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_CUSTOMER_BY_NAME) {
|
||||
/* Handle customer ID */
|
||||
if ($searchType && (int)$this->query && Validate::isUnsignedInt((int)$this->query)) {
|
||||
if (($customer = new Customer($this->query)) && Validate::isLoadedObject($customer)) {
|
||||
@@ -70,15 +94,19 @@ class AdminSearchControllerCore extends AdminController
|
||||
$this->searchCustomer();
|
||||
}
|
||||
|
||||
if ($searchType == 6) {
|
||||
if ($searchType == self::QLO_SEARCH_TYPE_CUSTOMER_BY_IP) {
|
||||
$this->searchIP();
|
||||
}
|
||||
|
||||
if (isset($this->_list['customers']) && is_array($this->_list['customers']) && count($this->_list['customers'])) {
|
||||
$this->addHotelRestrictionsToSearchedCustomers('customers');
|
||||
}
|
||||
}
|
||||
|
||||
/* Order */
|
||||
if (!$searchType || $searchType == 3) {
|
||||
if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_ORDER) {
|
||||
if (Validate::isUnsignedInt(trim($this->query)) && (int)$this->query && ($order = new Order((int)$this->query)) && Validate::isLoadedObject($order)) {
|
||||
if ($searchType == 3) {
|
||||
if ($searchType == self::QLO_SEARCH_TYPE_ORDER) {
|
||||
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)$order->id.'&vieworder'.'&token='.Tools::getAdminTokenLite('AdminOrders'));
|
||||
} else {
|
||||
$row = get_object_vars($order);
|
||||
@@ -96,7 +124,7 @@ class AdminSearchControllerCore extends AdminController
|
||||
} else {
|
||||
$orders = Order::getByReference($this->query);
|
||||
$nb_orders = count($orders);
|
||||
if ($nb_orders == 1 && $searchType == 3) {
|
||||
if ($nb_orders == 1 && $searchType == self::QLO_SEARCH_TYPE_ORDER) {
|
||||
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)$orders[0]->id.'&vieworder'.'&token='.Tools::getAdminTokenLite('AdminOrders'));
|
||||
} elseif ($nb_orders) {
|
||||
$this->_list['orders'] = array();
|
||||
@@ -113,14 +141,14 @@ class AdminSearchControllerCore extends AdminController
|
||||
$this->_list['orders'][] = $row;
|
||||
}
|
||||
}
|
||||
} elseif ($searchType == 3) {
|
||||
$this->errors[] = Tools::displayError('No order was found with this ID:').' '.Tools::htmlentitiesUTF8($this->query);
|
||||
}
|
||||
}
|
||||
|
||||
$this->searchOrderMessages();
|
||||
}
|
||||
|
||||
/* Invoices */
|
||||
if ($searchType == 4) {
|
||||
if ($searchType == self::QLO_SEARCH_TYPE_INVOICE) {
|
||||
if (Validate::isOrderInvoiceNumber($this->query) && ($invoice = OrderInvoice::getInvoiceByNumber($this->query))) {
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminPdf').'&submitAction=generateInvoicePDF&id_order='.(int)($invoice->id_order));
|
||||
}
|
||||
@@ -128,7 +156,7 @@ class AdminSearchControllerCore extends AdminController
|
||||
}
|
||||
|
||||
/* Cart */
|
||||
if ($searchType == 5) {
|
||||
if ($searchType == self::QLO_SEARCH_TYPE_CART) {
|
||||
if ((int)$this->query && Validate::isUnsignedInt((int)$this->query) && ($cart = new Cart($this->query)) && Validate::isLoadedObject($cart)) {
|
||||
Tools::redirectAdmin('index.php?tab=AdminCarts&id_cart='.(int)($cart->id).'&viewcart'.'&token='.Tools::getAdminToken('AdminCarts'.(int)(Tab::getIdFromClassName('AdminCarts')).(int)$this->context->employee->id));
|
||||
}
|
||||
@@ -138,19 +166,53 @@ class AdminSearchControllerCore extends AdminController
|
||||
// 6 - but it is included in the customer block
|
||||
|
||||
/* Module search */
|
||||
if (!$searchType || $searchType == 7) {
|
||||
if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_MODULE) {
|
||||
/* Handle module name */
|
||||
if ($searchType == 7 && Validate::isModuleName($this->query) and ($module = Module::getInstanceByName($this->query)) && Validate::isLoadedObject($module)) {
|
||||
if ($searchType == self::QLO_SEARCH_TYPE_MODULE && Validate::isModuleName($this->query) and ($module = Module::getInstanceByName($this->query)) && Validate::isLoadedObject($module)) {
|
||||
Tools::redirectAdmin('index.php?tab=AdminModules&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name).'&token='.Tools::getAdminTokenLite('AdminModules'));
|
||||
}
|
||||
|
||||
/* Normal catalog search */
|
||||
$this->searchModule();
|
||||
}
|
||||
|
||||
if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_HOTEL) {
|
||||
if ($searchType == self::QLO_SEARCH_TYPE_HOTEL && (int)$this->query && Validate::isUnsignedInt((int)$this->query)) {
|
||||
if (($objHotelBranchInfo = new HotelBranchInformation((int) $this->query))
|
||||
&& Validate::isLoadedObject($objHotelBranchInfo)
|
||||
) {
|
||||
Tools::redirectAdmin('index.php?tab=AdminAddHotel&id='.$objHotelBranchInfo->id.'&updatehtl_branch_info'.'&token='.Tools::getAdminTokenLite('AdminAddHotel'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->searchHotel();
|
||||
}
|
||||
|
||||
if (!$searchType) {
|
||||
$this->searchAddress();
|
||||
$this->searchHotelFeatures();
|
||||
$this->searchAdditionalFacilities();
|
||||
$this->searchRefundRules();
|
||||
}
|
||||
}
|
||||
|
||||
$this->display = 'view';
|
||||
}
|
||||
|
||||
public function setControllerAccesses()
|
||||
{
|
||||
$sql = 'SELECT a.`view`, t.`class_name` FROM `'._DB_PREFIX_.'access` a
|
||||
LEFT JOIN `'._DB_PREFIX_.'tab` t ON (t.`id_tab` = a.`id_tab`)
|
||||
WHERE t.`class_name` IN ("'.implode('", "', array_keys($this->controllerAccess)).'")
|
||||
AND a.`id_profile` = '.(int) $this->context->employee->id_profile.'
|
||||
';
|
||||
|
||||
if ($tabs = Db::getInstance()->executeS($sql)) {
|
||||
foreach ($tabs as $tab) {
|
||||
$this->controllerAccess[$tab['class_name']] = $tab['view'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function searchIP()
|
||||
{
|
||||
@@ -168,17 +230,57 @@ class AdminSearchControllerCore extends AdminController
|
||||
*/
|
||||
public function searchCatalog()
|
||||
{
|
||||
$this->context = Context::getContext();
|
||||
if ($this->_list['products'] = Product::searchByName($this->context->language->id, $this->query)) {
|
||||
if (((isset($this->controllerAccess['AdminProducts'])
|
||||
&& $this->controllerAccess['AdminProducts'])
|
||||
|| (isset($this->controllerAccess['AdminNormalProducts'])
|
||||
&& $this->controllerAccess['AdminNormalProducts']))
|
||||
&& ($this->_list['products'] = Product::searchByName($this->context->language->id, $this->query))
|
||||
) {
|
||||
$objRoomType = new HotelRoomType();
|
||||
$accessableHotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1);
|
||||
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
|
||||
foreach ($this->_list['products'] as $key => $product) {
|
||||
$roomInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product']);
|
||||
if (!in_array($roomInfo['id_hotel'], HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1))) {
|
||||
if ($roomInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product'])) {
|
||||
if (!in_array($roomInfo['id_hotel'], $accessableHotels)) {
|
||||
unset($this->_list['products'][$key]);
|
||||
}
|
||||
} else if ($associatedData = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($product['id_product'])) {
|
||||
$count = 0;
|
||||
foreach ($associatedData['room_types'] as $id_room_type) {
|
||||
$objRoomType = new HotelRoomType($id_room_type);
|
||||
if (in_array($objRoomType->id_hotel, $accessableHotels)) {
|
||||
$count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
$this->_list['service_products'][] = $this->_list['products'][$key];
|
||||
}
|
||||
|
||||
unset($this->_list['products'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->controllerAccess['AdminProducts'])
|
||||
&& $this->controllerAccess['AdminProducts']
|
||||
) {
|
||||
unset($this->_list['products']);
|
||||
}
|
||||
|
||||
if (isset($this->controllerAccess['AdminNormalProducts'])
|
||||
&& $this->controllerAccess['AdminNormalProducts']
|
||||
) {
|
||||
unset($this->_list['service_products']);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->controllerAccess['AdminCategories']) && $this->controllerAccess['AdminCategories']) {
|
||||
$this->_list['categories'] = Category::searchByName($this->context->language->id, $this->query);
|
||||
}
|
||||
|
||||
if (isset($this->controllerAccess['AdminFeatures']) && $this->controllerAccess['AdminFeatures']) {
|
||||
$this->_list['catalog_features'] = Feature::searchByName($this->query, $this->context->language->id);
|
||||
}
|
||||
$this->_list['categories'] = Category::searchByName($this->context->language->id, $this->query);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,29 +290,40 @@ class AdminSearchControllerCore extends AdminController
|
||||
*/
|
||||
public function searchCustomer()
|
||||
{
|
||||
$this->_list['customers'] = Customer::searchByName($this->query);
|
||||
if (isset($this->controllerAccess['AdminCustomers'])
|
||||
&& $this->controllerAccess['AdminCustomers']
|
||||
) {
|
||||
$this->_list['customers'] = Customer::searchByName($this->query);
|
||||
}
|
||||
|
||||
$objGroup = new Group();
|
||||
if (isset($this->controllerAccess['AdminGroups']) && $this->controllerAccess['AdminGroups']) {
|
||||
$this->_list['groups'] = $objGroup->searchGroupsByName($this->query);
|
||||
}
|
||||
}
|
||||
|
||||
public function searchModule()
|
||||
{
|
||||
$this->_list['modules'] = array();
|
||||
$all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id);
|
||||
foreach ($all_modules as $module) {
|
||||
if (stripos($module->name, $this->query) !== false || stripos($module->displayName, $this->query) !== false || stripos($module->description, $this->query) !== false) {
|
||||
$module->linkto = 'index.php?tab=AdminModules&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name).'&token='.Tools::getAdminTokenLite('AdminModules');
|
||||
$this->_list['modules'][] = $module;
|
||||
if (isset($this->controllerAccess['AdminModules']) && $this->controllerAccess['AdminModules']) {
|
||||
$this->_list['modules'] = array();
|
||||
$all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id);
|
||||
foreach ($all_modules as $module) {
|
||||
if (stripos($module->name, $this->query) !== false || stripos($module->displayName, $this->query) !== false || stripos($module->description, $this->query) !== false) {
|
||||
$module->linkto = 'index.php?tab=AdminModules&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name).'&token='.Tools::getAdminTokenLite('AdminModules');
|
||||
$this->_list['modules'][] = $module;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_numeric(trim($this->query)) && !Validate::isEmail($this->query)) {
|
||||
$iso_lang = Tools::strtolower(Context::getContext()->language->iso_code);
|
||||
$iso_country = Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
|
||||
if (($json_content = Tools::file_get_contents('https://api-addons.prestashop.com/'._PS_VERSION_.'/search/'.urlencode($this->query).'/'.$iso_country.'/'.$iso_lang.'/')) != false) {
|
||||
$results = json_decode($json_content, true);
|
||||
if (isset($results['id'])) {
|
||||
$this->_list['addons'] = array($results);
|
||||
} else {
|
||||
$this->_list['addons'] = $results;
|
||||
if (!is_numeric(trim($this->query)) && !Validate::isEmail($this->query)) {
|
||||
$iso_lang = Tools::strtolower(Context::getContext()->language->iso_code);
|
||||
$iso_country = Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
|
||||
if (($json_content = Tools::file_get_contents('https://api-addons.prestashop.com/'._PS_VERSION_.'/search/'.urlencode($this->query).'/'.$iso_country.'/'.$iso_lang.'/')) != false) {
|
||||
$results = json_decode($json_content, true);
|
||||
if (isset($results['id'])) {
|
||||
$this->_list['addons'] = array($results);
|
||||
} else {
|
||||
$this->_list['addons'] = $results;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -274,8 +387,175 @@ class AdminSearchControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function searchHotel()
|
||||
{
|
||||
if (class_exists('HotelBranchInformation')) {
|
||||
if (isset($this->controllerAccess['AdminAddHotel']) && $this->controllerAccess['AdminAddHotel']) {
|
||||
$objHotelBranchInformation = new HotelBranchInformation();
|
||||
$this->_list['hotels'] = $objHotelBranchInformation->searchByName(
|
||||
$this->query,
|
||||
$this->context->employee->id_profile,
|
||||
$this->context->language->id
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function searchOrderMessages()
|
||||
{
|
||||
if (class_exists('CustomerMessage')) {
|
||||
if (isset($this->controllerAccess['AdminCustomerThreads']) && $this->controllerAccess['AdminCustomerThreads']) {
|
||||
$objCustomerMessage = new CustomerMessage();
|
||||
if ($this->_list['order_messages'] = $objCustomerMessage->searchByName($this->query)) {
|
||||
$accesibleHotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1);
|
||||
foreach ($this->_list['order_messages'] as $key => $msg) {
|
||||
if (isset($msg['id_order'])
|
||||
&& $msg['id_order']
|
||||
) {
|
||||
// To set set restriction on the messages belonging to an order. While the other messages will be show to all
|
||||
$idHotel = HotelBookingDetail::getIdHotelByIdOrder($msg['id_order']);
|
||||
if (!in_array($idHotel, $accesibleHotels)) {
|
||||
unset($this->_list['order_messages'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function searchAddress()
|
||||
{
|
||||
if (isset($this->controllerAccess['AdminAddresses'])
|
||||
&& $this->controllerAccess['AdminAddresses']
|
||||
) {
|
||||
$objAddress = new Address();
|
||||
if ($this->_list['customer_address'] = $objAddress->searchByName($this->query)) {
|
||||
$this->addHotelRestrictionsToSearchedCustomers('customer_address');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function searchHotelFeatures()
|
||||
{
|
||||
if (class_exists('HotelFeatures')) {
|
||||
if (isset($this->controllerAccess['AdminHotelFeatures']) && $this->controllerAccess['AdminHotelFeatures']) {
|
||||
$objHotelFeatures = new HotelFeatures();
|
||||
if ($hotelFeatures = $objHotelFeatures->searchByName($this->query, $this->context->language->id)) {
|
||||
$features = array();
|
||||
foreach ($hotelFeatures as $key => $hotelFeature) {
|
||||
$features[$hotelFeature['id']]['name'] = $hotelFeature['name'];
|
||||
if ($hotelFeature['parent_feature_id']) {
|
||||
$features[$hotelFeature['id']]['id'] = $hotelFeature['parent_feature_id'];
|
||||
} else {
|
||||
$features[$hotelFeature['id']]['id'] = $hotelFeature['id'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->_list['hotel_features'] = $features;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function searchAdditionalFacilities()
|
||||
{
|
||||
if (class_exists('HotelRoomTypeGlobalDemand')) {
|
||||
if (isset($this->controllerAccess['AdminRoomTypeGlobalDemand']) && $this->controllerAccess['AdminRoomTypeGlobalDemand']) {
|
||||
$objHotelRoomTypeGlobalDemands = new HotelRoomTypeGlobalDemand();
|
||||
if ($globalDemads = $objHotelRoomTypeGlobalDemands->searchByName($this->query, $this->context->language->id)) {
|
||||
foreach ($globalDemads as $key => $demand) {
|
||||
if (!(int) $globalDemads[$key]['price']) {
|
||||
$globalDemads[$key]['price'] = $globalDemads[$key]['option_price'];
|
||||
}
|
||||
|
||||
$globalDemads[$key]['per_day_price_calc'] = $this->l('No');
|
||||
if ($globalDemads[$key]['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY) {
|
||||
$globalDemads[$key]['per_day_price_calc'] = $this->l('Yes');
|
||||
}
|
||||
}
|
||||
|
||||
$this->_list['global_demands'] = $globalDemads;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function searchRefundRules()
|
||||
{
|
||||
if (class_exists('HotelOrderRefundRules')) {
|
||||
if (isset($this->controllerAccess['AdminOrderRefundRulesController']) && $this->controllerAccess['AdminOrderRefundRulesController']) {
|
||||
$objRefundRule = new HotelOrderRefundRules();
|
||||
if ($refundRules = $objRefundRule->searchByName($this->query, $this->context->language->id)) {
|
||||
foreach ($refundRules as $key => $rule) {
|
||||
$refundRules[$key]['deduction_type'] = $this->l('Percentage');
|
||||
if ($rule['payment_type'] == HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_FIXED) {
|
||||
$refundRules[$key]['deduction_type'] = $this->l('Fixed Amount');
|
||||
$refundRules[$key]['deduction_value_full_pay'] = Tools::displayPrice($rule['deduction_value_full_pay']);
|
||||
$refundRules[$key]['deduction_value_adv_pay'] = Tools::displayPrice($rule['deduction_value_adv_pay']);
|
||||
} else if ($rule['payment_type'] == HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_PERCENTAGE) {
|
||||
$refundRules[$key]['deduction_value_full_pay'] = $rule['deduction_value_full_pay'].' %';
|
||||
$refundRules[$key]['deduction_value_adv_pay'] = $rule['deduction_value_adv_pay'].' %';
|
||||
}
|
||||
}
|
||||
|
||||
$this->_list['refund_rules'] = $refundRules;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function addHotelRestrictionsToSearchedCustomers($index)
|
||||
{
|
||||
$accessibleHotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1);
|
||||
foreach ($this->_list[$index] as $key => $item) {
|
||||
if ($this->context->employee->id_profile != _PS_ADMIN_PROFILE_) {
|
||||
$customerBelongsToHotel = 0;
|
||||
if(isset($item['id_customer'])) {
|
||||
$customerOrders = Order::getCustomerOrders($item['id_customer']);
|
||||
if (count($customerOrders)) {
|
||||
foreach($customerOrders as $order) {
|
||||
$idHotel = HotelBookingDetail::getIdHotelByIdOrder($order['id_order']);
|
||||
if (!in_array($idHotel, $accessibleHotels)) {
|
||||
$customerBelongsToHotel += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$customerBelongsToHotel) {
|
||||
unset($this->_list[$index][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function initGroupList()
|
||||
{
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['groups'] = array(
|
||||
'id_group' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'align' => 'center', 'width' => 65),
|
||||
'reduction' => array('title' => $this->l('Discount')),
|
||||
'show_prices' => array('title' => $this->l('Show prices'), 'callback' => 'printShowPricesIcon'),
|
||||
'date_add' => array('title' => $this->l('Creation date'), 'width' => 130, 'align' => 'right', 'type' => 'datetime'),
|
||||
);
|
||||
}
|
||||
|
||||
public function printShowPricesIcon($id_group, $tr)
|
||||
{
|
||||
$group = new Group($tr['id_group']);
|
||||
if (!Validate::isLoadedObject($group)) {
|
||||
return;
|
||||
}
|
||||
return '<a class="list-action-enable'.($group->show_prices ? ' action-enabled' : ' action-disabled').'" href="index.php?tab=AdminGroups&id_group='.(int)$group->id.'&changeShowPricesVal&token='.Tools::getAdminTokenLite('AdminGroups').'">
|
||||
'.($group->show_prices ? '<i class="icon-check"></i>' : '<i class="icon-remove"></i>').
|
||||
'</a>';
|
||||
}
|
||||
|
||||
protected function initOrderList()
|
||||
{
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['orders'] = array(
|
||||
'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 65),
|
||||
'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
@@ -287,6 +567,43 @@ class AdminSearchControllerCore extends AdminController
|
||||
);
|
||||
}
|
||||
|
||||
protected function initGlobalDemandList()
|
||||
{
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['global_demands'] = array(
|
||||
'id_global_demand' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name')),
|
||||
'option_name' => array('title' => $this->l('Advance Option Name')),
|
||||
'price' => array('title' => $this->l('Price'), 'type' => 'price', 'currency' => true),
|
||||
'per_day_price_calc' => array('title' => $this->l('Per day price calculation'))
|
||||
);
|
||||
}
|
||||
|
||||
protected function initRefundRuleList()
|
||||
{
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['refund_rules'] = array(
|
||||
'id_refund_rule' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name')),
|
||||
'payment_type' => array('title' => $this->l('Payment Type')),
|
||||
'deduction_value_full_pay' => array('title' => $this->l('Full Payment Deduction Percentage/Amount')),
|
||||
'deduction_value_adv_pay' => array('title' => $this->l('Full Payment Deduction Percentage/Amount')),
|
||||
'days' => array('title' => $this->l('Days Before Check-in')),
|
||||
);
|
||||
}
|
||||
|
||||
protected function initOrderMessagesList()
|
||||
{
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['order_messages'] = array(
|
||||
'id_customer_thread' => array('title' => $this->l('ID '), 'align' => 'center', 'width' => 65),
|
||||
'customer_name' => array('title' => $this->l('Customer Name'), 'align' => 'center'),
|
||||
'email' => array('title' => $this->l('Customer email')),
|
||||
'message' => array('title' => $this->l('Message'), 'width' => 70),
|
||||
'status' => array('title' => $this->l('Status'), 'width' => 280),
|
||||
);
|
||||
}
|
||||
|
||||
protected function initCustomerList()
|
||||
{
|
||||
$genders_icon = array('default' => 'unknown.gif');
|
||||
@@ -315,13 +632,71 @@ class AdminSearchControllerCore extends AdminController
|
||||
$this->fields_list['products'] = array(
|
||||
'id_product' => array('title' => $this->l('ID'), 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 'auto'),
|
||||
'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 150),
|
||||
// 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 150),
|
||||
'price_tax_excl' => array('title' => $this->l('Price (tax excl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60),
|
||||
'price_tax_incl' => array('title' => $this->l('Price (tax incl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60),
|
||||
'active' => array('title' => $this->l('Active'), 'width' => 70, 'active' => 'status', 'align' => 'center', 'type' => 'bool')
|
||||
);
|
||||
}
|
||||
|
||||
protected function initServiceProdList()
|
||||
{
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['service_products'] = array(
|
||||
'id_product' => array('title' => $this->l('ID'), 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 'auto'),
|
||||
'price_tax_excl' => array('title' => $this->l('Price (tax excl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60),
|
||||
'price_tax_incl' => array('title' => $this->l('Price (tax incl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60),
|
||||
'active' => array('title' => $this->l('Active'), 'width' => 70, 'active' => 'status', 'align' => 'center', 'type' => 'bool')
|
||||
);
|
||||
}
|
||||
|
||||
protected function initFeatureList()
|
||||
{
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['catalog_features'] = array(
|
||||
'id_feature' => array('title' => $this->l('ID'), 'width' => 25),
|
||||
'name' => array('title' => $this->l('Name'), 'width' => 'auto'),
|
||||
'logo' => array('title' => $this->l('Logo'),'image' => 'rf', 'align' => 'right', 'type' => 'price', 'width' => 60),
|
||||
);
|
||||
}
|
||||
|
||||
protected function initHotelList()
|
||||
{
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['hotels'] = array(
|
||||
'id' => array('title' => $this->l('ID'), 'width' => 25),
|
||||
'hotel_name' => array('title' => $this->l('Name'), 'width' => 'auto'),
|
||||
'city' => array('title' => $this->l('City'), 'align' => 'right'),
|
||||
'state_name' => array('title' => $this->l('State'), 'align' => 'right'),
|
||||
'country_name' => array('title' => $this->l('Country'), 'align' => 'right'),
|
||||
'active' => array('title' => $this->l('Active'), 'width' => 70, 'active' => 'status', 'align' => 'center', 'type' => 'bool')
|
||||
);
|
||||
}
|
||||
|
||||
protected function initAddressList()
|
||||
{
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['customer_address'] = array(
|
||||
'id_address' => array('title' => $this->l('ID'), 'width' => 25),
|
||||
'firstname' => array('title' => $this->l('First Name'), 'width' => 'auto'),
|
||||
'lastname' => array('title' => $this->l('Last Name'), 'align' => 'right'),
|
||||
'address1' => array('title' => $this->l('Address'), 'align' => 'right'),
|
||||
'postcode' => array('title' => $this->l('Zip/Postal Code'), 'align' => 'right'),
|
||||
'country_name' => array('title' => $this->l('Country'), 'align' => 'right'),
|
||||
'state_name' => array('title' => $this->l('State'), 'align' => 'right'),
|
||||
'city' => array('title' => $this->l('City'), 'width' => 70)
|
||||
);
|
||||
}
|
||||
|
||||
protected function initHotelFeatureList()
|
||||
{
|
||||
$this->show_toolbar = false;
|
||||
$this->fields_list['hotel_features'] = array(
|
||||
'name' => array('title' => $this->l('name'), 'width' => 'auto'),
|
||||
);
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
@@ -376,7 +751,6 @@ class AdminSearchControllerCore extends AdminController
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'product';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminProducts', false);
|
||||
|
||||
$query = trim(Tools::getValue('bo_query'));
|
||||
$searchType = (int)Tools::getValue('bo_search_type');
|
||||
|
||||
@@ -393,6 +767,152 @@ class AdminSearchControllerCore extends AdminController
|
||||
$this->tpl_view_vars['num_products'] = count($this->_list['products']);
|
||||
$this->tpl_view_vars['products'] = $view;
|
||||
}
|
||||
if (isset($this->_list['service_products']) && $this->_list['service_products']&& count($this->_list['service_products'])) {
|
||||
$view = '';
|
||||
$this->initServiceProdList();
|
||||
|
||||
$helper = new HelperList();
|
||||
$helper->shopLinkType = '';
|
||||
$helper->simple_header = true;
|
||||
$helper->identifier = 'id_product';
|
||||
$helper->actions = array('edit');
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'product';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminNormalProducts', false);
|
||||
|
||||
$query = trim(Tools::getValue('bo_query'));
|
||||
$searchType = (int)Tools::getValue('bo_search_type');
|
||||
|
||||
if ($query) {
|
||||
$helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
|
||||
}
|
||||
|
||||
$helper->token = Tools::getAdminTokenLite('AdminNormalProducts');
|
||||
|
||||
if ($this->_list['service_products']) {
|
||||
$view = $helper->generateList($this->_list['service_products'], $this->fields_list['service_products']);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars['num_service_products'] = count($this->_list['service_products']);
|
||||
$this->tpl_view_vars['service_products'] = $view;
|
||||
}
|
||||
if (isset($this->_list['catalog_features']) && $this->_list['catalog_features']&& count($this->_list['catalog_features'])) {
|
||||
$view = '';
|
||||
$this->initFeatureList();
|
||||
|
||||
$helper = new HelperList();
|
||||
$helper->shopLinkType = '';
|
||||
$helper->simple_header = true;
|
||||
$helper->identifier = 'id_feature';
|
||||
$helper->imageType = 'jpg';
|
||||
$helper->actions = array('edit');
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'feature';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminFeatures', false);
|
||||
|
||||
$query = trim(Tools::getValue('bo_query'));
|
||||
$searchType = (int)Tools::getValue('bo_search_type');
|
||||
|
||||
if ($query) {
|
||||
$helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
|
||||
}
|
||||
|
||||
$helper->token = Tools::getAdminTokenLite('AdminFeatures');
|
||||
|
||||
if ($this->_list['catalog_features']) {
|
||||
$view = $helper->generateList($this->_list['catalog_features'], $this->fields_list['catalog_features']);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars['num_catalog_features'] = count($this->_list['catalog_features']);
|
||||
$this->tpl_view_vars['catalog_features'] = $view;
|
||||
}
|
||||
if (isset($this->_list['customer_address']) && $this->_list['customer_address']&& count($this->_list['customer_address'])) {
|
||||
$view = '';
|
||||
$this->initAddressList();
|
||||
|
||||
$helper = new HelperList();
|
||||
$helper->shopLinkType = '';
|
||||
$helper->simple_header = true;
|
||||
$helper->identifier = 'id_address';
|
||||
$helper->actions = array('edit');
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'address';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminAddresses', false);
|
||||
|
||||
$query = trim(Tools::getValue('bo_query'));
|
||||
$searchType = (int)Tools::getValue('bo_search_type');
|
||||
|
||||
if ($query) {
|
||||
$helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
|
||||
}
|
||||
|
||||
$helper->token = Tools::getAdminTokenLite('AdminAddresses');
|
||||
|
||||
if ($this->_list['customer_address']) {
|
||||
$view = $helper->generateList($this->_list['customer_address'], $this->fields_list['customer_address']);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars['num_customer_address'] = count($this->_list['customer_address']);
|
||||
$this->tpl_view_vars['customer_address'] = $view;
|
||||
}
|
||||
if (isset($this->_list['order_messages']) && $this->_list['order_messages']&& count($this->_list['order_messages'])) {
|
||||
$view = '';
|
||||
$this->initOrderMessagesList();
|
||||
|
||||
$helper = new HelperList();
|
||||
$helper->shopLinkType = '';
|
||||
$helper->simple_header = true;
|
||||
$helper->identifier = 'id_customer_message';
|
||||
$helper->actions = array('edit');
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'feature';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminCustomerThreads', false);
|
||||
|
||||
$query = trim(Tools::getValue('bo_query'));
|
||||
$searchType = (int)Tools::getValue('bo_search_type');
|
||||
|
||||
if ($query) {
|
||||
$helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
|
||||
}
|
||||
|
||||
$helper->token = Tools::getAdminTokenLite('AdminCustomerThreads');
|
||||
|
||||
if ($this->_list['order_messages']) {
|
||||
$view = $helper->generateList($this->_list['order_messages'], $this->fields_list['order_messages']);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars['num_order_messages'] = count($this->_list['order_messages']);
|
||||
$this->tpl_view_vars['order_messages'] = $view;
|
||||
}
|
||||
if (isset($this->_list['hotels']) && $this->_list['hotels']&& count($this->_list['hotels'])) {
|
||||
$view = '';
|
||||
$this->initHotelList();
|
||||
|
||||
$helper = new HelperList();
|
||||
$helper->shopLinkType = '';
|
||||
$helper->simple_header = true;
|
||||
$helper->identifier = 'id';
|
||||
$helper->actions = array('edit');
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'htl_branch_info';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminAddHotel', false);
|
||||
|
||||
$query = trim(Tools::getValue('bo_query'));
|
||||
$searchType = (int)Tools::getValue('bo_search_type');
|
||||
|
||||
if ($query) {
|
||||
$helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
|
||||
}
|
||||
|
||||
$helper->token = Tools::getAdminTokenLite('AdminAddHotel');
|
||||
|
||||
if ($this->_list['hotels']) {
|
||||
$view = $helper->generateList($this->_list['hotels'], $this->fields_list['hotels']);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars['num_hotels'] = count($this->_list['hotels']);
|
||||
$this->tpl_view_vars['hotels'] = $view;
|
||||
}
|
||||
if (isset($this->_list['customers']) && count($this->_list['customers'])) {
|
||||
$view = '';
|
||||
$this->initCustomerList();
|
||||
@@ -416,6 +936,101 @@ class AdminSearchControllerCore extends AdminController
|
||||
$this->tpl_view_vars['num_customers'] = count($this->_list['customers']);
|
||||
$this->tpl_view_vars['customers'] = $view;
|
||||
}
|
||||
|
||||
if (isset($this->_list['hotel_features']) && count($this->_list['hotel_features'])) {
|
||||
$view = '';
|
||||
$this->initHotelFeatureList();
|
||||
|
||||
$helper = new HelperList();
|
||||
$helper->shopLinkType = '';
|
||||
$helper->simple_header = true;
|
||||
$helper->identifier = 'id';
|
||||
$helper->actions = array('edit', 'view');
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'htl_features';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminHotelFeatures', false);
|
||||
$helper->token = Tools::getAdminTokenLite('AdminHotelFeatures');
|
||||
|
||||
if ($this->_list['hotel_features']) {
|
||||
$view = $helper->generateList($this->_list['hotel_features'], $this->fields_list['hotel_features']);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars['num_hotel_features'] = count($this->_list['hotel_features']);
|
||||
$this->tpl_view_vars['hotel_features'] = $view;
|
||||
}
|
||||
if (isset($this->_list['groups']) && count($this->_list['groups'])) {
|
||||
$view = '';
|
||||
$this->initGroupList();
|
||||
|
||||
$helper = new HelperList();
|
||||
$helper->shopLinkType = '';
|
||||
$helper->simple_header = true;
|
||||
$helper->identifier = 'id_group';
|
||||
$helper->actions = array('edit');
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'group';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminGroups', false);
|
||||
|
||||
$query = trim(Tools::getValue('bo_query'));
|
||||
$searchType = (int)Tools::getValue('bo_search_type');
|
||||
|
||||
if ($query) {
|
||||
$helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
|
||||
}
|
||||
|
||||
$helper->token = Tools::getAdminTokenLite('AdminGroups');
|
||||
|
||||
if ($this->_list['groups']) {
|
||||
$view = $helper->generateList($this->_list['groups'], $this->fields_list['groups']);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars['num_groups'] = count($this->_list['groups']);
|
||||
$this->tpl_view_vars['groups'] = $view;
|
||||
}
|
||||
|
||||
if (isset($this->_list['global_demands']) && count($this->_list['global_demands'])) {
|
||||
$view = '';
|
||||
$this->initGlobalDemandList();
|
||||
$helper = new HelperList();
|
||||
$helper->shopLinkType = '';
|
||||
$helper->simple_header = true;
|
||||
$helper->identifier = 'id_global_demand';
|
||||
$helper->actions = array('edit');
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'htl_room_type_global_demand';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminRoomTypeGlobalDemand', false);
|
||||
$helper->token = Tools::getAdminTokenLite('AdminRoomTypeGlobalDemand');
|
||||
|
||||
if ($this->_list['global_demands']) {
|
||||
$view = $helper->generateList($this->_list['global_demands'], $this->fields_list['global_demands']);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars['num_global_demands'] = count($this->_list['global_demands']);
|
||||
$this->tpl_view_vars['global_demands'] = $view;
|
||||
}
|
||||
|
||||
if (isset($this->_list['refund_rules']) && count($this->_list['refund_rules'])) {
|
||||
$view = '';
|
||||
$this->initRefundRuleList();
|
||||
|
||||
$helper = new HelperList();
|
||||
$helper->shopLinkType = '';
|
||||
$helper->simple_header = true;
|
||||
$helper->identifier = 'id_refund_rule';
|
||||
$helper->actions = array('edit');
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = 'htl_order_refund_rules';
|
||||
$helper->currentIndex = $this->context->link->getAdminLink('AdminOrderRefundRules', false);
|
||||
$helper->token = Tools::getAdminTokenLite('AdminOrderRefundRules');
|
||||
|
||||
if ($this->_list['refund_rules']) {
|
||||
$view = $helper->generateList($this->_list['refund_rules'], $this->fields_list['refund_rules']);
|
||||
}
|
||||
|
||||
$this->tpl_view_vars['num_refund_rules'] = count($this->_list['refund_rules']);
|
||||
$this->tpl_view_vars['refund_rules'] = $view;
|
||||
}
|
||||
|
||||
if (isset($this->_list['orders']) && count($this->_list['orders'])) {
|
||||
$view = '';
|
||||
$this->initOrderList();
|
||||
|
||||
@@ -31,6 +31,9 @@ class AdminSearchEnginesControllerCore extends AdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// redirect to Dashboard for stats related to Search Engines
|
||||
Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminDashboard'));
|
||||
|
||||
$this->bootstrap = true;
|
||||
$this->table = 'search_engine';
|
||||
$this->className = 'SearchEngine';
|
||||
|
||||
@@ -295,4 +295,11 @@ class AdminSlipControllerCore extends AdminController
|
||||
|
||||
return '--';
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addJS(_PS_JS_DIR_.'admin/slips.js');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -285,17 +285,35 @@ class AdminSpecificPriceRuleControllerCore extends AdminController
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save')
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
|
||||
$price = number_format($value, 6);
|
||||
|
||||
$price = $this->getFieldValue($this->object, 'price');
|
||||
if ($price != -1 && Validate::isPrice($price)) {
|
||||
$price = number_format($price, 6);
|
||||
} else {
|
||||
$price = '';
|
||||
}
|
||||
|
||||
$reduction = $this->getFieldValue($this->object, 'reduction');
|
||||
if (Validate::isPrice($reduction)) {
|
||||
$reduction = number_format($reduction, 6);
|
||||
} else {
|
||||
$reduction = 0;
|
||||
}
|
||||
|
||||
$this->fields_value = array(
|
||||
'price' => $price,
|
||||
'from_quantity' => (($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1),
|
||||
'reduction' => number_format((($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0), 6),
|
||||
'reduction' => $reduction,
|
||||
'leave_bprice_on' => $price ? 0 : 1,
|
||||
'shop_id' => (($value = $this->getFieldValue($this->object, 'id_shop')) ? $value : 1)
|
||||
);
|
||||
@@ -356,6 +374,12 @@ class AdminSpecificPriceRuleControllerCore extends AdminController
|
||||
public function postProcess()
|
||||
{
|
||||
Tools::clearSmartyCache();
|
||||
if (Tools::isSubmit('submitAdd'.$this->table)) {
|
||||
if (strtotime(Tools::getValue('from')) > strtotime(Tools::getValue('to'))) {
|
||||
$this->errors[] = Tools::displayError('The price rule cannot end before it begins.');
|
||||
}
|
||||
}
|
||||
|
||||
return parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,16 @@ class AdminStatesControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
|
||||
@@ -217,17 +217,12 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
if ($granularity == 'day') {
|
||||
$sales = array();
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(
|
||||
'SELECT LEFT(`invoice_date`, 10) AS date, SUM(total_paid_tax_excl / o.conversion_rate) AS sales,
|
||||
(
|
||||
SELECT hbd.`id_hotel`
|
||||
FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`id_order` = o.`id_order` LIMIT 1
|
||||
) AS id_hotel
|
||||
'SELECT LEFT(`invoice_date`, 10) AS date, SUM(total_paid_tax_excl / o.`conversion_rate`) AS sales
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1
|
||||
GROUP BY LEFT(`invoice_date`, 10)
|
||||
HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.
|
||||
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '').'
|
||||
GROUP BY LEFT(`invoice_date`, 10)'
|
||||
);
|
||||
|
||||
foreach ($result as $row) {
|
||||
@@ -238,17 +233,11 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
} elseif ($granularity == 'month') {
|
||||
$sales = array();
|
||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(
|
||||
'SELECT LEFT(`invoice_date`, 7) AS date, SUM(total_paid_tax_excl / o.conversion_rate) AS sales,
|
||||
(
|
||||
SELECT hbd.`id_hotel`
|
||||
FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`id_order` = o.`id_order` LIMIT 1
|
||||
) AS id_hotel
|
||||
'SELECT LEFT(`invoice_date`, 7) AS date, SUM(total_paid_tax_excl / o.`conversion_rate`) AS sales
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1
|
||||
GROUP BY LEFT(`invoice_date`, 7)
|
||||
HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.
|
||||
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '').' GROUP BY LEFT(`invoice_date`, 7)'
|
||||
);
|
||||
|
||||
foreach ($result as $row) {
|
||||
@@ -258,16 +247,11 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
return $sales;
|
||||
} else {
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(
|
||||
'SELECT SUM(total_paid_tax_excl / o.conversion_rate),
|
||||
(
|
||||
SELECT hbd.`id_hotel`
|
||||
FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`id_order` = o.`id_order` LIMIT 1
|
||||
) AS id_hotel
|
||||
'SELECT SUM(total_paid_tax_excl / o.`conversion_rate`)
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1
|
||||
HAVING 1 '.HotelBranchInformation::addHotelRestriction($id_hotel)
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.
|
||||
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -369,6 +353,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
return array('type' => 'neutral', 'value' => round(100 * $row['neutral'] / $row['total']));
|
||||
}
|
||||
|
||||
// @todo price conversion for admin selected currency is to be corrected
|
||||
public static function getBestCategory($date_from, $date_to)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
@@ -391,7 +376,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
) t ON t.`id_product` = capr.`id_product`
|
||||
RIGHT JOIN `'._DB_PREFIX_.'category` c2
|
||||
ON c2.`id_category` = '.(int)Configuration::get('PS_SERVICE_CATEGORY').' AND ca.`nleft` >= c2.`nleft` AND ca.`nright` <= c2.`nright`
|
||||
WHERE ca.`level_depth` > 1
|
||||
WHERE ca.`level_depth` > 2
|
||||
GROUP BY ca.`id_category`
|
||||
ORDER BY SUM(t.`totalPriceSold`) DESC');
|
||||
}
|
||||
@@ -474,7 +459,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
return round($messages / $threads, 1);
|
||||
}
|
||||
|
||||
public static function getPurchases($date_from, $date_to, $granularity = false)
|
||||
public static function getPurchases($date_from, $date_to, $granularity = false, $id_hotel = 0)
|
||||
{
|
||||
if ($granularity == 'day') {
|
||||
$purchases = array();
|
||||
@@ -483,42 +468,44 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
LEFT(`invoice_date`, 10) as date,
|
||||
SUM(od.`product_quantity` * IF(
|
||||
od.`purchase_supplier_price` > 0,
|
||||
od.`purchase_supplier_price` / `conversion_rate`,
|
||||
od.`original_product_price` * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100
|
||||
od.`purchase_supplier_price`,
|
||||
(od.`original_product_price` / `conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100
|
||||
)) as total_purchase_price
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1
|
||||
'.Shop::addSqlRestriction(false, 'o').'
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.
|
||||
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '').Shop::addSqlRestriction(false, 'o').'
|
||||
GROUP BY LEFT(`invoice_date`, 10)');
|
||||
|
||||
foreach ($result as $row) {
|
||||
$purchases[strtotime($row['date'])] = $row['total_purchase_price'];
|
||||
}
|
||||
|
||||
return $purchases;
|
||||
} else {
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT SUM(od.`product_quantity` * IF(
|
||||
od.`purchase_supplier_price` > 0,
|
||||
od.`purchase_supplier_price` / `conversion_rate`,
|
||||
od.`original_product_price` * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100
|
||||
od.`purchase_supplier_price`,
|
||||
(od.`original_product_price` / `conversion_rate`) * '.(int)Configuration::get('CONF_AVERAGE_PRODUCT_MARGIN').' / 100
|
||||
)) as total_purchase_price
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od ON o.id_order = od.id_order
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1
|
||||
'.Shop::addSqlRestriction(false, 'o'));
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.
|
||||
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '').Shop::addSqlRestriction(false, 'o'));
|
||||
}
|
||||
}
|
||||
|
||||
public static function getExpenses($date_from, $date_to, $granularity = false)
|
||||
public static function getExpenses($date_from, $date_to, $granularity = false, $id_hotel = 0)
|
||||
{
|
||||
$expenses = ($granularity == 'day' ? array() : 0);
|
||||
|
||||
$orders = Db::getInstance()->ExecuteS('
|
||||
SELECT
|
||||
LEFT(`invoice_date`, 10) as date,
|
||||
total_paid_tax_incl / o.conversion_rate as total_paid_tax_incl,
|
||||
total_paid_tax_incl / o.conversion_rate as total_paid_tax_incl,
|
||||
total_shipping_tax_excl / o.conversion_rate as total_shipping_tax_excl,
|
||||
o.module,
|
||||
hbd.id_country,
|
||||
@@ -528,8 +515,9 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
LEFT JOIN `'._DB_PREFIX_.'address` hbd ON o.id_address_delivery = hbd.id_address
|
||||
LEFT JOIN `'._DB_PREFIX_.'carrier` c ON o.id_carrier = c.id_carrier
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON o.current_state = os.id_order_state
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1
|
||||
'.Shop::addSqlRestriction(false, 'o'));
|
||||
WHERE `invoice_date` BETWEEN "'.pSQL($date_from).' 00:00:00" AND "'.pSQL($date_to).' 23:59:59" AND os.logable = 1'.
|
||||
((int) $id_hotel ? ' AND o.`id_order` IN (SELECT id_order FROM `'._DB_PREFIX_.'htl_booking_detail` WHERE id_hotel = '.(int)$id_hotel.')' : '').Shop::addSqlRestriction(false, 'o'));
|
||||
|
||||
foreach ($orders as $order) {
|
||||
// Add flat fees for this order
|
||||
$flat_fees = Configuration::get('CONF_ORDER_FIXED') + (
|
||||
@@ -555,6 +543,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
$expenses += $flat_fees + $var_fees;
|
||||
}
|
||||
}
|
||||
|
||||
return $expenses;
|
||||
}
|
||||
|
||||
@@ -771,6 +760,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON os.`id_order_state` = o.`current_state`
|
||||
WHERE o.`invoice_date` BETWEEN "'.pSQL(date('Y-m-d', strtotime('-31 day'))).' 00:00:00" AND "'.pSQL(date('Y-m-d', strtotime('-1 day'))).' 23:59:59" AND os.`logable` = 1
|
||||
'.Shop::addSqlRestriction());
|
||||
|
||||
$value = Tools::displayPrice($row['orders'] ? $row['total_paid_tax_excl'] / $row['orders'] : 0, $currency);
|
||||
break;
|
||||
|
||||
@@ -800,7 +790,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
break;
|
||||
|
||||
case 'top_category':
|
||||
if (!($id_category = AdminStatsController::getBestCategory(date('Y-m-d', strtotime('-1 month')), date('Y-m-d')))) {
|
||||
if (!($id_category = AdminStatsController::getBestCategory(date('Y-m-d', strtotime('-1 month')), date('Y-m-d', strtotime('+1 month'))))) {
|
||||
$value = $this->l('No category', null, null, false);
|
||||
} else {
|
||||
$category = new Category($id_category, $this->context->language->id);
|
||||
@@ -956,6 +946,10 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
|
||||
public static function getOccupancyData($dateFrom, $dateTo, $idsHotel = false)
|
||||
{
|
||||
if ($dateFrom == $dateTo) {
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
|
||||
$occupancyData = array('count_total' => 0, 'count_occupied' => 0, 'count_available' => 0, 'count_unavailable' => 0);
|
||||
|
||||
$countTotal = Db::getInstance()->getValue(
|
||||
@@ -970,48 +964,60 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
);
|
||||
$occupancyData['count_total'] = $countTotal;
|
||||
|
||||
// Occupied rooms are booked rooms that are not refunded in the date range
|
||||
$countOccupied = 0;
|
||||
if ($dateFrom != $dateTo) {
|
||||
$countOccupied = Db::getInstance()->getValue(
|
||||
'SELECT COUNT(DISTINCT hbd.`id_room`)
|
||||
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 p.`active` = 1
|
||||
AND hbd.`date_from` < "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'.
|
||||
HotelBranchInformation::addHotelRestriction($idsHotel, 'hbd')
|
||||
);
|
||||
} else {
|
||||
$countOccupied = Db::getInstance()->getValue(
|
||||
'SELECT COUNT(DISTINCT hbd.`id_room`)
|
||||
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 p.`active` = 1
|
||||
AND hbd.`date_from` <= "'.pSQL($dateFrom).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'.
|
||||
HotelBranchInformation::addHotelRestriction($idsHotel, 'hbd')
|
||||
);
|
||||
}
|
||||
$occupancyData['count_occupied'] = $countOccupied;
|
||||
|
||||
$countUnavailable = Db::getInstance()->getValue(
|
||||
'SELECT COUNT(hri.`id`)
|
||||
FROM `'._DB_PREFIX_.'htl_room_information` hri
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
ON (hbd.`id` = hri.`id_hotel`)
|
||||
$occupiedRooms = Db::getInstance()->executeS(
|
||||
'SELECT DISTINCT hbd.`id_room`
|
||||
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 p.`active` = 1
|
||||
AND hri.`id_status` != '.(int) HotelRoomInformation::STATUS_ACTIVE.
|
||||
AND hbd.`is_refunded` = 0
|
||||
AND hbd.`date_from` < "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'.
|
||||
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`)
|
||||
FROM `'._DB_PREFIX_.'htl_room_information` hri
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info` hbi
|
||||
ON (hbi.`id` = hri.`id_hotel`)
|
||||
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;
|
||||
|
||||
$occupancyData['count_available'] = $countTotal - $countOccupied - $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'.
|
||||
(!is_null($idsHotel) ? HotelBranchInformation::addHotelRestriction($idsHotel, 'hri') : '')
|
||||
);
|
||||
$occupancyData['count_unavailable'] += $countDisabled;
|
||||
|
||||
$occupancyData['count_available'] = $occupancyData['count_total'] - $occupancyData['count_occupied'] - $occupancyData['count_unavailable'];
|
||||
|
||||
return $occupancyData;
|
||||
}
|
||||
@@ -1061,76 +1067,52 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
return $averageDailyRates;
|
||||
}
|
||||
|
||||
// Average Daily Rate is the average income per paid occupied room in a given time period
|
||||
public static function getAverageDailyRate($dateFrom, $dateTo, $idHotel = null)
|
||||
{
|
||||
if ($dateFrom == $dateTo) {
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
$roomsRevenueByDates = self::getRoomsRevenueForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$occupiedRoomByDates = self::getOccupiedRoomsForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
|
||||
$averageDailyRates = self::getAverageDailyRateForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$totalOccupiedRooms = array_sum($occupiedRoomByDates);
|
||||
$totalRoomsRevenues = array_sum($roomsRevenueByDates);
|
||||
|
||||
if (!is_array($averageDailyRates)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$sumAverageDailyRates = 0;
|
||||
$countAverageDailyRates = 0;
|
||||
foreach ($averageDailyRates as $averageDailyRate) {
|
||||
if ($averageDailyRate != 0) {
|
||||
$sumAverageDailyRates += $averageDailyRate;
|
||||
$countAverageDailyRates++;
|
||||
}
|
||||
}
|
||||
|
||||
return $countAverageDailyRates ? $sumAverageDailyRates / $countAverageDailyRates : 0;
|
||||
return $totalRoomsRevenues ? ($totalRoomsRevenues / $totalOccupiedRooms) : 0;
|
||||
}
|
||||
|
||||
public static function getCancellationRate($dateFrom, $dateTo, $idHotel = false)
|
||||
{
|
||||
$numAllOrders = Db::getInstance()->getValue(
|
||||
'SELECT COUNT(DISTINCT o.`id_order`) FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id_order` = o.`id_order`)
|
||||
WHERE o.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"'.
|
||||
$totalBookings = Db::getInstance()->getValue(
|
||||
'SELECT COUNT(hbd.`id`) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"'.
|
||||
HotelBranchInformation::addHotelRestriction($idHotel, 'hbd')
|
||||
);
|
||||
|
||||
$numCancelledOrders = Db::getInstance()->getValue(
|
||||
'SELECT COUNT(DISTINCT o.`id_order`) FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = o.`current_state`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id_order` = o.`id_order`)
|
||||
WHERE o.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"
|
||||
AND o.`current_state` IN ('.implode(',', array(
|
||||
(int) Configuration::get('PS_OS_CANCELED'),
|
||||
(int) Configuration::get('PS_OS_REFUND'))
|
||||
).')'.
|
||||
$cancelledBookings = Db::getInstance()->getValue(
|
||||
'SELECT COUNT(hbd.`id`) FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`is_refunded` = 1 AND hbd.`date_add` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"'.
|
||||
HotelBranchInformation::addHotelRestriction($idHotel, 'hbd')
|
||||
);
|
||||
|
||||
if ($numAllOrders != 0) {
|
||||
return $numCancelledOrders / $numAllOrders;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return $totalBookings ? (($cancelledBookings / $totalBookings) * 100) : 0;
|
||||
}
|
||||
|
||||
public static function getRevenue($dateFrom, $dateTo, $idHotel = false)
|
||||
public static function getRevenue($dateFrom, $dateTo, $idHotel = false, $orderSource = '')
|
||||
{
|
||||
$result = Db::getInstance()->getValue(
|
||||
'SELECT SUM(total_paid_tax_excl - refunded_amount)
|
||||
FROM (
|
||||
SELECT o.`total_paid_tax_excl` / o.`conversion_rate` AS total_paid_tax_excl,
|
||||
IFNULL(orr.`refunded_amount`, 0) AS refunded_amount,
|
||||
(
|
||||
SELECT hbd.`id_hotel`
|
||||
FROM`'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`id_order` = o.`id_order` LIMIT 1
|
||||
) AS id_hotel
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `' ._DB_PREFIX_.'order_return` orr ON orr.`id_order` = o.`id_order`
|
||||
WHERE o.`valid` = 1 AND o.`invoice_date` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"
|
||||
HAVING 1 '.HotelBranchInformation::addHotelRestriction($idHotel).'
|
||||
) AS t'
|
||||
);
|
||||
$sql = 'SELECT SUM(total_paid_tax_excl - refunded_amount)
|
||||
FROM (SELECT o.`total_paid_tax_excl` / o.`conversion_rate` AS total_paid_tax_excl,
|
||||
IFNULL(orr.`refunded_amount`, 0) AS refunded_amount,
|
||||
(SELECT hbd.`id_hotel` FROM`'._DB_PREFIX_.'htl_booking_detail` hbd WHERE hbd.`id_order` = o.`id_order` LIMIT 1) AS id_hotel
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `' ._DB_PREFIX_.'order_return` orr ON orr.`id_order` = o.`id_order`
|
||||
WHERE o.`valid` = 1 AND o.`invoice_date` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"';
|
||||
|
||||
if ($orderSource) {
|
||||
$sql .= ' AND o.`source` = "'.pSQL($orderSource).'"';
|
||||
}
|
||||
|
||||
$sql .= ' HAVING 1 '.HotelBranchInformation::addHotelRestriction($idHotel).') as t';
|
||||
|
||||
$result = Db::getInstance()->getValue($sql);
|
||||
|
||||
return $result ? $result : 0;
|
||||
}
|
||||
@@ -1156,15 +1138,13 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
|
||||
public static function getRecentOrdersByHotel($idHotel = null, $limit = null)
|
||||
{
|
||||
$idLang = Context::getContext()->language->id;
|
||||
return Db::getInstance()->executeS(
|
||||
'SELECT *, (
|
||||
SELECT osl.`name`
|
||||
FROM `'._DB_PREFIX_.'order_state_lang` osl
|
||||
WHERE osl.`id_order_state` = o.`current_state`
|
||||
AND osl.`id_lang` = '.(int) Context::getContext()->language->id.'
|
||||
LIMIT 1
|
||||
) AS `state_name`, o.`date_add` AS `date_add`, o.`date_upd` AS `date_upd`
|
||||
'SELECT *, osl.`name` AS `state_name`, os.`color` AS `state_color`, o.`date_add` AS `date_add`, o.`date_upd` AS `date_upd`
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (o.`current_state` = os.`id_order_state`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl
|
||||
ON (osl.`id_order_state` = o.`current_state` AND osl.`id_lang` = '.(int) $idLang.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id_order` = o.`id_order`)
|
||||
WHERE 1'.HotelBranchInformation::addHotelRestriction($idHotel, 'hbd').'
|
||||
@@ -1190,6 +1170,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
return $result;
|
||||
}
|
||||
|
||||
// Departures: Guest is going to depart from the hotel today
|
||||
public static function getDeparturesInfoByDate($date, $idHotel = null)
|
||||
{
|
||||
$sql = 'SELECT hbd.*, o.`with_occupancy`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
@@ -1205,6 +1186,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
return $result;
|
||||
}
|
||||
|
||||
// In-House or Stay Over: The guest is not expected to check out today and will remain at least one more night.
|
||||
public static function getInHousesInfo($idHotel = null)
|
||||
{
|
||||
$sql = 'SELECT hbd.*, o.`with_occupancy`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
@@ -1212,7 +1194,10 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`)
|
||||
WHERE hbd.`is_refunded` = 0 AND hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_IN.
|
||||
WHERE hbd.`is_refunded` = 0
|
||||
AND (hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_IN.'
|
||||
OR (hbd.`id_status` = '.(int) HotelBookingDetail::STATUS_CHECKED_OUT.' AND hbd.`check_out` > "'.pSQL(date('Y-m-d')).' 00:00:00"))
|
||||
AND hbd.`date_to` != "'.pSQL(date('Y-m-d')).' 00:00:00"'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '');
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
|
||||
@@ -1221,17 +1206,20 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
|
||||
public static function getNewBookingsInfoByDate($date, $idHotel = null)
|
||||
{
|
||||
$sql = 'SELECT hbd.`id_customer`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name,
|
||||
COUNT(hbd.`id`) AS total_rooms, SUM(hbd.`adults` + hbd.`children`) AS total_guests,
|
||||
hbd.`id_hotel`, hbd.`hotel_name`, hbd.`id_order`, o.`with_occupancy`, o.`total_paid_tax_excl`, o.`id_currency`, osl.`name` AS `state_name`
|
||||
$sql = 'SELECT hbd.`id_customer`, CONCAT(c.`firstname`, " ", c.`lastname`) AS customer_name, COUNT(hbd.`id`) AS total_rooms,
|
||||
SUM(hbd.`adults` + hbd.`children`) AS total_guests, hbd.`id_hotel`, hbd.`hotel_name`, hbd.`id_order`, o.`with_occupancy`,
|
||||
o.`total_paid_tax_excl`, o.`id_currency`, osl.`name` AS `state_name`, os.`color` AS `state_color`
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (o.`current_state` = os.`id_order_state`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl
|
||||
ON (osl.`id_order_state` = o.`current_state` AND osl.`id_lang` = '.(int) Context::getContext()->language->id.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = hbd.`id_customer`)
|
||||
WHERE hbd.`date_add` BETWEEN "'.pSQL($date).' 00:00:00" AND "'.pSQL($date).' 23:59:59"'.
|
||||
WHERE hbd.`date_add` BETWEEN "'.pSQL($date).' 00:00:00" AND "'.pSQL($date).' 23:59:59"'.'
|
||||
AND o.`current_state` NOT IN ('.implode(',', array((int) Configuration::get('PS_OS_CANCELED'), (int) Configuration::get('PS_OS_REFUND'))).')'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').'
|
||||
GROUP BY hbd.`id_order`';
|
||||
|
||||
$result = Db::getInstance()->executeS($sql);
|
||||
|
||||
return $result;
|
||||
@@ -1258,6 +1246,19 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getTotalOccupiedRooms($dateFrom, $dateTo, $idHotel = null)
|
||||
{
|
||||
$sql = 'SELECT COUNT(hbd.`id_room`)
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`is_refunded` = 0
|
||||
AND hbd.`date_from` <= "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '');
|
||||
|
||||
$result = Db::getInstance()->getValue($sql);
|
||||
|
||||
return $result ? $result : 0;
|
||||
}
|
||||
|
||||
public static function getOccupiedRoomsForDiscreteDates($dateFrom, $dateTo = null, $idHotel = null, $useCache = true)
|
||||
{
|
||||
$dateTo = !$dateTo ? date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))) : $dateTo;
|
||||
@@ -1321,11 +1322,12 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
$cacheKey = 'AdminStats::getRoomsRevenueForDiscreteDates'.'_'.(int) $discreteDate['timestamp_from'].'_'.
|
||||
(!is_array($idHotel) ? (int) $idHotel : implode('_', $idHotel));
|
||||
if (!Cache::isStored($cacheKey) || !$useCache) {
|
||||
$sql = 'SELECT IFNULL(SUM(hbd.`total_price_tax_excl` / DATEDIFF(hbd.`date_to`, hbd.`date_from`)), 0)
|
||||
$sql = 'SELECT IFNULL(SUM((hbd.`total_price_tax_excl` / o.`conversion_rate`) / DATEDIFF(hbd.`date_to`, hbd.`date_from`)), 0)
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hbd.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = hbd.`id_order`)
|
||||
WHERE p.`active` = 1
|
||||
AND o.`valid` = 1
|
||||
AND hbd.`is_refunded` = 0
|
||||
AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '');
|
||||
@@ -1368,20 +1370,18 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
(
|
||||
SELECT SUM(DATEDIFF(hbd.`date_to`, hbd.`date_from`))
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
INNER JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hbd.`id_product`)
|
||||
INNER JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`)
|
||||
WHERE hbd.`id_order` = o.`id_order`
|
||||
AND p.`active` = 1 AND hbd.`is_refunded` = 0'.
|
||||
AND p.`active` = 1 AND hbd.`is_refunded` = 0 AND o.`valid` = 1'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').'
|
||||
) AS total_parts,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
INNER JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hbd.`id_product`)
|
||||
INNER JOIN `'._DB_PREFIX_.'product` p ON (p.`id_product` = hbd.`id_product`)
|
||||
WHERE hbd.`id_order` = o.`id_order`
|
||||
AND hbd.`date_from` <= "'.pSQL($discreteDate['date_from']).' 00:00:00" AND hbd.`date_to` >= "'.pSQL($discreteDate['date_to']).' 00:00:00"
|
||||
AND p.`active` = 1 AND hbd.`is_refunded` = 0'.
|
||||
AND p.`active` = 1 AND hbd.`is_refunded` = 0 AND o.`valid` = 1'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').'
|
||||
) AS current_parts
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
@@ -1578,88 +1578,54 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
return $occupancyRates;
|
||||
}
|
||||
|
||||
// Occupancy rate is the percentage of occupied rooms in your hotel at a given time
|
||||
public static function getAverageOccupancyRate($dateFrom, $dateTo, $idHotel = null)
|
||||
{
|
||||
if ($dateFrom == $dateTo) {
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
$occupiedRooms = self::getOccupiedRoomsForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$allRooms = self::getTotalRoomsForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
|
||||
$occupancyRates = self::getOccupancyRateForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$totalOccupiedRooms = array_sum($occupiedRooms);
|
||||
$totalRooms = array_sum($allRooms);
|
||||
|
||||
if (!is_array($occupancyRates)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return array_sum($occupancyRates) / count($occupancyRates);
|
||||
return $totalRooms ? ($totalOccupiedRooms / $totalRooms) * 100 : 0;
|
||||
}
|
||||
|
||||
// Revenue Per Available Room is the average income on all rooms in a given time period
|
||||
// RevPAR relates only to room revenue
|
||||
public static function getRevenuePerAvailableRoom($dateFrom, $dateTo, $idHotel = null)
|
||||
{
|
||||
if ($dateFrom == $dateTo) {
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
$roomsRevenueByDates = self::getRoomsRevenueForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$allRoomsByDate = self::getTotalRoomsForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
|
||||
$averageDailyRates = self::getAverageDailyRateForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$occupancyRates = self::getOccupancyRateForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$totalRoomsRevenues = array_sum($roomsRevenueByDates);
|
||||
$totalRooms = array_sum($allRoomsByDate);
|
||||
|
||||
if (count($averageDailyRates) != count($occupancyRates)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sumRevPars = 0;
|
||||
$countRevPars = 0;
|
||||
foreach ($averageDailyRates as $key => $averageDailyRate) {
|
||||
if ($averageDailyRate != 0) {
|
||||
$sumRevPars += ($averageDailyRate * $occupancyRates[$key]);
|
||||
$countRevPars++;
|
||||
}
|
||||
}
|
||||
|
||||
return $countRevPars ? $sumRevPars / $countRevPars : 0;
|
||||
return $totalRooms ? ($totalRoomsRevenues / $totalRooms) : 0;
|
||||
}
|
||||
|
||||
// TrevPAR appears very similar to RevPAR
|
||||
// RevPAR relates only to room revenue But TrevPAR is for the total(all types services) revenue against your guest rooms.
|
||||
public static function getTotalRevenuePerAvailableRoom($dateFrom, $dateTo, $idHotel = null)
|
||||
{
|
||||
if ($dateFrom == $dateTo) {
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
$totalRevenueByDate = self::getTotalRevenueForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$allRoomsByDate = self::getTotalRoomsForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
|
||||
$totalRevenues = self::getTotalRevenueForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$totalRooms = self::getTotalRoomsForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$totalRevenues = array_sum($totalRevenueByDate);
|
||||
$totalRooms = array_sum($allRoomsByDate);
|
||||
|
||||
if (count($totalRevenues) != count($totalRooms)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sumTrevPars = 0;
|
||||
$countTrevPars = 0;
|
||||
foreach ($totalRevenues as $key => $totalRevenue) {
|
||||
if ($totalRevenue != 0) {
|
||||
$sumTrevPars += ($totalRevenue / $totalRooms[$key]);
|
||||
$countTrevPars++;
|
||||
}
|
||||
}
|
||||
|
||||
return $countTrevPars ? $sumTrevPars / $countTrevPars : 0;
|
||||
return $totalRooms ? ($totalRevenues / $totalRooms) : 0;
|
||||
}
|
||||
|
||||
// ALOS referes to the average number of nights guests stay at your property over a given time
|
||||
// Formula: [number of room nights booked for a given time / number of reservations for the same time]
|
||||
public static function getAverageLengthOfStay($dateFrom, $dateTo, $idHotel = null)
|
||||
{
|
||||
if ($dateFrom == $dateTo) {
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
$nightsBookedByDate = self::getRoomNightsData($dateFrom, $dateTo, $idHotel);
|
||||
|
||||
$sql = 'SELECT AVG(DATEDIFF(hbd.`date_to`, hbd.`date_from`))
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hbd.`id_product`)
|
||||
WHERE p.`active` = 1
|
||||
AND hbd.`is_refunded` = 0
|
||||
AND hbd.`date_from` < "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '');
|
||||
$result = Db::getInstance()->getValue($sql);
|
||||
$totalNightsBooked = array_sum($nightsBookedByDate);
|
||||
$totalOccupiedRoom = self::getTotalOccupiedRooms($dateFrom, $dateTo, $idHotel);
|
||||
|
||||
return $result ? $result : 0;
|
||||
return $totalOccupiedRoom ? ($totalNightsBooked / $totalOccupiedRoom) : 0;
|
||||
}
|
||||
|
||||
public static function getDirectRevenueRatio($dateFrom, $dateTo, $idHotel = null)
|
||||
@@ -1668,35 +1634,16 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
|
||||
$sql = 'SELECT SUM(total_paid_tax_excl - refunded_amount)
|
||||
FROM (
|
||||
SELECT o.`id_order`, o.`total_paid_tax_excl` / o.`conversion_rate` AS total_paid_tax_excl,
|
||||
IFNULL(orr.`refunded_amount`, 0) AS refunded_amount,
|
||||
(SELECT hbd.`id_hotel`
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`id_order` = o.`id_order` LIMIT 1
|
||||
) AS id_hotel
|
||||
FROM `'._DB_PREFIX_.'orders` o
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
ON (hbd.`id_order` = o.`id_order`)
|
||||
INNER JOIN `'._DB_PREFIX_.'htl_branch_info` hbi
|
||||
ON (hbi.`id` = hbd.`id_hotel`)
|
||||
LEFT JOIN `' ._DB_PREFIX_.'order_return` orr
|
||||
ON (orr.`id_order` = o.`id_order`)
|
||||
WHERE o.`valid` = 1 AND hbi.`active` = 1 AND hbd.`is_refunded` = 0
|
||||
AND o.`invoice_date` BETWEEN "'.pSQL($dateFrom).' 00:00:00" AND "'.pSQL($dateTo).' 23:59:59"
|
||||
AND o.`source` = "'.pSQL(Configuration::get('PS_SHOP_DOMAIN')).'"'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').'
|
||||
GROUP BY o.`id_order`
|
||||
) AS t';
|
||||
$directRevenue = (float) Db::getInstance()->getValue($sql);
|
||||
|
||||
// Direct revenue will be revenue from all the channels
|
||||
$totalRevenue = (float) self::getRevenue($dateFrom, $dateTo, $idHotel);
|
||||
|
||||
return $totalRevenue ? ($directRevenue / $totalRevenue) : 0;
|
||||
// Direct revenue will be revenue from this website only
|
||||
$directRevenue = (float) self::getRevenue($dateFrom, $dateTo, $idHotel, Configuration::get('PS_SHOP_DOMAIN'));
|
||||
|
||||
return $totalRevenue ? (($directRevenue / $totalRevenue) * 100) : 0;
|
||||
}
|
||||
|
||||
public static function getOperatingExpensesForDiscreteDates($dateFrom, $dateTo = null, $idHotel = null, $useCache = true)
|
||||
public static function getOperatingExpensesForDiscreteDates($dateFrom, $dateTo = null, $idHotel = null, $useCache = true, $onlyRooms = 0)
|
||||
{
|
||||
$dateTo = !$dateTo ? date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))) : $dateTo;
|
||||
|
||||
@@ -1717,7 +1664,8 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
$cacheKey = 'AdminStats::getOperatingExpensesForDiscreteDates'.'_'.(int) $discreteDate['timestamp_from'].'_'.
|
||||
(!is_array($idHotel) ? (int) $idHotel : implode('_', $idHotel));
|
||||
if (!Cache::isStored($cacheKey) || !$useCache) {
|
||||
$sql = 'SELECT
|
||||
// sql for rooms expenses
|
||||
$roomsSql = 'SELECT
|
||||
IFNULL(SUM(
|
||||
CASE
|
||||
WHEN od.`original_wholesale_price` <> "0.000000"
|
||||
@@ -1736,8 +1684,36 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '');
|
||||
|
||||
$value = Db::getInstance()->getValue($sql);
|
||||
Cache::store($cacheKey, $value);
|
||||
$roomsExpenses = Db::getInstance()->getValue($roomsSql);
|
||||
|
||||
// sql for services expenses
|
||||
$servicesExpenses = 0;
|
||||
if (!$onlyRooms) {
|
||||
$servicesSql = 'SELECT
|
||||
IFNULL(SUM(
|
||||
CASE
|
||||
WHEN od.`original_wholesale_price` <> "0.000000"
|
||||
THEN od.`original_wholesale_price`
|
||||
WHEN p.`wholesale_price` <> "0.000000"
|
||||
THEN p.`wholesale_price`
|
||||
END
|
||||
), 0)
|
||||
FROM `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rtspod
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
ON (rtspod.`id_htl_booking_detail` = hbd.`id`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hbd.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_detail` od
|
||||
ON (od.`id_order_detail` = rtspod.`id_order_detail`)
|
||||
WHERE p.`active` = 1
|
||||
AND hbd.`is_refunded` = 0
|
||||
AND hbd.`date_from` < "'.pSQL($discreteDate['date_to']).' 00:00:00" AND hbd.`date_to` > "'.pSQL($discreteDate['date_from']).' 00:00:00"'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '');
|
||||
|
||||
$servicesExpenses = Db::getInstance()->getValue($servicesSql);
|
||||
}
|
||||
|
||||
Cache::store($cacheKey, ($roomsExpenses + $servicesExpenses));
|
||||
}
|
||||
|
||||
$result[$discreteDate['timestamp_from']] = Cache::retrieve($cacheKey);
|
||||
@@ -1776,29 +1752,20 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
|
||||
public static function getGrossOperatingProfitPerAvailableRoom($dateFrom, $dateTo, $idHotel = null)
|
||||
{
|
||||
if ($dateFrom == $dateTo) {
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
$totalRevenueByDate = self::getTotalRevenueForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$operatingExpensesByDate = self::getOperatingExpensesForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$allRoomsByDate = self::getTotalRoomsForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
|
||||
$grossOpProfitPars = self::getGrossOperatingProfitPerAvailableRoomForDiscreteDates($dateFrom, $dateTo, $idHotel);
|
||||
$totalRevenues = array_sum($totalRevenueByDate);
|
||||
$totalExpenses = array_sum($operatingExpensesByDate);
|
||||
$totalRooms = array_sum($allRoomsByDate);
|
||||
|
||||
if (!count($grossOpProfitPars)) {
|
||||
return false;
|
||||
}
|
||||
$totalProfit = $totalRevenues - $totalExpenses;
|
||||
|
||||
$sumGrossOpProfitPars = 0;
|
||||
$countGrossOpProfitPars = 0;
|
||||
foreach ($grossOpProfitPars as $grossOpProfitPar) {
|
||||
if ($grossOpProfitPar != 0) {
|
||||
$sumGrossOpProfitPars += $grossOpProfitPar;
|
||||
$countGrossOpProfitPars++;
|
||||
}
|
||||
}
|
||||
|
||||
return $countGrossOpProfitPars ? $sumGrossOpProfitPars / $countGrossOpProfitPars : 0;
|
||||
return $totalProfit ? ($totalProfit / $totalRooms) : 0;
|
||||
}
|
||||
|
||||
public static function getRoomNightsData($dateFrom, $dateTo = null, $idHotel = null, $useCache = true, $average = false)
|
||||
public static function getRoomNightsData($dateFrom, $dateTo = null, $idHotel = null, $useCache = true, $average = false, $roundAvg = false)
|
||||
{
|
||||
$dateTo = !$dateTo ? date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))) : $dateTo;
|
||||
|
||||
@@ -1838,6 +1805,9 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
if ($totalHotels > 1) {
|
||||
foreach ($result as $timestamp => &$value) {
|
||||
$value = $value / $totalHotels;
|
||||
if ($roundAvg) {
|
||||
$value = Tools::ps_round($value, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1851,28 +1821,29 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
public static function getOccupiedRoomsForDayOfTheWeek($dow, $dateFrom, $dateTo = null, $idHotel = null, $useCache = true)
|
||||
{
|
||||
$dateTo = !$dateTo ? date('Y-m-d', strtotime('+1 day', strtotime($dateFrom))) : $dateTo;
|
||||
$dateToNext = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
|
||||
$result = 0;
|
||||
$cacheKey = 'AdminStats::getOccupiedRoomsForDayOfTheWeek'.'_'.(int) $dow.(int) strtotime($dateFrom).
|
||||
(int) strtotime($dateTo).(!is_array($idHotel) ? (int) $idHotel : implode('_', $idHotel));
|
||||
if (!Cache::isStored($cacheKey) || !$useCache) {
|
||||
// (los/7) + {if(los%7 has $dow) + 1 else + 0)}
|
||||
// dow(start_of(remaining_days)) = dow_date_from && dow(end_of(remaining_days)) = dow_date_to
|
||||
$sql = 'SELECT SUM((full_weeks + IF(('.(int) $dow.' >= dow_date_from AND '.(int) $dow.' < dow_date_to), 1, 0)))
|
||||
AS total_occupied
|
||||
$sql = 'SELECT SUM((full_weeks) + IF('.(int) $dow.' = dow_date_from || ('.(int) $dow.' > dow_date_from AND (dow_date_from + los - 1) > '.(int) $dow.') || (dow_date_from > '.(int) $dow.' AND ((dow_date_from + los - 1) - 7) >= '.(int) $dow.'), 1, 0)) AS total_occupied
|
||||
FROM (
|
||||
SELECT hbd.`id`, hbd.`date_from`, hbd.`date_to`, DAYOFWEEK(hbd.`date_from`) AS dow_date_from,
|
||||
DAYOFWEEK(hbd.`date_to`) AS dow_date_to,
|
||||
DATEDIFF(hbd.`date_to`, hbd.`date_from`) AS los,
|
||||
ROUND(DATEDIFF(hbd.`date_to`, hbd.`date_from`) / 7) AS full_weeks,
|
||||
DATEDIFF(hbd.`date_to`, hbd.`date_from`) % 7 AS remaining_days
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`is_refunded` = 0
|
||||
AND hbd.`date_from` < "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').'
|
||||
) AS t';
|
||||
SELECT DAYOFWEEK(`date_from_final`) AS dow_date_from,
|
||||
DAYOFWEEK(`date_to_final`) AS dow_date_to,
|
||||
DATEDIFF(`date_to_final`, `date_from_final`) as los,
|
||||
IF(('.(int) $dow.' >= DAYOFWEEK(`date_from_final`)), ((DATEDIFF(`date_to_final`, `date_from_final`) -('.(int) $dow.' + 1 - DAYOFWEEK(`date_from_final`))) DIV 7), ((DATEDIFF(`date_to_final`, `date_from_final`) - (7 - DAYOFWEEK(`date_from_final`) + '.(int) $dow.')) DIV 7)) AS full_weeks
|
||||
FROM (
|
||||
SELECT IF(DATEDIFF(hbd.`date_from`, \''.pSQL($dateFrom).'\') < 0, \''.pSQL($dateFrom).'\', hbd.`date_from`) AS date_from_final, IF(DATEDIFF(\''.pSQL($dateTo).'\', hbd.`date_to`) < 0, \''.pSQL($dateToNext).'\', hbd.`date_to`) AS date_to_final
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
WHERE hbd.`is_refunded` = 0
|
||||
AND hbd.`date_from` <= \''.pSQL($dateTo).'\' AND hbd.`date_to` > \''.pSQL($dateFrom).'\''.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').'
|
||||
) AS t
|
||||
) AS t1';
|
||||
|
||||
$value = (int) Db::getInstance()->getValue($sql);
|
||||
|
||||
Cache::store($cacheKey, $value);
|
||||
|
||||
$result = Cache::retrieve($cacheKey);
|
||||
@@ -1939,17 +1910,13 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
$cacheKey = 'AdminStats::getLengthOfStayRatio'.'_'.(int) $losMinimum.(int) $losMaximum.
|
||||
(int) strtotime($dateFrom).(int) strtotime($dateTo).(!is_array($idHotel) ? (int) $idHotel : implode('_', $idHotel));
|
||||
if (!Cache::isStored($cacheKey) || !$useCache) {
|
||||
if ($dateFrom == $dateTo) {
|
||||
$dateTo = date('Y-m-d', strtotime('+1 day', strtotime($dateTo)));
|
||||
}
|
||||
|
||||
$sql = 'SELECT COUNT(hbd.`id`) AS total
|
||||
FROM `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
LEFT JOIN `'._DB_PREFIX_.'product` p
|
||||
ON (p.`id_product` = hbd.`id_product`)
|
||||
WHERE p.`active` = 1
|
||||
AND hbd.`is_refunded` = 0
|
||||
AND hbd.`date_from` < "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'.
|
||||
AND hbd.`date_from` <= "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '');
|
||||
|
||||
$total = Db::getInstance()->getValue($sql);
|
||||
@@ -1962,7 +1929,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
ON (p.`id_product` = hbd.`id_product`)
|
||||
WHERE p.`active` = 1
|
||||
AND hbd.`is_refunded` = 0
|
||||
AND hbd.`date_from` < "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'.
|
||||
AND hbd.`date_from` <= "'.pSQL($dateTo).' 00:00:00" AND hbd.`date_to` > "'.pSQL($dateFrom).' 00:00:00"'.
|
||||
(!is_null($idHotel) ? HotelBranchInformation::addHotelRestriction($idHotel, 'hbd') : '').'
|
||||
) AS t
|
||||
WHERE los >= '.(int) $losMinimum.' AND los <= '.(int) ($losMaximum ? $losMaximum : $losMinimum);
|
||||
@@ -1978,7 +1945,7 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getLengthOfStayPercentages($days, $dateFrom, $dateTo, $idHotel = null, $useCache = true, $average = false)
|
||||
public static function getLengthOfStayInfo($days, $dateFrom, $dateTo, $idHotel = null, $useCache = true)
|
||||
{
|
||||
$idsHotel = array();
|
||||
if (is_int($idHotel)) {
|
||||
@@ -2017,18 +1984,11 @@ class AdminStatsControllerCore extends AdminStatsTabController
|
||||
}
|
||||
}
|
||||
|
||||
// calculate averages
|
||||
if ($average) {
|
||||
$totalHotels = count($idsHotel);
|
||||
if ($totalHotels > 1) {
|
||||
foreach ($result as $key => $ratio) {
|
||||
$result[$key] = $ratio['total'] ? ($ratio['fraction'] / $ratio['total']) : 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($result as $key => $ratio) {
|
||||
$result[$key] = $ratio['total'] ? ($ratio['fraction'] / $ratio['total']) : 0;
|
||||
}
|
||||
foreach ($result as $key => $ratio) {
|
||||
$result[$key] = array(
|
||||
'rooms_occupied' => $ratio['fraction'],
|
||||
'percent' => $ratio['total'] ? ($ratio['fraction'] / $ratio['total'] * 100) : 0
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
@@ -99,16 +99,6 @@ class AdminStatusesControllerCore extends AdminController
|
||||
'orderby' => false,
|
||||
'class' => 'fixed-width-sm'
|
||||
),
|
||||
'delivery' => array(
|
||||
'title' => $this->l('Delivery'),
|
||||
'align' => 'text-center',
|
||||
'active' => 'delivery',
|
||||
'type' => 'bool',
|
||||
'ajax' => true,
|
||||
'orderby' => false,
|
||||
'class' => 'fixed-width-sm'
|
||||
)
|
||||
,
|
||||
'invoice' => array(
|
||||
'title' => $this->l('Invoice'),
|
||||
'align' => 'text-center',
|
||||
@@ -238,8 +228,13 @@ class AdminStatusesControllerCore extends AdminController
|
||||
'show_admin_template' => $mailToSuperadmin || $mailToEmployee || $mailToHotelier,
|
||||
);
|
||||
} else {
|
||||
$name = array();
|
||||
foreach ($this->_languages as $language) {
|
||||
$name[$language['id_lang']] = $this->getFieldValue($order_return_state, 'name', $language['id_lang']);
|
||||
}
|
||||
|
||||
$this->fields_value = array(
|
||||
'name' => $this->getFieldValue($order_return_state, 'name'),
|
||||
'name' => $name,
|
||||
'color' => "#ffffff",
|
||||
);
|
||||
}
|
||||
@@ -412,28 +407,28 @@ class AdminStatusesControllerCore extends AdminController
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'pdf_delivery',
|
||||
'values' => array(
|
||||
'query' => array(
|
||||
array('id' => 'on', 'name' => $this->l('Attach delivery slip PDF to email.'), 'val' => '1'),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'shipped',
|
||||
'values' => array(
|
||||
'query' => array(
|
||||
array('id' => 'on', 'name' => $this->l('Set the order as shipped.'), 'val' => '1'),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'checkbox',
|
||||
// 'name' => 'pdf_delivery',
|
||||
// 'values' => array(
|
||||
// 'query' => array(
|
||||
// array('id' => 'on', 'name' => $this->l('Attach delivery slip PDF to email.'), 'val' => '1'),
|
||||
// ),
|
||||
// 'id' => 'id',
|
||||
// 'name' => 'name'
|
||||
// ),
|
||||
// ),
|
||||
// array(
|
||||
// 'type' => 'checkbox',
|
||||
// 'name' => 'shipped',
|
||||
// 'values' => array(
|
||||
// 'query' => array(
|
||||
// array('id' => 'on', 'name' => $this->l('Set the order as shipped.'), 'val' => '1'),
|
||||
// ),
|
||||
// 'id' => 'id',
|
||||
// 'name' => 'name'
|
||||
// )
|
||||
// ),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'paid',
|
||||
@@ -445,17 +440,17 @@ class AdminStatusesControllerCore extends AdminController
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'delivery',
|
||||
'values' => array(
|
||||
'query' => array(
|
||||
array('id' => 'on', 'name' => $this->l('Show delivery PDF.'), 'val' => '1'),
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
// array(
|
||||
// 'type' => 'checkbox',
|
||||
// 'name' => 'delivery',
|
||||
// 'values' => array(
|
||||
// 'query' => array(
|
||||
// array('id' => 'on', 'name' => $this->l('Show delivery PDF.'), 'val' => '1'),
|
||||
// ),
|
||||
// 'id' => 'id',
|
||||
// 'name' => 'name'
|
||||
// )
|
||||
// ),
|
||||
array(
|
||||
'type' => 'select_template',
|
||||
'is_customer_template' => 1,
|
||||
@@ -478,7 +473,16 @@ class AdminStatusesControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
return $this->renderOrderStatusForm();
|
||||
} elseif (Tools::isSubmit('updateorder_return_state')
|
||||
@@ -683,7 +687,16 @@ class AdminStatusesControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
@@ -789,7 +802,11 @@ class AdminStatusesControllerCore extends AdminController
|
||||
if (!$order_return_state->save()) {
|
||||
$this->errors[] = Tools::displayError('An error has occurred: Can\'t save the current order\'s refund status.');
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||
if (Tools::isSubmit('submitAddorder_return_stateAndStay')) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&updateorder_return_state&id_order_return_state='.$id_order_return_state.'&conf=4&token='.$this->token);
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,16 @@ class AdminTabsControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
@@ -340,7 +349,7 @@ class AdminTabsControllerCore extends AdminController
|
||||
{
|
||||
$way = (int)(Tools::getValue('way'));
|
||||
$id_tab = (int)(Tools::getValue('id'));
|
||||
$positions = Tools::getValue('tab');
|
||||
$positions = Tools::getValue('menu');
|
||||
|
||||
// when changing positions in a tab sub-list, the first array value is empty and needs to be removed
|
||||
if (!$positions[0]) {
|
||||
|
||||
@@ -233,7 +233,16 @@ class AdminTaxesControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save')
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
@@ -258,7 +267,11 @@ class AdminTaxesControllerCore extends AdminController
|
||||
if (!$result) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating an object.').' <b>'.$this->table.'</b>';
|
||||
} elseif ($this->postImage($object->id)) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=4'.'&token='.$this->token);
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&update'.$this->table.'&id_'.$this->table.'='.$object->id.'&conf=4'.'&token='.$this->token);
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=4&token='.$this->token);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating an object.').' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
@@ -272,10 +285,17 @@ class AdminTaxesControllerCore extends AdminController
|
||||
$this->copyFromPost($object, $this->table);
|
||||
if (!$object->add()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating an object.').' <b>'.$this->table.'</b>';
|
||||
} elseif (($_POST['id_'.$this->table] = $object->id /* voluntary */) && $this->postImage($object->id) && $this->_redirect) {
|
||||
} elseif ($this->postImage($object->id)) {
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&update'.$this->table.'&id_'.$this->table.'='.$object->id.'&conf=3'.'&token='.$this->token);
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=3&token='.$this->token);
|
||||
}
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_'.$this->table.'='.$object->id.'&conf=3'.'&token='.$this->token);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->display = 'add';
|
||||
}
|
||||
} else {
|
||||
parent::postProcess();
|
||||
|
||||
@@ -358,7 +358,16 @@ class AdminThemesControllerCore extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
),
|
||||
'buttons' => array(
|
||||
'save-and-stay' => array(
|
||||
'title' => $this->l('Save and stay'),
|
||||
'name' => 'submitAdd'.$this->table.'AndStay',
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-default pull-right',
|
||||
'icon' => 'process-icon-save',
|
||||
),
|
||||
),
|
||||
);
|
||||
// adding a new theme, you can create a directory, and copy from an existing theme
|
||||
if ($this->display == 'add' || !Validate::isLoadedObject($this->object)) {
|
||||
@@ -644,7 +653,12 @@ class AdminThemesControllerCore extends AdminController
|
||||
}
|
||||
$theme->update();
|
||||
}
|
||||
Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminThemes').'&conf=29');
|
||||
|
||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&update'.$this->table.'&id_theme='.$theme->id.'&token='.$this->token.'&conf=4');
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&conf=4');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2097,7 +2111,6 @@ class AdminThemesControllerCore extends AdminController
|
||||
'blockcart',
|
||||
'blockcurrencies',
|
||||
'blocklanguages',
|
||||
'qloblockcontact',
|
||||
'blockmyaccount',
|
||||
'blocknewsletter',
|
||||
'blocksocial',
|
||||
|
||||
@@ -118,6 +118,10 @@ class AdminWebserviceControllerCore extends AdminController
|
||||
{
|
||||
parent::processUpdateOptions();
|
||||
Tools::generateHtaccess();
|
||||
|
||||
if (!count($this->errors)) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&conf=6');
|
||||
}
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
|
||||
@@ -221,6 +221,8 @@ class AddressControllerCore extends FrontController
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
$this->show_breadcrump = true;
|
||||
|
||||
parent::initContent();
|
||||
|
||||
$this->assignCountries();
|
||||
|
||||
@@ -102,6 +102,7 @@ class AuthControllerCore extends FrontController
|
||||
|
||||
$newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active);
|
||||
|
||||
$this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE'));
|
||||
$this->context->smarty->assign('newsletter', $newsletter);
|
||||
$this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN'));
|
||||
|
||||
@@ -112,6 +113,9 @@ class AuthControllerCore extends FrontController
|
||||
$back .= (strpos($back, '?') !== false ? '&' : '?').'key='.$key;
|
||||
}
|
||||
|
||||
// sanitize backurl for XSS protection
|
||||
$back = filter_var($back, FILTER_SANITIZE_URL);
|
||||
|
||||
if ($back == Tools::secureReferrer(Tools::getValue('back'))) {
|
||||
$this->context->smarty->assign('back', html_entity_decode($back));
|
||||
} else {
|
||||
@@ -173,9 +177,15 @@ class AuthControllerCore extends FrontController
|
||||
'errors' => $this->errors,
|
||||
'hasAjaxExtraData' => !empty($this->ajaxExtraData),
|
||||
'ajaxExtraData' => $this->ajaxExtraData,
|
||||
'page' => $this->context->smarty->fetch($this->template),
|
||||
'token' => Tools::getToken(false)
|
||||
);
|
||||
|
||||
// send page html only if no errors in the form and we have to open registration form
|
||||
// It also prevents opening html in the response in case of an error for XSS protection
|
||||
if (empty($this->errors)) {
|
||||
$return['page'] = $this->context->smarty->fetch($this->template);
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($return));
|
||||
}
|
||||
}
|
||||
@@ -294,7 +304,9 @@ class AuthControllerCore extends FrontController
|
||||
$this->errors[] = Tools::displayError('Password is required.');
|
||||
} elseif (!Validate::isPasswd($passwd)) {
|
||||
$this->errors[] = Tools::displayError('Invalid password.');
|
||||
} else {
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$customer = new Customer();
|
||||
$authentication = $customer->getByEmail(trim($email), trim($passwd));
|
||||
if (isset($authentication->active) && !$authentication->active) {
|
||||
@@ -321,6 +333,7 @@ class AuthControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->ajax) {
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
@@ -386,7 +399,7 @@ class AuthControllerCore extends FrontController
|
||||
if (Validate::isEmail($email = Tools::getValue('email')) && !empty($email)) {
|
||||
if (Customer::customerExists($email)) {
|
||||
$this->errors[] = Tools::displayError('An account using this email address has already been registered.', false);
|
||||
} elseif (Customer::customerExists($email, false, false)) {
|
||||
} elseif (Tools::getValue('is_new_customer', 1) && Customer::customerExists($email, false, false)) {
|
||||
$this->errors[] = Tools::displayError('You are already registered as a guest with this email address.').' <button type="submit" class="btn btn-link alert-link btn-transform" name="submitTransformAccount">'.Tools::displayError('Click here').'</button>'.Tools::displayError('').' to generate a password for your account.';
|
||||
}
|
||||
}
|
||||
@@ -463,9 +476,11 @@ class AuthControllerCore extends FrontController
|
||||
$this->processCustomerNewsletter($customer);
|
||||
|
||||
$customer->firstname = Tools::ucwords($customer->firstname);
|
||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
|
||||
if (!Validate::isBirthDate($customer->birthday)) {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth.');
|
||||
if (Configuration::get('PS_CUSTOMER_BIRTHDATE')) {
|
||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
|
||||
if (!Validate::isBirthDate($customer->birthday)) {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth.');
|
||||
}
|
||||
}
|
||||
|
||||
// New Guest customer
|
||||
@@ -588,26 +603,42 @@ class AuthControllerCore extends FrontController
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
if (Customer::customerExists(Tools::getValue('email'))) {
|
||||
$this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false);
|
||||
if (!Tools::getValue('is_new_customer', 1)) {
|
||||
if ($idCustomer = Customer::customerExists(Tools::getValue('email'), true, false)) {
|
||||
if ($idAddress = Customer::getCustomerIdAddress($idCustomer)) {
|
||||
$address = new Address($idAddress);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Customer::customerExists(Tools::getValue('email'))) {
|
||||
$this->errors[] = Tools::displayError('An account using this email address has already been registered. Please enter a valid password or request a new one. ', false);
|
||||
}
|
||||
}
|
||||
|
||||
$this->processCustomerNewsletter($customer);
|
||||
|
||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
|
||||
if (!Validate::isBirthDate($customer->birthday)) {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth');
|
||||
if (Configuration::get('PS_CUSTOMER_BIRTHDATE')) {
|
||||
$customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'));
|
||||
if (!Validate::isBirthDate($customer->birthday)) {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth');
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$customer->active = 1;
|
||||
// New Guest customer
|
||||
if (Tools::isSubmit('is_new_customer')) {
|
||||
$customer->is_guest = !Tools::getValue('is_new_customer', 1);
|
||||
if (isset($idCustomer) && $idCustomer) {
|
||||
// update guest customer details
|
||||
$customer = new Customer($idCustomer);
|
||||
$customer->firstname = Tools::getValue('firstname');
|
||||
$customer->lastname = Tools::getValue('lastname');
|
||||
}
|
||||
$customer->is_guest = 1;
|
||||
} else {
|
||||
$customer->is_guest = 0;
|
||||
}
|
||||
if (!$customer->add()) {
|
||||
if (!$customer->save()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your account.');
|
||||
} else {
|
||||
foreach ($addresses_types as $addresses_type) {
|
||||
@@ -624,7 +655,7 @@ class AuthControllerCore extends FrontController
|
||||
if ($addresses_type == 'address_invoice') {
|
||||
$_POST = $post_back;
|
||||
}
|
||||
if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$$addresses_type->add()) {
|
||||
if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$$addresses_type->save()) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while creating your address.');
|
||||
}
|
||||
}
|
||||
@@ -736,6 +767,8 @@ class AuthControllerCore extends FrontController
|
||||
unset($_POST['email_create']);
|
||||
} elseif ($id_customer = Customer::customerExists($email, true, false)) {
|
||||
$this->informations[] = Tools::displayError('You are already registered as a guest with this email address.').' <button type="submit" class="btn btn-link alert-link btn-transform" name="submitTransformAccount">'.Tools::displayError('Click here').'</button>'.Tools::displayError('').' to generate a password for your account.';
|
||||
} elseif (Tools::getValue('back') && !Validate::isUrl(Tools::getValue('back'))) {
|
||||
$this->errors[] = Tools::displayError('back url is invalid.');
|
||||
} else {
|
||||
$this->create_account = true;
|
||||
$this->context->smarty->assign('email_create', Tools::safeOutput($email));
|
||||
@@ -788,10 +821,9 @@ class AuthControllerCore extends FrontController
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{email}' => $customer->email,
|
||||
'{passwd}' => str_repeat('*', strlen(Tools::getValue('passwd'))),
|
||||
),
|
||||
$customer->email,
|
||||
$customer->firstname.' '.$customer->lastname
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,25 +319,23 @@ class CartControllerCore extends FrontController
|
||||
$serviceProducts = json_decode(Tools::getValue('serviceProducts'),true);
|
||||
|
||||
// valdiate occupancy if providede
|
||||
if ($operator == 'up') {
|
||||
if ($occupancyRequiredForBooking) {
|
||||
foreach($occupancy as $key => $roomOccupancy) {
|
||||
if (!isset($roomOccupancy['adults']) || !$roomOccupancy['adults'] || !Validate::isUnsignedInt($roomOccupancy['adults'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid number of adults for Room %s.'), ($key + 1));
|
||||
if ($operator == 'up' && $occupancyRequiredForBooking) {
|
||||
foreach($occupancy as $key => $roomOccupancy) {
|
||||
if (!isset($roomOccupancy['adults']) || !$roomOccupancy['adults'] || !Validate::isUnsignedInt($roomOccupancy['adults'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid number of adults for Room %s.'), ($key + 1));
|
||||
}
|
||||
if (isset($roomOccupancy['children'])) {
|
||||
if (!Validate::isUnsignedInt($roomOccupancy['children'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid number of children for Room %s.'), ($key + 1));
|
||||
}
|
||||
if (isset($roomOccupancy['children'])) {
|
||||
if (!Validate::isUnsignedInt($roomOccupancy['children'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid number of children for Room %s.'), ($key + 1));
|
||||
}
|
||||
if ($roomOccupancy['children'] > 0) {
|
||||
if (!isset($roomOccupancy['child_ages']) || ($roomOccupancy['children'] != count($roomOccupancy['child_ages'])) || !is_array($roomOccupancy['child_ages'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Please provide all children age for Room %s.'), ($key + 1));
|
||||
} else {
|
||||
if (is_array($roomOccupancy['child_ages'])) {
|
||||
foreach($roomOccupancy['child_ages'] as $childAge) {
|
||||
if (!Validate::isUnsignedInt($childAge)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid children age for Room %s.'), ($key + 1));
|
||||
}
|
||||
if ($roomOccupancy['children'] > 0) {
|
||||
if (!isset($roomOccupancy['child_ages']) || ($roomOccupancy['children'] != count($roomOccupancy['child_ages'])) || !is_array($roomOccupancy['child_ages'])) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Please provide all children age for Room %s.'), ($key + 1));
|
||||
} else {
|
||||
if (is_array($roomOccupancy['child_ages'])) {
|
||||
foreach($roomOccupancy['child_ages'] as $childAge) {
|
||||
if (!Validate::isUnsignedInt($childAge)) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Invalid children age for Room %s.'), ($key + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,6 +343,20 @@ class CartControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
foreach($occupancy as $key => $roomOccupancy) {
|
||||
if ($roomOccupancy['adults'] > $roomTypeInfo['max_adults']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have adults more than %s'), $key + 1, $roomTypeInfo['max_adults']);
|
||||
}
|
||||
if ($roomOccupancy['children'] > $roomTypeInfo['max_children']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have children more than %s'), $key + 1, $roomTypeInfo['max_children']);
|
||||
}
|
||||
if ($roomOccupancy['adults'] + $roomOccupancy['children'] > $roomTypeInfo['max_guests']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have total guests more than %s'), $key + 1, $roomTypeInfo['max_guests']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($id_hotel = $roomTypeInfo['id_hotel']) {
|
||||
@@ -361,19 +373,7 @@ class CartControllerCore extends FrontController
|
||||
$this->errors[] = Tools::displayError('You can\'t book room after date '.$maxOrdDate);
|
||||
}
|
||||
}
|
||||
if ($occupancyRequiredForBooking) {
|
||||
foreach($occupancy as $key => $roomOccupancy) {
|
||||
if ($roomOccupancy['adults'] > $roomTypeInfo['max_adults']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have adults more than %s'), $key + 1, $roomTypeInfo['max_adults']);
|
||||
}
|
||||
if ($roomOccupancy['children'] > $roomTypeInfo['max_children']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have children more than %s'), $key + 1, $roomTypeInfo['max_children']);
|
||||
}
|
||||
if ($roomOccupancy['adults'] + $roomOccupancy['children'] > $roomTypeInfo['max_guests']) {
|
||||
$this->errors[] = sprintf(Tools::displayError('Room %s cannot have total guests more than %s'), $key + 1, $roomTypeInfo['max_guests']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->errors) {
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
$num_days = $objBookingDetail->getNumberOfDays($date_from, $date_to);
|
||||
|
||||
@@ -211,7 +211,7 @@ class CategoryControllerCore extends FrontController
|
||||
'order_date_restrict' => $order_date_restrict
|
||||
));
|
||||
} else {
|
||||
Tools::redirect($this->context->link->getPageLink('index'));
|
||||
Tools::redirect($this->context->link->getPageLink('pagenotfound'));
|
||||
}
|
||||
|
||||
$feat_img_dir = _PS_IMG_.'rf/';
|
||||
|
||||
@@ -221,10 +221,12 @@ class ContactControllerCore extends FrontController
|
||||
$this->addJS(_PS_JS_DIR_.'validate.js');
|
||||
|
||||
// GOOGLE MAP
|
||||
$language = $this->context->language;
|
||||
$country = $this->context->country;
|
||||
$PS_API_KEY = Configuration::get('PS_API_KEY');
|
||||
$this->addJs("https://maps.googleapis.com/maps/api/js?key=$PS_API_KEY&libraries=places&language=$language->iso_code®ion=$country->iso_code");
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
|
||||
$this->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.
|
||||
'&libraries=places&language='.$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,7 +305,7 @@ class ContactControllerCore extends FrontController
|
||||
);
|
||||
|
||||
//By webkul to send hotels Map Informations for google Map.
|
||||
if (Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
|
||||
if (Configuration::get('PS_API_KEY') && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
|
||||
$hotelLocationArray = $objHotelInfo->getMapFormatHotelsInfo(Configuration::get('WK_MAP_HOTEL_ACTIVE_ONLY'));
|
||||
if ($hotelLocationArray) {
|
||||
$this->context->smarty->assign('hotelLocationArray', json_encode($hotelLocationArray));
|
||||
|
||||
@@ -37,6 +37,8 @@ class DiscountControllerCore extends FrontController
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
$this->show_breadcrump = true;
|
||||
|
||||
parent::initContent();
|
||||
|
||||
$cart_rules = CartRule::getCustomerCartRules($this->context->language->id, $this->context->customer->id, true, false, true);
|
||||
|
||||
@@ -205,226 +205,259 @@ class GuestTrackingControllerCore extends FrontController
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
$objRoomType = new HotelRoomType();
|
||||
|
||||
$nonRequestedRooms = 0;
|
||||
$anyBackOrder = 0;
|
||||
$processedProducts = array();
|
||||
$cartHotelData = array();
|
||||
}
|
||||
|
||||
foreach ($order_list as &$order) {
|
||||
$idOrder = $order->id;
|
||||
/** @var Order $order */
|
||||
$order->id_order_state = (int)$order->getCurrentState();
|
||||
$order->invoice = (OrderState::invoiceAvailable((int)$order->id_order_state) && $order->invoice_number);
|
||||
$order->order_history = $order->getHistory((int)$this->context->language->id, false, true);
|
||||
$order->carrier = new Carrier((int)$order->id_carrier, (int)$order->id_lang);
|
||||
$order->address_invoice = new Address((int)$order->id_address_invoice);
|
||||
$order->address_delivery = new Address((int)$order->id_address_delivery);
|
||||
$order->inv_adr_fields = AddressFormat::getOrderedAddressFields($order->address_invoice->id_country);
|
||||
$order->dlv_adr_fields = AddressFormat::getOrderedAddressFields($order->address_delivery->id_country);
|
||||
$order->invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($order->address_invoice, $order->inv_adr_fields);
|
||||
$order->deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($order->address_delivery, $order->dlv_adr_fields);
|
||||
$order->currency = new Currency($order->id_currency);
|
||||
$order->discounts = $order->getCartRules();
|
||||
$order->invoiceState = (Validate::isLoadedObject($order->address_invoice) && $order->address_invoice->id_state) ? new State((int)$order->address_invoice->id_state) : false;
|
||||
$order->deliveryState = (Validate::isLoadedObject($order->address_delivery) && $order->address_delivery->id_state) ? new State((int)$order->address_delivery->id_state) : false;
|
||||
$order->products = $order->getProducts();
|
||||
$order->customizedDatas = Product::getAllCustomizedDatas((int)$order->id_cart);
|
||||
Product::addCustomizationPrice($order->products, $order->customizedDatas);
|
||||
$order->total_old = $order->total_discounts > 0 ? (float)$order->total_paid - (float)$order->total_discounts : false;
|
||||
foreach ($order_list as &$order) {
|
||||
$idOrder = $order->id;
|
||||
|
||||
if ($order->carrier->url && $order->shipping_number) {
|
||||
$order->followup = str_replace('@', $order->shipping_number, $order->carrier->url);
|
||||
}
|
||||
$order->hook_orderdetaildisplayed = Hook::exec('displayOrderDetail', array('order' => $order));
|
||||
$processedProducts = array();
|
||||
$cartHotelData = array();
|
||||
|
||||
// enter the details of the booking the order
|
||||
if ($hotelresInstalled) {
|
||||
if ($orderProducts = $order->getProducts()) {
|
||||
$total_demands_price_te = 0;
|
||||
$total_demands_price_ti = 0;
|
||||
$total_convenience_fee_te = 0;
|
||||
$total_convenience_fee_ti = 0;
|
||||
foreach ($orderProducts as $type_key => $type_value) {
|
||||
if (in_array($type_value['product_id'], $processedProducts)) {
|
||||
continue;
|
||||
}
|
||||
if ($type_value['is_booking_product']) {
|
||||
$processedProducts[] = $type_value['product_id'];
|
||||
$order->id_order_state = (int)$order->getCurrentState();
|
||||
$order->invoice = (OrderState::invoiceAvailable((int)$order->id_order_state) && $order->invoice_number);
|
||||
$order->order_history = $order->getHistory((int)$this->context->language->id, false, true);
|
||||
$order->carrier = new Carrier((int)$order->id_carrier, (int)$order->id_lang);
|
||||
$order->address_invoice = new Address((int)$order->id_address_invoice);
|
||||
$order->address_delivery = new Address((int)$order->id_address_delivery);
|
||||
$order->inv_adr_fields = AddressFormat::getOrderedAddressFields($order->address_invoice->id_country);
|
||||
$order->dlv_adr_fields = AddressFormat::getOrderedAddressFields($order->address_delivery->id_country);
|
||||
$order->invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($order->address_invoice, $order->inv_adr_fields);
|
||||
$order->deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($order->address_delivery, $order->dlv_adr_fields);
|
||||
$order->currency = new Currency($order->id_currency);
|
||||
$order->discounts = $order->getCartRules();
|
||||
$order->invoiceState = (Validate::isLoadedObject($order->address_invoice) && $order->address_invoice->id_state) ? new State((int)$order->address_invoice->id_state) : false;
|
||||
$order->deliveryState = (Validate::isLoadedObject($order->address_delivery) && $order->address_delivery->id_state) ? new State((int)$order->address_delivery->id_state) : false;
|
||||
$order->products = $order->getProducts();
|
||||
$order->customizedDatas = Product::getAllCustomizedDatas((int)$order->id_cart);
|
||||
Product::addCustomizationPrice($order->products, $order->customizedDatas);
|
||||
$order->total_old = $order->total_discounts > 0 ? (float)$order->total_paid - (float)$order->total_discounts : false;
|
||||
|
||||
$product = new Product($type_value['product_id'], false, $this->context->language->id);
|
||||
$cover_image_arr = $product->getCover($type_value['product_id']);
|
||||
if ($order->carrier->url && $order->shipping_number) {
|
||||
$order->followup = str_replace('@', $order->shipping_number, $order->carrier->url);
|
||||
}
|
||||
$order->hook_orderdetaildisplayed = Hook::exec('displayOrderDetail', array('order' => $order));
|
||||
|
||||
if (!empty($cover_image_arr)) {
|
||||
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default');
|
||||
} else {
|
||||
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default');
|
||||
// enter the details of the booking the order
|
||||
if ($hotelresInstalled) {
|
||||
if ($orderProducts = $order->getProducts()) {
|
||||
$total_demands_price_te = 0;
|
||||
$total_demands_price_ti = 0;
|
||||
$total_convenience_fee_te = 0;
|
||||
$total_convenience_fee_ti = 0;
|
||||
foreach ($orderProducts as $type_key => $type_value) {
|
||||
if (in_array($type_value['product_id'], $processedProducts)) {
|
||||
continue;
|
||||
}
|
||||
if ($type_value['is_booking_product']) {
|
||||
$processedProducts[] = $type_value['product_id'];
|
||||
|
||||
if (isset($customer->id)) {
|
||||
$obj_cart = new Cart($order->id_cart);
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id);
|
||||
} else {
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']);
|
||||
}
|
||||
$cartHotelData[$type_key]['id_product'] = $type_value['product_id'];
|
||||
$cartHotelData[$type_key]['cover_img'] = $cover_img;
|
||||
$product = new Product($type_value['product_id'], false, $this->context->language->id);
|
||||
$cover_image_arr = $product->getCover($type_value['product_id']);
|
||||
|
||||
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
foreach ($order_bk_data as $data_k => $data_v) {
|
||||
$date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']);
|
||||
|
||||
$cartHotelData[$type_key]['adults'] = $data_v['adults'];
|
||||
$cartHotelData[$type_key]['children'] = $data_v['children'];
|
||||
/*Product price when order was created*/
|
||||
$order_details_obj = new OrderDetail($data_v['id_order_detail']);
|
||||
$cartHotelData[$type_key]['name'] = $order_details_obj->product_name;
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity;
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity;
|
||||
|
||||
if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
|
||||
|
||||
$num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'];
|
||||
$var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['children'] += $data_v['children'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$anyBackOrder = 1;
|
||||
}
|
||||
if ($data_v['is_refunded']) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] += 1;
|
||||
}
|
||||
if ($data_v['is_cancelled']) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] += 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] -= 1;
|
||||
}
|
||||
if (!empty($cover_image_arr)) {
|
||||
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default');
|
||||
} else {
|
||||
$num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['children'] = $data_v['children'];
|
||||
$cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default');
|
||||
}
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$anyBackOrder = 1;
|
||||
if (isset($customer->id)) {
|
||||
$obj_cart = new Cart($order->id_cart);
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $obj_cart->id_guest, $type_value['product_id'], $customer->id);
|
||||
} else {
|
||||
$order_bk_data = $objBookingDetail->getOnlyOrderBookingData($order->id, $customer->id_guest, $type_value['product_id']);
|
||||
}
|
||||
$cartHotelData[$type_key]['id_product'] = $type_value['product_id'];
|
||||
$cartHotelData[$type_key]['cover_img'] = $cover_img;
|
||||
|
||||
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
foreach ($order_bk_data as $data_k => $data_v) {
|
||||
$date_join = strtotime($data_v['date_from']).strtotime($data_v['date_to']);
|
||||
|
||||
$cartHotelData[$type_key]['adults'] = $data_v['adults'];
|
||||
$cartHotelData[$type_key]['children'] = $data_v['children'];
|
||||
/*Product price when order was created*/
|
||||
$order_details_obj = new OrderDetail($data_v['id_order_detail']);
|
||||
$cartHotelData[$type_key]['name'] = $order_details_obj->product_name;
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_excl'] = ($order_details_obj->total_price_tax_excl)/$order_details_obj->product_quantity;
|
||||
$cartHotelData[$type_key]['paid_unit_price_tax_incl'] = ($order_details_obj->total_price_tax_incl)/$order_details_obj->product_quantity;
|
||||
|
||||
if (isset($cartHotelData[$type_key]['date_diff'][$date_join])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
|
||||
|
||||
$num_days = $cartHotelData[$type_key]['date_diff'][$date_join]['num_days'];
|
||||
$var_quant = (int) $cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['adults'] += $data_v['adults'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['children'] += $data_v['children'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] += $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] += $data_v['total_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] += $data_v['total_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$anyBackOrder = 1;
|
||||
}
|
||||
if ($data_v['is_refunded']) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] += 1;
|
||||
}
|
||||
if ($data_v['is_cancelled']) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] += 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] -= 1;
|
||||
}
|
||||
} else {
|
||||
$num_days = $objBookingDetail->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['adults'] = $data_v['adults'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['children'] = $data_v['children'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'] = $data_v['total_price_tax_excl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'] = $data_v['total_price_tax_incl']/$num_days;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_excl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['avg_paid_unit_price_tax_incl'] = $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_incl'] = $data_v['total_price_tax_incl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['amount_tax_excl'] = $data_v['total_price_tax_excl'];
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_backorder'] = $data_v['is_back_order'];
|
||||
if ($data_v['is_back_order']) {
|
||||
$anyBackOrder = 1;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] = 0;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] = 0;
|
||||
if ($data_v['is_refunded']) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] += 1;
|
||||
}
|
||||
if ($data_v['is_cancelled']) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] += 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] -= 1;
|
||||
}
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] = 0;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] = 0;
|
||||
if ($data_v['is_refunded']) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] += 1;
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_refunded'] = $data_v['is_refunded'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['ids_htl_booking_detail'][] = $data_v['id'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to']
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = 0;
|
||||
}
|
||||
if ($data_v['is_cancelled']) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_cancelled'] += 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['count_refunded'] -= 1;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] += $extraDemandPriceTI = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
$data_v['id_room'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
1
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] += $extraDemandPriceTE = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
$data_v['id_room'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
0
|
||||
);
|
||||
$total_demands_price_ti += $extraDemandPriceTI;
|
||||
$total_demands_price_te += $extraDemandPriceTE;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl;
|
||||
|
||||
$feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff;
|
||||
|
||||
$cartHotelData[$type_key]['hotel_name'] = $data_v['hotel_name'];
|
||||
// add additional services products in hotel detail.
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to']
|
||||
);
|
||||
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $additionalServicesPriceTI = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
1
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $additionalServicesPriceTE = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
0
|
||||
);
|
||||
// get auto added price to be displayed with room price
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
}
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['is_refunded'] = $data_v['is_refunded'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['ids_htl_booking_detail'][] = $data_v['id'];
|
||||
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands'] = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to']
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_ti'] += $extraDemandPriceTI = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
$data_v['id_room'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
1
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['extra_demands_price_te'] += $extraDemandPriceTE = $objBookingDemand->getRoomTypeBookingExtraDemands(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
$data_v['id_room'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
0,
|
||||
1,
|
||||
0
|
||||
);
|
||||
$total_demands_price_ti += $extraDemandPriceTI;
|
||||
$total_demands_price_te += $extraDemandPriceTE;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_excl'] = $order_details_obj->unit_price_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_tax_incl'] = $order_details_obj->unit_price_tax_incl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_excl'] = $order_details_obj->unit_price_tax_excl + $order_details_obj->reduction_amount_tax_excl;
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] = $order_details_obj->unit_price_tax_incl + $order_details_obj->reduction_amount_tax_incl;
|
||||
|
||||
$feature_price_diff = (float)($cartHotelData[$type_key]['date_diff'][$date_join]['product_price_without_reduction_tax_incl'] - $cartHotelData[$type_key]['date_diff'][$date_join]['paid_unit_price_tax_incl']);
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['feature_price_diff'] = $feature_price_diff;
|
||||
|
||||
$cartHotelData[$type_key]['hotel_name'] = $data_v['hotel_name'];
|
||||
// add additional services products in hotel detail.
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services'] = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to']
|
||||
);
|
||||
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_ti'] += $additionalServicesPriceTI = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
1
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_te'] += $additionalServicesPriceTE = $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
0
|
||||
);
|
||||
// get auto added price to be displayed with room price
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0;
|
||||
@@ -458,121 +491,85 @@ class GuestTrackingControllerCore extends FrontController
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
}
|
||||
// get auto added price to be displayed with room price
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_ti'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
if (empty($cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'])) {
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] = 0;
|
||||
}
|
||||
$cartHotelData[$type_key]['date_diff'][$date_join]['additional_services_price_auto_add_te'] += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
0,
|
||||
0,
|
||||
$type_value['product_id'],
|
||||
$data_v['date_from'],
|
||||
$data_v['date_to'],
|
||||
$data_v['id_room'],
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
Product::PRICE_ADDITION_TYPE_WITH_ROOM
|
||||
);
|
||||
// calculate averages now
|
||||
foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) {
|
||||
$value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6);
|
||||
$value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6);
|
||||
// calculate averages now
|
||||
foreach ($cartHotelData[$type_key]['date_diff'] as $key => &$value) {
|
||||
$value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6);
|
||||
$value['avg_paid_unit_price_tax_incl'] = Tools::ps_round($value['avg_paid_unit_price_tax_incl'] / $value['num_rm'], 6);
|
||||
|
||||
$value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6));
|
||||
$value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6));
|
||||
}
|
||||
} else if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITH_ROOMTYPE) {
|
||||
if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) {
|
||||
$total_convenience_fee_ti += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
);
|
||||
$total_convenience_fee_te += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// get all products that are independent.
|
||||
if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE) {
|
||||
$product = new Product($type_value['product_id'], false, $this->context->language->id);
|
||||
$cover_image_arr = $product->getCover($type_value['product_id']);
|
||||
|
||||
if (!empty($cover_image_arr)) {
|
||||
$type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default');
|
||||
} else {
|
||||
$type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default');
|
||||
$value['avg_price_diff_tax_excl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_excl'] - $value['product_price_tax_excl'], 6));
|
||||
$value['avg_price_diff_tax_incl'] = abs(Tools::ps_round($value['avg_paid_unit_price_tax_incl'] - $value['product_price_tax_incl'], 6));
|
||||
}
|
||||
} else if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITH_ROOMTYPE) {
|
||||
if ($type_value['product_auto_add'] && $type_value['product_price_addition_type'] == Product::PRICE_ADDITION_TYPE_INDEPENDENT) {
|
||||
$total_convenience_fee_ti += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
);
|
||||
$total_convenience_fee_te += $objRoomTypeServiceProductOrderDetail->getroomTypeServiceProducts(
|
||||
$idOrder,
|
||||
$type_value['product_id'],
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// get all products that are independent.
|
||||
if ($type_value['product_service_type'] == Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE) {
|
||||
$product = new Product($type_value['product_id'], false, $this->context->language->id);
|
||||
$cover_image_arr = $product->getCover($type_value['product_id']);
|
||||
|
||||
if (!empty($cover_image_arr)) {
|
||||
$type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'small_default');
|
||||
} else {
|
||||
$type_value['cover_img'] = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'small_default');
|
||||
}
|
||||
$cartServiceProducts[] = $type_value;
|
||||
}
|
||||
$cartServiceProducts[] = $type_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// end booking details entries
|
||||
$redirectTermsLink = $this->context->link->getCMSLink(
|
||||
new CMS(3, $this->context->language->id),
|
||||
null, $this->context->language->id
|
||||
);
|
||||
|
||||
$customerGuestDetail = false;
|
||||
if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) {
|
||||
$customerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail);
|
||||
}
|
||||
|
||||
// set order specific values
|
||||
$order->total_convenience_fee_ti = $total_convenience_fee_ti;
|
||||
$order->total_convenience_fee_te = $total_convenience_fee_te;
|
||||
$order->total_demands_price_ti = $total_demands_price_ti;
|
||||
$order->total_demands_price_te = $total_demands_price_te;
|
||||
$order->any_back_order = $anyBackOrder;
|
||||
$order->shw_bo_msg = Configuration::get('WK_SHOW_MSG_ON_BO');
|
||||
$order->back_ord_msg = Configuration::get('WK_BO_MESSAGE');
|
||||
$order->order_has_invoice = $order->hasInvoice();
|
||||
$order->cart_htl_data = $cartHotelData;
|
||||
$order->non_requested_rooms = $nonRequestedRooms;
|
||||
$order->customerGuestDetail = $customerGuestDetail;
|
||||
//end
|
||||
|
||||
Hook::exec('actionOrderDetail', array('carrier' => $order->carrier, 'order' => $order));
|
||||
}
|
||||
// end booking details entries
|
||||
$redirectTermsLink = $this->context->link->getCMSLink(
|
||||
new CMS(3, $this->context->language->id),
|
||||
null, $this->context->language->id
|
||||
);
|
||||
|
||||
$customerGuestDetail = false;
|
||||
if ($id_customer_guest_detail = OrderCustomerGuestDetail::isCustomerGuestBooking($order->id)) {
|
||||
$customerGuestDetail = new OrderCustomerGuestDetail($id_customer_guest_detail);
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'total_convenience_fee_ti' => $total_convenience_fee_ti,
|
||||
'total_convenience_fee_te' => $total_convenience_fee_te,
|
||||
'total_demands_price_ti' => $total_demands_price_ti,
|
||||
'total_demands_price_te' => $total_demands_price_te,
|
||||
'any_back_order' => $anyBackOrder,
|
||||
'shw_bo_msg' => Configuration::get('WK_SHOW_MSG_ON_BO'),
|
||||
'back_ord_msg' => Configuration::get('WK_BO_MESSAGE'),
|
||||
'order_has_invoice' => $order->hasInvoice(),
|
||||
'cart_htl_data' => $cartHotelData,
|
||||
'non_requested_rooms' => $nonRequestedRooms,
|
||||
'customerGuestDetail' => $customerGuestDetail,
|
||||
)
|
||||
);
|
||||
//end
|
||||
|
||||
Hook::exec('actionOrderDetail', array('carrier' => $order->carrier, 'order' => $order));
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
|
||||
@@ -53,6 +53,8 @@ class HistoryControllerCore extends FrontController
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
$this->show_breadcrump = true;
|
||||
|
||||
parent::initContent();
|
||||
if ($orders = Order::getCustomerOrders($this->context->customer->id)) {
|
||||
foreach ($orders as &$order) {
|
||||
|
||||
@@ -53,12 +53,14 @@ class IdentityControllerCore extends FrontController
|
||||
|
||||
$email = trim(Tools::getValue('email'));
|
||||
|
||||
if (Tools::getValue('months') != '' && Tools::getValue('days') != '' && Tools::getValue('years') != '') {
|
||||
$this->customer->birthday = (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days');
|
||||
} elseif (Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '') {
|
||||
$this->customer->birthday = null;
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth.');
|
||||
if (Configuration::get('PS_CUSTOMER_BIRTHDATE')) {
|
||||
if (Tools::getValue('months') != '' && Tools::getValue('days') != '' && Tools::getValue('years') != '') {
|
||||
$this->customer->birthday = (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days');
|
||||
} elseif (Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '') {
|
||||
$this->customer->birthday = null;
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('Invalid date of birth.');
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::getIsset('old_passwd')) {
|
||||
@@ -126,6 +128,8 @@ class IdentityControllerCore extends FrontController
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
$this->show_breadcrump = true;
|
||||
|
||||
parent::initContent();
|
||||
|
||||
if ($this->customer->birthday) {
|
||||
@@ -152,6 +156,7 @@ class IdentityControllerCore extends FrontController
|
||||
));
|
||||
|
||||
$newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active);
|
||||
$this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE'));
|
||||
$this->context->smarty->assign('newsletter', $newsletter);
|
||||
$this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN'));
|
||||
|
||||
|
||||
@@ -67,9 +67,16 @@ class OrderConfirmationControllerCore extends FrontController
|
||||
if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) {
|
||||
Tools::redirect($redirectLink);
|
||||
}
|
||||
$module = Module::getInstanceById((int)($this->id_module));
|
||||
if ($order->module != $module->name) {
|
||||
Tools::redirect($redirectLink);
|
||||
|
||||
if ($this->id_module == -1) {
|
||||
if ($order->module != 'free_order') {
|
||||
Tools::redirect($redirectLink);
|
||||
}
|
||||
} else {
|
||||
$module = Module::getInstanceById((int)($this->id_module));
|
||||
if ($order->module != $module->name) {
|
||||
Tools::redirect($redirectLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +110,6 @@ class OrderConfirmationControllerCore extends FrontController
|
||||
/*By webkul to show order details properly on order history page*/
|
||||
if (Module::isInstalled('hotelreservationsystem')) {
|
||||
require_once _PS_MODULE_DIR_.'hotelreservationsystem/define.php';
|
||||
$non_requested_rooms = 0;
|
||||
$any_back_order = 0;
|
||||
$processed_product = array();
|
||||
$orderTotalInfo = array();
|
||||
@@ -179,12 +185,6 @@ class OrderConfirmationControllerCore extends FrontController
|
||||
/*Product price when order was created*/
|
||||
$order_details_obj = new OrderDetail($data_v['id_order_detail']);
|
||||
$cart_htl_data[$type_key]['name'] = $order_details_obj->product_name;
|
||||
// $ord_refnd_info = $obj_ord_ref_info->getOderRefundInfoByIdOrderIdProductByDate($this->id_order, $type_value['product_id'], $data_v['date_from'], $data_v['date_to']);
|
||||
// if ($ord_refnd_info) {
|
||||
// $stage_name = $obj_refund_stages->getNameById($ord_refnd_info['refund_stage_id']);
|
||||
// } else {
|
||||
// $non_requested_rooms = 1;
|
||||
// }
|
||||
$stage_name = '';
|
||||
if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) {
|
||||
$cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
|
||||
@@ -396,7 +396,6 @@ class OrderConfirmationControllerCore extends FrontController
|
||||
}
|
||||
|
||||
$this->context->smarty->assign('orderTotalInfo', $orderTotalInfo);
|
||||
$this->context->smarty->assign('non_requested_rooms', $non_requested_rooms);
|
||||
$this->context->smarty->assign('orders_has_invoice', $orders_has_invoice);
|
||||
}
|
||||
|
||||
@@ -405,10 +404,12 @@ class OrderConfirmationControllerCore extends FrontController
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'refund_allowed' => (int) $order->isReturnable(),
|
||||
'is_free_order' => $this->id_module == -1 && $order->module == 'free_order',
|
||||
'any_back_order' => $any_back_order,
|
||||
'shw_bo_msg' => $shw_bo_msg,
|
||||
'back_ord_msg' => $bo_msg,
|
||||
'order' => $order,
|
||||
'objOrderCurrency' => (new Currency($order->id_currency)),
|
||||
'use_tax' => Configuration::get('PS_TAX'),
|
||||
'group_use_tax' => (Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC),
|
||||
)
|
||||
|
||||
@@ -214,6 +214,11 @@ class OrderDetailControllerCore extends FrontController
|
||||
'additionalServices' => $additionalServices,
|
||||
));
|
||||
}
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'objOrder' => new Order($idOrder)
|
||||
)
|
||||
);
|
||||
$response['extra_demands'] = $this->context->smarty->fetch(_PS_THEME_DIR_.'_partials/order_booking_demands.tpl');
|
||||
}
|
||||
|
||||
@@ -244,41 +249,70 @@ class OrderDetailControllerCore extends FrontController
|
||||
}
|
||||
$res = true;
|
||||
if (!$hasError) {
|
||||
if ((int)$order->total_paid_real == 0){
|
||||
$hasCancelled = 0;
|
||||
// if amount paid is > 0 then create refund request else cancel the booking directly
|
||||
if ($order->getTotalPaid() > 0) {
|
||||
$objOrderReturn = new OrderReturn();
|
||||
$objOrderReturn->id_customer = $order->id_customer;
|
||||
$objOrderReturn->id_order = $order->id;
|
||||
$objOrderReturn->state = 0;
|
||||
$objOrderReturn->by_admin = 0;
|
||||
$objOrderReturn->question = $refundReason;
|
||||
$objOrderReturn->save();
|
||||
if ($objOrderReturn->id) {
|
||||
foreach ($bookingRefunds as $idHtlBooking) {
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
$numDays = $objHtlBooking->getNumberOfDays(
|
||||
$objHtlBooking->date_from,
|
||||
$objHtlBooking->date_to
|
||||
);
|
||||
|
||||
$objOrderReturnDetail = new OrderReturnDetail();
|
||||
$objOrderReturnDetail->id_order_return = $objOrderReturn->id;
|
||||
$objOrderReturnDetail->id_order_detail = $objHtlBooking->id_order_detail;
|
||||
$objOrderReturnDetail->product_quantity = $numDays;
|
||||
$objOrderReturnDetail->id_htl_booking = $idHtlBooking;
|
||||
$objOrderReturnDetail->save();
|
||||
}
|
||||
}
|
||||
// Emails to customer, admin on refund request state change
|
||||
$objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING'));
|
||||
} else {
|
||||
$hasCancelled = 1;
|
||||
// cancel the booking directly
|
||||
foreach ($bookingRefunds as $idHtlBooking) {
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
$objHtlBooking->save();
|
||||
if (!$objHtlBooking->processRefundInBookingTables()) {
|
||||
die(json_encode(array('status' => 0)));
|
||||
} else {
|
||||
// set the message for the cancellation
|
||||
$message = Tools::displayError('1 Room from').' '.', '.$objHtlBooking->room_type_name.' '.Tools::displayError('has been cancelled by the hotel.');
|
||||
$message .= PHP_EOL.Tools::displayError('Reason').': '.$refundReason;
|
||||
|
||||
$objHtlBooking->setBookingCancellationMessage($refundReason);
|
||||
}
|
||||
}
|
||||
|
||||
// if all bookings are getting cancelled then cancel the order also
|
||||
if ($order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_FLAG)) {
|
||||
$objOrderHistory = new OrderHistory();
|
||||
$objOrderHistory->id_order = (int)$order->id;
|
||||
|
||||
$idOrderState = Configuration::get('PS_OS_CANCELED');
|
||||
|
||||
$useExistingPayment = false;
|
||||
if (!$order->hasInvoice()) {
|
||||
$useExistingPayment = true;
|
||||
}
|
||||
|
||||
$objOrderHistory->changeIdOrderState($idOrderState, $order, $useExistingPayment);
|
||||
$objOrderHistory->addWithemail();
|
||||
}
|
||||
}
|
||||
|
||||
$objOrderReturn = new OrderReturn();
|
||||
$objOrderReturn->id_customer = $order->id_customer;
|
||||
$objOrderReturn->id_order = $order->id;
|
||||
$objOrderReturn->state = 0;
|
||||
$objOrderReturn->by_admin = 0;
|
||||
$objOrderReturn->question = $refundReason;
|
||||
$objOrderReturn->save();
|
||||
if ($objOrderReturn->id) {
|
||||
foreach ($bookingRefunds as $idHtlBooking) {
|
||||
$objHtlBooking = new HotelBookingDetail($idHtlBooking);
|
||||
$numDays = $objHtlBooking->getNumberOfDays(
|
||||
$objHtlBooking->date_from,
|
||||
$objHtlBooking->date_to
|
||||
);
|
||||
|
||||
$objOrderReturnDetail = new OrderReturnDetail();
|
||||
$objOrderReturnDetail->id_order_return = $objOrderReturn->id;
|
||||
$objOrderReturnDetail->id_order_detail = $objHtlBooking->id_order_detail;
|
||||
$objOrderReturnDetail->product_quantity = $numDays;
|
||||
$objOrderReturnDetail->id_htl_booking = $idHtlBooking;
|
||||
$objOrderReturnDetail->save();
|
||||
}
|
||||
}
|
||||
// Emails to customer, admin on refund request state change
|
||||
$objOrderReturn->changeIdOrderReturnState(Configuration::get('PS_ORS_PENDING'));
|
||||
|
||||
die(json_encode(array('status' => 1)));
|
||||
die(json_encode(array('status' => 1, 'has_cancelled' => $hasCancelled)));
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => 0)));
|
||||
}
|
||||
} else {
|
||||
@@ -322,7 +356,6 @@ class OrderDetailControllerCore extends FrontController
|
||||
$objRoomType = new HotelRoomType();
|
||||
$objBookingDemand = new HotelBookingDemands();
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
$nonRequestedRooms = 1;
|
||||
$anyBackOrder = 0;
|
||||
$processedProducts = array();
|
||||
$cartHotelData = array();
|
||||
@@ -618,7 +651,6 @@ class OrderDetailControllerCore extends FrontController
|
||||
'order_has_invoice' => $order->hasInvoice(),
|
||||
'cart_htl_data' => $cartHotelData,
|
||||
'cart_service_products' => $cartServiceProducts,
|
||||
'non_requested_rooms' => $nonRequestedRooms,
|
||||
)
|
||||
);
|
||||
// }
|
||||
@@ -635,7 +667,7 @@ class OrderDetailControllerCore extends FrontController
|
||||
'refund_allowed' => (int) $order->isReturnable(),
|
||||
'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id),
|
||||
'refundReqBookings' => $refundReqBookings,
|
||||
'hasCompletelyRefunded' => $order->hasCompletelyRefunded(),
|
||||
'completeRefundRequestOrCancel' => $order->hasCompletelyRefunded(Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG),
|
||||
'refundedAmount' => $refundedAmount,
|
||||
'shop_name' => strval(Configuration::get('PS_SHOP_NAME')),
|
||||
'order' => $order,
|
||||
@@ -693,4 +725,4 @@ class OrderDetailControllerCore extends FrontController
|
||||
$this->addCSS(_THEME_CSS_DIR_.'addresses.css');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,9 @@ class OrderFollowControllerCore extends FrontController
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
$this->show_breadcrump = true;
|
||||
|
||||
parent::initContent();
|
||||
if (isset($this->context->customer->id) && $this->context->customer->id) {
|
||||
$ordersReturns = OrderReturn::getOrdersReturn($this->context->customer->id, Tools::getValue('id_order'));
|
||||
$this->context->smarty->assign('ordersReturns', $ordersReturns);
|
||||
|
||||
@@ -121,6 +121,31 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
$this->context->customer->newsletter = (int)Tools::isSubmit('newsletter');
|
||||
$this->context->customer->optin = (int)Tools::isSubmit('optin');
|
||||
$this->context->customer->is_guest = (Tools::isSubmit('is_new_customer') ? !Tools::getValue('is_new_customer', 1) : 0);
|
||||
|
||||
if ($idAddressDelivery = Tools::getValue('opc_id_address_delivery')) {
|
||||
$objAddress = new Address($idAddressDelivery);
|
||||
if (Validate::isLoadedObject($objAddress)) {
|
||||
$phoneMobile = Tools::getValue('phone_mobile');
|
||||
|
||||
if (Configuration::get('PS_ONE_PHONE_AT_LEAST') && !$phoneMobile) {
|
||||
$this->errors[] = Tools::displayError('Mobile phone number is a required field.', false);
|
||||
}
|
||||
|
||||
if (!Validate::isPhoneNumber($phoneMobile)) {
|
||||
$this->errors[] = Tools::displayError('Please enter a valid Mobile phone number.', false);
|
||||
}
|
||||
|
||||
if (!count($this->errors)) {
|
||||
$objAddress->phone_mobile = $phoneMobile;
|
||||
$objAddress->firstname = $this->context->customer->firstname;
|
||||
$objAddress->lastname = $this->context->customer->lastname;
|
||||
if (!$objAddress->save()) {
|
||||
$this->errors[] = Tools::displayError('Something went wrong while saving phone number. Please try again.', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return = array(
|
||||
'hasError' => !empty($this->errors),
|
||||
'errors' => $this->errors,
|
||||
@@ -221,10 +246,19 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
if (($id_order = $this->_checkFreeOrder()) && $id_order) {
|
||||
$order = new Order((int)$id_order);
|
||||
$email = $this->context->customer->email;
|
||||
$orderConfirmationUrl = $this->context->link->getPageLink('order-confirmation').'?id_cart='.$order->id_cart.'&id_module=-1'.'&id_order='.$id_order.'&key='.$order->secure_key;
|
||||
if ($this->context->customer->is_guest) {
|
||||
$this->context->customer->logout();
|
||||
} // If guest we clear the cookie for security reason
|
||||
$this->ajaxDie('freeorder:'.$order->reference.':'.$email);
|
||||
|
||||
$return = array(
|
||||
'success' => true,
|
||||
'reference' => $order->reference,
|
||||
'email' => $email,
|
||||
'order_confirmation_url' => $orderConfirmationUrl,
|
||||
);
|
||||
|
||||
$this->ajaxDie(json_encode($return));
|
||||
}
|
||||
exit;
|
||||
break;
|
||||
@@ -389,14 +423,11 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
// check all service products are available
|
||||
RoomTypeServiceProductCartDetail::validateServiceProductsInCart();
|
||||
// validate room types before payment by customer
|
||||
$orderRestrictErr = HotelCartBookingData::validateCartBookings();
|
||||
|
||||
parent::initContent();
|
||||
|
||||
// check ORDER RESTRICT condition before payment by the customer
|
||||
$orderRestrictErr = HotelOrderRestrictDate::validateOrderRestrictDateOnPayment($this);
|
||||
|
||||
/* id_carrier is not defined in database before choosing a carrier, set it to a default one to match a potential cart _rule */
|
||||
if (empty($this->context->cart->id_carrier)) {
|
||||
$checked = $this->context->cart->simulateCarrierSelectedOutput();
|
||||
@@ -519,7 +550,8 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
}
|
||||
Tools::safePostVars();
|
||||
|
||||
$newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active);
|
||||
$newsletter = Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active && Configuration::get('PS_CUSTOMER_NWSL');
|
||||
$this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE'));
|
||||
$this->context->smarty->assign('newsletter', $newsletter);
|
||||
$this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN'));
|
||||
$this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase());
|
||||
|
||||
@@ -48,6 +48,8 @@ class OrderSlipControllerCore extends FrontController
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
$this->show_breadcrump = true;
|
||||
|
||||
parent::initContent();
|
||||
|
||||
$this->context->smarty->assign('ordersSlip', OrderSlip::getOrdersSlip((int)$this->context->cookie->id_customer));
|
||||
|
||||
@@ -84,9 +84,6 @@ class PasswordControllerCore extends FrontController
|
||||
'{passwd}' => $password
|
||||
);
|
||||
if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'), $mail_params, $customer->email, $customer->firstname.' '.$customer->lastname)) {
|
||||
|
||||
$this->context->updateCustomer($customer);
|
||||
|
||||
$this->context->smarty->assign(array('confirmation' => 1, 'customer_email' => $customer->email));
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while sending the email.');
|
||||
|
||||
@@ -66,11 +66,27 @@ class ProductControllerCore extends FrontController
|
||||
$this->addJqueryPlugin('jqzoom');
|
||||
}
|
||||
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY')) && Configuration::get('WK_GOOGLE_ACTIVE_MAP')) {
|
||||
$this->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places&language='.
|
||||
$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
);
|
||||
if (($PS_API_KEY = Configuration::get('PS_API_KEY'))) {
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($this->product->id);
|
||||
if ($roomTypeInfo) {
|
||||
$objHotelBranchInformation = new HotelBranchInformation($roomTypeInfo['id_hotel']);
|
||||
if (floatval($objHotelBranchInformation->latitude) != 0
|
||||
&& floatval($objHotelBranchInformation->longitude) != 0
|
||||
) {
|
||||
Media::addJsDef(array(
|
||||
'hotel_location' => array(
|
||||
'latitude' => $objHotelBranchInformation->latitude,
|
||||
'longitude' => $objHotelBranchInformation->longitude,
|
||||
)
|
||||
));
|
||||
|
||||
$this->addJS(
|
||||
'https://maps.googleapis.com/maps/api/js?key='.$PS_API_KEY.'&libraries=places&language='.
|
||||
$this->context->language->iso_code.'®ion='.$this->context->country->iso_code
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +128,7 @@ class ProductControllerCore extends FrontController
|
||||
$this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id);
|
||||
}
|
||||
|
||||
if (!$this->product->booking_product) {
|
||||
if (!$this->product->booking_product || ($this->product->booking_product && !$this->product->show_at_front)) {
|
||||
Tools::redirect($this->context->link->getPageLink('pagenotfound'));
|
||||
}
|
||||
|
||||
@@ -327,10 +343,16 @@ class ProductControllerCore extends FrontController
|
||||
|
||||
if (!($date_from = Tools::getValue('date_from'))) {
|
||||
$date_from = date('Y-m-d');
|
||||
$date_to = date('Y-m-d', strtotime('+1 day', strtotime($date_from)));
|
||||
// set date to according to los
|
||||
$objHotelRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange();
|
||||
$los = $objHotelRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($this->product->id, $date_from);
|
||||
$date_to = date('Y-m-d', strtotime('+'.$los['min_los'].' day', strtotime($date_from)));
|
||||
}
|
||||
if (!($date_to = Tools::getValue('date_to'))) {
|
||||
$date_to = date('Y-m-d', strtotime('+1 day', strtotime($date_from)));
|
||||
// set date to according to los
|
||||
$objHotelRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange();
|
||||
$los = $objHotelRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($this->product->id, $date_from);
|
||||
$date_to = date('Y-m-d', strtotime('+'.$los['min_los'].' day', strtotime($date_from)));
|
||||
}
|
||||
|
||||
$hotel_branch_obj = new HotelBranchInformation($hotel_id);
|
||||
@@ -369,13 +391,6 @@ class ProductControllerCore extends FrontController
|
||||
}
|
||||
}
|
||||
|
||||
Media::addJsDef(array(
|
||||
'hotel_loc' => array(
|
||||
'latitude' => $hotel_branch_obj->latitude,
|
||||
'longitude' => $hotel_branch_obj->longitude,
|
||||
)
|
||||
));
|
||||
|
||||
$this->context->smarty->assign(
|
||||
array(
|
||||
'id_hotel' => $hotel_id,
|
||||
|
||||
Reference in New Issue
Block a user