FIX syntax error on list of intervention for external users
This commit is contained in:
parent
007fad9d98
commit
473e88a3e9
1 changed files with 17 additions and 4 deletions
|
|
@ -70,6 +70,12 @@ $toselect = GETPOST('toselect', 'array');
|
|||
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'interventionlist';
|
||||
$mode = GETPOST('mode', 'alpha');
|
||||
|
||||
if (getDolGlobalInt('MAIN_SEE_SUBORDINATES')) {
|
||||
$userschilds = $user->getAllChildIds();
|
||||
} else {
|
||||
$userschilds = array();
|
||||
}
|
||||
|
||||
$search_ref = GETPOST('search_ref') ? GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha');
|
||||
$search_ref_client = GETPOST('search_ref_client', 'alpha');
|
||||
$search_company = GETPOST('search_company', 'alpha');
|
||||
|
|
@ -170,6 +176,7 @@ if ($user->socid) {
|
|||
}
|
||||
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
|
||||
|
||||
$permissiontoreadallthirdparty = $user->hasRight('societe', 'client', 'voir');
|
||||
$permissiontoread = $user->hasRight('ficheinter', 'lire');
|
||||
$permissiontoadd = $user->hasRight('ficheinter', 'creer');
|
||||
$permissiontodelete = $user->hasRight('ficheinter', 'supprimer');
|
||||
|
|
@ -349,12 +356,18 @@ if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') && $atleastonefieldinlines)
|
|||
$sql .= " AND fd.date <= '".$db->idate($search_date_end)."'";
|
||||
}
|
||||
}
|
||||
if (!$user->hasRight('societe', 'client', 'voir')) {
|
||||
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
||||
}
|
||||
if ($socid) {
|
||||
if ($socid > 0) {
|
||||
$sql .= " AND s.rowid = ".((int) $socid);
|
||||
}
|
||||
// Restriction on sale representative
|
||||
if (empty($user->socid) && !$permissiontoreadallthirdparty) {
|
||||
$sql .= " AND (EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $user->id).")";
|
||||
if (getDolGlobalInt('MAIN_SEE_SUBORDINATES') && $userschilds) {
|
||||
$sql .= " OR EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user IN (".$db->sanitize(implode(',', $userschilds))."))";
|
||||
}
|
||||
$sql .= ")";
|
||||
}
|
||||
|
||||
if ($search_all) {
|
||||
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue