|
From: | Fabrice Delliaux |
Subject: | [Dolibarr-dev] [patch ?] dolibarr et encodage de caractères BDD |
Date: | Mon, 08 May 2006 16:08:57 +0200 |
User-agent: | Mozilla Thunderbird 1.0.8 (X11/20060427) |
Bonjour, Je me permet d'envoyer ce mail au format html, afin d'y insérer quelques images, de façon à ce que vous puissiez visualiser le problème. ---------------------- Description du système ---------------------- Apache : AddDefaultCharset UTF-8 Mysql : configuré pour stocker au format utf-8 ----------------------- Description du problème ----------------------- Je récupère la dernière version de dolibarr par CVS, et je lance l'installation. Je créé donc un fichier .htaccess dans le répertoire htdocs/ contenant : AddDefaultCharset ISO-8859-1 Je relance apache, et j'obtiens : Tout va bien. L'installation se passe sans problème. Puis : - je me loggue en tant qu'administateur. - j'active les modules. - je créé un utilisateur en lui donnant les droits de créer/modifier/supprimer une société. - je me délogue. - je me loggue en tant qu'utilisateur. Je veux créér une société : Je clique sur le bouton créer société, et j'obtiens : Pourquoi ? Parce que mon système est totalement en utf-8. Il faut donc que je modifie ce(s) formulaire(s) en ajoutant dans les balises <form> du fichier htdocs/soc.php l'attribut accept-charset. <form action="" method="post" name="formsoc">devient : <form action="" method="post" name="formsoc" accept-charset="ISO-8859-1, UTF-8">J'effectue cette opération, et je réessaye : Et oui, ma base de données est en utf-8, je dois donc décoder tout ce qui sort de la base avant de l'afficher. En fait, actuellement, dolibarr ne tient pas compte de l'encodage de la base de données. ----------------- Création du patch ----------------- Je créé donc une nouvelle variable $dolibarr_main_db_enc lors de l'installation, stockée dans le fichier conf.php : Je modifie la classe societe.class.php pour créer des accesseurs : function get($member) Et finalement, à chaque appel d'un membre de cette classe, je dois utiliser ces accesseurs, par exemple : $mysoc->id=0devient : $mysoc->set('id', 0);Et : if ($objsoc->client==1)devient if ($objsoc->get('client')==1) Note : l'accesseur set() n'est pas obligatoire, mais c'est pour la forme. Tout ceci donne un patch ci-joint de plus de 50 Ko, rien que pour créer/modifier/supprimer une société. Evidemment, il faudrait reproduire ces modifications avec chacun des formulaires de dolibarr (mouarf !). Pouvez-vous tester ce patch sur votre système, et me dire si cela change quelque chose pour vous, afin de savoir si je dois continuer dans ce sens. Peut-être avez-vous une solution plus rapide / élégante ? Merci. |
diff -Nru dolibarr-old/htdocs/.htaccess dolibarr/htdocs/.htaccess --- dolibarr-old/htdocs/.htaccess 1970-01-01 01:00:00.000000000 +0100 +++ dolibarr/htdocs/.htaccess 2006-05-07 16:00:18.000000000 +0200 @@ -0,0 +1 @@ +AddDefaultCharset ISO-8859-1 diff -Nru dolibarr-old/htdocs/html.form.class.php dolibarr/htdocs/html.form.class.php --- dolibarr-old/htdocs/html.form.class.php 2006-05-06 23:09:26.000000000 +0200 +++ dolibarr/htdocs/html.form.class.php 2006-05-07 20:34:07.000000000 +0200 @@ -1308,10 +1308,10 @@ { global $langs; $formlength=16; - 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==1 && $soc->get('pays_code') == 'FR') $formlength=9; + if ($idprof==2 && $soc->get('pays_code') == 'FR') $formlength=14; + if ($idprof==3 && $soc->get('pays_code') == 'FR') $formlength=4; + if ($idprof==4 && $soc->get('pays_code') == 'FR') $formlength=4; print '<input type="text" name="'.$htmlname.'" size="'.($formlength+1).'" maxlength="'.$formlength.'" value="'.$selected.'">'; } diff -Nru dolibarr-old/htdocs/includes/modules/societe/mod_codecompta_panicum.php dolibarr/htdocs/includes/modules/societe/mod_codecompta_panicum.php --- dolibarr-old/htdocs/includes/modules/societe/mod_codecompta_panicum.php 2006-03-25 13:28:39.000000000 +0100 +++ dolibarr/htdocs/includes/modules/societe/mod_codecompta_panicum.php 2006-05-07 21:15:14.000000000 +0200 @@ -60,7 +60,7 @@ function get_code($DB, $societe) { // Renvoie toujours ok - $this->code = $societe->code_compta; + $this->code = $societe->get('code_compta'); return 0; } } diff -Nru dolibarr-old/htdocs/includes/triggers/interface_demo.class.php dolibarr/htdocs/includes/triggers/interface_demo.class.php --- dolibarr-old/htdocs/includes/triggers/interface_demo.class.php 2006-04-24 23:29:02.000000000 +0200 +++ dolibarr/htdocs/includes/triggers/interface_demo.class.php 2006-05-07 21:17:33.000000000 +0200 @@ -121,15 +121,15 @@ // Companies elseif ($action == 'COMPANY_CREATE') { - dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id); + dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->get('id')); } elseif ($action == 'COMPANY_MODIFY') { - dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id); + dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->get('id')); } elseif ($action == 'COMPANY_DELETE') { - dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->id); + dolibarr_syslog("Trigger '".$this->name."' for action '$action' launched. id=".$object->get('id')); } // Products elseif ($action == 'PRODUCT_CREATE') diff -Nru dolibarr-old/htdocs/install/etape1.php dolibarr/htdocs/install/etape1.php --- dolibarr-old/htdocs/install/etape1.php 2006-05-05 01:47:24.000000000 +0200 +++ dolibarr/htdocs/install/etape1.php 2006-05-07 23:06:10.000000000 +0200 @@ -128,6 +128,10 @@ fputs($fp, '$dolibarr_main_db_type="'.$_POST["db_type"].'";'); fputs($fp,"\n"); + + fputs($fp, '$dolibarr_main_db_enc='.$_POST["db_enc"].';'); + fputs($fp,"\n"); + fputs($fp, '?>'); fclose($fp); diff -Nru dolibarr-old/htdocs/install/fileconf.php dolibarr/htdocs/install/fileconf.php --- dolibarr-old/htdocs/install/fileconf.php 2006-01-04 17:22:38.000000000 +0100 +++ dolibarr/htdocs/install/fileconf.php 2006-05-07 23:00:08.000000000 +0200 @@ -178,6 +178,26 @@ </tr> <tr> +<!-- Encodage de la base de données --> +<td valign="top" class="label"> +<?php echo $langs->trans("DatabaseEnc"); ?> +</td> + +<td class="label"><select name='db_enc'> +<option value='false'<?php echo (! isset($dolibarr_main_db_enc) || ! $dolibarr_main_db_enc)?" selected":"" ?>><?php echo $langs->trans("no"); ?></option> +<option value='true'<?php echo (isset($dolibarr_main_db_enc) && $dolibarr_main_db_enc)?" selected":"" ?>><?php echo $langs->trans("yes"); ?></option> +</select> + +</td> + +<td class="comment"> +<?php echo $langs->trans("DatabaseEncDesc"); ?> +</td> + +</tr> + + +<tr> <td valign="top" class="label"> <?php echo $langs->trans("Server"); ?> </td> diff -Nru dolibarr-old/htdocs/langs/fr_FR/install.lang dolibarr/htdocs/langs/fr_FR/install.lang --- dolibarr-old/htdocs/langs/fr_FR/install.lang 2005-12-27 10:15:01.000000000 +0100 +++ dolibarr/htdocs/langs/fr_FR/install.lang 2006-05-08 10:02:32.000000000 +0200 @@ -18,6 +18,8 @@ DolibarrDatabase=Base de données Dolibarr DatabaseChoice=Choix de la base de données DatabaseType=Type de la base de données +DatabaseEnc=Encodage par défaut : utf8 ? +DatabaseEncDesc=La base de données est t'elle configurée par défaut pour stocker de l'utf-8 ? Si vous n'êtes pas sûr, laissez à non. Server=Serveur DatabaseName=Nom de la base de données Login=Login @@ -79,4 +81,4 @@ YouMustCreateWithPermission=Vous devez créer un fichier %s et donner les droits d'écriture dans celui-ci au serveur web durant le processus d'installation. CorrectProblemAndReloadPage=Corrigez le problème et <a href="index.php">rechargez la page</a> (Touche F5). AlreadyDone=Déjà migré -DatabaseVersion=Version de la base \ Pas de fin de ligne à la fin du fichier. +DatabaseVersion=Version de la base diff -Nru dolibarr-old/htdocs/lib/company.lib.php dolibarr/htdocs/lib/company.lib.php --- dolibarr-old/htdocs/lib/company.lib.php 2006-05-06 21:06:40.000000000 +0200 +++ dolibarr/htdocs/lib/company.lib.php 2006-05-07 19:53:04.000000000 +0200 @@ -35,28 +35,28 @@ $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id; + $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->get('id'); $head[$h][1] = $langs->trans("Company"); $head[$h][2] = 'company'; $h++; - if ($objsoc->client==1) + if ($objsoc->get('client')==1) { - $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objsoc->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objsoc->get('id'); $head[$h][1] = $langs->trans("Customer");; $head[$h][2] = 'customer'; $h++; } - if ($objsoc->client==2) + if ($objsoc->get('client')==2) { - $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$objsoc->id; + $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$objsoc->get('id'); $head[$h][1] = $langs->trans("Prospect"); $head[$h][2] = 'prospect'; $h++; } - if ($objsoc->fournisseur) + if ($objsoc->get('fournisseur')) { - $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$objsoc->id; + $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$objsoc->get('id'); $head[$h][1] = $langs->trans("Supplier"); $head[$h][2] = 'supplier'; $h++; @@ -65,20 +65,20 @@ if ($conf->compta->enabled || $conf->comptaexpert->enabled) { $langs->load("compta"); - $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$objsoc->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$objsoc->get('id'); $head[$h][1] = $langs->trans("Accountancy"); $head[$h][2] = 'compta'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$objsoc->id; + $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$objsoc->get('id'); $head[$h][1] = $langs->trans("Note"); $head[$h][2] = 'note'; $h++; if ($user->societe_id == 0) { - $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$objsoc->id; + $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$objsoc->get('id'); $head[$h][1] = $langs->trans("Documents"); $head[$h][2] = 'document'; $h++; @@ -86,20 +86,20 @@ if (! $conf->global->SOCIETE_DISABLE_NOTIFICATIONS) { - $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$objsoc->id; + $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$objsoc->get('id'); $head[$h][1] = $langs->trans("Notifications"); $head[$h][2] = 'notify'; $h++; } - $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$objsoc->id; + $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$objsoc->get('id'); $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; if ($user->societe_id == 0) { - $head[$h][0] = DOL_URL_ROOT."/bookmarks/fiche.php?action=add&socid=".$objsoc->id."&urlsource=".$_SERVER["PHP_SELF"]."?socid=".$objsoc->id; + $head[$h][0] = DOL_URL_ROOT."/bookmarks/fiche.php?action=add&socid=".$objsoc->get('id')."&urlsource=".$_SERVER["PHP_SELF"]."?socid=".$objsoc->get('id'); $head[$h][1] = img_object($langs->trans("BookmarkThisPage"),'bookmark'); $head[$h][2] = 'image'; $h++; @@ -108,4 +108,4 @@ return $head; } -?> \ Pas de fin de ligne à la fin du fichier. +?> diff -Nru dolibarr-old/htdocs/master.inc.php dolibarr/htdocs/master.inc.php --- dolibarr-old/htdocs/master.inc.php 2006-05-05 22:01:58.000000000 +0200 +++ dolibarr/htdocs/master.inc.php 2006-05-07 19:48:31.000000000 +0200 @@ -466,6 +466,28 @@ */ require_once(DOL_DOCUMENT_ROOT ."/societe.class.php"); $mysoc=new Societe($db); +$mysoc->set('id', 0); +$mysoc->set('nom', $conf->global->MAIN_INFO_SOCIETE_NOM); +$mysoc->set('adresse', $conf->global->MAIN_INFO_SOCIETE_ADRESSE); +$mysoc->set('cp', $conf->global->MAIN_INFO_SOCIETE_CP); + +$mysoc->set('ville', $conf->global->MAIN_INFO_SOCIETE_VILLE); +$mysoc->set('pays_code', $conf->global->MAIN_INFO_SOCIETE_PAYS); +$mysoc->set('tel', $conf->global->MAIN_INFO_SOCIETE_TEL); +$mysoc->set('fax', $conf->global->MAIN_INFO_SOCIETE_FAX); +$mysoc->set('url', $conf->global->MAIN_INFO_SOCIETE_WEB); +$mysoc->set('siren', $conf->global->MAIN_INFO_SIREN); +$mysoc->set('siret', $conf->global->MAIN_INFO_SIRET); +$mysoc->set('ape', $conf->global->MAIN_INFO_APE); +$mysoc->set('rcs', $conf->global->MAIN_INFO_RCS); +$mysoc->set('tva_assuj', $conf->global->FACTURE_TVAOPTION); +$mysoc->set('tva_intra', $conf->global->MAIN_INFO_TVAINTRA); +$mysoc->set('capital', $conf->global->MAIN_INFO_CAPITAL); +$mysoc->set('forme_juridique_code', $conf->global->MAIN_INFO_FORME_JURIDIQUE); +$mysoc->set('email', $conf->global->MAIN_INFO_SOCIETE_MAIL); +$mysoc->set('adresse_full', $mysoc->get('adresse')."\n".$mysoc->get('cp')." ".$mysoc->get('ville')); + +/* $mysoc->id=0; $mysoc->nom=$conf->global->MAIN_INFO_SOCIETE_NOM; $mysoc->adresse=$conf->global->MAIN_INFO_SOCIETE_ADRESSE; @@ -485,6 +507,7 @@ $mysoc->forme_juridique_code=$conf->global->MAIN_INFO_FORME_JURIDIQUE; $mysoc->email=$conf->global->MAIN_INFO_SOCIETE_MAIL; $mysoc->adresse_full=$mysoc->adresse."\n".$mysoc->cp." ".$mysoc->ville; +*/ /* \todo Ajouter une option Gestion de la TVA dans le module compta qui permet de désactiver la fonction TVA * (pour particuliers ou libéraux en franchise) diff -Nru dolibarr-old/htdocs/societe.class.php dolibarr/htdocs/societe.class.php --- dolibarr-old/htdocs/societe.class.php 2006-04-07 23:35:17.000000000 +0200 +++ dolibarr/htdocs/societe.class.php 2006-05-07 23:17:22.000000000 +0200 @@ -85,6 +85,21 @@ var $price_level; + function get($member) + { + global $dolibarr_main_db_enc; + if($dolibarr_main_db_enc) + return utf8_decode($this->{$member}); + else + return $this->{$member}; + } + + function set($member, $value) + { + $this->{$member} = $value; + } + + /** * \brief Constructeur de la classe * \param DB handler accès base de données diff -Nru dolibarr-old/htdocs/soc.php dolibarr/htdocs/soc.php --- dolibarr-old/htdocs/soc.php 2006-04-09 00:47:51.000000000 +0200 +++ dolibarr/htdocs/soc.php 2006-05-07 21:20:25.000000000 +0200 @@ -95,35 +95,35 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) && ($_POST["action"] == 'add' || $_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"]; - $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"]; - $soc->tva_intra_code = $_POST["tva_intra_code"]; - $soc->tva_intra_num = $_POST["tva_intra_num"]; - $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->typent_id = $_POST["typent_id"]; - $soc->client = $_POST["client"]; - $soc->fournisseur = $_POST["fournisseur"]; + $soc->set('nom', $_POST["nom"]); + $soc->set('adresse', $_POST["adresse"]); + $soc->set('cp', $_POST["cp"]); + $soc->set('ville', $_POST["ville"]); + $soc->set('pays_id', $_POST["pays_id"]); + $soc->set('departement_id', $_POST["departement_id"]); + $soc->set('tel', $_POST["tel"]); + $soc->set('fax', $_POST["fax"]); + $soc->set('url', ereg_replace( "http://", "", $_POST["url"] )); + $soc->set('siren', $_POST["siren"]); + $soc->set('siret', $_POST["siret"]); + $soc->set('ape', $_POST["ape"]); + $soc->set('prefix_comm', $_POST["prefix_comm"]); + $soc->set('code_client', $_POST["code_client"]); + $soc->set('code_fournisseur', $_POST["code_fournisseur"]); + $soc->set('codeclient_modifiable', $_POST["codeclient_modifiable"]); + $soc->set('codefournisseur_modifiable', $_POST["codefournisseur_modifiable"]); + $soc->set('capital', $_POST["capital"]); + + $soc->set('tva_assuj', $_POST["assujtva_value"]); + $soc->set('tva_intra_code', $_POST["tva_intra_code"]); + $soc->set('tva_intra_num', $_POST["tva_intra_num"]); + $soc->set('tva_intra', $_POST["tva_intra_code"].$_POST["tva_intra_num"]); + + $soc->set('forme_juridique_code', $_POST["forme_juridique_code"]); + $soc->set('effectif_id', $_POST["effectif_id"]); + $soc->set('typent_id', $_POST["typent_id"]); + $soc->set('client', $_POST["client"]); + $soc->set('fournisseur', $_POST["fournisseur"]); if ($_POST["action"] == 'add') { @@ -131,12 +131,12 @@ if ($result >= 0) { - Header("Location: soc.php?socid=".$soc->id); + Header("Location: soc.php?socid=".$soc->get('id')); exit; } else { - $mesg=$soc->error; + $mesg=$soc->get('error'); $_GET["action"]='create'; } } @@ -151,9 +151,9 @@ } else { - $soc->id = $socid; + $soc->set('id', $socid); $reload = 0; - $mesg = $soc->error; + $mesg = $soc->get('error'); $_GET["action"]= "edit"; } } @@ -169,7 +169,7 @@ if ($result == 0) { llxHeader(); - print '<div class="ok">'.$langs->trans("CompanyDeleted",$soc->nom).'</div>'; + print '<div class="ok">'.$langs->trans("CompanyDeleted",$soc->get('nom')).'</div>'; llxFooter(); exit ; } @@ -199,42 +199,45 @@ /* * Fiche societe en mode création */ - $soc->fournisseur=0; - if ($_GET["type"]=='f') { $soc->fournisseur=1; } - if ($_GET["type"]=='c') { $soc->client=1; } - if ($_GET["type"]=='p') { $soc->client=2; } + $soc->set('fournisseur', 0); + if ($_GET["type"]=='f') { $soc->set('fournisseur', 1); } + if ($_GET["type"]=='c') { $soc->set('client', 1); } + if ($_GET["type"]=='p') { $soc->set('client', 2); } if ($_POST["nom"]) { - $soc->nom=$_POST["nom"]; - $soc->prefix_comm=$_POST["prefix_comm"]; - $soc->client=$_POST["client"]; - $soc->code_client=$_POST["code_client"]; - $soc->fournisseur=$_POST["fournisseur"]; - $soc->code_fournisseur=$_POST["code_fournisseur"]; - $soc->adresse=$_POST["adresse"]; - $soc->cp=$_POST["cp"]; - $soc->ville=$_POST["ville"]; - $soc->departement_id=$_POST["departement_id"]; - $soc->tel=$_POST["tel"]; - $soc->fax=$_POST["fax"]; - $soc->url=$_POST["url"]; - $soc->capital=$_POST["capital"]; - $soc->siren=$_POST["siren"]; - $soc->siret=$_POST["siret"]; - $soc->ape=$_POST["ape"]; - $soc->typent_id=$_POST["typent_id"]; - $soc->effectif_id=$_POST["effectif_id"]; - - $soc->tva_assuj = $_POST["assujtva_value"]; - $soc->tva_intra_code=$_POST["tva_intra_code"]; - $soc->tva_intra_num=$_POST["tva_intra_num"]; + $soc->set('nom', $_POST["nom"]); + $soc->set('prefix_comm', $_POST["prefix_comm"]); + $soc->set('client', $_POST["client"]); + $soc->set('code_client', $_POST["code_client"]); + $soc->set('fournisseur', $_POST["fournisseur"]); + $soc->set('code_fournisseur', $_POST["code_fournisseur"]); + $soc->set('adresse', $_POST["adresse"]); + $soc->set('cp', $_POST["cp"]); + $soc->set('ville', $_POST["ville"]); + $soc->set('departement_id', $_POST["departement_id"]); + $soc->set('tel', $_POST["tel"]); + $soc->set('fax', $_POST["fax"]); + $soc->set('url', $_POST["url"]); + $soc->set('capital', $_POST["capital"]); + $soc->set('siren', $_POST["siren"]); + $soc->set('siret', $_POST["siret"]); + $soc->set('ape', $_POST["ape"]); + $soc->set('typent_id', $_POST["typent_id"]); + $soc->set('effectif_id', $_POST["effectif_id"]); + + $soc->set('tva_assuj', $_POST["assujtva_value"]); + $soc->set('tva_intra_code', $_POST["tva_intra_code"]); + $soc->set('tva_intra_num', $_POST["tva_intra_num"]); } + $soc->set('pays_id', $conf->global->MAIN_INFO_SOCIETE_PAYS); // On positionne pays_id, pays_code et libelle du pays choisi - $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS; - if ($soc->pays_id) + if($_POST["pays_id"]) + $soc->set('pays_id', $_POST["pays_id"]); + + if ($soc->get('pays_id')) { - $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id; + $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->get('pays_id'); $resql=$db->query($sql); if ($resql) { @@ -244,8 +247,8 @@ { dolibarr_print_error($db); } - $soc->pays_code=$obj->code; - $soc->pays=$obj->libelle; + $soc->set('pays_code', $obj->code); + $soc->set('pays', $obj->libelle); } print_titre($langs->trans("NewCompany")); @@ -258,7 +261,7 @@ print '</div>'; } - print '<form action="soc.php" method="post" name="formsoc">'; + print '<form action="soc.php" method="post" name="formsoc" accept-charset="ISO-8859-1, UTF-8">'; print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="codeclient_modifiable" value="1">'; @@ -266,18 +269,18 @@ print '<table class="border" width="100%">'; - print '<tr><td>'.$langs->trans('Name').'</td><td><input type="text" size="30" name="nom" value="'.$soc->nom.'"></td>'; - print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" name="prefix_comm" value="'.$soc->prefix_comm.'"></td></tr>'; + print '<tr><td>'.$langs->trans('Name').'</td><td><input type="text" size="30" name="nom" value="'.$soc->get('nom').'"></td>'; + print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" name="prefix_comm" value="'.$soc->get('prefix_comm').'"></td></tr>'; // Client / Prospect print '<tr><td width="25%">'.$langs->trans('ProspectCustomer').'</td><td width="25%"><select class="flat" name="client">'; - print '<option value="2"'.($soc->client==2?' selected="true"':'').'>'.$langs->trans('Prospect').'</option>'; - print '<option value="1"'.($soc->client==1?' selected="true"':'').'>'.$langs->trans('Customer').'</option>'; - print '<option value="0"'.($soc->client==0?' selected="true"':'').'>Ni client, ni prospect</option>'; + print '<option value="2"'.($soc->get('client')==2?' selected="true"':'').'>'.$langs->trans('Prospect').'</option>'; + print '<option value="1"'.($soc->get('client')==1?' selected="true"':'').'>'.$langs->trans('Customer').'</option>'; + print '<option value="0"'.($soc->get('client')==0?' selected="true"':'').'>Ni client, ni prospect</option>'; print '</select></td>'; print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">'; print '<table class="noborder"><tr><td>'; - print '<input type="text" name="code_client" size="16" value="'.$soc->code_client.'" maxlength="15"></td><td>'; + print '<input type="text" name="code_client" size="16" value="'.$soc->get('code_client').'" maxlength="15"></td><td>'; //print '<input type="image" name="getcustomercode" value="1" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/refresh.png" class="noborder">'; print '</td></tr></table>'; print '</td></tr>'; @@ -285,34 +288,34 @@ // Fournisseur print '<tr>'; print '<td>'.$langs->trans('Supplier').'</td><td>'; - $form->selectyesnonum("fournisseur",$soc->fournisseur); + $form->selectyesnonum("fournisseur",$soc->get('fournisseur')); print '</td>'; print '<td>'.$langs->trans('SupplierCode').'</td><td>'; print '<table class="noborder"><tr><td>'; - print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->code_fournisseur.'" maxlength="15"></td><td>'; + print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->get('code_fournisseur').'" maxlength="15"></td><td>'; //print '<input type="image" name="getsuppliercode" value="1" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/refresh.png" class="noborder">'; print '</td></tr></table>'; print '</td></tr>'; print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">'; - print $soc->adresse; + print $soc->get('adresse'); print '</textarea></td></tr>'; - print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'"'; + print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->get('cp').'"'; if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"'; print '>'; if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville)">'; print '</td>'; - print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>'; + print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->get('ville').'"></td></tr>'; print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">'; - $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':''); + $form->select_pays($soc->get('pays_id'),'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':''); print '</td></tr>'; print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'; - if ($soc->pays_id) + if ($soc->get('pays_id')) { - $form->select_departement($soc->departement_id,$soc->pays_code); + $form->select_departement($soc->get('departement_id'),$soc->get('pays_code')); } else { @@ -320,17 +323,18 @@ } print '</td></tr>'; - print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>'; - print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>'; + print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->get('tel').'"></td>'; + print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->get('fax').'"></td></tr>'; - print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3"><input type="text" name="url" size="40" value="'.$soc->url.'"></td></tr>'; + print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3"><input type="text" name="url" size="40" value="'.$soc->get('url').'"></td></tr>'; - print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; + print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->get('capital').'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; - print '<tr><td>'.($langs->transcountry("ProfId1",$soc->pays_code) != '-'?$langs->transcountry('ProfId1',$soc->pays_code):'').'</td><td>'; - if ($soc->pays_id) + print '<tr><td>'.($langs->transcountry("ProfId1",$soc->get('pays_code')) != '-'?$langs->transcountry('ProfId1',$soc->get('pays_code')):'').'</td><td>'; + if ($soc->get('pays_id')) { - if ($langs->transcountry("ProfId1",$soc->pays_code) != '-') print '<input type="text" name="siren" size="15" maxlength="9" value="'.$soc->siren.'">'; + if ($langs->transcountry("ProfId1",$soc->get('pays_code')) != '-') + print '<input type="text" name="siren" size="15" maxlength="9" value="'.$soc->get('siren').'">'; else print ' '; } else @@ -338,10 +342,11 @@ print $countrynotdefined; } print '</td>'; - print '<td>'.($langs->transcountry("ProfId2",$soc->pays_code) != '-'?$langs->transcountry('ProfId2',$soc->pays_code):'').'</td><td>'; - if ($soc->pays_id) + print '<td>'.($langs->transcountry("ProfId2",$soc->get('pays_code')) != '-'?$langs->transcountry('ProfId2',$soc->get('pays_code')):'').'</td><td>'; + if ($soc->get('pays_id')) { - if ($langs->transcountry("ProfId2",$soc->pays_code) != '-') print '<input type="text" name="siret" size="15" maxlength="14" value="'.$soc->siret.'">'; + if ($langs->transcountry("ProfId2",$soc->get('pays_code')) != '-') + print '<input type="text" name="siret" size="15" maxlength="14" value="'.$soc->get('siret').'">'; else print ' '; } else @@ -349,10 +354,11 @@ print $countrynotdefined; } print '</td></tr>'; - print '<tr><td>'.($langs->transcountry("ProfId3",$soc->pays_code) != '-'?$langs->transcountry('ProfId3',$soc->pays_code):'').'</td><td>'; - if ($soc->pays_id) + print '<tr><td>'.($langs->transcountry("ProfId3",$soc->get('pays_code')) != '-'?$langs->transcountry('ProfId3',$soc->get('pays_code')):'').'</td><td>'; + if ($soc->get('pays_id')) { - if ($langs->transcountry("ProfId3",$soc->pays_code) != '-') print '<input type="text" name="ape" size="5" maxlength="4" value="'.$soc->ape.'">'; + if ($langs->transcountry("ProfId3",$soc->get('pays_code')) != '-') + print '<input type="text" name="ape" size="5" maxlength="4" value="'.$soc->get('ape').'">'; else print ' '; } else @@ -362,9 +368,9 @@ print '</td><td colspan="2"> </td></tr>'; print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'; - if ($soc->pays_id) + if ($soc->get('pays_id')) { - $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); + $form->select_forme_juridique($soc->get('forme_juridique_code'),$soc->get('pays_code')); } else { @@ -373,10 +379,10 @@ print '</td></tr>'; print '<tr><td>'.$langs->trans("Type").'</td><td>'; - $form->select_array("typent_id",$soc->typent_array(), $soc->typent_id); + $form->select_array("typent_id",$soc->typent_array(), $soc->get('typent_id')); print '</td>'; print '<td>'.$langs->trans("Staff").'</td><td>'; - $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id); + $form->select_array("effectif_id",$soc->effectif_array(), $soc->get('effectif_id')); print '</td></tr>'; print '<tr><td nowrap>'.$langs->trans('VATIntraShort').'</td><td colspan="3">'; @@ -415,7 +421,7 @@ if ($reload || ! $_POST["nom"]) { $soc = new Societe($db); - $soc->id = $socid; + $soc->set('id', $socid); $soc->fetch($socid); } else @@ -467,34 +473,34 @@ if ($soc->error) { print '<div class="error">'; - print $soc->error; + print $soc->get('error'); print '</div>'; } - print '<form action="soc.php?socid='.$soc->id.'" method="post" name="formsoc">'; + print '<form action="soc.php?socid='.$soc->get('id').'" method="post" name="formsoc" accept-charset="ISO-8859-1, UTF-8">'; 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 '<input type="hidden" name="socid" value="'.$soc->get('id').'">'; + print '<input type="hidden" name="codeclient_modifiable" value="'.$soc->get('codeclient_modifiable').'">'; + print '<input type="hidden" name="codefournisseur_modifiable" value="'.$soc->get('codefournisseur_modifiable').'">'; print '<table class="border" width="100%">'; - print '<tr><td>'.$langs->trans('Name').'</td><td colspan="3"><input type="text" size="40" name="nom" value="'.$soc->nom.'"></td></tr>'; + print '<tr><td>'.$langs->trans('Name').'</td><td colspan="3"><input type="text" size="40" name="nom" value="'.$soc->get('nom').'"></td></tr>'; print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">'; - print '<input type="text" size="5" name="prefix_comm" value="'.$soc->prefix_comm.'">'; + print '<input type="text" size="5" name="prefix_comm" value="'.$soc->get('prefix_comm').'">'; print '</td>'; // Client / Prospect print '<tr><td width="25%">'.$langs->trans('ProspectCustomer').'</td><td width="25%"><select class="flat" name="client">'; - print '<option value="2"'.($soc->client==2?' selected="true"':'').'>'.$langs->trans('Prospect').'</option>'; - print '<option value="1"'.($soc->client==1?' selected="true"':'').'>'.$langs->trans('Customer').'</option>'; - print '<option value="0"'.($soc->client==0?' selected="true"':'').'>Ni client, ni prospect</option>'; + print '<option value="2"'.($soc->get('client')==2?' selected="true"':'').'>'.$langs->trans('Prospect').'</option>'; + print '<option value="1"'.($soc->get('client')==1?' selected="true"':'').'>'.$langs->trans('Customer').'</option>'; + print '<option value="0"'.($soc->get('client')==0?' selected="true"':'').'>Ni client, ni prospect</option>'; print '</select></td>'; print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">'; - if ($soc->codeclient_modifiable == 1) + if ($soc->get('codeclient_modifiable') == 1) { - print '<input type="text" name="code_client" size="16" value="'.$soc->code_client.'" maxlength="15">'; + print '<input type="text" name="code_client" size="16" value="'.$soc->get('code_client').'" maxlength="15">'; } else { @@ -505,71 +511,71 @@ // Fournisseur print '<tr>'; print '<td>'.$langs->trans('Supplier').'</td><td>'; - $form->selectyesnonum("fournisseur",$soc->fournisseur); + $form->selectyesnonum("fournisseur",$soc->get('fournisseur')); print '</td>'; print '<td>'.$langs->trans('SupplierCode').'</td><td>'; - if ($soc->codefournisseur_modifiable == 1) + if ($soc->get('codefournisseur_modifiable') == 1) { - print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->code_fournisseur.'" maxlength="15">'; + print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->get('code_fournisseur').'" maxlength="15">'; } else { - print $soc->code_fournisseur; + print $soc->get('code_fournisseur'); } print '</td></tr>'; print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">'; - print $soc->adresse; + print $soc->get('adresse'); print '</textarea></td></tr>'; - print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'"'; + print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->get('cp').'"'; if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"'; print '>'; if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville)">'; print '</td>'; - print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>'; + print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->get('ville').'"></td></tr>'; print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'; - $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_edit()"':''); + $form->select_pays($soc->get('pays_id'),'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_edit()"':''); print '</td></tr>'; print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'; - $form->select_departement($soc->departement_id,$soc->pays_code); + $form->select_departement($soc->get('departement_id'),$soc->get('pays_code')); print '</td></tr>'; - print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>'; - print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>'; + print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->get('tel').'"></td>'; + print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->get('fax').'"></td></tr>'; - print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3"><input type="text" name="url" size="40" value="'.$soc->url.'"></td></tr>'; + print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3"><input type="text" name="url" size="40" value="'.$soc->get('url').'"></td></tr>'; print '<tr>'; // IdProf1 - $idprof=$langs->transcountry('ProfId1',$soc->pays_code); + $idprof=$langs->transcountry('ProfId1',$soc->get('pays_code')); if ($idprof!='-') { print '<td>'.$idprof.'</td><td>'; - $form->id_prof(1,$soc,'siren',$soc->siren); + $form->id_prof(1,$soc,'siren',$soc->get('siren')); print '</td>'; } else print '<td> </td><td> </td>'; // IdProf2 - $idprof=$langs->transcountry('ProfId2',$soc->pays_code); + $idprof=$langs->transcountry('ProfId2',$soc->get('pays_code')); if ($idprof!='-') { print '<td>'.$idprof.'</td><td>'; - $form->id_prof(2,$soc,'siret',$soc->siret); + $form->id_prof(2,$soc,'siret',$soc->get('siret')); print '</td>'; } else print '<td> </td><td> </td>'; print '</tr>'; print '<tr>'; // IdProf3 - $idprof=$langs->transcountry('ProfId3',$soc->pays_code); + $idprof=$langs->transcountry('ProfId3',$soc->get('pays_code')); if ($idprof!='-') { print '<td>'.$idprof.'</td><td>'; - $form->id_prof(3,$soc,'ape',$soc->ape); + $form->id_prof(3,$soc,'ape',$soc->get('ape')); print '</td>'; } else print '<td> </td><td> </td>'; @@ -579,7 +585,7 @@ if ($idprof!='-') { print '<td>'.$idprof.'</td><td>'; - $form->id_prof(4,$soc,'rcs',$soc->rcs); + $form->id_prof(4,$soc,'rcs',$soc->get('rcs')); print '</td>'; } else print '<td> </td><td> </td>'; @@ -587,26 +593,27 @@ // Assujeti TVA print '<tr><td>'.$langs->trans('VATIsUsed').'</td><td>'; - $form->select_assujetti_tva($soc->tva_assuj,'assujtva_value'); + $form->select_assujetti_tva($soc->get('tva_assuj'),'assujtva_value'); print '</td>'; print '<td nowrap="nowrap">'.$langs->trans('VATIntraShort').'</td><td>'; - print '<input type="text" name="tva_intra_code" size="3" maxlength="2" value="'.$soc->tva_intra_code.'">'; - print '<input type="text" name="tva_intra_num" size="18" maxlength="18" value="'.$soc->tva_intra_num.'">'; - print ' <a href="'.$langs->transcountry("VATIntraCheckURL",$soc->id_pays).'" target="_blank" alt="'.$langs->trans("VATIntraCheckableOnEUSite").'">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>'; + print '<input type="text" name="tva_intra_code" size="3" maxlength="2" value="'.$soc->get('tva_intra_code').'">'; + print '<input type="text" name="tva_intra_num" size="18" maxlength="18" value="'.$soc->get('tva_intra_num').'">'; + print ' <a href="'.$langs->transcountry("VATIntraCheckURL",$soc->get('id_pays')).'" target="_blank" alt="'.$langs->trans("VATIntraCheckableOnEUSite").'">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>'; print '</td></tr>'; - print '<tr><td>'.$langs->trans("Capital").'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; + print '<tr><td>'.$langs->trans("Capital").'</td><td colspan="3"><input + type="text" name="capital" size="10" value="'.$soc->get('capital').'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'; - $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); + $form->select_forme_juridique($soc->get('forme_juridique_code'),$soc->get('pays_code')); print '</td></tr>'; print '<tr><td>'.$langs->trans("Type").'</td><td>'; - $form->select_array("typent_id",$soc->typent_array(), $soc->typent_id); + $form->select_array("typent_id",$soc->typent_array(), $soc->get('typent_id')); print '</td>'; print '<td>'.$langs->trans("Staff").'</td><td>'; - $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id); + $form->select_array("effectif_id",$soc->effectif_array(), $soc->get('effectif_id')); print '</td></tr>'; print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>'; @@ -621,7 +628,7 @@ * Fiche société en mode visu */ $soc = new Societe($db); - $soc->id = $socid; + $mysoc->set('id', $socid); $result=$soc->fetch($socid); if ($result < 0) { @@ -631,40 +638,40 @@ $head = societe_prepare_head($soc); - dolibarr_fiche_head($head, 'company', $soc->nom); + dolibarr_fiche_head($head, 'company', $soc->get('nom')); // Confirmation de la suppression de la facture if ($_GET["action"] == 'delete') { $html = new Form($db); - $html->form_confirm("soc.php?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete"); + $html->form_confirm("soc.php?socid=".$soc->get('id'),$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete"); print "<br />\n"; } - if ($soc->error) + if ($soc->get('error')) { print '<div class="error">'; - print $soc->error; + print $soc->get('error'); print '</div>'; } print '<table class="border" width="100%">'; - print '<tr><td width="20%">'.$langs->trans('Name').'</td><td colspan="3">'.$soc->nom.'</td></tr>'; + print '<tr><td width="20%">'.$langs->trans('Name').'</td><td colspan="3">'.$soc->get('nom').'</td></tr>'; - print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$soc->prefix_comm.'</td></tr>'; + print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$soc->get('prefix_comm').'</td></tr>'; - if ($soc->client) { + if ($soc->get('client')) { print '<tr><td>'; print $langs->trans('CustomerCode').'</td><td colspan="3">'; - print $soc->code_client; + print $soc->get('code_client'); if ($soc->check_codeclient() <> 0) print ' '.$langs->trans("WrongCustomerCode"); print '</td></tr>'; } - if ($soc->fournisseur) { + if ($soc->get('fournisseur')) { print '<tr><td>'; print $langs->trans('SupplierCode').'</td><td colspan="3">'; print $soc->code_fournisseur; @@ -672,30 +679,30 @@ print '</td></tr>'; } - print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->adresse)."</td></tr>"; + print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->get('adresse'))."</td></tr>"; - print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$soc->cp."</td>"; - print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->ville."</td></tr>"; + print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$soc->get('cp')."</td>"; + print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->get('ville')."</td></tr>"; - print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$soc->pays.'</td>'; + print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$soc->get('pays').'</td>'; print '</td></tr>'; - print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$soc->departement.'</td>'; + print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$soc->get('departement').'</td>'; - print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dolibarr_print_phone($soc->tel).'</td>'; - print '<td>'.$langs->trans('Fax').'</td><td>'.dolibarr_print_phone($soc->fax).'</td></tr>'; + print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dolibarr_print_phone($soc->get('tel')).'</td>'; + print '<td>'.$langs->trans('Fax').'</td><td>'.dolibarr_print_phone($soc->get('fax')).'</td></tr>'; print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3">'; - if ($soc->url) { print '<a href="http://'.$soc->url.'" target="_blank">http://'.$soc->url.'</a>'; } + if ($soc->get('url')) { print '<a href="http://'.$soc->get('url').'" target="_blank">http://'.$soc->get('url').'</a>'; } print '</td></tr>'; // ProfId1 - $profid=$langs->transcountry('ProfId1',$soc->pays_code); + $profid=$langs->transcountry('ProfId1',$soc->get('pays_code')); if ($profid!='-') { print '<tr><td>'.$profid.'</td><td>'; - print $soc->siren; - if ($soc->siren) + print $soc->get('siren'); + if ($soc->get('siren')) { if ($soc->id_prof_check(1,$soc) > 0) print ' '.$soc->id_prof_url(1,$soc); else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>'; @@ -704,12 +711,12 @@ } else print '<tr><td> </td><td> </td>'; // ProfId2 - $profid=$langs->transcountry('ProfId2',$soc->pays_code); + $profid=$langs->transcountry('ProfId2',$soc->get('pays_code')); if ($profid!='-') { print '<td>'.$profid.'</td><td>'; - print $soc->siret; - if ($soc->siret) + print $soc->get('siret'); + if ($soc->get('siret')) { if ($soc->id_prof_check(2,$soc) > 0) print ' '.$soc->id_prof_url(2,$soc); else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>'; @@ -719,12 +726,12 @@ else print '<td> </td><td> </td></tr>'; // ProfId3 - $profid=$langs->transcountry('ProfId3',$soc->pays_code); + $profid=$langs->transcountry('ProfId3',$soc->get('pays_code')); if ($profid!='-') { print '<tr><td>'.$profid.'</td><td>'; - print $soc->ape; - if ($soc->ape) + print $soc->get('ape'); + if ($soc->get('ape')) { if ($soc->id_prof_check(3,$soc) > 0) print ' '.$soc->id_prof_url(3,$soc); else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>'; @@ -738,8 +745,8 @@ if ($profid!='-') { print '<td>'.$profid.'</td><td>'; - print $soc->rcs; - if ($soc->rcs) + print $soc->get('rcs'); + if ($soc->get('rcs')) { if ($soc->id_prof_check(4,$soc) > 0) print ' '.$soc->id_prof_url(4,$soc); else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>'; @@ -772,24 +779,24 @@ */ print $langs->trans('VATIsUsed'); print '</td><td>'; - print yn($soc->tva_assuj); + print yn($soc->get('tva_assuj')); print '</td>'; print '<td nowrap="nowrpa">'.$langs->trans('VATIntraShort').'</td><td colspan="3">'; - print $soc->tva_intra; + print $soc->get('tva_intra'); print '</td></tr>'; // Capital print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3">'; - if ($soc->capital) print $soc->capital.' '.$langs->trans("Currency".$conf->monnaie); + if ($soc->get('capital')) print $soc->get('capital').' '.$langs->trans("Currency".$conf->monnaie); else print ' '; print '</td></tr>'; // Statut juridique - print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'.$soc->forme_juridique.'</td></tr>'; + print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'.$soc->get('forme_juridique').'</td></tr>'; // Type + Staff - $arr = $soc->typent_array($soc->typent_id); - $soc->typent= $arr[$soc->typent_id]; + $arr = $soc->typent_array($soc->get('typent_id')); + $soc->typent= $arr[$soc->get('typent_id')]; print '<tr><td>'.$langs->trans("Type").'</td><td>'.$soc->typent.'</td><td>'.$langs->trans("Staff").'</td><td>'.$soc->effectif.'</td></tr>'; // RIB @@ -798,7 +805,7 @@ print $langs->trans('RIB'); print '<td><td align="right">'; if ($user->rights->societe->creer) - print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'">'.img_edit().'</a>'; + print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->get('id').'">'.img_edit().'</a>'; else print ' '; print '</td></tr></table>'; @@ -813,7 +820,7 @@ print $langs->trans('ParentCompany'); print '<td><td align="right">'; if ($user->rights->societe->creer) - print '<a href="'.DOL_URL_ROOT.'/societe/lien.php?socid='.$soc->id.'">'.img_edit() .'</a>'; + print '<a href="'.DOL_URL_ROOT.'/societe/lien.php?socid='.$soc->get('id').'">'.img_edit() .'</a>'; else print ' '; print '</td></tr></table>'; @@ -836,7 +843,8 @@ print $langs->trans('SalesRepresentatives'); print '<td><td align="right">'; if ($user->rights->societe->creer) - print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$soc->id.'">'.img_edit().'</a>'; + print '<a + href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$soc->get('id').'">'.img_edit().'</a>'; else print ' '; print '</td></tr></table>'; @@ -845,7 +853,7 @@ $sql = "SELECT count(sc.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE sc.fk_soc =".$soc->id; + $sql.= " WHERE sc.fk_soc =".$soc->get('id'); $resql = $db->query($sql); if ($resql) @@ -870,23 +878,23 @@ if ($user->rights->societe->creer) { - print '<a class="butAction" href="'.DOL_URL_ROOT.'/soc.php?socid='.$soc->id.'&action=edit">'.$langs->trans("Edit").'</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/soc.php?socid='.$soc->get('id').'&action=edit">'.$langs->trans("Edit").'</a>'; } if ($conf->projet->enabled && $user->rights->projet->creer) { $langs->load("projects"); - print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$soc->get('id').'&action=create">'.$langs->trans("AddProject").'</a>'; } if ($user->rights->societe->contact->creer) { - print '<a class="butAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddContact").'</a>'; + print '<a class="butAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$soc->get('id').'&action=create">'.$langs->trans("AddContact").'</a>'; } if ($user->rights->societe->supprimer) { - print '<a class="butActionDelete" href="'.DOL_URL_ROOT.'/soc.php?socid='.$soc->id.'&action=delete">'.$langs->trans("Delete").'</a>'; + print '<a class="butActionDelete" href="'.DOL_URL_ROOT.'/soc.php?socid='.$soc->get('id').'&action=delete">'.$langs->trans("Delete").'</a>'; } print '</div>';
[Prev in Thread] | Current Thread | [Next in Thread] |