// add restriction on addition and edition of an order

This commit is contained in:
aFolletete
2011-12-05 11:27:26 +00:00
parent 62c432b222
commit 1608547b5b
3 changed files with 36 additions and 12 deletions
@@ -96,7 +96,7 @@
{/if}
</td>
<td class="partial_refund_fields" style="text-align:right;background-color:rgb(232, 237, 194);display:none"><input type="text" size="3" name="partialRefundProduct[{$k}]" /> &euro;</td>
{if $can_edit}
{if ($can_edit && !$order->hasBeenDelivered())}
<td class="product_invoice" colspan="2" style="display: none;text-align:center;">
{if sizeof($invoices_collection)}
<select name="product_invoice" class="edit_product_invoice">
+3 -1
View File
@@ -493,7 +493,7 @@
<legend><img src="../img/admin/cart.gif" alt="{l s='Products'}" />{l s='Products'}</legend>
<div style="float:left;width: 100%;">
{if $can_edit}
<div style="float: left;"><a href="#" class="add_product"><img src="../img/admin/add.gif" alt="{l s='Add a product'}" /> {l s='Add a product'}</a></div>
{if !$order->hasBeenDelivered()}<div style="float: left;"><a href="#" class="add_product"><img src="../img/admin/add.gif" alt="{l s='Add a product'}" /> {l s='Add a product'}</a></div>{/if}
<div style="float: right; margin-right: 10px" id="refundForm">
<!--
<a href="#" class="standard_refund"><img src="../img/admin/add.gif" alt="{l s='Proceed a standard refund'}" /> {l s='Proceed a standard refund'}</a>
@@ -526,9 +526,11 @@
<th style="width: 8%;text-align:right;display:none" class="partial_refund_fields">
{l s='Partial refund'}
</th>
{if !$order->hasBeenDelivered()}
<th style="width: 8%;text-align:center;">
{l s='Action'}
</th>
{/if}
</tr>
{foreach from=$products item=product key=k}
+32 -10
View File
@@ -108,12 +108,13 @@ class AdminOrdersControllerCore extends AdminController
elseif ($order->hasBeenPaid()) $type = $this->l('Standard refund');
else $type = $this->l('Cancel products');
$this->toolbar_btn['new'] = array(
'short' => 'Create',
'href' => '',
'desc' => $this->l('Add a product'),
'class' => 'add_product'
);
if (!$order->hasBeenDelivered())
$this->toolbar_btn['new'] = array(
'short' => 'Create',
'href' => '',
'desc' => $this->l('Add a product'),
'class' => 'add_product'
);
$this->toolbar_btn['standard_refund'] = array(
'short' => 'Create',
'href' => '',
@@ -981,7 +982,7 @@ class AdminOrdersControllerCore extends AdminController
$order_invoice->total_products_wt = (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS);
$order_invoice->total_shipping_tax_excl = (float)$cart->getTotalShippingCost(null, false);
$order_invoice->total_shipping_tax_incl = (float)$cart->getTotalShippingCost();
$order_invoice->total_wrapping_tax_excl = abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING));
$order_invoice->total_wrapping_tax_incl = abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING));
@@ -1098,11 +1099,12 @@ class AdminOrdersControllerCore extends AdminController
// Return value
$res = true;
$order = new Order(Tools::getValue('id_order'));
$order_detail = new OrderDetail(Tools::getValue('product_id_order_detail'));
if (Tools::isSubmit('product_invoice'))
$order_invoice = new OrderInvoice(Tools::getValue('product_invoice'));
$this->doEditProductValidation($order_detail, isset($order_invoice) ? $order_invoice : null);
$this->doEditProductValidation($order_detail, $order, isset($order_invoice) ? $order_invoice : null);
$product_price_tax_incl = Tools::ps_round(Tools::getValue('product_price_tax_incl'), 2);
$product_price_tax_excl = Tools::ps_round(Tools::getValue('product_price_tax_excl'), 2);
@@ -1269,7 +1271,7 @@ class AdminOrdersControllerCore extends AdminController
)));
}
protected function doEditProductValidation(OrderDetail $order_detail, OrderInvoice $order_invoice = null)
protected function doEditProductValidation(OrderDetail $order_detail, Order $order, OrderInvoice $order_invoice = null)
{
if (!Validate::isLoadedObject($order_detail))
die(Tools::jsonEncode(array(
@@ -1283,12 +1285,25 @@ class AdminOrdersControllerCore extends AdminController
'error' => Tools::displayError('Can\'t load Invoice object')
)));
if ($order_detail->id_order != Tools::getValue('id_order'))
if (!Validate::isLoadedObject($order))
die(Tools::jsonEncode(array(
'result' => false,
'error' => Tools::displayError('Can\'t load Order object')
)));
if ($order_detail->id_order != $order->id_order)
die(Tools::jsonEncode(array(
'result' => false,
'error' => Tools::displayError('Can\'t edit this Order Detail for this order')
)));
// We can't edit a delivered order
if ($order->hasBeenDelivered())
die(Tools::jsonEncode(array(
'result' => false,
'error' => Tools::displayError('Can\'t edit an delivered order')
)));
if (!empty($order_invoice) && $order_invoice->id_order != Tools::getValue('id_order'))
die(Tools::jsonEncode(array(
'result' => false,
@@ -1331,6 +1346,13 @@ class AdminOrdersControllerCore extends AdminController
'result' => false,
'error' => Tools::displayError('Can\'t delete this Order Detail for this order')
)));
// We can't edit a delivered order
if ($order->hasBeenDelivered())
die(Tools::jsonEncode(array(
'result' => false,
'error' => Tools::displayError('Can\'t edit an delivered order')
)));
}
protected function getProducts($order)