From 3d179fb7d37b1e115f7c9f48bfa9cfae8c40c6a1 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 24 Apr 2018 09:17:03 +0200 Subject: [PATCH 01/34] FIX : Fetch function will fetch comments --- htdocs/projet/class/task.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 83de25b21ad..ab34ec1acb3 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -194,7 +194,7 @@ class Task extends CommonObject */ function fetch($id, $ref='', $loadparentdata=0) { - global $langs; + global $langs, $conf; $sql = "SELECT"; $sql.= " t.rowid,"; @@ -267,7 +267,11 @@ class Task extends CommonObject } // Retreive all extrafield data - $this->fetch_optionals(); + $this->fetch_optionals(); + + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) { + $this->fetchComments(); + } } $this->db->free($resql); From d875553648c1e41d9a2f2805f3994e77aee12b2e Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 22 May 2018 16:03:03 +0200 Subject: [PATCH 02/34] FIX : Remove fetchComments from project and task fetch function --- htdocs/projet/class/project.class.php | 8 +------- htdocs/projet/class/task.class.php | 4 ---- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8cbb45eae37..ef5844e4ab8 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -447,18 +447,12 @@ class Project extends CommonObject // Retreive all extrafield for thirdparty $this->fetch_optionals(); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) - { - $this->fetchComments(); - } - return 1; } $this->db->free($resql); - if ($num_rows) return 1; - else return 0; + return 0; } else { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 29cadb08ad6..c953ec58089 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -268,10 +268,6 @@ class Task extends CommonObject // Retreive all extrafield data $this->fetch_optionals(); - - if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK)) { - $this->fetchComments(); - } } $this->db->free($resql); From a455f60c42f41710536be2f23ff37c8e308798f3 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 22 May 2018 16:07:32 +0200 Subject: [PATCH 03/34] FIX : Add calls to fetchComments function --- htdocs/projet/card.php | 1 + htdocs/projet/comment.php | 1 + htdocs/projet/contact.php | 2 ++ htdocs/projet/document.php | 1 + htdocs/projet/element.php | 1 + htdocs/projet/ganttview.php | 1 + htdocs/projet/info.php | 1 + htdocs/projet/note.php | 1 + htdocs/projet/tasks.php | 1 + htdocs/projet/tasks/comment.php | 1 + htdocs/projet/tasks/contact.php | 2 ++ htdocs/projet/tasks/document.php | 2 ++ htdocs/projet/tasks/note.php | 2 ++ htdocs/projet/tasks/task.php | 2 ++ htdocs/projet/tasks/time.php | 2 ++ 15 files changed, 21 insertions(+) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index bd8709affaa..762fc1a7e06 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -64,6 +64,7 @@ if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $id=$object->id; } } diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index a51d4872c80..236233d983c 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -67,6 +67,7 @@ if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); // If we create project, ref may be defined into POST but record does not yet exists into database if ($ret > 0) { $object->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $id=$object->id; } } diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index f162aa9db40..5d9e8bcc056 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -43,6 +43,7 @@ $mine = GETPOST('mode')=='mine' ? 1 : 0; $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=0; @@ -140,6 +141,7 @@ $userstatic=new User($db); if ($id > 0 || ! empty($ref)) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); $userWrite = $object->restrictedProjectArea($user,'write'); diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index fbf9574bd75..b6c69e12622 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -48,6 +48,7 @@ $result=restrictedArea($user,'projet',$id,'projet&project'); $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); if ($id > 0 || ! empty($ref)) { $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index dd19ceeb263..e85db9b9252 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -97,6 +97,7 @@ $projectid=$id; // For backward compatibility $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=$object->socid; diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 0c1e86c8ab5..473aa18b744 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -42,6 +42,7 @@ $mine = ($mode == 'mine' ? 1 : 0); $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=0; diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 68f4b8b4cbb..8024977f2fa 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -97,6 +97,7 @@ if ($id > 0 || ! empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $object->info($object->id); } diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 88217fbfb1c..bb5a769640f 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -38,6 +38,7 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0; $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); // Security check $socid=0; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 9bbd7891ee7..49d52a522d6 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -51,6 +51,7 @@ $extrafields_project = new ExtraFields($db); $extrafields_task = new ExtraFields($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once +if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); if ($id > 0 || ! empty($ref)) { diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 3bf96d7d081..6eb441eb28c 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -105,6 +105,7 @@ if ($id > 0 || ! empty($ref)) $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index fad5466cb7f..747bf36391c 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -173,9 +173,11 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id, $ref) > 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $id = $object->id; // So when doing a search from ref, id is also set correctly. $result=$projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 1cb5acb73b5..92af4a35c65 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -92,7 +92,9 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) { $projectstatic->fetch_thirdparty(); diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index f915aaf836a..dd5c14d3c1f 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -50,7 +50,9 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 2f87d411c5f..12329c2ed6b 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -211,8 +211,10 @@ if ($id > 0 || ! empty($ref)) if ($object->fetch($id,$ref) > 0) { $res=$object->fetch_optionals($object->id,$extralabels); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $result=$projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $object->project = clone $projectstatic; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 2da534e53a0..4f8755ddb6d 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -292,7 +292,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } elseif ($object->fetch($id, $ref) >= 0) { + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) $object->fetchComments(); $result=$projectstatic->fetch($object->fk_project); + if(! empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) $projectstatic->fetchComments(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); From 4e16f64af0a95f0968cbdb37a8f6ec79fc18bdb7 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 9 Aug 2018 12:13:06 +0200 Subject: [PATCH 04/34] Fix project::delete to delete children tasks before parent tasks --- htdocs/projet/class/project.class.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 5dce267d965..6710aa98ffc 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -633,9 +633,7 @@ class Project extends CommonObject $this->getLinesArray($user); // Delete tasks - foreach($this->lines as &$task) { - $task->delete($user); - } + $this->deleteTasks($this->lines); // Delete project if (! $error) @@ -711,6 +709,25 @@ class Project extends CommonObject return -1; } } + + /** + * Reoder tasks to delete children tasks first + * + * @param array $arr Array of tasks + */ + function deleteTasks($arr) + { + global $user; + + $arrParents = array(); + foreach($arr as $task) + { + if($task->hasChildren() < 0) $task->delete($user); + else $arrParents[] = $task; + } + + if (count($arrParents)) $this->deleteTasks($arrParents); + } /** * Validate a project From 3d84adbd7635e772d9d38da435a6e00c9c37d6cd Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 9 Aug 2018 12:21:48 +0200 Subject: [PATCH 05/34] fix recurcivity --- htdocs/projet/class/project.class.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 6710aa98ffc..2292487898d 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -719,14 +719,12 @@ class Project extends CommonObject { global $user; - $arrParents = array(); foreach($arr as $task) { - if($task->hasChildren() < 0) $task->delete($user); - else $arrParents[] = $task; + if($task->hasChildren() <= 0) $task->delete($user); } - - if (count($arrParents)) $this->deleteTasks($arrParents); + $this->getLinesArray($user); + if (count($this->lines)) $this->deleteTasks($this->lines); } /** From ba6f7d4b0a1daba4ab391e76fc39d30eefe84699 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 14 Aug 2018 09:32:43 +0200 Subject: [PATCH 06/34] fix infinite loop --- htdocs/projet/class/project.class.php | 32 ++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 2292487898d..4413e9b3361 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -633,7 +633,8 @@ class Project extends CommonObject $this->getLinesArray($user); // Delete tasks - $this->deleteTasks($this->lines); + $ret = $this->deleteTasks($user); + if ($ret < 0) $error++; // Delete project if (! $error) @@ -715,16 +716,31 @@ class Project extends CommonObject * * @param array $arr Array of tasks */ - function deleteTasks($arr) + function deleteTasks($user) { - global $user; - - foreach($arr as $task) - { - if($task->hasChildren() <= 0) $task->delete($user); + $countTasks = count($this->lines); + $deleted = false; + if ($countTasks){ + foreach($this->lines as $task) + { + if($task->hasChildren() <= 0) { + $deleted = true; + $ret = $task->delete($user); + if ($ret < 1) + { + $this->errors[] = $this->db->lasterror(); + return -1; + } + } + } } $this->getLinesArray($user); - if (count($this->lines)) $this->deleteTasks($this->lines); + if($deleted && count($this->lines) < $countTasks) + { + if (count($this->lines)) $this->deleteTasks($this->lines); + } + + return 1; } /** From fe6779c2239e4374e0bad0ae9e7dbb739b7e6a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric?= <35066297+c3do@users.noreply.github.com> Date: Thu, 16 Aug 2018 17:20:38 +0200 Subject: [PATCH 07/34] Erreur de syntaxe ( + au lieu de . ) --- htdocs/core/lib/payments.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 73f8e507caf..ffb0aba36ca 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -303,7 +303,7 @@ function htmlPrintOnlinePaymentFooter($fromcompany,$langs,$addformmessage=0,$suf print '

