diff --git a/admin-dev/themes/template/orders/_documents.tpl b/admin-dev/themes/template/orders/_documents.tpl index f1df28292..e14560b55 100644 --- a/admin-dev/themes/template/orders/_documents.tpl +++ b/admin-dev/themes/template/orders/_documents.tpl @@ -10,30 +10,34 @@ {foreach from=$order->getDocuments() item=document} - {*if TYPE DOCUMENT = INVOICE *} - - {*/if*} + + {if get_class($document) eq 'OrderInvoice'} + + {elseif get_class($document) eq 'OrderSlip'} + + {/if} + {dateFormat date=$document->date_add} - Invoice - {$document->getInvoiceNumberFormatted($current_id_lang)} {l s='See the invoice'} + {if get_class($document) eq 'OrderInvoice'}Invoice{elseif get_class($document) eq 'OrderSlip'}Credit Slip{/if} + {if get_class($document) eq 'OrderInvoice'}{$document->getInvoiceNumberFormatted($current_id_lang)}{elseif get_class($document) eq 'OrderSlip'}{l s='#'}{'%06d'|sprintf:$document->id}{/if} {l s='See the invoice'} - {*if TYPE DOCUMENT = INVOICE *} + {if get_class($document) eq 'OrderInvoice'} {displayPrice price=$document->total_paid_tax_incl currency=$currency->id}  {if $document->getRestPaid()} ({displayPrice price=$document->getRestPaid() currency=$currency->id} {l s='not paid'}) {/if} - {*/if*} + {/if} - {*if TYPE DOCUMENT = INVOICE *} + {if get_class($document) eq 'OrderInvoice'} {if $document->getRestPaid()} {l s='Set payment form'} {/if} {if $document->note eq ''}{l s='Add note'}{else}{l s='Edit note'}{/if}note eq ''} class="js-disabled-action"{/if} /> - {*/if*} + {/if} - {*if TYPE DOCUMENT = INVOICE *} + {if get_class($document) eq 'OrderInvoice'}
@@ -49,7 +53,7 @@
- {*/if*} + {/if} {foreachelse} @@ -59,4 +63,4 @@ {/foreach} - \ No newline at end of file + diff --git a/admin-dev/themes/template/orders/view.tpl b/admin-dev/themes/template/orders/view.tpl index 54aeff585..198a94210 100755 --- a/admin-dev/themes/template/orders/view.tpl +++ b/admin-dev/themes/template/orders/view.tpl @@ -692,18 +692,7 @@ {/if} -
-
- {l s='Credit slip'}{l s='Credit slip'} - {if (!sizeof($slips))} - {l s='No slip for this order.'} - {else} - {foreach from=$slips item=slip} - ({dateFormat date=$slip['date_upd']}) : {l s='#'}{'%06d'|sprintf:$slip['id_order_slip']}
- {/foreach} - {/if} -
-
+
 


{l s='Back to list'}
diff --git a/classes/Collection.php b/classes/Collection.php index 7e64cc34c..b8aa35bd1 100644 --- a/classes/Collection.php +++ b/classes/Collection.php @@ -238,6 +238,7 @@ class CollectionCore implements Iterator, ArrayAccess, Countable */ public function getResults() { + $this->getAll(); return $this->results; } @@ -457,4 +458,4 @@ class CollectionCore implements Iterator, ArrayAccess, Countable $this->alias[$association] = 'a'.$this->alias_iterator++; return $this->alias[$association]; } -} \ No newline at end of file +} diff --git a/classes/order/Order.php b/classes/order/Order.php index 70c273533..d74f3c093 100644 --- a/classes/order/Order.php +++ b/classes/order/Order.php @@ -1394,10 +1394,18 @@ class OrderCore extends ObjectModel */ public function getDocuments() { - // TODO - $invoices = $this->getInvoicesCollection(); + $invoices = $this->getInvoicesCollection()->getResults(); + $order_slips = $this->getOrderSlipsCollection()->getResults(); + $documents = array_merge($invoices, $order_slips); + function sortDocuments($a, $b) + { + if ($a->date_add == $b->date_add) + return 0; + return ($a->date_add < $b->date_add) ? -1 : 1; + } + usort($documents, "sortDocuments"); - return $invoices; + return $documents; } public function getReturn() @@ -1424,6 +1432,21 @@ class OrderCore extends ObjectModel WHERE o.`id_order` = '.(int)$this->id); } + + /** + * + * Get all order_slips for the current order + * @since 1.5.0.1 + * @return Collection of Order slip + */ + public function getOrderSlipsCollection() + { + $order_slips = new Collection('OrderSlip'); + $order_slips->where('id_order', '=', $this->id); + return $order_slips; + } + + /** * * Get all invoices for the current order diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index b667bee8c..8ef855333 100755 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -1026,7 +1026,6 @@ class AdminOrdersControllerCore extends AdminController 'orders_total_paid_tax_incl' => $order->getOrdersTotalPaid(), // Get the sum of total_paid_tax_incl of the order with similar reference 'total_paid' => $order->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), - 'slips' => OrderSlip::getOrdersSlip($order->id_customer, $order->id), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier),