diff --git a/config/config.inc.php b/config/config.inc.php index 36f62cc..1060730 100755 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -268,3 +268,6 @@ if (!defined('_MEDIA_SERVER_3_')) { /* Get smarty */ require_once($currentDir.'/smarty.config.inc.php'); $context->smarty = $smarty; + +/* include erp defines */ +require_once($currentDir.'/settings.erp.php'); diff --git a/config/defines.inc.php b/config/defines.inc.php index 374cc37..a6cdb29 100755 --- a/config/defines.inc.php +++ b/config/defines.inc.php @@ -230,32 +230,3 @@ if (!defined('_PS_JQUERY_VERSION_')) { define('_PS_JQUERY_VERSION_', '1.11.0'); } -define('TEST_DISABLE_ERP', false); - -if (defined('TEST_DISABLE_ERP') && TEST_DISABLE_ERP) { - // if ($_SERVER['REMOTE_ADDR'] != '88.163.22.99') { - // define('ERP_URL', 'http://roykin.erp-odoo.fr:8069'); - define('ERP_URL', ''); - define('ERP_DB', ''); - // } else { - // define('ERP_DB', 'roykin_test'); - // } - - define('ERP_USERNAME', ''); - define('ERP_PASSWORD', ''); - define('ERP_SCRIPT_TOKEN', 'Wq56lnviuXAQCMFHV9YHJnGk3RXMLMTkz0xhIu6U'); - -} -else { - // if ($_SERVER['REMOTE_ADDR'] != '88.163.22.99') { - // define('ERP_URL', 'http://roykin.erp-odoo.fr:8069'); - define('ERP_URL', 'http://137.74.168.224:8069'); - define('ERP_DB', 'roykin'); - // } else { - // define('ERP_DB', 'roykin_test'); - // } - - define('ERP_USERNAME', 'admin'); - define('ERP_PASSWORD', 'AdmiROYkin2016'); - define('ERP_SCRIPT_TOKEN', 'Wq56lnviuXAQCMFHV9YHJnGk3RXMLMTkz0xhIu6U'); -} diff --git a/erp/config.php b/erp/config.php index 5ae854c..c0737a1 100644 --- a/erp/config.php +++ b/erp/config.php @@ -1,12 +1,23 @@ start(); diff --git a/erp/oneorderUpdate.php b/erp/oneorderUpdate.php index 0f63912..e6dc311 100644 --- a/erp/oneorderUpdate.php +++ b/erp/oneorderUpdate.php @@ -5,7 +5,11 @@ require_once dirname(__FILE__).'/../config/config.inc.php'; require_once dirname(__FILE__).'/../modules/erporder/erporder.php'; - + if (!defined(ERP_ENABLED) || !ERP_ENABLED) { + die(); + } + + // $model = ripcord::client(ERP_URL.'/xmlrpc/2/object'); // $report = ripcord::client(ERP_URL.'/xmlrpc/2/report'); diff --git a/modules/erporder/erporder.php b/modules/erporder/erporder.php index 6d1024f..0a026be 100644 --- a/modules/erporder/erporder.php +++ b/modules/erporder/erporder.php @@ -27,16 +27,16 @@ if (!defined('_PS_VERSION_')) exit; -if (defined('TEST_DISABLE_ERP') && TEST_DISABLE_ERP) { - require_once __DIR__.'/Mocks/newOrder.php'; - require_once __DIR__.'/Mocks/MockRipcord.php'; - require_once __DIR__.'/Mocks/ErpTools.php'; -} -else { +if (defined('ERP_ENABLED') && ERP_ENABLED) { require 'newOrder.php'; require_once _PS_ROOT_DIR_.'/erp/ripcord/ripcord.php'; require_once _PS_ROOT_DIR_.'/erp/ErpTools.php'; } +elseif (defined('ERP_MOCK_ENABLED') && ERP_MOCK_ENABLED) { + require_once __DIR__.'/Mocks/newOrder.php'; + require_once __DIR__.'/Mocks/MockRipcord.php'; + require_once __DIR__.'/Mocks/ErpTools.php'; +} class Erporder extends Module { @@ -52,11 +52,7 @@ class Erporder extends Module $this->displayName = $this->l('Erp order'); $this->description = $this->l('Sync order in Odoo'); - if (defined('TEST_DISABLE_ERP') && TEST_DISABLE_ERP) { - $this->uid = '0'; - $this->model = MockRipcord::client(''); - } - else { + if (defined('ERP_ENABLED') && ERP_ENABLED) { $this->common = ripcord::client(ERP_URL.'/xmlrpc/2/common'); $this->common->version(); $this->uid = $this->common->authenticate(ERP_DB, ERP_USERNAME, ERP_PASSWORD, array()); @@ -64,6 +60,10 @@ class Erporder extends Module $this->model = ripcord::client(ERP_URL.'/xmlrpc/2/object'); $this->report = ripcord::client(ERP_URL.'/xmlrpc/2/report'); } + else if (defined('ERP_MOCK_ENABLED') && ERP_MOCK_ENABLED) { + $this->uid = '0'; + $this->model = MockRipcord::client(''); + } } public function install() @@ -76,6 +76,14 @@ class Erporder extends Module public function hookActionOrderStatusPostUpdate($params) { + if (!defined('ERP_ENABLED')) { + return; + } + + if (!ERP_ENABLED && (!defined('ERP_MOCK_ENABLED') || !ERP_MOCK_ENABLED)) { + return; + } + $order = new Order($params['id_order']); // if ($_SERVER['REMOTE_ADDR'] != '88.163.22.99') { @@ -251,12 +259,12 @@ class Erporder extends Module } } -if (defined('TEST_DISABLE_ERP') && TEST_DISABLE_ERP) { - if ($order_id) { - $res = $newOrder->exec_workflow((int)$order_id); + if (!ERP_ENABLED && defined('ERP_MOCK_ENABLED') && ERP_MOCK_ENABLED) { + if ($order_id) { + $res = $newOrder->exec_workflow((int)$order_id); + } + return; } - return; -} if ($isCB && $order_id) { @@ -286,9 +294,9 @@ if (defined('TEST_DISABLE_ERP') && TEST_DISABLE_ERP) { public function hookActionPDFInvoiceRender($params) { -if (defined('TEST_DISABLE_ERP') && TEST_DISABLE_ERP) { - return; -} + if (!defined('ERP_ENABLED') || !ERP_ENABLED) { + return; + } if (!Tools::getValue('id_order')) { die(Tools::displayError('Order was not found.')); diff --git a/themes/roykin/shopping-cart.tpl b/themes/roykin/shopping-cart.tpl index 7a523ab..5493eb8 100644 --- a/themes/roykin/shopping-cart.tpl +++ b/themes/roykin/shopping-cart.tpl @@ -84,7 +84,7 @@
- {$HOOK_SHOPPING_CART} + {if isset($HOOK_SHOPPING_CART)}{$HOOK_SHOPPING_CART}{/if}