Fix: Le lien avec la forme juridique se fait sur le code (qui est unique) et qui vaut 0 si non dfini. Meme principe que les dpartements lis sur le code rgion

This commit is contained in:
Laurent Destailleur 2004-06-12 02:13:58 +00:00
parent 4396fc5537
commit 284d75b9a0
5 changed files with 18 additions and 18 deletions

View File

@ -63,7 +63,7 @@ class Form {
else {
if ($pays == '' || $pays != $obj->libelle_pays) {
// Affiche la rupture
print '<option value="-1">----- '.$obj->libelle_pays.' -----</option>';
print '<option value="-1">----- '.$obj->libelle_pays." -----</option>\n";
$pays=$obj->libelle_pays;
}
@ -128,13 +128,13 @@ class Form {
*/
Function select_forme_juridique($selected='')
{
print '<select name="forme_juridique_id">';
print '<select name="forme_juridique_code">';
// On recherche les formes juridiques actives des pays actifs
$sql = "SELECT f.rowid, f.code as code , f.libelle as nom, f.active, p.libelle as libelle_pays, p.code as code_pays FROM llx_c_forme_juridique as f, llx_c_pays as p";
$sql .= " WHERE f.fk_pays=p.rowid";
$sql .= " AND f.active = 1 AND p.active = 1 ORDER BY code_pays, code ASC";
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
@ -151,17 +151,17 @@ class Form {
else {
if ($pays == '' || $pays != $obj->libelle_pays) {
// Affiche la rupture
print '<option value="-1">----- '.$obj->libelle_pays.' -----</option>';
print '<option value="-1">----- '.$obj->libelle_pays." -----</option>\n";
$pays=$obj->libelle_pays;
}
if ($selected > 0 && $selected == $obj->rowid)
if ($selected > 0 && $selected == $obj->code)
{
print '<option value="'.$obj->rowid.'" selected>['.$obj->code.'] '.$obj->nom.'</option>';
print '<option value="'.$obj->code.'" selected>['.$obj->code.'] '.$obj->nom.'</option>';
}
else
{
print '<option value="'.$obj->rowid.'">['.$obj->code.'] '.$obj->nom.'</option>';
print '<option value="'.$obj->code.'">['.$obj->code.'] '.$obj->nom.'</option>';
}
}
$i++;

View File

@ -51,7 +51,7 @@ if ($_POST["action"] == 'add' or $_POST["action"] == 'update')
$soc->capital = $_POST["capital"];
$soc->tva_intra = $_POST["tva_intra_code"] . $_POST["tva_intra_num"];
$soc->forme_juridique_id = $_POST["forme_juridique_id"];
$soc->forme_juridique_code= $_POST["forme_juridique_code"];
$soc->effectif_id = $_POST["effectif_id"];
$soc->client = $_POST["client"];
$soc->fournisseur = $_POST["fournisseur"];
@ -111,7 +111,7 @@ if ($action == 'create')
print '<td>Capital</td><td><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.MAIN_MONNAIE.'</td></tr>';
print '<tr><td>Forme juridique</td><td colspan="3">';
print $form->select_forme_juridique($soc->forme_juridique_id);
print $form->select_forme_juridique($soc->forme_juridique_code);
print '</td></tr>';
print '<tr><td>Effectif</td><td colspan="3">';
@ -184,7 +184,7 @@ elseif ($action == 'edit')
print '<tr><td>Forme juridique</td><td colspan="3">';
print $form->select_forme_juridique($soc->forme_juridique_id);
print $form->select_forme_juridique($soc->forme_juridique_code);
print '</td></tr>';
print '<tr><td>Effectif</td><td colspan="3">';

View File

@ -37,7 +37,6 @@ class Societe {
var $fax;
var $url;
var $siren;
var $forme_juridique_id;
var $forme_juridique_code;
var $forme_juridique;
var $client;
@ -54,7 +53,7 @@ class Societe {
$this->client = 0;
$this->fournisseur = 0;
$this->effectif_id = 0;
$this->forme_juridique_id = 0;
$this->forme_juridique_code = 0;
return 1;
}
@ -115,7 +114,7 @@ class Societe {
$sql .= ",tva_intra = '" . trim($this->tva_intra) ."'";
$sql .= ",capital = '" . $this->capital ."'";
$sql .= ",fk_effectif = '" . $this->effectif_id ."'";
$sql .= ",fk_forme_juridique = '" . $this->forme_juridique_id ."'";
$sql .= ",fk_forme_juridique = '" . $this->forme_juridique_code ."'";
$sql .= ",client = '" . $this->client ."'";
$sql .= ",fournisseur = '" . $this->fournisseur ."'";
$sql .= " WHERE idp = '" . $id ."';";
@ -142,7 +141,7 @@ class Societe {
$sql .= ", s.tel, s.fax, s.url,s.cp,s.ville, s.note, s.siren, client, fournisseur";
$sql .= ", s.siret, s.capital, s.ape, s.tva_intra, s.rubrique, s.fk_effectif";
$sql .= ", e.libelle as effectif, e.id as effectif_id";
$sql .= ", s.fk_forme_juridique as forme_juridique_id, fj.code as forme_juridique_code, fj.libelle as forme_juridique";
$sql .= ", s.fk_forme_juridique as forme_juridique_code, fj.libelle as forme_juridique";
$sql .= ", s.fk_departement, s.fk_pays, s.fk_stcomm";
$sql .= ", p.libelle as pays";
$sql .= ", st.libelle as stcomm";
@ -155,7 +154,7 @@ class Societe {
$sql .= " AND s.fk_stcomm = st.id";
$sql .= " AND s.fk_effectif = e.id";
$sql .= " AND s.fk_pays = p.rowid";
$sql .= " AND s.fk_forme_juridique = fj.rowid";
$sql .= " AND s.fk_forme_juridique = fj.code";
$result = $this->db->query($sql);
if ($result)
@ -197,7 +196,6 @@ class Societe {
$this->effectif = $obj->effectif;
$this->effectif_id = $obj->effectif_id;
$this->forme_juridique_id = $obj->forme_juridique_id;
$this->forme_juridique_code= $obj->forme_juridique_code;
$this->forme_juridique = $obj->forme_juridique;

View File

@ -409,7 +409,7 @@ insert into llx_c_propalst (id,label) values (4, 'Factur
--
-- Formes juridiques
--
insert into llx_c_forme_juridique (rowid, fk_pays, code, libelle) values (0, 0, 0,'Non renseignée');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (0, 0,'Non renseignée');
-- Pour la France: Extrait de http://www.insee.fr/fr/nom_def_met/nomenclatures/cj/cjniveau2.htm
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,11,'Artisan Commerçant');

View File

@ -97,6 +97,8 @@ create table llx_paiement_facture
insert into llx_const(name, value, type, note) values ('MAIN_UPLOAD_DOC','1','chaine','Authorise l\'upload de document');
update llx_societe set fk_forme_juridique=0 where fk_forme_juridique >= 54
drop table llx_c_forme_juridique;
@ -111,7 +113,7 @@ create table llx_c_forme_juridique
)type=innodb;
insert into llx_c_forme_juridique (rowid,fk_pays, code, libelle) values (0, 0, 0,'Non renseignée');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (0, 0,'Non renseignée');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,11,'Artisan Commerçant');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,12,'Commerçant');