--- /tmp/dsg/dolibarr/htdocs/core/modules/rapport/github_pdf_paiement.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/rapport/client_pdf_paiement.class.php
@@ -2,7 +2,6 @@
 /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>

  * Copyright (C) 2006-2014 Laurent Destailleur  <eldy@users.sourceforge.net>

  * Copyright (C) 2015-2018 Charlene BENKE  	<charlie@patas-monkey.com>

- * Copyright (C) 2020      Maxime DEMAREST <maxime@indelog.fr>

  *

  * This program is free software; you can redistribute it and/or modify

  * it under the terms of the GNU General Public License as published by

@@ -34,16 +33,16 @@
 class pdf_paiement

 {

 	/**

-	 *  Constructor

-	 *

-	 *  @param      DoliDb		$db      Database handler

+     *  Constructor

+     *

+     *  @param      DoliDb		$db      Database handler

 	 */

 	public function __construct($db)

 	{

 		global $langs, $conf;

 

 		// Load translation files required by the page

-		$langs->loadLangs(array("bills", "compta", "main"));

+        $langs->loadLangs(array("bills", "compta", "main"));

 

 		$this->db = $db;

 		$this->description = $langs->transnoentities("ListOfCustomerPayments");

@@ -84,7 +83,7 @@
 	}

 

 

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

 	/**

 	 *	Fonction generant la rapport sur le disque

 	 *

@@ -96,7 +95,7 @@
 	 */

 	public function write_file($_dir, $month, $year, $outputlangs)

 	{

-		// phpcs:enable

+        // phpcs:enable

 		include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';

 

 		global $conf, $hookmanager, $langs, $user;

@@ -126,14 +125,14 @@
 		$year = sprintf("%04d", $year);

 

 		$file = $dir."/payments-".$year."-".$month.".pdf";

-		switch ($this->doc_type) {

-			case "client":

-				$file = $dir."/payments-".$year."-".$month.".pdf";

-				break;

-			case "fourn":

-				$file = $dir."/supplier_payments-".$year."-".$month.".pdf";

-				break;

-		}

+        switch ($this->doc_type) {

+            case "client":

+                $file = $dir."/payments-".$year."-".$month.".pdf";

+                break;

+            case "fourn":

+                $file = $dir."/supplier_payments-".$year."-".$month.".pdf";

+                break;

+        }

 

 

 		// Add pdfgeneration hook

@@ -147,29 +146,29 @@
 		global $action;

 		$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks

 

-		$pdf = pdf_getInstance($this->format);

-		$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance

-

-		if (class_exists('TCPDF'))

-		{

-			$pdf->setPrintHeader(false);

-			$pdf->setPrintFooter(false);

-		}

-		$pdf->SetFont(pdf_getPDFFont($outputlangs));

-

-		$num = 0;

-		$lines = array();

-

-		// count number of lines of payment

-		$sql = "SELECT p.rowid as prowid";

-		switch ($this->doc_type) {

-			case "client":

-				$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";

-				break;

-			case "fourn":

-				$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";

-				break;

-		}

+        $pdf = pdf_getInstance($this->format);

+        $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance

+

+        if (class_exists('TCPDF'))

+        {

+            $pdf->setPrintHeader(false);

+            $pdf->setPrintFooter(false);

+        }

+        $pdf->SetFont(pdf_getPDFFont($outputlangs));

+

+        $num = 0;

+        $lines = array();

+

+        // count number of lines of payment

+        $sql = "SELECT p.rowid as prowid";

+        switch ($this->doc_type) {

+            case "client":

+                $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";

+                break;

+            case "fourn":

+                $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";

+                break;

+        }

 		$sql .= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";

 		$sql .= " AND p.entity = ".$conf->entity;

 		$result = $this->db->query($sql);

@@ -208,10 +207,7 @@
 					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;

 				}

 				if (!empty($socid)) $sql .= " AND s.rowid = ".$socid;

-				// If global param PAYMENTS_REPORT_GROUP_BY_MOD is set, payement are ordered by paiement_code

-				if (!empty($conf->global->PAYMENTS_REPORT_GROUP_BY_MOD))

-					$sql .= " ORDER BY paiement_code ASC, p.datep ASC, pf.fk_paiement ASC";

-				else $sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC";

+				$sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC";

 				break;

 			case "fourn":

 				$sql = "SELECT p.datep as dp, f.ref as ref";

@@ -241,10 +237,7 @@
 					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;

 				}

 				if (!empty($socid)) $sql .= " AND s.rowid = ".$socid;

