--- /tmp/dsg/dolibarr/htdocs/core/modules/rapport/github_19.0.3_pdf_paiement.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/rapport/client_pdf_paiement.class.php @@ -5 +4,0 @@ - * Copyright (C) 2020 Maxime DEMAREST @@ -27 +25,0 @@ - @@ -30 +27,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; @@ -34 +31 @@ - * Class to manage reporting of payments + * Classe permettant de generer les rapports de paiement @@ -36 +33 @@ -class pdf_paiement extends CommonDocGenerator +class pdf_paiement @@ -38,18 +34,0 @@ - public $tab_top; - - public $line_height; - - public $line_per_page; - - public $tab_height; - - public $posxdate; - - public $posxpaymenttype; - public $posxinvoice; - public $posxbankaccount; - public $posxinvoiceamount; - public $posxpaymentamount; - - public $doc_type; - @@ -57,13 +36,3 @@ - * @var int - */ - public $year; - - /** - * @var int - */ - public $month; - - /** - * Constructor - * - * @param DoliDb $db Database handler + * Constructor + * + * @param DoliDb $db Database handler @@ -76 +45 @@ - $langs->loadLangs(array("bills", "compta", "main")); + $langs->loadLangs(array("bills", "compta", "main")); @@ -87,4 +56,4 @@ - $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10); - $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); - $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); - $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; @@ -104 +73,2 @@ - if ($this->page_largeur < 210) { // To work with US executive format + if ($this->page_largeur < 210) // To work with US executive format + { @@ -116 +86 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -124 +94 @@ - * @return int Return integer <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK @@ -128 +98 @@ - // phpcs:enable + // phpcs:enable @@ -134,7 +104,3 @@ - if ($user->socid) { - $socid = $user->socid; - } - - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if ($user->socid) $socid = $user->socid; + + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -142,3 +108 @@ - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; @@ -150 +114,2 @@ - if (!is_dir($dir)) { + if (!is_dir($dir)) + { @@ -152 +117,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -162,8 +128,8 @@ - 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; + } @@ -173 +139,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -178 +145 @@ - $parameters = array('file'=>$file, 'object'=>$this, 'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'outputlangs'=>$outputlangs); @@ -180,24 +147,25 @@ - $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $this, $action); // Note that $action and $this 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; - } + $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; + } @@ -207 +175,2 @@ - if ($result) { + if ($result) + { @@ -218 +187 @@ - if (isModEnabled("banque")) { + if (!empty($conf->banque->enabled)) @@ -220 +188,0 @@ - } @@ -225 +193 @@ - if (isModEnabled("banque")) { + if (!empty($conf->banque->enabled)) @@ -227 +194,0 @@ - } @@ -229 +196,2 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { + if (!$user->rights->societe->client->voir && !$socid) + { @@ -233 +201 @@ - if (isModEnabled("banque")) { + if (!empty($conf->banque->enabled)) @@ -235 +202,0 @@ - } @@ -238,2 +205,3 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); + if (!$user->rights->societe->client->voir && !$socid) + { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -241,9 +209,2 @@ - if (!empty($socid)) { - $sql .= " AND s.rowid = ".((int) $socid); - } - // If global param PAYMENTS_REPORT_GROUP_BY_MOD is set, payment are ordered by paiement_code - if (getDolGlobalString('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"; - } + if (!empty($socid)) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC"; @@ -256 +217 @@ - if (isModEnabled("banque")) { + if (!empty($conf->banque->enabled)) @@ -258 +218,0 @@ - } @@ -263 +223 @@ - if (isModEnabled("banque")) { + if (!empty($conf->banque->enabled)) @@ -265 +224,0 @@ - } @@ -267 +226,2 @@ - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { + if (!$user->rights->societe->client->voir && !$socid) + { @@ -271 +231 @@ - if (isModEnabled("banque")) { + if (!empty($conf->banque->enabled)) @@ -272,0 +233,5 @@ + $sql .= " AND f.entity = ".$conf->entity; + $sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'"; + if (!$user->rights->societe->client->voir && !$socid) + { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -274,14 +239,2 @@ - $sql .= " AND f.entity IN (".getEntity('invoice').")"; - $sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'"; - if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - if (!empty($socid)) { - $sql .= " AND s.rowid = ".((int) $socid); - } - // If global param PAYMENTS_FOURN_REPORT_GROUP_BY_MOD is set, payment fourn are ordered by paiement_code - if (getDolGlobalString('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"; - } + if (!empty($socid)) $sql .= " AND s.rowid = ".$socid; + $sql .= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC"; @@ -293 +246,2 @@ - if ($result) { + if ($result) + { @@ -297 +251,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -312 +267,3 @@ - } else { + } + else + { @@ -318 +275,2 @@ - if ((($num + $numpaiement) % $this->line_per_page) > 0) { + if ((($num + $numpaiement) % $this->line_per_page) > 0) + { @@ -322 +280,2 @@ - if ($pages == 0) { + if ($pages == 0) + { @@ -336,3 +295 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -354,3 +311 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -363 +318,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -368 +324 @@ - $parameters = array('file'=>$file, 'object'=>$this, 'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); @@ -371,6 +327,8 @@ - if ($reshook < 0) { - $this->error = $hookmanager->error; - $this->errors = $hookmanager->errors; - } - - dolChmod($file); + if ($reshook < 0) + { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; + } + + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -383 +341 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore @@ -387 +345 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -395 +353 @@ - // phpcs:enable + // phpcs:enable @@ -404,8 +362,8 @@ - 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; + } @@ -419 +377 @@ - $pdf->SetXY($this->posxdate, 16); + $pdf->SetXY($this->posxdate, 16); @@ -422 +380 @@ - $pdf->SetXY($this->posxdate + 100, 16); + $pdf->SetXY($this->posxdate + 100, 16); @@ -427 +385 @@ - $pdf->SetXY($this->posxdate, $this->tab_top + 2); + $pdf->SetXY($this->posxdate, $this->tab_top + 2); @@ -431 +389 @@ - $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 2); + $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 2); @@ -435 +393 @@ - $pdf->SetXY($this->posxinvoice, $this->tab_top + 2); + $pdf->SetXY($this->posxinvoice, $this->tab_top + 2); @@ -439 +397 @@ - $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2); + $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2); @@ -444 +402 @@ - $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 2); + $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 2); @@ -448 +406 @@ - $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 2); + $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 2); @@ -457 +415 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -461 +419 @@ - * @param TCPDF $pdf PDF object + * @param PDF $pdf PDF object @@ -469,2 +427,2 @@ - // phpcs:enable - global $langs, $conf; + // phpcs:enable + global $langs; @@ -480,5 +438,2 @@ - if (($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) { - $mod = $lines[0][2]; - $total_mod = 0; - } - for ($j = 0; $j < $numlines; $j++) { + for ($j = 0; $j < $numlines; $j++) + { @@ -486 +441,2 @@ - if ($yp > $this->tab_height - 5) { + if ($yp > $this->tab_height - 5) + { @@ -493,13 +449,6 @@ - if ($oldprowid != $lines[$j][7]) { - 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); + if ($oldprowid <> $lines[$j][7]) + { + if ($yp > $this->tab_height - 15) + { + $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); @@ -528,3 +476,0 @@ - if (($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) { - $total_mod += $lines[$j][9]; - } @@ -550 +496,2 @@ - if ($oldprowid != $lines[$j][7]) { + if ($oldprowid <> $lines[$j][7]) + { @@ -553,25 +499,0 @@ - - // Add line to add total by payment mode if mode reglement for nex line change - if ((($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('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); - } @@ -580,10 +502,2 @@ - $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_19.0.3_pdf_paiement_fourn.class.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/rapport/client_pdf_paiement_fourn.class.php @@ -34,3 +34,3 @@ - * Constructor - * - * @param DoliDb $db Database handler + * Constructor + * + * @param DoliDb $db Database handler