Merge branch 'develop' into gli-1768

This commit is contained in:
Sumit Panwar
2024-07-23 11:29:55 +05:30
93 changed files with 1211 additions and 428 deletions

View File

@@ -1,2 +1,10 @@
Order deny,allow
Deny from all
# Apache 2.2
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>

31
classes/BoOrder.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
/**
* 2010-2022 Webkul.
*
* NOTICE OF LICENSE
*
* All right is reserved,
* Please go through this link for complete license : https://store.webkul.com/license.html
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please refer to https://store.webkul.com/customisation-guidelines/ for more information.
*
* @author Webkul IN <support@webkul.com>
* @copyright 2010-2022 Webkul IN
* @license https://store.webkul.com/license.html
*/
class BoOrder extends PaymentModule
{
public $active = 1;
public $name = 'bo_order';
public function __construct()
{
$this->displayName = $this->l('Back office order');
$this->validateOrderAmount = false;
}
}

View File

@@ -294,21 +294,37 @@ class CustomerCore extends ObjectModel
}
/**
* Return customers list
* Returns a list of customers.
*
* @param null|bool $only_active Returns only active customers when true
* @return array Customers
* @param null|bool $active Optional. Filter customers by their active status. If null, no filter is applied.
* @param null|bool $deleted Optional. Filter customers by their deleted status. If null, no filter is applied.
* @param null|bool $havingAddress Optional. Filter customers having|not having address. If true, only customers having an address are returned.
* If false, only customers without an address are returned. If null, no filter is applied.
* @return array List of customers matching the specified criteria.
*/
public static function getCustomers($only_active = null)
public static function getCustomers($active = null, $deleted = null, $havingAddress = null)
{
$sql = 'SELECT `id_customer`, `email`, `firstname`, `lastname`
FROM `'._DB_PREFIX_.'customer`
WHERE 1 '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).
($only_active ? ' AND `active` = 1' : '').'
ORDER BY `id_customer` ASC';
$sqlSelect = 'SELECT c.`id_customer`, c.`email`, c.`firstname`, c.`lastname`';
$sqlFrom = 'FROM `'._DB_PREFIX_.'customer` c';
$sqlJoin = '';
$sqlWhere = 'WHERE 1 '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).
(!is_null($active) ? ' AND c.`active` = '.(int) $active: ' ' ).
(!is_null($deleted) ? ' AND c.`deleted` = '.(int) $deleted : ' ');
$sqlOrderBy = 'ORDER BY c.`id_customer` ASC';
$sqlGroupBy = 'GROUP BY c.`id_customer`';
if (!is_null($havingAddress)) {
$sqlJoin .= ' LEFT JOIN `'._DB_PREFIX_.'address` a
ON a.`id_customer` = c.`id_customer` AND a.`deleted`=0';
$sqlWhere .= (($havingAddress) ? ' AND a.`id_address` IS NOT NULL': ' AND a.`id_address` IS NULL');
}
$sql = $sqlSelect .' '. $sqlFrom.' '.$sqlJoin.' '.$sqlWhere.' '.$sqlGroupBy.' '.$sqlOrderBy;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
}
/**
* Return customer instance from its e-mail (optionnaly check password)
*
@@ -951,4 +967,5 @@ class CustomerCore extends ObjectModel
$sql_filter .= Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'main');
return parent::getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit);
}
}

View File

@@ -33,6 +33,7 @@ abstract class PaymentModuleCore extends Module
public $currencies = true;
public $currencies_mode = 'checkbox';
public $payment_type = OrderPayment::PAYMENT_TYPE_REMOTE_PAYMENT;
public $validateOrderAmount = true;
public function install()
{
@@ -162,7 +163,7 @@ abstract class PaymentModuleCore extends Module
*/
public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown',
$message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false,
$secure_key = false, Shop $shop = null)
$secure_key = false, Shop $shop = null, $send_mails = true)
{
if (self::DEBUG_MODE) {
PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int)$id_cart, true);
@@ -418,8 +419,7 @@ abstract class PaymentModuleCore extends Module
// If webservice order request then no need to impose equal amounts(total cart and sent amount) condition
if ($order_status->logable
&& number_format($cart_total_paid, _PS_PRICE_COMPUTE_PRECISION_) != number_format($amount_paid, _PS_PRICE_COMPUTE_PRECISION_)
&& $this->name != 'wsorder'
&& $this->name != 'bo_order'
&& ($this->validateOrderAmount)
) {
// if customer is paying full payment amount
$id_order_state = Configuration::get('PS_OS_ERROR');
@@ -684,24 +684,25 @@ abstract class PaymentModuleCore extends Module
if ($voucher->add()) {
// If the voucher has conditions, they are now copied to the new voucher
CartRule::copyConditions($cart_rule['obj']->id, $voucher->id);
$params = array(
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
'{voucher_num}' => $voucher->code,
'{firstname}' => $this->context->customer->firstname,
'{lastname}' => $this->context->customer->lastname,
'{id_order}' => $order->reference,
'{order_name}' => $order->getUniqReference()
);
Mail::Send(
(int)$order->id_lang,
'voucher',
sprintf(Mail::l('New voucher for your order %s', (int)$order->id_lang), $order->reference),
$params,
$this->context->customer->email,
$this->context->customer->firstname.' '.$this->context->customer->lastname,
null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop
);
if ($send_mails) {
$params = array(
'{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
'{voucher_num}' => $voucher->code,
'{firstname}' => $this->context->customer->firstname,
'{lastname}' => $this->context->customer->lastname,
'{id_order}' => $order->reference,
'{order_name}' => $order->getUniqReference()
);
Mail::Send(
(int)$order->id_lang,
'voucher',
sprintf(Mail::l('New voucher for your order %s', (int)$order->id_lang), $order->reference),
$params,
$this->context->customer->email,
$this->context->customer->firstname.' '.$this->context->customer->lastname,
null, null, null, null, _PS_MAIL_DIR_, false, (int)$order->id_shop
);
}
}
}
@@ -1050,10 +1051,12 @@ abstract class PaymentModuleCore extends Module
// Set the order status
$new_history = new OrderHistory();
$new_history->id_order = (int)$order->id;
$new_history->changeIdOrderState((int)$id_order_state, $order, true);
$new_history->addWithemail(true, $extra_vars);
if ($send_mails) {
$new_history->addWithemail(true, $extra_vars);
} else {
$new_history->add(true);
}
// Switch to back order if needed
$objHotelBookingDetail = new HotelBookingDetail();
@@ -1089,7 +1092,11 @@ abstract class PaymentModuleCore extends Module
$history = new OrderHistory();
$history->id_order = (int)$order->id;
$history->changeIdOrderState($id_order_state, $order, true);
$history->addWithemail();
if ($send_mails) {
$history->addWithemail();
} else {
$history->add();
}
}
unset($order_detail);
@@ -1098,7 +1105,11 @@ abstract class PaymentModuleCore extends Module
$order = new Order((int)$order->id);
// Send an e-mail to customer (one order = one email)
if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) {
if ($id_order_state != Configuration::get('PS_OS_ERROR')
&& $id_order_state != Configuration::get('PS_OS_CANCELED')
&& $this->context->customer->id
&& $send_mails
) {
$invoice = new Address($order->id_address_invoice);
$delivery = new Address($order->id_address_delivery);
$delivery_state = $delivery->id_state ? new State($delivery->id_state) : false;
@@ -1327,9 +1338,7 @@ abstract class PaymentModuleCore extends Module
}
}
}
if ($idHotel
&& Validate::isLoadedObject($objHotel = new HotelBranchInformation($idHotel))
) {
if ($idHotel && Validate::isLoadedObject($objHotel = new HotelBranchInformation($idHotel))) {
if (Configuration::get('PS_ORDER_CONF_MAIL_TO_HOTEL_MANAGER')){
// If order currenct state is overbooking, the send overbooking email or send order confirmation email
if ($isOverBookingStatus) {

View File

@@ -364,7 +364,7 @@ class ValidateCore
*/
public static function isCityName($city)
{
return preg_match(Tools::cleanNonUnicodeSupport('/^[^!<>;?=+@#"°{}_$%]*$/u'), $city);
return preg_match(Tools::cleanNonUnicodeSupport('/^\p{L}+[^!<>;?=+@#"°{}_$%]*$/u'), $city);
}
/**

View File

@@ -502,7 +502,7 @@ abstract class CacheCore
$this->_deleteMulti($invalidKeys);
if ($keyToKeep) {
$this->sql_tables_cached[$table][$keyToKeep] = $toKeep ?? null;
$this->sql_tables_cached[$table][$keyToKeep] = isset($toKeep) ? $toKeep : null;
}
}
$this->adjustTableCacheSize = false;

View File

@@ -822,7 +822,9 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
*/
protected function getTemplateByCountry($iso_country)
{
$file = Configuration::get('PS_INVOICE_MODEL');
// $file = Configuration::get('PS_INVOICE_MODEL');
// @todo redesign invoice template for b2b, for now we have ony one template design.
$file = 'invoice';
// try to fetch the iso template
$template = $this->getTemplate($file.'.'.$iso_country);

View File

@@ -26,5 +26,6 @@ class WebserviceOrderCore extends PaymentModule
public function __construct()
{
$this->displayName = $this->l('Order from API');
$this->validateOrderAmount = false;
}
}