'."\n"; print $fromcompany->name.'
'; print $line1; - if (strlen($line1+$line2) > 50) print '
'; + if (strlen($line1.$line2) > 50) print '
'; else print ' - '; print $line2; print '
'."\n"; From 3523c2b3d2461fec5e223696b26e87a64e9b56fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Aug 2018 13:09:06 +0200 Subject: [PATCH 08/34] Update project.class.php --- htdocs/projet/class/project.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 4413e9b3361..ebc887ccbb6 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -712,21 +712,22 @@ class Project extends CommonObject } /** - * Reoder tasks to delete children tasks first + * Delete tasks with no children first, then task with children recursively * - * @param array $arr Array of tasks + * @param int <0 if KO, 1 if OK */ function deleteTasks($user) { $countTasks = count($this->lines); $deleted = false; - if ($countTasks){ + if ($countTasks) + { foreach($this->lines as $task) { - if($task->hasChildren() <= 0) { + if ($task->hasChildren() <= 0) { // If there is no children (or error to detect them) $deleted = true; $ret = $task->delete($user); - if ($ret < 1) + if ($ret <= 0) { $this->errors[] = $this->db->lasterror(); return -1; @@ -735,7 +736,7 @@ class Project extends CommonObject } } $this->getLinesArray($user); - if($deleted && count($this->lines) < $countTasks) + if ($deleted && count($this->lines) < $countTasks) { if (count($this->lines)) $this->deleteTasks($this->lines); } From 91bfa4be6cb9022f7474cb53cc8518feeff6c4f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Aug 2018 13:10:20 +0200 Subject: [PATCH 09/34] Update project.class.php --- htdocs/projet/class/project.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index ebc887ccbb6..59a8db62dab 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -714,14 +714,15 @@ class Project extends CommonObject /** * Delete tasks with no children first, then task with children recursively * - * @param int <0 if KO, 1 if OK + * @param User $user User + * @return int <0 if KO, 1 if OK */ function deleteTasks($user) { $countTasks = count($this->lines); $deleted = false; if ($countTasks) - { + { foreach($this->lines as $task) { if ($task->hasChildren() <= 0) { // If there is no children (or error to detect them) From 243cbbc11dd15d242fa4b9b2038cbc589c12d820 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Aug 2018 13:58:24 +0200 Subject: [PATCH 10/34] Fix missing trans --- htdocs/cron/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 238bd17d5c5..cc3b8e879ed 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","cron","bills")); +$langs->loadLangs(array("admin","cron","bills","members")); if (!$user->rights->cron->read) accessforbidden(); From 9dbb0eaab08216fee729629a1b078fec3f662479 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Aug 2018 14:01:03 +0200 Subject: [PATCH 11/34] Fix cron task label --- htdocs/core/modules/modAdherent.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 5fde53c9653..f5f63324063 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -349,12 +349,12 @@ class modAdherent extends DolibarrModules // Cronjobs $this->cronjobs = array( 0=>array( - 'label'=>'SendReminderForExpiredSubscription', + 'label'=>'SendReminderForExpiredSubscriptionTitle', 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', 'objectname'=>'Adherent', 'method'=>'sendReminderForExpiredSubscription', 'parameters'=>'10', - 'comment'=>'sendReminderForExpiredSubscription', + 'comment'=>'SendReminderForExpiredSubscription', 'frequency'=>1, 'unitfrequency'=> 3600 * 24, 'priority'=>50, From b86d54cab381f9c61aa1663273bdbbc2db7ae149 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Aug 2018 14:05:53 +0200 Subject: [PATCH 12/34] Trad --- htdocs/cron/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 6b052ca59d4..855620756a7 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT."/core/class/html.formcron.class.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('admin', 'cron')); +$langs->loadLangs(array('admin', 'cron', 'members')); if (!$user->rights->cron->create) accessforbidden(); From 3cfc47a732c4b4f6575f74c16487f7955a74e195 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Aug 2018 14:41:59 +0200 Subject: [PATCH 13/34] Fix urls in project module --- htdocs/projet/tasks/time.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 3844d8eeb50..905b8bbf4f1 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -71,7 +71,7 @@ $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield='t.task_date,t.task_datehour,t.rowid'; -if (! $sortorder) $sortorder='DESC'; +if (! $sortorder) $sortorder='DESC,DESC,DESC'; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context //$object = new TaskTime($db); @@ -158,7 +158,7 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) else { $object->timespent_note = $_POST["timespent_note"]; - $object->progress = GETPOST('progress', 'int'); + if (GETPOST('progress', 'int') > 0) $object->progress = GETPOST('progress', 'int'); // If progress is -1 (not defined), we do not change value $object->timespent_duration = $_POST["timespent_durationhour"]*60*60; // We store duration in seconds $object->timespent_duration+= $_POST["timespent_durationmin"]*60; // We store duration in seconds if (GETPOST("timehour") != '' && GETPOST("timehour") >= 0) // If hour was entered @@ -422,7 +422,16 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { if ($projectstatic->public || $userWrite > 0) { - $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + if (! empty($projectidforalltimes)) // We are on tab 'Time Spent' of project + { + $backtourl = $_SERVER['PHP_SELF'].'?projectid='.$projectstatic->id.($withproject?'&withproject=1':''); + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + } + else // We are on tab 'Time Spent' of task + { + $backtourl = $_SERVER['PHP_SELF'].'?id='.$object->id.($withproject?'&withproject=1':''); + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + } } else { @@ -600,7 +609,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Progress declared print ''; - print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); + print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress, 'progress', 0, 5, 0, 100, 1); print ''; print ''; @@ -785,7 +794,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Progress declared print ''; - print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); + print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress, 'progress', 0, 5, 0, 100, 1); print ''; print ''; From cd09052e80b6b36e2f12a00e64e388c4b25c0c50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Aug 2018 14:52:22 +0200 Subject: [PATCH 14/34] FIX badge on time spent on project and tasks --- htdocs/core/lib/project.lib.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index e11fd409a6e..db1aff3d444 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -104,9 +104,24 @@ function project_prepare_head($object) $head[$h][2] = 'tasks'; $h++; + $nbTimeSpent=0; + $sql = "SELECT t.rowid"; + //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; + //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt"; + $sql .= " WHERE t.fk_task = pt.rowid"; + $sql .= " AND pt.fk_projet =".$object->id; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $nbTimeSpent=1; + } + else dol_print_error($db); + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; $head[$h][1] = $langs->trans("TimeSpent"); - //if ($nbTasks > 0) $head[$h][1].= ' '.($nbTasks).''; + if ($nbTimeSpent > 0) $head[$h][1].= ' ...'; $head[$h][2] = 'timespent'; $h++; } @@ -165,9 +180,10 @@ function task_prepare_head($object) // Is there timespent ? $nbTimeSpent=0; $sql = "SELECT t.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; - $sql .= " AND t.fk_task =".$object->id; + //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; + //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " WHERE t.fk_task =".$object->id; $resql = $db->query($sql); if ($resql) { From c20d556265aa48ee9e8438c15ce8e0e2805dfe74 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Aug 2018 13:16:55 +0200 Subject: [PATCH 15/34] FIX Get templates in a forced language --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index ffe22b580e7..90700c6b016 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1082,7 +1082,7 @@ class FormMail extends Form $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned if ($active >= 0) $sql.=" AND active = ".$active; if ($label) $sql.=" AND label ='".$db->escape($label)."'"; - if (is_object($outputlangs)) $sql.= " AND (lang = '".$db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; + if (! ($id > 0) && is_object($outputlangs)) $sql.= " AND (lang = '".$db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; if ($id > 0) $sql.= " AND rowid=".$id; if ($id == -1) $sql.= " AND position=0"; if (is_object($outputlangs)) $sql.= $db->order("position,lang,label","ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' From c7a241a5dbf47178cc9c5bae423211277bdf052d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Aug 2018 13:16:55 +0200 Subject: [PATCH 16/34] FIX Get templates in a forced language Conflicts: htdocs/core/class/html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 2fd38d097c0..da4b1ecec97 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1003,7 +1003,7 @@ class FormMail extends Form $sql.= " AND entity IN (".getEntity('c_email_templates').")"; $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned if ($active >= 0) $sql.=" AND active = ".$active; - if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; + if (! ($id > 0) && is_object($outputlangs)) $sql.= " AND (lang = '".$db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; if ($id > 0) $sql.= " AND rowid=".$id; if ($id == -1) $sql.= " AND position=0"; $sql.= $db->order("position,lang,label","ASC"); From de2cdfc70f10d6483ff2f878b88e29929266d74b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Aug 2018 13:23:46 +0200 Subject: [PATCH 17/34] FIX Language selection lost if error during creation of email template --- htdocs/admin/mails_templates.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index c63ff44c32b..394742c7d2a 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2016 Juanjo Menent @@ -989,7 +989,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') print ''; if (! empty($conf->global->MAIN_MULTILANGS)) { - $selectedlang = $langs->defaultlang; + $selectedlang = GETPOSTISSET('langcode','aZ09')?GETPOST('langcode','aZ09'):$langs->defaultlang; if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]}; print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); } From b650f7ac17f3544b48c434f76b485ad46101da7c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Aug 2018 13:37:18 +0200 Subject: [PATCH 18/34] Fix tab --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 90700c6b016..fe3ef54552e 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -286,7 +286,7 @@ class FormMail extends Form $disablebademails=1; - // Define output language + // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels']; From 61ced8220b1f7fd24721a17cdac8ce414ba788eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Aug 2018 17:49:14 +0200 Subject: [PATCH 19/34] Fix sample doc --- htdocs/modulebuilder/template/class/myobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index e40b6b178e6..7b92e593d4b 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -65,6 +65,7 @@ class MyObject extends CommonObject * 'position' is the sort order of field. * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' * 'help' is a string visible as a tooltip on field * 'comment' is not used. You can store here any text of your choice. It is not used by application. * 'default' is a default value for creation (can still be replaced by the global setup of default values) From e2e09f8534c7011e590f8d5320aea8daa42763e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Aug 2018 17:56:16 +0200 Subject: [PATCH 20/34] Fix hookmanager var --- htdocs/modulebuilder/template/class/myobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index ac2347b723d..09aea4a56cc 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -285,7 +285,7 @@ class MyObject extends CommonObject */ function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) { - global $db, $conf, $langs, $hoomanager; + global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; From e6acacee4b86f0410aa8fe5f0ae91aa4f65b1fe1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Aug 2018 19:19:25 +0200 Subject: [PATCH 21/34] Fix cleandata method of modulebuilder template of AAPI --- .../template/class/api_mymodule.class.php | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index b4abf60861e..7de56ff726e 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -170,7 +170,7 @@ class MyModuleApi extends DolibarrApi $obj = $db->fetch_object($result); $myobject_static = new MyObject($db); if($myobject_static->fetch($obj->rowid)) { - $obj_ret[] = parent::_cleanObjectDatas($myobject_static); + $obj_ret[] = $this->_cleanObjectDatas($myobject_static); } $i++; } @@ -279,6 +279,27 @@ class MyModuleApi extends DolibarrApi } + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) + { + $object = parent::_cleanObjectDatas($object); + + /*unset($object->note); + unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder);*/ + + return $object; + } + /** * Validate fields before create or update object * From 8757392e6b3965aabab2d5e54fb9392084637704 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Aug 2018 19:24:00 +0200 Subject: [PATCH 22/34] FIX remove internal property isextrafieldmanaged from API returns --- htdocs/api/class/api.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 5918b1a5414..63f66295556 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -98,6 +98,7 @@ class DolibarrApi // Remove $db object property for object unset($object->db); + unset($object->isextrafieldmanaged); unset($object->ismultientitymanaged); unset($object->restrictiononfksoc); From 019ff534a06c739a548c5216c2f8165a8bc9964d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Aug 2018 19:46:08 +0200 Subject: [PATCH 23/34] FIX api template for list in module builder --- .../template/class/api_mymodule.class.php | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 7de56ff726e..87802d80ef2 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -116,27 +116,29 @@ class MyModuleApi extends DolibarrApi $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $restictonsocid = 0; // Set to 1 if there is a field socid in table of object + // If the internal user must only see his customers, force searching by him - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + if ($restictonsocid && ! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; - $sql = "SELECT s.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."myobject as s"; + $sql = "SELECT t.rowid"; + if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql.= " FROM ".MAIN_DB_PREFIX."myobject_mytable as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; - $sql.= " WHERE s.fk_stcomm = st.id"; + if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql.= " WHERE 1 = 1"; // Example of use $mode //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - $sql.= ' AND s.entity IN ('.getEntity('myobject').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND s.fk_soc = sc.fk_soc"; - if ($socid) $sql.= " AND s.fk_soc = ".$socid; - if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + $tmpobject = new MyObject($db); + if ($tmpobject->ismultientitymanaged) $sql.= ' AND t.entity IN ('.getEntity('myobject').')'; + if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ($restictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid; + if ($restictonsocid && $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter - if ($search_sale > 0) + if ($restictonsocid && $search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } From 781a55429a204d7e9429029d078bc07022961978 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Aug 2018 20:03:41 +0200 Subject: [PATCH 24/34] FIX API template to delete a record --- htdocs/modulebuilder/template/class/api_mymodule.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 87802d80ef2..5b77c477429 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -255,7 +255,7 @@ class MyModuleApi extends DolibarrApi */ function delete($id) { - if(! DolibarrApiAccess::$user->rights->myobject->supprimer) { + if(! DolibarrApiAccess::$user->rights->myobject->delete) { throw new RestException(401); } $result = $this->myobject->fetch($id); @@ -267,7 +267,7 @@ class MyModuleApi extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( !$this->myobject->delete($id)) + if( !$this->myobject->delete(DolibarrApiAccess::$user, 0)) { throw new RestException(500); } From 64427dafb65e24f8993aceeffbf453ea89ebbec0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Aug 2018 20:21:27 +0200 Subject: [PATCH 25/34] Fix back to page when canceling an edit in the module template --- htdocs/modulebuilder/template/myobject_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 137e394fe08..cfc79b2f232 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -122,7 +122,7 @@ if (empty($reshook)) $permissiontoadd = $user->rights->mymodule->write; $permissiontodelete = $user->rights->mymodule->delete; - if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id=__ID__'; + if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id='.($id > 0 ? $id : '__ID__'); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1); $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record From a82d86cec4e070f8d75f15636be699c187208f0a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Aug 2018 10:46:47 +0200 Subject: [PATCH 26/34] FIX warning for late template invoices to remove when suspended --- htdocs/compta/facture/fiche-rec.php | 2 +- htdocs/compta/facture/invoicetemplate_list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 6719e7091c8..fb70da42665 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1513,7 +1513,7 @@ else //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour')); if (! $object->isMaxNbGenReached()) { - if ($action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); + if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late")); } else { diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 13db00a02c2..b7b985dd73c 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -607,7 +607,7 @@ if ($resql) print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').''); if (! $invoicerectmp->isMaxNbGenReached()) { - if ($objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); + if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); } else { From 07407f46a7ff33bc588548a23c3f6443aa76e727 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Aug 2018 15:02:19 +0200 Subject: [PATCH 27/34] Remove colspan --- htdocs/core/class/html.form.class.php | 30 +++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6fe2dffd3d3..67b1e4c1bf0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3689,7 +3689,7 @@ class Form // Now add questions $more.=''."\n"; - $more.=''."\n"; + if (! empty($formquestion['text'])) $more.=''."\n"; foreach ($formquestion as $key => $input) { if (is_array($input) && ! empty($input)) @@ -3700,16 +3700,16 @@ class Form if ($input['type'] == 'text') { - $more.=''."\n"; + $more.=''."\n"; } else if ($input['type'] == 'password') { - $more.=''."\n"; + $more.=''."\n"; } else if ($input['type'] == 'select') { $more.=''."\n"; } @@ -3722,7 +3722,6 @@ class Form if (is_bool($input['value']) && $input['value']) $more.=' checked'; if (isset($input['disabled'])) $more.=' disabled'; $more.=' />'; - $more.=''; $more.=''."\n"; } else if ($input['type'] == 'radio') @@ -3733,10 +3732,9 @@ class Form $more.=''; if ($i==0) $more.=''; else $more.=''; - $more.=''."\n"; $formquestion[] = array('name'=>$input['name'].'day'); @@ -3757,14 +3755,14 @@ class Form else if ($input['type'] == 'other') { $more.=''."\n"; } else if ($input['type'] == 'onecolumn') { - $more.=''."\n"; } @@ -3818,14 +3816,14 @@ class Form $( "#'.$dialogconfirm.'" ).dialog( { autoOpen: '.($autoOpen ? "true" : "false").','; - if ($newselectedchoice == 'no') - { - $formconfirm.=' + if ($newselectedchoice == 'no') + { + $formconfirm.=' open: function() { $(this).parent().find("button.ui-button:eq(2)").focus(); },'; - } - $formconfirm.=' + } + $formconfirm.=' resizable: false, height: "'.$height.'", width: "'.$width.'", From d2a7c9976bdda791ae9a7c5fa5c53ec5c4183e79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Aug 2018 15:05:57 +0200 Subject: [PATCH 28/34] Fix syntax error --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 67b1e4c1bf0..c7cac9826e0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3734,7 +3734,7 @@ class Form else $more.=''; $more.=''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'password') { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 5a7916f6bd9..14814efc198 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1801,10 +1801,10 @@ if (count($object->records) > 0) if ($action == 'createpagefromclone') { // Create an array for form $formquestion = array( - array('type' => 'text', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME") ,'value'=> 'copy_of_'.$objectpage->pageurl), + array('type' => 'text', 'tdclass'=>'maxwidth200', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME"), 'value'=> 'copy_of_'.$objectpage->pageurl), array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), - array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, 1, 0, 0, 'minwidth200')), - array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), + array('type' => 'other','name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, 1, 0, 0, 'minwidth200')), + array('type' => 'other','name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?website='.$object->ref.'&pageid=' . $pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550); From 9f92974e9800b292906bd7a8e8fd4521215ff069 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Aug 2018 15:13:34 +0200 Subject: [PATCH 30/34] Fix tdclass --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 77c744c5da4..fc7d64d2e2c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3700,7 +3700,7 @@ class Form if ($input['type'] == 'text') { - $more.=''.$input['label'].''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'password') { From 4885e612403eba8b61b551cbea0ea6d96ac70650 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Aug 2018 15:16:03 +0200 Subject: [PATCH 31/34] Fix tdclass --- htdocs/core/class/html.form.class.php | 2 +- htdocs/website/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fc7d64d2e2c..683b6871a28 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3716,7 +3716,7 @@ class Form else if ($input['type'] == 'checkbox') { $more.=''; - $more.=''."\n"; + $more.=''.$input['label'].''."\n"; } else if ($input['type'] == 'select') { - $more.=''; if (! empty($input['label'])) $more.=$input['label'].''."\n"; @@ -3730,8 +3730,8 @@ class Form foreach($input['values'] as $selkey => $selval) { $more.=''; - if ($i==0) $more.=''; - else $more.=''; + if ($i==0) $more.=''.$input['label'].''; + else $more.=' '; $more.=''.$input['label'].''; $more.=''."\n"; @@ -3754,7 +3754,7 @@ class Form } else if ($input['type'] == 'other') { - $more.=''; if (! empty($input['label'])) $more.=$input['label'].''."\n"; From e67e32c0232a1171a6f9ce54b39d86b8b7de33bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Aug 2018 15:25:18 +0200 Subject: [PATCH 33/34] Add forcecombo on select language --- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/core/class/html.formadmin.class.php | 10 +++++++--- htdocs/website/index.php | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 84af1c5325b..146c544b32e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1347,7 +1347,7 @@ class Form * @param string $moreclass Add more class to class style * @param bool $options_only Return options only (for ajax treatment) * @param integer $showsoc Add company into label - * @param int $forcecombo Force to use combo box + * @param int $forcecombo Force to use combo box (so no ajax beautify effect) * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @param string $htmlid Html id to use instead of htmlname @@ -1554,7 +1554,7 @@ class Form else $sql.= " WHERE u.entity IS NOT NULL"; } else - { + { if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug"; diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index fd0470c63f4..8c2af9c9f3a 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -56,9 +56,10 @@ class FormAdmin * @param int $disabled Disable edit of select * @param string $morecss Add more css styles * @param int $showcode Add language code into label + * @param int $forcecombo Force to use combo box (so no ajax beautify effect) * @return string Return HTML select string with list of languages */ - function select_language($selected='', $htmlname='lang_id', $showauto=0, $filter=null, $showempty='', $showwarning=0, $disabled=0, $morecss='', $showcode=0) + function select_language($selected='', $htmlname='lang_id', $showauto=0, $filter=null, $showempty='', $showwarning=0, $disabled=0, $morecss='', $showcode=0, $forcecombo=0) { global $langs; @@ -109,8 +110,11 @@ class FormAdmin $out.= ''; // Make select dynamic - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $out.= ajax_combobox($htmlname); + if (! $forcecombo) + { + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out.= ajax_combobox($htmlname); + } return $out; } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 6d3dc5d9fd2..f1aa69d22d4 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1803,7 +1803,7 @@ if (count($object->records) > 0) $formquestion = array( array('type' => 'text', 'tdclass'=>'maxwidth200', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME"), 'value'=> 'copy_of_'.$objectpage->pageurl), array('type' => 'checkbox', 'tdclass'=>'maxwidth200', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), - array('type' => 'other','name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, 1, 0, 0, 'minwidth200')), + array('type' => 'other','name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, 1, 0, 0, 'minwidth200', 0, 1)), array('type' => 'other','name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), ); From a896fb419f8cf63517c153bf814fe1c5381da6f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Aug 2018 15:28:53 +0200 Subject: [PATCH 34/34] Fix preselected language --- htdocs/website/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index f1aa69d22d4..ce8be81e2cd 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1800,10 +1800,11 @@ if (count($object->records) > 0) // Confirmation to clone if ($action == 'createpagefromclone') { // Create an array for form + $preselectedlanguage = GETPOST('newlang', 'az09') ? GETPOST('newlang', 'az09') : ($objectpage->lang ? $objectpage->lang : $langs->defaultlang); $formquestion = array( array('type' => 'text', 'tdclass'=>'maxwidth200', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME"), 'value'=> 'copy_of_'.$objectpage->pageurl), array('type' => 'checkbox', 'tdclass'=>'maxwidth200', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), - array('type' => 'other','name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, 1, 0, 0, 'minwidth200', 0, 1)), + array('type' => 'other','name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language($preselectedlanguage, 'newlang', 0, null, 1, 0, 0, 'minwidth200', 0, 1)), array('type' => 'other','name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), );
'.(! empty($formquestion['text'])?$formquestion['text']:'').'
'.$formquestion['text'].'
'.$input['label'].'
'.$input['label'].'
'.$input['label'].'
'.$input['label'].'
'; - if (! empty($input['label'])) $more.=$input['label'].''; + if (! empty($input['label'])) $more.=$input['label'].''; $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1,0,0,$moreattr,0,0,0,'',$morecss); $more.='
 
