From 416c809f742a5f919ef176665695d88bde2e0c94 Mon Sep 17 00:00:00 2001 From: atm-steve Date: Tue, 22 Nov 2022 15:05:24 +0100 Subject: [PATCH 01/12] 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 02/12] 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 03/12] 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 04/12] 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 05/12] 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 06/12] 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 07/12] 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 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 08/12] 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 09/12] 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 745d95e48dc44d53fbc3f7dff817ac2d919c9057 Mon Sep 17 00:00:00 2001 From: kkhelifa Date: Mon, 28 Nov 2022 12:15:21 +0100 Subject: [PATCH 10/12] FIX: fix recruitment ODT template --- .../doc/doc_generic_recruitmentjobposition_odt.modules.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index c86713ffb93..38e1ead836e 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -28,6 +28,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/recruitment/core/modules/recruitment/modules_recruitmentjobposition.php'; +require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -238,7 +239,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi // If $object is id instead of object if (!is_object($object)) { $id = $object; - $object = new Commande($this->db); + $object = new RecruitmentJobPosition($this->db); $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -339,7 +340,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $odfHandler = new odf( $srctemplatepath, array( - 'PATH_TO_TMP' => $conf->commande->dir_temp, + 'PATH_TO_TMP' => $conf->recruitment->dir_temp, 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' From 95f0881ddc3df63ecee5bab5354d7a189faa7d51 Mon Sep 17 00:00:00 2001 From: hystepik Date: Mon, 28 Nov 2022 15:07:25 +0100 Subject: [PATCH 11/12] Fix : Missing closing of a div --- htdocs/public/eventorganization/attendee_new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index 21901753692..e5f03d7fadb 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -819,7 +819,7 @@ if ((!empty($conference->id) && $conference->status == ConferenceOrBooth::STATUS print ''; // Country - print 'trans('Country') . ''; + print ''.$langs->trans('Country').''; print img_picto('', 'country', 'class="pictofixedwidth"'); $country_id = GETPOST('country_id'); if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) { From e2b2b30320b050a127984882fec67c21c01b4e55 Mon Sep 17 00:00:00 2001 From: hystepik Date: Mon, 28 Nov 2022 16:49:58 +0100 Subject: [PATCH 12/12] fix : php8.1 warnings --- htdocs/opensurvey/card.php | 2 +- htdocs/opensurvey/class/opensurveysondage.class.php | 4 ++-- htdocs/opensurvey/exportcsv.php | 7 +++++-- htdocs/opensurvey/list.php | 9 +++++---- htdocs/opensurvey/results.php | 2 +- htdocs/public/opensurvey/studs.php | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index b243b8c8342..36c5b2ea07d 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -209,7 +209,7 @@ $toutsujet = explode(",", $object->sujet); $listofanswers = array(); foreach ($toutsujet as $value) { $tmp = explode('@', $value); - $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); + $listofanswers[] = array('label'=>$tmp[0], 'format'=>(!empty($tmp[1]) ? $tmp[1] : 'checkbox')); } $toutsujet = str_replace("@", "
", $toutsujet); $toutsujet = str_replace("°", "'", $toutsujet); diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index b7fadbdb60d..8848af12629 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -274,7 +274,7 @@ class Opensurveysondage extends CommonObject $this->sujet = $obj->sujet; $this->fk_user_creat = $obj->fk_user_creat; - $this->date_m = $this->db->jdate($obj->tls); + $this->date_m = $this->db->jdate(!empty($obj->tls) ? $obj->tls : ""); $ret = 1; } else { $sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey); @@ -686,7 +686,7 @@ class Opensurveysondage extends CommonObject { $result = 0; - $sql .= " SELECT COUNT(id_users) as nb FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql = " SELECT COUNT(id_users) as nb FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; $sql .= " WHERE id_sondage = '".$this->db->escape($this->ref)."'"; $resql = $this->db->query($sql); diff --git a/htdocs/opensurvey/exportcsv.php b/htdocs/opensurvey/exportcsv.php index a7e8b709793..1e9005b6af4 100644 --- a/htdocs/opensurvey/exportcsv.php +++ b/htdocs/opensurvey/exportcsv.php @@ -63,9 +63,9 @@ $now = dol_now(); $nbcolonnes = substr_count($object->sujet, ',') + 1; $toutsujet = explode(",", $object->sujet); - +$somme = array(); // affichage des sujets du sondage -$input .= $langs->trans("Name").";"; +$input = $langs->trans("Name").";"; for ($i = 0; $toutsujet[$i]; $i++) { if ($object->format == "D") { $input .= ''.dol_print_date($toutsujet[$i], 'dayhour').';'; @@ -105,6 +105,9 @@ if ($resql) { //affichage des resultats $ensemblereponses = $obj->reponses; for ($k = 0; $k < $nbcolonnes; $k++) { + if (empty($somme[$k])) { + $somme[$k] = 0; + } $car = substr($ensemblereponses, $k, 1); if ($car == "1") { $input .= 'OK;'; diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index e03ee278574..626499e2412 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -40,6 +40,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'opensurveylist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $id = GETPOST('id', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); @@ -175,16 +176,16 @@ $sql .= " WHERE p.entity IN (".getEntity('survey').")"; if ($search_status != '-1' && $search_status != '') { $sql .= natural_search("p.status", $search_status, 2); } -if ($search_expired == 'expired') { +if (!empty($search_expired) && $search_expired == 'expired') { $sql .= " AND p.date_fin < '".$db->idate($now)."'"; } -if ($search_expired == 'opened') { +if (!empty($search_expired) && $search_expired == 'opened') { $sql .= " AND p.date_fin >= '".$db->idate($now)."'"; } -if ($search_ref) { +if (!empty($search_ref)) { $sql .= natural_search("p.id_sondage", $search_ref); } -if ($search_title) { +if (!empty($search_title)) { $sql .= natural_search("p.titre", $search_title); } // Add where from extra fields diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index f8a2648a809..bedec1eb1aa 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -435,7 +435,7 @@ $toutsujet = explode(",", $object->sujet); $listofanswers = array(); foreach ($toutsujet as $value) { $tmp = explode('@', $value); - $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); + $listofanswers[] = array('label'=>$tmp[0], 'format'=>(!empty($tmp[1]) ? $tmp[1] : 'checkbox')); } $toutsujet = str_replace("@", "
", $toutsujet); $toutsujet = str_replace("°", "'", $toutsujet); diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 900483bbbfa..b6708a5b5f6 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -319,7 +319,7 @@ $toutsujet = explode(",", $object->sujet); $listofanswers = array(); foreach ($toutsujet as $value) { $tmp = explode('@', $value); - $listofanswers[] = array('label'=>$tmp[0], 'format'=>($tmp[1] ? $tmp[1] : 'checkbox')); + $listofanswers[] = array('label'=>$tmp[0], 'format'=>(!empty($tmp[1]) ? $tmp[1] : 'checkbox')); } $toutsujet = str_replace("°", "'", $toutsujet);