mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Uniformize code and use a new generic search architecture
This commit is contained in:
parent
a2382bdde3
commit
7fd6d8839a
|
|
@ -108,7 +108,7 @@ if (count($listofsearchfields))
|
|||
{
|
||||
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>';
|
||||
print '<td class="nowrap"><label for="'.$key.'">'.$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++;
|
||||
|
|
|
|||
|
|
@ -71,37 +71,40 @@ print load_fiche_titre($langs->trans("HRMArea"),'', 'title_hrm.png');
|
|||
|
||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
/*
|
||||
* Search expenses
|
||||
*/
|
||||
|
||||
if (! empty($conf->holiday->enabled) && $user->rights->holiday->read)
|
||||
{
|
||||
$langs->load("holiday");
|
||||
$listofsearchfields['search_holiday']=array('text'=>'TitreRequestCP');
|
||||
}
|
||||
if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
|
||||
{
|
||||
$langs->load("trips");
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/compta/deplacement/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("SearchATripAndExpense").'</td></tr>';
|
||||
print "<tr ".$bc[0].">";
|
||||
print "<td><label for=\"search_ref\">".$langs->trans("Ref").'</label>:</td><td><input type="text" name="search_ref" id="search_ref" class="flat" size="18"></td>';
|
||||
print '<td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
//print "<tr ".$bc[0]."><td><label for=\"sall\">".$langs->trans("Other").'</label>:</td><td><input type="text" name="sall" id="sall" class="flat" size="18"></td>';
|
||||
print '</tr>';
|
||||
print "</table></form><br>";
|
||||
$listofsearchfields['search_deplacement']=array('text'=>'ExpenseReport');
|
||||
}
|
||||
|
||||
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
|
||||
{
|
||||
$langs->load("trips");
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/expensereport/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("SearchATripAndExpense").'</td></tr>';
|
||||
print "<tr ".$bc[0].">";
|
||||
print "<td><label for=\"search_ref\">".$langs->trans("Ref").'</label>:</td><td><input type="text" name="search_ref" id="search_ref" class="flat" size="18"></td>';
|
||||
print '<td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
//print "<tr ".$bc[0]."><td><label for=\"sall\">".$langs->trans("Other").'</label>:</td><td><input type="text" name="sall" id="sall" class="flat" size="18"></td>';
|
||||
print '</tr>';
|
||||
print "</table></form><br>";
|
||||
$listofsearchfields['search_expensereport']=array('text'=>'ExpenseReport');
|
||||
}
|
||||
if (count($listofsearchfields))
|
||||
{
|
||||
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 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="'.$key.'">'.$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>';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ if (count($listofsearchfields))
|
|||
{
|
||||
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>';
|
||||
print '<td class="nowrap"><label for="'.$key.'">'.$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++;
|
||||
|
|
|
|||
|
|
@ -94,9 +94,22 @@ if (GETPOST('search_contact') != '')
|
|||
header("Location: ".DOL_URL_ROOT.'/contact/list.php?mode=search&sall='.urlencode(GETPOST('search_contact')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_deplacement') != '')
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/compta/deplacement/list.php?mode=search&sall='.urlencode(GETPOST('search_deplacement')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_expensereport') != '')
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/expensereport/list.php?mode=search&sall='.urlencode(GETPOST('search_expensereport')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_holiday') != '')
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/holiday/list.php?mode=search&sall='.urlencode(GETPOST('search_holiday')));
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// If we are here, search was called with no supported criteria
|
||||
if (! empty($_SERVER['HTTP_REFERER']))
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ $socid = $_GET["socid"]?$_GET["socid"]:'';
|
|||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'expensereport','','');
|
||||
|
||||
$sall = GETPOST('sall');
|
||||
$search_ref = GETPOST('search_ref');
|
||||
$search_user = GETPOST('search_user','int');
|
||||
$search_amount_ht = GETPOST('search_amount_ht','alpha');
|
||||
|
|
@ -66,6 +67,14 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
|
|||
if ($search_status == '') $search_status=-1;
|
||||
if ($search_user == '') $search_user=-1;
|
||||
|
||||
// List of fields to search into when doing a "search in all"
|
||||
$fieldstosearchall = array(
|
||||
'd.ref'=>'Ref',
|
||||
'u.lastname'=>'Lastname',
|
||||
'u.firstname'=>"Firstname",
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
|
@ -101,6 +110,11 @@ $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
|
|||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid";
|
||||
$sql.= " WHERE d.entity = ".$conf->entity;
|
||||
|
||||
// Search all
|
||||
if (!empty($sall))
|
||||
{
|
||||
$sql.= natural_search(array_keys($fieldstosearchall), $sall);
|
||||
}
|
||||
// Ref
|
||||
if(!empty($search_ref)){
|
||||
$sql.= " AND d.ref LIKE '%".$db->escape($search_ref)."%'";
|
||||
|
|
@ -183,6 +197,16 @@ if ($resql)
|
|||
print_barre_liste($langs->trans("ListTripsAndExpenses"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||
print $langs->trans("FilterOnInto", $sall, join(', ',$fieldstosearchall));
|
||||
}
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print "<tr class=\"liste_titre\">";
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ $pagenext = $page + 1;
|
|||
|
||||
$id = GETPOST('id','int');
|
||||
|
||||
$sall = GETPOST('sall');
|
||||
$search_ref = GETPOST('search_ref');
|
||||
$month_create = GETPOST('month_create');
|
||||
$year_create = GETPOST('year_create');
|
||||
|
|
@ -64,7 +65,7 @@ $search_employe = GETPOST('search_employe');
|
|||
$search_valideur = GETPOST('search_valideur');
|
||||
$search_statut = GETPOST('select_statut');
|
||||
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
{
|
||||
$search_ref="";
|
||||
$month_create="";
|
||||
|
|
@ -78,6 +79,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
|
|||
$search_statut="";
|
||||
}
|
||||
|
||||
// List of fields to search into when doing a "search in all"
|
||||
$fieldstosearchall = array(
|
||||
'cp.rowid'=>'Ref',
|
||||
'cp.description'=>'Description',
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
|
@ -171,6 +178,12 @@ if(!empty($search_valideur) && $search_valideur != -1) {
|
|||
if(!empty($search_statut) && $search_statut != -1) {
|
||||
$filter.= " AND cp.statut = '".$db->escape($search_statut)."'\n";
|
||||
}
|
||||
// Search all
|
||||
if (!empty($sall))
|
||||
{
|
||||
$filter.= natural_search(array_keys($fieldstosearchall), $sall);
|
||||
}
|
||||
|
||||
|
||||
/*************************************
|
||||
* Fin des filtres de recherche
|
||||
|
|
@ -252,6 +265,18 @@ if ($id > 0) print '</br>';
|
|||
|
||||
|
||||
print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
|
||||
print $langs->trans("FilterOnInto", $sall, join(', ',$fieldstosearchall));
|
||||
}
|
||||
|
||||
print '<table class="noborder" width="100%;">';
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"cp.rowid","",'','',$sortfield,$sortorder);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ BoxLastExpiredServices=Last %s oldest contacts with active expired services
|
|||
BoxTitleLastActionsToDo=Last %s actions to do
|
||||
BoxTitleLastContracts=Last %s contracts
|
||||
BoxTitleLastModifiedDonations=Last %s modified donations
|
||||
BoxTitleLastModifiedExpenses=Last %s modified expenses
|
||||
BoxTitleLastModifiedExpenses=Last %s modified expense reports
|
||||
BoxGlobalActivity=Global activity (invoices, proposals, orders)
|
||||
FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Last successfull refresh date: %s
|
||||
LastRefreshDate=Last refresh date
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ if (count($listofsearchfields))
|
|||
{
|
||||
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>';
|
||||
print '<td class="nowrap"><label for="'.$key.'">'.$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++;
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ if (count($listofsearchfields))
|
|||
{
|
||||
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>';
|
||||
print '<td class="nowrap"><label for="'.$key.'">'.$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++;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user