2
0
forked from Wavyzz/dolibarr

FIX update extrafields

This commit is contained in:
Laurent Destailleur
2018-08-12 16:29:26 +02:00
parent e1877625a0
commit 12e21b4886
14 changed files with 90 additions and 70 deletions

View File

@@ -464,7 +464,7 @@ class Adherent extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)

View File

@@ -142,7 +142,7 @@ class AdherentType extends CommonObject
/**
* Met a jour en base donnees du type
*
* @param User $user Object user making change
* @param User $user Object user making change
* @param int $notrigger 1=do not execute triggers, 0 otherwise
* @return int >0 if OK, < 0 if KO
*/
@@ -172,7 +172,7 @@ class AdherentType extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)

View File

@@ -1464,6 +1464,8 @@ class Propal extends CommonObject
*/
function update(User $user, $notrigger=0)
{
global $conf;
$error=0;
// Clean parameters
@@ -1512,17 +1514,23 @@ class Propal extends CommonObject
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
if (! $error)
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
if (! $notrigger)
$result=$this->insertExtraFields();
if ($result < 0)
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY', $user);
if ($result < 0) $error++;
// End call triggers
$error++;
}
}
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('PROPAL_MODIFY', $user);
if ($result < 0) $error++;
// End call triggers
}
// Commit or rollback
if ($error)
{

View File

@@ -3067,17 +3067,23 @@ class Commande extends CommonOrder
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
if (! $error)
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
if (! $notrigger)
$result=$this->insertExtraFields();
if ($result < 0)
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY', $user);
if ($result < 0) $error++;
// End call triggers
$error++;
}
}
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('ORDER_MODIFY', $user);
if ($result < 0) $error++;
// End call triggers
}
// Commit or rollback
if ($error)
{

View File

@@ -1549,6 +1549,8 @@ class Facture extends CommonInvoice
*/
function update(User $user, $notrigger=0)
{
global $conf;
$error=0;
// Clean parameters
@@ -1614,17 +1616,23 @@ class Facture extends CommonInvoice
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
if (! $error)
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
if (! $notrigger)
$result=$this->insertExtraFields();
if ($result < 0)
{
// Call trigger
$result=$this->call_trigger('BILL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
$error++;
}
}
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('BILL_MODIFY',$user);
if ($result < 0) $error++;
// End call triggers
}
// Commit or rollback
if ($error)
{

View File

@@ -371,15 +371,12 @@ class Contact extends CommonObject
$action='update';
// Actions on extra fields
if (! $error)
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$result=$this->insertExtraFields();
if ($result < 0)
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
$error++;
}
}

View File

@@ -925,16 +925,13 @@ class Contrat extends CommonObject
}
}
if (! $error)
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
// Insert contacts commerciaux ('SALESREPSIGN','contrat')
@@ -1283,18 +1280,7 @@ class Contrat extends CommonObject
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Call triggers
$result=$this->call_trigger('CONTRACT_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
}
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -1303,6 +1289,14 @@ class Contrat extends CommonObject
}
}
if (! $error && ! $notrigger)
{
// Call triggers
$result=$this->call_trigger('CONTRACT_MODIFY',$user);
if ($result < 0) { $error++; }
// End call triggers
}
// Commit or rollback
if ($error)
{

View File

@@ -7044,15 +7044,12 @@ abstract class CommonObject
}
// Update extrafield
if (! $error)
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
$result=$this->insertExtraFields();
if ($result < 0)
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
$error++;
}
}

View File

@@ -313,7 +313,7 @@ class Expedition extends CommonObject
}
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -541,8 +541,7 @@ class Expedition extends CommonObject
*/
$result=$this->fetch_thirdparty();
// Retreive all extrafield
// fetch optionals attributes and labels
// Retreive extrafields
$this->fetch_optionals();
/*
@@ -2412,7 +2411,8 @@ class ExpeditionLigne extends CommonObjectLine
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet");
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)

View File

@@ -222,7 +222,7 @@ class Fichinter extends CommonObject
if (! $resql) $error++;
}
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -285,6 +285,8 @@ class Fichinter extends CommonObject
$this->fk_project = 0;
}
$error = 0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET ";
@@ -299,8 +301,16 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
if ($this->db->query($sql))
{
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
}
if (! $notrigger)
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('FICHINTER_MODIFY',$user);
@@ -372,8 +382,7 @@ class Fichinter extends CommonObject
if ($this->statut == 0) $this->brouillon = 1;
// Retreive all extrafield
// fetch optionals attributes and labels
// Retreive extrafields
$this->fetch_optionals();
/*

View File

@@ -916,7 +916,7 @@ class Product extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)

View File

@@ -754,6 +754,7 @@ class Societe extends CommonObject
function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1)
{
global $langs,$conf,$hookmanager;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (empty($id)) $id = $this->id;
@@ -1053,7 +1054,7 @@ class Societe extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)

View File

@@ -1013,7 +1013,7 @@ class SupplierProposal extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -1022,7 +1022,7 @@ class SupplierProposal extends CommonObject
}
}
if (! $erro && ! $notrigger)
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('PROPAL_SUPPLIER_CREATE',$user);

View File

@@ -135,7 +135,7 @@ class User extends CommonObject
public $default_c_exp_tax_cat;
public $default_range;
public $fields=array(
'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'),
@@ -1581,7 +1581,7 @@ class User extends CommonObject
$action='update';
// Actions on extra fields
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
$result=$this->insertExtraFields();
if ($result < 0)