From 4a17250bd9c09964856fc3a66472cac76c821736 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 23 Jan 2024 15:51:07 +0100 Subject: [PATCH 1/4] NEW filter on sale representative in contact list --- htdocs/contact/list.php | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index cacc80be90f..f238207fcba 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -97,6 +97,7 @@ if (isModEnabled('socialnetworks')) { } } $search_priv = GETPOST("search_priv", 'alpha'); +$search_sale = GETPOSTINT('search_sale'); $search_categ = GETPOST("search_categ", 'int'); $search_categ_thirdparty = GETPOST("search_categ_thirdparty", 'int'); $search_categ_supplier = GETPOST("search_categ_supplier", 'int'); @@ -383,6 +384,7 @@ if (empty($reshook)) { $search_stcomm = ''; $search_level = ''; $search_status = -1; + $search_sale = ''; $search_categ = ''; $search_categ_thirdparty = ''; $search_categ_supplier = ''; @@ -416,6 +418,10 @@ if (empty($reshook)) { if ($search_priv < 0) { $search_priv = ''; } +// the user has not right to see other third-party than their own +if (!$user->hasRight('societe', 'client', 'voir')) { + $search_sale = $user->id; +} /* @@ -495,18 +501,12 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact"; -if (!$user->hasRight('societe', 'client', 'voir')) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; -} // Add fields from hooks - ListFrom $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= ' WHERE p.entity IN ('.getEntity('contact').')'; -if (!$user->hasRight('societe', 'client', 'voir')) { - $sql .= " AND (sc.fk_user = ".((int) $user->id)." OR p.fk_soc IS NULL)"; -} if (!empty($userid)) { // propre au commercial $sql .= " AND p.fk_user_creat=".((int) $userid); } @@ -529,6 +529,14 @@ if ($search_priv != '0' && $search_priv != '1') { } } +// Search on sale representative +if (!empty($search_sale) && $search_sale != '-1') { + if ($search_sale == -2) { + $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc)"; + } elseif ($search_sale > 0) { + $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_soc = p.fk_soc AND sc.fk_user = ".((int) $search_sale).")"; + } +} // Search Contact Categories $searchCategoryContactList = $search_categ ? array($search_categ) : array(); @@ -823,6 +831,9 @@ if ($optioncss != '') { } $param .= '&begin='.urlencode($begin).'&userid='.urlencode($userid).'&contactname='.urlencode($search_all); $param .= '&type='.urlencode($type).'&view='.urlencode($view); +if (!empty($search_sale) && $search_sale != '-1') { + $param .= '&search_sale='.urlencode($search_sale); +} if (!empty($search_categ) && $search_categ != '-1') { $param .= '&search_categ='.urlencode($search_categ); } @@ -981,6 +992,16 @@ if ($search_firstlast_only) { } $moreforfilter = ''; + +// If the user can view third-party other than their own +if ($user->hasRight('societe', 'client', 'voir')) { + $langs->load('commercial'); + $moreforfilter .= '
'; + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx', 1); + $moreforfilter .= '
'; +} + if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $moreforfilter .= '
'; From d657c2d5eef32141db402352e0638de424a657b5 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 23 Jan 2024 16:12:20 +0100 Subject: [PATCH 2/4] Fix precommit --- htdocs/accountancy/bookkeeping/export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index f35cad6c18f..2695eac0444 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -644,7 +644,7 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements // TODO Merge update for each line into one global using rowid IN (list of movement ids) foreach ($object->lines as $movement) { - // Upate the line to set date_export and/or date_validated (if not already set !) + // Update the line to set date_export and/or date_validated (if not already set !) $now = dol_now(); $setfields = ''; From cad122cf081f5abdf2413e88813ca302a78673f7 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 23 Jan 2024 17:03:34 +0100 Subject: [PATCH 3/4] Fix dol_fiche_end --- htdocs/admin/expensereport_rules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 8fbf0edb9a7..639fcf50077 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -242,7 +242,7 @@ if ($action == 'edit') { echo ''; } -print dol_fiche_end(); +print dol_get_fiche_end(); echo ''; From 102df27061ea972f3fe45356d147896c452659df Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 23 Jan 2024 17:13:15 +0100 Subject: [PATCH 4/4] Fix precommit --- htdocs/modulebuilder/template/admin/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index d843de8a342..d23368dbfc2 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -102,7 +102,7 @@ $item->cssClass = 'minwidth500'; // Setup conf for selection of a simple string input $item = $formSetup->newItem('MYMODULE_MYPARAM2'); $item->defaultFieldValue = 'default value'; -$item->fieldAttr['placeholder'] = 'A placehoder here'; +$item->fieldAttr['placeholder'] = 'A placeholder here'; // Setup conf for selection of a simple textarea input but we replace the text of field title $item = $formSetup->newItem('MYMODULE_MYPARAM3');