Merge pull request #19829 from OPEN-DSI/v12-fix-supplier-order-list-search-user
FIX search by user in supplier order list
This commit is contained in:
commit
90c3c90864
@ -501,7 +501,7 @@ $help_url = '';
|
|||||||
// llxHeader('',$title,$help_url);
|
// llxHeader('',$title,$help_url);
|
||||||
|
|
||||||
$sql = 'SELECT';
|
$sql = 'SELECT';
|
||||||
if ($sall || $search_product_category > 0 || $search_user > 0) $sql = 'SELECT DISTINCT';
|
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
|
||||||
$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,';
|
$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,';
|
||||||
$sql .= " typent.code as typent_code,";
|
$sql .= " typent.code as typent_code,";
|
||||||
$sql .= " state.code_departement as state_code, state.nom as state_name,";
|
$sql .= " state.code_departement as state_code, state.nom as state_name,";
|
||||||
@ -531,11 +531,6 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON cf.fk_user_author = u.rowid";
|
|||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cf.fk_projet";
|
||||||
// We'll need this table joined to the select in order to filter by sale
|
// We'll need this table joined to the select in order to filter by sale
|
||||||
if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
if ($search_user > 0)
|
|
||||||
{
|
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
|
|
||||||
$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
|
||||||
}
|
|
||||||
$sql .= ' WHERE cf.fk_soc = s.rowid';
|
$sql .= ' WHERE cf.fk_soc = s.rowid';
|
||||||
$sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')';
|
$sql .= ' AND cf.entity IN ('.getEntity('supplier_order').')';
|
||||||
if ($socid > 0) $sql .= " AND s.rowid = ".$socid;
|
if ($socid > 0) $sql .= " AND s.rowid = ".$socid;
|
||||||
@ -561,7 +556,15 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).
|
|||||||
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
|
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
|
||||||
if ($search_company) $sql .= natural_search('s.nom', $search_company);
|
if ($search_company) $sql .= natural_search('s.nom', $search_company);
|
||||||
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale);
|
if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale);
|
||||||
if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user);
|
if ($search_user > 0) {
|
||||||
|
$sql .= " AND EXISTS (";
|
||||||
|
$sql .= " SELECT ec.rowid ";
|
||||||
|
$sql .= " FROM " . MAIN_DB_PREFIX . "element_contact as ec";
|
||||||
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact";
|
||||||
|
$sql .= " WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user);
|
||||||
|
$sql .= " AND tc.element = 'order_supplier' AND tc.source = 'internal'";
|
||||||
|
$sql .= ")";
|
||||||
|
}
|
||||||
if ($search_total_ht != '') $sql .= natural_search('cf.total_ht', $search_total_ht, 1);
|
if ($search_total_ht != '') $sql .= natural_search('cf.total_ht', $search_total_ht, 1);
|
||||||
if ($search_total_vat != '') $sql .= natural_search('cf.tva', $search_total_vat, 1);
|
if ($search_total_vat != '') $sql .= natural_search('cf.tva', $search_total_vat, 1);
|
||||||
if ($search_total_ttc != '') $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1);
|
if ($search_total_ttc != '') $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user