-				// If global param PAYMENTS_FOURN_REPORT_GROUP_BY_MOD is set, payement fourn are ordered by paiement_code

-				if (!empty($conf->global->PAYMENTS_FOURN_REPORT_GROUP_BY_MOD))

-					$sql .= " ORDER BY paiement_code ASC, p.datep ASC, pf.fk_paiementfourn ASC";

-				else $sql .= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";

+				$sql .= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";

 				break;

 		}

 

@@ -271,7 +264,9 @@
 				$lines[$i][9] = $objp->paiement_amount;

 				$i++;

 			}

-		} else {

+		}

+		else

+		{

 			dol_print_error($this->db);

 		}

 

@@ -331,8 +326,8 @@
 		$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks

 		if ($reshook < 0)

 		{

-			$this->error = $hookmanager->error;

-			$this->errors = $hookmanager->errors;

+		    $this->error = $hookmanager->error;

+		    $this->errors = $hookmanager->errors;

 		}

 

 		if (!empty($conf->global->MAIN_UMASK))

@@ -343,11 +338,11 @@
 		return 1;

 	}

 

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore

 	/**

 	 *  Show top header of page.

 	 *

-	 *  @param	TCPDF			$pdf     		Object PDF

+	 *  @param	PDF			$pdf     		Object PDF

 	 *  @param  int			$page	     	Object to show

 	 *  @param  int	    	$showaddress    0=no, 1=yes

 	 *  @param  Translate	$outputlangs	Object lang for output

@@ -355,7 +350,7 @@
 	 */

 	protected function _pagehead(&$pdf, $page, $showaddress, $outputlangs)

 	{

-		// phpcs:enable

+        // phpcs:enable

 		global $langs, $conf;

 

 		// Do not add the BACKGROUND as this is a report

@@ -364,14 +359,14 @@
 		$default_font_size = pdf_getPDFFontSize($outputlangs);

 

 		$title = $conf->global->MAIN_INFO_SOCIETE_NOM;

-		switch ($this->doc_type) {

-			case "client":

-				$title .= ' - '.$outputlangs->transnoentities("ListOfCustomerPayments");

-				break;

-			case "fourn":

-				$title .= ' - '.$outputlangs->transnoentities("ListOfSupplierPayments");

-				break;

-		}

+        switch ($this->doc_type) {

+            case "client":

+                $title .= ' - '.$outputlangs->transnoentities("ListOfCustomerPayments");

+                break;

+            case "fourn":

+                $title .= ' - '.$outputlangs->transnoentities("ListOfSupplierPayments");

+                break;

+        }

 		$title .= ' - '.dol_print_date(dol_mktime(0, 0, 0, $this->month, 1, $this->year), "%B %Y", false, $outputlangs, true);

 		$pdf->SetFont('', 'B', $default_font_size + 1);

 		$pdf->SetXY($this->marge_gauche, 10);

@@ -379,36 +374,36 @@
 

 		$pdf->SetFont('', '', $default_font_size);

 

-		$pdf->SetXY($this->posxdate, 16);

+        $pdf->SetXY($this->posxdate, 16);

 		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(), "day", false, $outputlangs, true), 0, 'L');

 

-		$pdf->SetXY($this->posxdate + 100, 16);

+        $pdf->SetXY($this->posxdate + 100, 16);

 		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');

 

 

 		// Title line

-		$pdf->SetXY($this->posxdate, $this->tab_top + 2);

+        $pdf->SetXY($this->posxdate, $this->tab_top + 2);

 		$pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');

 

 		$pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);

-		$pdf->SetXY($this->posxpaymenttype, $this->tab_top + 2);

+        $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 2);

 		$pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');

 

 		$pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);

-		$pdf->SetXY($this->posxinvoice, $this->tab_top + 2);

+        $pdf->SetXY($this->posxinvoice, $this->tab_top + 2);

 		$pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');

 

 		$pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);

-		$pdf->SetXY($this->posxbankaccount, $this->tab_top + 2);

+        $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2);

 		$pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L');

 

 

 		$pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);

-		$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 2);

+        $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 2);

 		$pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');

 

 		$pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);

-		$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 2);

+        $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 2);

 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');

 

 		$pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);

@@ -417,11 +412,11 @@
 	}

 

 

