Fix search on shipment

This commit is contained in:
Laurent Destailleur 2016-01-08 23:59:02 +01:00
parent 99f3870ee6
commit 37c106acff
3 changed files with 25 additions and 5 deletions

View File

@ -51,9 +51,9 @@ $var=false;
print '<form method="post" action="list.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchASending").'</td></tr>';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print $langs->trans("Shipment").':</td><td><input type="text" class="flat" name="sall" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print "</table></form><br>\n";
/*

View File

@ -38,6 +38,7 @@ $result = restrictedArea($user, 'expedition',$expeditionid,'');
$search_ref_exp = GETPOST("search_ref_exp");
$search_ref_liv = GETPOST('search_ref_liv');
$search_company = GETPOST("search_company");
$sall = GETPOST('sall');
$optioncss = GETPOST('optioncss','alpha');
$sortfield = GETPOST('sortfield','alpha');
@ -63,6 +64,13 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$viewstatut='';
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
'e.ref'=>"Ref",
's.nom'=>"ThirdParty"
);
/*
* View
*/
@ -100,6 +108,7 @@ if ($viewstatut <> '') {
if ($search_ref_exp) $sql .= natural_search('e.ref', $search_ref_exp);
if ($search_ref_liv) $sql .= natural_search('l.ref', $search_ref_liv);
if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit + 1,$offset);
@ -123,12 +132,21 @@ if ($resql)
$i = 0;
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<table class="noborder" width="100%">';
if ($sall)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
}
$moreforfilter='';
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"],"e.ref","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Company"), $_SERVER["PHP_SELF"],"s.nom", "", $param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ThirdParty"), $_SERVER["PHP_SELF"],"s.nom", "", $param,'align="left"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateDeliveryPlanned"), $_SERVER["PHP_SELF"],"e.date_delivery","",$param, 'align="center"',$sortfield,$sortorder);
if($conf->livraison_bon->enabled)
{

View File

@ -111,7 +111,9 @@ if ($result)
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
}
print '<table class="noborder" width="100%">';
$moreforfilter='';
print '<table class="liste '.($moreforfilter?"listwithfilterbefore":"").'">';
print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "e.label","","","",$sortfield,$sortorder);