Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
9c31e6b2db
@ -113,10 +113,16 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
|
||||
|
||||
// Regle gestion compte compta
|
||||
$codetouse='';
|
||||
if ($type == 'customer') $codetouse = $this->prefixcustomeraccountancycode;
|
||||
if ($type == 'supplier') $codetouse = $this->prefixsupplieraccountancycode;
|
||||
if ($type == 'customer') $codetouse.= (! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
|
||||
if ($type == 'supplier') $codetouse.= (! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
|
||||
if ($type == 'customer')
|
||||
{
|
||||
$codetouse = $this->prefixcustomeraccountancycode;
|
||||
$codetouse.= (! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
|
||||
}
|
||||
else if ($type == 'supplier')
|
||||
{
|
||||
$codetouse = $this->prefixsupplieraccountancycode;
|
||||
$codetouse.= (! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
|
||||
}
|
||||
$codetouse=strtoupper(preg_replace('/([^a-z0-9])/i','',$codetouse));
|
||||
|
||||
$is_dispo = $this->verif($db, $codetouse, $societe, $type);
|
||||
@ -147,11 +153,11 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode
|
||||
{
|
||||
$sql = "SELECT ";
|
||||
if ($type == 'customer') $sql.= "code_compta";
|
||||
if ($type == 'supplier') $sql.= "code_compta_fournisseur";
|
||||
else if ($type == 'supplier') $sql.= "code_compta_fournisseur";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe";
|
||||
$sql.= " WHERE ";
|
||||
if ($type == 'customer') $sql.= "code_compta";
|
||||
if ($type == 'supplier') $sql.= "code_compta_fournisseur";
|
||||
else if ($type == 'supplier') $sql.= "code_compta_fournisseur";
|
||||
$sql.= " = '".$this->db->escape($code)."'";
|
||||
if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id;
|
||||
|
||||
|
||||
@ -434,7 +434,7 @@ foreach ($dirsociete as $dirroot)
|
||||
|
||||
$modulequalified=1;
|
||||
if (! empty($module->version)) {
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
|
||||
else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
|
||||
}
|
||||
|
||||
|
||||
@ -212,11 +212,11 @@ class Societe extends CommonObject
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe (nom, entity, datec, datea, fk_user_creat, canvas, status, ref_int, ref_ext, fk_stcomm)";
|
||||
$sql.= " VALUES ('".$this->db->escape($this->name)."', ".$conf->entity.", '".$this->db->idate($now)."', '".$this->db->idate($now)."'";
|
||||
$sql.= ", ".($user->id > 0 ? "'".$user->id."'":"null");
|
||||
$sql.= ", ".($this->canvas ? "'".$this->canvas."'":"null");
|
||||
$sql.= ", ".(! empty($user->id) ? "'".$user->id."'":"null");
|
||||
$sql.= ", ".(! empty($this->canvas) ? "'".$this->canvas."'":"null");
|
||||
$sql.= ", ".$this->status;
|
||||
$sql.= ", ".($this->ref_int ? "'".$this->ref_int."'":"null");
|
||||
$sql.= ", ".($this->ref_ext ? "'".$this->ref_ext."'":"null");
|
||||
$sql.= ", ".(! empty($this->ref_int) ? "'".$this->ref_int."'":"null");
|
||||
$sql.= ", ".(! empty($this->ref_ext) ? "'".$this->ref_ext."'":"null");
|
||||
$sql.= ", 0)";
|
||||
|
||||
dol_syslog(get_class($this)."::create sql=".$sql);
|
||||
@ -413,8 +413,8 @@ class Societe extends CommonObject
|
||||
$this->idprof2 = trim($this->idprof2);
|
||||
$this->idprof3 = trim($this->idprof3);
|
||||
$this->idprof4 = trim($this->idprof4);
|
||||
$this->idprof5 = trim($this->idprof5);
|
||||
$this->idprof6 = trim($this->idprof6);
|
||||
$this->idprof5 = (! empty($this->idprof5)?trim($this->idprof5):'');
|
||||
$this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):'');
|
||||
$this->prefix_comm = trim($this->prefix_comm);
|
||||
|
||||
$this->tva_assuj = trim($this->tva_assuj);
|
||||
@ -455,6 +455,32 @@ class Societe extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
$customer=false;
|
||||
if (! empty($allowmodcodeclient) && ! empty($this->client))
|
||||
{
|
||||
// Attention get_codecompta peut modifier le code suivant le module utilise
|
||||
if (empty($this->code_compta))
|
||||
{
|
||||
$ret=$this->get_codecompta('customer');
|
||||
if ($ret < 0) return -1;
|
||||
}
|
||||
|
||||
$customer=true;
|
||||
}
|
||||
|
||||
$supplier=false;
|
||||
if (! empty($allowmodcodefournisseur) && ! empty($this->fournisseur))
|
||||
{
|
||||
// Attention get_codecompta peut modifier le code suivant le module utilise
|
||||
if (empty($this->code_compta_fournisseur))
|
||||
{
|
||||
$ret=$this->get_codecompta('supplier');
|
||||
if ($ret < 0) return -1;
|
||||
}
|
||||
|
||||
$supplier=true;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Check name is required and codes are ok or unique.
|
||||
@ -467,20 +493,20 @@ class Societe extends CommonObject
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET ";
|
||||
$sql .= "nom = '" . $this->db->escape($this->name) ."'"; // Required
|
||||
$sql .= ",ref_ext = " .($this->ref_ext?"'".$this->db->escape($this->ref_ext) ."'":"null");
|
||||
$sql .= ",ref_ext = " .(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext) ."'":"null");
|
||||
$sql .= ",datea = '".$this->db->idate($now)."'";
|
||||
$sql .= ",address = '" . $this->db->escape($this->address) ."'";
|
||||
|
||||
$sql .= ",cp = ".($this->zip?"'".$this->zip."'":"null");
|
||||
$sql .= ",ville = ".($this->town?"'".$this->db->escape($this->town)."'":"null");
|
||||
$sql .= ",cp = ".(! empty($this->zip)?"'".$this->zip."'":"null");
|
||||
$sql .= ",ville = ".(! empty($this->town)?"'".$this->db->escape($this->town)."'":"null");
|
||||
|
||||
$sql .= ",fk_departement = '" . ($this->state_id?$this->state_id:'0') ."'";
|
||||
$sql .= ",fk_pays = '" . ($this->country_id?$this->country_id:'0') ."'";
|
||||
$sql .= ",fk_departement = '" . (! empty($this->state_id)?$this->state_id:'0') ."'";
|
||||
$sql .= ",fk_pays = '" . (! empty($this->country_id)?$this->country_id:'0') ."'";
|
||||
|
||||
$sql .= ",tel = ".($this->phone?"'".$this->db->escape($this->phone)."'":"null");
|
||||
$sql .= ",fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null");
|
||||
$sql .= ",email = ".($this->email?"'".$this->db->escape($this->email)."'":"null");
|
||||
$sql .= ",url = ".($this->url?"'".$this->db->escape($this->url)."'":"null");
|
||||
$sql .= ",tel = ".(! empty($this->phone)?"'".$this->db->escape($this->phone)."'":"null");
|
||||
$sql .= ",fax = ".(! empty($this->fax)?"'".$this->db->escape($this->fax)."'":"null");
|
||||
$sql .= ",email = ".(! empty($this->email)?"'".$this->db->escape($this->email)."'":"null");
|
||||
$sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null");
|
||||
|
||||
$sql .= ",siren = '". $this->db->escape($this->idprof1) ."'";
|
||||
$sql .= ",siret = '". $this->db->escape($this->idprof2) ."'";
|
||||
@ -499,44 +525,36 @@ class Societe extends CommonObject
|
||||
|
||||
$sql .= ",capital = ".$this->capital;
|
||||
|
||||
$sql .= ",prefix_comm = ".($this->prefix_comm?"'".$this->db->escape($this->prefix_comm)."'":"null");
|
||||
$sql .= ",prefix_comm = ".(! empty($this->prefix_comm)?"'".$this->db->escape($this->prefix_comm)."'":"null");
|
||||
|
||||
$sql .= ",fk_effectif = ".($this->effectif_id?"'".$this->effectif_id."'":"null");
|
||||
$sql .= ",fk_effectif = ".(! empty($this->effectif_id)?"'".$this->effectif_id."'":"null");
|
||||
|
||||
$sql .= ",fk_typent = ".($this->typent_id?"'".$this->typent_id."'":"0");
|
||||
$sql .= ",fk_typent = ".(! empty($this->typent_id)?"'".$this->typent_id."'":"0");
|
||||
|
||||
$sql .= ",fk_forme_juridique = ".($this->forme_juridique_code?"'".$this->forme_juridique_code."'":"null");
|
||||
$sql .= ",fk_forme_juridique = ".(! empty($this->forme_juridique_code)?"'".$this->forme_juridique_code."'":"null");
|
||||
|
||||
$sql .= ",client = " . ($this->client?$this->client:0);
|
||||
$sql .= ",fournisseur = " . ($this->fournisseur?$this->fournisseur:0);
|
||||
$sql .= ",barcode = ".($this->barcode?"'".$this->barcode."'":"null");
|
||||
$sql .= ",default_lang = ".($this->default_lang?"'".$this->default_lang."'":"null");
|
||||
$sql .= ",logo = ".($this->logo?"'".$this->logo."'":"null");
|
||||
$sql .= ",client = " . (! empty($this->client)?$this->client:0);
|
||||
$sql .= ",fournisseur = " . (! empty($this->fournisseur)?$this->fournisseur:0);
|
||||
$sql .= ",barcode = ".(! empty($this->barcode)?"'".$this->barcode."'":"null");
|
||||
$sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->default_lang."'":"null");
|
||||
$sql .= ",logo = ".(! empty($this->logo)?"'".$this->logo."'":"null");
|
||||
|
||||
if ($allowmodcodeclient && $this->client)
|
||||
if ($customer)
|
||||
{
|
||||
//$this->check_codeclient();
|
||||
|
||||
$sql .= ", code_client = ".($this->code_client?"'".$this->db->escape($this->code_client)."'":"null");
|
||||
|
||||
// Attention get_codecompta peut modifier le code suivant le module utilise
|
||||
if (empty($this->code_compta)) $this->get_codecompta('customer');
|
||||
|
||||
$sql .= ", code_compta = ".($this->code_compta?"'".$this->db->escape($this->code_compta)."'":"null");
|
||||
$sql .= ", code_client = ".(! empty($this->code_client)?"'".$this->db->escape($this->code_client)."'":"null");
|
||||
$sql .= ", code_compta = ".(! empty($this->code_compta)?"'".$this->db->escape($this->code_compta)."'":"null");
|
||||
}
|
||||
|
||||
if ($allowmodcodefournisseur && $this->fournisseur)
|
||||
if ($supplier)
|
||||
{
|
||||
//$this->check_codefournisseur();
|
||||
|
||||
$sql .= ", code_fournisseur = ".($this->code_fournisseur?"'".$this->db->escape($this->code_fournisseur)."'":"null");
|
||||
|
||||
// Attention get_codecompta peut modifier le code suivant le module utilise
|
||||
if (empty($this->code_compta_fournisseur)) $this->get_codecompta('supplier');
|
||||
|
||||
$sql .= ", code_compta_fournisseur = ".($this->code_compta_fournisseur?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null");
|
||||
$sql .= ", code_fournisseur = ".(! empty($this->code_fournisseur)?"'".$this->db->escape($this->code_fournisseur)."'":"null");
|
||||
$sql .= ", code_compta_fournisseur = ".(! empty($this->code_compta_fournisseur)?"'".$this->db->escape($this->code_compta_fournisseur)."'":"null");
|
||||
}
|
||||
$sql .= ", fk_user_modif = ".($user->id > 0 ? "'".$user->id."'":"null");
|
||||
$sql .= ", fk_user_modif = ".(! empty($user->id)?"'".$user->id."'":"null");
|
||||
$sql .= " WHERE rowid = '" . $id ."'";
|
||||
|
||||
|
||||
@ -1803,30 +1821,44 @@ class Societe extends CommonObject
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if ($conf->global->SOCIETE_CODECOMPTA_ADDON)
|
||||
if (! empty($conf->global->SOCIETE_CODECOMPTA_ADDON))
|
||||
{
|
||||
$dirsociete=array_merge(array('/core/modules/societe/'),$conf->societe_modules);
|
||||
$file='';
|
||||
$dirsociete=array_merge(array('/core/modules/societe/'), $conf->societe_modules);
|
||||
foreach ($dirsociete as $dirroot)
|
||||
{
|
||||
$res=dol_include_once($dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.".php");
|
||||
if ($res) break;
|
||||
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.".php"))
|
||||
{
|
||||
$file=$dirroot.$conf->global->SOCIETE_CODECOMPTA_ADDON.".php";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$var = $conf->global->SOCIETE_CODECOMPTA_ADDON;
|
||||
$mod = new $var;
|
||||
if (! empty($file))
|
||||
{
|
||||
dol_include_once($file);
|
||||
|
||||
// Defini code compta dans $mod->code
|
||||
$result = $mod->get_code($this->db, $this, $type);
|
||||
$classname = $conf->global->SOCIETE_CODECOMPTA_ADDON;
|
||||
$mod = new $classname;
|
||||
|
||||
if ($type == 'customer') $this->code_compta = $mod->code;
|
||||
if ($type == 'supplier') $this->code_compta_fournisseur = $mod->code;
|
||||
// Defini code compta dans $mod->code
|
||||
$result = $mod->get_code($this->db, $this, $type);
|
||||
|
||||
return $result;
|
||||
if ($type == 'customer') $this->code_compta = $mod->code;
|
||||
else if ($type == 'supplier') $this->code_compta_fournisseur = $mod->code;
|
||||
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = 'ErrorAccountancyCodeNotDefined';
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 'customer') $this->code_compta = '';
|
||||
if ($type == 'supplier') $this->code_compta_fournisseur = '';
|
||||
else if ($type == 'supplier') $this->code_compta_fournisseur = '';
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user