From 93ee9a7496d7e6a355d73d9c3623624c475c9a07 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 9 Dec 2022 12:56:35 +0100 Subject: [PATCH 01/14] Delete links when MO is deleted --- htdocs/mrp/class/mo.class.php | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index d186c6e533b..9aa1ef5bd8e 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -744,8 +744,31 @@ class Mo extends CommonObject */ public function delete(User $user, $notrigger = false) { - return $this->deleteCommon($user, $notrigger); - //return $this->deleteCommon($user, $notrigger, 1); + $this->db->begin(); + + $error = 0; + + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) { + $error++; + } + + if(!$error){ + $res = $this->deleteCommon($user, $notrigger); + if($res < 0){ + $error++; + } + } + + if(!$error){ + dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); + $this->db->commit(); + return $res; + } else { + $this->db->rollback(); + return -1; + } } /** From 488a434c8b031230e87980af561aa45321056ca0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 9 Dec 2022 11:58:27 +0000 Subject: [PATCH 02/14] Fixing style errors. --- htdocs/mrp/class/mo.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 9aa1ef5bd8e..5eeb387fc88 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -754,14 +754,14 @@ class Mo extends CommonObject $error++; } - if(!$error){ + if (!$error) { $res = $this->deleteCommon($user, $notrigger); - if($res < 0){ + if ($res < 0) { $error++; } } - if(!$error){ + if (!$error) { dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); $this->db->commit(); return $res; From 95f437b45c8103cb8a871e49939fd1cb81bbf238 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 12 Dec 2022 10:05:44 +0100 Subject: [PATCH 03/14] deleteObjectLinked() in deleteCommon() function --- htdocs/core/class/commonobject.class.php | 6 ++++++ htdocs/mrp/class/mo.class.php | 27 ++---------------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3e10ea82eaa..de19d651ba2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9472,6 +9472,12 @@ abstract class CommonObject } } + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) { + $error++; + } + // Commit or rollback if ($error) { $this->db->rollback(); diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 9aa1ef5bd8e..d186c6e533b 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -744,31 +744,8 @@ class Mo extends CommonObject */ public function delete(User $user, $notrigger = false) { - $this->db->begin(); - - $error = 0; - - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) { - $error++; - } - - if(!$error){ - $res = $this->deleteCommon($user, $notrigger); - if($res < 0){ - $error++; - } - } - - if(!$error){ - dol_syslog(get_class($this)."::delete ".$this->id." by ".$user->id, LOG_DEBUG); - $this->db->commit(); - return $res; - } else { - $this->db->rollback(); - return -1; - } + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); } /** From b906619ce1826babbaca1c8fd89914fb6349bb67 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 14 Dec 2022 10:31:11 +0100 Subject: [PATCH 04/14] FIX : methods declaration (backport fix 67b9a7dc07d708231d12b5e58800334d4a01ef98) --- htdocs/projet/class/taskstats.class.php | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index a5b088f01e8..16bd0afd480 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -193,4 +193,35 @@ class TaskStats extends Stats // var_dump($res);print '
'; return $res; } + + /** + * Return the Task amount by month for a year + * + * @param int $year Year to scan + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array with amount by month + */ + public function getAmountByMonth($year, $format = 0) + { + // Return an empty array at the moment because task has no amount + return array(); + } + + /** + * Return average of entity by month + * @param int $year year number + * @return int value + */ + protected function getAverageByMonth($year) + { + $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; + $sql .= " FROM ".$this->from; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + return $this->_getAverageByMonth($year, $sql); + } + } From d679a321551fc33cc610ef66770326088e157eb9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Dec 2022 09:36:25 +0000 Subject: [PATCH 05/14] Fixing style errors. --- htdocs/projet/class/taskstats.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index 16bd0afd480..39efd957bb5 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -223,5 +223,4 @@ class TaskStats extends Stats return $this->_getAverageByMonth($year, $sql); } - } From ed8900594190903165a2ef87fe9e810cd87961f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Prud=27homme?= Date: Wed, 14 Dec 2022 11:45:40 +0100 Subject: [PATCH 06/14] Fix #23019 Impossible to add task times to an existing draft invoice --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index debfb427111..6ff81ff3fbf 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1240,7 +1240,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print $langs->trans('InvoiceToUse'); print ''; print ''; - $form->selectInvoice('invoice', '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); + $form->selectInvoice($projectstatic->thirdparty->id, '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); print ''; print ''; /*print ''; From 4c43d81872e9e5d70d6f84e67c0d09e44fcdb402 Mon Sep 17 00:00:00 2001 From: hystepik Date: Wed, 14 Dec 2022 15:39:02 +0100 Subject: [PATCH 07/14] Fix #23064 : diplays total at end of inter list --- htdocs/fichinter/list.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 4ab4f0a90e3..9f887c36900 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -496,7 +496,7 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; -print ''."\n"; +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- @@ -844,6 +844,9 @@ while ($i < $imaxinloop) { if (!$i) { $totalarray['type'][$totalarray['nbfield']] = 'duration'; } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree'; + } $totalarray['val']['fd.duree'] += $obj->duree; } // Action column From 1a16e41ce3f49d17c807fa159842ad645fd8af3d Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 14 Dec 2022 16:04:35 +0100 Subject: [PATCH 08/14] FIX : Can't see all time spent by all user --- htdocs/projet/tasks/time.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index ef8ac6aa9df..3be8c731545 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -162,7 +162,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_date_update = ''; $search_task_ref = ''; $search_task_label = ''; - $search_user = 0; + $search_user = -1; $search_valuebilled = ''; $toselect = ''; $search_array_options = array(); @@ -1277,7 +1277,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (empty($search_user)) { $search_user = $user->id; } - $sql .= " AND t.fk_user = ".((int) $search_user); + if($search_user > 0) $sql .= " AND t.fk_user = ".((int) $search_user); } if ($search_note) { From 70b6b3d82d5053816d3f9b6be918588a52727a30 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 14 Dec 2022 15:21:42 +0000 Subject: [PATCH 09/14] Fixing style errors. --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 3be8c731545..67024ee8fa5 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1277,7 +1277,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (empty($search_user)) { $search_user = $user->id; } - if($search_user > 0) $sql .= " AND t.fk_user = ".((int) $search_user); + if ($search_user > 0) $sql .= " AND t.fk_user = ".((int) $search_user); } if ($search_note) { From eff01374b1163a8bf304f5c1a7a190bef44e5c43 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 15 Dec 2022 15:09:50 +0100 Subject: [PATCH 10/14] Change place of deleteobjectlinked in deletecommon function --- htdocs/core/class/commonobject.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index de19d651ba2..d7d41a545ef 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9455,6 +9455,12 @@ abstract class CommonObject } } + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) { + $error++; + } + if (!$error && !empty($this->isextrafieldmanaged)) { $result = $this->deleteExtraFields(); if ($result < 0) { @@ -9472,12 +9478,6 @@ abstract class CommonObject } } - // Delete linked object - $res = $this->deleteObjectLinked(); - if ($res < 0) { - $error++; - } - // Commit or rollback if ($error) { $this->db->rollback(); From 55b51b94f11c89c0d3f116ccce7b1b01a94171ab Mon Sep 17 00:00:00 2001 From: Braito Date: Tue, 20 Dec 2022 10:13:47 +0100 Subject: [PATCH 11/14] php 8 warning --- htdocs/projet/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index aabf14e8655..c4b5c29a149 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -489,11 +489,11 @@ llxHeader("", $title, $help_url); $titleboth = $langs->trans("LeadsOrProjects"); $titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default -if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { +if (!getDolGlobalInt('PROJECT_USE_OPPORTUNITIES')) { $titleboth = $langs->trans("Projects"); $titlenew = $langs->trans("NewProject"); } -if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only +if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only $titleboth = $langs->trans("Leads"); $titlenew = $langs->trans("NewLead"); } From ec32d284eb0acb59ff9bc720f6170934579006d8 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 20 Dec 2022 11:31:44 +0100 Subject: [PATCH 12/14] FIX : Product list in setup.php in new Module --- htdocs/modulebuilder/template/admin/setup.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 1c46028b142..9ee07b3a1fd 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -55,6 +55,8 @@ global $langs, $user; // Libraries require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/mymodule.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + //require_once "../class/myclass.class.php"; // Translations From 2f64eaff0514d8d3b1506fdbf26c485f000cfeb1 Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 20 Dec 2022 12:25:20 +0100 Subject: [PATCH 13/14] FIX : CI --- htdocs/modulebuilder/template/admin/setup.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 9ee07b3a1fd..7bf97081341 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -57,6 +57,7 @@ require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/mymodule.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + //require_once "../class/myclass.class.php"; // Translations From 1681674cdf7d0b14f4986630bb8b3bc58937fd27 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Dec 2022 20:45:11 +0100 Subject: [PATCH 14/14] Update card.php --- htdocs/projet/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index c4b5c29a149..7fe1f8f77e0 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -493,7 +493,7 @@ if (!getDolGlobalInt('PROJECT_USE_OPPORTUNITIES')) { $titleboth = $langs->trans("Projects"); $titlenew = $langs->trans("NewProject"); } -if (isset($conf->global->PROJECT_USE_OPPORTUNITIES) && $conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only +if (getDolGlobalInt('PROJECT_USE_OPPORTUNITIES') == 2) { // 2 = leads only $titleboth = $langs->trans("Leads"); $titlenew = $langs->trans("NewLead"); }