diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 54c1f546903..e8dee5b8068 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -216,11 +216,11 @@ class pdf_einstein extends ModelePDFCommandes
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1,0);
-
+
$heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-
+
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
@@ -293,16 +293,16 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
-
+
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
-
+
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
-
+
// Affiche notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
@@ -454,7 +454,7 @@ class pdf_einstein extends ModelePDFCommandes
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
else $tvaligne=$object->lines[$i]->total_tva;
-
+
$localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$object->lines[$i]->total_localtax2;
$localtax1_rate=$object->lines[$i]->localtax1_tx;
@@ -561,7 +561,7 @@ class pdf_einstein extends ModelePDFCommandes
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
}
*/
-
+
// Pied de page
$this->_pagefoot($pdf,$object,$outputlangs);
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
@@ -838,6 +838,8 @@ class pdf_einstein extends ModelePDFCommandes
// Show VAT by rates and total
$pdf->SetFillColor(248,248,248);
+ $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+
$this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
@@ -1011,7 +1013,6 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
- $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
}
@@ -1024,7 +1025,7 @@ class pdf_einstein extends ModelePDFCommandes
//$creditnoteamount=$object->getSumCreditNotesUsed();
//$depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit;
- $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (! empty($object->paye)) $resteapayer=0;
if ($deja_regle > 0)
@@ -1270,7 +1271,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
}
}
-
+
$posy+=2;
// Show list of linked objects
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index d1697b767bd..62862e06e11 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -84,7 +84,7 @@ class pdf_rouget extends ModelePdfExpedition
}
$this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
-
+
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxweightvol-=20;
@@ -92,7 +92,7 @@ class pdf_rouget extends ModelePdfExpedition
$this->posxqtyordered-=20;
$this->posxqtytoship-=20;
}
-
+
if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
@@ -139,17 +139,17 @@ class pdf_rouget extends ModelePdfExpedition
if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
{
$objphoto = new Product($this->db);
-
+
for ($i = 0 ; $i < $nblignes ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
-
+
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
-
+
$pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
-
+
$realpath='';
foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
@@ -169,17 +169,17 @@ class pdf_rouget extends ModelePdfExpedition
{
$filename=$obj['photo'];
}
-
+
$realpath = $dir.$filename;
break;
}
-
+
if ($realpath) $realpatharray[$i]=$realpath;
}
}
-
- if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
-
+
+ if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol;
+
if ($conf->expedition->dir_output)
{
// Definition de $dir et $file
@@ -219,7 +219,7 @@ class pdf_rouget extends ModelePdfExpedition
// Set nblignes with the new facture lines content after hook
$nblignes = count($object->lines);
-
+
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 8; // Height reserved to output the info and total part
@@ -282,11 +282,11 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = $pdf->GetY();
$height_incoterms=$nexY-$tab_top;
-
+
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
-
+
$tab_top = $nexY+6;
$height_incoterms += 4;
}
@@ -343,7 +343,7 @@ class pdf_rouget extends ModelePdfExpedition
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
-
+
$tab_height = $tab_height - $height_note;
$tab_top = $nexY+6;
}
@@ -400,7 +400,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->startTransaction();
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc);
-
+
$pageposafter=$pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
@@ -434,10 +434,10 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->commitTransaction();
}
$posYAfterDescription=$pdf->GetY();
-
+
$nexY = $pdf->GetY();
$pageposafter=$pdf->getPage();
-
+
$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
@@ -456,29 +456,29 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetXY($this->posxweightvol, $curY);
$weighttxt='';
- if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
+ if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
{
$weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight");
}
$voltxt='';
- if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
+ if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
{
$voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume");
}
-
+
$pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C');
//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C');
-
+
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$pdf->SetXY($this->posxqtyordered, $curY);
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
}
-
+
$pdf->SetXY($this->posxqtytoship, $curY);
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C');
- if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT))
+ if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT))
{
$pdf->SetXY($this->posxpuht, $curY);
$pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R');
@@ -489,7 +489,7 @@ class pdf_rouget extends ModelePdfExpedition
$nexY+=3;
if ($weighttxt && $voltxt) $nexY+=2;
-
+
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
{
@@ -548,7 +548,7 @@ class pdf_rouget extends ModelePdfExpedition
}
// Affiche zone totaux
- $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+ $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
// Pied de page
$this->_pagefoot($pdf,$object,$outputlangs);
@@ -612,7 +612,7 @@ class pdf_rouget extends ModelePdfExpedition
}*/
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
-
+
$useborder=0;
$index = 0;
@@ -626,12 +626,12 @@ class pdf_rouget extends ModelePdfExpedition
$totalOrdered=$tmparray['ordered'];
$totalToShip=$tmparray['toship'];
// Set trueVolume and volume_units not currently stored into database
- if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
+ if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
{
$object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
$object->volume_units=$object->size_units * 3;
}
-
+
if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
@@ -640,48 +640,48 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
-
+
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
}
-
+
$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
-
+
if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
-
+
$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
}
-
+
// Total Weight
if ($totalWeighttoshow)
{
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
-
+
$index++;
}
if ($totalVolumetoshow)
{
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
-
+
$index++;
}
if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++;
-
+
$pdf->SetTextColor(0,0,0);
return ($tab2_top + ($tab2_hl * $index));
}
-
+
/**
* Show table for lines
*
@@ -728,7 +728,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetXY($this->posxweightvol-1, $tab_top+1);
$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C');
}
-
+
if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
{
$pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
@@ -738,14 +738,14 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
}
}
-
+
$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxqtytoship, $tab_top+1);
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C');
}
-
+
if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) {
$pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height);
@@ -754,7 +754,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetXY($this->posxpuht-1, $tab_top+1);
$pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C');
}
-
+
$pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height);
if (empty($hidetop))
{
@@ -763,7 +763,7 @@ class pdf_rouget extends ModelePdfExpedition
}
}
-
+
}
/**
@@ -780,7 +780,7 @@ class pdf_rouget extends ModelePdfExpedition
global $conf,$langs,$mysoc;
$langs->load("orders");
-
+
$default_font_size = pdf_getPDFFontSize($outputlangs);
pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
@@ -796,7 +796,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetFont('','B', $default_font_size + 3);
$w = 110;
-
+
$posy=$this->marge_haute;
$posx=$this->page_largeur-$this->marge_droite-$w;
@@ -863,7 +863,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetFont('','', $default_font_size + 1);
$posy+=5;
-
+
$pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R');
@@ -876,7 +876,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R');
}
-
+
if (! empty($object->thirdparty->code_client))
{
$posy+=4;
@@ -904,7 +904,7 @@ class pdf_rouget extends ModelePdfExpedition
if ($result >= 0)
{
//$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
-
+
$pdf->SetFont('','', $default_font_size - 2);
$text=$linkedobject->ref;
if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
@@ -939,7 +939,7 @@ class pdf_rouget extends ModelePdfExpedition
$hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
$widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
-
+
// Show sender frame
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 2);
@@ -950,7 +950,7 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
$pdf->SetTextColor(0,0,60);
$pdf->SetFillColor(255,255,255);
-
+
// Show sender name
$pdf->SetXY($posx+2,$posy+3);
$pdf->SetFont('','B',$default_font_size);
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 02d239105b0..be88b7d4114 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -214,9 +214,9 @@ class pdf_crabe extends ModelePDFFactures
{
$object->fetch_thirdparty();
- $deja_regle = $object->getSommePaiement();
- $amount_credit_notes_included = $object->getSumCreditNotesUsed();
- $amount_deposits_included = $object->getSumDepositsUsed();
+ $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
// Definition of $dir and $file
if ($object->specimen)
@@ -255,16 +255,16 @@ class pdf_crabe extends ModelePDFFactures
// Set nblignes with the new facture lines content after hook
$nblignes = count($object->lines);
$nbpayments = count($object->getListOfPayments());
-
+
// Create pdf instance
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1,0);
-
+
$heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-
+
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
@@ -509,7 +509,7 @@ class pdf_crabe extends ModelePDFFactures
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$pdf->SetXY($this->posxqty, $curY);
// Enough for 6 chars
-
+
if ($this->situationinvoice)
{
$pdf->MultiCell($this->posxprogress-$this->posxqty-0.8, 4, $qty, 0, 'R');
@@ -769,9 +769,9 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFont('','', $default_font_size - 4);
-
+
// Loop on each deposits and credit notes included
- $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
+ $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
$sql.= " re.description, re.fk_facture_source,";
$sql.= " f.type, f.datef";
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f";
@@ -796,7 +796,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($tab3_posx, $tab3_top+$y);
$pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
- $pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
$pdf->MultiCell(20, 3, $text, 0, 'L', 0);
$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
@@ -815,14 +815,14 @@ class pdf_crabe extends ModelePDFFactures
// Loop on each payment
// TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql
- $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount,";
+ $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
$sql.= " cp.code";
$sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
//$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1";
$sql.= " ORDER BY p.datep";
-
+
$resql=$this->db->query($sql);
if ($resql)
{
@@ -835,7 +835,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($tab3_posx, $tab3_top+$y);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
- $pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
@@ -1052,7 +1052,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + 0);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
-
+
$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);
@@ -1060,6 +1060,8 @@ class pdf_crabe extends ModelePDFFactures
// Show VAT by rates and total
$pdf->SetFillColor(248,248,248);
+ $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+
$this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
@@ -1071,7 +1073,7 @@ class pdf_crabe extends ModelePDFFactures
else
{
// FIXME amount of vat not supported with multicurrency
-
+
//Local tax 1 before VAT
//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
//{
@@ -1141,26 +1143,26 @@ class pdf_crabe extends ModelePDFFactures
}
//}
-
+
// VAT
// Situations totals migth be wrong on huge amounts
if ($object->situation_cycle_ref && $object->situation_counter > 1) {
-
+
$sum_pdf_tva = 0;
foreach($this->tva as $tvakey => $tvaval){
$sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object
}
-
+
if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one)
$coef_fix_tva = $object->total_tva / $sum_pdf_tva;
-
+
foreach($this->tva as $tvakey => $tvaval) {
$this->tva[$tvakey]=$tvaval * $coef_fix_tva;
}
}
-
+
}
-
+
foreach($this->tva as $tvakey => $tvaval)
{
if ($tvakey != 0) // On affiche pas taux 0
@@ -1270,7 +1272,6 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
- $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);
}
@@ -1278,10 +1279,10 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,0);
- $creditnoteamount=$object->getSumCreditNotesUsed();
- $depositsamount=$object->getSumDepositsUsed();
+ $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
//print "x".$creditnoteamount."-".$depositsamount;exit;
- $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if ($object->paye) $resteapayer=0;
if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0)
@@ -1416,7 +1417,7 @@ class pdf_crabe extends ModelePDFFactures
if (empty($hidetop))
{
$pdf->SetXY($this->posxqty-1, $tab_top+1);
-
+
if($this->situationinvoice)
{
$pdf->MultiCell($this->posxprogress-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
@@ -1430,14 +1431,14 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
}
}
-
+
if ($this->situationinvoice) {
$pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
-
+
if (empty($hidetop)) {
-
+
$pdf->SetXY($this->posxprogress, $tab_top+1);
-
+
if($conf->global->PRODUCT_USE_UNITS)
{
$pdf->MultiCell($this->posxunit-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C');
@@ -1450,9 +1451,9 @@ class pdf_crabe extends ModelePDFFactures
{
$pdf->MultiCell($this->postotalht-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C');
}
-
+
}
-
+
}
if($conf->global->PRODUCT_USE_UNITS) {
@@ -1617,7 +1618,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : " . dol_print_date($object->date_pointoftax,"day",false,$outputlangs), '', 'R');
}
-
+
if ($object->type != 2)
{
$posy+=3;
@@ -1648,7 +1649,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell($w, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
}
}
-
+
$posy+=1;
// Show list of linked objects
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index d2ecfb60d81..54f3a4e351e 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -273,7 +273,7 @@ class pdf_azur extends ModelePDFPropales
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1,0);
-
+
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
@@ -322,19 +322,19 @@ class pdf_azur extends ModelePDFPropales
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
-
+
$heightforinfotot = 40; // Height reserved to output the info and total part
$heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0;
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
-
+ //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
+
$this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
-
+
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130;
@@ -383,7 +383,7 @@ class pdf_azur extends ModelePDFPropales
$notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs);
if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email;
if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
- }
+ }
if ($notetoshow)
{
$tab_top = 88 + $height_incoterms;
@@ -552,14 +552,14 @@ class pdf_azur extends ModelePDFPropales
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
else $tvaligne=$object->lines[$i]->total_tva;
-
+
$localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$object->lines[$i]->total_localtax2;
$localtax1_rate=$object->lines[$i]->localtax1_tx;
$localtax2_rate=$object->lines[$i]->localtax2_tx;
$localtax1_type=$object->lines[$i]->localtax1_type;
- $localtax2_type=$object->lines[$i]->localtax2_type;
-
+ $localtax2_type=$object->lines[$i]->localtax2_type;
+
if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
@@ -667,7 +667,7 @@ class pdf_azur extends ModelePDFPropales
{
$posy=$this->_signature_area($pdf, $object, $posy, $outputlangs);
}
-
+
// Pied de page
$this->_pagefoot($pdf,$object,$outputlangs);
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
@@ -1010,6 +1010,8 @@ class pdf_azur extends ModelePDFPropales
// Show VAT by rates and total
$pdf->SetFillColor(248,248,248);
+ $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+
$this->atleastoneratenotnull=0;
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{
@@ -1186,7 +1188,6 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetFillColor(224,224,224);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
- $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
}
@@ -1479,7 +1480,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
}
}
-
+
$posy+=2;
// Show list of linked objects
diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
index 1e7e6f4bcad..2578509cf71 100644
--- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -717,6 +717,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$useborder=0;
+ // Total TTC
$index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->SetTextColor(0,0,60);
@@ -727,6 +728,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
+ $creditnoteamount=0;
+ $depositsamount=0;
+ //$creditnoteamount=$object->getSumCreditNotesUsed();
+ //$depositsamount=$object->getSumDepositsUsed();
+ //print "x".$creditnoteamount."-".$depositsamount;exit;
+ $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ if (! empty($object->paye)) $resteapayer=0;
+
if ($deja_regle > 0)
{
$index++;
@@ -743,7 +752,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$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($resteapayer), $useborder, 'R', 1);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetTextColor(0,0,0);
}
@@ -877,6 +886,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
*/
function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
{
+ global $conf;
+
+ $sign=1;
+ if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
+
$tab3_posx = 120;
$tab3_top = $posy + 8;
$tab3_width = 80;
@@ -910,8 +924,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetFont('','', $default_font_size - 4);
+ // Loop on each deposits and credit notes included
+ //
+
// Loop on each payment
- $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,";
+ $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
$sql.= " cp.code";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
@@ -929,7 +946,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetXY($tab3_posx, $tab3_top+$y);
$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
- $pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0);
$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
index c882ed89800..2be42687f80 100644
--- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
+++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
@@ -840,7 +840,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
//$creditnoteamount=$object->getSumCreditNotesUsed();
//$depositsamount=$object->getSumDepositsUsed();
//print "x".$creditnoteamount."-".$depositsamount;exit;
- $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
+ $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (! empty($object->paye)) $resteapayer=0;
if ($deja_regle > 0)