Modification de la gestion du codeclient
This commit is contained in:
parent
239b6b7f00
commit
056b66bad0
@ -24,9 +24,26 @@
|
||||
class mod_codeclient_leopard
|
||||
{
|
||||
|
||||
/*
|
||||
* Attention ce module est utilisé par défaut si aucun module n'a
|
||||
* été définit dans la configuration
|
||||
*
|
||||
* Le fonctionnement de celui-ci doit dont rester le plus ouvert
|
||||
* possible
|
||||
*/
|
||||
|
||||
function mod_codeclient_leopard()
|
||||
{
|
||||
$this->nom = "Léopard";
|
||||
$this->code_modifiable = 1;
|
||||
|
||||
$this->code_modifiable_invalide = 1; // code modifiable si il est invalide
|
||||
|
||||
$this->code_modifiable_null = 1; // code modifiable si il est null
|
||||
|
||||
$this->code_null = 1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function info()
|
||||
|
||||
@ -27,6 +27,15 @@ class mod_codeclient_zebre
|
||||
function mod_codeclient_zebre()
|
||||
{
|
||||
$this->nom = "Zèbre";
|
||||
|
||||
$this->code_modifiable = 0; // code modifiable
|
||||
|
||||
$this->code_modifiable_invalide = 0; // code modifiable si il est invalide
|
||||
|
||||
$this->code_modifiable_null = 1; // code modifiable si il est null
|
||||
|
||||
$this->code_null = 0; // Saisi vide interdite
|
||||
|
||||
}
|
||||
/*! \brief Renvoi la description du module
|
||||
* \return string Texte descripif
|
||||
@ -42,13 +51,13 @@ class mod_codeclient_zebre
|
||||
*
|
||||
*/
|
||||
|
||||
function verif($db, $code)
|
||||
function verif($db, $code, $socid=0)
|
||||
{
|
||||
if ($this->verif_syntax($code) == 0)
|
||||
{
|
||||
$i = 1;
|
||||
|
||||
$is_dispo = $this->verif_dispo($db, $code);
|
||||
$is_dispo = $this->verif_dispo($db, $code, $socid);
|
||||
|
||||
while ( $is_dispo <> 0 && $i < 99)
|
||||
{
|
||||
|
||||
@ -47,30 +47,27 @@ $soc = new Societe($db);
|
||||
|
||||
if ($_POST["action"] == 'add' or $_POST["action"] == 'update')
|
||||
{
|
||||
$soc->nom = $_POST["nom"];
|
||||
$soc->adresse = $_POST["adresse"];
|
||||
$soc->cp = $_POST["cp"];
|
||||
$soc->ville = $_POST["ville"];
|
||||
$soc->pays_id = $_POST["pays_id"];
|
||||
$soc->departement_id = $_POST["departement_id"];
|
||||
$soc->tel = $_POST["tel"];
|
||||
$soc->fax = $_POST["fax"];
|
||||
$soc->url = ereg_replace( "http://", "", $_POST["url"] );
|
||||
$soc->siren = $_POST["siren"];
|
||||
$soc->siret = $_POST["siret"];
|
||||
$soc->ape = $_POST["ape"];
|
||||
$soc->prefix_comm = $_POST["prefix_comm"];
|
||||
|
||||
if (strlen(trim($_POST["code_client"])))
|
||||
{
|
||||
$soc->code_client = $_POST["code_client"];
|
||||
}
|
||||
$soc->capital = $_POST["capital"];
|
||||
$soc->tva_intra = $_POST["tva_intra_code"] . $_POST["tva_intra_num"];
|
||||
$soc->forme_juridique_code = $_POST["forme_juridique_code"];
|
||||
$soc->effectif_id = $_POST["effectif_id"];
|
||||
$soc->client = $_POST["client"];
|
||||
$soc->fournisseur = $_POST["fournisseur"];
|
||||
$soc->nom = $_POST["nom"];
|
||||
$soc->adresse = $_POST["adresse"];
|
||||
$soc->cp = $_POST["cp"];
|
||||
$soc->ville = $_POST["ville"];
|
||||
$soc->pays_id = $_POST["pays_id"];
|
||||
$soc->departement_id = $_POST["departement_id"];
|
||||
$soc->tel = $_POST["tel"];
|
||||
$soc->fax = $_POST["fax"];
|
||||
$soc->url = ereg_replace( "http://", "", $_POST["url"] );
|
||||
$soc->siren = $_POST["siren"];
|
||||
$soc->siret = $_POST["siret"];
|
||||
$soc->ape = $_POST["ape"];
|
||||
$soc->prefix_comm = $_POST["prefix_comm"];
|
||||
$soc->code_client = $_POST["code_client"];
|
||||
$soc->codeclient_modifiable = $_POST["codeclient_modifiable"];
|
||||
$soc->capital = $_POST["capital"];
|
||||
$soc->tva_intra = $_POST["tva_intra_code"] . $_POST["tva_intra_num"];
|
||||
$soc->forme_juridique_code = $_POST["forme_juridique_code"];
|
||||
$soc->effectif_id = $_POST["effectif_id"];
|
||||
$soc->client = $_POST["client"];
|
||||
$soc->fournisseur = $_POST["fournisseur"];
|
||||
|
||||
if ($_POST["action"] == 'update')
|
||||
{
|
||||
@ -208,6 +205,7 @@ elseif ($_GET["action"] == 'edit')
|
||||
$soc->id = $_GET["socid"];
|
||||
$soc->fetch($_GET["socid"]);
|
||||
}
|
||||
|
||||
if ($soc->error_message)
|
||||
{
|
||||
print '<div class="errormessage">';
|
||||
@ -217,6 +215,7 @@ elseif ($_GET["action"] == 'edit')
|
||||
|
||||
print '<form action="soc.php?socid='.$soc->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="codeclient_modifiable" value="'.$soc->codeclient_modifiable.'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans('Name').'</td><td><input type="text" size="40" name="nom" value="'.stripslashes($soc->nom).'"></td>';
|
||||
@ -241,15 +240,15 @@ elseif ($_GET["action"] == 'edit')
|
||||
print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Code client').'</td><td colspan="3">';
|
||||
if ($soc->code_client && $soc->check_codeclient() == 0)
|
||||
{
|
||||
print $soc->code_client;
|
||||
}
|
||||
else
|
||||
|
||||
if ($soc->codeclient_modifiable == 1)
|
||||
{
|
||||
print '<input type="text" name="code_client" size="16" value="'.$soc->code_client.'" maxlength="15">';
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
print $soc->code_client;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3"><input type="text" name="url" size="40" value="'.$soc->url.'"></td></tr>';
|
||||
@ -276,9 +275,9 @@ elseif ($_GET["action"] == 'edit')
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('ProspectCustomer').'</td><td><select name="client">';
|
||||
print '<option value="2"'.($soc->client==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
|
||||
print '<option value="1"'.($soc->client==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
|
||||
print '<option value="0"'.($soc->client==0?' selected':'').'>Ni client, ni prospect</option>';
|
||||
print '<option value="2"'.($soc->client==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
|
||||
print '<option value="1"'.($soc->client==1?' selected':'').'>'.$langs->trans('Customer').'</option>';
|
||||
print '<option value="0"'.($soc->client==0?' selected':'').'>Ni client, ni prospect</option>';
|
||||
print '</select></td>';
|
||||
|
||||
print '<td>'.$langs->trans('Supplier').'</td><td>';
|
||||
|
||||
@ -67,7 +67,7 @@ class Societe {
|
||||
function Societe($DB, $id=0)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$this->creation_bit = 0;
|
||||
$this->db = $DB;
|
||||
$this->id = $id;
|
||||
$this->client = 0;
|
||||
@ -75,6 +75,24 @@ class Societe {
|
||||
$this->effectif_id = 0;
|
||||
$this->forme_juridique_code = 0;
|
||||
|
||||
if (defined('CODECLIENT_ADDON') && strlen(CODECLIENT_ADDON) > 0)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.CODECLIENT_ADDON.'.php';
|
||||
|
||||
$var = CODECLIENT_ADDON;
|
||||
}
|
||||
else
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/mod_code_client_leopard.php';
|
||||
|
||||
$var = "mod_code_client_leopard";
|
||||
}
|
||||
|
||||
$this->mod_codeclient = new $var;
|
||||
|
||||
|
||||
$this->codeclient_modifiable = $this->mod_codeclient->modifiable;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -99,6 +117,8 @@ class Societe {
|
||||
$this->id = $this->db->last_insert_id();
|
||||
}
|
||||
|
||||
$this->creation_bit = 1;
|
||||
|
||||
$result = $this->update($this->id);
|
||||
|
||||
return $result;
|
||||
@ -110,10 +130,9 @@ class Societe {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mise a jour des paramètres de la société
|
||||
* \param id id societe
|
||||
* \param user Utilisateur qui demande la mise à jour
|
||||
* \brief Verification lors de la modification
|
||||
*/
|
||||
function verify()
|
||||
{
|
||||
@ -125,31 +144,37 @@ class Societe {
|
||||
$result = -2;
|
||||
}
|
||||
|
||||
$rescode = $this->verif_codeclient();
|
||||
|
||||
if ($rescode <> 0)
|
||||
if ($this->codeclient_modifiable)
|
||||
{
|
||||
if ($rescode == -1)
|
||||
{
|
||||
$this->error_message .= "La syntaxe du code client est incorrecte.\n";
|
||||
}
|
||||
// On ne vérifie le code client que si celui-ci est modifiable
|
||||
// Si il n'est pas modifiable il n'est pas mis à jour lors de l'update
|
||||
|
||||
if ($rescode == -2)
|
||||
{
|
||||
$this->error_message .= "Vous devez saisir un code client.\n";
|
||||
}
|
||||
$rescode = $this->verif_codeclient();
|
||||
|
||||
if ($rescode == -3)
|
||||
if ($rescode <> 0)
|
||||
{
|
||||
if ($rescode == -1)
|
||||
{
|
||||
$this->error_message .= "La syntaxe du code client est incorrecte.\n";
|
||||
}
|
||||
|
||||
if ($rescode == -2)
|
||||
{
|
||||
$this->error_message .= "Vous devez saisir un code client.\n";
|
||||
}
|
||||
|
||||
if ($rescode == -3)
|
||||
{
|
||||
$this->error_message .= "Ce code client est déjà utilisé.\n";
|
||||
}
|
||||
|
||||
$result = -3;
|
||||
|
||||
$result = -3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,7 +273,7 @@ class Societe {
|
||||
$sql .= ",fk_user_modif = '".$user->id."'";
|
||||
}
|
||||
|
||||
if (trim($this->code_client))
|
||||
if ($this->creation_bit || $this->codeclient_modifiable)
|
||||
{
|
||||
// Attention check_codeclient peut modifier le code
|
||||
// suivant le module utilisé
|
||||
@ -349,6 +374,13 @@ $this->error_message = "Erreur, le prefix '".$this->prefix_comm."' existe d
|
||||
$this->capital = $obj->capital;
|
||||
|
||||
$this->code_client = $obj->code_client;
|
||||
|
||||
if (strlen($this->code_client) == 0 && $this->mod_codeclient->code_modifiable_null == 1)
|
||||
{
|
||||
$this->codeclient_modifiable = 1;
|
||||
}
|
||||
|
||||
|
||||
$this->code_compta = $obj->code_compta;
|
||||
|
||||
$this->tva_intra = $obj->tva_intra;
|
||||
@ -880,7 +912,7 @@ $this->error_message = "Erreur, le prefix '".$this->prefix_comm."' existe d
|
||||
|
||||
$mod = new $var;
|
||||
|
||||
return $mod->verif($this->db, $this->code_client);
|
||||
return $mod->verif($this->db, $this->code_client, $this->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user