mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 00:52:01 +01:00
FIX - Search user in where propal and order (#29374)
* FIX - INNER JOIN for search user * Search in where no joint * FIX - Propal * FIX * Update list.php * Update list.php * Update list.php * Update list.php --------- Co-authored-by: Anthony Berton <anthony.berton@bb2a.fr> Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -831,7 +831,7 @@ $help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_P
|
||||
// Build and execute select
|
||||
// --------------------------------------------------------------------
|
||||
$sql = 'SELECT';
|
||||
if ($search_all || $search_user > 0) {
|
||||
if ($search_all) {
|
||||
$sql = 'SELECT DISTINCT';
|
||||
}
|
||||
$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client,';
|
||||
@@ -878,11 +878,6 @@ if ($search_all) {
|
||||
}
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet";
|
||||
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid';
|
||||
if ($search_user > 0) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||
}
|
||||
|
||||
// Add table from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
@@ -980,9 +975,6 @@ if (empty($arrayfields['s.name_alias']['checked']) && $search_company) {
|
||||
if ($search_parent_name) {
|
||||
$sql .= natural_search('s2.nom', $search_parent_name);
|
||||
}
|
||||
if ($search_user > 0) {
|
||||
$sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user);
|
||||
}
|
||||
if ($search_total_ht != '') {
|
||||
$sql .= natural_search('c.total_ht', $search_total_ht, 1);
|
||||
}
|
||||
@@ -1031,6 +1023,15 @@ if ($search_fk_mode_reglement > 0) {
|
||||
if ($search_fk_input_reason > 0) {
|
||||
$sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason);
|
||||
}
|
||||
// Search on user
|
||||
if ($search_user > 0) {
|
||||
$sql .= " AND EXISTS (";
|
||||
$sql .= " SELECT ec.fk_c_type_contact, ec.element_id, ec.fk_socpeople";
|
||||
$sql .= " FROM llx_element_contact as ec";
|
||||
$sql .= " INNER JOIN llx_c_type_contact as tc";
|
||||
$sql .= " ON ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal'";
|
||||
$sql .= " WHERE ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user).")";
|
||||
}
|
||||
// Search on sale representative
|
||||
if ($search_sale && $search_sale != '-1') {
|
||||
if ($search_sale == -2) {
|
||||
|
||||
Reference in New Issue
Block a user