From 6b64aa40ace1291f7e35d6864fa380ef07fb5f5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 20 Aug 2005 14:36:32 +0000 Subject: [PATCH] =?UTF-8?q?New:=20Ajout=20de=20la=20forme=20juridique=20da?= =?UTF-8?q?ns=20la=20configuration=20globale=20de=20sa=20soci=E9t=E9=20(re?= =?UTF-8?q?quis=20dans=20les=20factures).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/admin/index.php | 354 +++++++++++------- htdocs/facture.class.php | 3 + htdocs/html.form.class.php | 36 +- .../modules/facture/pdf_crabe.modules.php | 23 +- htdocs/langs/en_US/admin.lang | 2 + htdocs/langs/fr_FR/admin.lang | 2 + htdocs/lib/functions.inc.php | 23 +- mysql/data/data.sql | 2 +- 8 files changed, 298 insertions(+), 147 deletions(-) diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 054e28c65f6..2eeee4c4c49 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -35,108 +35,186 @@ if (!$user->admin) accessforbidden(); -if (isset($_POST["action"]) && $_POST["action"] == 'update') +if ( (isset($_POST["action"]) && $_POST["action"] == 'update') + || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) { - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"]); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"]); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS",$_POST["pays_id"]); - dolibarr_set_const($db, "MAIN_MONNAIE",$_POST["currency"]); - dolibarr_set_const($db, "MAIN_INFO_CAPITAL",$_POST["capital"]); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"]); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"]); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS",$_POST["pays_id"]); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE",$_POST["forme_juridique_code"]); + dolibarr_set_const($db, "MAIN_MONNAIE",$_POST["currency"]); + dolibarr_set_const($db, "MAIN_INFO_CAPITAL",$_POST["capital"]); - dolibarr_set_const($db, "MAIN_INFO_SIREN",$_POST["siren"]); - dolibarr_set_const($db, "MAIN_INFO_SIRET",$_POST["siret"]); - dolibarr_set_const($db, "MAIN_INFO_APE",$_POST["ape"]); - dolibarr_set_const($db, "MAIN_INFO_TVAINTRA",$_POST["tva"]); + dolibarr_set_const($db, "MAIN_INFO_SIREN",$_POST["siren"]); + dolibarr_set_const($db, "MAIN_INFO_SIRET",$_POST["siret"]); + dolibarr_set_const($db, "MAIN_INFO_APE",$_POST["ape"]); + dolibarr_set_const($db, "MAIN_INFO_TVAINTRA",$_POST["tva"]); - Header("Location: index.php"); + if ($_POST['action'] != 'updateedit') + { + Header("Location: index.php"); + } } + llxHeader(); $form = new Form($db); +$countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; + print_titre($langs->trans("GlobalSetup")); print "
\n"; -if (isset($_GET["action"]) && $_GET["action"] == 'edit') +if ((isset($_GET["action"]) && $_GET["action"] == 'edit') + || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) { - /* - * Edition des paramètres - */ - print '
'; - print ''; + /* + * Edition des paramètres + */ + print ' + + '; - print ''; - print ''; + print ''; + print ''; + $var=true; - print ''; + print '
'.$langs->trans("CompanyInfo").'
'.$langs->trans("CompanyName").''; - print '
'; + print ''; - print ''; + $var=!$var; + print ''; - print ''; + $var=!$var; + print ''; - print ''; + $var=!$var; + print ''; - print ''; + $var=!$var; + print ''; - print '
'.$langs->trans("CompanyInfo").'
'.$langs->trans("CompanyAddress").''; - print '
'.$langs->trans("CompanyName").''; + print '
'.$langs->trans("Country").''; - $form->select_pays(MAIN_INFO_SOCIETE_PAYS); - print '
'.$langs->trans("CompanyAddress").''; + print '
'.$langs->trans("CompanyCurrency").''; - $form->select_currency(MAIN_MONNAIE,"currency"); - print '
'.$langs->trans("Country").''; + $form->select_pays($conf->global->MAIN_INFO_SOCIETE_PAYS,'pays_id',' onChange="save_refresh()"'); + print '
'.$langs->trans("Capital").''; - print '
'.$langs->trans("CompanyCurrency").''; + $form->select_currency($conf->global->MAIN_MONNAIE,"currency"); + print '
'; + $var=!$var; + print ''.$langs->trans("Capital").''; + print ''; - print '
'; - - print ''; - print ''; + print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'; - $langs->load("companies"); + print '
'; - // Recupere code pays - $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation - $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; - $sql .= " WHERE rowid = ".MAIN_INFO_SOCIETE_PAYS; - $result=$db->query($sql); - if ($result) { - $obj = $db->fetch_object(); - if ($obj->code) $code_pays=$obj->code; - } - else { - dolibarr_print_error($db); - } - - if ($langs->transcountry("ProfId1",$code_pays) != '-') - { - print ''.$langs->transcountry("ProfId1",$code_pays).''; - print ''; - } - - if ($langs->transcountry("ProfId2",$code_pays) != '-') - { - print ''.$langs->transcountry("ProfId2",$code_pays).''; - print ''; - } + // Identifiants de la société (propre au pays) + print ''; + print ''; + $var=true; - if ($langs->transcountry("ProfId3",$code_pays) != '-') - { - print ''; - } - - print ''; + $langs->load("companies"); - print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->transcountry("ProfId3",$code_pays).''; - print '
'.$langs->trans("TVAIntra").''; - print '
'; + // Recupere code pays + $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; + $sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS; + $result=$db->query($sql); + if ($result) { + $obj = $db->fetch_object(); + if ($obj->code) $code_pays=$obj->code; + } + else { + dolibarr_print_error($db); + } + } - print '
'; + // Forme juridique + $var=!$var; + print ''.$langs->trans("JuridicalStatus").''; + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + $form->select_forme_juridique($conf->global->MAIN_INFO_FORME_JURIDIQUE,$code_pays); + } + else + { + print $countrynotdefined; + } + print ''; - print '
'; + // ProfID1 + $var=!$var; + print ''.$langs->transcountry("ProfId1",$code_pays).''; + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + if ($langs->transcountry("ProfId1",$code_pays) != '-') + { + print ''; + } + } + else + { + print $countrynotdefined; + } + print ''; + + // ProfId2 + $var=!$var; + print ''.$langs->transcountry("ProfId2",$code_pays).''; + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + if ($langs->transcountry("ProfId2",$code_pays) != '-') + { + print ''; + } + } + else + { + print $countrynotdefined; + } + print ''; + + // ProfId3 + $var=!$var; + print ''.$langs->transcountry("ProfId3",$code_pays).''; + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + if ($langs->transcountry("ProfId3",$code_pays) != '-') + { + print ''; + } + } + else + { + print $countrynotdefined; + } + print ''; + + // TVA Intra + $var=!$var; + print ''.$langs->trans("TVAIntra").''; + print ''; + + print ''; + + print '
'; + + print ''; } else { @@ -144,71 +222,95 @@ else * Affichage des paramètres */ - print ''; - print ''; + print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'; + print ''; + $var=true; - print ''; + $var=!$var; + print ''; - print ''; + $var=!$var; + print ''; - print ''; + $var=!$var; + print ''; - print ''; + $var=!$var; + print ''; - print ''; + $var=!$var; + print ''; - print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyName").'' . MAIN_INFO_SOCIETE_NOM . '
'.$langs->trans("CompanyName").'' . $conf->global->MAIN_INFO_SOCIETE_NOM . '
'.$langs->trans("CompanyAddress").'' . nl2br(MAIN_INFO_SOCIETE_ADRESSE) . '
'.$langs->trans("CompanyAddress").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_ADRESSE) . '
'.$langs->trans("Country").''; - print $form->pays_name(MAIN_INFO_SOCIETE_PAYS,1); - print '
'.$langs->trans("Country").''; + print $form->pays_name($conf->global->MAIN_INFO_SOCIETE_PAYS,1); + print '
'.$langs->trans("CompanyCurrency").''; - print $form->currency_name(MAIN_MONNAIE,1); - print '
'.$langs->trans("CompanyCurrency").''; + print $form->currency_name($conf->global->MAIN_MONNAIE,1); + print '
'.$langs->trans("Capital").''; - print MAIN_INFO_CAPITAL . '
'.$langs->trans("Capital").''; + print $conf->global->MAIN_INFO_CAPITAL . '
'; + print ''; - print '
'; - - print ''; - print ''; + print '
'; - // Recupere code pays - $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation - $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; - $sql .= " WHERE rowid = ".MAIN_INFO_SOCIETE_PAYS; - $result=$db->query($sql); - if ($result) { - $obj = $db->fetch_object(); - if ($obj->code) $code_pays=$obj->code; - } - else { - dolibarr_print_error($db); - } - - if ($langs->transcountry("ProfId1",$code_pays) != '-') - { - print ''; - } - - if ($langs->transcountry("ProfId2",$code_pays) != '-') - { - print ''; - } - - if ($langs->transcountry("ProfId3",$code_pays) != '-') - { - print ''; - } - - print ''; + // Identifiants de la société (propre au pays) + print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->transcountry("ProfId1",$code_pays).''; - print MAIN_INFO_SIREN . '
'.$langs->transcountry("ProfId2",$code_pays).''; - print MAIN_INFO_SIRET . '
'.$langs->transcountry("ProfId3",$code_pays).''; - print MAIN_INFO_APE . '
'.$langs->trans("TVAIntra").'' . MAIN_INFO_TVAINTRA . '
'; + print ''; + $var=true; - print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'

