Fix check of customer/supplier code
This commit is contained in:
parent
43d560830c
commit
f2b8c3c97d
@ -297,12 +297,14 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
|
|||||||
* @param DoliDB $db Handler acces base
|
* @param DoliDB $db Handler acces base
|
||||||
* @param string $code Code a verifier
|
* @param string $code Code a verifier
|
||||||
* @param Societe $soc Objet societe
|
* @param Societe $soc Objet societe
|
||||||
|
* @param int $type 0 = customer/prospect , 1 = supplier
|
||||||
* @return int 0 if available, <0 if KO
|
* @return int 0 if available, <0 if KO
|
||||||
*/
|
*/
|
||||||
function verif_dispo($db, $code, $soc)
|
function verif_dispo($db, $code, $soc, $type=0)
|
||||||
{
|
{
|
||||||
$sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
|
||||||
$sql.= " WHERE code_client = '".$code."'";
|
if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'";
|
||||||
|
else $sql.= " WHERE code_client = '".$code."'";
|
||||||
if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
|
if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
|
|||||||
@ -182,7 +182,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
|
|||||||
{
|
{
|
||||||
if ($this->verif_syntax($code) >= 0)
|
if ($this->verif_syntax($code) >= 0)
|
||||||
{
|
{
|
||||||
$is_dispo = $this->verif_dispo($db, $code, $soc);
|
$is_dispo = $this->verif_dispo($db, $code, $soc, $type);
|
||||||
if ($is_dispo <> 0)
|
if ($is_dispo <> 0)
|
||||||
{
|
{
|
||||||
$result=-3;
|
$result=-3;
|
||||||
@ -205,7 +205,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::verif type=".$type." result=".$result);
|
dol_syslog(get_class($this)."::verif code=".$code." type=".$type." result=".$result);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,14 +216,16 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
|
|||||||
* @param DoliDB $db Handler acces base
|
* @param DoliDB $db Handler acces base
|
||||||
* @param string $code Code a verifier
|
* @param string $code Code a verifier
|
||||||
* @param Societe $soc Objet societe
|
* @param Societe $soc Objet societe
|
||||||
|
* @param int $type 0 = customer/prospect , 1 = supplier
|
||||||
* @return int 0 if available, <0 if KO
|
* @return int 0 if available, <0 if KO
|
||||||
*/
|
*/
|
||||||
function verif_dispo($db, $code, $soc)
|
function verif_dispo($db, $code, $soc, $type=0)
|
||||||
{
|
{
|
||||||
global $conf, $mc;
|
global $conf, $mc;
|
||||||
|
|
||||||
$sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe";
|
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
|
||||||
$sql.= " WHERE code_client = '".$code."'";
|
if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'";
|
||||||
|
else $sql.= " WHERE code_client = '".$code."'";
|
||||||
$sql.= " AND entity IN (".getEntity('societe').")";
|
$sql.= " AND entity IN (".getEntity('societe').")";
|
||||||
if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
|
if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
|
||||||
|
|
||||||
@ -244,7 +246,6 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
|
|||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -462,8 +462,8 @@ class Societe extends CommonObject
|
|||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts)
|
// For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts)
|
||||||
if ($this->code_client == -1) $this->get_codeclient($this,0);
|
if ($this->code_client == -1 || $this->code_client === 'auto') $this->get_codeclient($this,0);
|
||||||
if ($this->code_fournisseur == -1) $this->get_codefournisseur($this,1);
|
if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') $this->get_codefournisseur($this,1);
|
||||||
|
|
||||||
// Check more parameters (including mandatory setup
|
// Check more parameters (including mandatory setup
|
||||||
// If error, this->errors[] is filled
|
// If error, this->errors[] is filled
|
||||||
@ -812,8 +812,8 @@ class Societe extends CommonObject
|
|||||||
$this->barcode=trim($this->barcode);
|
$this->barcode=trim($this->barcode);
|
||||||
|
|
||||||
// For automatic creation
|
// For automatic creation
|
||||||
if ($this->code_client == -1) $this->get_codeclient($this,0);
|
if ($this->code_client == -1 || $this->code_client === 'auto') $this->get_codeclient($this,0);
|
||||||
if ($this->code_fournisseur == -1) $this->get_codefournisseur($this,1);
|
if ($this->code_fournisseur == -1 || $this->code_fournisseur === 'auto') $this->get_codefournisseur($this,1);
|
||||||
|
|
||||||
$this->code_compta=trim($this->code_compta);
|
$this->code_compta=trim($this->code_compta);
|
||||||
$this->code_compta_fournisseur=trim($this->code_compta_fournisseur);
|
$this->code_compta_fournisseur=trim($this->code_compta_fournisseur);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user