Merge branch 'develop' into gli-2032

This commit is contained in:
vishalsingh.qlo325
2024-06-28 15:17:44 +05:30
56 changed files with 7687 additions and 7175 deletions

View File

@@ -54,7 +54,16 @@ class AdminMaintenanceControllerCore extends AdminController
'validation' => 'isBool',
'cast' => 'intval',
'type' => 'bool',
'class' => "hello"
'form_group_class' => (Tools::getValue('PS_SHOP_ENABLE', Configuration::get('PS_SHOP_ENABLE'))) ? 'collapse' : '',
),
'PS_ALLOW_EMP_MAX_ATTEMPTS' => array(
'title' => $this->l('Maximum Login Attempts'),
'validation' => 'isUnsignedInt',
'cast' => 'intval',
'type' => 'text',
'class' => 'fixed-width-xl',
'desc' => sprintf($this->l('Set the number of maximum login attempts allowed in %d minutes. Set to 0 to disable this feature.'), MaintenanceAccess::LOGIN_ATTEMPTS_WINDOW),
'form_group_class' => ((Tools::getValue('PS_SHOP_ENABLE', Configuration::get('PS_SHOP_ENABLE'))) || !(Tools::getValue('PS_ALLOW_EMP', Configuration::get('PS_ALLOW_EMP')))) ? ' collapse' : '',
),
'PS_MAINTENANCE_IP' => array(
'title' => $this->l('Maintenance IP'),
@@ -69,9 +78,44 @@ class AdminMaintenanceControllerCore extends AdminController
);
}
public function postProcess()
{
if (Tools::isSubmit('submitOptionsconfiguration')) {
$shopEnable = Tools::getValue('PS_SHOP_ENABLE');
$allowEmp = Tools::getValue('PS_ALLOW_EMP');
$allowEmpMaxAttempts = trim(Tools::getValue('PS_ALLOW_EMP_MAX_ATTEMPTS'));
$maintenanceIp = trim(Tools::getValue('PS_MAINTENANCE_IP'));
// validations
if (!$shopEnable && $allowEmp) {
if ($allowEmpMaxAttempts == '') {
$this->errors[] = $this->l('Maximum Login Attempts is a required field.');
} elseif (!Validate::isUnsignedInt($allowEmpMaxAttempts)) {
$this->errors[] = $this->l('Maximum Login Attempts is invalid. Please enter a value greater than or equal to 0.');
}
}
// update values
if (!count($this->errors)) {
Configuration::updateValue('PS_SHOP_ENABLE', $shopEnable);
Configuration::updateValue('PS_MAINTENANCE_IP', $maintenanceIp);
if (!$shopEnable) {
Configuration::updateValue('PS_ALLOW_EMP', $allowEmp);
if ($allowEmp) {
Configuration::updateValue('PS_ALLOW_EMP_MAX_ATTEMPTS', $allowEmpMaxAttempts);
}
}
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token.'&conf=6');
}
}
}
public function setMedia()
{
parent::setMedia();
$this->addJS(_PS_JS_DIR_.'maintenance.js');
$this->addJS(_PS_JS_DIR_.'/admin/maintenance.js');
}
}

View File

