diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 78ff0b84c11..26daf4782ad 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -54,7 +54,7 @@ class pdf_einstein extends ModelePDFCommandes $langs->load("bills"); $this->db = $db; $this->name = "einstein"; - $this->description = "Modèle de commandes complet (logo...)"; + $this->description = $langs->trans('PDFEinsteinDescription'); // Dimension page pour format A4 $this->type = 'pdf'; @@ -93,15 +93,6 @@ class pdf_einstein extends ModelePDFCommandes $this->atleastonediscount=0; } - /** - \brief Renvoi dernière erreur - \return string Dernière erreur - */ - function pdferror() - { - return $this->error; - } - /** \brief Fonction générant la commande sur le disque \param com Objet commande à générer @@ -109,7 +100,7 @@ class pdf_einstein extends ModelePDFCommandes */ function write_pdf_file($com,$outputlangs='') { - global $user,$langs,$conf,$mysoc; + global $user,$langs,$conf; if (! is_object($outputlangs)) $outputlangs=$langs; $outputlangs->load("main"); @@ -144,7 +135,7 @@ class pdf_einstein extends ModelePDFCommandes $file = $dir . "/" . $comref . ".pdf"; } - if (! file_exists($dir)) + if (! file_exists($dir)) { if (create_exdir($dir) < 0) { @@ -156,6 +147,7 @@ class pdf_einstein extends ModelePDFCommandes if (file_exists($dir)) { $nblignes = sizeof($com->lignes); + // Initialisation document vierge $pdf=new FPDF('P','mm',$this->format); $pdf->Open(); @@ -260,7 +252,7 @@ class pdf_einstein extends ModelePDFCommandes if ($com->lignes[$i]->date_start && $com->lignes[$i]->date_end) { // Affichage durée si il y en a une - $libelleproduitservice.="\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")"; + $libelleproduitservice.=_dol_htmlentities("\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")",0); } $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page @@ -301,11 +293,10 @@ class pdf_einstein extends ModelePDFCommandes $total = price($com->lignes[$i]->price * $com->lignes[$i]->qty); $pdf->MultiCell(23, 4, $total, 0, 'R', 0); - // Collecte des totaux par valeur de tva - // dans le tableau tva["taux"]=total_tva - $tvaligne=$com->lignes[$i]->price * $com->lignes[$i]->qty; + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + $tvaligne=$com->lignes[$i]->total_tva; if ($com->remise_percent) $tvaligne-=($tvaligne*$com->remise_percent)/100; - $this->tva[ (string)$com->lignes[$i]->tva_tx ] += $tvaligne; + $this->tva[(string) $com->lignes[$i]->tva_tx] += $tvaligne; $nexY+=2; // Passe espace entre les lignes @@ -441,7 +432,7 @@ class pdf_einstein extends ModelePDFCommandes } /* - * Check si absence mode de règlement + * Check si absence mode règlement */ if (! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER) { @@ -580,7 +571,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht +$object->remise), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ht + $object->remise)), 0, 'R', 1); // Remise globale if ($object->remise > 0) @@ -595,7 +586,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("WithDiscountTotalHT"), 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * 2); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht), 0, 'R', 0); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ht)), 0, 'R', 1); $index = 2; } @@ -618,7 +609,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval * (float)$tvakey / 100 ), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($tvaval)), 0, 'R', 1); } } if (! $this->atleastoneratenotnull) @@ -628,7 +619,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_tva)), 0, 'R', 1); } $useborder=0; @@ -640,7 +631,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ttc)), $useborder, 'R', 1); $pdf->SetTextColor(0,0,0); if ($deja_regle > 0) @@ -653,6 +644,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); + $resteapayer = $object->total_ttc - $deja_regle; $index++; @@ -662,7 +654,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($resteapayer)), $useborder, 'R', 1); // Fin $pdf->SetFont('Arial','', 9); @@ -674,7 +666,7 @@ class pdf_einstein extends ModelePDFCommandes } /* - * \brief Affiche la grille des lignes de propales + * \brief Affiche la grille des lignes de commandes * \param pdf objet PDF */ function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) @@ -728,7 +720,7 @@ class pdf_einstein extends ModelePDFCommandes } /* - * \brief Affiche en-tête propale + * \brief Affiche en-tête commande * \param pdf Objet PDF * \param com Objet commande * \param showadress 0=non, 1=oui @@ -736,7 +728,7 @@ class pdf_einstein extends ModelePDFCommandes */ function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) { - global $conf; + global $conf,$langs; $outputlangs->load("main"); $outputlangs->load("bills"); @@ -774,7 +766,8 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('Arial','B',13); $pdf->SetXY(100,$posy); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order"), '' , 'R'); + $title=$outputlangs->transnoentities("Order"); + $pdf->MultiCell(100, 4, $title, '' , 'R'); $pdf->SetFont('Arial','B',12); @@ -783,19 +776,15 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); + $posy+=1; $pdf->SetFont('Arial','',10); - $posy+=6; + $posy+=5; $pdf->SetXY(100,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dolibarr_print_date($object->date,"%d %b %Y"), '', 'R'); -/* - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dolibarr_print_date($fac->date_lim_reglement,"%d %b %Y"), '', 'R'); -*/ + if ($showadress) { @@ -867,7 +856,7 @@ class pdf_einstein extends ModelePDFCommandes $carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n"; if ($this->emetteur->pays_code != $object->client->pays_code) { - $carac_client.=$object->client->pays."\n"; + $carac_client.=$object->client->pays."\n"; } if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra; $pdf->SetFont('Arial','',9); diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index 2e289e1b2aa..f7da7891eaf 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -234,7 +234,7 @@ class pdf_crabe extends ModelePDFFactures $prefix_prodserv = ""; if($prodser->isservice()) $prefix_prodserv = $outputlangs->transnoentities("Service")." "; - else + else $prefix_prodserv = $outputlangs->transnoentities("Product")." "; $libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice; @@ -295,11 +295,10 @@ class pdf_crabe extends ModelePDFFactures $total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty); $pdf->MultiCell(23, 4, $total, 0, 'R', 0); - // Collecte des totaux par valeur de tva - // dans le tableau tva["taux"]=total_tva - $tvaligne=$fac->lignes[$i]->price * $fac->lignes[$i]->qty; + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + $tvaligne=$fac->lignes[$i]->total_tva; if ($fac->remise_percent) $tvaligne-=($tvaligne*$fac->remise_percent)/100; - $this->tva[ (string)$fac->lignes[$i]->tva_tx ] += $tvaligne; + $this->tva[(string) $fac->lignes[$i]->tva_tx] += $tvaligne; $nexY+=2; // Passe espace entre les lignes @@ -678,6 +677,7 @@ class pdf_crabe extends ModelePDFFactures // Affichage des totaux de TVA par taux (conformément à réglementation) $pdf->SetFillColor(248,248,248); + foreach( $this->tva as $tvakey => $tvaval ) { if ($tvakey) // On affiche pas taux 0 @@ -690,7 +690,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price(abs($tvaval * (float)$tvakey / 100 )), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($tvaval)), 0, 'R', 1); } } if (! $this->atleastoneratenotnull) @@ -819,6 +819,7 @@ class pdf_crabe extends ModelePDFFactures * \param pdf Objet PDF * \param fac Objet facture * \param showadress 0=non, 1=oui + * \param outputlang Objet lang cible */ function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) { diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index 8a0dcb760e7..f7b11347ace 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -55,7 +55,7 @@ class pdf_propale_azur extends ModelePDFPropales $this->db = $db; $this->name = "azur"; - $this->description = "Modèle de propositions commerciales complet (logo...)"; + $this->description = $langs->trans('PDFAzurDescription'); // Dimension page pour format A4 $this->type = 'pdf'; @@ -101,7 +101,7 @@ class pdf_propale_azur extends ModelePDFPropales */ function write_pdf_file($propale,$outputlangs='') { - global $user,$conf,$langs; + global $user,$langs,$conf; if (! is_object($outputlangs)) $outputlangs=$langs; $outputlangs->load("main"); @@ -292,11 +292,10 @@ class pdf_propale_azur extends ModelePDFPropales $total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty); $pdf->MultiCell(23, 4, $total, 0, 'R', 0); - // Collecte des totaux par valeur de tva - // dans le tableau tva["taux"]=total_tva - $tvaligne=$propale->lignes[$i]->price * $propale->lignes[$i]->qty; + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + $tvaligne=$propale->lignes[$i]->total_tva; if ($propale->remise_percent) $tvaligne-=($tvaligne*$propale->remise_percent)/100; - $this->tva[ (string)$propale->lignes[$i]->tva_tx ] += $tvaligne; + $this->tva[(string) $propale->lignes[$i]->tva_tx] += $tvaligne; $nexY+=2; // Passe espace entre les lignes @@ -304,11 +303,11 @@ class pdf_propale_azur extends ModelePDFPropales { if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $nexY - $tab_top + 20, $nexY, $outputlangs); + $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); } else { - $this->_tableau($pdf, $tab_top_newpage, $nexY - $tab_top_newpage + 20, $nexY, $outputlangs); + $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); } $this->_pagefoot($pdf,$outputlangs); @@ -328,13 +327,13 @@ class pdf_propale_azur extends ModelePDFPropales // Affiche cadre tableau if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $nexY - $tab_top + 20, $nexY, $outputlangs); - $bottomlasttab=$tab_top + $nexY - $tab_top + 20 + 1; + $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); + $bottomlasttab=$tab_top + $tab_height + 1; } else { - $this->_tableau($pdf, $tab_top_newpage, $nexY - $tab_top_newpage + 20, $nexY, $outputlangs); - $bottomlasttab=$tab_top_newpage + $nexY - $tab_top_newpage + 20 + 1; + $this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY, $outputlangs); + $bottomlasttab=$tab_top_newpage + $tab_height + 1; } // Affiche zone infos @@ -349,7 +348,7 @@ class pdf_propale_azur extends ModelePDFPropales } // Pied de page - $this->_pagefoot($pdf, $outputlangs); + $this->_pagefoot($pdf,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); @@ -434,7 +433,7 @@ class pdf_propale_azur extends ModelePDFPropales } /* - * Check si absence mode de règlement + * Check si absence mode règlement */ if (! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER) { @@ -562,7 +561,7 @@ class pdf_propale_azur extends ModelePDFPropales $tab2_top = $posy; $tab2_hl = 5; $tab2_height = $tab2_hl * 4; - $pdf->SetFont('Arial','', 8); + $pdf->SetFont('Arial','', 9); // Tableau total $lltot = 200; $col1x = 120; $col2x = 182; $largcol2 = $lltot - $col2x; @@ -573,7 +572,7 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ht + $object->remise)), 0, 'R', 1); // Remise globale if ($object->remise > 0) @@ -588,7 +587,7 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("WithDiscountTotalHT"), 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * 2); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht), 0, 'R', 0); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ht)), 0, 'R', 0); $index = 2; } @@ -611,7 +610,7 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval * abs((float)$tvakey) / 100 ), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($tvaval)), 0, 'R', 1); } } if (! $this->atleastoneratenotnull) @@ -621,7 +620,7 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_tva)), 0, 'R', 1); } $useborder=0; @@ -633,7 +632,7 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ttc)), $useborder, 'R', 1); $pdf->SetTextColor(0,0,0); if ($deja_regle > 0) @@ -668,7 +667,7 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price(abs($resteapayer)), $useborder, 'R', 1); // Fin $pdf->SetFont('Arial','', 9); @@ -741,7 +740,7 @@ class pdf_propale_azur extends ModelePDFPropales */ function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) { - global $conf; + global $conf,$langs; $outputlangs->load("main"); $outputlangs->load("bills"); @@ -779,7 +778,8 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->SetFont('Arial','B',13); $pdf->SetXY(100,$posy); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("CommercialProposal"), '' , 'R'); + $title=$outputlangs->transnoentities("CommercialProposal"); + $pdf->MultiCell(100, 4, $title, '' , 'R'); $pdf->SetFont('Arial','B',12); @@ -788,9 +788,10 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); + $posy+=1; $pdf->SetFont('Arial','',10); - $posy+=6; + $posy+=5; $pdf->SetXY(100,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dolibarr_print_date($object->date,"%d %b %Y"), '', 'R');