From abc8e98de0f7cad5617292d5f8831ce30deb37da Mon Sep 17 00:00:00 2001 From: MDW Date: Sun, 5 Jan 2025 18:12:36 +0100 Subject: [PATCH] Qual: Fix phan notices --- htdocs/core/customreports.php | 47 +++++--- .../commande/doc/pdf_eratosthene.modules.php | 2 +- .../modules/commande/modules_commande.php | 4 +- .../delivery/doc/pdf_typhon.modules.php | 11 +- .../expedition/doc/pdf_merou.modules.php | 13 ++- .../pdf_standard_expensereport.modules.php | 29 ++++- .../modules/facture/doc/pdf_crabe.modules.php | 18 +-- .../facture/doc/pdf_octopus.modules.php | 12 +- .../facture/doc/pdf_sponge.modules.php | 18 +-- .../core/modules/facture/modules_facture.php | 50 ++++++++- htdocs/core/modules/fichinter/mod_pacific.php | 5 +- .../doc/pdf_standard_evaluation.modules.php | 2 +- .../modules/mailings/contacts1.modules.php | 4 +- .../modules/mailings/thirdparties.modules.php | 4 +- .../pdf_standard_movementstock.modules.php | 104 ++++++++++++------ .../modules/mrp/doc/pdf_vinci.modules.php | 6 +- .../modules/printing/printgcp.modules.php | 18 ++- .../product/doc/pdf_standard.modules.php | 67 +++++------ .../task/doc/doc_generic_task_odt.modules.php | 4 +- .../modules/propale/doc/pdf_azur.modules.php | 21 ++-- .../modules/propale/doc/pdf_cyan.modules.php | 44 ++++---- .../core/modules/propale/modules_propale.php | 49 ++++++++- .../reception/doc/pdf_squille.modules.php | 4 +- 23 files changed, 377 insertions(+), 159 deletions(-) diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 5535546dece65..266537541a98a 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -1,4 +1,5 @@ * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France @@ -41,9 +42,9 @@ */ // Initialise values -$search_xaxis = array(); $search_groupby = array(); $tabfamily = null; +$objecttype = null; if (!defined('USE_CUSTOM_REPORT_AS_INCLUDE')) { require '../main.inc.php'; @@ -70,7 +71,7 @@ '@phan-var-force string[] $search_groupby'; $search_yaxis = GETPOST('search_yaxis', 'array'); - $search_graph = GETPOST('search_graph', 'restricthtml'); + $search_graph = (string) GETPOST('search_graph', 'restricthtml'); // Load variable for pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; @@ -113,10 +114,18 @@ if (!isset($search_measures)) { $search_measures = array(0 => 't.count'); } +if (!isset($search_xaxis)) { + // Ensure value is set and not null. + $search_xaxis = array(); +} +if (!isset($search_graph)) { + // Ensure value is set and not null + $search_graph = ''; +} if (!empty($object)) { $objecttype = $object->element.($object->module ? '@'.$object->module : ''); } -if (empty($objecttype)) { +if (!is_string($objecttype) || empty($objecttype)) { $objecttype = 'thirdparty'; } @@ -163,6 +172,7 @@ // Complete $arrayoftype by external modules $parameters = array('objecttype' => $objecttype, 'tabfamily' => $tabfamily); +// @phan-suppress-next-line PhanTypeMismatchArgumentNullable $reshook = $hookmanager->executeHooks('loadDataForCustomReports', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -191,9 +201,12 @@ } else { $fileforclass = "/".$objecttype."/class/".$objecttype.".class.php"; } - dol_include_once($fileforclass); + $ObjectClassName = null; - $ObjectClassName = $arrayoftype[$objecttype]['ObjectClassName']; + if ($fileforclass !== null) { + dol_include_once($fileforclass); + $ObjectClassName = $arrayoftype[$objecttype]['ObjectClassName']; + } if (!empty($ObjectClassName)) { if (class_exists($ObjectClassName)) { $object = new $ObjectClassName($db); @@ -369,7 +382,7 @@ $newarrayoftype = array(); foreach ($arrayoftype as $key => $val) { - if (dol_eval($val['enabled'], 1, 1, '1')) { + if (dol_eval((string) $val['enabled'], 1, 1, '1')) { $newarrayoftype[$key] = $arrayoftype[$key]; } if (!empty($val['langs'])) { @@ -378,11 +391,15 @@ } $count = 0; -$arrayoffilterfields = fillArrayOfFilterFields($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayoffilterfields, 0, $count); +$label = ''; +if ($objecttype !== null && array_key_exists($objecttype, $newarrayoftype)) { + $label = $langs->trans($newarrayoftype[$objecttype]['label']); +} +$arrayoffilterfields = fillArrayOfFilterFields($object, 't', $label, $arrayoffilterfields, 0, $count); $arrayoffilterfields = dol_sort_array($arrayoffilterfields, 'position', 'asc', 0, 0, 1); $count = 0; -$arrayofmesures = fillArrayOfMeasures($object, 't', $langs->trans($newarrayoftype[$objecttype]['label']), $arrayofmesures, 0, $count); +$arrayofmesures = fillArrayOfMeasures($object, 't', $label, $arrayofmesures, 0, $count); $arrayofmesures = dol_sort_array($arrayofmesures, 'position', 'asc', 0, 0, 1); $count = 0; @@ -396,17 +413,17 @@ // Check parameters if ($action == 'viewgraph') { - if (is_array($search_measures) && !count($search_measures)) { + if (!count($search_measures)) { setEventMessages($langs->trans("AtLeastOneMeasureIsRequired"), null, 'warnings'); } elseif ($mode == 'graph' && is_array($search_xaxis) && count($search_xaxis) > 1) { setEventMessages($langs->trans("OnlyOneFieldForXAxisIsPossible"), null, 'warnings'); $search_xaxis = array(0 => $search_xaxis[0]); } - if (is_array($search_groupby) && count($search_groupby) >= 2) { + if (count($search_groupby) >= 2) { setEventMessages($langs->trans("ErrorOnlyOneFieldForGroupByIsPossible"), null, 'warnings'); $search_groupby = array(0 => $search_groupby[0]); } - if (is_array($search_xaxis) && !count($search_xaxis)) { + if (!count($search_xaxis)) { setEventMessages($langs->trans("AtLeastOneXAxisIsRequired"), null, 'warnings'); } elseif ($mode == 'graph' && $search_graph == 'bars' && count($search_measures) > $MAXMEASURESINBARGRAPH) { $langs->load("errors"); @@ -417,7 +434,7 @@ // Get all possible values of fields when a 'group by' is set, and save this into $arrayofvaluesforgroupby // $arrayofvaluesforgroupby will be used to forge lael of each grouped series -if (is_array($search_groupby) && count($search_groupby)) { +if (count($search_groupby)) { $fieldtocount = ''; foreach ($search_groupby as $gkey => $gval) { $gvalwithoutprefix = preg_replace('/^[a-z]+\./', '', $gval); @@ -563,7 +580,7 @@ } } //var_dump($labeloffield); - setEventMessages($langs->transnoentitiesnoconv("ErrorTooManyDifferentValueForSelectedGroupBy", $MAXUNIQUEVALFORGROUP, $labeloffield), null, 'warnings'); + setEventMessages($langs->transnoentitiesnoconv("ErrorTooManyDifferentValueForSelectedGroupBy", (string) $MAXUNIQUEVALFORGROUP, (string) $labeloffield), null, 'warnings'); $search_groupby = array(); } @@ -1064,7 +1081,7 @@ function (array $matches): string { $legend[] = $langs->trans($arrayofmesures[$val]['label']); } -$useagroupby = (is_array($search_groupby) && count($search_groupby)); +$useagroupby = count($search_groupby); //var_dump($useagroupby); //var_dump($arrayofvaluesforgroupby); @@ -1221,7 +1238,7 @@ function (array $matches): string { $px1->SetLegend($legend); $px1->setShowLegend($SHOWLEGEND); - $px1->SetMinValue($px1->GetFloorMinValue()); + $px1->SetMinValue((int) $px1->GetFloorMinValue()); $px1->SetMaxValue($px1->GetCeilMaxValue()); $px1->SetWidth($WIDTH); $px1->SetHeight($HEIGHT); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 5f1a384d7a091..1362556387d6f 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -278,7 +278,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if ($dir === null) { dol_syslog(get_class($this).'::'.__METHOD__."Target directory should not be null.". getCallerInfoString(), LOG_ERR); - $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", "Null dir"); return 0; } diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index db65437e38eee..fdac0976b70bc 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -85,14 +85,14 @@ abstract class ModelePDFCommandes extends CommonDocGenerator /** * Local tax rates Array[tax_type][tax_rate] * - * @var array> + * @var array> */ public $localtax1; /** * Local tax rates Array[tax_type][tax_rate] * - * @var array> + * @var array> */ public $localtax2; diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 9371f68b116a7..5841616cda738 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -5,7 +5,7 @@ * Copyright (C) 2008 Chiptronik * Copyright (C) 2011-2021 Philippe Grand * Copyright (C) 2015 Marcos García - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Nick Fragoulis * @@ -72,8 +72,17 @@ class pdf_typhon extends ModelePDFDeliveryOrder */ public $version = 'dolibarr'; + /** + * @var float + */ public $posxcomm; // For customer comment column + /** + * @var float + */ public $posxweightvol; // For weight or volume + /** + * @var float + */ public $posxremainingqty; diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index d4aca633a6e40..d54d831adb108 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015 Marcos García - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Nick Fragoulis * @@ -65,8 +65,17 @@ class pdf_merou extends ModelePdfExpedition */ public $type; + /** + * @var Contact + */ public $destinataire; + /** + * @var ?Societe + */ public $expediteur; + /** + * @var User + */ public $livreur; /** @@ -624,7 +633,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $label .= $object->tracking_url; } $pdf->SetFont('', 'B', $default_font_size - 3); - $pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L'); + $pdf->writeHTMLCell(50, 8, '', '', $label, 0, 1, false, true, 'L'); } } } else { diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php index 44d26eb9f0b8f..925ff9efce612 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php @@ -7,7 +7,7 @@ * Copyright (C) 2019 Markus Welters * Copyright (C) 2019 Rafael Ingenleuf * Copyright (C) 2020 Marc Guenneugues - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify @@ -77,19 +77,46 @@ class pdf_standard_expensereport extends ModeleExpenseReport */ public $version = 'dolibarr'; + /** + * @var float + */ public $posxpiece; + /** + * @var float + */ public $posxcomment; + /** + * @var float + */ public $posxtva; + /** + * @var float + */ public $posxup; + /** + * @var float + */ public $posxqty; + /** + * @var float + */ public $posxtype; /** * @var int posx date */ public $posxdate; + /** + * @var float + */ public $posxprojet; + /** + * @var float + */ public $postotalht; + /** + * @var float + */ public $postotalttc; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 9b540229124bf..b751a886983ea 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -11,7 +11,7 @@ * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2022-2024 Anthony Berton * Copyright (C) 2022 Charlene Benke - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Nick Fragoulis * Copyright (C) 2024 Alexandre Spangaro * @@ -800,7 +800,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['tot_ht'])) { $this->tva_array[$vatrate . ($vatcode ? ' (' . $vatcode . ')' : '')]['tot_ht'] = 0; } - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne, 'tot_ht'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['tot_ht'] + $object->lines[$i]->total_ht); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate' => $vatrate, 'vatcode' => $vatcode, 'amount' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne, 'tot_ht' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['tot_ht'] + $object->lines[$i]->total_ht); } else { if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; @@ -901,7 +901,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pagecount = $pdf->setSourceFile($termsofsale); for ($i = 1; $i <= $pagecount; $i++) { $tplIdx = $pdf->importPage($i); - if ($tplIdx!==false) { + if ($tplIdx !== false) { $s = $pdf->getTemplatesize($tplIdx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); $pdf->useTemplate($tplIdx); @@ -1884,7 +1884,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1903,10 +1903,10 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ if (getDolGlobalString('MAIN_GENERATE_INVOICES_WITH_PICTURE')) { $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height); - if (empty($hidetop)) { - //$pdf->SetXY($this->posxpicture-1, $tab_top+1); - //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C'); - } + //if (empty($hidetop)) { + //$pdf->SetXY($this->posxpicture-1, $tab_top+1); + //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C'); + //} } if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) { @@ -2338,7 +2338,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output // Show shipping frame $pdf->SetXY($posx + 2, $posy - 5); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); + $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show shipping name diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index b3fa9ee860fcc..ae9408a933d73 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -12,7 +12,7 @@ * Copyright (C) 2022 Anthony Berton * Copyright (C) 2022-2024 Alexandre Spangaro * Copyright (C) 2022-2024 Eric Seigne - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify @@ -336,6 +336,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $arephoto = false; + $realpath = false; foreach ($pdir as $midir) { if (!$arephoto) { if ($conf->entity != $objphoto->entity) { @@ -811,6 +812,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } + /** @phan-suppress-next-line PhanTypeMismatchProperty */ if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $posy + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually @@ -1046,7 +1048,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['tot_ht'])) { $this->tva_array[$vatrate . ($vatcode ? ' (' . $vatcode . ')' : '')]['tot_ht'] = 0; } - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne, 'tot_ht'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['tot_ht'] + $object->lines[$i]->total_ht); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate' => $vatrate, 'vatcode' => $vatcode, 'amount' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne, 'tot_ht' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['tot_ht'] + $object->lines[$i]->total_ht); } else { if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; @@ -2077,7 +2079,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ // MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } $tab_top += 4; } @@ -2503,7 +2505,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output // Show shipping frame $pdf->SetXY($posx + 2, $posy - 5); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); + $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show shipping name @@ -2883,7 +2885,7 @@ public function _tableFirstPage(&$pdf, $tab_top, $tab_height, $nexY, $outputlang //$pdf->Rect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); $pdf->RoundedRect($this->posx_cumul_anterieur - 1, $tab_top, $width, 5, $this->corner_radius, '1001', 'F', explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); //$pdf->Rect($this->marge_gauche, $tab_top + 92.5, $this->page_largeur - $this->marge_gauche - $this->marge_droite, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); - $pdf->RoundedRect($this->marge_gauche, $tab_top + 92.5, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top + 92.5, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 10bd454492320..0474bd6bf616a 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -11,7 +11,7 @@ * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2018-2024 Anthony Berton * Copyright (C) 2022-2024 Alexandre Spangaro - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Nick Fragoulis * Copyright (C) 2024 Franck Moreau * @@ -262,6 +262,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $arephoto = false; + $realpath = false; foreach ($pdir as $midir) { if (!$arephoto) { if ($conf->entity != $objphoto->entity) { @@ -751,6 +752,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $pdf->setPageOrientation('', 0, $this->heightforfooter + $this->heightforfreetext); // The only function to edit the bottom margin of current page to set it. + // @phan-suppress-next-line PhanTypeMismatchProperty if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + $imageTopMargin, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually @@ -941,7 +943,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['tot_ht'])) { $this->tva_array[$vatrate . ($vatcode ? ' (' . $vatcode . ')' : '')]['tot_ht'] = 0; } - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne, 'tot_ht'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['tot_ht'] + $object->lines[$i]->total_ht); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate' => $vatrate, 'vatcode' => $vatcode, 'amount' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne, 'tot_ht' => $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['tot_ht'] + $object->lines[$i]->total_ht); } else { if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) { $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0; @@ -979,7 +981,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw table frames and columns borders $drawTabNumbPage = $pdf->getNumPages(); - for ($i=$pageposbeforeprintlines; $i<=$drawTabNumbPage; $i++) { + for ($i = $pageposbeforeprintlines; $i <= $drawTabNumbPage; $i++) { $pdf->setPage($i); // reset page orientation each loop to override it if it was changed $pdf->setPageOrientation('', 0, 0); // The only function to edit the bottom margin of current page to set it. @@ -994,7 +996,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $drawTabTop = $this->tab_top; } elseif (!$drawTabHideTop) { if (getDolGlobalInt('MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) { - $drawTabTop-= $this->tabTitleHeight; + $drawTabTop -= $this->tabTitleHeight; } else { $drawTabHideTop = 1; } @@ -1003,7 +1005,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // last page need to include document footer if ($i == $pdf->getNumPages()) { // remove document footer height to tab bottom position - $drawTabBottom-= $this->heightforfreetext + $this->heightforinfotot + $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs); + $drawTabBottom -= $this->heightforfreetext + $this->heightforinfotot + $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs); } $drawTabHeight = $drawTabBottom - $drawTabTop; @@ -1061,7 +1063,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pagecount = $pdf->setSourceFile($termsofsale); for ($i = 1; $i <= $pagecount; $i++) { $tplIdx = $pdf->importPage($i); - if ($tplIdx!==false) { + if ($tplIdx !== false) { $s = $pdf->getTemplatesize($tplIdx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); $pdf->useTemplate($tplIdx); @@ -2190,7 +2192,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -2586,7 +2588,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $output // Show shipping frame $pdf->SetXY($posx + 2, $posy - 5); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); + $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0); $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius, '1234', 'D'); // Show shipping name diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index b81a17895d4ee..0f6ace0c642fc 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Marcos García - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -42,21 +42,69 @@ */ abstract class ModelePDFFactures extends CommonDocGenerator { + /** + * @var float + */ public $posxpicture; + /** + * @var float + */ public $posxtva; + /** + * @var float + */ public $posxup; + /** + * @var float + */ public $posxqty; + /** + * @var float + */ public $posxunit; + /** + * @var float + */ public $posxdesc; + /** + * @var float + */ public $posxdiscount; + /** + * @var float + */ public $postotalht; + + /** + * @var array + */ public $tva; + /** + * @var array + */ public $tva_array; + /** + * Local tax rates Array[tax_type][tax_rate] + * + * @var array> + */ public $localtax1; + + /** + * Local tax rates Array[tax_type][tax_rate] + * + * @var array> + */ public $localtax2; + /** + * @var int<0,1> + */ public $atleastonediscount = 0; + /** + * @var int<0,1> + */ public $atleastoneratenotnull = 0; diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index f6eaa326c7560..fe69438341b9d 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -140,13 +140,12 @@ public function getNextValue($objsoc = '', $object = '') $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $sql .= " AND entity = ".$conf->entity; + $max = 0; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); if ($obj) { $max = intval($obj->max); - } else { - $max = 0; } } diff --git a/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php b/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php index e0d8afd866844..8b2b2fb5c0b6f 100644 --- a/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php +++ b/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php @@ -7,7 +7,7 @@ * Copyright (C) 2019 Markus Welters * Copyright (C) 2019 Rafael Ingenleuf * Copyright (C) 2020 Marc Guenneugues - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index e8eca88cf4fec..6a47290e352aa 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2005-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -314,7 +314,7 @@ public function formFilter() require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($this->db); $s .= img_picto($langs->trans("DefaultLang"), 'language', 'class="pictofixedwidth"'); - $s .= $formadmin->select_language(GETPOST('filter_lang', 'aZ09'), 'filter_lang', 0, null, $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, null, 1); + $s .= $formadmin->select_language(GETPOST('filter_lang', 'aZ09'), 'filter_lang', 0, array(), $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, array(), 1); } return $s; diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 583d0aec20601..4385c0395963d 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -2,7 +2,7 @@ /* Copyright (C) 2018-2018 Andre Schild * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This file is an example to follow to add your own email selector inside @@ -385,7 +385,7 @@ public function formFilter() $formadmin = new FormAdmin($this->db); $s .= img_picto($langs->trans("DefaultLang"), 'language', 'class="pictofixedwidth"'); //$s .= ''.$langs->trans("DefaultLang").': '; - $s .= $formadmin->select_language(GETPOST('filter_lang_thirdparties', 'aZ09'), 'filter_lang_thirdparties', 0, null, $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, null, 1); + $s .= $formadmin->select_language(GETPOST('filter_lang_thirdparties', 'aZ09'), 'filter_lang_thirdparties', 0, array(), $langs->trans("DefaultLang"), 0, 0, '', 0, 0, 0, array(), 1); } return $s; diff --git a/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php b/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php index 7a0624cb99b96..9f461561c32fe 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Nick Fragoulis * @@ -45,16 +45,49 @@ class pdf_standard_movementstock extends ModelePDFMovement */ public $update_main_doc_field; + /** + * @var int + */ public $wref; + /** + * @var float + */ public $posxidref; + /** + * @var float + */ public $posxdatemouv; + /** + * @var float + */ public $posxdesc; + /** + * @var float + */ public $posxlabel; + /** + * @var float + */ public $posxtva; + /** + * @var float + */ public $posxqty; + /** + * @var float + */ public $posxup; + /** + * @var float + */ public $posxunit; + /** + * @var float + */ public $posxdiscount; + /** + * @var float + */ public $postotalht; @@ -320,7 +353,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $resql = $this->db->query($sql); - $nbtotalofrecords = $this->db->num_rows($result); + $nbtotalofrecords = $this->db->num_rows($resql); /* * END TODO @@ -840,7 +873,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ if (empty($hidetop)) { //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter $pdf->SetXY($this->posxidref, $tab_top + 1); - $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L'); + $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L'); } //Date mouv @@ -1036,6 +1069,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlek $obj = $this->db->fetch_object($resqlbis); $lastmovementdate = $this->db->jdate($obj->datem); } else { + $lastmovementdate = 0; dol_print_error($this->db); } @@ -1088,39 +1122,39 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlek // $top_shift = $pdf->getY() - $current_y; //} - if ($showaddress) { - /* - // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); - - // Show sender - $posy=42; - $posx=$this->marge_gauche; - if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; - - // Show sender frame - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','', $default_font_size - 2); - $pdf->SetXY($posx,$posy-5); - $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, 'L'); - $pdf->SetXY($posx,$posy); - $pdf->SetFillColor(230,230,230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); - $pdf->SetTextColor(0,0,60); + //if ($showaddress) { + /* + // Sender properties + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + + // Show sender + $posy=42; + $posx=$this->marge_gauche; + if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) $posx=$this->page_largeur-$this->marge_droite-80; + $hautcadre=40; + + // Show sender frame + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posx,$posy-5); + $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, 'L'); + $pdf->SetXY($posx,$posy); + $pdf->SetFillColor(230,230,230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0,0,60); - // Show sender name - $pdf->SetXY($posx+2,$posy+3); - $pdf->SetFont('','B', $default_font_size); - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); - - // Show sender information - $pdf->SetXY($posx+2,$posy); - $pdf->SetFont('','', $default_font_size - 1); - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); - */ - } + // Show sender name + $pdf->SetXY($posx+2,$posy+3); + $pdf->SetFont('','B', $default_font_size); + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy=$pdf->getY(); + + // Show sender information + $pdf->SetXY($posx+2,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); + */ + //} $pdf->SetTextColor(0, 0, 0); diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 1625bbffca06d..9fde1bfb43265 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -5,8 +5,8 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2018-2025 Frédéric France + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Josep Lluís Amador * Copyright (C) 2024 Nick Fragoulis * @@ -944,7 +944,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 060168279abad..af35adb57d02b 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -1,7 +1,7 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -216,7 +216,7 @@ public function listAvailablePrinters() $html .= ''.$langs->trans('GCP_Type').''; $html .= ''.$langs->trans("Select").''; $html .= ''."\n"; - $list = $this->getlistAvailablePrinters(); + $list = $this->getlistAvailableGcpPrinters(); //$html.= '
'.print_r($list,true).'
'; foreach ($list['available'] as $printer_det) { $html .= ''; @@ -245,9 +245,21 @@ public function listAvailablePrinters() /** * Return list of available printers * - * @return array{available:array{name:string,displayname:string,id:string,ownerName:string,status:string,connectionStatus:string,type:string}} list of printers + * @return array list of printers */ public function getlistAvailablePrinters() + { + /* Compatible with paretn class signature */ + return $this->getlistAvailableGcpPrinters()['available']; + } + + + /** + * Return list of available printers (internal format) + * + * @return array{available:array} list of printers + */ + public function getlistAvailableGcpPrinters() { global $conf; $ret = array(); diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 68f6a5a7e8136..adba3813d903d 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -1,7 +1,7 @@ * Copyright (C) 2023 Anthony Berton - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Nick Fragoulis * @@ -278,6 +278,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } // Define size of image if we need it $imglinesize = array(); + $nexyafterphoto = null; if (!empty($realpath) && $arephoto) { $imgsize = pdf_getSizeForImage($realpath); $imgsizewidth = $imgsize['width'] + 20; @@ -832,39 +833,39 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlek // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); - if ($showaddress) { - /* - // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); - - // Show sender - $posy=42; - $posx=$this->marge_gauche; - if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) $posx=$this->page_largeur-$this->marge_droite-80; - $hautcadre=40; - - // Show sender frame - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('','', $default_font_size - 2); - $pdf->SetXY($posx,$posy-5); - $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, 'L'); - $pdf->SetXY($posx,$posy); - $pdf->SetFillColor(230,230,230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); - $pdf->SetTextColor(0,0,60); + //if ($showaddress) { + /* + // Sender properties + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + + // Show sender + $posy=42; + $posx=$this->marge_gauche; + if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) $posx=$this->page_largeur-$this->marge_droite-80; + $hautcadre=40; + + // Show sender frame + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posx,$posy-5); + $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, 'L'); + $pdf->SetXY($posx,$posy); + $pdf->SetFillColor(230,230,230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0,0,60); - // Show sender name - $pdf->SetXY($posx+2,$posy+3); - $pdf->SetFont('','B', $default_font_size); - $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); - - // Show sender information - $pdf->SetXY($posx+2,$posy); - $pdf->SetFont('','', $default_font_size - 1); - $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); - */ - } + // Show sender name + $pdf->SetXY($posx+2,$posy+3); + $pdf->SetFont('','B', $default_font_size); + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy=$pdf->getY(); + + // Show sender information + $pdf->SetXY($posx+2,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); + */ + //} $pdf->SetTextColor(0, 0, 0); diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index a20c933500a73..705f32894e505 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -5,7 +5,7 @@ * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2023 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -647,7 +647,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '') $soc->fetch($contact['socid']); $contact['socname'] = $soc->name; } - $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); + $contact['fullname'] = is_object($objectdetail) ? $objectdetail->getFullName($outputlangs, 1) : null; $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 0397dd86f0fce..03d5134db0e11 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -10,7 +10,7 @@ * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2019 Pierre Ardoin * Copyright (C) 2021-2024 Anthony Berton - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Nick Fragoulis * Copyright (C) 2024 Alexandre Spangaro * @@ -775,7 +775,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pagecount = $pdf->setSourceFile($termsofsale); for ($i = 1; $i <= $pagecount; $i++) { $tplIdx = $pdf->importPage($i); - if ($tplIdx!==false) { + if ($tplIdx !== false) { $s = $pdf->getTemplatesize($tplIdx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); $pdf->useTemplate($tplIdx); @@ -816,6 +816,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // If PDF is selected and file is not empty if (count($filetomerge->lines) > 0) { foreach ($filetomerge->lines as $linefile) { + $filetomerge_dir = null; if (!empty($linefile->id) && !empty($linefile->file_name)) { if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) { if (isModEnabled("product")) { @@ -831,7 +832,11 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } - dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, LOG_DEBUG); + dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, $filetomerge_dir === null ? LOG_ERR : LOG_DEBUG); + if ($filetomerge_dir === null) { + // Skip loop + continue; + } $infile = $filetomerge_dir.'/'.$linefile->file_name; if (file_exists($infile) && is_readable($infile)) { @@ -1447,7 +1452,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -1466,10 +1471,10 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ if (getDolGlobalString('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')) { $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height); - if (empty($hidetop)) { - //$pdf->SetXY($this->posxpicture-1, $tab_top+1); - //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C'); - } + //if (empty($hidetop)) { + //$pdf->SetXY($this->posxpicture-1, $tab_top+1); + //$pdf->MultiCell($this->posxtva-$this->posxpicture-1,2, $outputlangs->transnoentities("Photo"),'','C'); + //} } if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 6121fc0bff59d..4170db78e4be9 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -9,7 +9,7 @@ * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2021-2024 Anthony Berton * Copyright (C) 2018-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Nick Fragoulis * Copyright (C) 2024 Alexandre Spangaro * @@ -359,7 +359,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); if (!$hidetop && getDolGlobalInt('MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) { // TODO : make this hidden conf the default behavior for each PDF when each PDF managed this new Display - $tab_top_newpage+= $this->tabTitleHeight; + $tab_top_newpage += $this->tabTitleHeight; } $nexY = $tab_top; @@ -611,6 +611,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $pdf->setPageOrientation('', 0, $heightforfooter + $heightforfreetext); // The only function to edit the bottom margin of current page to set it. + // @phan-suppress-next-line PhanTypeMismatchProperty if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + $imageTopMargin, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually @@ -804,7 +805,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Add last page for document footer if there are not enough size left $afterPosData = $this->getMaxAfterColsLinePositionsData(); - if ($afterPosData['y'] > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot) ) { + if ($afterPosData['y'] > $this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)) { $pdf->AddPage(); if (!empty($tplidx)) { $pdf->useTemplate($tplidx); @@ -815,7 +816,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Draw table frames and columns borders $drawTabNumbPage = $pdf->getNumPages(); - for ($i=$pageposbeforeprintlines; $i<=$drawTabNumbPage; $i++) { + for ($i = $pageposbeforeprintlines; $i <= $drawTabNumbPage; $i++) { $pdf->setPage($i); // reset page orientation each loop to override it if it was changed $pdf->setPageOrientation('', 0, 0); // The only function to edit the bottom margin of current page to set it. @@ -830,7 +831,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $drawTabTop = $tab_top; } elseif (!$drawTabHideTop) { if (getDolGlobalInt('MAIN_PDF_ENABLE_COL_HEAD_TITLE_REPEAT')) { - $drawTabTop-= $this->tabTitleHeight; + $drawTabTop -= $this->tabTitleHeight; } else { $drawTabHideTop = 1; } @@ -839,7 +840,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // last page need to include document footer if ($i == $pdf->getNumPages()) { // remove document footer height to tab bottom position - $drawTabBottom-= $heightforsignature + $heightforfreetext + $heightforinfotot; + $drawTabBottom -= $heightforsignature + $heightforfreetext + $heightforinfotot; } $drawTabHeight = $drawTabBottom - $drawTabTop; @@ -895,7 +896,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pagecount = $pdf->setSourceFile($termsofsale); for ($i = 1; $i <= $pagecount; $i++) { $tplIdx = $pdf->importPage($i); - if ($tplIdx!==false) { + if ($tplIdx !== false) { $s = $pdf->getTemplatesize($tplIdx); $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); $pdf->useTemplate($tplIdx); @@ -937,6 +938,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if (count($filetomerge->lines) > 0) { foreach ($filetomerge->lines as $linefile) { if (!empty($linefile->id) && !empty($linefile->file_name)) { + $filetomerge_dir = null; if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) { if (isModEnabled("product")) { $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir($product->id, 2, 0, 0, $product, 'product').$product->id."/photos"; @@ -951,7 +953,11 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } - dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, LOG_DEBUG); + dol_syslog(get_class($this).':: upload_dir='.$filetomerge_dir, $filetomerge_dir === null ? LOG_ERR : LOG_DEBUG); + if ($filetomerge_dir === null) { + // Skip loop + continue; + } $infile = $filetomerge_dir.'/'.$linefile->file_name; if (file_exists($infile) && is_readable($infile)) { @@ -1259,11 +1265,11 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan // Total HT $pdf->SetFillColor(255, 255, 255); - $pdf->SetXY($col1x, $tab2_top+ $tab2_hl * $index); + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1); $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht); - $pdf->SetXY($col2x, $tab2_top+ $tab2_hl * $index); + $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1); // Show VAT by rates and total @@ -1377,12 +1383,12 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan foreach ($localtax_rate as $tvakey => $tvaval) { if ($tvakey != 0) { // On affiche pas taux 0 - //$this->atleastoneratenotnull++; + //$this->atleastoneratenotnull++; - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl = ''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; @@ -1412,12 +1418,12 @@ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlan foreach ($localtax_rate as $tvakey => $tvaval) { // retrieve global local tax if ($tvakey != 0) { // On affiche pas taux 0 - //$this->atleastoneratenotnull++; + //$this->atleastoneratenotnull++; - $index++; - $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); + $index++; + $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $tvacompl = ''; + $tvacompl = ''; if (preg_match('/\*/', $tvakey)) { $tvakey = str_replace('*', '', $tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; @@ -1555,7 +1561,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { - $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); + $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, $this->corner_radius, '1001', 'F', array(), explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index f21eb694c9e7c..b4643a0ab69f4 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2014 Marcos García - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * * 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 @@ -38,21 +38,68 @@ */ abstract class ModelePDFPropales extends CommonDocGenerator { + /** + * @var float + */ public $posxpicture; + /** + * @var float + */ public $posxtva; + /** + * @var float + */ public $posxup; + /** + * @var float + */ public $posxqty; + /** + * @var float + */ public $posxunit; + /** + * @var float + */ public $posxdesc; + /** + * @var float + */ public $posxdiscount; + /** + * @var float + */ public $postotalht; + /** + * @var array + */ public $tva; + /** + * @var array + */ public $tva_array; + /** + * Local tax rates Array[tax_type][tax_rate] + * + * @var array> + */ public $localtax1; + + /** + * Local tax rates Array[tax_type][tax_rate] + * + * @var array> + */ public $localtax2; + /** + * @var int<0,1> + */ public $atleastonediscount = 0; + /** + * @var int<0,1> + */ public $atleastoneratenotnull = 0; diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 3062ff64178ab..35d4e0fe107e7 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -1,7 +1,7 @@ * Copyright (C) 2023-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Nick Fragoulis * * This program is free software; you can redistribute it and/or modify @@ -1029,7 +1029,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) if (empty($arrayidcontact)) { $arrayidcontact = $object->origin_object->getIdContact('internal', 'SHIPPING'); } - if (count($arrayidcontact) > 0) { + if (is_array($arrayidcontact) && count($arrayidcontact) > 0) { $object->fetch_user(reset($arrayidcontact)); $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name")); $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));