From 009588e04d69ddfe8caae2197e4c26b9a656857b Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 14 May 2021 11:02:55 +0200 Subject: [PATCH 01/11] fix implode on string for formproduct loadwarehouse --- htdocs/product/class/html.formproduct.class.php | 14 +++++--------- htdocs/product/stock/stockatdate.php | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index a5f28c50ee8..69429677c27 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -66,13 +66,13 @@ class FormProduct * 'warehouseclosed' = select products from closed warehouses, * 'warehouseinternal' = select products from warehouses for internal correct/transfer only * @param boolean $sumStock sum total stock of a warehouse, default true - * @param string $exclude warehouses ids to exclude + * @param array $exclude warehouses ids to exclude * @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by * @return int Nb of loaded lines, 0 if already loaded, <0 if KO * @throws Exception */ - public function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '', $stockMin = false, $orderBy = 'e.ref') + public function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = array(), $stockMin = false, $orderBy = 'e.ref') { global $conf, $langs; @@ -80,10 +80,6 @@ class FormProduct return 0; // Cache already loaded and we do not want a list with information specific to a product } - if (is_array($exclude)) { - $excludeGroups = implode("','", $exclude); - } - $warehouseStatus = array(); if (preg_match('/warehouseclosed/', $status)) { @@ -121,7 +117,7 @@ class FormProduct $sql .= " AND e.statut = 1"; } - if (!empty($exclude)) { + if (is_array($exclude) && !empty($exclude)) { $sql .= ' AND e.rowid NOT IN('.$this->db->sanitize(implode(',', $exclude)).')'; } @@ -220,7 +216,7 @@ class FormProduct * @param int $forcecombo 1=Force combo iso ajax select2 * @param array $events Events to add to select2 * @param string $morecss Add more css classes to HTML select - * @param string $exclude Warehouses ids to exclude + * @param array $exclude Warehouses ids to exclude * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse * @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by @@ -228,7 +224,7 @@ class FormProduct * * @throws Exception */ - public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1, $stockMin = false, $orderBy = 'e.ref') + public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = array(), $showfullpath = 1, $stockMin = false, $orderBy = 'e.ref') { global $conf, $langs, $user, $hookmanager; diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 788c75f1141..b36d530d624 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -363,7 +363,7 @@ print $form->select_produits($productid, 'productid', '', 0, 0, -1, 2, '', 0, ar print '   '; print img_picto('', 'stock').' '; print $langs->trans('Warehouse').' '; -print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? $fk_warehouse : 'ifone'), 'fk_warehouse', '', 1, 0, 0, '', 0, 0, null, '', '', 1, false, 'e.ref'); +print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? $fk_warehouse : 'ifone'), 'fk_warehouse', '', 1, 0, 0, '', 0, 0, null, '', null, 1, false, 'e.ref'); print ''; $parameters = array(); From cff0b69ce052258f1bbc3a4870c1ad32ba2f4a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 14 May 2021 18:30:56 +0200 Subject: [PATCH 02/11] avoid sql error with sql_mode=only_full_group_by SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM llx_societe as s, llx_contrat as t, llx_contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (2) AND t.entity IN (1)[DB_ERROR_1140] In aggregated query without GROUP BY, expression #4 of SELECT list contains nonaggregated column 'dolibarrdev.t.rowid'; this is incompatible with sql_mode=only_full_group_by --- htdocs/core/class/html.form.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 625e8e23d57..a0846b2b3ed 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7692,8 +7692,12 @@ class Form 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande').')'), 'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('invoice').')'), 'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('invoice').')'), - 'contrat'=>array('enabled'=>$conf->contrat->enabled, 'perms'=>1, 'label'=>'LinkToContract', - 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').')'), + 'contrat'=>array( + 'enabled'=>$conf->contrat->enabled, + 'perms'=>1, + 'label'=>'LinkToContract', + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY t.rowid' + ), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'), 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande_fournisseur').')'), From e5e317bae3bfe331d86e21ba4998a892a022ce20 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 16 May 2021 09:58:34 +0200 Subject: [PATCH 03/11] Fix entity was set to 0 on group creation --- htdocs/user/group/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 33921544b45..21f53c64c68 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -138,7 +138,7 @@ if (empty($reshook)) { if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 0; } else { - $object->entity = GETPOST("entity"); + $object->entity = GETPOSTISSET("entity") ? GETPOST("entity") : $conf->entity; } $db->begin(); From c820231363a75f0d528d7332b7a103e41f6f3e8f Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 16 May 2021 12:24:27 +0200 Subject: [PATCH 04/11] Fix id of expense report must be before object fetch --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a4c565bc1be..cb6dcfc94b8 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -55,6 +55,7 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); +$id = GETPOST('id', 'int'); $date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_finmonth', 'int'), GETPOST('date_finday', 'int'), GETPOST('date_finyear', 'int')); $date = dol_mktime(0, 0, 0, GETPOST('datemonth', 'int'), GETPOST('dateday', 'int'), GETPOST('dateyear', 'int')); @@ -120,7 +121,6 @@ if ($object->id > 0) { } // Security check -$id = GETPOST("id", 'int'); if ($user->socid) { $socid = $user->socid; } From 240137b768e4993406c2fe0037f1090438d4790d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 16 May 2021 16:04:19 +0200 Subject: [PATCH 05/11] Fix HRM homepage --- htdocs/hrm/index.php | 60 ++++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 09485357956..af9518d4622 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -40,8 +40,13 @@ if ($conf->deplacement->enabled) { if ($conf->expensereport->enabled) { require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; } -require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; -require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +if ($conf->recruitment->enabled) { + require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php'; + require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentjobposition.class.php'; +} +if ($conf->holiday->enabled) { + require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +} $hookmanager = new HookManager($db); $hookmanager->initHooks('hrmindex'); @@ -60,10 +65,6 @@ if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INF $setupcompanynotcomplete = 1; } -$holiday = new Holiday($db); -$holidaystatic = new Holiday($db); -$staticrecruitmentcandidature = new RecruitmentCandidature($db); - $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; @@ -73,7 +74,8 @@ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; // Update sold if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete)) { - $result = $holiday->updateBalance(); + $holidaystatic = new Holiday($db); + $result = $holidaystatic->updateBalance(); } @@ -144,6 +146,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel if (!empty($conf->holiday->enabled)) { if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) { + $holidaystatic = new Holiday($db); $user_id = $user->id; print '
'; @@ -154,9 +157,9 @@ if (!empty($conf->holiday->enabled)) { $out = ''; $nb_holiday = 0; - $typeleaves = $holiday->getTypes(1, 1); + $typeleaves = $holidaystatic->getTypes(1, 1); foreach ($typeleaves as $key => $val) { - $nb_type = $holiday->getCPforUser($user->id, $val['rowid']); + $nb_type = $holidaystatic->getCPforUser($user->id, $val['rowid']); $nb_holiday += $nb_type; $out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': '.($nb_type ? price2num($nb_type) : 0).'
'; } @@ -179,7 +182,7 @@ print '
'; // Latest leave requests if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,"; - $sql .= " x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; + $sql .= " x.rowid, x.ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = x.fk_user"; $sql .= " AND x.entity = ".$conf->entity; @@ -236,8 +239,8 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; - print ''.dol_print_date($db->jdate($obj->date_start), 'day').' '.$langs->trans($listhalfday[$starthalfday]).''; - print ''.dol_print_date($db->jdate($obj->date_end), 'day').' '.$langs->trans($listhalfday[$endhalfday]).''; + print ''.dol_print_date($db->jdate($obj->date_start), 'day').'
'.$langs->trans($listhalfday[$starthalfday]).''; + print ''.dol_print_date($db->jdate($obj->date_end), 'day').'
'.$langs->trans($listhalfday[$endhalfday]).''; print ''.dol_print_date($db->jdate($obj->dm), 'day').''; print ''.$holidaystatic->LibStatut($obj->status, 3).''; print ''; @@ -330,20 +333,23 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) // Last modified job position if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) { - $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status"; + $staticrecruitmentcandidature = new RecruitmentCandidature($db); + $staticrecruitmentjobposition = new RecruitmentJobPosition($db); + $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status,"; + $sql.= " rp.rowid as jobid, rp.ref as jobref, rp.label"; $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as rp ON rc.fk_recruitmentjobposition = rp.rowid"; + if ($conf->societe->enabled && !$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; - if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentcandidature->element).")"; + if ($conf->societe->enabled && !$user->rights->societe->client->voir && !$socid) { + $sql .= " AND rp.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { - $sql .= " AND s.fk_soc = $socid"; + $sql .= " AND rp.fk_soc = $socid"; } - $sql .= " ORDER BY rc.tms DESC"; + $sql .= $db->order("rc.tms", "DESC"); $sql .= $db->plimit($max, 0); $resql = $db->query($sql); @@ -354,8 +360,8 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme print '
'; print ''; print ''; - print ''; print ''; print ''; @@ -370,11 +376,15 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme $staticrecruitmentcandidature->firstname = $objp->firstname; $staticrecruitmentcandidature->lastname = $objp->lastname; + $staticrecruitmentjobposition->id = $objp->jobid; + $staticrecruitmentjobposition->ref = $objp->jobref; + $staticrecruitmentjobposition->label = $objp->label; + print ''; print ''; - print '"; - print '"; + print ''; + print ''; + print ''; print '"; From 78633ccb2ba3a09d5b0a4aaa6850824e04b99664 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 16 May 2021 16:20:46 +0200 Subject: [PATCH 06/11] Fix expensereport and recruitment homepages --- htdocs/expensereport/index.php | 9 --------- htdocs/recruitment/recruitmentindex.php | 12 ++++++------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index be8c735edc1..8198883e58f 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -171,9 +171,6 @@ $langs->load("boxes"); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.statut as user_status, u.photo, u.email, u.admin,"; $sql .= " d.rowid, d.ref, d.date_debut as dated, d.date_fin as datef, d.date_create as dm, d.total_ht, d.total_ttc, d.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as d, ".MAIN_DB_PREFIX."user as u"; -if (!$user->rights->societe->client->voir && !$user->socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} $sql .= " WHERE u.rowid = d.fk_user_author"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) @@ -183,12 +180,6 @@ if (empty($user->rights->expensereport->readall) && empty($user->rights->expense $sql .= " AND d.fk_user_author IN (".$db->sanitize(join(',', $childids)).")\n"; } $sql .= ' AND d.entity IN ('.getEntity('expensereport').')'; -if (!$user->rights->societe->client->voir && !$user->socid) { - $sql .= " AND d.fk_user_author = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -} -if ($socid) { - $sql .= " AND d.fk_user_author = ".$socid; -} $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($max, 0); diff --git a/htdocs/recruitment/recruitmentindex.php b/htdocs/recruitment/recruitmentindex.php index 3b6ff756b3c..7e369fe6bb2 100644 --- a/htdocs/recruitment/recruitmentindex.php +++ b/htdocs/recruitment/recruitmentindex.php @@ -331,18 +331,18 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status, COUNT(rc.rowid) as nbapplications"; $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc ON rc.fk_recruitmentjobposition = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) { + if ($conf->societe->enabled && !$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE s.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; - if (!$user->rights->societe->client->voir && !$socid) { + if ($conf->societe->enabled && !$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { $sql .= " AND s.fk_soc = $socid"; } $sql .= " GROUP BY s.rowid, s.ref, s.label, s.date_creation, s.tms, s.status"; - $sql .= " ORDER BY s.tms DESC"; + $sql .= $db->order('s.tms', 'DESC'); $sql .= $db->plimit($max, 0); $resql = $db->query($sql); @@ -402,17 +402,17 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status"; $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid"; - if (!$user->rights->societe->client->voir && !$socid) { + if ($conf->societe->enabled && !$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")"; - if (!$user->rights->societe->client->voir && !$socid) { + if ($conf->societe->enabled && !$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid) { $sql .= " AND s.fk_soc = $socid"; } - $sql .= " ORDER BY rc.tms DESC"; + $sql .= $db->order('rc.tms', 'DESC'); $sql .= $db->plimit($max, 0); $resql = $db->query($sql); From d4aa0ae4225f37569bf41a241b79d1e0a3cfcb42 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 16 May 2021 18:26:26 +0200 Subject: [PATCH 07/11] Update box_dolibarr_state_board.php Global stats box is always enabled --- htdocs/core/boxes/box_dolibarr_state_board.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index d26dd2cb075..348ffeda4cd 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -60,13 +60,6 @@ class box_dolibarr_state_board extends ModeleBoxes global $conf, $user; $this->db = $db; - - // disable box for such cases - if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { - $this->enabled = 0; // disabled by this option - } - - $this->hidden = !(!empty($user->rights->societe->lire) && empty($user->socid)); } /** From d3ff549b21417c314ced1c2a9d01acd821612e1e Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 16 May 2021 18:48:18 +0200 Subject: [PATCH 08/11] Fix ticket when module societe not enabled --- htdocs/core/class/html.formticket.class.php | 4 +++- htdocs/core/lib/ticket.lib.php | 5 +++-- htdocs/ticket/class/ticket.class.php | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 7d012077700..3cec6c19789 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -103,11 +103,13 @@ class FormTicket */ public function __construct($db) { + global $conf; + $this->db = $db; $this->action = 'add'; - $this->withcompany = 1; + $this->withcompany = $conf->societe->enabled ? 1 : 0; $this->withfromsocid = 0; $this->withfromcontactid = 0; //$this->withthreadid=0; diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index e2e06487de8..4d9d4bb2fa2 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -84,7 +84,7 @@ function ticket_prepare_head($object) $head[$h][2] = 'tabTicket'; $h++; - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid)) { + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && empty($user->socid) && $conf->societe->enabled) { $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external')); $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; $head[$h][1] = $langs->trans('ContactsAddresses'); @@ -157,7 +157,8 @@ function showDirectPublicLink($object) $out = ''; if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { - $out .= ''.$langs->trans("PublicInterfaceNotEnabled").''; + $langs->load('errors'); + $out .= ''.$langs->trans("ErrorPublicInterfaceNotEnabled").''; } else { $out .= img_picto('', 'object_globe.png').' '.$langs->trans("TicketPublicAccess").'
'; if ($url) { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 6c883be6b1a..5180abe6140 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -2917,7 +2917,7 @@ class Ticket extends CommonObject $sql = "SELECT p.rowid, p.ref, p.datec as datec"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as p"; - if (!$user->rights->societe->client->voir && !$user->socid) { + if ($conf->societe->enabled && !$user->rights->societe->client->voir && !$user->socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; $sql .= " WHERE sc.fk_user = ".$user->id; $clause = " AND"; From ea5d374f233e0162838aeb0df4606e1d8458b8bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 06:57:21 +0200 Subject: [PATCH 09/11] Update index.php --- htdocs/hrm/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index af9518d4622..50fd4c3f521 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -239,8 +239,8 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; - print '
'; print ''; print ''; From 7d0fa95d8134cf44f09bcf78e674d285c1b23d3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 07:08:45 +0200 Subject: [PATCH 10/11] Update card.php --- htdocs/user/group/card.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 21f53c64c68..19b78cf06e9 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -138,7 +138,11 @@ if (empty($reshook)) { if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 0; } else { - $object->entity = GETPOSTISSET("entity") ? GETPOST("entity") : $conf->entity; + if ($conf->entity == 1 && $user->admin && !$user->entity) { // Same permissions test than the one used to show the combo of entities into the form + $object->entity = GETPOSTISSET("entity") ? GETPOST("entity") : $conf->entity; + } else { + $object->entity = $conf->entity; + } } $db->begin(); From ad64b43e3080412ec089585b653fa8a8c5276d66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 07:11:41 +0200 Subject: [PATCH 11/11] Update html.form.class.php --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a0846b2b3ed..9b90ed0b30a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7696,7 +7696,7 @@ class Form 'enabled'=>$conf->contrat->enabled, 'perms'=>1, 'label'=>'LinkToContract', - 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY t.rowid' + 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier' ), 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'),
'; - print $langs->trans("BoxTitleLatestModifiedCandidatures", $max); + print ''; + print $langs->trans("BoxTitleLatestModifiedCandidatures", min($max, $num)); print ''.$langs->trans("FullList").'
'.$staticrecruitmentcandidature->getNomUrl(1, '').''; - print "'.dol_print_date($db->jdate($objp->tms), 'day')."'.$staticrecruitmentcandidature->getFullName($langs).''.$staticrecruitmentjobposition->getNomUrl(1).''.dol_print_date($db->jdate($objp->tms), 'day').''; print $staticrecruitmentcandidature->getLibStatut(3); print "'.dol_print_date($db->jdate($obj->date_start), 'day').'
'.$langs->trans($listhalfday[$starthalfday]).''; - print '
'.dol_print_date($db->jdate($obj->date_end), 'day').'
'.$langs->trans($listhalfday[$endhalfday]).''; + print '
'.dol_print_date($db->jdate($obj->date_start), 'day').' '.$langs->trans($listhalfday[$starthalfday]).''; + print ''.dol_print_date($db->jdate($obj->date_end), 'day').' '.$langs->trans($listhalfday[$endhalfday]).''; print ''.dol_print_date($db->jdate($obj->dm), 'day').''.$holidaystatic->LibStatut($obj->status, 3).'