From 2147bd23e64da09d96fc2a44395aa4293a2ab427 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 2 Feb 2018 10:22:47 +0100 Subject: [PATCH 1/6] Fix: remove lines with special code when convert to reduc --- htdocs/compta/facture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b5b200aa540..5fcd2d05aee 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -611,7 +611,7 @@ if (empty($reshook)) $i = 0; foreach ($object->lines as $line) { - if ($line->total_ht!=0) + if (empty($line->special_code) && $line->total_ht != 0) // Remove lines with special code { // no need to create discount if amount is null $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; From a161ca37ffe23e530870f5fb83522910d075fff6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 4 Feb 2018 08:58:31 +0100 Subject: [PATCH 2/6] Fix: use product_type instead special_code --- htdocs/compta/facture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 5fcd2d05aee..63b8f2a102b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -611,7 +611,7 @@ if (empty($reshook)) $i = 0; foreach ($object->lines as $line) { - if (empty($line->special_code) && $line->total_ht != 0) // Remove lines with special code + if (empty($line->product_type >= 9) && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 { // no need to create discount if amount is null $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; From d5b7184c8d501e6d4e8b83afeed36027eed9a2c6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 4 Feb 2018 09:04:15 +0100 Subject: [PATCH 3/6] Fix: wrong test --- htdocs/compta/facture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 63b8f2a102b..39d603a6c5e 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -611,7 +611,7 @@ if (empty($reshook)) $i = 0; foreach ($object->lines as $line) { - if (empty($line->product_type >= 9) && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 + if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 { // no need to create discount if amount is null $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; From 839de650121b330daed69476aec3baae58b2a68f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 5 Feb 2018 11:30:31 +0100 Subject: [PATCH 4/6] Fix: avoid error -1 --- htdocs/core/class/commonobject.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fa59659ab31..e9498d52d7d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1210,7 +1210,10 @@ abstract class CommonObject if ($resql) { $row = $this->db->fetch_row($resql); - $result = $this->fetch($row[0]); + // Test for avoid error -1 + if ($row[0] > 0) { + $result = $this->fetch($row[0]); + } } return $result; From 6254e20c676319e0b29dc2bd5262644270af32dd Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 7 Feb 2018 15:33:40 +0100 Subject: [PATCH 5/6] Fix position if module use pdf hook "linkedobjects" --- .../commande/doc/pdf_einstein.modules.php | 22 +++++++++++++------ .../modules/facture/doc/pdf_crabe.modules.php | 20 ++++++++++++----- .../modules/propale/doc/pdf_azur.modules.php | 22 +++++++++++++------ 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 7e9535fb48c..5d07085378b 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -293,16 +293,17 @@ class pdf_einstein extends ModelePDFCommandes $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs); + $top_shift = $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; + $tab_top = 90+$top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_height = 130-$top_shift; $tab_height_newpage = 150; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift; // Incoterm $height_incoterms = 0; @@ -1298,16 +1299,22 @@ class pdf_einstein extends ModelePDFCommandes $posy+=2; + $top_shift = 0; // Show list of linked objects + $current_y = $pdf->getY(); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); - + if ($current_y < $pdf->getY()) + { + $top_shift = $pdf->getY() - $current_y; + } + if ($showaddress) { // Sender properties $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender - $posy=42; + $posy=42+$top_shift; $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; $hautcadre=40; @@ -1359,7 +1366,7 @@ class pdf_einstein extends ModelePDFCommandes // Show recipient $widthrecbox=100; if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42; + $posy=42+$top_shift; $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; @@ -1384,6 +1391,7 @@ class pdf_einstein extends ModelePDFCommandes } $pdf->SetTextColor(0,0,0); + return $top_shift; } /** diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index d4872b000de..de0b126b059 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -331,15 +331,16 @@ class pdf_crabe extends ModelePDFFactures if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs); + $top_shift = $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; + $tab_top = 90+$top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_height = 130-$top_shift; $tab_height_newpage = 150; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift; // Incoterm $height_incoterms = 0; @@ -1670,9 +1671,15 @@ class pdf_crabe extends ModelePDFFactures $posy+=1; + $top_shift = 0; // Show list of linked objects + $current_y = $pdf->getY(); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); - + if ($current_y < $pdf->getY()) + { + $top_shift = $pdf->getY() - $current_y; + } + if ($showaddress) { // Sender properties @@ -1680,6 +1687,7 @@ class pdf_crabe extends ModelePDFFactures // Show sender $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy+=$top_shift; $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; @@ -1735,6 +1743,7 @@ class pdf_crabe extends ModelePDFFactures $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy+=$top_shift; $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; @@ -1759,6 +1768,7 @@ class pdf_crabe extends ModelePDFFactures } $pdf->SetTextColor(0,0,0); + return $top_shift; } /** diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 604940b017e..b2a0a522cc9 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -329,16 +329,17 @@ class pdf_azur extends ModelePDFPropales $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; - $this->_pagehead($pdf, $object, 1, $outputlangs); + $top_shift = $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; + $tab_top = 90+$top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10); + $tab_height = 130-$top_shift; $tab_height_newpage = 150; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift; // Incoterm $height_incoterms = 0; @@ -1484,9 +1485,15 @@ class pdf_azur extends ModelePDFPropales $posy+=2; + $top_shift = 0; // Show list of linked objects + $current_y = $pdf->getY(); $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); - + if ($current_y < $pdf->getY()) + { + $top_shift = $pdf->getY() - $current_y; + } + if ($showaddress) { // Sender properties @@ -1503,7 +1510,7 @@ class pdf_azur extends ModelePDFPropales $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender - $posy=42; + $posy=42+$top_shift; $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; $hautcadre=40; @@ -1554,7 +1561,7 @@ class pdf_azur extends ModelePDFPropales // Show recipient $widthrecbox=100; if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=42; + $posy=42+$top_shift; $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; @@ -1579,6 +1586,7 @@ class pdf_azur extends ModelePDFPropales } $pdf->SetTextColor(0,0,0); + return $top_shift; } /** From a26bb2d884220a0093f82f1f7155771bdc89a252 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 8 Feb 2018 12:41:31 +0100 Subject: [PATCH 6/6] FIX #8151 --- htdocs/fichinter/class/fichinter.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index fb2359092a0..13eb2e74d7d 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1169,6 +1169,8 @@ class Fichinter extends CommonObject */ function fetch_lines() { + $this->lines = array(); + $sql = 'SELECT rowid, description, duree, date, rang'; $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet'; $sql.=' WHERE fk_fichinter = '.$this->id .' ORDER BY rang ASC, date ASC' ;