From 3d179fb7d37b1e115f7c9f48bfa9cfae8c40c6a1 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 24 Apr 2018 09:17:03 +0200 Subject: [PATCH 001/256] 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 002/256] 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 003/256] 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 2ba7c075742c299131ba1e86a73dea6577125cc5 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Mon, 9 Jul 2018 17:34:31 +0200 Subject: [PATCH 004/256] FIX: propal: correctly preset project when creating with origin/originid --- htdocs/comm/propal/card.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index e0a4c19c9cb..9a1c2dcb54f 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -74,6 +74,7 @@ $originid = GETPOST('originid', 'int'); $confirm = GETPOST('confirm', 'alpha'); $lineid = GETPOST('lineid', 'int'); $contactid = GETPOST('contactid','int'); +$projectid = GETPOST('projectid','int'); // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -1310,7 +1311,7 @@ if ($action == 'create') } $objectsrc->fetch_thirdparty(); - $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); + $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : 0); $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); $ref_int = (! empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); @@ -1478,9 +1479,6 @@ if ($action == 'create') // Project if (! empty($conf->projet->enabled) && $socid > 0) { - $projectid = GETPOST('projectid')?GETPOST('projectid'):0; - if ($origin == 'project') $projectid = ($originid ? $originid : 0); - $langs->load("projects"); print ''; print '' . $langs->trans("Project") . ''; From 103c7e6d066ad7a0754e6db85a93e8ac4b7252e6 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 11 Jul 2018 09:51:36 +0200 Subject: [PATCH 005/256] FIX : page must always be 0 when we search (to avoid case : when we're on page 3 and we're looking for a precise thirdparty, we stay on page 3 and nothing's displaied) --- htdocs/comm/propal/list.php | 4 +++- htdocs/commande/list.php | 4 +++- htdocs/compta/facture/list.php | 4 +++- htdocs/fourn/commande/list.php | 4 +++- htdocs/fourn/facture/list.php | 4 +++- htdocs/societe/list.php | 4 +++- htdocs/supplier_proposal/list.php | 4 +++- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 72491e90e3e..fe35c2bc4e8 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -83,12 +83,14 @@ $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); $search_day=GETPOST("search_day","int"); $search_month=GETPOST("search_month","int"); $search_year=GETPOST("search_year","int"); +$search_btn=GETPOST('button_search','alpha'); +$search_remove_btn=GETPOST('button_removefilter','alpha'); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 6284e53aa5c..6e57b55b2c7 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -74,6 +74,8 @@ $search_total_ht=GETPOST('search_total_ht','alpha'); $optioncss = GETPOST('optioncss','alpha'); $billed = GETPOST('billed','int'); $viewstatut=GETPOST('viewstatut'); +$search_btn=GETPOST('button_search','alpha'); +$search_remove_btn=GETPOST('button_removefilter','alpha'); // Security check $id = (GETPOST('orderid')?GETPOST('orderid','int'):GETPOST('id','int')); @@ -86,7 +88,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 994f1d93569..1e857abfa7e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -93,6 +93,8 @@ $year = GETPOST('year','int'); $day_lim = GETPOST('day_lim','int'); $month_lim = GETPOST('month_lim','int'); $year_lim = GETPOST('year_lim','int'); +$search_btn=GETPOST('button_search','alpha'); +$search_remove_btn=GETPOST('button_removefilter','alpha'); $option = GETPOST('option'); if ($option == 'late') { @@ -104,7 +106,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; if (! $sortorder && ! empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == 1) $sortorder=$conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; if (! $sortorder) $sortorder='DESC'; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 4d5f2999943..1bb52d8ae48 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -85,6 +85,8 @@ $search_total_ttc=GETPOST('search_total_ttc','alpha'); $optioncss = GETPOST('optioncss','alpha'); $billed = GETPOST('billed','int'); $search_project_ref=GETPOST('search_project_ref','alpha'); +$search_btn=GETPOST('button_search','alpha'); +$search_remove_btn=GETPOST('button_removefilter','alpha'); $page = GETPOST('page','int'); $sortorder = GETPOST('sortorder','alpha'); @@ -105,7 +107,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index a602badfb05..960fac83216 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -99,6 +99,8 @@ $day_lim = GETPOST('day_lim','int'); $month_lim = GETPOST('month_lim','int'); $year_lim = GETPOST('year_lim','int'); $toselect = GETPOST('toselect', 'array'); +$search_btn=GETPOST('button_search','alpha'); +$search_remove_btn=GETPOST('button_removefilter','alpha'); $option = GETPOST('option'); if ($option == 'late') { @@ -110,7 +112,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); -if ($page == -1 || $page == null) { $page = 0 ; } +if ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0 ; } $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3d56fa9401a..b3f070124a6 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -82,6 +82,8 @@ $search_type=GETPOST('search_type','alpha'); $search_level_from = GETPOST("search_level_from","alpha"); $search_level_to = GETPOST("search_level_to","alpha"); $search_stcomm=GETPOST('search_stcomm','int'); +$search_btn=GETPOST('button_search','alpha'); +$search_remove_btn=GETPOST('button_removefilter','alpha'); $type=GETPOST('type'); $optioncss=GETPOST('optioncss','alpha'); @@ -95,7 +97,7 @@ $sortorder=GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="s.nom"; -if (empty($page) || $page == -1) { $page = 0; } +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 4240ca72a08..c1267fce72a 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -73,6 +73,8 @@ $search_montant_vat=GETPOST('search_montant_vat','alpha'); $search_montant_ttc=GETPOST('search_montant_ttc','alpha'); $search_status=GETPOST('viewstatut','alpha')?GETPOST('viewstatut','alpha'):GETPOST('search_status','int'); $object_statut=$db->escape(GETPOST('supplier_proposal_statut')); +$search_btn=GETPOST('button_search','alpha'); +$search_remove_btn=GETPOST('button_removefilter','alpha'); $sall=GETPOST('sall', 'alphanohtml'); $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); @@ -85,7 +87,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; From 80ff7fa86f34d11c9facedac8bab3b3250b91b53 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 11 Jul 2018 15:18:30 +0200 Subject: [PATCH 006/256] FIX : case when we valid form with keyboard --- htdocs/comm/propal/list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/societe/list.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index fe35c2bc4e8..52a712ab043 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -90,7 +90,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 6e57b55b2c7..db1b7554e4f 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -88,7 +88,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 1e857abfa7e..859889966eb 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -106,7 +106,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; if (! $sortorder && ! empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == 1) $sortorder=$conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; if (! $sortorder) $sortorder='DESC'; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 1bb52d8ae48..d1b8cdcdcaf 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -107,7 +107,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 960fac83216..5ba2a2b9779 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -112,7 +112,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); -if ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0 ; } +if ($page == -1 || $page == null || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0 ; } $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index b3f070124a6..3f011d588f5 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -97,7 +97,7 @@ $sortorder=GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="s.nom"; -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index c1267fce72a..cf492137330 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -87,7 +87,7 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn)) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; From 7dada7ae8e2c020cda81d614c96d694c7d1f99da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 29 Jul 2018 09:15:42 +0200 Subject: [PATCH 007/256] fix #8820 --- htdocs/product/reassort.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index e3983344cff..70dce7470cd 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -134,7 +134,7 @@ if (dol_strlen($type)) $sql.= " AND p.fk_product_type <> '1'"; } } -if ($sref) $sql.= natural_search('p.ref', $ref); +if ($sref) $sql.= natural_search('p.ref', $sref); if ($sbarcode) $sql.= natural_search('p.barcode', $sbarcode); if ($snom) $sql.= natural_search('p.label', $snom); if (! empty($tosell)) $sql.= " AND p.tosell = ".$tosell; From b9a44fc76bbe4fe4f84f8fdfe0b41ab278b82fe3 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 31 Jul 2018 12:15:18 +0200 Subject: [PATCH 008/256] FIX : Wrong position of firstname lastname --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d9c86dd45f4..7b8d110802c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5856,7 +5856,7 @@ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) $ret=''; // If order not defined, we use the setup if ($nameorder < 0) $nameorder=$conf->global->MAIN_FIRSTNAME_NAME_POSITION; - if ($nameorder && ((string) $nameorder != '2')) + if (empty($nameorder) && ((string) $nameorder != '2')) { $ret.=$firstname; if ($firstname && $lastname) $ret.=' '; From 4ddca02bb9d86d3e6abfdfe2cb4a75359e9e3582 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 31 Jul 2018 14:58:33 +0200 Subject: [PATCH 009/256] fix situation line's total --- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/core/lib/pdf.lib.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3de5ae96458..e0b6d1d81bc 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4834,7 +4834,7 @@ class FactureLigne extends CommonInvoiceLine $resql = $this->db->query($sql); if ($resql && $resql->num_rows > 0) { $res = $this->db->fetch_array($resql); - return $res['situation_percent']; + return floatval($res['situation_percent']); } else { $this->error = $this->db->error(); dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR); diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index cb061bc9f2e..234c0cc7e34 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1899,13 +1899,13 @@ function pdf_getlinetotalexcltax($object,$i,$outputlangs,$hidedetails=0) { $prev_progress = 0; $progress = 1; - if (method_exists($object, 'get_prev_progress')) + if (method_exists($object->lines[$i], 'get_prev_progress')) { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); $progress = ($object->lines[$i]->situation_percent - $prev_progress) / 100; } $result.=price($sign * ($total_ht/($object->lines[$i]->situation_percent/100)) * $progress, 0, $outputlangs); - } + } else $result.=price($sign * $total_ht, 0, $outputlangs); } From ceb85cfa45d60cb987a3ef5271cd11fef844d99d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 31 Jul 2018 17:29:08 +0200 Subject: [PATCH 010/256] fix : odt project and task extrafields management --- .../doc/doc_generic_project_odt.modules.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index e050bf8e3eb..c2258f9ba97 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -130,12 +130,9 @@ class doc_generic_project_odt extends ModelePDFProjects $array_key.'_statut'=>$object->getLibStatut() ); - // Retrieve extrafields - $extrafieldkey=$object->element; - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); - $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element,true); $object->fetch_optionals($object->id,$extralabels); $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); @@ -154,7 +151,7 @@ class doc_generic_project_odt extends ModelePDFProjects { global $conf; - return array( + $resarray = array( 'task_ref'=>$task->ref, 'task_fk_project'=>$task->fk_project, 'task_projectref'=>$task->projectref, @@ -170,6 +167,16 @@ class doc_generic_project_odt extends ModelePDFProjects 'task_note_private'=>$task->note_private, 'task_note_public'=>$task->note_public ); + + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + $extralabels = $extrafields->fetch_name_optionals_label($task->table_element,true); + $task->fetch_optionals($task->id,$extralabels); + + $resarray = $this->fill_substitutionarray_with_extrafields($task,$resarray,$extrafields,'task',$outputlangs); + + return $resarray; + } /** From 70adfb135dc332c30a225b1412fd1e50f71f2992 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Fri, 3 Aug 2018 09:51:29 +0200 Subject: [PATCH 011/256] FIX : Missing behavior --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7b8d110802c..28a31507733 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5855,8 +5855,8 @@ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) $ret=''; // If order not defined, we use the setup - if ($nameorder < 0) $nameorder=$conf->global->MAIN_FIRSTNAME_NAME_POSITION; - if (empty($nameorder) && ((string) $nameorder != '2')) + if ($nameorder < 0) $nameorder=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION); + if ($nameorder && ((string) $nameorder != '2')) { $ret.=$firstname; if ($firstname && $lastname) $ret.=' '; From 615ed115343b4f49345a30589e45759d1ee3721d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 3 Aug 2018 17:09:58 +0200 Subject: [PATCH 012/256] fix bad use of test_sql_and_script_inject return int not value tested --- htdocs/core/class/html.form.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 776c04bfc41..5c7091ba6e3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1070,7 +1070,11 @@ class Form $outarray=array(); // Clean $filter that may contains sql conditions so sql code - if (function_exists('test_sql_and_script_inject')) $filter = test_sql_and_script_inject($filter, 3); + if (function_exists('test_sql_and_script_inject')) { + if (test_sql_and_script_inject($filter, 3)>0) { + $filter =''; + } + } // On recherche les societes $sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur"; From 74d05da149655e29933b689881d0881833203b7c Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 6 Aug 2018 11:28:34 +0200 Subject: [PATCH 013/256] fix : display if error --- htdocs/holiday/card.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index b19f63e0ab3..348edcac1e7 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -452,10 +452,15 @@ if ($action == 'confirm_valid') $newSolde = $soldeActuel - ($nbopenedday * $object->getConfCP('nbHolidayDeducted')); // On ajoute la modification dans le LOG - $object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("Holidays"), $newSolde, $object->fk_type); - + $result=$object->addLogCP($user->id, $object->fk_user, $langs->transnoentitiesnoconv("Holidays"), $newSolde, $object->fk_type); + if ($result<0) { + setEventMessages(null, $object->errors,'errors'); + } // Mise à jour du solde - $object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); + $result=$object->updateSoldeCP($object->fk_user, $newSolde, $object->fk_type); + if ($result<0) { + setEventMessages(null, $object->errors,'errors'); + } // To $destinataire = new User($db); From e84018ac1532daabea7e4a25b6f5ef4a43630755 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 6 Aug 2018 19:21:12 +0200 Subject: [PATCH 014/256] Fix 3D secure convett to dolibarr standard stripe payment metadata --- htdocs/public/stripe/ipn.php | 40 ++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index c5d2cd85e5c..7d2c8d47ff6 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -42,11 +42,13 @@ if (isset($_GET['connect'])){ { $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_CONNECT_KEY; $service = 'StripeTest'; + $servicestatus = 0; } else { $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_CONNECT_KEY; $service = 'StripeLive'; + $servicestatus = 1; } } else { @@ -54,11 +56,13 @@ else { { $endpoint_secret = $conf->global->STRIPE_TEST_WEBHOOK_KEY; $service = 'StripeTest'; + $servicestatus = 0; } else { $endpoint_secret = $conf->global->STRIPE_LIVE_WEBHOOK_KEY; $service = 'StripeLive'; + $servicestatus = 1; } } $payload = @file_get_contents("php://input"); @@ -227,19 +231,37 @@ elseif ($event->type == 'charge.failed') { } elseif (($event->type == 'source.chargeable') && ($event->data->object->type == 'three_d_secure') && ($event->data->object->three_d_secure->authenticated==true)) { - $stripe=new Stripe($db); - $charge=$stripe->CreatePaymentStripe($event->data->object->amount/100,$event->data->object->currency,$event->data->object->metadata->source,$event->data->object->metadata->idsource,$event->data->object->id,$event->data->object->metadata->customer,$stripe->getStripeAccount($service)); + $fulltag=$event->data->object->metadata->FULLTAG; + // Save into $tmptag all metadata + $tmptag=dolExplodeIntoArray($fulltag,'.','='); + + if (! empty($tmptag['ORD'])){ + $order=new Commande($db); + $order->fetch('',$tmptag['ORD']); + $origin='order'; + $item=$order->id; + } elseif (! empty($tmptag['INV'])) { + $invoice = new Facture($db); + $invoice->fetch('',$tmptag['INV']); + $origin='invoice'; + $item=$invoice->id; + } + $stripe=new Stripe($db); + $stripeacc = $stripe->getStripeAccount($service); // Stripe OAuth connect account of dolibarr user (no network access here) + $stripecu = $stripe->getStripeCustomerAccount($tmptag['CUS'], $servicestatus); // Get thirdparty cu_... + $charge=$stripe->createPaymentStripe($event->data->object->amount/100,$event->data->object->currency,$origin,$item,$event->data->object->id,$stripecu,$stripeacc,$servicestatus); + if (isset($charge->id) && $charge->statut=='error'){ $msg=$charge->message; $code=$charge->code; $error++; - } - elseif (isset($charge->id) && $charge->statut=='success' && $event->data->object->metadata->source=='order') { - $order=new Commande($db); - $order->fetch($event->data->object->metadata->idsource); + } + elseif (isset($charge->id) && $charge->statut=='success' && (! empty($tmptag['ORD']))) { + //$order=new Commande($db); + //$order->fetch('',$tmptag['ORD']); $invoice = new Facture($db); - $idinv=$invoice->createFromOrder($order); + $idinv=$invoice->createFromOrder($order,$user); if ($idinv > 0) { @@ -265,7 +287,7 @@ elseif (($event->type == 'source.chargeable') && ($event->data->object->type == if (!$error){ $datepaye = dol_now(); - $paiementcode ="CB"; + $paymentType ="CB"; $amounts=array(); $amounts[$invoice->id] = $total; $multicurrency_amounts=array(); @@ -274,7 +296,7 @@ elseif (($event->type == 'source.chargeable') && ($event->data->object->type == $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array with all payments dispatching $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement'); + $paiement->paiementid = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); $paiement->num_paiement = $charge->message; $paiement->note = ''; } From 4e16f64af0a95f0968cbdb37a8f6ec79fc18bdb7 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 9 Aug 2018 12:13:06 +0200 Subject: [PATCH 015/256] 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 016/256] 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 f0a32a2dead96577c9813acf995b41130ac54499 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 9 Aug 2018 20:41:15 +0200 Subject: [PATCH 017/256] fix : remove comment on commit --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 3e4af5438c6..f7a074106b9 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -330,7 +330,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if (! $error) { -// $db->commit(); + $db->commit(); } else { From d8d54d246c5cc64cf0699efbf6aeef73b7d89dcd Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Fri, 10 Aug 2018 15:05:21 +0200 Subject: [PATCH 018/256] FIX : Pagination on withdraw request list --- htdocs/compta/prelevement/create.php | 30 +++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index cd3aebf62f4..af49e849e9f 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -47,7 +47,10 @@ $result = restrictedArea($user, 'prelevement', '', '', 'bons'); $action = GETPOST('action','alpha'); $mode = GETPOST('mode','alpha')?GETPOST('mode','alpha'):'real'; $format = GETPOST('format','aZ09'); - +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$page = GETPOST("page",'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; /* * Actions @@ -196,13 +199,33 @@ $sql.= " AND pfd.traite = 0"; $sql.= " AND pfd.fk_facture = f.rowid"; if ($socid) $sql.= " AND f.fk_soc = ".$socid; +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); +} + +$sql.= $db->plimit($limit+1,$offset); + $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; - print load_fiche_titre($langs->trans("InvoiceWaitingWithdraw").($num > 0?' ('.$num.')':''),'',''); + $param=''; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if($socid) $param .= '&socid='.urlencode($socid); + if($option) $param .= "&option=".urlencode($option); + + if(! empty($page) && $num <= $nbtotalofrecords) $page = 0; + + print '
'; + print ''; + print ''; + + print_barre_liste($langs->trans("InvoiceWaitingWithdraw"),$page,$_SERVER['PHP_SELF'],$param,'','','',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit); print ''; print ''; @@ -219,7 +242,7 @@ if ($resql) require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; $bac = new CompanyBankAccount($db); - while ($i < $num && $i < 20) + while ($i < $num && $i < $limit) { $obj = $db->fetch_object($resql); @@ -260,6 +283,7 @@ if ($resql) } else print ''; print "
'.$langs->trans("None").'
"; + print "
"; print "
\n"; } else From 391230babcc097772bad8edfc560a779c4b0408b Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 10 Aug 2018 15:39:49 +0200 Subject: [PATCH 019/256] FIX : global $mysoc missing (to avoid php notice on lines 279, 280 & 281) --- htdocs/core/modules/modService.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 7a9a3f4df3f..7302ebc673b 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -42,7 +42,7 @@ class modService extends DolibarrModules */ function __construct($db) { - global $conf; + global $conf, $mysoc; $this->db = $db; $this->numero = 53; From 12e21b48866ec7ad7de996afe2c0b182c3aea45c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Aug 2018 16:29:26 +0200 Subject: [PATCH 020/256] FIX update extrafields --- htdocs/adherents/class/adherent.class.php | 2 +- .../adherents/class/adherent_type.class.php | 4 +-- htdocs/comm/propal/class/propal.class.php | 20 +++++++---- htdocs/commande/class/commande.class.php | 18 ++++++---- htdocs/compta/facture/class/facture.class.php | 20 +++++++---- htdocs/contact/class/contact.class.php | 11 +++--- htdocs/contrat/class/contrat.class.php | 36 ++++++++----------- htdocs/core/class/commonobject.class.php | 11 +++--- htdocs/expedition/class/expedition.class.php | 8 ++--- htdocs/fichinter/class/fichinter.class.php | 17 ++++++--- htdocs/product/class/product.class.php | 2 +- htdocs/societe/class/societe.class.php | 3 +- .../class/supplier_proposal.class.php | 4 +-- htdocs/user/class/user.class.php | 4 +-- 14 files changed, 90 insertions(+), 70 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 537b6f76a63..5d7664b13aa 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -464,7 +464,7 @@ class Adherent extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 75f518074b1..ca8372c04ed 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -142,7 +142,7 @@ class AdherentType extends CommonObject /** * Met a jour en base donnees du type * - * @param User $user Object user making change + * @param User $user Object user making change * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ @@ -172,7 +172,7 @@ class AdherentType extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9ebd4a85e5e..e49fe43e2c9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1464,6 +1464,8 @@ class Propal extends CommonObject */ function update(User $user, $notrigger=0) { + global $conf; + $error=0; // Clean parameters @@ -1512,17 +1514,23 @@ class Propal extends CommonObject $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { - if (! $notrigger) + $result=$this->insertExtraFields(); + if ($result < 0) { - // Call trigger - $result=$this->call_trigger('PROPAL_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers + $error++; } } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('PROPAL_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } + // Commit or rollback if ($error) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index fd903c4fcfb..ecd2be95d7a 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -3067,17 +3067,23 @@ class Commande extends CommonOrder $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { - if (! $notrigger) + $result=$this->insertExtraFields(); + if ($result < 0) { - // Call trigger - $result=$this->call_trigger('ORDER_MODIFY', $user); - if ($result < 0) $error++; - // End call triggers + $error++; } } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('ORDER_MODIFY', $user); + if ($result < 0) $error++; + // End call triggers + } + // Commit or rollback if ($error) { diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c6e43206c78..93a97eaee1a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1549,6 +1549,8 @@ class Facture extends CommonInvoice */ function update(User $user, $notrigger=0) { + global $conf; + $error=0; // Clean parameters @@ -1614,17 +1616,23 @@ class Facture extends CommonInvoice $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { - if (! $notrigger) + $result=$this->insertExtraFields(); + if ($result < 0) { - // Call trigger - $result=$this->call_trigger('BILL_MODIFY',$user); - if ($result < 0) $error++; - // End call triggers + $error++; } } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILL_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } + // Commit or rollback if ($error) { diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 013751e8282..d7df30d5ee5 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -371,15 +371,12 @@ class Contact extends CommonObject $action='update'; // Actions on extra fields - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 640793b7f37..a867d8937c9 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -925,16 +925,13 @@ class Contrat extends CommonObject } } - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } // Insert contacts commerciaux ('SALESREPSIGN','contrat') @@ -1283,18 +1280,7 @@ class Contrat extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { - // Call triggers - $result=$this->call_trigger('CONTRACT_MODIFY',$user); - if ($result < 0) { $error++; } - // End call triggers - } - } - - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { $result=$this->insertExtraFields(); if ($result < 0) @@ -1303,6 +1289,14 @@ class Contrat extends CommonObject } } + if (! $error && ! $notrigger) + { + // Call triggers + $result=$this->call_trigger('CONTRACT_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers + } + // Commit or rollback if ($error) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1dfc9c90718..6fc7467bb9d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7044,15 +7044,12 @@ abstract class CommonObject } // Update extrafield - if (! $error) + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + $result=$this->insertExtraFields(); + if ($result < 0) { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $error++; } } diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 4042b202300..5728d60932a 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -313,7 +313,7 @@ class Expedition extends CommonObject } // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) @@ -541,8 +541,7 @@ class Expedition extends CommonObject */ $result=$this->fetch_thirdparty(); - // Retreive all extrafield - // fetch optionals attributes and labels + // Retreive extrafields $this->fetch_optionals(); /* @@ -2412,7 +2411,8 @@ class ExpeditionLigne extends CommonObjectLine if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expeditiondet"); - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 370fed20768..d14419f49b0 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -222,7 +222,7 @@ class Fichinter extends CommonObject if (! $resql) $error++; } - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) @@ -285,6 +285,8 @@ class Fichinter extends CommonObject $this->fk_project = 0; } + $error = 0; + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter SET "; @@ -299,8 +301,16 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); if ($this->db->query($sql)) { + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } - if (! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('FICHINTER_MODIFY',$user); @@ -372,8 +382,7 @@ class Fichinter extends CommonObject if ($this->statut == 0) $this->brouillon = 1; - // Retreive all extrafield - // fetch optionals attributes and labels + // Retreive extrafields $this->fetch_optionals(); /* diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c271346d4bc..d9e393575df 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -916,7 +916,7 @@ class Product extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f5b291ba2a0..38d07e8e4db 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -754,6 +754,7 @@ class Societe extends CommonObject function update($id, $user='', $call_trigger=1, $allowmodcodeclient=0, $allowmodcodefournisseur=0, $action='update', $nosyncmember=1) { global $langs,$conf,$hookmanager; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; if (empty($id)) $id = $this->id; @@ -1053,7 +1054,7 @@ class Societe extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); if ($result < 0) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 54672da2b75..c3b6e4b3338 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1013,7 +1013,7 @@ class SupplierProposal extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) @@ -1022,7 +1022,7 @@ class SupplierProposal extends CommonObject } } - if (! $erro && ! $notrigger) + if (! $error && ! $notrigger) { // Call trigger $result=$this->call_trigger('PROPAL_SUPPLIER_CREATE',$user); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 8e3ae7222fb..fed37fc0d5a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -135,7 +135,7 @@ class User extends CommonObject public $default_c_exp_tax_cat; public $default_range; - + public $fields=array( 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), @@ -1581,7 +1581,7 @@ class User extends CommonObject $action='update'; // Actions on extra fields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { $result=$this->insertExtraFields(); if ($result < 0) From 6954ab00f9ada8e986af9594e210034652e834f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 12 Aug 2018 18:11:27 +0200 Subject: [PATCH 021/256] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 28a31507733..f27c1fbf0a0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5855,7 +5855,7 @@ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) $ret=''; // If order not defined, we use the setup - if ($nameorder < 0) $nameorder=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION); + if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?1:0); if ($nameorder && ((string) $nameorder != '2')) { $ret.=$firstname; From ddbfaf07888590f9271e877adde3a56adaa345e9 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 9 Aug 2018 20:57:32 +0200 Subject: [PATCH 022/256] wrong position of counter reset extrafields will work now ;) and not the first product gets the last extrafields values --- htdocs/webservices/server_productorservice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index c4c4d40191e..6094d2e0798 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -1048,11 +1048,11 @@ function getProductsForCategory($authentication,$id,$lang='') $res = $db->query($sql); if ($res) { + $iProduct = 0; while ($rec = $db->fetch_array($res)) { $obj = new Product($db); $obj->fetch($rec['fk_'.$field]); - $iProduct = 0; if($obj->status > 0 ) { $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); From 21555a7435858c46e4b5b72de536058789936bab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 01:10:51 +0200 Subject: [PATCH 023/256] Fix firstname/lastname --- htdocs/admin/ihm.php | 4 ++-- htdocs/core/class/html.form.class.php | 15 ++++++++++----- .../societe/canvas/actions_card_common.class.php | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 03f3d364cca..a9bf5313789 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -315,8 +315,8 @@ if ($action == 'edit') // Edit // Firstname/Name print ''.$langs->trans("FirstnameNamePosition").''; - $array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"),1=>$langs->trans("Lastname").' '.$langs->trans("Firstname")); - print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION',$array,(isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0)); + $array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname")); + print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0)); print ''; print ' '; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5c7091ba6e3..bd7feb9414d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1530,9 +1530,12 @@ class Form if (! empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql.= " AND u.statut <> 0"; if (! empty($morefilter)) $sql.=" ".$morefilter; - if(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)){ + if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname + { $sql.= " ORDER BY u.firstname ASC"; - }else{ + } + else + { $sql.= " ORDER BY u.lastname ASC"; } @@ -1579,9 +1582,11 @@ class Form $out.= '>'; } - $fullNameMode = 0; //Lastname + firstname - if(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)){ - $fullNameMode = 1; //firstname + lastname + // $fullNameMode is 0=Lastname+Firstname (MAIN_FIRSTNAME_NAME_POSITION=1), 1=Firstname+Lastname (MAIN_FIRSTNAME_NAME_POSITION=0) + $fullNameMode = 0; + if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) + { + $fullNameMode = 1; //Firstname+lastname } $out.= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength); diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 452a9cc6a61..a0980563996 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -121,7 +121,7 @@ abstract class ActionsCardCommon { $this->object->particulier = GETPOST("private"); - $this->object->name = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?trim($_POST["firstname"].' '.$_POST["lastname"]):trim($_POST["lastname"].' '.$_POST["firstname"]); + $this->object->name = dolGetFirstLastname(GETPOST('firstname','alpha'),GETPOST('lastname','alpha')); $this->object->civility_id = $_POST["civility_id"]; // Add non official properties $this->object->name_bis = $_POST["lastname"]; From 7cd24c389db208d52b10363fba0192d51442417a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 01:21:23 +0200 Subject: [PATCH 024/256] Fix firstname/lastname --- test/phpunit/AdherentTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index a2f4f64aba5..7f3455ce37a 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -317,7 +317,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase $langs=$this->savlangs; $db=$this->savdb; - $conf->global->MAIN_FIRSTNAME_NAME_POSITION = 1; // Force setup for firstname then lastname + $conf->global->MAIN_FIRSTNAME_NAME_POSITION = 0; // Force setup for firstname+lastname $template = '__CIVILITY__,__FIRSTNAME__,__LASTNAME__,__FULLNAME__,__COMPANY__,'. '__ADDRESS__,__ZIP__,__TOWN__,__COUNTRY__,__EMAIL__,__BIRTH__,__PHOTO__,__LOGIN__'; From d92096f74a67dd96557a15a33140246ac936863c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 02:04:38 +0200 Subject: [PATCH 025/256] Fix menu payment not required if only module bank on --- htdocs/core/menus/standard/eldy.lib.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 2ad176fff91..695e7c4ca7f 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -150,11 +150,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode if (! empty($conf->salaries->enabled)) $menuqualified++; if (! empty($conf->supplier_invoice->enabled)) $menuqualified++; if (! empty($conf->loan->enabled)) $menuqualified++; - if (! empty($conf->banque->enabled)) $menuqualified++; $tmpentry=array( 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read) || ! empty($user->rights->banque->lire)), - 'module'=>'facture|supplier_invoice|don|tax|salaries|loan|banque'); + 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), + 'module'=>'facture|supplier_invoice|don|tax|salaries|loan'); $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { From c6adeabb557b7192548cb1186ab3b8896e628d6a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 13 Aug 2018 12:22:51 +0200 Subject: [PATCH 026/256] Fix dolibarr_set_const --- htdocs/public/stripe/ipn.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 7d2c8d47ff6..13ba40c6981 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -1,5 +1,5 @@ * * 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 @@ -26,6 +26,7 @@ if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.p if (! $res) die("Include of main fails"); if (empty($conf->stripe->enabled)) accessforbidden('',0,0,1); +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/includes/stripe/init.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; @@ -143,7 +144,7 @@ if ($event->type == 'payout.created') { elseif ($event->type == 'payout.paid') { global $conf; $error=0; - $result=dolibarr_set_const($db, $service."_NEXTPAYOUT",null,'chaine',0,'',$conf->entity); + $result=dolibarr_set_const($db, $servicestatus."_NEXTPAYOUT",null,'chaine',0,'',1); if ($result) { $langs->load("errors"); From b977c3a9f50e73de5f629b015a50e590d87aef0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 14:04:10 +0200 Subject: [PATCH 027/256] Fix translation --- htdocs/compta/facture/card.php | 6 ++---- htdocs/fourn/facture/card.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 45e94d1e5d3..f33c41b4c86 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4028,8 +4028,6 @@ else if ($id > 0 || ! empty($ref)) print ''; - // List of previous situation invoices - $sign = 1; if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = - 1; $nbrows = 8; @@ -4370,7 +4368,7 @@ else if ($id > 0 || ! empty($ref)) } else // Credit note { - $cssforamountpaymentcomplete=''; + $cssforamountpaymentcomplete='amountpaymentneutral'; // Total already paid back print ''; @@ -4385,7 +4383,7 @@ else if ($id > 0 || ! empty($ref)) if ($resteapayeraffiche <= 0) print $langs->trans('RemainderToPayBack'); else - print $langs->trans('ExcessPaydBack'); + print $langs->trans('ExcessPaid'); print ' :'; print '' . price($sign * $resteapayeraffiche) . ''; print ' '; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index d409ba35b86..7032f80574c 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2898,7 +2898,7 @@ else if ($resteapayeraffiche <= 0) print $langs->trans('RemainderToPayBack'); else - print $langs->trans('ExcessPaydBack'); + print $langs->trans('ExcessPaid'); print ' :'; print '' . price($sign * $resteapayeraffiche) . ''; print ' '; From d0666a9583619dff9b579917b702c339659ec40b Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 13 Aug 2018 14:34:54 +0200 Subject: [PATCH 028/256] Fix incorrect entity --- htdocs/public/stripe/ipn.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 13ba40c6981..ad6aee43bd4 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -124,7 +124,7 @@ $stripe=new Stripe($db); if ($event->type == 'payout.created') { $error=0; - $result=dolibarr_set_const($db, $service."_NEXTPAYOUT", date('Y-m-d H:i:s',$event->data->object->arrival_date), 'chaine', 0, '', $conf->entity); + $result=dolibarr_set_const($db, $servicestatus."_NEXTPAYOUT", date('Y-m-d H:i:s',$event->data->object->arrival_date), 'chaine', 0, '', $conf->entity); if ($result > 0) { @@ -144,7 +144,7 @@ if ($event->type == 'payout.created') { elseif ($event->type == 'payout.paid') { global $conf; $error=0; - $result=dolibarr_set_const($db, $servicestatus."_NEXTPAYOUT",null,'chaine',0,'',1); + $result=dolibarr_set_const($db, $servicestatus."_NEXTPAYOUT",null,'chaine',0,'',$conf->entity); if ($result) { $langs->load("errors"); From df57bd176bf2b7325efd7e12a76ab9d2aa5d4520 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 14:53:04 +0200 Subject: [PATCH 029/256] Fix translation --- htdocs/langs/en_US/agenda.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index f1e17a43cfe..9c1a0a35837 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -35,7 +35,7 @@ AgendaAutoActionDesc= Define here events for which you want Dolibarr to create a AgendaSetupOtherDesc= This page provides options to allow export of your Dolibarr events into an external calendar (thunderbird, google calendar, ...) AgendaExtSitesDesc=This page allows to declare external sources of calendars to see their events into Dolibarr agenda. ActionsEvents=Events for which Dolibarr will create an action in agenda automatically -EventRemindersByEmailNotEnabled=Event reminders by email was not enabled into Agenda module setup. +EventRemindersByEmailNotEnabled=Event reminders by email was not enabled into %s module setup. ##### Agenda event labels ##### NewCompanyToDolibarr=Third party %s created ContractValidatedInDolibarr=Contract %s validated From f96dd391fa2891612d77cb294d81cf1ac48db791 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 16:11:23 +0200 Subject: [PATCH 030/256] Fix error in foreign key pointing to old table --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 530070c8252..a3bed1fd332 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -32,6 +32,10 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +-- Forgot in < 4.0 + +ALTER TABLE llx_c_ziptown DROP FOREIGN KEY fk_c_ziptown_fk_pays; +ALTER TABLE llx_c_ziptown ADD CONSTRAINT fk_c_ziptown_fk_pays FOREIGN KEY (fk_pays) REFERENCES llx_c_country(rowid); -- Forgot in 7.0 @@ -48,6 +52,8 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (filepath, filename, ent UPDATE llx_const set name = __ENCRYPT('INVOICE_FREE_TEXT')__ where name = __ENCRYPT('FACTURE_FREE_TEXT')__; +fk_c_ziptown_fk_pays + -- drop very old table (bad name) DROP TABLE llx_c_accountancy_category; From 33f0172603e62f237b7159c30d334838df1ef9f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Aug 2018 16:44:49 +0200 Subject: [PATCH 031/256] Fix select zip/town --- htdocs/core/ajax/ziptown.php | 1 + htdocs/core/class/html.formcompany.class.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index 9fa475039d9..2100d3d3600 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -120,6 +120,7 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town'])) $row_array['selectcountry_id'] = $row['fk_country']; $row_array['state_id'] = $row['fk_county']; + // TODO Use a cache here to avoid to make select_state in each pass (this make a SQL and lot of logs) $row_array['states'] = $formcompany->select_state('',$row['fk_country'],''); array_push($return_arr,$row_array); diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 86105133c4c..f04cfad54bc 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -203,7 +203,7 @@ class FormCompany * * @param string $selected Code state preselected (mus be state id) * @param integer $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show - * @param string $htmlname Id of department + * @param string $htmlname Id of department. If '', we want only the string with