'; + // Recupere code pays + $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; + $sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS; + $result=$db->query($sql); + if ($result) + { + $obj = $db->fetch_object(); + if ($obj->code) $code_pays=$obj->code; + } + else { + dolibarr_print_error($db); + } + } - // Boutons d'action - print '
'; - print ''.$langs->trans("Edit").''; - print '
'; + // Forme juridique + $var=!$var; + print ''.$langs->trans("JuridicalStatus").''; + print $form->forme_juridique_name($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,1); + print ''; + $var=!$var; + print ''.$langs->transcountry("ProfId1",$code_pays).''; + if ($langs->transcountry("ProfId1",$code_pays) != '-') + { + print $conf->global->MAIN_INFO_SIREN; + } + print ''; + + $var=!$var; + print ''.$langs->transcountry("ProfId2",$code_pays).''; + if ($langs->transcountry("ProfId2",$code_pays) != '-') + { + print $conf->global->MAIN_INFO_SIRET; + } + print ''; + + $var=!$var; + print ''.$langs->transcountry("ProfId3",$code_pays).''; + if ($langs->transcountry("ProfId3",$code_pays) != '-') + { + print $conf->global->MAIN_INFO_APE; + } + print ''; + + $var=!$var; + print ''.$langs->trans("TVAIntra").'' . $conf->global->MAIN_INFO_TVAINTRA . ''; + + print '
'; + + // Boutons d'action + print '
'; + print ''.$langs->trans("Edit").''; + print '
'; } diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 4fa1c9e9aaf..a34c20ec378 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -1642,6 +1642,8 @@ class Facture class FactureLigne { + var $subprice; // Prix unitaire HT + var $price; // Prix HT apres remise % /** * \brief Constructeur d'objets ligne de facture @@ -1670,6 +1672,7 @@ class FactureLigne $this->desc = stripslashes($objp->description); $this->qty = $objp->qty; $this->price = $objp->price; + $this->price_ttc = $objp->price_ttc; $this->subprice = $objp->subprice; $this->tva_taux = $objp->tva_taux; $this->remise = $objp->remise; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 2c5a50137a5..dd6bf0e7ca3 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -185,10 +185,11 @@ class Form * \brief Retourne la liste déroulante des pays actifs, dans la langue de l'utilisateur * \param selected Code pays pré-sélectionné * \param htmlname Nom de la liste deroulante + * \param htmloption Options html sur le select * \todo trier liste sur noms après traduction plutot que avant */ - function select_pays($selected='',$htmlname='pays_id') + function select_pays($selected='',$htmlname='pays_id',$htmloption='') { global $conf,$langs; $langs->load("dict"); @@ -199,7 +200,7 @@ class Form if ($this->db->query($sql)) { - print ''; $num = $this->db->num_rows(); $i = 0; if ($num) @@ -688,6 +689,36 @@ class Form } + /** + * \brief Retourne le nom traduit de la forme juridique + * \param code Code de la forme juridique + * \return string Nom traduit du pays + */ + function forme_juridique_name($code) + { + global $langs; + + $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique"; + $sql.= " WHERE code='$code';"; + + if ($this->db->query($sql)) + { + $num = $this->db->num_rows(); + + if ($num) + { + $obj = $this->db->fetch_object(); + $label=$obj->libelle; + return $label; + } + else + { + return $langs->trans("NotDefined"); + } + + } + } + /** * \brief Retourne le nom traduit ou code+nom d'un pays * \param id id du pays @@ -720,6 +751,7 @@ class Form } } + /** * \brief Retourne le nom traduit ou code+nom d'une devise * \param code_iso Code iso de la devise diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index d009f56a61a..591328113a1 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -18,7 +18,6 @@ * * $Id$ * $Source$ -* */ /** @@ -49,6 +48,7 @@ class pdf_crabe extends ModelePDFFactures $this->db = $db; $this->name = "crabe"; $this->description = "Modèle de facture complet (Gère l'option fiscale de facturation TVA, le choix du mode de règlement à afficher, logo...)"; + $this->format="A4"; $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_modereg = 1; // Gere choix mode règlement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER @@ -148,6 +148,13 @@ class pdf_crabe extends ModelePDFFactures $nexY = $pdf->GetY(); $nblignes = sizeof($fac->lignes); + $posxdesc=11; + $posxtva=121; + $posxup=133; + $posxqty=151; + $posxdiscount=163; + $postotttc=173; + // Boucle sur les lignes for ($i = 0 ; $i < $nblignes ; $i++) { @@ -160,7 +167,7 @@ class pdf_crabe extends ModelePDFFactures if ($libelleproduitservice) $libelleproduitservice.="\n"; $libelleproduitservice.=$fac->lignes[$i]->desc; } - $pdf->SetXY (11, $curY ); + $pdf->SetXY ($posxdesc, $curY ); if ($conf->global->FACTURE_CODEPRODUITSERVICE && $fac->lignes[$i]->produit_id) { @@ -181,25 +188,25 @@ class pdf_crabe extends ModelePDFFactures $nexY = $pdf->GetY(); // TVA - $pdf->SetXY (121, $curY); + $pdf->SetXY ($posxtva, $curY); $pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C'); // Prix unitaire HT avant remise - $pdf->SetXY (133, $curY); + $pdf->SetXY ($posxup, $curY); $pdf->MultiCell(17, 5, price($fac->lignes[$i]->subprice), 0, 'R', 0); // Quantité - $pdf->SetXY (151, $curY); + $pdf->SetXY ($posxqty, $curY); $pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'R'); // Remise sur ligne - $pdf->SetXY (163, $curY); + $pdf->SetXY ($posxdiscount, $curY); if ($fac->lignes[$i]->remise_percent) { $pdf->MultiCell(14, 5, $fac->lignes[$i]->remise_percent."%", 0, 'R'); } - // Total HT - $pdf->SetXY (173, $curY); + // Total TTC + $pdf->SetXY ($postotttc, $curY); $total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty); $pdf->MultiCell(26, 5, $total, 0, 'R', 0); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0c2754e1887..0c7d7b7c58c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -34,6 +34,8 @@ ActiveOn=Activated on SourceFile=Source file TriggersAvailable=Triggers available TriggersDesc=Triggers are components that modify, once activated, the behaviour of Dolibarr workflow. They add new actions, activated on Dolibarr events (new company creation, invoice validation, ...). +SeeAbove=See above +ErrorSetACountryFirst=Set the country first ModuleFamilyCrm=Customer Ressource Management (CRM) ModuleFamilyProducts=Products Management ModuleFamilyHr=Human Ressource Management diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index ecd40d89d9d..5ba78a8e925 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -34,6 +34,8 @@ ActiveOn=Active sur SourceFile=Fichier source TriggersAvailable=Triggers disponibles TriggersDesc=Les triggers sont des composants qui, une fois activés, modifient le comportement du workflow de Dolibarr. Ils réalisent des actions suplémentaires, délenchées par les évennements Dolibarr (création société, validation facture, cloture contrat...). +SeeAbove=Voir ci-dessus +ErrorSetACountryFirst=Définisser le pays d'abord ModuleFamilyCrm=Gestion client (CRM) ModuleFamilyProducts=Gestion produits ModuleFamilyHr=Ressources humaines diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index bfbb148ee6f..dbcd0a9aadc 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -210,7 +210,7 @@ function dolibarr_fiche_head($links, $active=0, $title='') /** \brief Récupère une constante depuis la base de données. - \see dolibarr_del_const, dolibarr_sel_const + \see dolibarr_del_const, dolibarr_set_const \param db Handler d'accès base \param name Nom de la constante \return string Valeur de la constante @@ -262,17 +262,19 @@ function dolibarr_set_php_lang($code_lang) /** \brief Insertion d'une constante dans la base de données. - \see dolibarr_del_const, dolibarr_gel_const - \param db handler d'accès base - \param name nom de la constante - \param value valeur de la constante - \param type type de constante (chaine par défaut) - \param visible la constante est elle visible (0 par défaut) - \param note explication de la constante - \return int 0 si KO, 1 si OK + \see dolibarr_del_const, dolibarr_get_const + \param db Handler d'accès base + \param name Nom de la constante + \param value Valeur de la constante + \param type Type de constante (chaine par défaut) + \param visible La constante est elle visible (0 par défaut) + \param note Explication de la constante + \return int <0 si ko, >0 si ok */ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='') { + global $conf; + $db->begin(); $sql = "DELETE FROM llx_const WHERE name = '$name';"; @@ -285,12 +287,13 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not if ($resql) { $db->commit(); + $conf->global->$name=$value; return 1; } else { $db->rollback(); - return 0; + return -1; } } diff --git a/mysql/data/data.sql b/mysql/data/data.sql index 0b01bba8e1c..4676b53aabf 100644 --- a/mysql/data/data.sql +++ b/mysql/data/data.sql @@ -480,7 +480,7 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'62','Group insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'63','Société coopérative agricole'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'64','Société non commerciale d\'assurances'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'65','Société civile'); -insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'69','Autres personnes de droit privé inscrites au registre du commerce et des sociétés'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'69','Autres personnes de droit privé inscrites au registre du commerce et sociétés'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'71','Administration de l\'état'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'72','Collectivité territoriale');