// fix calculation issue on product addition

// all elements are correctly updated when we adding, editing or deleting a product
This commit is contained in:
aFolletete
2011-12-17 16:20:03 +00:00
parent 039b2388b9
commit ef46bd8819
6 changed files with 715 additions and 599 deletions
@@ -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}&nbsp;
{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">
{if sizeof($invoices_collection)}
<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}
<option value="{$invoice->id}">#{Configuration::get('PS_INVOICE_PREFIX', $current_id_lang)}{'%06d'|sprintf:$invoice->number}</option>
{/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>
+4 -103
View File
@@ -218,66 +218,8 @@
<fieldset style="width: 100%">
<legend><img src="../img/admin/details.gif" /> {l s='Documents'}</legend>
<table class="table" width="100%;" cellspacing="0" cellpadding="0">
<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}
<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}&nbsp;
{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>
{* Include document template *}
{include file='orders/_documents.tpl'}
</fieldset>
<br />
@@ -364,7 +306,7 @@
</select>
</td>
<td>
<select name="payment_invoice">
<select name="payment_invoice" id="payment_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>
{/foreach}
@@ -406,48 +348,7 @@
</div>
<div class="clear" style="margin-bottom: 10px;"></div>
<table class="table" width="100%" cellspacing="0" cellpadding="0">
<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>
{include file='orders/_shipping.tpl'}
{if $carrierModuleCall}
{$carrierModuleCall}