CS
This commit is contained in:
parent
67b9dd85be
commit
b907ac0e66
@ -562,8 +562,7 @@ class AdminOrders extends AdminTab
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
|
||||
/* Cancel product from order */
|
||||
// Cancel product from order
|
||||
elseif (Tools::isSubmit('cancelProduct') AND Validate::isLoadedObject($order = new Order((int)(Tools::getValue('id_order')))))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
@ -609,6 +608,7 @@ class AdminOrders extends AdminTab
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($customizationList)
|
||||
{
|
||||
$customization_quantities = Customization::retrieveQuantitiesFromIds(array_keys($customizationList));
|
||||
@ -627,6 +627,7 @@ class AdminOrders extends AdminTab
|
||||
}
|
||||
|
||||
if (!sizeof($this->_errors) AND $productList)
|
||||
{
|
||||
foreach ($productList AS $key => $id_order_detail)
|
||||
{
|
||||
$qtyCancelProduct = abs($qtyList[$key]);
|
||||
@ -648,21 +649,20 @@ class AdminOrders extends AdminTab
|
||||
);
|
||||
|
||||
// Reinject product
|
||||
if (
|
||||
!$order->hasBeenDelivered()
|
||||
OR ($order->hasBeenDelivered() AND Tools::isSubmit('reinjectQuantities') AND !$is_philea AND !$is_braderie)
|
||||
){
|
||||
if(
|
||||
(($is_philea || $is_braderie) && !$order->hasBeenShipped() && !$order->hasBeenDelivered())
|
||||
|| (!$is_philea && !$is_braderie)
|
||||
){
|
||||
if (!$order->hasBeenDelivered() || ($order->hasBeenDelivered()
|
||||
&& Tools::isSubmit('reinjectQuantities')
|
||||
&& !$is_philea && !$is_braderie) ) {
|
||||
|
||||
if ( (($is_philea || $is_braderie) && !$order->hasBeenShipped() && !$order->hasBeenDelivered())
|
||||
|| (!$is_philea && !$is_braderie) ){
|
||||
|
||||
$reinjectableQuantity = (int)($orderDetail->product_quantity) - (int)($orderDetail->product_quantity_reinjected);
|
||||
$quantityToReinject = $qtyCancelProduct > $reinjectableQuantity ? $reinjectableQuantity : $qtyCancelProduct;
|
||||
|
||||
if (!Product::reinjectQuantities($orderDetail, $quantityToReinject))
|
||||
if (!Product::reinjectQuantities($orderDetail, $quantityToReinject)) {
|
||||
$this->_errors[] = Tools::displayError('Cannot re-stock product').' <span class="bold">'.$orderDetail->product_name.'</span>';
|
||||
else
|
||||
{
|
||||
}
|
||||
else {
|
||||
$updProductAttributeID = !empty($orderDetail->product_attribute_id) ? (int)($orderDetail->product_attribute_id) : NULL;
|
||||
$newProductQty = Product::getQuantity((int)($orderDetail->product_id), $updProductAttributeID);
|
||||
$product = get_object_vars(new Product((int)($orderDetail->product_id), false, (int)($cookie->id_lang)));
|
||||
@ -682,23 +682,29 @@ class AdminOrders extends AdminTab
|
||||
}
|
||||
|
||||
// Delete product
|
||||
if (!$order->deleteProduct($order, $orderDetail, $qtyCancelProduct))
|
||||
if (!$order->deleteProduct($order, $orderDetail, $qtyCancelProduct)) {
|
||||
$this->_errors[] = Tools::displayError('An error occurred during deletion of the product.').' <span class="bold">'.$orderDetail->product_name.'</span>';
|
||||
}
|
||||
|
||||
Module::hookExec('cancelProduct', array('order' => $order, 'id_order_detail' => $id_order_detail));
|
||||
}
|
||||
|
||||
if (!sizeof($this->_errors) AND $customizationList)
|
||||
foreach ($customizationList AS $id_customization => $id_order_detail)
|
||||
{
|
||||
}
|
||||
|
||||
if (!sizeof($this->_errors) AND $customizationList) {
|
||||
foreach ($customizationList AS $id_customization => $id_order_detail) {
|
||||
$orderDetail = new OrderDetail((int)($id_order_detail));
|
||||
$qtyCancelProduct = abs($customizationQtyList[$id_customization]);
|
||||
if (!$order->deleteCustomization($id_customization, $qtyCancelProduct, $orderDetail))
|
||||
if (!$order->deleteCustomization($id_customization, $qtyCancelProduct, $orderDetail)) {
|
||||
$this->_errors[] = Tools::displayError('An error occurred during deletion of product customization.').' '.$id_customization;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Préparation
|
||||
if (!sizeof($this->_errors) && (isset($_POST['generateCreditSlip'])
|
||||
|| isset($_POST['generateDiscount'])
|
||||
|| isset($_POST['generateDiscount2']))) {
|
||||
|
||||
// E-mail params
|
||||
if ((isset($_POST['generateCreditSlip']) OR isset($_POST['generateDiscount']) OR isset($_POST['generateDiscount2'])) AND !sizeof($this->_errors))
|
||||
{
|
||||
$customer = new Customer((int)($order->id_customer));
|
||||
$params['{lastname}'] = $customer->lastname;
|
||||
$params['{firstname}'] = $customer->firstname;
|
||||
@ -709,10 +715,8 @@ class AdminOrders extends AdminTab
|
||||
$total_refund = 0;
|
||||
foreach ($productList as $key => $id_order_detail) {
|
||||
$details_refund = new OrderDetail($id_order_detail);
|
||||
|
||||
$tprice = $details_refund->product_price * (1 - $details_refund->reduction_percent / 100) - $details_refund->reduction_amount;
|
||||
$tprice = $tprice * ( 1+ $details_refund->tax_rate / 100 );
|
||||
|
||||
$tprice = $tprice * ( 1 + $details_refund->tax_rate / 100 );
|
||||
$products_refund .= "
|
||||
<tr>
|
||||
<td>". $details_refund->product_name . "</td>
|
||||
@ -728,8 +732,7 @@ class AdminOrders extends AdminTab
|
||||
$params['{total_products}'] = Tools::displayPrice($total_refund);
|
||||
|
||||
$fraisport = "";
|
||||
if(isset($_POST['shippingBack']))
|
||||
{
|
||||
if (isset($_POST['shippingBack'])) {
|
||||
$order = new Order($details_refund->id_order);
|
||||
Module::hookExec('cancelShipping', array('order' => $order));
|
||||
$fraisport .= "
|
||||
@ -741,16 +744,15 @@ class AdminOrders extends AdminTab
|
||||
}
|
||||
|
||||
$params['{fraisport}'] = $fraisport;
|
||||
|
||||
}
|
||||
|
||||
// Generate voucher
|
||||
if (isset($_POST['generateDiscount']) AND !sizeof($this->_errors))
|
||||
{
|
||||
if (!$voucher = Discount::createOrderDiscount($order, $full_product_list, $full_quantity_list, $this->l('Geste commercial concernant la commande '), isset($_POST['shippingBack'])))
|
||||
if (!$voucher = Discount::createOrderDiscount($order, $full_product_list, $full_quantity_list, $this->l('Geste commercial concernant la commande '), isset($_POST['shippingBack']))) {
|
||||
$this->_errors[] = Tools::displayError('Cannot generate voucher');
|
||||
else
|
||||
{
|
||||
}
|
||||
else {
|
||||
// $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
// $params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
|
||||
// $params['{voucher_num}'] = $voucher->name;
|
||||
@ -773,10 +775,10 @@ class AdminOrders extends AdminTab
|
||||
// Generate voucher 2 @Addition Antadis
|
||||
if (isset($_POST['generateDiscount2']) AND !sizeof($this->_errors))
|
||||
{
|
||||
if (!$voucher = Discount::createOrderDiscount($order, $full_product_list, $full_quantity_list, $this->l('Geste commercial concernant la commande '), isset($_POST['shippingBack']),0,0,5))
|
||||
if (!$voucher = Discount::createOrderDiscount($order, $full_product_list, $full_quantity_list, $this->l('Geste commercial concernant la commande '), isset($_POST['shippingBack']),0,0,5)) {
|
||||
$this->_errors[] = Tools::displayError('Cannot generate voucher');
|
||||
else
|
||||
{
|
||||
}
|
||||
else {
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
|
||||
$params['{voucher_num}'] = $voucher->name;
|
||||
@ -806,8 +808,8 @@ class AdminOrders extends AdminTab
|
||||
}
|
||||
}
|
||||
|
||||
// update order state if it's partial
|
||||
if($order->getCurrentState() == 17) {
|
||||
// Update order state if it's partial
|
||||
if ($order->getCurrentState() == 17) {
|
||||
$partial = true;
|
||||
|
||||
$to_send = Db::getInstance()->ExecuteS('
|
||||
@ -817,14 +819,14 @@ class AdminOrders extends AdminTab
|
||||
AND (`product_quantity` - IF(`product_quantity_return` > 0, `product_quantity_return`, `product_quantity_refunded`)) > 0
|
||||
');
|
||||
|
||||
if(count($to_send) == 0) {
|
||||
if (count($to_send) == 0) {
|
||||
$partial = false;
|
||||
} else {
|
||||
include_once dirname(__FILE__).'/../../modules/privatesales/Sale.php';
|
||||
$quantities_sent = array();
|
||||
|
||||
$product_ids = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
foreach (Db::getInstance()->ExecuteS('
|
||||
SELECT `product_id`
|
||||
FROM `'._DB_PREFIX_.'order_detail`
|
||||
WHERE `id_order` = '.(int) $order->id.'
|
||||
@ -835,12 +837,12 @@ class AdminOrders extends AdminTab
|
||||
/**
|
||||
* @Override Philea
|
||||
*/
|
||||
if(Db::getInstance()->getRow('
|
||||
if (Db::getInstance()->getRow('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'philea_parcel`
|
||||
WHERE `id_order` = '.(int) $order->id.'
|
||||
')) {
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
foreach (Db::getInstance()->ExecuteS('
|
||||
SELECT c.`id_product`
|
||||
FROM `'._DB_PREFIX_.'product_ps_cache` c
|
||||
WHERE c.`id_product` IN ('.implode(', ', $products_ids).')
|
||||
@ -856,7 +858,7 @@ class AdminOrders extends AdminTab
|
||||
}
|
||||
}
|
||||
|
||||
if(count($parcel_quantities) > 0) {
|
||||
if (count($parcel_quantities) > 0) {
|
||||
$partial = false;
|
||||
$sent_logistics = array();
|
||||
|
||||
@ -887,7 +889,7 @@ class AdminOrders extends AdminTab
|
||||
$sent_logistics[(int) $row['id_order_detail']] = (int) $row['quantity'];
|
||||
}
|
||||
|
||||
if(count($sent_logistics) == 0) {
|
||||
if (count($sent_logistics) == 0) {
|
||||
$partial = true;
|
||||
} else {
|
||||
foreach($parcel_quantities as $k => $v) {
|
||||
@ -906,7 +908,7 @@ class AdminOrders extends AdminTab
|
||||
$partial = false;
|
||||
}
|
||||
|
||||
if(!$partial) {
|
||||
if (!$partial) {
|
||||
global $cookie;
|
||||
Db::getInstance()->ExecuteS('
|
||||
INSERT INTO `'._DB_PREFIX_.'order_history`
|
||||
@ -935,20 +937,23 @@ class AdminOrders extends AdminTab
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
$this->_errors[] = Tools::displayError('No product or quantity selected.');
|
||||
}
|
||||
|
||||
// Redirect if no errors
|
||||
if (!sizeof($this->_errors))
|
||||
if (!sizeof($this->_errors)) {
|
||||
Tools::redirectAdmin($currentIndex.'&id_order='.$order->id.'&vieworder&conf=24&token='.$this->token);
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
}
|
||||
elseif (isset($_GET['messageReaded']))
|
||||
{
|
||||
elseif (isset($_GET['messageReaded'])) {
|
||||
Message::markAsReaded((int)($_GET['messageReaded']), (int)($cookie->id_employee));
|
||||
}
|
||||
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
|
@ -646,7 +646,7 @@ class Paybox extends PaymentModule
|
||||
$amt = $products[(int) $order_detail->id]['product_price_wt'] * (int) ($_POST['cancelQuantity'][(int) $order_detail->id]);
|
||||
$montant = min($amt, $order->total_paid_real - ((int) $total_shipping * $order->total_shipping) - $total_refunded);
|
||||
|
||||
// Call Paybox and make the refund
|
||||
// Call Paybox and make the refund - shipping refund is made outside
|
||||
$refund = $this->sendRefundPaybox($montant, 978, $transaction['num_transaction'], $order->id_cart, $transaction['num_appel']);
|
||||
|
||||
if (!$refund) {
|
||||
|
@ -716,7 +716,7 @@ class PayPal extends PaymentModule
|
||||
$this->formatMessage($refund, $message);
|
||||
$this->_addNewPrivateMessage((int)$order->id, $message);
|
||||
}
|
||||
|
||||
|
||||
public function hookBackOfficeHeader()
|
||||
{
|
||||
if ((strcmp(Tools::getValue('configure'), $this->name) === 0) ||
|
||||
@ -1176,8 +1176,6 @@ class PayPal extends PaymentModule
|
||||
}
|
||||
// Add shipping, add wrapping, remove discount
|
||||
$amt += (float)($order->total_shipping) + (float)($order->total_wrapping) - (float)($order->total_discounts);
|
||||
|
||||
// @todo : add frais de port
|
||||
|
||||
if ($amt > 0) {
|
||||
// check if total or partial
|
||||
|
Loading…
Reference in New Issue
Block a user