From 54216fc00d59c91bf317b0c8d82425171af639f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Nov 2024 14:16:32 +0100 Subject: [PATCH 01/18] Fix phan --- htdocs/compta/resultat/projects.php | 15 +++++++++++++-- htdocs/core/class/commonobjectline.class.php | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/resultat/projects.php b/htdocs/compta/resultat/projects.php index 0fceb60fdfb..eb1fc5545ec 100644 --- a/htdocs/compta/resultat/projects.php +++ b/htdocs/compta/resultat/projects.php @@ -44,6 +44,13 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +/** + * @var Conf $conf + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ // Load translation files required by the page $langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy', 'loan')); @@ -175,6 +182,10 @@ $exportlink = ''; $total_ht = 0; $total_ttc = 0; +$builddate = ''; +$name = ''; +$period = ''; + // Affiche en-tete de rapport if ($modecompta == "CREANCES-DETTES") { $name = $langs->trans("ReportInOut").', '.$langs->trans("ByProjects"); @@ -328,7 +339,7 @@ if ($modecompta == 'BOOKKEEPING') { } else { echo $langs->trans("None"); } - $detailed_list_url = '?search_project_ref='.urlencode($search_project_ref); + //$detailed_list_url = '?search_project_ref='.urlencode($search_project_ref); $detailed_list_url .= empty($objp->project_name)? "!*": $objp->project_name; $detailed_list_url .= $search_date_url; echo ' ('.$langs->trans("DetailedListLowercase").")\n"; @@ -525,7 +536,7 @@ if ($modecompta == 'BOOKKEEPING') { } else { echo $langs->trans("None"); } - $detailed_list_url = '?search_project='.urlencode($search_project_ref); + //$detailed_list_url = '?search_project='.urlencode($search_project_ref); $detailed_list_url .= empty($objp->project_name)? "!*": $objp->project_name; $detailed_list_url .= $search_date_url; echo ' ('.$langs->trans("DetailedListLowercase").")\n"; diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 39922f4f1a9..5878002cc9d 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -343,9 +343,10 @@ abstract class CommonObjectLine extends CommonObject { $parent_element_properties = getElementProperties($this->parent_element); $parent_classname = $parent_element_properties['classname']; + $parent_element = new $parent_classname($this->db); $parentattribute = $this->fk_parent_attribute; - if ($parentattribute) { + if ($parentattribute && method_exists($parent_element, 'fetch')) { $parent_element->fetch($this->$parentattribute); } From d980889f8a223156c5cbf1252423967f98e6404b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Nov 2024 14:22:06 +0100 Subject: [PATCH 02/18] Doc comment --- htdocs/core/class/commonobjectline.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 5878002cc9d..a44d2bd2c12 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -344,6 +344,7 @@ abstract class CommonObjectLine extends CommonObject $parent_element_properties = getElementProperties($this->parent_element); $parent_classname = $parent_element_properties['classname']; + // TODO Avoid a fetch inside a getNomUrl $parent_element = new $parent_classname($this->db); $parentattribute = $this->fk_parent_attribute; if ($parentattribute && method_exists($parent_element, 'fetch')) { From 91fdfc7bf0d387a6bbe77429acac3ad5e6f34578 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Nov 2024 14:25:49 +0100 Subject: [PATCH 03/18] Fix phan --- htdocs/compta/resultat/projects.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/projects.php b/htdocs/compta/resultat/projects.php index eb1fc5545ec..cd1086a0fc1 100644 --- a/htdocs/compta/resultat/projects.php +++ b/htdocs/compta/resultat/projects.php @@ -288,6 +288,7 @@ if ($modecompta == 'BOOKKEEPING') { */ print ''.$langs->trans("CustomersInvoices").''; + $sql = ''; if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT p.rowid as rowid, p.ref as project_name, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -339,7 +340,8 @@ if ($modecompta == 'BOOKKEEPING') { } else { echo $langs->trans("None"); } - //$detailed_list_url = '?search_project_ref='.urlencode($search_project_ref); + $detailed_list_url = ''; + //$detailed_list_url .= '?search_project_ref='.urlencode($search_project_ref); $detailed_list_url .= empty($objp->project_name)? "!*": $objp->project_name; $detailed_list_url .= $search_date_url; echo ' ('.$langs->trans("DetailedListLowercase").")\n"; @@ -536,7 +538,8 @@ if ($modecompta == 'BOOKKEEPING') { } else { echo $langs->trans("None"); } - //$detailed_list_url = '?search_project='.urlencode($search_project_ref); + $detailed_list_url = ''; + //$detailed_list_url .= '?search_project='.urlencode($search_project_ref); $detailed_list_url .= empty($objp->project_name)? "!*": $objp->project_name; $detailed_list_url .= $search_date_url; echo ' ('.$langs->trans("DetailedListLowercase").")\n"; From b25c75c87de0c4cb97ebfdeb116cf6b28c982b82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Nov 2024 14:52:59 +0100 Subject: [PATCH 04/18] Clean code --- htdocs/core/class/commonobjectline.class.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index a44d2bd2c12..ef3b9359a70 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -341,16 +341,23 @@ abstract class CommonObjectLine extends CommonObject */ public function getNomUrl($withpicto = 0) { + $parentattribute = $this->fk_parent_attribute; + + /* + if ($parentattribute) { + return 'Parent #'.$this->$parentattribute.' - Line #'.$this->id; + } else { + return 'Line #'.$this->id; + } + */ + $parent_element_properties = getElementProperties($this->parent_element); $parent_classname = $parent_element_properties['classname']; - - // TODO Avoid a fetch inside a getNomUrl $parent_element = new $parent_classname($this->db); - $parentattribute = $this->fk_parent_attribute; if ($parentattribute && method_exists($parent_element, 'fetch')) { - $parent_element->fetch($this->$parentattribute); + $parent_element->fetch($this->$parentattribute); /* @phpstan-ignore-line */ } - return $parent_element->getNomUrl($withpicto).' - Line #'.$this->id; + return $parent_element->getNomUrl($withpicto).' - Line #'.$this->id; /* @phpstan-ignore-line */ } } From fc0496c48bd6f7cad2ecd25749914fa915bda2d9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Nov 2024 15:06:17 +0100 Subject: [PATCH 05/18] Fix phan --- htdocs/core/class/commonobjectline.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index ef3b9359a70..9be90a220c9 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -355,9 +355,11 @@ abstract class CommonObjectLine extends CommonObject $parent_classname = $parent_element_properties['classname']; $parent_element = new $parent_classname($this->db); if ($parentattribute && method_exists($parent_element, 'fetch')) { + // @phan-suppress-next-line PhanPluginUnknownObjectMethodCall $parent_element->fetch($this->$parentattribute); /* @phpstan-ignore-line */ } + // @phan-suppress-next-line PhanPluginUnknownObjectMethodCall return $parent_element->getNomUrl($withpicto).' - Line #'.$this->id; /* @phpstan-ignore-line */ } } From 1558112e554f91f9ba21bb9da5161ec401893fd6 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 5 Nov 2024 15:10:27 +0100 Subject: [PATCH 06/18] Fix phan (#31690) * Fix phan * Fix phan * Fix phan * Fix copyright * Fix phan * Fix phan --------- Co-authored-by: Laurent Destailleur --- htdocs/compta/resultat/projects.php | 70 ++++++++++++++++++----------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/htdocs/compta/resultat/projects.php b/htdocs/compta/resultat/projects.php index cd1086a0fc1..d001c8610bb 100644 --- a/htdocs/compta/resultat/projects.php +++ b/htdocs/compta/resultat/projects.php @@ -1,16 +1,16 @@ - * Copyright (C) 2004-2017 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012 Cédric Salvador - * Copyright (C) 2012-2014 Raphaël Dourseanud - * Copyright (C) 2014-2106 Ferran Marcet - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2018 Frédéric France - * Copyright (C) 2020 Maxime DEMAREST - * Copyright (C) 2021 Alexandre Spangaro - * Copyright (C) 2024 Yoan Mollard +/* Copyright (C) 2002-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud + * Copyright (C) 2014-2016 Ferran Marcet + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2018 Frédéric France + * Copyright (C) 2020 Maxime DEMAREST + * Copyright (C) 2021-2024 Alexandre Spangaro + * Copyright (C) 2024 Yoan Mollard * * 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 @@ -51,6 +51,7 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; * @var Translate $langs * @var User $user */ + // Load translation files required by the page $langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy', 'loan')); @@ -62,6 +63,8 @@ $date_endday = GETPOSTINT('date_endday'); $date_endyear = GETPOSTINT('date_endyear'); $showaccountdetail = GETPOST('showaccountdetail', 'aZ09') ? GETPOST('showaccountdetail', 'aZ09') : 'yes'; +$search_project_ref = GETPOST('search_project_ref', 'alpha'); + $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -146,7 +149,8 @@ $nbofyear = ($year_end - $year_start) + 1; // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING') $modecompta = getDolGlobalString('ACCOUNTING_MODE'); if (isModEnabled('accounting')) { - $modecompta = 'BOOKKEEPING'; + // $modecompta = 'BOOKKEEPING'; + $modecompta = 'CREANCES-DETTES'; } if (GETPOST("modecompta", 'alpha')) { $modecompta = GETPOST("modecompta", 'alpha'); @@ -182,11 +186,11 @@ $exportlink = ''; $total_ht = 0; $total_ttc = 0; -$builddate = ''; -$name = ''; -$period = ''; +$name = $langs->trans("ReportInOut").', '.$langs->trans("ByProjects"); +$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); +$builddate = dol_now(); -// Affiche en-tete de rapport +// Display report header if ($modecompta == "CREANCES-DETTES") { $name = $langs->trans("ReportInOut").', '.$langs->trans("ByProjects"); $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); @@ -211,10 +215,12 @@ if ($modecompta == "CREANCES-DETTES") { // Define $calcmode line $calcmode = ''; +/* if (isModEnabled('accounting')) { $calcmode .= ''; $calcmode .= '
'; } +*/ $calcmode .= '