Skip to content

Commit

Permalink
fix: better inner join than comma for hook printFieldListFrom after (#…
Browse files Browse the repository at this point in the history
…28681)

* better inner jion than comme for hook after

* better inner jion than comme for hook after

---------

Co-authored-by: Laurent Destailleur <[email protected]>
  • Loading branch information
FHenry and eldy authored Mar 7, 2024
1 parent 1aa0f82 commit 4fcbdf1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions htdocs/comm/propal/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
// 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 +588,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 +599,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 +721,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 +1147,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 4fcbdf1

Please sign in to comment.