@@ -186,19 +186,17 @@ class AdminNormalProductsControllerCore extends AdminController
$id_shop = Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP? (int)$this->context->shop->id : 'a.id_shop_default';
$this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.$id_shop.')
LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (a.`id_product` = hrt.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info` hb ON (hrt.`id_hotel` = hb.`id`)
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl ON (hb.`id` = hbl.`id` AND b.`id_lang` = hbl.`id_lang`)
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.$id_shop.')
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.$id_shop.')
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_.'htl_room_type_service_product` rsp ON (rsp.`id_product` = a.`id_product`)
LEFT JOIN `'._DB_PREFIX_.'address` aa ON (aa.`id_hotel` = hb.`id`)';
LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (rsp.`id_element` = hrt.`id_product` AND rsp.`element_type` = '.(int)RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.')
'.HotelBranchInformation::addHotelRestriction(false, 'hrt');
$this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, IF(a.`price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_PER_DAY.', "'.$this->l('Per Day').'", "'.$this->l('Per Booking').'") as price_calculation_method_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, ';
$this->_select .= ' COUNT(rsp.`id_product`) as products_associated, hrt.`adults`, hrt.`children`, hb.`id` as id_hotel, aa.`city`, hbl.`hotel_name`, ';
$this->_select .= ' COUNT(hrt.`id_product`) as products_associated, ';
$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`';

View File

@@ -3272,22 +3272,26 @@ class AdminProductsControllerCore extends AdminController
$this->errors[] = Tools::displayError('Invalid base children');
} else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) {
if ($baseChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) {
$this->errors[] = sprintf(Tools::displayError('Base children cannot be greater than max childern allowed on your website (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'));
$this->errors[] = sprintf(Tools::displayError('Base children cannot be greater than max childern allowed in the room of this room type (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'));
}
}
if (!$maxAdults || !Validate::isUnsignedInt($maxAdults)) {
$this->errors[] = Tools::displayError('Invalid maximum number of adults');
} elseif ($maxAdults < $baseAdults) {
$this->errors[] = Tools::displayError('Maximum number of adults cannot be less than base adults');
} elseif ($maxAdults > $maxGuests) {
$this->errors[] = Tools::displayError('Maximum number of adults cannot be more than maximum number of guests');
}
if ($maxChildren == '' || !Validate::isUnsignedInt($maxChildren)) {
$this->errors[] = Tools::displayError('Invalid maximum number of children');
} else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) {
if ($maxChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) {
$this->errors[] = sprintf(Tools::displayError('Maximum number of children cannot be greater than max childern allowed on your website (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'));
}
} elseif ($maxChildren < $baseChildren) {
$this->errors[] = Tools::displayError('Maximum number of children cannot be less than base children');
} elseif ($maxChildren >= $maxGuests) {
$this->errors[] = Tools::displayError('Maximum number of children cannot be more or equal than maximum number of guests.(1 adult is mandatory in a room)');
} else if (Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) {
if ($maxChildren > Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM')) {
$this->errors[] = sprintf(Tools::displayError('Maximum number of children cannot be greater than max childern allowed in the room of this room type (Max: %s)'), Configuration::get('WK_GLOBAL_MAX_CHILD_IN_ROOM'));
}
}
if (!$maxGuests || !Validate::isUnsignedInt($maxGuests)) {
$this->errors[] = Tools::displayError('Invalid maximum number of guests');

View File

@@ -677,6 +677,8 @@ class AdminThemesControllerCore extends AdminController
if (!count($this->errors)) {
Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminThemes').'&conf=6');
} else {
$this->redirect_after = '';
}
}
@@ -1981,7 +1983,7 @@ class AdminThemesControllerCore extends AdminController
}
}
if ($xml_version_too_old && !$this->_checkConfigForFeatures(array_keys(AdminThemes::$check_features))) {
$this->errors[] .= Tools::displayError('The config.xml file has not been created for this version of PrestaShop.');
$this->errors[] = Tools::displayError('The config.xml file has not been created for this version of QloApps.');
$return = false;
}

View File

