From c12a6bd4d1b7728724c464c30ee769c11b7e4d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Thu, 10 Nov 2022 17:10:51 +0100 Subject: [PATCH 001/320] FIX: GetNextValue() adding regexsql() function --- htdocs/core/db/DoliDB.class.php | 19 +++++++++++++++++++ htdocs/core/db/pgsql.class.php | 18 ++++++++++++++++++ htdocs/core/lib/functions2.lib.php | 7 ++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 63fec8968ec..31cc300fb2f 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -79,6 +79,25 @@ abstract class DoliDB implements Database { return 'IF('.$test.','.$resok.','.$resko.')'; } + + + /** + * Format a SQL REGEXP + * + * @param string $subject string tested + * @param string $pattern SQL pattern to match + * @param string $sqlstring whether or not the string being tested is an SQL expression + * @return string SQL string + */ + public function regexpsql($subject, $pattern, $sqlstring = false) + { + if ($sqlstring) { + return "(". $subject ." REGEXP '" . $pattern . "')"; + } + + return "('". $subject ."' REGEXP '" . $pattern . "')"; + } + /** * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 543e24a1b12..833be28d6bb 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -724,6 +724,24 @@ class DoliDBPgsql extends DoliDB return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)'; } + /** + * Format a SQL REGEXP + * + * @param string $subject string tested + * @param string $pattern SQL pattern to match + * @param string $sqlstring whether or not the string being tested is an SQL expression + * @return string SQL string + */ + public function regexpsql($subject, $pattern, $sqlstring = false) + { + if ($sqlstring) { + return "(". $subject ." ~ '" . $pattern . "')"; + } + + return "('". $subject ."' ~ '" . $pattern . "')"; + } + + /** * Renvoie le code erreur generique de l'operation precedente. * diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 0035688c66f..b8a1135c838 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1282,6 +1282,11 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $sql .= " FROM ".MAIN_DB_PREFIX.$table; $sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike)."'"; $sql .= " AND ".$field." NOT LIKE '(PROV%)'"; + + // To ensure that all variables within the MAX() brackets are integers + $sql .= " AND ". $db->regexpsql($sqlstring, '^[0-9]+$', true); + + if ($bentityon) { // only if entity enable $sql .= " AND entity IN (".getEntity($sharetable).")"; } elseif (!empty($forceentity)) { @@ -1293,7 +1298,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if ($sqlwhere) { $sql .= ' AND '.$sqlwhere; } - + //print $sql.'
'; dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); $resql = $db->query($sql); From 97618510e52359892360657114a74839122cbf4c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 10 Nov 2022 16:19:12 +0000 Subject: [PATCH 002/320] Fixing style errors. --- htdocs/core/db/DoliDB.class.php | 18 +++++++++--------- htdocs/core/db/pgsql.class.php | 16 ++++++++-------- htdocs/core/lib/functions2.lib.php | 10 +++++----- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 31cc300fb2f..2116148adb8 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -79,23 +79,23 @@ abstract class DoliDB implements Database { return 'IF('.$test.','.$resok.','.$resko.')'; } - - - /** + + + /** * Format a SQL REGEXP * * @param string $subject string tested - * @param string $pattern SQL pattern to match + * @param string $pattern SQL pattern to match * @param string $sqlstring whether or not the string being tested is an SQL expression * @return string SQL string */ public function regexpsql($subject, $pattern, $sqlstring = false) { - if ($sqlstring) { - return "(". $subject ." REGEXP '" . $pattern . "')"; - } - - return "('". $subject ."' REGEXP '" . $pattern . "')"; + if ($sqlstring) { + return "(". $subject ." REGEXP '" . $pattern . "')"; + } + + return "('". $subject ."' REGEXP '" . $pattern . "')"; } diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 833be28d6bb..ee72c63bc0d 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -724,24 +724,24 @@ class DoliDBPgsql extends DoliDB return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)'; } - /** + /** * Format a SQL REGEXP * * @param string $subject string tested - * @param string $pattern SQL pattern to match + * @param string $pattern SQL pattern to match * @param string $sqlstring whether or not the string being tested is an SQL expression * @return string SQL string */ public function regexpsql($subject, $pattern, $sqlstring = false) { - if ($sqlstring) { - return "(". $subject ." ~ '" . $pattern . "')"; - } - - return "('". $subject ."' ~ '" . $pattern . "')"; + if ($sqlstring) { + return "(". $subject ." ~ '" . $pattern . "')"; + } + + return "('". $subject ."' ~ '" . $pattern . "')"; } - + /** * Renvoie le code erreur generique de l'operation precedente. * diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index b8a1135c838..e194a45f9dc 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1282,11 +1282,11 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $sql .= " FROM ".MAIN_DB_PREFIX.$table; $sql .= " WHERE ".$field." LIKE '".$db->escape($maskLike)."'"; $sql .= " AND ".$field." NOT LIKE '(PROV%)'"; - - // To ensure that all variables within the MAX() brackets are integers - $sql .= " AND ". $db->regexpsql($sqlstring, '^[0-9]+$', true); - + // To ensure that all variables within the MAX() brackets are integers + $sql .= " AND ". $db->regexpsql($sqlstring, '^[0-9]+$', true); + + if ($bentityon) { // only if entity enable $sql .= " AND entity IN (".getEntity($sharetable).")"; } elseif (!empty($forceentity)) { @@ -1298,7 +1298,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if ($sqlwhere) { $sql .= ' AND '.$sqlwhere; } - + //print $sql.'
'; dol_syslog("functions2::get_next_value mode=".$mode."", LOG_DEBUG); $resql = $db->query($sql); From 416c809f742a5f919ef176665695d88bde2e0c94 Mon Sep 17 00:00:00 2001 From: atm-steve Date: Tue, 22 Nov 2022 15:05:24 +0100 Subject: [PATCH 003/320] fix: filter user by hierarchy on task --- htdocs/projet/activity/permonth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 273affc3563..49849b362ba 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -419,7 +419,7 @@ if (!empty($conf->categorie->enabled)) // If the user can view user other than himself $moreforfilter .= '
'; $moreforfilter .= '
'; -$includeonly = 'hierachyme'; +$includeonly = 'hierarchyme'; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } From e7096509b502400deeb70a8d99777b2669952c51 Mon Sep 17 00:00:00 2001 From: atm-steve Date: Wed, 23 Nov 2022 12:19:07 +0100 Subject: [PATCH 004/320] add project label and ref columns --- htdocs/projet/tasks/time.php | 85 ++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 0b6896260c2..cf627431483 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -77,6 +77,8 @@ $search_user = GETPOST('search_user', 'int'); $search_valuebilled = GETPOST('search_valuebilled', 'int'); $search_product_ref = GETPOST('search_product_ref', 'alpha'); $search_company = GETPOST('$search_company', 'alpha'); +$search_project_ref = GETPOST('$search_project_ref', 'alpha'); +$search_project_label = GETPOST('$search_project_label', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -168,6 +170,8 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_date_update = ''; $search_task_ref = ''; $search_company = ''; + $search_project_ref = ''; + $search_project_label = ''; $search_task_label = ''; $search_user = 0; $search_valuebilled = ''; @@ -1221,10 +1225,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $arrayfields['t.task_date'] = array('label'=>$langs->trans("Date"), 'checked'=>1); $arrayfields['p.fk_soc'] = array('label'=>$langs->trans("ThirdParty"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1','checked'=>1); if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task + if(! empty($allprojectforuser)) { + $arrayfields['p.project_ref'] = ['label' => $langs->trans('RefProject'), 'checked' => 1]; + $arrayfields['p.project_label'] = ['label' => $langs->trans('ProjectLabel'), 'checked' => 1]; + } $arrayfields['t.task_ref'] = array('label'=>$langs->trans("RefTask"), 'checked'=>1); $arrayfields['t.task_label'] = array('label'=>$langs->trans("LabelTask"), 'checked'=>1); - } - $arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1); + } + $arrayfields['author'] = array('label'=>$langs->trans("By"), 'checked'=>1); $arrayfields['t.note'] = array('label'=>$langs->trans("Note"), 'checked'=>1); if ($conf->service->enabled && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) { $arrayfields['t.fk_product'] = array('label' => $langs->trans("Product"), 'checked' => 1); @@ -1259,6 +1267,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_company != '') { $param .= '&$search_company='.urlencode($search_company); } + if ($search_project_ref != '') { + $param .= '&$search_project_ref='.urlencode($search_project_ref); + } + if ($search_project_label != '') { + $param .= '&$search_project_label='.urlencode($search_project_label); + } if ($search_task_label != '') { $param .= '&search_task_label='.urlencode($search_task_label); } @@ -1503,6 +1517,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_company) { $sql .= natural_search('s.nom', $search_company); } + if ($search_project_ref) { + $sql .= natural_search('p.ref', $search_project_ref); + } + if ($search_project_label) { + $sql .= natural_search('p.title', $search_project_label); + } if ($search_task_label) { $sql .= natural_search('pt.label', $search_task_label); } @@ -1755,7 +1775,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } if (!empty($allprojectforuser)) { - print ''; + if (!empty($arrayfields['p.project_ref']['checked'])) { + print ''; + } + if (!empty($arrayfields['p.project_label']['checked'])) { + print ''; + } } // Task if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task @@ -1814,7 +1839,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); } if (!empty($allprojectforuser)) { - print_liste_field_titre("Project", $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.project_ref']['checked'])) { + print_liste_field_titre("Project", $_SERVER['PHP_SELF'], 'p.ref', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.project_label']['checked'])) { + print_liste_field_titre("ProjectLabel", $_SERVER['PHP_SELF'], 'p.title', '', $param, '', $sortfield, $sortorder); + } } if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task if (!empty($arrayfields['t.task_ref']['checked'])) { @@ -1909,21 +1939,40 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } } - // Project ref + // Project ref & label if (!empty($allprojectforuser)) { - print ''; - if (empty($conf->cache['project'][$task_time->fk_projet])) { - $tmpproject = new Project($db); - $tmpproject->fetch($task_time->fk_projet); - $conf->cache['project'][$task_time->fk_projet] = $tmpproject; - } else { - $tmpproject = $conf->cache['project'][$task_time->fk_projet]; - } - print $tmpproject->getNomUrl(1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } + if (!empty($arrayfields['p.project_ref']['checked'])) { + print ''; + if(empty($conf->cache['project'][$task_time->fk_projet])) { + $tmpproject = new Project($db); + $tmpproject->fetch($task_time->fk_projet); + $conf->cache['project'][$task_time->fk_projet] = $tmpproject; + } + else { + $tmpproject = $conf->cache['project'][$task_time->fk_projet]; + } + print $tmpproject->getNomUrl(1); + print ''; + if(! $i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['p.project_label']['checked'])) { + print ''; + if(empty($conf->cache['project'][$task_time->fk_projet])) { + $tmpproject = new Project($db); + $tmpproject->fetch($task_time->fk_projet); + $conf->cache['project'][$task_time->fk_projet] = $tmpproject; + } + else { + $tmpproject = $conf->cache['project'][$task_time->fk_projet]; + } + print $tmpproject->title; + print ''; + if(! $i) { + $totalarray['nbfield']++; + } + } } // Task ref From 8d879eb8f580d5065330782c943b7bf8aa3cb02a Mon Sep 17 00:00:00 2001 From: atm-steve Date: Fri, 25 Nov 2022 10:24:44 +0100 Subject: [PATCH 005/320] feat: add name alias column --- htdocs/projet/tasks/time.php | 102 +++++++++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 11 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index cf627431483..e5a36f5a7aa 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -68,6 +68,14 @@ $search_month = GETPOST('search_month', 'int'); $search_year = GETPOST('search_year', 'int'); $search_datehour = ''; $search_datewithhour = ''; +$search_date_startday = GETPOST('search_date_startday', 'int'); +$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); +$search_date_startyear = GETPOST('search_date_startyear', 'int'); +$search_date_endday = GETPOST('search_date_endday', 'int'); +$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); +$search_date_endyear = GETPOST('search_date_endyear', 'int'); +$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver +$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); $search_note = GETPOST('search_note', 'alpha'); $search_duration = GETPOST('search_duration', 'int'); $search_value = GETPOST('search_value', 'int'); @@ -77,6 +85,7 @@ $search_user = GETPOST('search_user', 'int'); $search_valuebilled = GETPOST('search_valuebilled', 'int'); $search_product_ref = GETPOST('search_product_ref', 'alpha'); $search_company = GETPOST('$search_company', 'alpha'); +$search_company_alias = GETPOST('$search_company_alias', 'alpha'); $search_project_ref = GETPOST('$search_project_ref', 'alpha'); $search_project_label = GETPOST('$search_project_label', 'alpha'); @@ -168,8 +177,17 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_value = ''; $search_date_creation = ''; $search_date_update = ''; + $search_date_startday = ''; + $search_date_startmonth = ''; + $search_date_startyear = ''; + $search_date_endday = ''; + $search_date_endmonth = ''; + $search_date_endyear = ''; + $search_date_start = ''; + $search_date_end = ''; $search_task_ref = ''; $search_company = ''; + $search_company_alias = ''; $search_project_ref = ''; $search_project_label = ''; $search_task_label = ''; @@ -1224,6 +1242,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $arrayfields = array(); $arrayfields['t.task_date'] = array('label'=>$langs->trans("Date"), 'checked'=>1); $arrayfields['p.fk_soc'] = array('label'=>$langs->trans("ThirdParty"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1','checked'=>1); + $arrayfields['s.name_alias'] = array('label'=>$langs->trans("AliasNameShort"), 'type'=>'integer:Societe:/societe/class/societe.class.php:1'); if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task if(! empty($allprojectforuser)) { $arrayfields['p.project_ref'] = ['label' => $langs->trans('RefProject'), 'checked' => 1]; @@ -1267,6 +1286,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_company != '') { $param .= '&$search_company='.urlencode($search_company); } + if ($search_company_alias != '') { + $param .= '&$search_company_alias='.urlencode($search_company_alias); + } if ($search_project_ref != '') { $param .= '&$search_project_ref='.urlencode($search_project_ref); } @@ -1285,6 +1307,25 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } + if ($search_date_startday) { + $param .= '&search_date_startday='.urlencode($search_date_startday); + } + if ($search_date_startmonth) { + $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); + } + if ($search_date_startyear) { + $param .= '&search_date_startyear='.urlencode($search_date_startyear); + } + if ($search_date_endday) { + $param .= '&search_date_endday='.urlencode($search_date_endday); + } + if ($search_date_endmonth) { + $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); + } + if ($search_date_endyear) { + $param .= '&search_date_endyear='.urlencode($search_date_endyear); + } + /* // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -1474,7 +1515,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= " pt.ref, pt.label, pt.fk_projet,"; $sql .= " u.lastname, u.firstname, u.login, u.photo, u.statut as user_status,"; $sql .= " il.fk_facture as invoice_id, inv.fk_statut,"; - $sql .= " p.fk_soc,"; + $sql .= " p.fk_soc,s.name_alias,"; // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -1517,6 +1558,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_company) { $sql .= natural_search('s.nom', $search_company); } + if ($search_company_alias) { + $sql .= natural_search('s.name_alias', $search_company_alias); + } if ($search_project_ref) { $sql .= natural_search('p.ref', $search_project_ref); } @@ -1539,6 +1583,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= ' AND (t.invoice_id = 0 OR t.invoice_id IS NULL)'; } + if ($search_date_start) { + $sql .= " AND t.task_date >= '".$db->idate($search_date_start)."'"; + } + if ($search_date_end) { + $sql .= " AND t.task_date <= '".$db->idate($search_date_end)."'"; + } + $sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year); // Add where from hooks @@ -1760,20 +1811,26 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Fields title search print ''; // Date - if (!empty($arrayfields['t.task_date']['checked'])) { - print ''; - if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { - print ''; - } - print ''; - print $formother->selectyear($search_year, 'search_year', 1, 20, 5); - print ''; - } + if (!empty($arrayfields['t.task_date']['checked'])) { + print ''; + print '
'; + print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print ''; + } // Thirdparty if (!empty($arrayfields['p.fk_soc']['checked'])) { print ''; } + // Thirdparty alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + } + if (!empty($allprojectforuser)) { if (!empty($arrayfields['p.project_ref']['checked'])) { print ''; @@ -1835,9 +1892,13 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!empty($arrayfields['t.task_date']['checked'])) { print_liste_field_titre($arrayfields['t.task_date']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['p.fk_soc']['checked'])) { print_liste_field_titre($arrayfields['p.fk_soc']['label'], $_SERVER['PHP_SELF'], 't.task_date,t.task_datehour,t.rowid', '', $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER['PHP_SELF'], 's.name_alias', '', $param, '', $sortfield, $sortorder); + } if (!empty($allprojectforuser)) { if (!empty($arrayfields['p.project_ref']['checked'])) { print_liste_field_titre("Project", $_SERVER['PHP_SELF'], 'p.ref', '', $param, '', $sortfield, $sortorder); @@ -1931,7 +1992,26 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } else { $tmpsociete = $conf->cache['thridparty'][$task_time->fk_soc]; } - print $tmpsociete->getNomUrl(1); + print $tmpsociete->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Thirdparty alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if ($task_time->fk_soc > 0) { + if (empty($conf->cache['thridparty'][$task_time->fk_soc])) { + $tmpsociete = new Societe($db); + $tmpsociete->fetch($task_time->fk_soc); + $conf->cache['thridparty'][$task_time->fk_soc] = $tmpsociete; + } else { + $tmpsociete = $conf->cache['thridparty'][$task_time->fk_soc]; + } + print $tmpsociete->name_alias; } print ''; if (!$i) { From f3c257003d876c0b5749e3e4e80898054e3f8b98 Mon Sep 17 00:00:00 2001 From: atm-steve Date: Fri, 25 Nov 2022 10:53:44 +0100 Subject: [PATCH 006/320] resolve issue --- htdocs/projet/activity/permonth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/activity/permonth.php b/htdocs/projet/activity/permonth.php index 49849b362ba..273affc3563 100644 --- a/htdocs/projet/activity/permonth.php +++ b/htdocs/projet/activity/permonth.php @@ -419,7 +419,7 @@ if (!empty($conf->categorie->enabled)) // If the user can view user other than himself $moreforfilter .= '
'; $moreforfilter .= '
'; -$includeonly = 'hierarchyme'; +$includeonly = 'hierachyme'; if (empty($user->rights->user->user->lire)) { $includeonly = array($user->id); } From d3ccfeeadc789aa4ee2accaade3d1439b1774bc1 Mon Sep 17 00:00:00 2001 From: amarchal Date: Fri, 25 Nov 2022 22:12:41 +0100 Subject: [PATCH 007/320] hide private contact in thirdparty list --- htdocs/core/lib/company.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index cfd3e69a577..bc51a7884cc 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1123,6 +1123,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; $sql .= " WHERE t.fk_soc = ".((int) $object->id); + $sql .= " AND ((t.fk_user_creat = ".$user->id." AND t.priv = 1) OR t.priv = 0)"; if ($search_rowid) { $sql .= natural_search('t.rowid', $search_rowid); } From f7adbfef1663dfdfc8b923c69d260662685d2e5f Mon Sep 17 00:00:00 2001 From: amarchal Date: Fri, 25 Nov 2022 22:33:34 +0100 Subject: [PATCH 008/320] block visibility to private contact (thirdparty list / card) --- htdocs/contact/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 8e9c6f2a321..84a84321a52 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -86,6 +86,7 @@ $hookmanager->initHooks(array('contactcard', 'globalcard')); if ($id > 0) { $object->fetch($id); + $object->info($id); } if (!($object->id > 0) && $action == 'view') { @@ -101,6 +102,9 @@ $permissiontoadd = $user->rights->societe->contact->creer; if ($user->socid) { $socid = $user->socid; } +if($object->priv && $object->user_creation->id != $user->id){ + accessforbidden(); +} $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission From 1c6828e816c588d15e6e77d12f0f4b0780344c51 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 25 Nov 2022 21:36:11 +0000 Subject: [PATCH 009/320] Fixing style errors. --- htdocs/contact/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 84a84321a52..c5184a18454 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -102,7 +102,7 @@ $permissiontoadd = $user->rights->societe->contact->creer; if ($user->socid) { $socid = $user->socid; } -if($object->priv && $object->user_creation->id != $user->id){ +if ($object->priv && $object->user_creation->id != $user->id) { accessforbidden(); } $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', 0); // If we create a contact with no company (shared contacts), no check on write permission From 59ec20f549200bca9a35b6823ebbdb72c4617c15 Mon Sep 17 00:00:00 2001 From: antonin_tdj <50403308+ibuiv@users.noreply.github.com> Date: Fri, 25 Nov 2022 23:44:32 +0100 Subject: [PATCH 010/320] Fix #20685 User Id not transmitted on Api addTimeSpent Fix #20685 User Id not transmitted on Api addTimeSpent The User ID will be transmitted to the API call (if 0 then, the user will be selected from API key) --- htdocs/projet/class/api_tasks.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 49a5d9d418b..5c1dae46822 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -545,7 +545,7 @@ class Tasks extends DolibarrApi $this->task->timespent_datehour = $newdate; $this->task->timespent_withhour = 1; $this->task->timespent_duration = $duration; - $this->task->timespent_fk_user = $user_id; + $this->task->timespent_fk_user = $uid; $this->task->timespent_note = $note; $result = $this->task->addTimeSpent(DolibarrApiAccess::$user, 0); From f3e689f841c4b1a0a62779e32866d18d41f347a8 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Sat, 26 Nov 2022 00:02:17 +0100 Subject: [PATCH 011/320] FIX : Documents API inconsistency --- htdocs/api/class/api_documents.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 3b6e89c6643..ba9035a1fbe 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -462,6 +462,9 @@ class Documents extends DolibarrApi throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } + $objectType = $modulepart; + if(! empty($object->id) && ! empty($object->table_element)) $objectType = $object->table_element; + $filearray = dol_dir_list($upload_dir, $type, $recursive, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); if (empty($filearray)) { throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->ref) ? ' or Ref '.$object->ref : '').' does not return any document.'); @@ -469,11 +472,13 @@ class Documents extends DolibarrApi if (($object->id) > 0 && !empty($modulepart)) { require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmfiles.class.php'; $ecmfile = new EcmFiles($this->db); - $result = $ecmfile->fetchAll('', '', 0, 0, array('t.src_object_type' => $modulepart, 't.src_object_id' => $object->id)); + $result = $ecmfile->fetchAll('', '', 0, 0, array('t.src_object_type' => $objectType, 't.src_object_id' => $object->id)); if ($result < 0) { throw new RestException(503, 'Error when retrieve ecm list : ' . $this->db->lasterror()); } elseif (is_array($ecmfile->lines) && count($ecmfile->lines) > 0) { - $filearray['ecmfiles_infos'] = $ecmfile->lines; + for($i = 0 ; $i < count($filearray) ; $i++) { + if($filearray[$i]['name'] == $ecmfile->lines[$i]->filename) $filearray[$i] = array_merge($filearray[$i], (array) $ecmfile->lines[0]); + } } } } From 6768697497420f8cdb8b426b0581319b187c6a80 Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Sat, 26 Nov 2022 00:13:15 +0100 Subject: [PATCH 012/320] Fix #21357 --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c0ff43083eb..d1cd74099ae 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3505,7 +3505,7 @@ if ($action == 'create') { } print ''; print ''; - print ''.(!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency).' '.price(price2num($object->multicurrency_tx*$resteapayeraffiche, 'MT')).' '; + print ''.(!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency).' '.price(price2num($multicurrency_resteapayer, 'MT')).' '; } } else // Credit note { From c49e7e882fc2cf01bdcd54705e2ff11647b70712 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Sat, 26 Nov 2022 00:20:27 +0100 Subject: [PATCH 013/320] FIX#20415 --- htdocs/core/lib/project.lib.php | 12 ++++++++++++ htdocs/core/modules/modTicket.class.php | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 15162c8b273..7265ad4149c 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -207,6 +207,18 @@ function project_prepare_head(Project $project, $moreparam = '') $head[$h][2] = 'element'; $h++; } + if (!empty($conf->ticket->enabled)) { + $Tickettatic = new Ticket($db); + $nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id,'*','fk_project','ticket')); + $head[$h][0] = DOL_URL_ROOT.'/ticket/list.php?projectid='.((int) $project->id); + $head[$h][1] = $langs->trans("Ticket"); + if ($nbTicket > 0) { + $head[$h][1] .= ''.($nbTicket).''; + } + $head[$h][2] = 'ticket'; + $h++; + } + if ($conf->eventorganization->enabled && !empty($project->usage_organize_event)) { $langs->load('eventorganization'); diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 01561b40b01..8d258f63a96 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -112,7 +112,6 @@ class modTicket extends DolibarrModules $this->tabs = array( 'thirdparty:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?socid=__ID__', - 'project:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?projectid=__ID__', ); // Dictionaries From 9852d470ec5c2ad8d1b9fd7a055d9684ec9c69e6 Mon Sep 17 00:00:00 2001 From: antonin_tdj <50403308+ibuiv@users.noreply.github.com> Date: Sat, 26 Nov 2022 00:23:29 +0100 Subject: [PATCH 014/320] Fix #20533 Dispatch Tab Quantity Fix #20533 Dispatch Tab Total Quantity now considers services (and the configuration option to manage stocks on services) --- htdocs/core/lib/fourn.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 8ba05557220..b4b116c5c6b 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -178,7 +178,10 @@ function ordersupplier_prepare_head(CommandeFournisseur $object) $sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty']; } for ($line = 0 ; $line < $nbLinesOrdered; $line++) { - $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty; + //If line is a product of conf to manage stocks for services + if($object->lines[$line]->product_type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)){ + $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty; + } } $head[$h][1] .= ''.price2num($sumQtyAllreadyDispatched, 'MS').' / '.price2num($sumQtyOrdered, 'MS').''; } From ebae1c024f66d76a77df7d90b6d69be5644d8d50 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 25 Nov 2022 23:24:17 +0000 Subject: [PATCH 015/320] Fixing style errors. --- htdocs/core/lib/fourn.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index b4b116c5c6b..93ac290e08c 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -179,7 +179,7 @@ function ordersupplier_prepare_head(CommandeFournisseur $object) } for ($line = 0 ; $line < $nbLinesOrdered; $line++) { //If line is a product of conf to manage stocks for services - if($object->lines[$line]->product_type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)){ + if ($object->lines[$line]->product_type == 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty; } } From 99a34e23c87ee1c22654fc576924a596ddf21e4a Mon Sep 17 00:00:00 2001 From: Mathieu Date: Sat, 26 Nov 2022 00:33:23 +0100 Subject: [PATCH 016/320] FIX#20415 --- htdocs/core/lib/project.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 7265ad4149c..4b41ddf67e1 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -209,7 +209,7 @@ function project_prepare_head(Project $project, $moreparam = '') } if (!empty($conf->ticket->enabled)) { $Tickettatic = new Ticket($db); - $nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id,'*','fk_project','ticket')); + $nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id, '*', 'fk_project', 'ticket')); $head[$h][0] = DOL_URL_ROOT.'/ticket/list.php?projectid='.((int) $project->id); $head[$h][1] = $langs->trans("Ticket"); if ($nbTicket > 0) { From a0553c6e5253e589fbf538c5cd678548b8534620 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Sat, 26 Nov 2022 00:35:08 +0100 Subject: [PATCH 017/320] FIX : Stickler --- htdocs/api/class/api_documents.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index ba9035a1fbe..88c5ecd604c 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -463,7 +463,7 @@ class Documents extends DolibarrApi } $objectType = $modulepart; - if(! empty($object->id) && ! empty($object->table_element)) $objectType = $object->table_element; + if (! empty($object->id) && ! empty($object->table_element)) $objectType = $object->table_element; $filearray = dol_dir_list($upload_dir, $type, $recursive, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); if (empty($filearray)) { @@ -476,8 +476,8 @@ class Documents extends DolibarrApi if ($result < 0) { throw new RestException(503, 'Error when retrieve ecm list : ' . $this->db->lasterror()); } elseif (is_array($ecmfile->lines) && count($ecmfile->lines) > 0) { - for($i = 0 ; $i < count($filearray) ; $i++) { - if($filearray[$i]['name'] == $ecmfile->lines[$i]->filename) $filearray[$i] = array_merge($filearray[$i], (array) $ecmfile->lines[0]); + for ($i = 0 ; $i < count($filearray); $i++) { + if ($filearray[$i]['name'] == $ecmfile->lines[$i]->filename) $filearray[$i] = array_merge($filearray[$i], (array) $ecmfile->lines[0]); } } } From e767c9b4a98427ead0204d2933d6391f934b8cf0 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Sat, 26 Nov 2022 00:42:50 +0100 Subject: [PATCH 018/320] FIX : Stickler --- htdocs/api/class/api_documents.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 88c5ecd604c..197ca42469d 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -476,7 +476,8 @@ class Documents extends DolibarrApi if ($result < 0) { throw new RestException(503, 'Error when retrieve ecm list : ' . $this->db->lasterror()); } elseif (is_array($ecmfile->lines) && count($ecmfile->lines) > 0) { - for ($i = 0 ; $i < count($filearray); $i++) { + $count = count($filearray); + for ($i = 0 ; $i < $count ; $i++) { if ($filearray[$i]['name'] == $ecmfile->lines[$i]->filename) $filearray[$i] = array_merge($filearray[$i], (array) $ecmfile->lines[0]); } } From 616e2b79efb0381377190ccdd1fe9dfee48cd876 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Sat, 26 Nov 2022 00:50:45 +0100 Subject: [PATCH 019/320] fix #22766: better API response HTTP code --- htdocs/adherents/class/api_members.class.php | 10 +++++++--- .../adherents/class/api_memberstypes.class.php | 9 ++++++--- .../adherents/class/api_subscriptions.class.php | 9 ++++++--- htdocs/product/class/api_products.class.php | 14 +++++++++++++- htdocs/societe/class/api_thirdparties.class.php | 17 ++++++++++++++++- htdocs/user/class/api_users.class.php | 13 ++++++++++++- 6 files changed, 60 insertions(+), 12 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index d57a01510d4..f5efbd8582e 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -382,14 +382,18 @@ class Members extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$member->delete($member->id, DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when deleting member'); + + $res = $member->delete($member->id, DolibarrApiAccess::$user); + if($res < 0) { + throw new RestException(500, "Can't delete, error occurs"); + }elseif($res == 0) { + throw new RestException(409, "Can't delete, that product is probably used"); } return array( 'success' => array( 'code' => 200, - 'message' => 'member deleted' + 'message' => 'Member deleted' ) ); } diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index b02a81dc5c9..a4ce0ddf1f4 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -228,14 +228,17 @@ class MembersTypes extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$membertype->delete()) { - throw new RestException(401, 'error when deleting member type'); + $res = $membertype->delete(); + if($res < 0) { + throw new RestException(500, "Can't delete, error occurs"); + }elseif($res == 0) { + throw new RestException(409, "Can't delete, that product is probably used"); } return array( 'success' => array( 'code' => 200, - 'message' => 'member type deleted' + 'message' => 'Member type deleted' ) ); } diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 831be2882f1..1cada6c7f3e 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -214,14 +214,17 @@ class Subscriptions extends DolibarrApi throw new RestException(404, 'Subscription not found'); } - if (!$subscription->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when deleting subscription'); + $res = $subscription->delete(DolibarrApiAccess::$user); + if($res < 0) { + throw new RestException(500, "Can't delete, error occurs"); + }elseif($res == 0) { + throw new RestException(409, "Can't delete, that product is probably used"); } return array( 'success' => array( 'code' => 200, - 'message' => 'subscription deleted' + 'message' => 'Subscription deleted' ) ); } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 6283b692a28..b3dd2c019df 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -435,7 +435,19 @@ class Products extends DolibarrApi global $user; $user = DolibarrApiAccess::$user; - return $this->product->delete(DolibarrApiAccess::$user); + $res = $this->product->delete(DolibarrApiAccess::$user); + if($res < 0) { + throw new RestException(500, "Can't delete, error occurs"); + }elseif($res == 0) { + throw new RestException(409, "Can't delete, that product is probably used"); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Object deleted' + ) + ); } /** diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 0257b692b62..4646175878c 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -525,7 +525,22 @@ class Thirdparties extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->company->oldcopy = clone $this->company; - return $this->company->delete($id); + + $res = $this->company->delete($id); + if($res < 0) { + throw new RestException(500, "Can't delete, error occurs"); + }elseif($res == 0) { + throw new RestException(409, "Can't delete, that product is probably used"); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Object deleted' + ) + ); + + } /** diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index e0cbd849092..83cd88f8ade 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -628,7 +628,18 @@ class Users extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->useraccount->oldcopy = clone $this->useraccount; - return $this->useraccount->delete(DolibarrApiAccess::$user); + + if (!$this->useraccount->delete(DolibarrApiAccess::$user)) { + throw new RestException(500); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Ticket deleted' + ) + ); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From 3fd81293a389cb8e0ad2fa3a98ac624da8b43424 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 25 Nov 2022 23:57:35 +0000 Subject: [PATCH 020/320] Fixing style errors. --- htdocs/adherents/class/api_members.class.php | 4 ++-- htdocs/adherents/class/api_memberstypes.class.php | 4 ++-- htdocs/adherents/class/api_subscriptions.class.php | 4 ++-- htdocs/product/class/api_products.class.php | 4 ++-- htdocs/societe/class/api_thirdparties.class.php | 6 ++---- htdocs/user/class/api_users.class.php | 1 - 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index f5efbd8582e..9038ada74d3 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -384,9 +384,9 @@ class Members extends DolibarrApi $res = $member->delete($member->id, DolibarrApiAccess::$user); - if($res < 0) { + if ($res < 0) { throw new RestException(500, "Can't delete, error occurs"); - }elseif($res == 0) { + } elseif ($res == 0) { throw new RestException(409, "Can't delete, that product is probably used"); } diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index a4ce0ddf1f4..eb561ff6c60 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -229,9 +229,9 @@ class MembersTypes extends DolibarrApi } $res = $membertype->delete(); - if($res < 0) { + if ($res < 0) { throw new RestException(500, "Can't delete, error occurs"); - }elseif($res == 0) { + } elseif ($res == 0) { throw new RestException(409, "Can't delete, that product is probably used"); } diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 1cada6c7f3e..b3871cb08d6 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -215,9 +215,9 @@ class Subscriptions extends DolibarrApi } $res = $subscription->delete(DolibarrApiAccess::$user); - if($res < 0) { + if ($res < 0) { throw new RestException(500, "Can't delete, error occurs"); - }elseif($res == 0) { + } elseif ($res == 0) { throw new RestException(409, "Can't delete, that product is probably used"); } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index b3dd2c019df..445387fb2b5 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -436,9 +436,9 @@ class Products extends DolibarrApi $user = DolibarrApiAccess::$user; $res = $this->product->delete(DolibarrApiAccess::$user); - if($res < 0) { + if ($res < 0) { throw new RestException(500, "Can't delete, error occurs"); - }elseif($res == 0) { + } elseif ($res == 0) { throw new RestException(409, "Can't delete, that product is probably used"); } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 4646175878c..27da78e9456 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -527,9 +527,9 @@ class Thirdparties extends DolibarrApi $this->company->oldcopy = clone $this->company; $res = $this->company->delete($id); - if($res < 0) { + if ($res < 0) { throw new RestException(500, "Can't delete, error occurs"); - }elseif($res == 0) { + } elseif ($res == 0) { throw new RestException(409, "Can't delete, that product is probably used"); } @@ -539,8 +539,6 @@ class Thirdparties extends DolibarrApi 'message' => 'Object deleted' ) ); - - } /** diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 83cd88f8ade..0acfe30d279 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -639,7 +639,6 @@ class Users extends DolibarrApi 'message' => 'Ticket deleted' ) ); - } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From b98eaa4d45a615ac1700cd2af2cc57a4ea342d21 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Sat, 26 Nov 2022 01:01:22 +0100 Subject: [PATCH 021/320] #FIX: #22509 default value on integer fields don't retrieve by setSaveQuery --- htdocs/core/class/commonobject.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0fb5bcedae0..3e10ea82eaa 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8829,7 +8829,11 @@ abstract class CommonObject // $this->{$field} may be null, '', 0, '0', 123, '123' if ((isset($this->{$field}) && $this->{$field} != '') || !empty($info['notnull'])) { if (!isset($this->{$field})) { - $queryarray[$field] = 0; + if (!empty($info['default'])) { + $queryarray[$field] = $info['default']; + } else { + $queryarray[$field] = 0; + } } else { $queryarray[$field] = (int) $this->{$field}; // If '0', it may be set to null later if $info['notnull'] == -1 } From 7a8c35baa75a8ff92cc7949f064ef697b4f53ff8 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sat, 26 Nov 2022 01:33:11 +0100 Subject: [PATCH 022/320] FIX Negative consumption in MO creates additional goods issue #21343 --- htdocs/mrp/mo_production.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 64ae11909ef..7bff43bfc7b 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -220,7 +220,7 @@ if (empty($reshook)) { if ($qtytoprocess >= 0) { $idstockmove = $stockmove->livraison($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); } else { - $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); + $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess * -1, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); } if ($idstockmove < 0) { $error++; From 5b53d1c5cf606af5be5e245289061ae5847dffcd Mon Sep 17 00:00:00 2001 From: antonin_tdj <50403308+ibuiv@users.noreply.github.com> Date: Sat, 26 Nov 2022 09:30:40 +0100 Subject: [PATCH 023/320] add cast to avoid sql injection (eldy asked) add cast to avoid sql injection (eldy asked) --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index bc51a7884cc..51106b8568d 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1123,7 +1123,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; $sql .= " WHERE t.fk_soc = ".((int) $object->id); - $sql .= " AND ((t.fk_user_creat = ".$user->id." AND t.priv = 1) OR t.priv = 0)"; + $sql .= " AND ((t.fk_user_creat = ".(int) $user->id." AND t.priv = 1) OR t.priv = 0)"; if ($search_rowid) { $sql .= natural_search('t.rowid', $search_rowid); } From cd94e42291472555a662bdd006dcb44f0f573d4a Mon Sep 17 00:00:00 2001 From: antonin_tdj <50403308+ibuiv@users.noreply.github.com> Date: Sat, 26 Nov 2022 09:32:10 +0100 Subject: [PATCH 024/320] add parenthesis --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 51106b8568d..8629e3e59d1 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1123,7 +1123,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)"; $sql .= " WHERE t.fk_soc = ".((int) $object->id); - $sql .= " AND ((t.fk_user_creat = ".(int) $user->id." AND t.priv = 1) OR t.priv = 0)"; + $sql .= " AND ((t.fk_user_creat = ".((int) $user->id)." AND t.priv = 1) OR t.priv = 0)"; if ($search_rowid) { $sql .= natural_search('t.rowid', $search_rowid); } From 60257cec096cf2ec82d724cc0568c85f947607a1 Mon Sep 17 00:00:00 2001 From: Delthair <41671350+Delthair@users.noreply.github.com> Date: Sat, 26 Nov 2022 10:06:39 +0100 Subject: [PATCH 025/320] Fix #22998 Disabled module before delete (modulebuilder) Ensure that the module is disabled before delete --- htdocs/modulebuilder/index.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 538b1cac290..91f038983f6 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1642,6 +1642,34 @@ if ($dirins && $action == 'confirm_deletemodule') { // Dir for module $dir = $dirins.'/'.$modulelowercase; + + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + + // Dir for module + $dir = dol_buildpath($modulelowercase, 0); + + // Zip file to build + $FILENAMEZIP = ''; + + // Load module + dol_include_once($pathtofile); + $class = 'mod'.$module; + + if (class_exists($class)) { + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } else { + $error++; + $langs->load("errors"); + dol_print_error($db, $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); + exit; + } + + $moduleobj->remove(); $result = dol_delete_dir_recursive($dir); From c8090a03613d433bb28dac7655463004494f61b3 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 26 Nov 2022 10:13:48 +0000 Subject: [PATCH 026/320] Fixing style errors. --- htdocs/modulebuilder/index.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 91f038983f6..de3059b264f 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1642,10 +1642,10 @@ if ($dirins && $action == 'confirm_deletemodule') { // Dir for module $dir = $dirins.'/'.$modulelowercase; - + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; - // Dir for module + // Dir for module $dir = dol_buildpath($modulelowercase, 0); // Zip file to build @@ -1668,8 +1668,8 @@ if ($dirins && $action == 'confirm_deletemodule') { dol_print_error($db, $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); exit; } - - $moduleobj->remove(); + + $moduleobj->remove(); $result = dol_delete_dir_recursive($dir); From 4a0822ef2cb46beaac22ea921abb250f5e770e25 Mon Sep 17 00:00:00 2001 From: hystepik Date: Sat, 26 Nov 2022 12:21:50 +0100 Subject: [PATCH 027/320] Fix : fatal error in adherent/agenda.php --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index cfd3e69a577..037dda8d135 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1896,7 +1896,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) { $labeltype = 'AC_OTH'; } - if (preg_mach('/^TICKET_MSG/', $actionstatic->code)) { + if (preg_match('/^TICKET_MSG/', $actionstatic->code)) { $labeltype = $langs->trans("Message"); } else { if (!empty($arraylist[$labeltype])) { From 7017b37354a8a0820eafc0eb46a4d19a22eef67b Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sat, 26 Nov 2022 16:28:58 +0100 Subject: [PATCH 028/320] FIX product_type 9 --- htdocs/compta/facture/class/facture-rec.class.php | 4 ++-- htdocs/delivery/class/delivery.class.php | 2 +- htdocs/expensereport/class/expensereport.class.php | 10 +++++----- htdocs/fourn/class/fournisseur.commande.class.php | 6 +++--- htdocs/fourn/class/fournisseur.facture.class.php | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 8306a5c9c0d..9d0a8212ba5 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -992,7 +992,7 @@ class FactureRec extends CommonInvoice if ($this->db->query($sql)) { $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX."facturedet_rec"); $this->id = $facid; - $this->update_price(); + $this->update_price(1); return $lineId; } else { $this->error = $this->db->lasterror(); @@ -1166,7 +1166,7 @@ class FactureRec extends CommonInvoice dol_syslog(get_class($this)."::updateline", LOG_DEBUG); if ($this->db->query($sql)) { $this->id = $facid; - $this->update_price(); + $this->update_price(1); return 1; } else { $this->error = $this->db->lasterror(); diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 6bfe3a33dd7..e7ccffd45af 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -634,7 +634,7 @@ class Delivery extends CommonObject $sql .= " WHERE rowid = ".((int) $lineid); if ($this->db->query($sql)) { - $this->update_price(); + $this->update_price(1); return 1; } else { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 3f62087dd0b..8d8de8a9d5a 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -359,7 +359,7 @@ class ExpenseReport extends CommonObject } if (!$error) { - $result = $this->update_price(); + $result = $this->update_price(1); if ($result > 0) { if (!$notrigger) { // Call trigger @@ -1841,7 +1841,7 @@ class ExpenseReport extends CommonObject $result = $this->line->insert(0, true); if ($result > 0) { - $result = $this->update_price(); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + $result = $this->update_price(1); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); return $this->line->id; @@ -2180,7 +2180,7 @@ class ExpenseReport extends CommonObject return -1; } - $this->update_price(); + $this->update_price(1); $this->db->commit(); @@ -2747,7 +2747,7 @@ class ExpenseReportLine if (!$fromaddline) { $tmpparent = new ExpenseReport($this->db); $tmpparent->fetch($this->fk_expensereport); - $result = $tmpparent->update_price(); + $result = $tmpparent->update_price(1); if ($result < 0) { $error++; $this->error = $tmpparent->error; @@ -2874,7 +2874,7 @@ class ExpenseReportLine $tmpparent = new ExpenseReport($this->db); $result = $tmpparent->fetch($this->fk_expensereport); if ($result > 0) { - $result = $tmpparent->update_price(); + $result = $tmpparent->update_price(1); if ($result < 0) { $error++; $this->error = $tmpparent->error; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e78dd9dd02a..d7d9cb26194 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2067,7 +2067,7 @@ class CommandeFournisseur extends CommonOrder } if ($line->delete($notrigger) > 0) { - $this->update_price(); + $this->update_price(1); return 1; } else { $this->error = $line->error; @@ -2564,7 +2564,7 @@ class CommandeFournisseur extends CommonOrder $sql .= ", ".$comclient->lines[$i]->qty.", ".$comclient->lines[$i]->tva_tx.", ".$comclient->lines[$i]->localtax1_tx.", ".$comclient->lines[$i]->localtax2_tx.", ".$comclient->lines[$i]->remise_percent; $sql .= ", '".price2num($comclient->lines[$i]->subprice)."','0', '".$this->db->escape($ref)."');"; if ($this->db->query($sql)) { - $this->update_price(); + $this->update_price(1); } } @@ -2817,7 +2817,7 @@ class CommandeFournisseur extends CommonOrder // Mise a jour info denormalisees au niveau facture if ($result >= 0) { - $this->update_price('', 'auto'); + $this->update_price('1', 'auto'); $this->db->commit(); return $result; } else { diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c4635962368..c8036b5610d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -590,7 +590,7 @@ class FactureFournisseur extends CommonInvoice } // Update total price - $result = $this->update_price(); + $result = $this->update_price(1); if ($result > 0) { // Actions on extra fields if (!$error) { @@ -2192,7 +2192,7 @@ class FactureFournisseur extends CommonInvoice $this->errors[] = $line->error; } else { // Update total price into invoice record - $res = $this->update_price('', 'auto', 0, $this->thirdparty); + $res = $this->update_price('1', 'auto', 0, $this->thirdparty); } return $res; @@ -2239,7 +2239,7 @@ class FactureFournisseur extends CommonInvoice $this->db->rollback(); return -3; } else { - $res = $this->update_price(); + $res = $this->update_price(1); if ($res > 0) { $this->db->commit(); From c1b355fcac04df23c7d31d46dc520d227cf8e73d Mon Sep 17 00:00:00 2001 From: hystepik Date: Sun, 27 Nov 2022 00:44:05 +0100 Subject: [PATCH 029/320] Fix : php 8.1 warnings --- htdocs/comm/action/card.php | 2 +- htdocs/compta/bank/bankentries_list.php | 1 + .../class/bonprelevement.class.php | 4 +- htdocs/core/lib/modulebuilder.lib.php | 2 +- htdocs/hrm/skill_card.php | 2 +- htdocs/modulebuilder/index.php | 2 +- htdocs/reception/card.php | 2 +- htdocs/stripe/charge.php | 298 +++++++++--------- 8 files changed, 158 insertions(+), 155 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 7788c72ea59..9a8c59b8533 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1253,7 +1253,7 @@ if ($action == 'create') { print $langs->trans("DayOfWeek").': '; print '
'; // limit date - $repeateventlimitdate = $repeateventlimitdate ? $repeateventlimitdate : ''; + $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate : ''; print '