'.$input['label'].' '; - $more.=''; + $more.=''; $more.=$this->select_date($input['value'],$input['name'],0,0,0,'',1,0,1); $more.='
'; - if (! empty($input['label'])) $more.=$input['label'].''; + if (! empty($input['label'])) $more.=$input['label'].''; $more.=$input['value']; $more.='
'; + $more.='
'; $more.=$input['value']; $more.='
  Date: Fri, 24 Aug 2018 15:12:47 +0200 Subject: [PATCH 29/34] Add tdclass to form confirm for more control --- htdocs/core/class/html.form.class.php | 2 +- htdocs/website/index.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c7cac9826e0..77c744c5da4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3700,7 +3700,7 @@ class Form if ($input['type'] == 'text') { - $more.='
'.$input['label'].'
'.$input['label'].' '; + $more.=''.$input['label'].' '; $more.='records) > 0) // Create an array for form $formquestion = array( array('type' => 'text', 'tdclass'=>'maxwidth200', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME"), 'value'=> 'copy_of_'.$objectpage->pageurl), - array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), + array('type' => 'checkbox', 'tdclass'=>'maxwidth200', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), array('type' => 'other','name' => 'newlang', 'label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, 1, 0, 0, 'minwidth200')), array('type' => 'other','name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), ); From b22d9db1a5e00ccf8c8b1f14072ec33d46bfc507 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Aug 2018 15:18:19 +0200 Subject: [PATCH 32/34] Fix tdclass --- htdocs/core/class/html.form.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 683b6871a28..84af1c5325b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3704,11 +3704,11 @@ class Form } else if ($input['type'] == 'password') { - $more.='
'.$input['label'].'
'; + $more.='
'; $more.=$this->selectarray($input['name'],$input['values'],$input['default'],1,0,0,$moreattr,0,0,0,'',$morecss); $more.='
'.$input['label'].' '; + $more.='
'; $more.=$this->select_date($input['value'],$input['name'],0,0,0,'',1,0,1); $more.='
'; + $more.='
'; $more.=$input['value']; $more.='