[-] Project : #PSCFV-2633 #PSCFV-2622 - Fix problems with multishipping and order payment & invoice
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15797 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -82,12 +82,12 @@
|
||||
--
|
||||
{else}
|
||||
{displayPrice price=$document->total_paid_tax_incl currency=$currency->id}
|
||||
{if $document->getRestPaid()}
|
||||
{if $document->getGlobalRestPaid()}
|
||||
<span style="color:red;font-weight:bold;">
|
||||
{if $document->getRestPaid() >= 0}
|
||||
({displayPrice price=$document->getRestPaid() currency=$currency->id} {l s='not paid'})
|
||||
{if $document->getGlobalRestPaid() >= 0}
|
||||
({displayPrice price=$document->getGlobalRestPaid() currency=$currency->id} {l s='not paid'})
|
||||
{else}
|
||||
({displayPrice price=-$document->getRestPaid() currency=$currency->id} {l s='overpaid'})
|
||||
({displayPrice price=-$document->getGlobalRestPaid() currency=$currency->id} {l s='overpaid'})
|
||||
{/if}
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
@@ -202,6 +202,50 @@
|
||||
{if $nextOrder}<a class="button" href="{$link->getAdminLink('AdminOrders')}&vieworder&id_order={$nextOrder}">{l s='Next >'}</a>{/if}
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
||||
<!-- linked orders block -->
|
||||
{if count($order->getBrother()) > 0}
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/tab-orders.gif" /> {l s='Linked orders'}</legend>
|
||||
<table class="table" width="100%;" cellspacing="0" cellpadding="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%">
|
||||
{l s='Order n°'}
|
||||
</th>
|
||||
<th>
|
||||
{l s='Status'}
|
||||
</th>
|
||||
<th width="10%">
|
||||
{l s='Amount'}
|
||||
</th>
|
||||
<th width="5%">
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach $order->getBrother() as $brother_order}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{$current_index}&vieworder&id_order={$brother_order->id}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}">#{'%06d'|sprintf:$brother_order->id}</a>
|
||||
</td>
|
||||
<td>
|
||||
{$brother_order->getCurrentOrderState()->name[$current_id_lang]}
|
||||
</td>
|
||||
<td>
|
||||
{displayPrice price=$brother_order->total_paid_tax_incl currency=$currency->id}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{$current_index}&vieworder&id_order={$brother_order->id}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}"><img alt="{l s='See the order'}" src="../img/admin/details.gif"></a>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
<br />
|
||||
{/if}
|
||||
|
||||
<!-- Documents block -->
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/details.gif" /> {l s='Documents'}</legend>
|
||||
@@ -230,15 +274,26 @@
|
||||
</form>
|
||||
<hr />
|
||||
{/if}
|
||||
{if $order->hasBeenPaid()}
|
||||
|
||||
{if count($order->getOrderPayments()) > 0}
|
||||
<p class="error" style="{if round($orders_total_paid_tax_incl, 2) == round($total_paid, 2) || $currentState->id == 6}display: none;{/if}">
|
||||
{l s='Warning:'} {displayPrice price=$total_paid currency=$currency->id}
|
||||
|
||||
{l s='paid instead of'} <span class="total_paid">{displayPrice price=$orders_total_paid_tax_incl currency=$currency->id}</span>
|
||||
|
||||
{foreach $order->getBrother() as $brother_order}
|
||||
{if $brother_order@first}
|
||||
{if count($order->getBrother()) == 1}
|
||||
<br />{l s='This warning also concerns the order '}
|
||||
{else}
|
||||
<br />{l s='This warning also concerns the next orders:'}
|
||||
{/if}
|
||||
{/if}
|
||||
<a href="{$current_index}&vieworder&id_order={$brother_order->id}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}">#{'%06d'|sprintf:$brother_order->id}</a>
|
||||
{/foreach}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<form id="formAddPayment" method="post" action="{$current_index}&viewOrder&id_order={$smarty.get.id_order|escape:'htmlall':'UTF-8'}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}">
|
||||
<form id="formAddPayment" method="post" action="{$current_index}&vieworder&id_order={$smarty.get.id_order|escape:'htmlall':'UTF-8'}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}">
|
||||
<table class="table" width="100%" cellspacing="0" cellpadding="0">
|
||||
<colgroup>
|
||||
<col width="15%"></col>
|
||||
@@ -266,8 +321,8 @@
|
||||
<td>{$payment->transaction_id}</td>
|
||||
<td>{displayPrice price=$payment->amount currency=$payment->id_currency}</td>
|
||||
<td>
|
||||
{if $payment->id_order_invoice}
|
||||
{OrderInvoice::retrieveOneById($payment->id_order_invoice)->getInvoiceNumberFormatted($current_id_lang)}
|
||||
{if $invoice = $payment->getOrderInvoice($order->id)}
|
||||
{$invoice->getInvoiceNumberFormatted($current_id_lang)}
|
||||
{else}
|
||||
{l s='No invoice'}
|
||||
{/if}
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
name="{$input.name}"
|
||||
id="{if isset($input.id)}{$input.id}{else}{$input.name}{/if}"
|
||||
value="{if isset($input.string_format) && $input.string_format}{$value_text|string_format:$input.string_format|escape:'htmlall':'UTF-8'}{else}{$value_text|escape:'htmlall':'UTF-8'}{/if}"
|
||||
class="{if $input.type == 'tags'}tagify {/if}"
|
||||
class="{if $input.type == 'tags'}tagify {/if}{if isset($input.class)}{$input.class}{/if}"
|
||||
{if isset($input.size)}size="{$input.size}"{/if}
|
||||
{if isset($input.maxlength)}maxlength="{$input.maxlength}"{/if}
|
||||
{if isset($input.class)}class="{$input.class}"{/if}
|
||||
|
||||
@@ -84,6 +84,7 @@ class PaymentCCCore extends OrderPayment
|
||||
public static function getByOrderId($id_order)
|
||||
{
|
||||
Tools::displayAsDeprecated();
|
||||
return OrderPayment::getByOrderId($id_order);
|
||||
$order = new Order($id_order);
|
||||
return OrderPayment::getByOrderReference($order->reference);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-12
@@ -143,6 +143,10 @@ abstract class PaymentModuleCore extends Module
|
||||
$cart = new Cart($id_cart);
|
||||
$this->context->cart = $cart;
|
||||
|
||||
$order_status = new OrderState((int)$id_order_state, (int)$cart->id_lang);
|
||||
if (!Validate::isLoadedObject($order_status))
|
||||
throw new PrestaShopException('Can\'t load Order state status');
|
||||
|
||||
if (!$this->active)
|
||||
die(Tools::displayError());
|
||||
// Does order already exists ?
|
||||
@@ -183,10 +187,6 @@ abstract class PaymentModuleCore extends Module
|
||||
die($error);
|
||||
}
|
||||
|
||||
$order_status = new OrderState((int)$id_order_state, (int)$cart->id_lang);
|
||||
if (!Validate::isLoadedObject($order_status))
|
||||
throw new PrestaShopException('Can\'t load Order state status');
|
||||
|
||||
foreach ($cart_delivery_option as $id_address => $key_carriers)
|
||||
foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data)
|
||||
foreach ($data['package_list'] as $id_package)
|
||||
@@ -270,18 +270,14 @@ abstract class PaymentModuleCore extends Module
|
||||
// Creating order
|
||||
$result = $order->add();
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($result && $order_status->logable)
|
||||
{
|
||||
if (!$order->addOrderPayment($amount_paid))
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
if (!$result)
|
||||
throw new PrestaShopException('Can\'t save Order');
|
||||
|
||||
// Amount paid by customer is not the right one -> Status = payment error
|
||||
// We don't use the following condition to avoid the float precision issues : http://www.php.net/manual/en/language.types.float.php
|
||||
// if ($order->total_paid != $order->total_paid_real)
|
||||
// We use number_format in order to compare two string
|
||||
if ($order_status->logable && number_format($cart_total_paid, 2) != number_format($order->total_paid_real, 2))
|
||||
if ($order_status->logable && number_format($cart_total_paid, 2) != number_format($amount_paid, 2))
|
||||
$id_order_state = Configuration::get('PS_OS_ERROR');
|
||||
|
||||
$order_list[] = $order;
|
||||
@@ -304,6 +300,16 @@ abstract class PaymentModuleCore extends Module
|
||||
}
|
||||
}
|
||||
|
||||
// Register Payment only if the order status validate the order
|
||||
if ($order_status->logable)
|
||||
{
|
||||
// $order is the last order loop in the foreach
|
||||
// The method addOrderPayment of the class Order make a create a paymentOrder
|
||||
// linked to the order reference and not to the order id
|
||||
if (!$order->addOrderPayment($amount_paid))
|
||||
throw new PrestaShopException('Can\'t save Order Payment');
|
||||
}
|
||||
|
||||
// Next !
|
||||
$only_one_gift = false;
|
||||
$cart_rule_used = array();
|
||||
@@ -617,7 +623,7 @@ abstract class PaymentModuleCore extends Module
|
||||
Logger::addLog($error, 4, '0000002', 'Cart', intval($order->id_cart));
|
||||
die($error);
|
||||
}
|
||||
}
|
||||
} // End foreach $order_detail_list
|
||||
// Use the last order as currentOrder
|
||||
$this->currentOrder = (int)$order->id;
|
||||
return true;
|
||||
|
||||
+48
-7
@@ -1116,9 +1116,15 @@ class OrderCore extends ObjectModel
|
||||
|
||||
// Update order payment
|
||||
Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'order_payment`
|
||||
SET `id_order_invoice` = '.(int)$order_invoice->id.'
|
||||
WHERE `id_order` = '.(int)$order_invoice->id_order);
|
||||
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
|
||||
SET
|
||||
`id_order_invoice` = '.(int)$order_invoice->id.',
|
||||
`id_order_payment` = (
|
||||
SELECT id_order_payment FROM `'._DB_PREFIX_.'order_payment` op
|
||||
INNER JOIN `'._DB_PREFIX_.'orders` o
|
||||
ON o.reference = op.order_reference
|
||||
WHERE id_order = '.(int)$order_invoice->id_order.' LIMIT 1),
|
||||
`id_order` = '.(int)$order_invoice->id_order);
|
||||
|
||||
// Update order cart rule
|
||||
Db::getInstance()->execute('
|
||||
@@ -1357,7 +1363,7 @@ class OrderCore extends ObjectModel
|
||||
public function getOrderPaymentCollection()
|
||||
{
|
||||
$order_payments = new Collection('OrderPayment');
|
||||
$order_payments->where('id_order', '=', $this->id);
|
||||
$order_payments->where('order_reference', '=', $this->reference);
|
||||
return $order_payments;
|
||||
}
|
||||
|
||||
@@ -1376,8 +1382,7 @@ class OrderCore extends ObjectModel
|
||||
public function addOrderPayment($amount_paid, $payment_method = null, $payment_transaction_id = null, $currency = null, $date = null, $order_invoice = null)
|
||||
{
|
||||
$order_payment = new OrderPayment();
|
||||
$order_payment->id_order = $this->id;
|
||||
$order_payment->id_order_invoice = (!is_null($order_invoice) ? $order_invoice->id : null);
|
||||
$order_payment->order_reference = $this->reference;
|
||||
$order_payment->id_currency = ($currency ? $currency->id : $this->id_currency);
|
||||
// we kept the currency rate for historization reasons
|
||||
$order_payment->conversion_rate = ($currency ? $currency->conversion_rate : 1);
|
||||
@@ -1394,7 +1399,19 @@ class OrderCore extends ObjectModel
|
||||
$this->total_paid_real += Tools::ps_round(Tools::convertPrice($order_payment->amount, $order_payment->id_currency, false), 2);
|
||||
|
||||
// We put autodate parameter of add method to true if date_add field is null
|
||||
return $order_payment->add(is_null($order_payment->date_add)) && $this->update();
|
||||
$res = $order_payment->add(is_null($order_payment->date_add)) && $this->update();
|
||||
|
||||
if (!$res)
|
||||
return false;
|
||||
|
||||
if (!is_null($order_invoice))
|
||||
{
|
||||
$res = Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
|
||||
VALUES('.(int)$order_invoice->id.', '.(int)$order_payment->id.', '.(int)$this->id.')');
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1745,5 +1762,29 @@ class OrderCore extends ObjectModel
|
||||
$sql_filter .= Shop::addSqlRestriction(Shop::SHARE_ORDER, 'main');
|
||||
return parent::getWebserviceObjectList($sql_join, $sql_filter, $sql_sort, $sql_limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all other orders with the same reference
|
||||
*
|
||||
* @since 1.5.0.13
|
||||
*/
|
||||
public function getBrother()
|
||||
{
|
||||
$collection = new Collection('order');
|
||||
$collection->where('reference', '=', $this->reference);
|
||||
$collection->where('id_order', '<>', $this->id);
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a collection of order payments
|
||||
*
|
||||
* @since 1.5.0.13
|
||||
*/
|
||||
public function getOrderPayments()
|
||||
{
|
||||
return OrderPayment::getByOrderReference($this->reference);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -226,16 +226,19 @@ class OrderHistoryCore extends ObjectModel
|
||||
foreach ($invoices as $invoice)
|
||||
{
|
||||
$rest_paid = $invoice->getRestPaid();
|
||||
if ($rest_paid)
|
||||
if ($rest_paid > 0)
|
||||
{
|
||||
$payment = new OrderPayment();
|
||||
$payment->id_order = $order->id;
|
||||
$payment->id_order_invoice = $invoice->id;
|
||||
$payment->order_reference = $order->reference;
|
||||
$payment->id_currency = $order->id_currency;
|
||||
$payment->amount = $rest_paid;
|
||||
$payment->payment_method = $payment_method->displayName;
|
||||
$payment->conversion_rate = 1;
|
||||
$payment->save();
|
||||
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'order_invoice_payment`
|
||||
VALUES('.(int)$invoice->id.', '.(int)$payment->id.', '.(int)$order->id.')');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,11 +442,11 @@ class OrderInvoiceCore extends ObjectModel
|
||||
return $carrier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.5
|
||||
* @static
|
||||
* @param $id_order_invoice
|
||||
*/
|
||||
/**
|
||||
* @since 1.5
|
||||
* @static
|
||||
* @param $id_order_invoice
|
||||
*/
|
||||
public static function getCarrierId($id_order_invoice)
|
||||
{
|
||||
$sql = 'SELECT `id_carrier`
|
||||
@@ -496,6 +496,39 @@ class OrderInvoiceCore extends ObjectModel
|
||||
return round($this->total_paid_tax_incl - $this->getTotalPaid(), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get global rest to paid
|
||||
* This method will return something different of the method getRestPaid if
|
||||
* there is an other invoice linked to the payments of the current invoice
|
||||
* @since 1.5.0.13
|
||||
*/
|
||||
public function getGlobalRestPaid()
|
||||
{
|
||||
static $cache;
|
||||
|
||||
if (!isset($cache[$this->id]))
|
||||
{
|
||||
$res = Db::getInstance()->getRow('
|
||||
SELECT SUM(sub.paid) paid, SUM(sub.to_paid) to_paid
|
||||
FROM (
|
||||
SELECT
|
||||
op.amount as paid, SUM(oi.total_paid_tax_incl) to_paid
|
||||
FROM `'._DB_PREFIX_.'order_invoice_payment` oip1
|
||||
INNER JOIN `'._DB_PREFIX_.'order_invoice_payment` oip2
|
||||
ON oip2.id_order_payment = oip1.id_order_payment
|
||||
INNER JOIN `'._DB_PREFIX_.'order_invoice` oi
|
||||
ON oi.id_order_invoice = oip2.id_order_invoice
|
||||
INNER JOIN `'._DB_PREFIX_.'order_payment` op
|
||||
ON op.id_order_payment = oip2.id_order_payment
|
||||
WHERE oip1.id_order_invoice = '.(int)$this->id.'
|
||||
GROUP BY op.id_order_payment
|
||||
) sub');
|
||||
$cache[$this->id] = round($res['to_paid'] - $res['paid'], 2);
|
||||
}
|
||||
|
||||
return $cache[$this->id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.5.0.2
|
||||
* @return bool Is paid ?
|
||||
@@ -511,9 +544,7 @@ class OrderInvoiceCore extends ObjectModel
|
||||
*/
|
||||
public function getOrderPaymentCollection()
|
||||
{
|
||||
$order_payments = new Collection('OrderPayment');
|
||||
$order_payments->where('id_order_invoice', '=', $this->id);
|
||||
return $order_payments;
|
||||
return OrderPayment::getByInvoiceId($this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,9 +27,8 @@
|
||||
|
||||
class OrderPaymentCore extends ObjectModel
|
||||
{
|
||||
public $id_order;
|
||||
public $order_reference;
|
||||
public $id_currency;
|
||||
public $id_order_invoice;
|
||||
public $amount;
|
||||
public $payment_method;
|
||||
public $conversion_rate;
|
||||
@@ -47,9 +46,8 @@ class OrderPaymentCore extends ObjectModel
|
||||
'table' => 'order_payment',
|
||||
'primary' => 'id_order_payment',
|
||||
'fields' => array(
|
||||
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'order_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isAnything', 'size' => 9),
|
||||
'id_currency' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_order_invoice' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true),
|
||||
'payment_method' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
|
||||
'conversion_rate' => array('type' => self::TYPE_INT, 'validate' => 'isFloat'),
|
||||
@@ -79,12 +77,27 @@ class OrderPaymentCore extends ObjectModel
|
||||
*/
|
||||
public static function getByOrderId($id_order)
|
||||
{
|
||||
return Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'order_payment`
|
||||
WHERE `id_order` = '.(int)$id_order);
|
||||
Tools::displayAsDeprecated();
|
||||
$order = new Order($id_order);
|
||||
return OrderPayment::getByOrderReference($order->reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the detailed payment of an order
|
||||
* @param int $order_reference
|
||||
* @return array
|
||||
* @since 1.5.0.13
|
||||
*/
|
||||
public static function getByOrderReference($order_reference)
|
||||
{
|
||||
return ObjectModel::hydrateCollection('OrderPayment',
|
||||
Db::getInstance()->executeS('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'order_payment`
|
||||
WHERE `order_reference` = \''.pSQL($order_reference).'\'')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Order Payments By Invoice ID
|
||||
* @static
|
||||
@@ -93,9 +106,38 @@ class OrderPaymentCore extends ObjectModel
|
||||
*/
|
||||
public static function getByInvoiceId($id_invoice)
|
||||
{
|
||||
$payments = Db::getInstance()->executeS('SELECT id_order_payment FROM `'._DB_PREFIX_.'order_invoice_payment` WHERE id_order_invoice = '.(int)$id_invoice);
|
||||
if (!$payments)
|
||||
return array();
|
||||
|
||||
$payment_list = array();
|
||||
foreach ($payments as $payment)
|
||||
$payment_list[] = $payment['id_order_payment'];
|
||||
|
||||
$payments = new Collection('OrderPayment');
|
||||
$payments->where('id_order_invoice', '=', $id_invoice);
|
||||
$payments->where('id_order_payment', 'IN', $payment_list);
|
||||
return $payments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return order invoice object linked to the payment
|
||||
*
|
||||
* @param int $id_order Order Id
|
||||
*
|
||||
* @since 1.5.0.13
|
||||
*/
|
||||
public function getOrderInvoice($id_order)
|
||||
{
|
||||
$res = Db::getInstance()->getValue('
|
||||
SELECT id_order_invoice
|
||||
FROM `'._DB_PREFIX_.'order_invoice_payment`
|
||||
WHERE id_order_payment = '.(int)$this->id.'
|
||||
AND id_order = '.(int)$id_order);
|
||||
|
||||
if (!$res)
|
||||
return false;
|
||||
|
||||
return new OrderInvoice($res['id_order_invoice']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
Options +FollowSymLinks
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule "(.*)\.css$" retro-compat.css.php?file=$1.css [QSA,L]
|
||||
</IfModule>
|
||||
|
||||
+8
-1
@@ -471,11 +471,18 @@ select optgroup option {
|
||||
margin:0 5px 0 0;
|
||||
}
|
||||
|
||||
#content .error {
|
||||
#content .error {
|
||||
background: #FFBABA url(../img/admin/icon-cancel.png) no-repeat scroll 6px 6px;
|
||||
border: 1px solid #CC0000;
|
||||
color:#D8000C;
|
||||
}
|
||||
#content .conf a, #content .warn a, #content .error a {
|
||||
color:#D8000C;
|
||||
font-weight: bold;
|
||||
}
|
||||
#content .conf a:hover, #content .warn a:hover, #content .error a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#ajax_confirmation .error {
|
||||
background: #FFBABA url(../img/admin/icon-cancel.png) no-repeat scroll 6px 6px;
|
||||
|
||||
@@ -1310,8 +1310,7 @@ CREATE TABLE `PREFIX_page_viewed` (
|
||||
|
||||
CREATE TABLE `PREFIX_order_payment` (
|
||||
`id_order_payment` INT NOT NULL auto_increment,
|
||||
`id_order_invoice` INT UNSIGNED NULL,
|
||||
`id_order` INT UNSIGNED NULL,
|
||||
`order_reference` VARCHAR(9),
|
||||
`id_currency` INT UNSIGNED NOT NULL,
|
||||
`amount` DECIMAL(10,2) NOT NULL,
|
||||
`payment_method` varchar(255) NOT NULL,
|
||||
@@ -1323,7 +1322,7 @@ CREATE TABLE `PREFIX_order_payment` (
|
||||
`card_holder` VARCHAR(254) NULL,
|
||||
`date_add` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`id_order_payment`),
|
||||
KEY `id_order` (`id_order`)
|
||||
KEY `order_reference`(`order_reference`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `PREFIX_product` (
|
||||
@@ -2408,3 +2407,14 @@ CREATE TABLE `PREFIX_module_preference` (
|
||||
PRIMARY KEY (`id_carrier`, `id_tax_rules_group`, `id_shop`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `PREFIX_order_invoice_payment` (
|
||||
`id_order_invoice` int(11) unsigned NOT NULL,
|
||||
`id_order_payment` int(11) unsigned NOT NULL,
|
||||
`id_order` int(11) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_order_invoice`,`id_order_payment`),
|
||||
KEY `order_payment` (`id_order_payment`),
|
||||
KEY `id_order` (`id_order`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2012 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2012 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
function add_order_reference_in_order_payment()
|
||||
{
|
||||
$payments = Db::getInstance()->executeS('
|
||||
SELECT op.id_order_payment, o.reference
|
||||
FROM `'._DB_PREFIX_.'order_payment` op
|
||||
INNER JOIN `'._DB_PREFIX_.'orders` o
|
||||
ON o.id_order = op.id_order');
|
||||
|
||||
if (!is_array($payments))
|
||||
return false;
|
||||
|
||||
$errors = array();
|
||||
|
||||
|
||||
// Populate "order_reference"
|
||||
foreach ($payments as $payment)
|
||||
{
|
||||
$res = Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'order_payment`
|
||||
SET order_reference = \''.$payment['reference'].'\'
|
||||
WHERE id_order_payment = '.(int)$payment['id_order_payment']);
|
||||
|
||||
if (!$res)
|
||||
$errors[] = Db::getInstance()->getMsgError();
|
||||
}
|
||||
|
||||
if (count($errors))
|
||||
return array('error' => true, 'msg' => implode('<br/>', $errors));
|
||||
|
||||
// Get lines to merge (with multishipping on, durring the payment one line was added by order, only one is necessary by cart)
|
||||
$duplicate_lines = Db::getInstance()->executeS('
|
||||
SELECT GROUP_CONCAT(id_order_payment) as id_order_payments
|
||||
FROM `'._DB_PREFIX_.'order_payment`
|
||||
GROUP BY order_reference, date_add
|
||||
HAVING COUNT(*) > 1');
|
||||
|
||||
if (!is_array($duplicate_lines))
|
||||
return false;
|
||||
|
||||
$order_payments_to_remove = array();
|
||||
foreach ($duplicate_lines as $order_payments)
|
||||
{
|
||||
$order_payments_array = explode(',', $order_payments['id_order_payments']);
|
||||
// Remove the first item (we want to keep one line)
|
||||
$id_order_payment_keep = array_shift($order_payments_array);
|
||||
|
||||
$res = Db::getInstance()->execute('
|
||||
UPDATE `'._DB_PREFIX_.'order_invoice_payment`
|
||||
SET id_order_payement = '.(int)$id_order_payment_keep.'
|
||||
WHERE id_order_payment IN ('.implode(',', $order_payments_array).')');
|
||||
|
||||
$order_payments_to_remove = array_merge($order_payments_to_remove, $order_payments_array);
|
||||
}
|
||||
// Remove the duplicate lines (because of the multishipping)
|
||||
if (count($order_payments_to_remove))
|
||||
$res = Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'order_payment` WHERE id_order_payment IN ('.implode(',', $order_payments_to_remove).')');
|
||||
|
||||
if (!$res)
|
||||
return array('errors' => true, 'msg' => Db::getInstance()->getMsgError());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -5,3 +5,33 @@ DROP TABLE `PREFIX_discount_type`;
|
||||
DROP TABLE `PREFIX_discount_type_lang`;
|
||||
|
||||
/* PHP:add_missing_image_key(); */;
|
||||
|
||||
-- Update order_payment structure for multishipping
|
||||
|
||||
-- Step 1: Add the table ps_order_invoice_payment and populate it
|
||||
CREATE TABLE `PREFIX_order_invoice_payment` (
|
||||
`id_order_invoice` int(11) unsigned NOT NULL,
|
||||
`id_order_payment` int(11) unsigned NOT NULL,
|
||||
`id_order` int(11) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_order_invoice`,`id_order_payment`),
|
||||
KEY `order_payment` (`id_order_payment`),
|
||||
KEY `id_order` (`id_order`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `PREFIX_order_invoice_payment`
|
||||
(SELECT id_order_invoice, id_order_payment, id_order FROM `PREFIX_order_payment` WHERE id_order_invoice > 0);
|
||||
|
||||
-- Step 2: Add the collumn id_order_reference
|
||||
ALTER TABLE `PREFIX_order_payment`
|
||||
ADD COLUMN `order_reference` VARCHAR(9) AFTER `id_order`,
|
||||
ADD INDEX `order_reference`(`order_reference`);
|
||||
|
||||
|
||||
-- Step 3: Fill in id_order_reference and merge duplicate lines
|
||||
/* PHP:add_order_reference_in_order_payment(); */;
|
||||
|
||||
-- Step 4: Drop collumn id_order
|
||||
ALTER TABLE `PREFIX_order_payment`
|
||||
DROP COLUMN `id_order`,
|
||||
DROP COLUMN `id_order_invoice`;
|
||||
|
||||
|
||||
@@ -192,6 +192,7 @@ $_LANGADM['AdminBackupaea390041b1129a817610ff53181cd4b'] = 'Si le poids de votre
|
||||
$_LANGADM['AdminBackupb3bd0f5ff93aa82c778f1486bdfecb90'] = 'Cliquez sur le bouton \"Exécuter\" et patientez durant l\'import de votre fichier, cela peut prendre plusieurs minutes';
|
||||
$_LANGADM['AdminBackupb828e7a94de289536d535e8c141868b9'] = 'Si ce n\'est pas le cas,';
|
||||
$_LANGADM['AdminBackupc4a8330b099d9409ed1ba801d69a1dd0'] = 'Lancement du téléchargement...';
|
||||
$_LANGADM['AdminBackupc9cc8cce247e49bae79f15173ce97354'] = 'Sauvegarder';
|
||||
$_LANGADM['AdminBackupd1c6b1687ebbc336f9bd13beba87b0cf'] = 'veuillez cliquer ici !';
|
||||
$_LANGADM['AdminBackupd3b206d196cd6be3a2764c1fb90b200f'] = 'Supprimer la sélection';
|
||||
$_LANGADM['AdminBackupe25f0ecd41211b01c83e5fec41df4fe7'] = 'Supprimer la sélection ?';
|
||||
@@ -1952,6 +1953,7 @@ $_LANGADM['AdminOrderPreferencese4045598261988d9988c594243a9434d'] = 'Conditions
|
||||
$_LANGADM['AdminOrderPreferencese84eed89f38f20639431d99ad2f5ee8a'] = 'Suggérer au client de choisir un colis en matières recyclées';
|
||||
$_LANGADM['AdminOrderPreferencesf5aec3fffaa728afbea122ca6dc5e036'] = 'Permettre aux clients de fractionner leurs commandes. Une avec les produits \"en stock\", et une autre avec les autres produits. Cette option va transformer le panier des clients dans deux commandes.';
|
||||
$_LANGADM['AdminOrders004bf6c9a40003140292e97330236c53'] = 'Action';
|
||||
$_LANGADM['AdminOrders010cd82f1f972dc6b720536adb555533'] = 'Commandes liées';
|
||||
$_LANGADM['AdminOrders0110ae516fc412d9e286afdb312caeb4'] = 'Propriétaire de la carte :';
|
||||
$_LANGADM['AdminOrders01abfc750a0c942167651c40d088531d'] = 'n°';
|
||||
$_LANGADM['AdminOrders02c0f707ac36ba1b280e5ce66dcd6402'] = 'créer une commande';
|
||||
@@ -2036,6 +2038,7 @@ $_LANGADM['AdminOrders53488e4e281c04a26dc9bb8e13ef1da6'] = 'Messages :';
|
||||
$_LANGADM['AdminOrders543ae6adeb524f98cc7d3c816a1ec1e3'] = 'Total des ventes HT :';
|
||||
$_LANGADM['AdminOrders54431df3f2451575c469f55e99a49f3a'] = 'Avoir concernant la commande n°';
|
||||
$_LANGADM['AdminOrders552a0d8c17d95d5dbdc0c28217024f5a'] = 'Coût du transport';
|
||||
$_LANGADM['AdminOrders55a204c5cf6c0239fb7657ebaa168c42'] = 'Commander n°';
|
||||
$_LANGADM['AdminOrders57494d3f60983abfdea2c71f5f893cdc'] = 'Ce document n\'est pas disponible';
|
||||
$_LANGADM['AdminOrders585bc67adbb73dcca638b897fb73a900'] = 'Voir le document';
|
||||
$_LANGADM['AdminOrders5a9ec4ab51bd41f2618ef91ec90d55b2'] = 'Vous souhaitez ajouter plus de produit qu\'il n\'y a de stock, êtes-vous sûr de vouloir ajouter cette quantité ?';
|
||||
@@ -2057,6 +2060,7 @@ $_LANGADM['AdminOrders6a5efd211a422296eab4adc476c98f0e'] = 'Retourner les produi
|
||||
$_LANGADM['AdminOrders6a94d8492279c2bfd3e81f3158658980'] = '[Génération] Règle Panier pour livraison offerte';
|
||||
$_LANGADM['AdminOrders6c957f72dc8cdacc75762f2cbdcdfaf2'] = 'Prix unique';
|
||||
$_LANGADM['AdminOrders6fe50cb3c0bf60f28ac9049ae6cb8c26'] = 'Cette commande a été passée par un compte invité.';
|
||||
$_LANGADM['AdminOrders7111c54c532874058efa792da6d2b05d'] = 'Cet avertissement concerne aussi la facture';
|
||||
$_LANGADM['AdminOrders711cb64729ed5b666cf97c01691f5806'] = 'Inclure frais de port';
|
||||
$_LANGADM['AdminOrders71e2851d86b252a44c658b896c486921'] = 'Modifier une note';
|
||||
$_LANGADM['AdminOrders729a51874fe901b092899e9e8b31c97a'] = 'Êtes-vous sûr ?';
|
||||
@@ -2174,6 +2178,7 @@ $_LANGADM['AdminOrdersf0aaaae189e9c7711931a65ffcd22543'] = 'Méthode de paiement
|
||||
$_LANGADM['AdminOrdersf14b582c1b0eab88ed5904fb781568c0'] = 'Nom de la réduction';
|
||||
$_LANGADM['AdminOrdersf28128b38efbc6134dc40751ee21fd29'] = 'Documents';
|
||||
$_LANGADM['AdminOrdersf2a6c498fb90ee345d997f888fce3b18'] = 'Supprimer';
|
||||
$_LANGADM['AdminOrdersf38c718d5cc5ea7331d8acf533f9bf0d'] = 'Cette avertissement concerne aussi les commandes suivantes :';
|
||||
$_LANGADM['AdminOrdersf4ec5f57bd4d31b803312d873be40da9'] = 'Modifier';
|
||||
$_LANGADM['AdminOrdersf53e8d0e97c47ce70ca9c5eaa08a00d0'] = 'Avoir';
|
||||
$_LANGADM['AdminOrdersf8246f1c2cfd9a81a376223428bd09d7'] = 'Pas de facture';
|
||||
@@ -2181,6 +2186,7 @@ $_LANGADM['AdminOrdersf8617a92ba0a0a4eabee724eab7c9f48'] = 'Transporteur :';
|
||||
$_LANGADM['AdminOrdersf8a09f634b7b3ede2da34607da2aaebe'] = 'Quantités disponibles';
|
||||
$_LANGADM['AdminOrdersf8b1369a8e9d90da0cae0b11049309af'] = 'Non défini';
|
||||
$_LANGADM['AdminOrdersfb61758d0f0fda4ba867c3d5a46c16a7'] = 'Sources';
|
||||
$_LANGADM['AdminOrdersfc24bca31a0e2f75c9979c18760a4960'] = 'Voir la commande';
|
||||
$_LANGADM['AdminOrdersfcf180ebb3cd68250a42bf69795217d8'] = 'Aucune marchandise n\'a été retournée';
|
||||
$_LANGADM['AdminOrdersfdb70f044434286838493fb91d31f6bc'] = 'pour voir tous les messages';
|
||||
$_LANGADM['AdminOrdersfdf9a25b5aa1ba1105aab61cb4508729'] = 'Livraison gratuite :';
|
||||
|
||||
Reference in New Issue
Block a user