<?xml version="1.0" encoding="UTF-8"?>
<modification>
	<name>invoiceno-in-orderlist</name>
	<version>1.00</version>
	<author>Wayne Stams</author>
	<code>Invoice No. in Admin Order List</code>
	<file path="admin/controller/sale/order.php">
		<operation>
			<search trim="true" index="0"><![CDATA[foreach ($results as $result) {]]></search>
			<add position="after">
				<![CDATA[
					$invoice_no = $result['invoice_no'];
					$invoice_pre = $result['invoice_prefix'];

					$show_invoice = $invoice_no > 0;
				]]>
			</add>
		</operation>
		<operation>
			<search trim="true"><![CDATA['edit'          => $this->url->link('sale/order/edit', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $result['order_id'] . $url, true)]]></search>
			<add position="replace"><![CDATA[
			    'edit'          => $this->url->link('sale/order/edit', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $result['order_id'] . $url, true),
                'invoice_url'   => $this->url->link('sale/order/invoice', 'user_token=' . $this->session->data['user_token'] . '&order_id=' . $result['order_id'] . $url, true),
                'invoice_no'    => $invoice_pre . $invoice_no,
                'show_invoice'  => $show_invoice,
			]]>
			</add>
		</operation>
	</file>
	<file path="admin/view/template/sale/order_list.twig">
		<operation>
			<search trim="true"><![CDATA[<td class="text-right">{{ order.order_id }}</td>]]></search>
			<add position="replace"><![CDATA[<td class="text-right">{{ order.order_id }}{% if order.show_invoice %} <br/> <a target="_blank" href="{{ order.invoice_url }}">{{ order.invoice_no }}</a> {% endif %}</td>]]></add>
		</operation>
	</file>
    <file path="admin/model/sale/order.php">
        <operation>
            <search trim="true"><![CDATA[$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";]]></search>
            <add position="replace"><![CDATA[$sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified, o.invoice_no, o.invoice_prefix FROM `" . DB_PREFIX . "order` o";]]></add>
        </operation>
    </file>
</modification>