NEW Merge all search fields of an area page into one search box

This commit is contained in:
Laurent Destailleur 2015-10-16 10:52:49 +02:00
parent b3491ef4e5
commit dc5cc52395
2 changed files with 105 additions and 60 deletions

View File

@ -75,84 +75,51 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
// Search proposal
if (! empty($conf->propal->enabled) && $user->rights->propal->lire)
{
$var=false;
print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/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("SearchAProposal").'</td></tr>';
print '<tr '.$bc[$var].'>';
print '<td class="nowrap"><label for="sf_ref">'.$langs->trans("Ref").'</label>:</td><td><input type="text" class="flat" name="sf_ref" id="sf_ref" size="18"></td>';
print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<tr '.$bc[$var].'><td class="nowrap"><label for="sall">'.$langs->trans("Other").'</label>:</td><td><input type="text" class="flat" name="sall" id="sall" size="18"></td>';
print '</tr>';
print "</table></form>\n";
print "<br>\n";
$listofsearchfields['search_proposal']=array('text'=>'Proposal');
}
// Search customer order
if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
{
$var=false;
print '<form method="post" action="'.DOL_URL_ROOT.'/commande/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("SearchACustomerOrder").'</td></tr>';
print '<tr '.$bc[$var].'><td>';
print '<label for="sref">'.$langs->trans("Ref").'</label>:</td><td><input type="text" class="flat" name="sref" id="sref" size=18></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<tr '.$bc[$var].'><td class="nowrap"><label for="sall">'.$langs->trans("Other").'</label>:</td><td><input type="text" class="flat" name="sall" id="sall" size="18"></td>';
print '</tr>';
print "</table></form><br>\n";
$listofsearchfields['search_customer_order']=array('text'=>'CustomerOrder');
}
// Search supplier order
if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire)
{
$var=false;
print '<form method="post" action="'.DOL_URL_ROOT.'/fourn/commande/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("SearchASupplierOrder").'</td></tr>';
print '<tr '.$bc[$var].'><td>';
print '<label for="search_ref">'.$langs->trans("Ref").'</label>:</td><td><input type="text" class="flat" name="search_ref" id="search_ref" size=18></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<tr '.$bc[$var].'><td class="nowrap"><label for="search_all">'.$langs->trans("Other").'</label>:</td><td><input type="text" class="flat" name="search_all" id="search_all" size="18"></td>';
print '</tr>';
print "</table></form><br>\n";
$listofsearchfields['search_supplier_order']=array('text'=>'SupplierOrder');
}
// Search intervention
if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
{
$listofsearchfields['search_intervention']=array('text'=>'Intervention');
}
// Search contract
if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
{
$var=false;
print '<form method="post" action="'.DOL_URL_ROOT.'/contrat/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("SearchAContract").'</td></tr>';
print '<tr '.$bc[$var].'>';
print '<td class="nowrap"><label for="search_contract">'.$langs->trans("Ref").'</label>:</td><td><input type="text" class="flat" name="search_contract" id="search_contract" size="18"></td>';
print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<tr '.$bc[$var].'><td class="nowrap"><label for="sall">'.$langs->trans("Other").'</label>:</td><td><input type="text" class="flat" name="sall" id="sall" size="18"></td>';
print '</tr>';
print "</table></form>\n";
print "<br>";
$listofsearchfields['search_contract']=array('text'=>'Contrat');
}
// Search contract
if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire)
if (count($listofsearchfields))
{
$var=false;
print '<form method="post" action="'.DOL_URL_ROOT.'/fichinter/list.php">';
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.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("SearchAnIntervention").'</td></tr>';
print '<tr '.$bc[$var].'>';
print '<td class="nowrap"><label for="search_contract">'.$langs->trans("Ref").'</label>:</td><td><input type="text" class="flat" name="search_inter" id="search_inter" size="18"></td>';
print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<tr '.$bc[$var].'><td class="nowrap"><label for="sall">'.$langs->trans("Other").'</label>:</td><td><input type="text" class="flat" name="sall" id="sall" size="18"></td>';
print '</tr>';
print "</table></form>\n";
print "<br>";
print '<table class="noborder nohover centpercent">';
$i=0;
foreach($listofsearchfields as $key => $value)
{
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
print '<tr>';
print '<td class="nowrap"><label for="search_contract">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat" name="'.$key.'" id="'.$key.'" size="18"></td>';
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
print '</tr>';
$i++;
}
print '</table>';
print '</form>';
print '<br>';
}
/*
* Draft proposals
*/

78
htdocs/core/search.php Normal file
View File

@ -0,0 +1,78 @@
<?php
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This file is a modified version of datepicker.php from phpBSM to fix some
* bugs, to add new features and to dramatically increase speed.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/search.php
* \brief Wrapper that receive any search. Depending on input field, make a redirect to correct URL.
*/
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1);
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1);
if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
require_once '../main.inc.php';
/*
* Actions
*/
if (GETPOST('search_proposal') != '')
{
header("Location: ".DOL_URL_ROOT.'/comm/propal/list.php?sall='.urlencode(GETPOST('search_proposal')));
exit;
}
if (GETPOST('search_customer_order') != '')
{
header("Location: ".DOL_URL_ROOT.'/commande/list.php?sall='.urlencode(GETPOST('search_customer_order')));
exit;
}
if (GETPOST('search_supplier_order') != '')
{
header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php?search_all='.urlencode(GETPOST('search_supplier_order')));
exit;
}
if (GETPOST('search_intervention') != '')
{
header("Location: ".DOL_URL_ROOT.'/fichinter/list.php?sall='.urlencode(GETPOST('search_intervention')));
exit;
}
if (GETPOST('search_contract') != '')
{
header("Location: ".DOL_URL_ROOT.'/contrat/list.php?sall='.urlencode(GETPOST('search_contract')));
exit;
}
// If we are here, search was called with no supported criteria
if (! empty($_SERVER['HTTP_REFERER']))
{
header("Location: ".$_SERVER['HTTP_REFERER']);
exit;
}
else
{
print 'The wrapper search.php was called without any search criteria';
}