@@ -115,99 +115,112 @@ class ContactControllerCore extends FrontController
WHERE cc.id_customer_thread = '.(int)$id_customer_thread.' AND cc.id_shop = '.(int)$this->context->shop->id.'
ORDER BY cm.date_add DESC');
if ($old_message == $message) {
$this->context->smarty->assign('alreadySent', 1);
$this->errors[] = Tools::displayError('Your message has already been sent.');
$_POST = array();
$contact->email = '';
$contact->customer_service = 0;
}
if ($contact->customer_service) {
if ((int)$id_customer_thread) {
$ct = new CustomerThread($id_customer_thread);
$ct->status = 'open';
$ct->id_lang = (int)$this->context->language->id;
$ct->id_contact = (int)$id_contact;
$ct->id_order = (int)$id_order;
if ($id_product = (int)Tools::getValue('id_product')) {
$ct->id_product = $id_product;
} else {
if ($contact->customer_service) {
if ((int)$id_customer_thread) {
$ct = new CustomerThread($id_customer_thread);
$ct->status = 'open';
$ct->id_lang = (int)$this->context->language->id;
$ct->id_contact = (int)$id_contact;
$ct->id_order = (int)$id_order;
if ($id_product = (int)Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->update();
} else {
$ct = new CustomerThread();
if (isset($customer->id)) {
$ct->id_customer = (int)$customer->id;
}
$ct->id_shop = (int)$this->context->shop->id;
$ct->id_order = (int)$id_order;
if ($id_product = (int)Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->id_contact = (int)$id_contact;
$ct->id_lang = (int)$this->context->language->id;
$ct->email = $from;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
}
$ct->update();
} else {
$ct = new CustomerThread();
if (isset($customer->id)) {
$ct->id_customer = (int)$customer->id;
}
$ct->id_shop = (int)$this->context->shop->id;
$ct->id_order = (int)$id_order;
if ($id_product = (int)Tools::getValue('id_product')) {
$ct->id_product = $id_product;
}
$ct->id_contact = (int)$id_contact;
$ct->id_lang = (int)$this->context->language->id;
$ct->email = $from;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
}
if ($ct->id) {
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = $message;
if (isset($file_attachment['rename']) && !empty($file_attachment['rename']) && rename($file_attachment['tmp_name'], _PS_UPLOAD_DIR_.basename($file_attachment['rename']))) {
$cm->file_name = $file_attachment['rename'];
@chmod(_PS_UPLOAD_DIR_.basename($file_attachment['rename']), 0664);
}
$cm->ip_address = (int)ip2long(Tools::getRemoteAddr());
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
if (!$cm->add()) {
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
}
}
if (!count($this->errors)) {
$var_list = array(
'{order_name}' => '-',
'{attached_file}' => '-',
'{message}' => Tools::nl2br(stripslashes($message)),
'{email}' => $from,
'{product_name}' => '',
);
if (isset($file_attachment['name'])) {
$var_list['{attached_file}'] = $file_attachment['name'];
}
$id_product = (int)Tools::getValue('id_product');
if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order) {
$order = new Order((int)$ct->id_order);
$var_list['{order_name}'] = $order->getUniqReference();
$var_list['{id_order}'] = (int)$order->id;
}
if ($id_product) {
$product = new Product((int)$id_product);
if (Validate::isLoadedObject($product) && isset($product->name[Context::getContext()->language->id])) {
$var_list['{product_name}'] = $product->name[Context::getContext()->language->id];
}
}
if (!empty($contact->email)) {
if (!Mail::Send($this->context->language->id, 'contact', Mail::l('Message from contact form').' [no_sync]',
$var_list, $contact->email, $contact->name, null, null,
$file_attachment, null, _PS_MAIL_DIR_, false, null, null, $from)) {
if ($ct->id) {
$cm = new CustomerMessage();
$cm->id_customer_thread = $ct->id;
$cm->message = $message;
if (isset($file_attachment['rename']) && !empty($file_attachment['rename']) && rename($file_attachment['tmp_name'], _PS_UPLOAD_DIR_.basename($file_attachment['rename']))) {
$cm->file_name = $file_attachment['rename'];
@chmod(_PS_UPLOAD_DIR_.basename($file_attachment['rename']), 0664);
}
$cm->ip_address = (int)ip2long(Tools::getRemoteAddr());
$cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
if (!$cm->add()) {
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred while sending the message.');
}
}
}
if (count($this->errors) > 1) {
array_unique($this->errors);
} elseif (!count($this->errors)) {
$this->context->smarty->assign('confirmation', 1);
if (!count($this->errors)) {
$var_list = array(
'{order_name}' => '-',
'{attached_file}' => '-',
'{message}' => Tools::nl2br(stripslashes($message)),
'{email}' => $from,
'{product_name}' => '',
);
if (isset($file_attachment['name'])) {
$var_list['{attached_file}'] = $file_attachment['name'];
}
$id_product = (int)Tools::getValue('id_product');
if (isset($ct) && Validate::isLoadedObject($ct) && $ct->id_order) {
$order = new Order((int)$ct->id_order);
$var_list['{order_name}'] = $order->getUniqReference();
$var_list['{id_order}'] = (int)$order->id;
}
if ($id_product) {
$product = new Product((int)$id_product);
if (Validate::isLoadedObject($product) && isset($product->name[Context::getContext()->language->id])) {
$var_list['{product_name}'] = $product->name[Context::getContext()->language->id];
}
}
if (!empty($contact->email)) {
Mail::Send(
$this->context->language->id,
'contact',
Mail::l('Message from contact form').' [no_sync]',
$var_list,
$contact->email,
$contact->name,
null,
null,
$file_attachment,
null,
_PS_MAIL_DIR_,
false,
null,
null,
$from
);
}
}
if (count($this->errors) > 1) {
array_unique($this->errors);
} elseif (!count($this->errors)) {
Tools::redirect($this->context->link->getPageLink('contact', null, null, array('confirm' => 1)));
}
}
}
}
@@ -312,6 +325,7 @@ class ContactControllerCore extends FrontController
}
}
//End
$this->setTemplate(_PS_THEME_DIR_.'contact-form.tpl');
}

View File

@@ -100,6 +100,7 @@ class OrderDetailControllerCore extends FrontController
$total_demands_price_ti = 0;
$total_convenience_fee_te = 0;
$total_convenience_fee_ti = 0;
$roomTypes = array();
if (!empty($products)) {
foreach ($products as $type_key => $type_value) {
if (in_array($type_value['product_id'], $processedProducts)) {
@@ -374,7 +375,7 @@ class OrderDetailControllerCore extends FrontController
}
}
$roomTypes[$type_value['id_product']] = $type_value;
}
$redirectTermsLink = $this->context->link->getCMSLink(new CMS(3, $this->context->language->id), null, $this->context->language->id);
@@ -437,6 +438,7 @@ class OrderDetailControllerCore extends FrontController
'order_history' => $order->getHistory($this->context->language->id, false, true),
'overbooking_order_states' => OrderState::getOverBookingStates(),
'products' => $products,
'roomTypes' => $roomTypes,
'discounts' => $order->getCartRules(),
'carrier' => $carrier,
'address_invoice' => $addressInvoice,