72 lines
2.2 KiB
PHP
72 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* Module allow edit existing orders and set rules for automatically generating numbers for orders and other documents
|
|
*
|
|
* @author Keshva <keshvathakur47@gmail.com>
|
|
* @copyright 2021 Keshva
|
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
*/
|
|
|
|
if (!defined('_PS_VERSION_'))
|
|
exit;
|
|
}
|
|
|
|
require_once(_PS_MODULE_DIR_.'modrefchange/classes/DocumentReferences.php');
|
|
|
|
class Order extends OrderCore
|
|
{
|
|
public function setInvoice($use_existing_payment = false)
|
|
{
|
|
if (!$this->hasInvoice()) {
|
|
parent::setInvoice($use_existing_payment);
|
|
DocumentReferences::storeReference('invoice', $this->id);
|
|
}
|
|
}
|
|
|
|
public function setDelivery()
|
|
{
|
|
$order_invoice_collection = $this->getInvoicesCollection();
|
|
foreach ($order_invoice_collection as $order_invoice) {
|
|
if ($order_invoice->delivery_number) {
|
|
continue;
|
|
}
|
|
DocumentReferences::storeReference('delivery_slip', $this->id, $order_invoice->id);
|
|
}
|
|
parent::setDelivery();
|
|
}
|
|
|
|
public static function generateReference()
|
|
{
|
|
return DocumentReferences::storeReference('order');
|
|
}
|
|
|
|
public function hasBeenDelivered()
|
|
{
|
|
if (version_compare(_PS_VERSION_, '1.7.7', '>=')) {
|
|
if (Context::getContext()->controller->controller_name == 'Admin') {
|
|
return false;
|
|
}
|
|
parent::hasBeenDelivered();
|
|
} else {
|
|
if (Tools::getIsset('action'))
|
|
if (Tools::getValue('action') == 'editProductOnOrder' || Tools::getValue('action') == 'deleteProductLine')
|
|
return false;
|
|
return parent::hasBeenDelivered();
|
|
}
|
|
}
|
|
|
|
public function hasBeenShipped()
|
|
{
|
|
if (version_compare(_PS_VERSION_, '1.7.7', '>=')) {
|
|
if (Context::getContext()->controller->controller_name == 'Admin') {
|
|
return false;
|
|
}
|
|
return parent::hasBeenShipped();
|
|
} else {
|
|
if (Tools::getIsset('action'))
|
|
if (Tools::getValue('action') == 'addProductOnOrder')
|
|
return false;
|
|
return parent::hasBeenShipped();
|
|
}
|
|
}
|
|
} |