commit
d8a9a0cfb8
@ -6975,13 +6975,15 @@ class Form
|
||||
|
||||
// Search data
|
||||
$sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX.$objecttmp->table_element." as t";
|
||||
if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
|
||||
$tmparray = explode('@', $objecttmp->ismultientitymanaged);
|
||||
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.$tmparray[1].' as parenttable ON parenttable.rowid = t.'.$tmparray[0];
|
||||
}
|
||||
if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
if (isset($objecttmp->ismultientitymanaged)) {
|
||||
if (!is_numeric($objecttmp->ismultientitymanaged)) {
|
||||
$tmparray = explode('@', $objecttmp->ismultientitymanaged);
|
||||
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.$tmparray[1].' as parenttable ON parenttable.rowid = t.'.$tmparray[0];
|
||||
}
|
||||
if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6992,27 +6994,29 @@ class Form
|
||||
$sql .= $hookmanager->resPrint;
|
||||
} else {
|
||||
$sql .= " WHERE 1=1";
|
||||
if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) {
|
||||
$sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
|
||||
}
|
||||
if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
|
||||
$sql .= ' AND parenttable.entity = t.'.$tmparray[0];
|
||||
}
|
||||
if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
|
||||
if ($objecttmp->element == 'societe') {
|
||||
$sql .= " AND t.rowid = ".$user->socid;
|
||||
} else {
|
||||
$sql .= " AND t.fk_soc = ".$user->socid;
|
||||
if (isset($objecttmp->ismultientitymanaged)) {
|
||||
if ($objecttmp->ismultientitymanaged == 1) {
|
||||
$sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
|
||||
}
|
||||
if (!is_numeric($objecttmp->ismultientitymanaged)) {
|
||||
$sql .= ' AND parenttable.entity = t.'.$tmparray[0];
|
||||
}
|
||||
if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
|
||||
if ($objecttmp->element == 'societe') {
|
||||
$sql .= " AND t.rowid = ".$user->socid;
|
||||
} else {
|
||||
$sql .= " AND t.fk_soc = ".$user->socid;
|
||||
}
|
||||
}
|
||||
if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
$sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($searchkey != '') {
|
||||
$sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
|
||||
}
|
||||
if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
|
||||
if (!$user->rights->societe->client->voir && !$user->socid) {
|
||||
$sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
|
||||
}
|
||||
}
|
||||
if ($objecttmp->filter) { // Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
|
||||
/*if (! DolibarrApi::_checkFilters($objecttmp->filter))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user