-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps

 	/**

 	 *	Output body

 	 *

-	 *	@param	TCPDF		$pdf			PDF object

+	 *	@param	PDF			$pdf			PDF object

 	 *	@param	string		$page			Page

 	 *	@param	array		$lines			Array of lines

 	 *	@param	Translate	$outputlangs	Object langs

@@ -429,8 +424,8 @@
 	 */

 	public function Body(&$pdf, $page, $lines, $outputlangs)

 	{

-		// phpcs:enable

-		global $langs, $conf;

+        // phpcs:enable

+		global $langs;

 		$default_font_size = pdf_getPDFFontSize($outputlangs);

 

 		$pdf->SetFont('', '', $default_font_size - 1);

@@ -440,11 +435,6 @@
 		$pdf->SetFillColor(220, 220, 220);

 		$yp = 0;

 		$numlines = count($lines);

-		if (($this->doc_type == 'client' && !empty($conf->global->PAYMENTS_REPORT_GROUP_BY_MOD)) || ($this->doc_type == 'fourn' && !empty($conf->global->PAYMENTS_FOURN_REPORT_GROUP_BY_MOD)))

-		{

-			$mod = $lines[0][2];

-			$total_mod = 0;

-		}

 		for ($j = 0; $j < $numlines; $j++)

 		{

 			$i = $j;

@@ -460,17 +450,8 @@
 			{

 				if ($yp > $this->tab_height - 15)

 				{

-					$pdf->SetFillColor(255, 255, 255);

-					$pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());

-					$pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash'=>1));

-					$pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);

-					$pdf->SetFont('', 'B', $default_font_size - 1);

-					$pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);

-					$pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('SubTotal')." : ", 0, 'R', 1);

-					$pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);

-					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_page), 0, 'R', 1);

-					$pdf->SetFont('', '', $default_font_size - 1);

-					$pdf->SetFillColor(220, 220, 220);

+					$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);

+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0);

 					$page++;

 					$pdf->AddPage();

 					$this->_pagehead($pdf, $page, 0, $outputlangs);

@@ -493,7 +474,6 @@
 				$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);

 				$yp = $yp + 5;

 				$total_page += $lines[$j][9];

-				if (($this->doc_type == 'client' && !empty($conf->global->PAYMENTS_REPORT_GROUP_BY_MOD)) || ($this->doc_type == 'fourn' && !empty($conf->global->PAYMENTS_FOURN_REPORT_GROUP_BY_MOD))) $total_mod += $lines[$j][9];

 			}

 

 			// Invoice number

@@ -517,44 +497,9 @@
 			{

 				$oldprowid = $lines[$j][7];

 			}

-

-			// Add line to add total by payment mode if mode reglement for nex line change

-			if ((($this->doc_type == 'client' && !empty($conf->global->PAYMENTS_REPORT_GROUP_BY_MOD)) || ($this->doc_type == 'fourn' && !empty($conf->global->PAYMENTS_FOURN_REPORT_GROUP_BY_MOD))) && ($mod != $lines[$j + 1][2]))

-			{

-				$pdf->SetFillColor(245, 245, 245);

-				$pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());

-				$pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash'=>1));

-				$pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);

-				$pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);

-				$pdf->SetFont('', 'I', $default_font_size - 1);

-				$pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total').' '.$mod." : ", 0, 'R', 1);

-				$pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);

-				$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_mod), 0, 'R', 1);

-				$pdf->SetFont('', '', $default_font_size - 1);

-				$mod = $lines[$j + 1][2];

-				$total_mod = 0;

-				$yp = $yp + 5;

-				if ($yp > $this->tab_height - 5)

-				{

-					$page++;

-					$pdf->AddPage();

-					$this->_pagehead($pdf, $page, 0, $outputlangs);

-					$pdf->SetFont('', '', $default_font_size - 1);

-					$yp = 0;

-				}

-				$pdf->SetFillColor(220, 220, 220);

-			}

 		}

 		$total += $total_page;

-		$pdf->SetFillColor(255, 255, 255);

-		$pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());

-		$pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash'=>1));

-		$pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);

-		$pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);

-		$pdf->SetFont('', 'B');

-		$pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total')." : ", 0, 'R', 1);

-		$pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);

-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total), 0, 'R', 1);

-		$pdf->SetFillColor(220, 220, 220);

+		$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);

+		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('Total')." : ".price($total), 0, 'R', 0);

 	}

 }

--- /tmp/dsg/dolibarr/htdocs/core/modules/rapport/github_pdf_paiement_fourn.class.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/rapport/client_pdf_paiement_fourn.class.php
@@ -31,9 +31,9 @@
 class pdf_paiement_fourn extends pdf_paiement

 {

 	/**

-	 *  Constructor

-	 *

-	 *  @param      DoliDb		$db      Database handler

+     *  Constructor

+     *

+     *  @param      DoliDb		$db      Database handler

 	 */

 	public function __construct($db)

 	{