task #4146 : Ajout d'un 4eme champ identifiant professionnel

This commit is contained in:
Laurent Destailleur 2007-02-10 13:43:49 +00:00
parent ab353c80ea
commit e2e3119297
3 changed files with 97 additions and 71 deletions

View File

@ -1463,7 +1463,7 @@ class Form
if ($idprof==1 && $soc->pays_code == 'FR') $formlength=9;
if ($idprof==2 && $soc->pays_code == 'FR') $formlength=14;
if ($idprof==3 && $soc->pays_code == 'FR') $formlength=4;
if ($idprof==4 && $soc->pays_code == 'FR') $formlength=4;
if ($idprof==4 && $soc->pays_code == 'FR') $formlength=12;
print '<input type="text" name="'.$htmlname.'" size="'.($formlength+1).'" maxlength="'.$formlength.'" value="'.$selected.'">';
}

View File

@ -39,7 +39,10 @@ $user->getrights('commercial');
$langs->load("companies");
$langs->load("commercial");
$langs->load("bills");
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
// Sécurité accés client
if (! $user->rights->societe->creer)
{
if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
@ -47,16 +50,11 @@ if (! $user->rights->societe->creer)
accessforbidden();
}
}
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
if (! $socid && ($_REQUEST["action"] != 'create' && $_REQUEST["action"] != 'add')) accessforbidden();
// Sécurité accés client
if ($user->societe_id > 0)
{
$_GET["action"] = '';
$_POST["action"] = '';
$socid = $user->societe_id;
$_GET["action"] = '';
$_POST["action"] = '';
$socid = $user->societe_id;
}
// Protection restriction commercial
@ -104,9 +102,10 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
$soc->fax = $_POST["fax"];
$soc->email = $_POST["email"];
$soc->url = $_POST["url"];
$soc->siren = $_POST["siren"];
$soc->siret = $_POST["siret"];
$soc->ape = $_POST["ape"];
$soc->siren = $_POST["idprof1"];
$soc->siret = $_POST["idprof2"];
$soc->ape = $_POST["idprof3"];
$soc->idprof4 = $_POST["idprof4"];
$soc->prefix_comm = $_POST["prefix_comm"];
$soc->code_client = $_POST["code_client"];
$soc->code_fournisseur = $_POST["code_fournisseur"];
@ -165,7 +164,10 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
exit;
}
$result = $soc->update($socid,$user);
$oldsoc=new Societe($db);
$result=$oldsoc->fetch($socid);
$result = $soc->update($socid,$user,1,$oldsoc->codeclient_modifiable(),$oldsoc->codefournisseur_modifiable());
if ($result >= 0)
{
Header("Location: soc.php?socid=".$socid);
@ -262,9 +264,10 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
$soc->email=$_POST["email"];
$soc->url=$_POST["url"];
$soc->capital=$_POST["capital"];
$soc->siren=$_POST["siren"];
$soc->siret=$_POST["siret"];
$soc->ape=$_POST["ape"];
$soc->siren=$_POST["idprof1"];
$soc->siret=$_POST["idprof2"];
$soc->ape=$_POST["idprof3"];
$soc->idprof4=$_POST["idprof4"];
$soc->typent_id=$_POST["typent_id"];
$soc->effectif_id=$_POST["effectif_id"];
@ -402,10 +405,17 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
print '<tr><td><div id="particulier13" class="visible">'.$langs->trans('Capital').'</div></td><td colspan="3"><div id="particulier14" class="visible"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</div></td></tr>';
if ($soc->pays_code == 'FR')
{
$maxlength1=9;
$maxlength2=14;
$maxlength3=4;
$maxlength4=12;
}
print '<tr><td><div id="particulier10" class="visible">'.($langs->transcountry("ProfId1",$soc->pays_code) != '-'?$langs->transcountry('ProfId1',$soc->pays_code):'').'</div></td><td>';
if ($soc->pays_id)
{
if ($langs->transcountry("ProfId1",$soc->pays_code) != '-') print '<div id="particulier11" class="visible"><input type="text" name="siren" size="15" maxlength="9" value="'.$soc->siren.'"></div>';
if ($langs->transcountry("ProfId1",$soc->pays_code) != '-') print '<div id="particulier11" class="visible"><input type="text" name="idprof1" size="15" maxlength="'.$maxlength1.'" value="'.$soc->siren.'"></div>';
else print '<div id="particulier11" class="visible">&nbsp;</div>';
}
else
@ -416,7 +426,7 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
print '<td><div id="particulier8" class="visible">'.($langs->transcountry("ProfId2",$soc->pays_code) != '-'?$langs->transcountry('ProfId2',$soc->pays_code):'').'</div></td><td>';
if ($soc->pays_id)
{
if ($langs->transcountry("ProfId2",$soc->pays_code) != '-') print '<div id="particulier9" class="visible"><input type="text" name="siret" size="15" maxlength="14" value="'.$soc->siret.'"></div>';
if ($langs->transcountry("ProfId2",$soc->pays_code) != '-') print '<div id="particulier9" class="visible"><input type="text" name="idprof2" size="15" maxlength="'.$maxlength2.'" value="'.$soc->siret.'"></div>';
else print '<div id="particulier9" class="visible">&nbsp;</div>';
}
else
@ -428,14 +438,25 @@ if ($_POST["getcustomercode"] || $_POST["getsuppliercode"] ||
print '<tr><td><div id="particulier6" class="visible">'.($langs->transcountry("ProfId3",$soc->pays_code) != '-'?$langs->transcountry('ProfId3',$soc->pays_code):'').'</div></td><td>';
if ($soc->pays_id)
{
if ($langs->transcountry("ProfId3",$soc->pays_code) != '-') print '<div id="particulier7" class="visible"><input type="text" name="ape" size="5" maxlength="4" value="'.$soc->ape.'"></div>';
if ($langs->transcountry("ProfId3",$soc->pays_code) != '-') print '<div id="particulier7" class="visible"><input type="text" name="idprof3" size="15" maxlength="'.$maxlength3.'" value="'.$soc->ape.'"></div>';
else print '<div id="particulier7" class="visible">&nbsp;</div>';
}
else
{
print $countrynotdefined;
}
print '</td><td colspan="2"><div id="particulier12" class="visible">&nbsp;</div></td></tr>'."\n";
print '</td>';
print '<td><div id="particulier12" class="visible">'.($langs->transcountry("ProfId4",$soc->pays_code) != '-'?$langs->transcountry('ProfId4',$soc->pays_code):'').'</div></td><td>';
if ($soc->pays_id)
{
if ($langs->transcountry("ProfId4",$soc->pays_code) != '-') print '<div id="particulier13" class="visible"><input type="text" name="idprof4" size="15" maxlength="'.$maxlength4.'" value="'.$soc->idprof4.'"></div>';
else print '<div id="particulier9" class="visible">&nbsp;</div>';
}
else
{
print $countrynotdefined;
}
print '</td></tr>';
// Forme juridique
print '<tr><td><div id="particulier1" class="visible">'.$langs->trans('JuridicalStatus').'</div></td>';
@ -553,9 +574,10 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
$soc->email=$_POST["email"];
$soc->url=$_POST["url"];
$soc->capital=$_POST["capital"];
$soc->siren=$_POST["siren"];
$soc->siret=$_POST["siret"];
$soc->ape=$_POST["ape"];
$soc->siren=$_POST["idprof1"];
$soc->siret=$_POST["idprof2"];
$soc->ape=$_POST["idprof3"];
$soc->idprof4=$_POST["idprof4"];
$soc->typent_id=$_POST["typent_id"];
$soc->effectif_id=$_POST["effectif_id"];
@ -697,42 +719,41 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
print '<td>'.$langs->trans('Web').'</td><td><input type="text" name="url" size="32" value="'.$soc->url.'"></td></tr>';
print '<tr>';
// IdProf1
// IdProf1 (SIREN pour France)
$idprof=$langs->transcountry('ProfId1',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$form->id_prof(1,$soc,'siren',$soc->siren);
$form->id_prof(1,$soc,'idprof1',$soc->siren);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
// IdProf2
// IdProf2 (SIRET pour France)
$idprof=$langs->transcountry('ProfId2',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$form->id_prof(2,$soc,'siret',$soc->siret);
$form->id_prof(2,$soc,'idprof2',$soc->siret);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
print '</tr>';
print '<tr>';
// IdProf3
// IdProf3 (APE pour France)
$idprof=$langs->transcountry('ProfId3',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$form->id_prof(3,$soc,'ape',$soc->ape);
$form->id_prof(3,$soc,'idprof3',$soc->ape);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
// IdProf4
// $idprof=$langs->transcountry('ProfId4',$soc->pays_code);
$idprof='-'; // L'identifiant 4 n'est pas encore géré
// IdProf4 (NU pour France)
$idprof=$langs->transcountry('ProfId4',$soc->pays_code);
if ($idprof!='-')
{
print '<td>'.$idprof.'</td><td>';
$form->id_prof(4,$soc,'rcs',$soc->rcs);
$form->id_prof(4,$soc,'idprof4',$soc->idprof4);
print '</td>';
}
else print '<td>&nbsp;</td><td>&nbsp;</td>';
@ -873,7 +894,7 @@ else
else print '&nbsp;';
print '</td></tr>';
// ProfId1
// ProfId1 (SIREN pour France)
$profid=$langs->transcountry('ProfId1',$soc->pays_code);
if ($profid!='-')
{
@ -887,7 +908,7 @@ else
print '</td>';
}
else print '<tr><td>&nbsp;</td><td>&nbsp;</td>';
// ProfId2
// ProfId2 (SIRET pour France)
$profid=$langs->transcountry('ProfId2',$soc->pays_code);
if ($profid!='-')
{
@ -902,7 +923,7 @@ else
}
else print '<td>&nbsp;</td><td>&nbsp;</td></tr>';
// ProfId3
// ProfId3 (APE pour France)
$profid=$langs->transcountry('ProfId3',$soc->pays_code);
if ($profid!='-')
{
@ -916,14 +937,13 @@ else
print '</td>';
}
else print '<tr><td>&nbsp;</td><td>&nbsp;</td>';
// ProfId4
// $profid=$langs->transcountry('ProfId4',$soc->pays_code);
$profid='-'; // L'identifiant 4 n'est pas encore géré
// ProfId4 (NU pour France)
$profid=$langs->transcountry('ProfId4',$soc->pays_code);
if ($profid!='-')
{
print '<td>'.$profid.'</td><td>';
print $soc->rcs;
if ($soc->rcs)
print $soc->idprof4;
if ($soc->idprof4)
{
if ($soc->id_prof_check(4,$soc) > 0) print ' &nbsp; '.$soc->id_prof_url(4,$soc);
else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';

View File

@ -52,9 +52,12 @@ class Societe
var $fax;
var $email;
var $url;
var $siren;
var $siret;
var $ape;
// 4 identifiants porfessionnels (leur utilisation depend du pays)
var $siren; // IdProf1
var $siret; // IdProf2
var $ape; // IdProf3
var $idprof4; // IdProf4
var $prefix_comm;
@ -98,7 +101,6 @@ class Societe
global $conf;
$this->db = $DB;
$this->creation_bit = 0;
$this->id = $id;
$this->client = 0;
@ -152,9 +154,7 @@ class Societe
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe");
$this->creation_bit = 1;
$ret = $this->update($this->id,$user,0);
$ret = $this->update($this->id,$user,0,1,1);
// si un commercial crée un client il lui est affecté automatiquement
if (!$user->rights->commercial->client->voir)
@ -273,17 +273,19 @@ 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
* \param call_trigger 0=non, 1=oui
* \return int <0 si ko, >=0 si ok
* \brief Mise a jour des paramètres de la société
* \param id id societe
* \param user Utilisateur qui demande la mise à jour
* \param call_trigger 0=non, 1=oui
* \param allowmodcodeclient Autorise modif code client
* \param allowmodcodefournisseur Autorise modif code fournisseur
* \return int <0 si ko, >=0 si ok
*/
function update($id, $user='', $call_trigger=1)
function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0)
{
global $langs;
dolibarr_syslog("Societe::Update id=".$id." call_trigger=".$call_triger." creation_bit=".$this->creation_bit);
dolibarr_syslog("Societe::Update id=".$id." call_trigger=".$call_triger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
// Nettoyage des paramètres
$this->id=$id;
@ -296,11 +298,16 @@ class Societe
$this->pays_id=trim($this->pays_id);
$this->tel=trim($this->tel);
$this->fax=trim($this->fax);
$this->tel = ereg_replace(" ","",$this->tel);
$this->tel = ereg_replace("\.","",$this->tel);
$this->fax = ereg_replace(" ","",$this->fax);
$this->fax = ereg_replace("\.","",$this->fax);
$this->email=trim($this->email);
$this->url=trim($this->url);
$this->siren=trim($this->siren);
$this->siret=trim($this->siret);
$this->ape=trim($this->ape);
$this->idprof4=trim($this->idprof4);
$this->prefix_comm=trim($this->prefix_comm);
$this->tva_assuj=trim($this->tva_assuj);
@ -318,11 +325,6 @@ class Societe
{
dolibarr_syslog("Societe::Update verify ok");
$this->tel = ereg_replace(" ","",$this->tel);
$this->tel = ereg_replace("\.","",$this->tel);
$this->fax = ereg_replace(" ","",$this->fax);
$this->fax = ereg_replace("\.","",$this->fax);
$sql = "UPDATE ".MAIN_DB_PREFIX."societe";
$sql.= " SET nom = '" . addslashes($this->nom) ."'"; // Champ obligatoire
$sql.= ",datea = now()";
@ -339,9 +341,10 @@ class Societe
$sql .= ",email = ".($this->email?"'".addslashes($this->email)."'":"null");
$sql .= ",url = ".($this->url?"'".addslashes($this->url)."'":"null");
$sql .= ",siren = '". addslashes($this->siren) ."'";
$sql .= ",siret = '". addslashes($this->siret) ."'";
$sql .= ",ape = '". addslashes($this->ape) ."'";
$sql .= ",siren = '". addslashes($this->siren) ."'";
$sql .= ",siret = '". addslashes($this->siret) ."'";
$sql .= ",ape = '". addslashes($this->ape) ."'";
$sql .= ",idprof4 = '". addslashes($this->idprof4) ."'";
$sql .= ",tva_assuj = ".($this->tva_assuj>=0?"'".$this->tva_assuj."'":"null");
$sql .= ",tva_intra = '" . addslashes($this->tva_intra) ."'";
@ -359,7 +362,7 @@ class Societe
$sql .= ",client = " . $this->client;
$sql .= ",fournisseur = " . $this->fournisseur;
if ($this->creation_bit || $this->codeclient_modifiable())
if ($allowmodcodeclient)
{
// Attention check_codeclient peut modifier le code suivant le module utilise
$this->check_codeclient();
@ -372,7 +375,7 @@ class Societe
$sql .= ", code_compta = ".($this->code_compta?"'".addslashes($this->code_compta)."'":"null");
}
if ($this->creation_bit || $this->codefournisseur_modifiable())
if ($allowmodcodefournisseur)
{
// Attention check_codefournisseur peut modifier le code suivant le module utilise
$this->check_codefournisseur();
@ -463,8 +466,9 @@ class Societe
if($conf->global->PRODUIT_MULTIPRICES == 1)
$sql .= ', s.price_level';
$sql .= ','. $this->db->pdate('s.tms').' as date_update';
$sql .= ', s.tel, s.fax, s.email, s.url, s.cp, s.ville, s.note, s.siren, client, fournisseur';
$sql .= ', s.siret, s.capital, s.ape, s.tva_intra, s.rubrique';
$sql .= ', s.tel, s.fax, s.email, s.url, s.cp, s.ville, s.note, client, fournisseur';
$sql .= ', s.siren, s.siret, s.ape, s.idprof4';
$sql .= ', s.capital, s.tva_intra, s.rubrique';
$sql .= ', s.fk_typent as typent_id';
$sql .= ', s.fk_effectif as effectif_id, e.libelle as effectif';
$sql .= ', s.fk_forme_juridique as forme_juridique_code, fj.libelle as forme_juridique';
@ -519,6 +523,8 @@ class Societe
$this->siren = $obj->siren;
$this->siret = $obj->siret;
$this->ape = $obj->ape;
$this->idprof4 = $obj->idprof4;
$this->capital = $obj->capital;
$this->code_client = $obj->code_client;
@ -1419,9 +1425,9 @@ class Societe
$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;
if ($mod->code_modifiable) return 1; // A mettre en dernier
return 0;
}
else
@ -1432,7 +1438,7 @@ class Societe
/**
* \brief Verifie si un code client est modifiable dans configuration du module de controle des codes
* \brief Verifie si un code fournisseur est modifiable dans configuration du module de controle des codes
* \return int 0=Non, 1=Oui
*/
function codefournisseur_modifiable()
@ -1447,9 +1453,9 @@ class Societe
$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;
if ($mod->code_modifiable) return 1; // A mettre en dernier
return 0;
}
else