<?xml version="1.0" encoding="UTF-8"?>
<modification>
    <code>module_generator_order_id</code>
    <name>Generator Order ID</name>
    <version>0.5.3.0</version>
    <author>aauwwo</author>
    <link>http://www.opencart.com/index.php?route=marketplace/extension&amp;filter_member=aauwwo</link>

	<file path="catalog/model/checkout/order.php">
		<operation>
			<search><![CDATA[$order_id = $this->db->getLastId();]]></search>
			<add position="after"><![CDATA[
        if ($this->config->get('module_generator_status')) {
           $next_order_id = $order_id + mt_rand($this->config->get('module_generator_order_min'),$this->config->get('module_generator_order_max'));

           $this->db->query("ALTER TABLE `" . DB_PREFIX . "order` AUTO_INCREMENT = " . (int)$next_order_id . "");
        }
			]]></add>
		</operation>
	</file>

	<file path="admin/model/sale/order.php">
		<operation>
			<search><![CDATA[$invoice_no = $query->row['invoice_no'] + 1;]]></search>
			<add position="replace"><![CDATA[
               if ($this->config->get('module_generator_invoice_status')) {
                  if ($this->config->get('module_generator_invoice_type')) {
                      $invoice_no = $order_id;
                  } else {
                      $invoice_no = $query->row['invoice_no'] + mt_rand($this->config->get('module_generator_invoice_min'),$this->config->get('module_generator_invoice_max'));
                  }
               } else {
			      $invoice_no = $query->row['invoice_no'] + 1;
               }
			]]></add>
		</operation>
		<operation>
			<search><![CDATA[$invoice_no = 1;]]></search>
			<add position="replace"><![CDATA[
               if ($this->config->get('module_generator_invoice_status')) {
                  if ($this->config->get('module_generator_invoice_type')) {
                      $invoice_no = $order_id;
                  } else {
                      $invoice_no = mt_rand($this->config->get('module_generator_invoice_min'),$this->config->get('module_generator_invoice_max'));
                  }
               } else {
			      $invoice_no = 1;
               }
			]]></add>
		</operation>
	</file>

	<file path="catalog/model/checkout/order.php">
		<operation error="skip">
			<search><![CDATA[$invoice_no = $query->row['invoice_no'] + 1;]]></search>
			<add position="replace"><![CDATA[
               if ($this->config->get('module_generator_invoice_status')) {
                  if ($this->config->get('module_generator_invoice_type')) {
                      $invoice_no = $order_id;
                  } else {
                      $invoice_no = $query->row['invoice_no'] + mt_rand($this->config->get('module_generator_invoice_min'),$this->config->get('module_generator_invoice_max'));
                  }
               } else {
			      $invoice_no = $query->row['invoice_no'] + 1;
               }
			]]></add>
		</operation>
		<operation error="skip">
			<search><![CDATA[$invoice_no = 1;]]></search>
			<add position="replace"><![CDATA[
               if ($this->config->get('module_generator_invoice_status')) {
                  if ($this->config->get('module_generator_invoice_type')) {
                      $invoice_no = $order_id;
                  } else {
                      $invoice_no = mt_rand($this->config->get('module_generator_invoice_min'),$this->config->get('module_generator_invoice_max'));
                  }
               } else {
			      $invoice_no = 1;
               }
			]]></add>
		</operation>
	</file>

</modification>