Skip to content

Commit

Permalink
better inner jion than comme for hook after
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry committed Mar 7, 2024
1 parent 21ef877 commit 52ee24e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions htdocs/comm/propal/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
// Search Fields
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$search_user = GETPOSTINT('search_user');
if ($search_user==-1) {
$search_user=0;
}
$search_sale = GETPOSTINT('search_sale');
$search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
$search_refcustomer = GETPOST('search_refcustomer', 'alpha');
Expand Down Expand Up @@ -587,7 +590,7 @@
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";

$sql .= ', '.MAIN_DB_PREFIX.'propal as p';
$sql .= ' INNER JOIN '.MAIN_DB_PREFIX.'propal as p ON p.fk_soc = s.rowid';
if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
}
Expand All @@ -598,17 +601,19 @@
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)";
if ($search_user > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_contact as c";
$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_contact as c";
$sql .= " ON c.element_id = p.rowid AND c.fk_socpeople = ".((int) $search_user);
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql .= " ON c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal'";
}

// Add table from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;

$sql .= ' WHERE p.fk_soc = s.rowid';
$sql .= ' AND p.entity IN ('.getEntity('propal').')';
$sql .= ' WHERE';
$sql .= ' p.entity IN ('.getEntity('propal').')';
if ($search_town) {
$sql .= natural_search('s.town', $search_town);
}
Expand Down Expand Up @@ -718,9 +723,6 @@
if ($search_date_delivery_end) {
$sql .= " AND p.date_livraison <= '".$db->idate($search_date_delivery_end)."'";
}
if ($search_user > 0) {
$sql .= " AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = ".((int) $search_user);
}
if ($search_date_signature_start) {
$sql .= " AND p.date_signature >= '".$db->idate($search_date_signature_start)."'";
}
Expand Down Expand Up @@ -1147,7 +1149,7 @@
if ($user->hasRight('user', 'user', 'lire')) {
$moreforfilter .= '<div class="divsearchfield">';
$tmptitle = $langs->trans('LinkedToSpecificUsers');
$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
$moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers((empty($search_user)?-2:0), 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx');
$moreforfilter .= '</div>';
}
// If the user can view products
Expand Down

0 comments on commit 52ee24e

Please sign in to comment.