// fix calculation issue on product addition
// all elements are correctly updated when we adding, editing or deleting a product
This commit is contained in:
@@ -0,0 +1,62 @@
|
|||||||
|
<table class="table" width="100%;" cellspacing="0" cellpadding="0" id="documents_table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width:20%">{l s='Date'}</th>
|
||||||
|
<th style="width:25%">{l s='Document'}</th>
|
||||||
|
<th style="width:20%">{l s='Number'}</th>
|
||||||
|
<th>{l s='Amount'}</th>
|
||||||
|
<th style="width:42px"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{foreach from=$order->getDocuments() item=document}
|
||||||
|
{*if TYPE DOCUMENT = INVOICE *}
|
||||||
|
<tr class="invoice_line" id="invoice_{$document->id}">
|
||||||
|
{*/if*}
|
||||||
|
<td class="document_date">{dateFormat date=$document->date_add}</td>
|
||||||
|
<td class="document_type">Invoice</td>
|
||||||
|
<td class="document_number"><a href="pdf.php?pdf&id_order_invoice={$document->id}">#{Configuration::get('PS_INVOICE_PREFIX', $current_id_lang)}{'%06d'|sprintf:$document->number}</a></td>
|
||||||
|
<td class="document_amount">
|
||||||
|
{*if TYPE DOCUMENT = INVOICE *}
|
||||||
|
{displayPrice price=$document->total_paid_tax_incl currency=$currency->id}
|
||||||
|
{if $document->getRestPaid()}
|
||||||
|
<span style="color:red;font-weight:bold;">({displayPrice price=$document->getRestPaid() currency=$currency->id} {l s='not paid'})</span>
|
||||||
|
{/if}
|
||||||
|
{*/if*}
|
||||||
|
</td>
|
||||||
|
<td class="right document_action">
|
||||||
|
{*if TYPE DOCUMENT = INVOICE *}
|
||||||
|
{if $document->getRestPaid()}
|
||||||
|
<a href="#" class="js-set-payment" data-amount="{$document->getRestPaid()}" data-id-invoice="{$document->id}" title="{l s='Set payment form'}"><img src="../img/admin/money_add.png" alt="{l s='Set payment form'}" /></a>
|
||||||
|
{/if}
|
||||||
|
<a href="#" onclick="$('#invoiceNote{$document->id}').show(); return false;" title="{if $document->note eq ''}{l s='Add note'}{else}{l s='Edit note'}{/if}"><img src="../img/admin/note.png" alt="{if $document->note eq ''}{l s='Add note'}{else}{l s='Edit note'}{/if}"{if $document->note eq ''} class="js-disabled-action"{/if} /></a>
|
||||||
|
{*/if*}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{*if TYPE DOCUMENT = INVOICE *}
|
||||||
|
<tr id="invoiceNote{$document->id}" style="display:none" class="current-edit">
|
||||||
|
<td colspan="5">
|
||||||
|
<form action="{$currentIndex}&viewOrder&id_order={$smarty.get.id_order|escape:'htmlall':'UTF-8'}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}" method="post">
|
||||||
|
<p>
|
||||||
|
<label for="editNote{$document->id}" class="t">{l s='Note'}</label>
|
||||||
|
<input type="hidden" name="id_order_invoice" value="{$document->id}" />
|
||||||
|
<textarea name="note" rows="10" cols="10" id="editNote{$document->id}" class="edit-note">{$document->note|escape:'htmlall':'UTF-8'}</textarea>
|
||||||
|
</p>
|
||||||
|
<p class="right">
|
||||||
|
<input type="submit" name="submitEditNote" value="{l s='Save'}" class="button" />
|
||||||
|
<input type="button" name="cancelNote" id="cancelNote" value="{l s='Cancel'}" onclick="$('#invoiceNote{$document->id}').hide();" class="button" />
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{*/if*}
|
||||||
|
{foreachelse}
|
||||||
|
<tr>
|
||||||
|
<td colspan="5" class="center">
|
||||||
|
<h3>{l s='No document is available'}</h3>
|
||||||
|
<p><a class="button" href="{$currentIndex}&viewOrder&submitGenerateInvoice&id_order={$smarty.get.id_order|escape:'htmlall':'UTF-8'}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}">{l s='Generate invoice'}</a></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<td style="display:none;" align="center" colspan="2">
|
<td style="display:none;" align="center" colspan="2">
|
||||||
{if sizeof($invoices_collection)}
|
{if sizeof($invoices_collection)}
|
||||||
<select name="add_product[invoice]" id="add_product_product_invoice" disabled="disabled">
|
<select name="add_product[invoice]" id="add_product_product_invoice" disabled="disabled">
|
||||||
<optgroup label="{l s='Existing'}">
|
<optgroup class="existing" label="{l s='Existing'}">
|
||||||
{foreach from=$invoices_collection item=invoice}
|
{foreach from=$invoices_collection item=invoice}
|
||||||
<option value="{$invoice->id}">#{Configuration::get('PS_INVOICE_PREFIX', $current_id_lang)}{'%06d'|sprintf:$invoice->number}</option>
|
<option value="{$invoice->id}">#{Configuration::get('PS_INVOICE_PREFIX', $current_id_lang)}{'%06d'|sprintf:$invoice->number}</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<table class="table" width="100%" cellspacing="0" cellpadding="0" id="shipping_table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width:30%">{l s='Date:'}</th>
|
||||||
|
<th>{l s='Type'}</th>
|
||||||
|
<th style="width:20%">{l s='Carrier'}</th>
|
||||||
|
<th>{l s='Weight'}</th>
|
||||||
|
<th style="width:15%">{l s='Shipping cost'}</th>
|
||||||
|
<th style="width:30%">{l s='Tracking number'}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{foreach from=$order->getShipping() item=line}
|
||||||
|
<tr>
|
||||||
|
<td>{$line.date_add}</td>
|
||||||
|
<td>{$line.type}</td>
|
||||||
|
<td>{$line.state_name}</td>
|
||||||
|
<td>{$line.weight|string_format:"%.3f"} {Configuration::get('PS_WEIGHT_UNIT')}</td>
|
||||||
|
<td>
|
||||||
|
{if $order->getTaxCalculationMethod() == $smarty.const.PS_TAX_INC}
|
||||||
|
{displayPrice price=$line.shipping_cost_tax_incl currency=$currency->id}
|
||||||
|
{else}
|
||||||
|
{displayPrice price=$line.shipping_cost_tax_excl currency=$currency->id}
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span id="shipping_number_show">{if $line.url && $line.tracking_number}<a href="{$line.url|replace:'@':$line.tracking_number}">{$line.tracking_number}</a>{else}{$line.tracking_number}{/if}</span>
|
||||||
|
{if $line.can_edit}
|
||||||
|
<form style="display: inline;" method="POST" action="{$link->getAdminLink('AdminOrders')}&vieworder&id_order={$smarty.get.id_order|escape:'htmlall':'UTF-8'}&id_order_invoice={if $line.id_order_invoice}{$line.id_order_invoice|escape:'htmlall':'UTF-8'}{else}0{/if}&id_carrier={if $line.id_carrier}{$line.id_carrier|escape:'htmlall':'UTF-8'}{else}0{/if}">
|
||||||
|
<span class="shipping_number_edit" style="display:none;">
|
||||||
|
<input type="text" name="tracking_number" value="{$line.tracking_number}" />
|
||||||
|
<input type="submit" class="button" name="submitShippingNumber" value="{l s='Update'}" />
|
||||||
|
</span>
|
||||||
|
<a href="#" class="edit_shipping_number_link"><img src="../img/admin/edit.gif" alt="{l s='Edit'}" /></a>
|
||||||
|
<a href="#" class="cancel_shipping_number_link" style="display: none;"><img src="../img/admin/disabled.gif" alt="{l s='Cancel'}" /></a>
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -218,66 +218,8 @@
|
|||||||
<fieldset style="width: 100%">
|
<fieldset style="width: 100%">
|
||||||
<legend><img src="../img/admin/details.gif" /> {l s='Documents'}</legend>
|
<legend><img src="../img/admin/details.gif" /> {l s='Documents'}</legend>
|
||||||
|
|
||||||
<table class="table" width="100%;" cellspacing="0" cellpadding="0">
|
{* Include document template *}
|
||||||
<thead>
|
{include file='orders/_documents.tpl'}
|
||||||
<tr>
|
|
||||||
<th style="width:20%">{l s='Date'}</th>
|
|
||||||
<th style="width:25%">{l s='Document'}</th>
|
|
||||||
<th style="width:20%">{l s='Number'}</th>
|
|
||||||
<th>{l s='Amount'}</th>
|
|
||||||
<th style="width:42px"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{foreach from=$order->getDocuments() item=document}
|
|
||||||
<tr>
|
|
||||||
<td>{dateFormat date=$document->date_add}</td>
|
|
||||||
<td>Invoice</td>
|
|
||||||
<td><a href="pdf.php?pdf&id_order_invoice={$document->id}">#{Configuration::get('PS_INVOICE_PREFIX', $current_id_lang)}{'%06d'|sprintf:$document->number}</a></td>
|
|
||||||
<td>
|
|
||||||
{*if TYPE DOCUMENT = INVOICE *}
|
|
||||||
{displayPrice price=$document->total_paid_tax_incl currency=$currency->id}
|
|
||||||
{if $document->getRestPaid()}
|
|
||||||
<span style="color:red;font-weight:bold;">({displayPrice price=$document->getRestPaid() currency=$currency->id} {l s='not paid'})</span>
|
|
||||||
{/if}
|
|
||||||
{*/if*}
|
|
||||||
</td>
|
|
||||||
<td class="right">
|
|
||||||
{*if TYPE DOCUMENT = INVOICE *}
|
|
||||||
{if $document->getRestPaid()}
|
|
||||||
<a href="#" class="js-set-payment" data-amount="{$document->getRestPaid()}" data-id-invoice="{$document->id}" title="{l s='Set payment form'}"><img src="../img/admin/money_add.png" alt="{l s='Set payment form'}" /></a>
|
|
||||||
{/if}
|
|
||||||
<a href="#" onclick="$('#invoiceNote{$document->id}').show(); return false;" title="{if $document->note eq ''}{l s='Add note'}{else}{l s='Edit note'}{/if}"><img src="../img/admin/note.png" alt="{if $document->note eq ''}{l s='Add note'}{else}{l s='Edit note'}{/if}"{if $document->note eq ''} class="js-disabled-action"{/if} /></a>
|
|
||||||
{*/if*}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{*if TYPE DOCUMENT = INVOICE *}
|
|
||||||
<tr id="invoiceNote{$document->id}" style="display:none" class="current-edit">
|
|
||||||
<td colspan="5">
|
|
||||||
<form action="{$currentIndex}&viewOrder&id_order={$smarty.get.id_order|escape:'htmlall':'UTF-8'}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}" method="post">
|
|
||||||
<p>
|
|
||||||
<label for="editNote{$document->id}" class="t">{l s='Note'}</label>
|
|
||||||
<input type="hidden" name="id_order_invoice" value="{$document->id}" />
|
|
||||||
<textarea name="note" rows="10" cols="10" id="editNote{$document->id}" class="edit-note">{$document->note|escape:'htmlall':'UTF-8'}</textarea>
|
|
||||||
</p>
|
|
||||||
<p class="right">
|
|
||||||
<input type="submit" name="submitEditNote" value="{l s='Save'}" class="button" />
|
|
||||||
<input type="button" name="cancelNote" id="cancelNote" value="{l s='Cancel'}" onclick="$('#invoiceNote{$document->id}').hide();" class="button" />
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{*/if*}
|
|
||||||
{foreachelse}
|
|
||||||
<tr>
|
|
||||||
<td colspan="5" class="center">
|
|
||||||
<h3>{l s='No document is available'}</h3>
|
|
||||||
<p><a class="button" href="{$currentIndex}&viewOrder&submitGenerateInvoice&id_order={$smarty.get.id_order|escape:'htmlall':'UTF-8'}&token={$smarty.get.token|escape:'htmlall':'UTF-8'}">{l s='Generate invoice'}</a></p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{/foreach}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
@@ -364,7 +306,7 @@
|
|||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select name="payment_invoice">
|
<select name="payment_invoice" id="payment_invoice">
|
||||||
{foreach from=$not_paid_invoices_collection item=invoice}
|
{foreach from=$not_paid_invoices_collection item=invoice}
|
||||||
<option value="{$invoice->id}" selected="selected">#{Configuration::get('PS_INVOICE_PREFIX', $current_id_lang)}{'%06d'|sprintf:$invoice->number}</option>
|
<option value="{$invoice->id}" selected="selected">#{Configuration::get('PS_INVOICE_PREFIX', $current_id_lang)}{'%06d'|sprintf:$invoice->number}</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
@@ -406,48 +348,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="clear" style="margin-bottom: 10px;"></div>
|
<div class="clear" style="margin-bottom: 10px;"></div>
|
||||||
|
|
||||||
<table class="table" width="100%" cellspacing="0" cellpadding="0">
|
{include file='orders/_shipping.tpl'}
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width:30%">{l s='Date:'}</th>
|
|
||||||
<th>{l s='Type'}</th>
|
|
||||||
<th style="width:20%">{l s='Carrier'}</th>
|
|
||||||
<th>{l s='Weight'}</th>
|
|
||||||
<th style="width:15%">{l s='Shipping cost'}</th>
|
|
||||||
<th style="width:30%">{l s='Tracking number'}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{foreach from=$order->getShipping() item=line}
|
|
||||||
<tr>
|
|
||||||
<td>{$line.date_add}</td>
|
|
||||||
<td>{$line.type}</td>
|
|
||||||
<td>{$line.state_name}</td>
|
|
||||||
<td>{$line.weight|string_format:"%.3f"} {Configuration::get('PS_WEIGHT_UNIT')}</td>
|
|
||||||
<td>
|
|
||||||
{if $order->getTaxCalculationMethod() == $smarty.const.PS_TAX_INC}
|
|
||||||
{displayPrice price=$line.shipping_cost_tax_incl currency=$currency->id}
|
|
||||||
{else}
|
|
||||||
{displayPrice price=$line.shipping_cost_tax_excl currency=$currency->id}
|
|
||||||
{/if}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span id="shipping_number_show">{if $line.url && $line.tracking_number}<a href="{$line.url|replace:'@':$line.tracking_number}">{$line.tracking_number}</a>{else}{$line.tracking_number}{/if}</span>
|
|
||||||
{if $line.can_edit}
|
|
||||||
<form style="display: inline;" method="POST" action="{$link->getAdminLink('AdminOrders')}&vieworder&id_order={$smarty.get.id_order|escape:'htmlall':'UTF-8'}&id_order_invoice={if $line.id_order_invoice}{$line.id_order_invoice|escape:'htmlall':'UTF-8'}{else}0{/if}&id_carrier={if $line.id_carrier}{$line.id_carrier|escape:'htmlall':'UTF-8'}{else}0{/if}">
|
|
||||||
<span class="shipping_number_edit" style="display:none;">
|
|
||||||
<input type="text" name="tracking_number" value="{$line.tracking_number}" />
|
|
||||||
<input type="submit" class="button" name="submitShippingNumber" value="{l s='Update'}" />
|
|
||||||
</span>
|
|
||||||
<a href="#" class="edit_shipping_number_link"><img src="../img/admin/edit.gif" alt="{l s='Edit'}" /></a>
|
|
||||||
<a href="#" class="cancel_shipping_number_link" style="display: none;"><img src="../img/admin/disabled.gif" alt="{l s='Cancel'}" /></a>
|
|
||||||
</form>
|
|
||||||
{/if}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{/foreach}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{if $carrierModuleCall}
|
{if $carrierModuleCall}
|
||||||
{$carrierModuleCall}
|
{$carrierModuleCall}
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
if (!$order->hasBeenDelivered())
|
if (!$order->hasBeenDelivered())
|
||||||
$this->toolbar_btn['new'] = array(
|
$this->toolbar_btn['new'] = array(
|
||||||
'short' => 'Create',
|
'short' => 'Create',
|
||||||
'href' => '',
|
'href' => '#',
|
||||||
'desc' => $this->l('Add a product'),
|
'desc' => $this->l('Add a product'),
|
||||||
'class' => 'add_product'
|
'class' => 'add_product'
|
||||||
);
|
);
|
||||||
@@ -959,7 +959,10 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
$product_informations = $_POST['add_product'];
|
$product_informations = $_POST['add_product'];
|
||||||
|
if (isset($_POST['add_invoice']))
|
||||||
$invoice_informations = $_POST['add_invoice'];
|
$invoice_informations = $_POST['add_invoice'];
|
||||||
|
else
|
||||||
|
$invoice_informations = array();
|
||||||
$product = new Product($product_informations['product_id'], false, $order->id_lang);
|
$product = new Product($product_informations['product_id'], false, $order->id_lang);
|
||||||
if (!Validate::isLoadedObject($product))
|
if (!Validate::isLoadedObject($product))
|
||||||
die(Tools::jsonEncode(array(
|
die(Tools::jsonEncode(array(
|
||||||
@@ -977,6 +980,9 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Total method
|
||||||
|
$total_method = Cart::BOTH_WITHOUT_SHIPPING;
|
||||||
|
|
||||||
// Create new cart
|
// Create new cart
|
||||||
$cart = new Cart();
|
$cart = new Cart();
|
||||||
$cart->id_group_shop = $order->id_group_shop;
|
$cart->id_group_shop = $order->id_group_shop;
|
||||||
@@ -1010,23 +1016,7 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
$reduction_tax_incl = $initial_prodcut_price_tax_incl - $product_informations['product_price_tax_incl'];
|
$reduction_tax_incl = $initial_prodcut_price_tax_incl - $product_informations['product_price_tax_incl'];
|
||||||
|
|
||||||
// FIXME Cart Rule isn't applied but correctly save in database
|
// TODO Use Specific price !!!
|
||||||
$cart_rule = new CartRule();
|
|
||||||
$cart_rule->id_customer = $order->id_customer;
|
|
||||||
$cart_rule->date_from = date('Y-m-d H:i:s', time());
|
|
||||||
$cart_rule->date_to = date('Y-m-d H:i:s', time() + 24 * 3600);
|
|
||||||
$cart_rule->quantity = 1;
|
|
||||||
$cart_rule->quantity_per_user = 1;
|
|
||||||
$cart_rule->minimum_amount_currency = $order->id_currency;
|
|
||||||
$cart_rule->reduction_product = $product->id;
|
|
||||||
$cart_rule->reduction_amount = $reduction_tax_incl;
|
|
||||||
$cart_rule->reduction_currency = $order->id_currency;
|
|
||||||
$cart_rule->reduction_tax = true;
|
|
||||||
$cart_rule->active = 1;
|
|
||||||
$cart_rule->add();
|
|
||||||
|
|
||||||
$cart->addCartRule($cart_rule->id);
|
|
||||||
$order->addCartRule($cart_rule->id, $cart_rule->name, $cart_rule->getContextualValue(true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If order is valid, we can create a new invoice or edit an existing invoice
|
// If order is valid, we can create a new invoice or edit an existing invoice
|
||||||
@@ -1036,10 +1026,11 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
// Create new invoice
|
// Create new invoice
|
||||||
if ($order_invoice->id == 0)
|
if ($order_invoice->id == 0)
|
||||||
{
|
{
|
||||||
|
// If we create a new invoice, we calculate shipping cost
|
||||||
|
$total_method = Cart::BOTH;
|
||||||
// Create Cart rule in order to make free shipping
|
// Create Cart rule in order to make free shipping
|
||||||
if (isset($invoice_informations['free_shipping']) && $invoice_informations['free_shipping'])
|
if (isset($invoice_informations['free_shipping']) && $invoice_informations['free_shipping'])
|
||||||
{
|
{
|
||||||
// FIXME Cart Rule isn't applied but correctly save in database
|
|
||||||
$cart_rule = new CartRule();
|
$cart_rule = new CartRule();
|
||||||
$cart_rule->id_customer = $order->id_customer;
|
$cart_rule->id_customer = $order->id_customer;
|
||||||
$cart_rule->name = array(
|
$cart_rule->name = array(
|
||||||
@@ -1055,6 +1046,7 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
$cart_rule->active = 1;
|
$cart_rule->active = 1;
|
||||||
$cart_rule->add();
|
$cart_rule->add();
|
||||||
|
|
||||||
|
// Add cart rule to cart and in order
|
||||||
$cart->addCartRule($cart_rule->id);
|
$cart->addCartRule($cart_rule->id);
|
||||||
$order->addCartRule($cart_rule->id, $cart_rule->name[Configuration::get('PS_LANG_DEFAULT')], $cart_rule->getContextualValue(true));
|
$order->addCartRule($cart_rule->id, $cart_rule->name[Configuration::get('PS_LANG_DEFAULT')], $cart_rule->getContextualValue(true));
|
||||||
}
|
}
|
||||||
@@ -1065,8 +1057,8 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
else
|
else
|
||||||
$order_invoice->number = Order::getLastInvoiceNumber() + 1;
|
$order_invoice->number = Order::getLastInvoiceNumber() + 1;
|
||||||
|
|
||||||
$order_invoice->total_paid_tax_excl = Tools::ps_round((float)$cart->getOrderTotal(false, Cart::BOTH), 2);
|
$order_invoice->total_paid_tax_excl = Tools::ps_round((float)$cart->getOrderTotal(false, $total_method), 2);
|
||||||
$order_invoice->total_paid_tax_incl = Tools::ps_round((float)$cart->getOrderTotal($use_taxes, Cart::BOTH), 2);
|
$order_invoice->total_paid_tax_incl = Tools::ps_round((float)$cart->getOrderTotal($use_taxes, $total_method), 2);
|
||||||
$order_invoice->total_products = (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
$order_invoice->total_products = (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||||
$order_invoice->total_products_wt = (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS);
|
$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_excl = (float)$cart->getTotalShippingCost(null, false);
|
||||||
@@ -1097,8 +1089,8 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
// Update current invoice
|
// Update current invoice
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$order_invoice->total_paid_tax_excl += Tools::ps_round((float)($cart->getOrderTotal(false, Cart::BOTH)), 2);
|
$order_invoice->total_paid_tax_excl += Tools::ps_round((float)($cart->getOrderTotal(false, $total_method)), 2);
|
||||||
$order_invoice->total_paid_tax_incl += Tools::ps_round((float)($cart->getOrderTotal($use_taxes, Cart::BOTH)), 2);
|
$order_invoice->total_paid_tax_incl += Tools::ps_round((float)($cart->getOrderTotal($use_taxes, $total_method)), 2);
|
||||||
$order_invoice->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
$order_invoice->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||||
$order_invoice->total_products_wt += (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS);
|
$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_excl += (float)$cart->getTotalShippingCost(null, false);
|
||||||
@@ -1117,9 +1109,9 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
$order->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
$order->total_products += (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
|
||||||
$order->total_products_wt += (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS);
|
$order->total_products_wt += (float)$cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS);
|
||||||
|
|
||||||
$order->total_paid += Tools::ps_round((float)($cart->getOrderTotal(true, Cart::BOTH)), 2);
|
$order->total_paid += Tools::ps_round((float)($cart->getOrderTotal(true, $total_method)), 2);
|
||||||
$order->total_paid_tax_excl += Tools::ps_round((float)($cart->getOrderTotal(false, Cart::BOTH)), 2);
|
$order->total_paid_tax_excl += Tools::ps_round((float)($cart->getOrderTotal(false, $total_method)), 2);
|
||||||
$order->total_paid_tax_incl += Tools::ps_round((float)($cart->getOrderTotal($use_taxes, Cart::BOTH)), 2);
|
$order->total_paid_tax_incl += Tools::ps_round((float)($cart->getOrderTotal($use_taxes, $total_method)), 2);
|
||||||
|
|
||||||
// discount
|
// discount
|
||||||
$order->total_discounts += (float)abs($cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS));
|
$order->total_discounts += (float)abs($cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS));
|
||||||
@@ -1133,20 +1125,36 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
// Get the last product
|
// Get the last product
|
||||||
$product = $products[max(array_keys($products))];
|
$product = $products[max(array_keys($products))];
|
||||||
|
|
||||||
|
// Get invoices collection
|
||||||
|
$invoice_collection = $order->getInvoicesCollection();
|
||||||
|
|
||||||
|
$invoice_array = array();
|
||||||
|
foreach($invoice_collection as $invoice)
|
||||||
|
{
|
||||||
|
$invoice->name = '#'.Configuration::get('PS_INVOICE_PREFIX', Context::getContext()->language->id).sprintf('%06d', $invoice->number);
|
||||||
|
$invoice_array[] = $invoice;
|
||||||
|
}
|
||||||
|
|
||||||
// Assign to smarty informations in order to show the new product line
|
// Assign to smarty informations in order to show the new product line
|
||||||
$this->context->smarty->assign(array(
|
$this->context->smarty->assign(array(
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'order' => $order,
|
'order' => $order,
|
||||||
'currency' => new Currency($order->id_currency),
|
'currency' => new Currency($order->id_currency),
|
||||||
'can_edit' => $this->tabAccess['edit'],
|
'can_edit' => $this->tabAccess['edit'],
|
||||||
'invoices_collection' => $order->getInvoicesCollection()
|
'invoices_collection' => $invoice_collection,
|
||||||
|
'current_id_lang' => Context::getContext()->language->id,
|
||||||
|
'link' => Context::getContext()->link,
|
||||||
|
'current_index' => self::$currentIndex
|
||||||
));
|
));
|
||||||
|
|
||||||
die(Tools::jsonEncode(array(
|
die(Tools::jsonEncode(array(
|
||||||
'result' => true,
|
'result' => true,
|
||||||
'view' => $this->context->smarty->fetch('orders/_product_line.tpl'),
|
'view' => $this->context->smarty->fetch('orders/_product_line.tpl'),
|
||||||
'can_edit' => $this->tabAccess['add'],
|
'can_edit' => $this->tabAccess['add'],
|
||||||
'order' => $order
|
'order' => $order,
|
||||||
|
'invoices' => $invoice_array,
|
||||||
|
'documents_html' => $this->context->smarty->fetch('orders/_documents.tpl'),
|
||||||
|
'shipping_html' => $this->context->smarty->fetch('orders/_shipping.tpl')
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1274,9 +1282,23 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
'product' => $product,
|
'product' => $product,
|
||||||
'order' => $order,
|
'order' => $order,
|
||||||
'currency' => new Currency($order->id_currency),
|
'currency' => new Currency($order->id_currency),
|
||||||
'can_edit' => $this->tabAccess['edit']
|
'can_edit' => $this->tabAccess['edit'],
|
||||||
|
'invoices_collection' => $invoice_collection,
|
||||||
|
'current_id_lang' => Context::getContext()->language->id,
|
||||||
|
'link' => Context::getContext()->link,
|
||||||
|
'current_index' => self::$currentIndex
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Get invoices collection
|
||||||
|
$invoice_collection = $order->getInvoicesCollection();
|
||||||
|
|
||||||
|
$invoice_array = array();
|
||||||
|
foreach($invoice_collection as $invoice)
|
||||||
|
{
|
||||||
|
$invoice->name = '#'.Configuration::get('PS_INVOICE_PREFIX', Context::getContext()->language->id).sprintf('%06d', $invoice->number);
|
||||||
|
$invoice_array[] = $invoice;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$res)
|
if (!$res)
|
||||||
die(Tools::jsonEncode(array(
|
die(Tools::jsonEncode(array(
|
||||||
'result' => $res,
|
'result' => $res,
|
||||||
@@ -1287,8 +1309,11 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
'result' => $res,
|
'result' => $res,
|
||||||
'view' => $this->context->smarty->fetch('orders/_product_line.tpl'),
|
'view' => $this->context->smarty->fetch('orders/_product_line.tpl'),
|
||||||
'can_edit' => $this->tabAccess['add'],
|
'can_edit' => $this->tabAccess['add'],
|
||||||
'invoices_collection' => $order->getInvoicesCollection(),
|
'invoices_collection' => $invoice_collection,
|
||||||
'order' => $order
|
'order' => $order,
|
||||||
|
'invoices' => $invoice_array,
|
||||||
|
'documents_html' => $this->context->smarty->fetch('orders/_documents.tpl'),
|
||||||
|
'shipping_html' => $this->context->smarty->fetch('orders/_shipping.tpl')
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1353,9 +1378,32 @@ class AdminOrdersControllerCore extends AdminController
|
|||||||
'error' => Tools::displayError('Error occured on deletion of this product line')
|
'error' => Tools::displayError('Error occured on deletion of this product line')
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
// Get invoices collection
|
||||||
|
$invoice_collection = $order->getInvoicesCollection();
|
||||||
|
|
||||||
|
$invoice_array = array();
|
||||||
|
foreach($invoice_collection as $invoice)
|
||||||
|
{
|
||||||
|
$invoice->name = '#'.Configuration::get('PS_INVOICE_PREFIX', Context::getContext()->language->id).sprintf('%06d', $invoice->number);
|
||||||
|
$invoice_array[] = $invoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign to smarty informations in order to show the new product line
|
||||||
|
$this->context->smarty->assign(array(
|
||||||
|
'order' => $order,
|
||||||
|
'currency' => new Currency($order->id_currency),
|
||||||
|
'invoices_collection' => $invoice_collection,
|
||||||
|
'current_id_lang' => Context::getContext()->language->id,
|
||||||
|
'link' => Context::getContext()->link,
|
||||||
|
'current_index' => self::$currentIndex
|
||||||
|
));
|
||||||
|
|
||||||
die(Tools::jsonEncode(array(
|
die(Tools::jsonEncode(array(
|
||||||
'result' => $res,
|
'result' => $res,
|
||||||
'order' => $order
|
'order' => $order,
|
||||||
|
'invoices' => $invoice_array,
|
||||||
|
'documents_html' => $this->context->smarty->fetch('orders/_documents.tpl'),
|
||||||
|
'shipping_html' => $this->context->smarty->fetch('orders/_shipping.tpl')
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+234
-171
@@ -27,6 +27,224 @@
|
|||||||
var current_product = null;
|
var current_product = null;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
// Init all events
|
||||||
|
init();
|
||||||
|
|
||||||
|
$('img.js-disabled-action').css({"opacity":0.5});
|
||||||
|
});
|
||||||
|
|
||||||
|
function updateInvoice(invoices)
|
||||||
|
{
|
||||||
|
// Update select on product edition line
|
||||||
|
$('.edit_product_invoice').each(function() {
|
||||||
|
var selected = $(this).children('option:selected').val();
|
||||||
|
|
||||||
|
$(this).children('option').remove();
|
||||||
|
for(i in invoices)
|
||||||
|
{
|
||||||
|
// Create new option
|
||||||
|
var option = $('<option>'+invoices[i].name+'</option>').attr('value', invoices[i].id);
|
||||||
|
if (invoices[i].id == selected)
|
||||||
|
option.attr('selected', true);
|
||||||
|
|
||||||
|
$(this).append(option);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update select on product addition line
|
||||||
|
$('#add_product_product_invoice').each(function() {
|
||||||
|
var parent = $(this).children('optgroup.existing');
|
||||||
|
parent.children('option').remove();
|
||||||
|
for(i in invoices)
|
||||||
|
{
|
||||||
|
// Create new option
|
||||||
|
var option = $('<option>'+invoices[i].name+'</option>').attr('value', invoices[i].id);
|
||||||
|
|
||||||
|
parent.append(option);
|
||||||
|
}
|
||||||
|
parent.children('option:first').attr('selected', true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update select on product addition line
|
||||||
|
$('#payment_invoice').each(function() {
|
||||||
|
$(this).children('option').remove();
|
||||||
|
for(i in invoices)
|
||||||
|
{
|
||||||
|
// Create new option
|
||||||
|
var option = $('<option>'+invoices[i].name+'</option>').attr('value', invoices[i].id);
|
||||||
|
|
||||||
|
$(this).append(option);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateDocuments(documents_html)
|
||||||
|
{
|
||||||
|
$('#documents_table').attr('id', 'documents_table_old');
|
||||||
|
$('#documents_table_old').after(documents_html);
|
||||||
|
$('#documents_table_old').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateShipping(shipping_html)
|
||||||
|
{
|
||||||
|
$('#shipping_table').attr('id', 'shipping_table_old');
|
||||||
|
$('#shipping_table_old').after(shipping_html);
|
||||||
|
$('#shipping_table_old').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateWarehouseList(warehouse_list)
|
||||||
|
{
|
||||||
|
$('#add_product_product_warehouse_area').hide();
|
||||||
|
if (warehouse_list.length > 1)
|
||||||
|
{
|
||||||
|
$('#add_product_product_warehouse_area').show();
|
||||||
|
}
|
||||||
|
var order_warehouse_list = $('#warehouse_list').val().split(',');
|
||||||
|
$('#add_product_warehouse').html('');
|
||||||
|
var warehouse_selected = false;
|
||||||
|
$.each(warehouse_list, function() {
|
||||||
|
if (warehouse_selected == false && $.inArray(this.id_warehouse, order_warehouse_list))
|
||||||
|
warehouse_selected = this.id_warehouse;
|
||||||
|
|
||||||
|
$('#add_product_warehouse').append($('<option value="' + this.id_warehouse + '">' + this.name + '</option>'));
|
||||||
|
});
|
||||||
|
if (warehouse_selected)
|
||||||
|
$('#add_product_warehouse').val(warehouse_selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addProductRefreshTotal()
|
||||||
|
{
|
||||||
|
var quantity = parseInt($('#add_product_product_quantity').val());
|
||||||
|
if (quantity < 1|| isNaN(quantity))
|
||||||
|
quantity = 1;
|
||||||
|
if (use_taxes)
|
||||||
|
var price = parseFloat($('#add_product_product_price_tax_incl').val());
|
||||||
|
else
|
||||||
|
var price = parseFloat($('#add_product_product_price_tax_excl').val());
|
||||||
|
|
||||||
|
if (price < 0 || isNaN(price))
|
||||||
|
price = 0;
|
||||||
|
var total = makeTotalProductCaculation(quantity, price);
|
||||||
|
$('#add_product_product_total').html(formatCurrency(total, currency_format, currency_sign, currency_blank));
|
||||||
|
}
|
||||||
|
|
||||||
|
function editProductRefreshTotal(element)
|
||||||
|
{
|
||||||
|
element = element.parent().parent().parent();
|
||||||
|
|
||||||
|
var quantity = parseInt(element.find('td .edit_product_quantity').val());
|
||||||
|
if (quantity < 1 || isNaN(quantity))
|
||||||
|
quantity = 1;
|
||||||
|
if (use_taxes)
|
||||||
|
var price = parseFloat(element.find('td .edit_product_price_tax_incl').val());
|
||||||
|
else
|
||||||
|
var price = parseFloat(element.find('td .edit_product_price_tax_excl').val())
|
||||||
|
|
||||||
|
if (price < 0 || isNaN(price))
|
||||||
|
price = 0;
|
||||||
|
|
||||||
|
var total = makeTotalProductCaculation(quantity, price);
|
||||||
|
element.find('td.total_product').html(formatCurrency(total, currency_format, currency_sign, currency_blank));
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeTotalProductCaculation(quantity, price)
|
||||||
|
{
|
||||||
|
return Math.round(quantity * price * 100) / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addViewOrderDetailRow(view)
|
||||||
|
{
|
||||||
|
html = $(view);
|
||||||
|
html.find('td').hide();
|
||||||
|
$('tr#new_invoice').hide();
|
||||||
|
$('tr#new_product').hide();
|
||||||
|
|
||||||
|
// Initialize fields
|
||||||
|
closeAddProduct();
|
||||||
|
|
||||||
|
$('tr#new_product').before(html);
|
||||||
|
html.find('td').each(function() {
|
||||||
|
if (!$(this).is('.product_invoice'))
|
||||||
|
$(this).fadeIn('slow');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshProductLineView(element, view)
|
||||||
|
{
|
||||||
|
var new_product_line = $(view);
|
||||||
|
new_product_line.find('td').hide();
|
||||||
|
|
||||||
|
var current_product_line = element.parent().parent();
|
||||||
|
current_product_line.before(new_product_line);
|
||||||
|
current_product_line.remove();
|
||||||
|
|
||||||
|
new_product_line.find('td').each(function() {
|
||||||
|
if (!$(this).is('.product_invoice'))
|
||||||
|
$(this).fadeIn('slow');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateAmounts(order)
|
||||||
|
{
|
||||||
|
$('#total_products td.amount').fadeOut('slow', function() {
|
||||||
|
$(this).html(formatCurrency(parseFloat(order.total_products_wt), currency_format, currency_sign, currency_blank));
|
||||||
|
$(this).fadeIn('slow');
|
||||||
|
});
|
||||||
|
$('#total_discounts td.amount').fadeOut('slow', function() {
|
||||||
|
$(this).html(formatCurrency(parseFloat(order.total_discounts_tax_incl), currency_format, currency_sign, currency_blank));
|
||||||
|
$(this).fadeIn('slow');
|
||||||
|
});
|
||||||
|
if (order.total_discounts_tax_incl > 0)
|
||||||
|
$('#total_discounts').slideDown('slow');
|
||||||
|
$('#total_wrapping td.amount').fadeOut('slow', function() {
|
||||||
|
$(this).html(formatCurrency(parseFloat(order.total_wrapping_tax_incl), currency_format, currency_sign, currency_blank));
|
||||||
|
$(this).fadeIn('slow');
|
||||||
|
});
|
||||||
|
if (order.total_wrapping_tax_incl > 0)
|
||||||
|
$('#total_wrapping').slideDown('slow');
|
||||||
|
$('#total_shipping td.amount').fadeOut('slow', function() {
|
||||||
|
$(this).html(formatCurrency(parseFloat(order.total_shipping_tax_incl), currency_format, currency_sign, currency_blank));
|
||||||
|
$(this).fadeIn('slow');
|
||||||
|
});
|
||||||
|
$('#total_order td.amount').fadeOut('slow', function() {
|
||||||
|
$(this).html(formatCurrency(parseFloat(order.total_paid_tax_incl), currency_format, currency_sign, currency_blank));
|
||||||
|
$(this).fadeIn('slow');
|
||||||
|
});
|
||||||
|
$('.total_paid').fadeOut('slow', function() {
|
||||||
|
$(this).html(formatCurrency(parseFloat(order.total_paid_tax_incl), currency_format, currency_sign, currency_blank));
|
||||||
|
$(this).fadeIn('slow');
|
||||||
|
});
|
||||||
|
$('.alert').slideDown('slow');
|
||||||
|
$('#product_number').fadeOut('slow', function() {
|
||||||
|
var old_quantity = parseInt($(this).html());
|
||||||
|
$(this).html(old_quantity + 1);
|
||||||
|
$(this).fadeIn('slow');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeAddProduct()
|
||||||
|
{
|
||||||
|
$('tr#new_invoice').hide();
|
||||||
|
$('tr#new_product').hide();
|
||||||
|
|
||||||
|
// Initialize fields
|
||||||
|
$('tr#new_product select, tr#new_product input').each(function() {
|
||||||
|
if (!$(this).is('.button'))
|
||||||
|
$(this).val('')
|
||||||
|
});
|
||||||
|
$('tr#new_invoice select, tr#new_invoice input').val('');
|
||||||
|
$('#add_product_product_quantity').val('1');
|
||||||
|
$('#add_product_product_attribute_id option').remove();
|
||||||
|
$('#add_product_product_attribute_area').hide();
|
||||||
|
$('#add_product_product_stock').html('0');
|
||||||
|
current_product = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method allow to initialize all events
|
||||||
|
*/
|
||||||
|
function init()
|
||||||
|
{
|
||||||
$('.add_product').click(function() {
|
$('.add_product').click(function() {
|
||||||
$('.cancel_product_change_link:visible').trigger('click');
|
$('.cancel_product_change_link:visible').trigger('click');
|
||||||
$('.add_product_fields').show();
|
$('.add_product_fields').show();
|
||||||
@@ -132,26 +350,6 @@ $(document).ready(function() {
|
|||||||
$('#add_product_product_stock').html(current_product.combinations[$(this).val()].qty_in_stock);
|
$('#add_product_product_stock').html(current_product.combinations[$(this).val()].qty_in_stock);
|
||||||
});
|
});
|
||||||
|
|
||||||
function populateWarehouseList(warehouse_list)
|
|
||||||
{
|
|
||||||
$('#add_product_product_warehouse_area').hide();
|
|
||||||
if (warehouse_list.length > 1)
|
|
||||||
{
|
|
||||||
$('#add_product_product_warehouse_area').show();
|
|
||||||
}
|
|
||||||
var order_warehouse_list = $('#warehouse_list').val().split(',');
|
|
||||||
$('#add_product_warehouse').html('');
|
|
||||||
var warehouse_selected = false;
|
|
||||||
$.each(warehouse_list, function() {
|
|
||||||
if (warehouse_selected == false && $.inArray(this.id_warehouse, order_warehouse_list))
|
|
||||||
warehouse_selected = this.id_warehouse;
|
|
||||||
|
|
||||||
$('#add_product_warehouse').append($('<option value="' + this.id_warehouse + '">' + this.name + '</option>'));
|
|
||||||
});
|
|
||||||
if (warehouse_selected)
|
|
||||||
$('#add_product_warehouse').val(warehouse_selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
$('input#add_product_product_quantity').keyup(function() {
|
$('input#add_product_product_quantity').keyup(function() {
|
||||||
var quantity = parseInt($(this).val());
|
var quantity = parseInt($(this).val());
|
||||||
if (quantity < 1 || isNaN(quantity))
|
if (quantity < 1 || isNaN(quantity))
|
||||||
@@ -215,8 +413,16 @@ $(document).ready(function() {
|
|||||||
{
|
{
|
||||||
if (data.result)
|
if (data.result)
|
||||||
{
|
{
|
||||||
|
go = false;
|
||||||
addViewOrderDetailRow(data.view);
|
addViewOrderDetailRow(data.view);
|
||||||
updateAmounts(data.order);
|
updateAmounts(data.order);
|
||||||
|
updateInvoice(data.invoices);
|
||||||
|
updateDocuments(data.documents_html);
|
||||||
|
updateShipping(data.shipping_html);
|
||||||
|
|
||||||
|
// Initialize all events
|
||||||
|
init();
|
||||||
|
|
||||||
$('.standard_refund_fields').hide();
|
$('.standard_refund_fields').hide();
|
||||||
$('.partial_refund_fields').hide();
|
$('.partial_refund_fields').hide();
|
||||||
}
|
}
|
||||||
@@ -228,26 +434,6 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#edit_shipping_cost_link').click(function() {
|
|
||||||
$('#shipping_cost_show').hide();
|
|
||||||
$('#shipping_cost_edit').show();
|
|
||||||
|
|
||||||
$('#edit_shipping_cost_link').hide();
|
|
||||||
$('#cancel_shipping_cost_link').show();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#cancel_shipping_cost_link').click(function() {
|
|
||||||
$('#shipping_cost_show').show();
|
|
||||||
$('#shipping_cost_edit').hide();
|
|
||||||
|
|
||||||
$('#edit_shipping_cost_link').show();
|
|
||||||
$('#cancel_shipping_cost_link').hide();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.edit_shipping_number_link').click(function() {
|
$('.edit_shipping_number_link').click(function() {
|
||||||
$(this).parent().find('.shipping_number_show').hide();
|
$(this).parent().find('.shipping_number_show').hide();
|
||||||
$(this).parent().find('.shipping_number_edit').show();
|
$(this).parent().find('.shipping_number_edit').show();
|
||||||
@@ -403,6 +589,12 @@ $(document).ready(function() {
|
|||||||
{
|
{
|
||||||
refreshProductLineView(element, data.view);
|
refreshProductLineView(element, data.view);
|
||||||
updateAmounts(data.order);
|
updateAmounts(data.order);
|
||||||
|
updateInvoice(data.invoices);
|
||||||
|
updateDocuments(data.documents_html);
|
||||||
|
|
||||||
|
// Initialize all events
|
||||||
|
init();
|
||||||
|
|
||||||
$('.standard_refund_fields').hide();
|
$('.standard_refund_fields').hide();
|
||||||
$('.partial_refund_fields').hide();
|
$('.partial_refund_fields').hide();
|
||||||
}
|
}
|
||||||
@@ -471,6 +663,8 @@ $(document).ready(function() {
|
|||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
updateAmounts(data.order);
|
updateAmounts(data.order);
|
||||||
|
updateInvoice(data.invoices);
|
||||||
|
updateDocuments(data.documents_html);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
alert(data.error);
|
alert(data.error);
|
||||||
@@ -489,139 +683,8 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('img.js-disabled-action').css({"opacity":0.5});
|
|
||||||
});
|
|
||||||
|
|
||||||
function addProductRefreshTotal()
|
|
||||||
{
|
|
||||||
var quantity = parseInt($('#add_product_product_quantity').val());
|
|
||||||
if (quantity < 1|| isNaN(quantity))
|
|
||||||
quantity = 1;
|
|
||||||
if (use_taxes)
|
|
||||||
var price = parseFloat($('#add_product_product_price_tax_incl').val());
|
|
||||||
else
|
|
||||||
var price = parseFloat($('#add_product_product_price_tax_excl').val());
|
|
||||||
|
|
||||||
if (price < 0 || isNaN(price))
|
|
||||||
price = 0;
|
|
||||||
var total = makeTotalProductCaculation(quantity, price);
|
|
||||||
$('#add_product_product_total').html(formatCurrency(total, currency_format, currency_sign, currency_blank));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function editProductRefreshTotal(element)
|
|
||||||
{
|
|
||||||
element = element.parent().parent().parent();
|
|
||||||
|
|
||||||
var quantity = parseInt(element.find('td .edit_product_quantity').val());
|
|
||||||
if (quantity < 1 || isNaN(quantity))
|
|
||||||
quantity = 1;
|
|
||||||
if (use_taxes)
|
|
||||||
var price = parseFloat(element.find('td .edit_product_price_tax_incl').val());
|
|
||||||
else
|
|
||||||
var price = parseFloat(element.find('td .edit_product_price_tax_excl').val())
|
|
||||||
|
|
||||||
if (price < 0 || isNaN(price))
|
|
||||||
price = 0;
|
|
||||||
|
|
||||||
var total = makeTotalProductCaculation(quantity, price);
|
|
||||||
element.find('td.total_product').html(formatCurrency(total, currency_format, currency_sign, currency_blank));
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeTotalProductCaculation(quantity, price)
|
|
||||||
{
|
|
||||||
return Math.round(quantity * price * 100) / 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
function addViewOrderDetailRow(view)
|
|
||||||
{
|
|
||||||
html = $(view);
|
|
||||||
html.find('td').hide();
|
|
||||||
$('tr#new_invoice').hide();
|
|
||||||
$('tr#new_product').hide();
|
|
||||||
|
|
||||||
// Initialize fields
|
|
||||||
closeAddProduct();
|
|
||||||
|
|
||||||
$('tr#new_product').before(html);
|
|
||||||
html.find('td').each(function() {
|
|
||||||
if (!$(this).is('.product_invoice'))
|
|
||||||
$(this).fadeIn('slow');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function refreshProductLineView(element, view)
|
|
||||||
{
|
|
||||||
var new_product_line = $(view);
|
|
||||||
new_product_line.find('td').hide();
|
|
||||||
|
|
||||||
var current_product_line = element.parent().parent();
|
|
||||||
current_product_line.before(new_product_line);
|
|
||||||
current_product_line.remove();
|
|
||||||
|
|
||||||
new_product_line.find('td').each(function() {
|
|
||||||
if (!$(this).is('.product_invoice'))
|
|
||||||
$(this).fadeIn('slow');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateAmounts(order)
|
|
||||||
{
|
|
||||||
$('#total_products td.amount').fadeOut('slow', function() {
|
|
||||||
$(this).html(formatCurrency(parseFloat(order.total_products_wt), currency_format, currency_sign, currency_blank));
|
|
||||||
$(this).fadeIn('slow');
|
|
||||||
});
|
|
||||||
$('#total_discounts td.amount').fadeOut('slow', function() {
|
|
||||||
$(this).html(formatCurrency(parseFloat(order.total_discounts_tax_incl), currency_format, currency_sign, currency_blank));
|
|
||||||
$(this).fadeIn('slow');
|
|
||||||
});
|
|
||||||
if (order.total_discounts_tax_incl > 0)
|
|
||||||
$('#total_discounts').slideDown('slow');
|
|
||||||
$('#total_wrapping td.amount').fadeOut('slow', function() {
|
|
||||||
$(this).html(formatCurrency(parseFloat(order.total_wrapping_tax_incl), currency_format, currency_sign, currency_blank));
|
|
||||||
$(this).fadeIn('slow');
|
|
||||||
});
|
|
||||||
if (order.total_wrapping_tax_incl > 0)
|
|
||||||
$('#total_wrapping').slideDown('slow');
|
|
||||||
$('#total_shipping td.amount').fadeOut('slow', function() {
|
|
||||||
$(this).html(formatCurrency(parseFloat(order.total_shipping_tax_incl), currency_format, currency_sign, currency_blank));
|
|
||||||
$(this).fadeIn('slow');
|
|
||||||
});
|
|
||||||
$('#total_order td.amount').fadeOut('slow', function() {
|
|
||||||
$(this).html(formatCurrency(parseFloat(order.total_paid_tax_incl), currency_format, currency_sign, currency_blank));
|
|
||||||
$(this).fadeIn('slow');
|
|
||||||
});
|
|
||||||
$('.total_paid').fadeOut('slow', function() {
|
|
||||||
$(this).html(formatCurrency(parseFloat(order.total_paid_tax_incl), currency_format, currency_sign, currency_blank));
|
|
||||||
$(this).fadeIn('slow');
|
|
||||||
});
|
|
||||||
$('.alert').slideDown('slow');
|
|
||||||
$('#product_number').fadeOut('slow', function() {
|
|
||||||
var old_quantity = parseInt($(this).html());
|
|
||||||
$(this).html(old_quantity + 1);
|
|
||||||
$(this).fadeIn('slow');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeAddProduct()
|
|
||||||
{
|
|
||||||
$('tr#new_invoice').hide();
|
|
||||||
$('tr#new_product').hide();
|
|
||||||
|
|
||||||
// Initialize fields
|
|
||||||
$('tr#new_product select, tr#new_product input').each(function() {
|
|
||||||
if (!$(this).is('.button'))
|
|
||||||
$(this).val('')
|
|
||||||
});
|
|
||||||
$('tr#new_invoice select, tr#new_invoice input').val('');
|
|
||||||
$('#add_product_product_quantity').val('1');
|
|
||||||
$('#add_product_product_attribute_id option').remove();
|
|
||||||
$('#add_product_product_attribute_area').hide();
|
|
||||||
$('#add_product_product_stock').html('0');
|
|
||||||
current_product = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user