Fix: Amlioration de la gestion du code client et code fournisseur. Debuggage.
This commit is contained in:
parent
c6ccf20ca8
commit
cc6e66f513
@ -30,11 +30,11 @@
|
||||
|
||||
require_once(DOL_DOCUMENT_ROOT."/includes/modules/societe/modules_societe.class.php");
|
||||
|
||||
|
||||
/**
|
||||
\class mod_codeclient_leopard
|
||||
\brief Classe permettant la gestion leopard des codes tiers
|
||||
*/
|
||||
|
||||
class mod_codeclient_leopard extends ModeleThirdPartyCode
|
||||
{
|
||||
/*
|
||||
|
||||
@ -35,7 +35,6 @@ require_once(DOL_DOCUMENT_ROOT."/includes/modules/societe/modules_societe.class.
|
||||
\class mod_codeclient_lion
|
||||
\brief Classe permettant la gestion lion des codes tiers
|
||||
*/
|
||||
|
||||
class mod_codeclient_lion extends ModeleThirdPartyCode
|
||||
{
|
||||
var $nom; // Nom du modele
|
||||
@ -51,7 +50,7 @@ class mod_codeclient_lion extends ModeleThirdPartyCode
|
||||
{
|
||||
$this->nom = "Lion";
|
||||
$this->code_modifiable = 0;
|
||||
$this->code_modifiable_invalide = 0;
|
||||
$this->code_modifiable_invalide = 1;
|
||||
$this->code_modifiable_null = 1;
|
||||
$this->code_null = 0;
|
||||
}
|
||||
@ -80,31 +79,45 @@ class mod_codeclient_lion extends ModeleThirdPartyCode
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code a vérifier/corriger
|
||||
* \param $soc Objet societe
|
||||
* \return int <0 si ko
|
||||
* \return int <0 si KO, 0 si OK
|
||||
*/
|
||||
function verif($db, &$code, $soc)
|
||||
{
|
||||
$result=0;
|
||||
$code = strtoupper(trim($code));
|
||||
|
||||
if ($this->verif_syntax($code) == 0)
|
||||
{
|
||||
$is_dispo = $this->verif_dispo($db, $code);
|
||||
if ($is_dispo <> 0)
|
||||
{
|
||||
return -3;
|
||||
}
|
||||
if (! $code && $this->code_null)
|
||||
{
|
||||
$result=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($code) == 0)
|
||||
{
|
||||
return -2;
|
||||
if ($this->verif_syntax($code) >= 0)
|
||||
{
|
||||
$is_dispo = $this->verif_dispo($db, $code, $soc);
|
||||
if ($is_dispo <> 0)
|
||||
{
|
||||
$result=-3;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
if (strlen($code) == 0)
|
||||
{
|
||||
$result=-2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
dolibarr_syslog("mod_codeclient_lion::verif result=".$result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -112,9 +125,9 @@ class mod_codeclient_lion extends ModeleThirdPartyCode
|
||||
* \brief Renvoi une valeur correcte
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code reference eventuel
|
||||
* \return string Code correct
|
||||
* \return string Code correct, <0 si KO
|
||||
*/
|
||||
function get_correct($db,$code)
|
||||
function get_correct($db, $code)
|
||||
{
|
||||
$return='001';
|
||||
|
||||
@ -138,20 +151,22 @@ class mod_codeclient_lion extends ModeleThirdPartyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoi si un code est pris ou non
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code a verifier
|
||||
* \return int 0 si dispo, <0 si erreur
|
||||
* \brief Renvoi si un code est pris ou non (par autre tiers)
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code a verifier
|
||||
* \param $soc Objet societe
|
||||
* \return int 0 si dispo, <0 si erreur
|
||||
*/
|
||||
function verif_dispo($db, $code)
|
||||
function verif_dispo($db, $code, $soc)
|
||||
{
|
||||
$sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe";
|
||||
$sql .= " WHERE code_client = '".$code."'";
|
||||
$sql.= " WHERE code_client = '".$code."'";
|
||||
$sql.= " AND idp != '".$soc->id."'";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($db->num_rows() == 0)
|
||||
if ($db->num_rows($resql) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -170,7 +185,8 @@ class mod_codeclient_lion extends ModeleThirdPartyCode
|
||||
|
||||
/**
|
||||
* \brief Renvoi si un code respecte la syntaxe
|
||||
* \return int 0 si dispo, <0 si erreur
|
||||
* \param $code Code a verifier
|
||||
* \return int 0 si OK, <0 si KO
|
||||
*/
|
||||
function verif_syntax($code)
|
||||
{
|
||||
|
||||
@ -80,52 +80,62 @@ class mod_codeclient_zebre extends ModeleThirdPartyCode
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code a vérifier/corriger
|
||||
* \param $soc Objet societe
|
||||
* \return int <0 si KO, 0 si OK
|
||||
*/
|
||||
function verif($db, &$code, $soc)
|
||||
{
|
||||
$result=0;
|
||||
$code = strtoupper(trim($code));
|
||||
|
||||
if ($this->verif_syntax($code) == 0)
|
||||
{
|
||||
$i = 1;
|
||||
|
||||
$is_dispo = $this->verif_dispo($db, $code);
|
||||
|
||||
while ($is_dispo <> 0 && $i < 99)
|
||||
{
|
||||
$arr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
$code = substr($code,0,6) . substr("00".$i, -2);
|
||||
|
||||
$is_dispo = $this->verif_dispo($db, $code);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($is_dispo <> 0)
|
||||
{
|
||||
return -3;
|
||||
}
|
||||
if (! $code && $this->code_null)
|
||||
{
|
||||
$result=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen(trim($code)) == 0)
|
||||
{
|
||||
return -2;
|
||||
if ($this->verif_syntax($code) == 0)
|
||||
{
|
||||
$i = 1;
|
||||
|
||||
$is_dispo = $this->verif_dispo($db, $code, $soc);
|
||||
while ($is_dispo <> 0 && $i < 99)
|
||||
{
|
||||
$arr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
$code = substr($code,0,6) . substr("00".$i, -2);
|
||||
|
||||
$is_dispo = $this->verif_dispo($db, $code, $soc);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($is_dispo <> 0)
|
||||
{
|
||||
$result=-3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
if (strlen(trim($code)) == 0)
|
||||
{
|
||||
$result=-2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
dolibarr_syslog("mod_codeclient_zebre::verif result=".$result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoi une valeur correcte
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code reference eventuel
|
||||
* \return string Code correcte
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code reference eventuel
|
||||
* \return string Code correct, <0 si KO
|
||||
*/
|
||||
function get_correct($db, $code)
|
||||
{
|
||||
@ -133,7 +143,7 @@ class mod_codeclient_zebre extends ModeleThirdPartyCode
|
||||
{
|
||||
$i = 1;
|
||||
|
||||
$is_dispo = $this->verif_dispo($db, $code);
|
||||
$is_dispo = $this->verif_dispo($db, $code, $soc);
|
||||
|
||||
while ( $is_dispo <> 0 && $i < 99)
|
||||
{
|
||||
@ -141,7 +151,7 @@ class mod_codeclient_zebre extends ModeleThirdPartyCode
|
||||
|
||||
$code = substr($code,0,6) . substr("00".$i, -2);
|
||||
|
||||
$is_dispo = $this->verif_dispo($db, $code);
|
||||
$is_dispo = $this->verif_dispo($db, $code, $soc);
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -158,19 +168,22 @@ class mod_codeclient_zebre extends ModeleThirdPartyCode
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoi si un code est pris ou non
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code a verifier
|
||||
* \return int 0 si dispo, <0 si erreur
|
||||
* \brief Renvoi si un code est pris ou non (par autre tiers)
|
||||
* \param $db Handler acces base
|
||||
* \param $code Code a verifier
|
||||
* \param $soc Objet societe
|
||||
* \return int 0 si dispo, <0 si erreur
|
||||
*/
|
||||
function verif_dispo($db, $code)
|
||||
function verif_dispo($db, $code, $soc)
|
||||
{
|
||||
$sql = "SELECT code_client FROM ".MAIN_DB_PREFIX."societe";
|
||||
$sql .= " WHERE code_client = '".$code."'";
|
||||
$sql.= " WHERE code_client = '".$code."'";
|
||||
$sql.= " AND idp != '".$soc->id."'";
|
||||
|
||||
if ($db->query($sql))
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($db->num_rows() == 0)
|
||||
if ($db->num_rows($resql) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -181,18 +194,16 @@ class mod_codeclient_zebre extends ModeleThirdPartyCode
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($code) == 0)
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoi si un code respecte la syntaxe
|
||||
* \param $code Code a verifier
|
||||
* \return int 0 si OK, <0 si KO
|
||||
*/
|
||||
function verif_syntax(&$code)
|
||||
{
|
||||
$res = 0;
|
||||
|
||||
@ -52,6 +52,8 @@ Web=Web
|
||||
Birthday=Birthday
|
||||
VATIsUsed=Using VAT
|
||||
ThirdPartyEMail=%s
|
||||
WrongCustomerCode=Customer code invalid
|
||||
WrongSupplierCode=Supplier code invalid
|
||||
##### Professionnal ID #####
|
||||
ProfId1=Professional ID 1
|
||||
ProfId2=Professional ID 2
|
||||
|
||||
@ -27,6 +27,7 @@ ErrorWrongValue=Wrong value
|
||||
ErrorWrongValueForParameterX=Wrong value for parameter %s
|
||||
ErrorNoRequestInError=No request in error
|
||||
ErrorServiceUnavailableTryLater=Service not available or busy for the moment. Try again later.
|
||||
ErrorDuplicateField=Duplicate value in a unique field
|
||||
SeeAbove=See above
|
||||
HomeArea=Home area
|
||||
LastConnexion=Last connection
|
||||
|
||||
@ -52,6 +52,8 @@ Web=Web
|
||||
Birthday=Date de naissance
|
||||
VATIsUsed=Assujéti à TVA
|
||||
ThirdPartyEMail=%s
|
||||
WrongCustomerCode=Code client incorrect
|
||||
WrongSupplierCode=Code fournisseur incorrect
|
||||
##### Professionnal ID #####
|
||||
ProfId1=ID professionnel 1
|
||||
ProfId2=ID professionnel 2
|
||||
|
||||
@ -18,7 +18,7 @@ ErrorGoToModuleSetup=Allez dans la Configuration du module pour corriger
|
||||
ErrorFailedToSendMail=Échec de l'envoi du mail (emetteur=%s, destinataire=%s)
|
||||
ErrorAttachedFilesDisabled=La gestion des fichiers associés est désactivée sur ce serveur
|
||||
ErrorFileNotUploaded=Le fichier n'a pas été transféré
|
||||
ErrorInternalErrorDetected=Erreur detectee
|
||||
ErrorInternalErrorDetected=Erreur détectée
|
||||
ErrorNoRequestRan=Aucune requête exécutée
|
||||
ErrorWrongHostParameter=Mauvais paramètre Serveur
|
||||
ErrorYourCountryIsNotDefined=Votre pays n'est pas défini. Corriger en allant dans Configuration-Général-Editer.
|
||||
@ -27,6 +27,7 @@ ErrorWrongValue=Valeur incorrecte
|
||||
ErrorWrongValueForParameterX=Valeur incorrecte pour le paramètre %s
|
||||
ErrorNoRequestInError=Aucune requete en erreur
|
||||
ErrorServiceUnavailableTryLater=Service non disponible ou saturé actuellement. Réessayer plus tard.
|
||||
ErrorDuplicateField=Doublon dans un champ unique
|
||||
SeeAbove=Voir ci-dessus
|
||||
HomeArea=Espace accueil
|
||||
LastConnexion=Dernière connexion
|
||||
|
||||
@ -110,8 +110,6 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
|
||||
$soc->prefix_comm = $_POST["prefix_comm"];
|
||||
$soc->code_client = $_POST["code_client"];
|
||||
$soc->code_fournisseur = $_POST["code_fournisseur"];
|
||||
$soc->codeclient_modifiable = $_POST["codeclient_modifiable"];
|
||||
$soc->codefournisseur_modifiable = $_POST["codefournisseur_modifiable"];
|
||||
$soc->capital = $_POST["capital"];
|
||||
|
||||
$soc->tva_assuj = $_POST["assujtva_value"];
|
||||
@ -306,8 +304,6 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
|
||||
print '<form action="soc.php" method="post" name="formsoc">';
|
||||
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="codeclient_modifiable" value="1">';
|
||||
print '<input type="hidden" name="codefournisseur_modifiable" value="1">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
@ -595,8 +591,6 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
||||
print '<form action="soc.php?socid='.$soc->id.'" method="post" name="formsoc">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
||||
print '<input type="hidden" name="codeclient_modifiable" value="'.$soc->codeclient_modifiable.'">';
|
||||
print '<input type="hidden" name="codefournisseur_modifiable" value="'.$soc->codefournisseur_modifiable.'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
@ -615,7 +609,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
||||
print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">';
|
||||
|
||||
print '<table class="nobordernopadding"><tr><td>';
|
||||
if ($soc->codeclient_modifiable == 1)
|
||||
if ($soc->codeclient_modifiable())
|
||||
{
|
||||
print '<input type="text" name="code_client" size="16" value="'.$soc->code_client.'" maxlength="15">';
|
||||
}
|
||||
@ -642,7 +636,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
|
||||
print '<td>'.$langs->trans('SupplierCode').'</td><td>';
|
||||
|
||||
print '<table class="nobordernopadding"><tr><td>';
|
||||
if ($soc->codefournisseur_modifiable == 1)
|
||||
if ($soc->codefournisseur_modifiable())
|
||||
{
|
||||
print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->code_fournisseur.'" maxlength="15">';
|
||||
}
|
||||
@ -845,7 +839,7 @@ else
|
||||
print '<tr><td>';
|
||||
print $langs->trans('CustomerCode').'</td><td colspan="3">';
|
||||
print $soc->code_client;
|
||||
if ($soc->check_codeclient() <> 0) print ' '.$langs->trans("WrongCustomerCode");
|
||||
if ($soc->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -853,7 +847,7 @@ else
|
||||
print '<tr><td>';
|
||||
print $langs->trans('SupplierCode').'</td><td colspan="3">';
|
||||
print $soc->code_fournisseur;
|
||||
if ($soc->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode");
|
||||
if ($soc->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
@ -114,13 +114,11 @@ class Societe
|
||||
$varclient = $conf->global->SOCIETE_CODECLIENT_ADDON;
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$varclient.'.php';
|
||||
$this->mod_codeclient = new $varclient;
|
||||
$this->codeclient_modifiable = $this->mod_codeclient->code_modifiable;
|
||||
|
||||
// definit module code fournisseur
|
||||
$varfournisseur = $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$varfournisseur.'.php';
|
||||
$this->mod_codefournisseur = new $varfournisseur;
|
||||
$this->codefournisseur_modifiable = $this->mod_codefournisseur->code_modifiable;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -214,18 +212,19 @@ class Societe
|
||||
|
||||
/**
|
||||
* \brief Verification lors de la modification
|
||||
* \return 0 si ok, < 0 en cas d'erreur
|
||||
* \return int 0 si OK, <0 si KO
|
||||
*/
|
||||
function verify()
|
||||
{
|
||||
$this->nom=trim($this->nom);
|
||||
$result = 0;
|
||||
$this->nom=trim($this->nom);
|
||||
|
||||
if (! $this->nom)
|
||||
{
|
||||
$this->error = "Le nom de la société ne peut être vide.\n";
|
||||
$result = -2;
|
||||
}
|
||||
if ($this->client && $this->codeclient_modifiable == 1)
|
||||
if ($this->client && $this->codeclient_modifiable())
|
||||
{
|
||||
// On ne vérifie le code client que si la société est un client / prospect et que le code est modifiable
|
||||
// Si il n'est pas modifiable il n'est pas mis à jour lors de l'update
|
||||
@ -247,7 +246,7 @@ class Societe
|
||||
$result = -3;
|
||||
}
|
||||
}
|
||||
if ($this->fournisseur && $this->codefournisseur_modifiable == 1)
|
||||
if ($this->fournisseur && $this->codefournisseur_modifiable())
|
||||
{
|
||||
// On ne vérifie le code fournisseur que si la société est un fournisseur et que le code est modifiable
|
||||
// Si il n'est pas modifiable il n'est pas mis à jour lors de l'update
|
||||
@ -269,6 +268,7 @@ class Societe
|
||||
$result = -3;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ class Societe
|
||||
{
|
||||
global $langs;
|
||||
|
||||
dolibarr_syslog("Societe::Update");
|
||||
dolibarr_syslog("Societe::Update id=".$id." call_trigger=".$call_triger." creation_bit=".$this->creation_bit);
|
||||
|
||||
// Nettoyage des paramètres
|
||||
$this->id=$id;
|
||||
@ -307,6 +307,8 @@ class Societe
|
||||
$this->tva_intra=trim($this->tva_intra);
|
||||
|
||||
$this->capital=trim($this->capital);
|
||||
if (strlen($this->capital) == 0) $this->capital = 0;
|
||||
|
||||
$this->effectif_id=trim($this->effectif_id);
|
||||
$this->forme_juridique_code=trim($this->forme_juridique_code);
|
||||
|
||||
@ -316,11 +318,6 @@ class Societe
|
||||
{
|
||||
dolibarr_syslog("Societe::Update verify ok");
|
||||
|
||||
if (strlen($this->capital) == 0)
|
||||
{
|
||||
$this->capital = 0;
|
||||
}
|
||||
|
||||
$this->tel = ereg_replace(" ","",$this->tel);
|
||||
$this->tel = ereg_replace("\.","",$this->tel);
|
||||
$this->fax = ereg_replace(" ","",$this->fax);
|
||||
@ -331,11 +328,8 @@ class Societe
|
||||
$sql.= ",datea = now()";
|
||||
$sql.= ",address = '" . addslashes($this->adresse) ."'";
|
||||
|
||||
if ($this->cp)
|
||||
{ $sql .= ",cp = '" . $this->cp ."'"; }
|
||||
|
||||
if ($this->ville)
|
||||
{ $sql .= ",ville = '" . addslashes($this->ville) ."'"; }
|
||||
$sql.= ",cp = ".($this->cp?"'".$this->cp."'":"null");
|
||||
$sql.= ",ville = ".($this->ville?"'".addslashes($this->ville)."'":"null");
|
||||
|
||||
$sql .= ",fk_departement = '" . ($this->departement_id?$this->departement_id:'0') ."'";
|
||||
$sql .= ",fk_pays = '" . ($this->pays_id?$this->pays_id:'0') ."'";
|
||||
@ -365,7 +359,7 @@ class Societe
|
||||
$sql .= ",client = " . $this->client;
|
||||
$sql .= ",fournisseur = " . $this->fournisseur;
|
||||
|
||||
if ($this->creation_bit || $this->codeclient_modifiable)
|
||||
if ($this->creation_bit || $this->codeclient_modifiable())
|
||||
{
|
||||
// Attention check_codeclient peut modifier le code suivant le module utilise
|
||||
$this->check_codeclient();
|
||||
@ -378,7 +372,7 @@ class Societe
|
||||
$sql .= ", code_compta = ".($this->code_compta?"'".addslashes($this->code_compta)."'":"null");
|
||||
}
|
||||
|
||||
if ($this->creation_bit || $this->codefournisseur_modifiable)
|
||||
if ($this->creation_bit || $this->codefournisseur_modifiable())
|
||||
{
|
||||
// Attention check_codefournisseur peut modifier le code suivant le module utilise
|
||||
$this->check_codefournisseur();
|
||||
@ -394,14 +388,13 @@ class Societe
|
||||
$sql .= " WHERE idp = '" . $id ."'";
|
||||
|
||||
|
||||
dolibarr_syslog("Societe::update sql=".$sql);
|
||||
dolibarr_syslog("Societe::update sql=".$sql);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
// si le fournisseur est classe on l'ajoute
|
||||
$this->AddFournisseurInCategory($this->fournisseur_categorie);
|
||||
|
||||
// si le fournisseur est classe on l'ajoute
|
||||
$this->AddFournisseurInCategory($this->fournisseur_categorie);
|
||||
|
||||
if ($call_trigger)
|
||||
{
|
||||
@ -531,16 +524,6 @@ class Societe
|
||||
$this->code_client = $obj->code_client;
|
||||
$this->code_fournisseur = $obj->code_fournisseur;
|
||||
|
||||
if (! $this->code_client && $this->mod_codeclient->code_modifiable_null == 1)
|
||||
{
|
||||
$this->codeclient_modifiable = 1;
|
||||
}
|
||||
|
||||
if (! $this->code_fournisseur && $this->mod_codefournisseur->code_modifiable_null == 1)
|
||||
{
|
||||
$this->codefournisseur_modifiable = 1;
|
||||
}
|
||||
|
||||
$this->code_compta = $obj->code_compta;
|
||||
$this->code_compta_fournisseur = $obj->code_compta_fournisseur;
|
||||
|
||||
@ -1376,53 +1359,109 @@ class Societe
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Affiche le rib
|
||||
*/
|
||||
function display_rib()
|
||||
{
|
||||
global $langs;
|
||||
/**
|
||||
* \brief Affiche le rib
|
||||
*/
|
||||
function display_rib()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . "/companybankaccount.class.php";
|
||||
require_once DOL_DOCUMENT_ROOT . "/companybankaccount.class.php";
|
||||
|
||||
$bac = new CompanyBankAccount($this->db, $this->id);
|
||||
$bac->fetch();
|
||||
$bac = new CompanyBankAccount($this->db, $this->id);
|
||||
$bac->fetch();
|
||||
|
||||
if ($bac->code_banque || $bac->code_guichet || $bac->number || $bac->cle_rib)
|
||||
{
|
||||
$rib = $bac->code_banque." ".$bac->code_guichet." ".$bac->number." (".$bac->cle_rib.")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$rib=$langs->trans("NoRIB");
|
||||
}
|
||||
return $rib;
|
||||
}
|
||||
if ($bac->code_banque || $bac->code_guichet || $bac->number || $bac->cle_rib)
|
||||
{
|
||||
$rib = $bac->code_banque." ".$bac->code_guichet." ".$bac->number." (".$bac->cle_rib.")";
|
||||
}
|
||||
else
|
||||
{
|
||||
$rib=$langs->trans("NoRIB");
|
||||
}
|
||||
return $rib;
|
||||
}
|
||||
|
||||
|
||||
function rib()
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . "/companybankaccount.class.php";
|
||||
function rib()
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . "/companybankaccount.class.php";
|
||||
|
||||
$bac = new CompanyBankAccount($this->db, $this->id);
|
||||
$bac->fetch();
|
||||
$bac = new CompanyBankAccount($this->db, $this->id);
|
||||
$bac->fetch();
|
||||
|
||||
$this->bank_account = $bac;
|
||||
$this->bank_account = $bac;
|
||||
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function verif_rib()
|
||||
{
|
||||
$this->rib();
|
||||
return $this->bank_account->verif();
|
||||
}
|
||||
function verif_rib()
|
||||
{
|
||||
$this->rib();
|
||||
return $this->bank_account->verif();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Verifie si un code client est modifiable dans configuration du module de controle des codes
|
||||
* \return int 0=Non, 1=Oui
|
||||
*/
|
||||
function codeclient_modifiable()
|
||||
{
|
||||
global $conf;
|
||||
if ($conf->global->SOCIETE_CODECLIENT_ADDON)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$conf->global->SOCIETE_CODECLIENT_ADDON.'.php';
|
||||
|
||||
$var = $conf->global->SOCIETE_CODECLIENT_ADDON;
|
||||
|
||||
$mod = new $var;
|
||||
|
||||
dolibarr_syslog("Societe::codeclient_modifiable code_client=".$this->code_client." module=".$var);
|
||||
if ($mod->code_modifiable) return 1;
|
||||
if ($mod->code_modifiable_null && ! $this->code_fournisseur) return 1;
|
||||
if ($mod->code_modifiable_invalide && $this->check_codeclient() < 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Verifie si un code client est modifiable dans configuration du module de controle des codes
|
||||
* \return int 0=Non, 1=Oui
|
||||
*/
|
||||
function codefournisseur_modifiable()
|
||||
{
|
||||
global $conf;
|
||||
if ($conf->global->SOCIETE_CODEFOURNISSEUR_ADDON)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON.'.php';
|
||||
|
||||
$var = $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON;
|
||||
|
||||
$mod = new $var;
|
||||
|
||||
dolibarr_syslog("Societe::codefournisseur_modifiable code_founisseur=".$this->code_fournisseur." module=".$var);
|
||||
if ($mod->code_modifiable) return 1;
|
||||
if ($mod->code_modifiable_null && ! $this->code_fournisseur) return 1;
|
||||
if ($mod->code_modifiable_invalide && $this->check_codefournisseur() < 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Verifie code client
|
||||
* \return Renvoie 0 si ok, peut modifier le code client suivant le module utilis
|
||||
* \return int <0 si KO, 0 si OK, peut modifier le code client suivant le module utilisé
|
||||
*/
|
||||
function check_codeclient()
|
||||
{
|
||||
@ -1446,7 +1485,7 @@ class Societe
|
||||
|
||||
/**
|
||||
* \brief Verifie code fournisseur
|
||||
* \return Renvoie 0 si ok, peut modifier le code client suivant le module utilis
|
||||
* \return int <0 si KO, 0 si OK, peut modifier le code client suivant le module utilisé
|
||||
*/
|
||||
function check_codefournisseur()
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user