// add restriction on addition and edition of an order
This commit is contained in:
@@ -96,7 +96,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</td>
|
</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}]" /> €</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}]" /> €</td>
|
||||||
{if $can_edit}
|
{if ($can_edit && !$order->hasBeenDelivered())}
|
||||||
<td class="product_invoice" colspan="2" style="display: none;text-align:center;">
|
<td class="product_invoice" colspan="2" style="display: none;text-align:center;">
|
||||||
{if sizeof($invoices_collection)}
|
{if sizeof($invoices_collection)}
|
||||||
<select name="product_invoice" class="edit_product_invoice">
|
<select name="product_invoice" class="edit_product_invoice">
|
||||||
|
|||||||
@@ -493,7 +493,7 @@
|
|||||||
<legend><img src="../img/admin/cart.gif" alt="{l s='Products'}" />{l s='Products'}</legend>
|
<legend><img src="../img/admin/cart.gif" alt="{l s='Products'}" />{l s='Products'}</legend>
|
||||||
<div style="float:left;width: 100%;">
|
<div style="float:left;width: 100%;">
|
||||||
{if $can_edit}
|
{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">
|
<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>
|
<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">
|
<th style="width: 8%;text-align:right;display:none" class="partial_refund_fields">
|
||||||
{l s='Partial refund'}
|
{l s='Partial refund'}
|
||||||
</th>
|
</th>
|
||||||
|
{if !$order->hasBeenDelivered()}
|
||||||
<th style="width: 8%;text-align:center;">
|
<th style="width: 8%;text-align:center;">
|
||||||
{l s='Action'}
|
{l s='Action'}
|
||||||
</th>
|
</th>
|
||||||
|
{/if}
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{foreach from=$products item=product key=k}
|
{foreach from=$products item=product key=k}
|
||||||
|
|||||||
@@ -108,12 +108,13 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
elseif ($order->hasBeenPaid()) $type = $this->l('Standard refund');
|
elseif ($order->hasBeenPaid()) $type = $this->l('Standard refund');
|
||||||
else $type = $this->l('Cancel products');
|
else $type = $this->l('Cancel products');
|
||||||
|
|
||||||
$this->toolbar_btn['new'] = array(
|
if (!$order->hasBeenDelivered())
|
||||||
'short' => 'Create',
|
$this->toolbar_btn['new'] = array(
|
||||||
'href' => '',
|
'short' => 'Create',
|
||||||
'desc' => $this->l('Add a product'),
|
'href' => '',
|
||||||
'class' => 'add_product'
|
'desc' => $this->l('Add a product'),
|
||||||
);
|
'class' => 'add_product'
|
||||||
|
);
|
||||||
$this->toolbar_btn['standard_refund'] = array(
|
$this->toolbar_btn['standard_refund'] = array(
|
||||||
'short' => 'Create',
|
'short' => 'Create',
|
||||||
'href' => '',
|
'href' => '',
|
||||||
@@ -1098,11 +1099,12 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
// Return value
|
// Return value
|
||||||
$res = true;
|
$res = true;
|
||||||
|
|
||||||
|
$order = new Order(Tools::getValue('id_order'));
|
||||||
$order_detail = new OrderDetail(Tools::getValue('product_id_order_detail'));
|
$order_detail = new OrderDetail(Tools::getValue('product_id_order_detail'));
|
||||||
if (Tools::isSubmit('product_invoice'))
|
if (Tools::isSubmit('product_invoice'))
|
||||||
$order_invoice = new OrderInvoice(Tools::getValue('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_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);
|
$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))
|
if (!Validate::isLoadedObject($order_detail))
|
||||||
die(Tools::jsonEncode(array(
|
die(Tools::jsonEncode(array(
|
||||||
@@ -1283,12 +1285,25 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
'error' => Tools::displayError('Can\'t load Invoice object')
|
'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(
|
die(Tools::jsonEncode(array(
|
||||||
'result' => false,
|
'result' => false,
|
||||||
'error' => Tools::displayError('Can\'t edit this Order Detail for this order')
|
'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'))
|
if (!empty($order_invoice) && $order_invoice->id_order != Tools::getValue('id_order'))
|
||||||
die(Tools::jsonEncode(array(
|
die(Tools::jsonEncode(array(
|
||||||
'result' => false,
|
'result' => false,
|
||||||
@@ -1331,6 +1346,13 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
'result' => false,
|
'result' => false,
|
||||||
'error' => Tools::displayError('Can\'t delete this Order Detail for this order')
|
'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)
|
protected function getProducts($order)
|
||||||
|
|||||||
Reference in New Issue
Block a user