From 74806473ab676362b1e85f6eb190f3df1b5891c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 5 Jun 2024 14:55:07 +0200 Subject: [PATCH] fix cti (#29842) * fix cti odt asset * comment unused code in template * phpdoc * fix unreachable code * fix unreachable code * fix not falsy --- dev/initdata/import-users.php | 3 +- .../core/class/commondocgenerator.class.php | 6 +- htdocs/core/menus/standard/auguria_menu.php | 16 +++- htdocs/core/menus/standard/eldy_menu.php | 21 +++-- .../doc/doc_generic_asset_odt.modules.php | 16 +--- .../bom/doc/doc_generic_bom_odt.modules.php | 8 -- .../doc/pdf_standard_myobject.modules.php | 90 +++++++++---------- 7 files changed, 82 insertions(+), 78 deletions(-) diff --git a/dev/initdata/import-users.php b/dev/initdata/import-users.php index a1a3b299e7b..eb4625c96b1 100755 --- a/dev/initdata/import-users.php +++ b/dev/initdata/import-users.php @@ -2,6 +2,7 @@ * Copyright (C) 2016 Juanjo Menent + * Copyright (C) 2024 Frédéric France * * 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 @@ -124,7 +125,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) $nboflines++; $object = new User($db); - $object->statut = 1; + $object->status = 1; $tmp=explode(' ', $fields[3], 2); $object->firstname = trim($tmp[0]); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 9f6e444cbf9..ccc1da0d98a 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -255,7 +255,7 @@ abstract class CommonDocGenerator global $conf, $extrafields; if ($member->photo) { - $logotouse = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $member, 'user').'/photos/'.$member->photo; + $logotouse = $conf->member->dir_output.'/'.get_exdir(0, 0, 0, 1, $member, 'user').'/photos/'.$member->photo; } else { $logotouse = DOL_DOCUMENT_ROOT.'/public/theme/common/nophoto.png'; } @@ -386,7 +386,7 @@ abstract class CommonDocGenerator 'company_vatnumber' => $object->tva_intra, 'company_customercode' => $object->code_client, 'company_suppliercode' => $object->code_fournisseur, - 'company_customeraccountancycode' => $object->code_compta, + 'company_customeraccountancycode' => $object->code_compta_client, 'company_supplieraccountancycode' => $object->code_compta_fournisseur, 'company_juridicalstatus' => $object->forme_juridique, 'company_outstanding_limit' => $object->outstanding_limit, @@ -903,7 +903,7 @@ abstract class CommonDocGenerator } // Add info from $object->xxx where xxx has been loaded by fetch_origin() of shipment - if (!empty($object->commande) && is_object($object->commande)) { + if (is_object($object->commande) && !empty($object->commande->ref)) { $array_shipment['order_ref'] = $object->commande->ref; $array_shipment['order_ref_customer'] = $object->commande->ref_customer; } diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index ebdef15b063..fcb5e02c775 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -3,6 +3,7 @@ * Copyright (C) 2009 Regis Houssin * Copyright (C) 2008-2013 Laurent Destailleur * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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,8 +35,19 @@ class MenuManager */ public $db; - public $type_user; // Put 0 for internal users, 1 for external users - public $atarget = ""; // To store default target to use onto links + /** + * @var int Put 0 for internal users, 1 for external users + */ + public $type_user; + + /** + * @var string To store default target to use onto links + */ + public $atarget = ""; + + /** + * @var string Menu name + */ public $name = "auguria"; /** diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 2d0bd731194..56094843f25 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2007-2009 Regis Houssin * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * 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 @@ -33,8 +34,19 @@ class MenuManager */ public $db; - public $type_user; // Put 0 for internal users, 1 for external users - public $atarget = ""; // To store default target to use onto links + /** + * @var int Put 0 for internal users, 1 for external users + */ + public $type_user; + + /** + * @var string To store default target to use onto links + */ + public $atarget = ""; + + /** + * @var string Menu name + */ public $name = "eldy"; /** @@ -118,9 +130,6 @@ class MenuManager $menuArbo = new Menubase($this->db, 'eldy'); $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'eldy', $tabMenu); $this->tabMenu = $tabMenu; - //var_dump($tabMenu); - - //if ($forcemainmenu == 'all') { var_dump($this->tabMenu); exit; } } @@ -136,8 +145,6 @@ class MenuManager { global $conf, $langs, $user; - //var_dump($this->tabMenu); - require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; if ($this->type_user == 1) { diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index 0b4b2785638..3d767b59571 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -332,10 +332,10 @@ class doc_generic_asset_odt extends ModelePDFAsset $odfHandler = new Odf( $srctemplatepath, array( - 'PATH_TO_TMP' => $conf->asset->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. - 'DELIMITER_LEFT' => '{', - 'DELIMITER_RIGHT' => '}' + 'PATH_TO_TMP' => $conf->asset->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' ) ); } catch (Exception $e) { @@ -346,9 +346,6 @@ class doc_generic_asset_odt extends ModelePDFAsset // After construction $odfHandler->contentXml contains content and // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN lines --]*[!-- END lines --] - //print html_entity_decode($odfHandler->__toString()); - //print exit; - // Make substitutions into odt of freetext try { @@ -403,9 +400,6 @@ class doc_generic_asset_odt extends ModelePDFAsset // We may arrive here if tags for lines not present into template $foundtagforlines = 0; dol_syslog($e->getMessage(), LOG_INFO); - } catch (OdfException $e) { - $foundtagforlines = 0; - dol_syslog($e->getMessage(), LOG_INFO); } if ($foundtagforlines) { $linenumber = 0; @@ -419,8 +413,6 @@ class doc_generic_asset_odt extends ModelePDFAsset foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 4670d883838..9233a93f151 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -347,9 +347,6 @@ class doc_generic_bom_odt extends ModelePDFBom // After construction $odfHandler->contentXml contains content and // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by // [!-- BEGIN lines --]*[!-- END lines --] - //print html_entity_decode($odfHandler->__toString()); - //print exit; - // Make substitutions into odt of freetext try { @@ -402,9 +399,6 @@ class doc_generic_bom_odt extends ModelePDFBom // We may arrive here if tags for lines not present into template $foundtagforlines = 0; dol_syslog($e->getMessage(), LOG_INFO); - } catch (OdfException $e) { - $foundtagforlines = 0; - dol_syslog($e->getMessage(), LOG_INFO); } if ($foundtagforlines) { $linenumber = 0; @@ -429,8 +423,6 @@ class doc_generic_bom_odt extends ModelePDFBom foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 57d42e71a8c..e9379d8a348 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -8,7 +8,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify @@ -523,10 +523,10 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize = array(); - if (!empty($realpatharray[$i])) { - $imglinesize = pdf_getSizeForImage($realpatharray[$i]); - } + // $imglinesize = array(); + // if (!empty($realpatharray[$i])) { + // $imglinesize = pdf_getSizeForImage($realpatharray[$i]); + // } $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. @@ -536,31 +536,31 @@ class pdf_standard_myobject extends ModelePDFMyObject $posYAfterImage = 0; $posYAfterDescription = 0; - if ($this->getColumnStatus('photo')) { - // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page - $pdf->AddPage('', '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - $pdf->setPage($pageposbefore + 1); + // if ($this->getColumnStatus('photo')) { + // // We start with Photo of product line + // if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page + // $pdf->AddPage('', '', true); + // if (!empty($tplidx)) { + // $pdf->useTemplate($tplidx); + // } + // $pdf->setPage($pageposbefore + 1); - $curY = $tab_top_newpage; + // $curY = $tab_top_newpage; - // Allows data in the first page if description is long enough to break in multiples pages - if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) { - $showpricebeforepagebreak = 1; - } else { - $showpricebeforepagebreak = 0; - } - } + // // Allows data in the first page if description is long enough to break in multiples pages + // if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) { + // $showpricebeforepagebreak = 1; + // } else { + // $showpricebeforepagebreak = 0; + // } + // } - if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { - $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi - // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage = $curY + $imglinesize['height']; - } - } + // if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { + // $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + // // $pdf->Image does not increase value return by getY, so we save it manually + // $posYAfterImage = $curY + $imglinesize['height']; + // } + // } // Description of product line if ($this->getColumnStatus('desc')) { @@ -578,7 +578,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); - //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page $pdf->AddPage('', '', true); @@ -1241,24 +1241,24 @@ class pdf_standard_myobject extends ModelePDFMyObject ); // PHOTO - $rank = $rank + 10; - $this->cols['photo'] = array( - 'rank' => $rank, - 'width' => (!getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')), // in mm - 'status' => false, - 'title' => array( - 'textkey' => 'Photo', - 'label' => ' ' - ), - 'content' => array( - 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - 'border-left' => false, // remove left line separator - ); + // $rank = $rank + 10; + // $this->cols['photo'] = array( + // 'rank' => $rank, + // 'width' => (!getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')), // in mm + // 'status' => false, + // 'title' => array( + // 'textkey' => 'Photo', + // 'label' => ' ' + // ), + // 'content' => array( + // 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + // ), + // 'border-left' => false, // remove left line separator + // ); - if (getDolGlobalInt('MAIN_GENERATE_INVOICES_WITH_PICTURE') && !empty($this->atleastonephoto)) { - $this->cols['photo']['status'] = true; - } + // if (getDolGlobalInt('MAIN_GENERATE_INVOICES_WITH_PICTURE') && !empty($this->atleastonephoto)) { + // $this->cols['photo']['status'] = true; + // } $rank = $rank + 10;