From c91da9ee357d0cf30e3a181d4df05f8512123962 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 20 Nov 2007 17:23:21 +0000 Subject: [PATCH] =?UTF-8?q?D=E9but=20d=E9bugage=20et=20am=E9lioration=20du?= =?UTF-8?q?=20module=20exp=E9dition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../propale/pdf_propale_azur.modules.php | 2 + .../livraison/mods/pdf/pdf_typhon.modules.php | 50 +++++++++---------- htdocs/societe.class.php | 11 ++-- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index 3bc962d56a5..2ffd8e1aad6 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -931,6 +931,8 @@ class pdf_propale_azur extends ModelePDFPropales // Caractéristiques client $carac_client.="\n".$object->client->adresse; $carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n"; + + //Pays si différent de l'émetteur if ($this->emetteur->pays_code != $object->client->pays_code) { $carac_client.=$object->client->pays."\n"; diff --git a/htdocs/livraison/mods/pdf/pdf_typhon.modules.php b/htdocs/livraison/mods/pdf/pdf_typhon.modules.php index 8d6b638221a..e15cb468565 100644 --- a/htdocs/livraison/mods/pdf/pdf_typhon.modules.php +++ b/htdocs/livraison/mods/pdf/pdf_typhon.modules.php @@ -71,18 +71,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->franchise=1; // Recupere code pays de l'emmetteur - $this->emetteur->code_pays=substr($langs->defaultlang,-2); // Par defaut, si on trouve pas - $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; - $sql .= " WHERE rowid = '".$conf->global->MAIN_INFO_SOCIETE_PAYS."'"; - $result=$this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); - if ($obj->code) $this->emetteur->code_pays=$obj->code; - } - else { - dolibarr_print_error($this->db); - } - $this->db->free($result); + if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini $this->tva=array(); @@ -757,27 +746,34 @@ class pdf_typhon extends ModelePDFDeliveryOrder /* * if a delivery address is used, use that, else use the client address */ - $client = new Societe($this->db); - if ($commande->adresse_livraison_id>0) { + $client = new Societe($this->db); + if ($commande->adresse_livraison_id > 0) { $client->fetch_adresse_livraison($commande->adresse_livraison_id); } else { $client->fetch($delivery->socid); } - $delivery->client = $client; - // + $delivery->client = $client; // Cadre client destinataire $pdf->rect(100, $posy, 100, $hautcadre); - - // Nom client + + // Nom client $pdf->SetXY(102,$posy+3); $pdf->SetFont('Arial','B',11); $pdf->MultiCell(106,4, $delivery->client->nom, 0, 'L'); + + // Caractéristiques client + $carac_client=$delivery->client->adresse."\n"; + $carac_client.=$delivery->client->cp . " " . $delivery->client->ville."\n"; - // Caractéristiques client - $carac_client=$delivery->client->adresse; - $carac_client.="\n".$delivery->client->cp . " " . $delivery->client->ville."\n"; - if ($delivery->client->tva_intra) $carac_client.="\n".$langs->transnoentities("VATIntraShort").': '.$delivery->client->tva_intra; + // Pays si différent de l'émetteur + if ($this->emetteur->pays_code != $delivery->client->pays_code) + { + $carac_client.=$delivery->client->pays."\n"; + } + + // Tva intracom + if ($delivery->client->tva_intra) $carac_client.="\n".$langs->transnoentities("VATIntraShort").': '.$delivery->client->tva_intra; $pdf->SetFont('Arial','',9); $pdf->SetXY(102,$posy+8); $pdf->MultiCell(86,4, $carac_client); @@ -810,22 +806,22 @@ class pdf_typhon extends ModelePDFDeliveryOrder } if ($conf->global->MAIN_INFO_SIRET) { - $ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId2",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIRET; + $ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId2",$this->emetteur->pays_code).": ".$conf->global->MAIN_INFO_SIRET; } - if ($conf->global->MAIN_INFO_SIREN && (! $conf->global->MAIN_INFO_SIRET || $this->emetteur->code_pays != 'FR')) + if ($conf->global->MAIN_INFO_SIREN && (! $conf->global->MAIN_INFO_SIRET || $this->emetteur->pays_code != 'FR')) { - $ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId1",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIREN; + $ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId1",$this->emetteur->pays_code).": ".$conf->global->MAIN_INFO_SIREN; } if ($conf->global->MAIN_INFO_APE) { - $ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId3",$this->emetteur->code_pays).": ".MAIN_INFO_APE; + $ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId3",$this->emetteur->pays_code).": ".MAIN_INFO_APE; } // Deuxieme ligne d'info réglementaires $ligne2=""; if ($conf->global->MAIN_INFO_RCS) { - $ligne2.=($ligne2?" - ":"").$langs->transcountry("ProfId4",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_RCS; + $ligne2.=($ligne2?" - ":"").$langs->transcountry("ProfId4",$this->emetteur->pays_code).": ".$conf->global->MAIN_INFO_RCS; } if ($conf->global->MAIN_INFO_TVAINTRA != '') { diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index aef5ef6ef50..bd2075772dd 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -635,12 +635,12 @@ class Societe */ function fetch_adresse_livraison($id) { - global $conf; + global $conf,$langs; $sql = "SELECT l.rowid, l.label, l.fk_societe, l.nom, l.address, l.cp"; $sql .= ", ".$this->db->pdate("l.tms")."as dm, ".$this->db->pdate("l.datec")."as dc"; $sql .= ", l.ville, l.fk_pays, l.note"; - $sql .= ", p.libelle as pays, p.code, s.nom as socname"; + $sql .= ", p.libelle as pays, p.code as pays_code, s.nom as socname"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_adresse_livraison as l"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON l.fk_pays = p.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON l.fk_societe = s.rowid"; @@ -660,10 +660,13 @@ class Societe $this->societe = $obj->socname; $this->nom = $obj->nom; $this->address = $obj->address; + $this->adresse = $obj->address; //Todo: uniformiser le nom des champs $this->cp = $obj->cp; $this->ville = $obj->ville; - $this->pays = $obj->pays; - $this->code_pays = $obj->code; + $this->pays_id = $obj->fk_pays; + $this->pays_code = $obj->fk_pays?$obj->pays_code:''; + $this->pays = $obj->fk_pays?($langs->trans('Country'.$obj->pays_code)!='Country'.$obj->pays_code?strtoupper(clean_html($langs->trans('Country'.$obj->pays_code))):$obj->pays):''; + $this->db->free($result);