disable synchro button in adm order
This commit is contained in:
parent
fac0185cd9
commit
f6d0d7a1c2
@ -170,15 +170,21 @@
|
||||
{l s='Partial refund'}
|
||||
</a>
|
||||
{/if}
|
||||
{if !$order->isSynchIntoErp()}
|
||||
<a class="btn btn-default" href="{$link->getAdminLink('AdminOrders')|escape:'html':'UTF-8'}&vieworder&id_order={$order->id|intval}&syncherp=1">
|
||||
<i class="icon-upload"></i>
|
||||
{l s='Synchroniser dans Odoo'}
|
||||
</a>
|
||||
{if $erp_enabled}
|
||||
{if !$order->isSynchIntoErp()}
|
||||
<a class="btn btn-default" href="{$link->getAdminLink('AdminOrders')|escape:'html':'UTF-8'}&vieworder&id_order={$order->id|intval}&syncherp=1">
|
||||
<i class="icon-upload"></i>
|
||||
{l s='Synchroniser dans Odoo'}
|
||||
</a>
|
||||
{else}
|
||||
<span class="span label label-inactive">
|
||||
<i class="icon-remove"></i>
|
||||
{l s='Synchronisée'}
|
||||
</span>
|
||||
{/if}
|
||||
{else}
|
||||
<span class="span label label-inactive">
|
||||
<i class="icon-remove"></i>
|
||||
{l s='Synchronisée'}
|
||||
{l s='Synchronisation désactivée'}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
@ -1522,37 +1522,43 @@ class AdminOrdersControllerCore extends AdminController
|
||||
}
|
||||
} elseif (Tools::getValue('syncherp') == 1) {
|
||||
|
||||
$id_order = Tools::getValue('id_order', false);
|
||||
if ($id_order) {
|
||||
$order = new Order((int)$id_order);
|
||||
if (!$order->isSynchIntoErp()) {
|
||||
if (!defined('ERP_ENABLED') || !ERP_ENABLED) {
|
||||
$this->errors[] = Tools::displayError('La synchro avec Odoo est actuellement désactivée.');
|
||||
}
|
||||
else {
|
||||
|
||||
if ($order->getIdErp() === 1) {
|
||||
$order->deletIdErpIfNotSynch();
|
||||
}
|
||||
$id_order = Tools::getValue('id_order', false);
|
||||
if ($id_order) {
|
||||
$order = new Order((int)$id_order);
|
||||
if (!$order->isSynchIntoErp()) {
|
||||
|
||||
$params['id_order'] = $order->id;
|
||||
$params['newOrderStatus'] = new StdClass();
|
||||
|
||||
if ($order->hasStatusInHistory(2)) {
|
||||
$params['newOrderStatus']->id = 2;
|
||||
} elseif ($order->hasStatusInHistory(10)) {
|
||||
$params['newOrderStatus']->id = 10;
|
||||
} elseif ($order->hasStatusInHistory(1)) {
|
||||
$params['newOrderStatus']->id = 1;
|
||||
}
|
||||
|
||||
if (!empty($params['newOrderStatus']->id)) {
|
||||
$erporder = Module::getInstanceByName('erporder');
|
||||
if ($erporder) {
|
||||
return $erporder->hookActionOrderStatusPostUpdate($params);
|
||||
if ($order->getIdErp() === 1) {
|
||||
$order->deletIdErpIfNotSynch();
|
||||
}
|
||||
} else {
|
||||
$sql = 'SELECT `name` FROM `'._DB_PREFIX_.'order_state_lang` WHERE `id_order_state` IN (1,2,10) AND id_lang = 1';
|
||||
$rows = Db::getInstance()->executeS($sql);
|
||||
|
||||
$txt .= implode('", "', array_column($rows, 'name'));
|
||||
$this->errors[] = Tools::displayError('Pas de synchro possible, la commande doit avoir eu l\'un des status suivants : "'.$txt.'"');
|
||||
$params['id_order'] = $order->id;
|
||||
$params['newOrderStatus'] = new StdClass();
|
||||
|
||||
if ($order->hasStatusInHistory(2)) {
|
||||
$params['newOrderStatus']->id = 2;
|
||||
} elseif ($order->hasStatusInHistory(10)) {
|
||||
$params['newOrderStatus']->id = 10;
|
||||
} elseif ($order->hasStatusInHistory(1)) {
|
||||
$params['newOrderStatus']->id = 1;
|
||||
}
|
||||
|
||||
if (!empty($params['newOrderStatus']->id)) {
|
||||
$erporder = Module::getInstanceByName('erporder');
|
||||
if ($erporder) {
|
||||
return $erporder->hookActionOrderStatusPostUpdate($params);
|
||||
}
|
||||
} else {
|
||||
$sql = 'SELECT `name` FROM `'._DB_PREFIX_.'order_state_lang` WHERE `id_order_state` IN (1,2,10) AND id_lang = 1';
|
||||
$rows = Db::getInstance()->executeS($sql);
|
||||
|
||||
$txt .= implode('", "', array_column($rows, 'name'));
|
||||
$this->errors[] = Tools::displayError('Pas de synchro possible, la commande doit avoir eu l\'un des status suivants : "'.$txt.'"');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1759,6 +1765,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
// Smarty assign
|
||||
$this->tpl_view_vars = array(
|
||||
'erp_enabled' => (defined('ERP_ENABLED') && ERP_ENABLED)?true:false,
|
||||
'order' => $order,
|
||||
'cart' => new Cart($order->id_cart),
|
||||
'customer' => $customer,
|
||||
|
Loading…
Reference in New Issue
Block a user