make erp activable or not, centralize credentials (not in repo)
This commit is contained in:
parent
dd3b15996d
commit
fac0185cd9
@ -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');
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -1,12 +1,23 @@
|
||||
<?php
|
||||
if (!defined('ERP_ENABLED') || !ERP_ENABLED) {
|
||||
die('erp disabled');
|
||||
}
|
||||
if (!defined('ERP_URL') || !defined('ERP_DB') || !defined('ERP_USERNAME') || !defined('ERP_PASSWORD')) {
|
||||
die('ERP not found');
|
||||
}
|
||||
|
||||
ini_set("memory_limit","256M");
|
||||
|
||||
// CONFIGURATION
|
||||
// $url = 'http://roykin.erp-odoo.fr:8069';
|
||||
$url = 'http://137.74.168.224:8069';
|
||||
$db = 'roykin';
|
||||
$username = 'admin';
|
||||
$password = 'AdmiROYkin2016';
|
||||
// $url = 'http://137.74.168.224:8069';
|
||||
// $db = 'roykin';
|
||||
// $username = 'admin';
|
||||
// $password = 'AdmiROYkin2016';
|
||||
$url = ERP_URL;
|
||||
$db = ERP_DB;
|
||||
$username = ERP_USERNAME;
|
||||
$password = ERP_PASSWORD;
|
||||
|
||||
// Load Demo Data
|
||||
// $info = ripcord::client('https://demo.odoo.com/start')->start();
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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.'));
|
||||
|
@ -84,7 +84,7 @@
|
||||
<!-- Giveagift module -->
|
||||
<div id="HOOK_SHOPPING_CART">
|
||||
<div class="ctn">
|
||||
{$HOOK_SHOPPING_CART}
|
||||
{if isset($HOOK_SHOPPING_CART)}{$HOOK_SHOPPING_CART}{/if}
|
||||
</div>
|
||||
</div>
|
||||
<!-- /Giveagift module -->
|
||||
|
Loading…
Reference in New Issue
Block a user