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>';
|
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||||
print '<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>';
|
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
@ -71,37 +71,40 @@ print load_fiche_titre($langs->trans("HRMArea"),'', 'title_hrm.png');
|
|||||||
|
|
||||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
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)
|
if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
|
||||||
{
|
{
|
||||||
$langs->load("trips");
|
$langs->load("trips");
|
||||||
print '<form method="post" action="'.DOL_URL_ROOT.'/compta/deplacement/list.php">';
|
$listofsearchfields['search_deplacement']=array('text'=>'ExpenseReport');
|
||||||
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>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
|
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
|
||||||
{
|
{
|
||||||
$langs->load("trips");
|
$langs->load("trips");
|
||||||
print '<form method="post" action="'.DOL_URL_ROOT.'/expensereport/list.php">';
|
$listofsearchfields['search_expensereport']=array('text'=>'ExpenseReport');
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
}
|
||||||
print '<table class="noborder nohover" width="100%">';
|
if (count($listofsearchfields))
|
||||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchATripAndExpense").'</td></tr>';
|
{
|
||||||
print "<tr ".$bc[0].">";
|
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
||||||
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 '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
print '<table class="noborder nohover centpercent">';
|
||||||
//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>';
|
$i=0;
|
||||||
print '</tr>';
|
foreach($listofsearchfields as $key => $value)
|
||||||
print "</table></form><br>";
|
{
|
||||||
|
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>';
|
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||||
print '<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>';
|
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
@ -94,8 +94,21 @@ if (GETPOST('search_contact') != '')
|
|||||||
header("Location: ".DOL_URL_ROOT.'/contact/list.php?mode=search&sall='.urlencode(GETPOST('search_contact')));
|
header("Location: ".DOL_URL_ROOT.'/contact/list.php?mode=search&sall='.urlencode(GETPOST('search_contact')));
|
||||||
exit;
|
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 we are here, search was called with no supported criteria
|
||||||
|
|||||||
@ -39,6 +39,7 @@ $socid = $_GET["socid"]?$_GET["socid"]:'';
|
|||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'expensereport','','');
|
$result = restrictedArea($user, 'expensereport','','');
|
||||||
|
|
||||||
|
$sall = GETPOST('sall');
|
||||||
$search_ref = GETPOST('search_ref');
|
$search_ref = GETPOST('search_ref');
|
||||||
$search_user = GETPOST('search_user','int');
|
$search_user = GETPOST('search_user','int');
|
||||||
$search_amount_ht = GETPOST('search_amount_ht','alpha');
|
$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_status == '') $search_status=-1;
|
||||||
if ($search_user == '') $search_user=-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
|
* 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.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON d.fk_user_author = u.rowid";
|
||||||
$sql.= " WHERE d.entity = ".$conf->entity;
|
$sql.= " WHERE d.entity = ".$conf->entity;
|
||||||
|
|
||||||
|
// Search all
|
||||||
|
if (!empty($sall))
|
||||||
|
{
|
||||||
|
$sql.= natural_search(array_keys($fieldstosearchall), $sall);
|
||||||
|
}
|
||||||
// Ref
|
// Ref
|
||||||
if(!empty($search_ref)){
|
if(!empty($search_ref)){
|
||||||
$sql.= " AND d.ref LIKE '%".$db->escape($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_barre_liste($langs->trans("ListTripsAndExpenses"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
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 '<table class="noborder" width="100%">';
|
||||||
print "<tr class=\"liste_titre\">";
|
print "<tr class=\"liste_titre\">";
|
||||||
|
|||||||
@ -53,6 +53,7 @@ $pagenext = $page + 1;
|
|||||||
|
|
||||||
$id = GETPOST('id','int');
|
$id = GETPOST('id','int');
|
||||||
|
|
||||||
|
$sall = GETPOST('sall');
|
||||||
$search_ref = GETPOST('search_ref');
|
$search_ref = GETPOST('search_ref');
|
||||||
$month_create = GETPOST('month_create');
|
$month_create = GETPOST('month_create');
|
||||||
$year_create = GETPOST('year_create');
|
$year_create = GETPOST('year_create');
|
||||||
@ -64,7 +65,7 @@ $search_employe = GETPOST('search_employe');
|
|||||||
$search_valideur = GETPOST('search_valideur');
|
$search_valideur = GETPOST('search_valideur');
|
||||||
$search_statut = GETPOST('select_statut');
|
$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="";
|
$search_ref="";
|
||||||
$month_create="";
|
$month_create="";
|
||||||
@ -78,6 +79,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
|
|||||||
$search_statut="";
|
$search_statut="";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List of fields to search into when doing a "search in all"
|
||||||
|
$fieldstosearchall = array(
|
||||||
|
'cp.rowid'=>'Ref',
|
||||||
|
'cp.description'=>'Description',
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -171,6 +178,12 @@ if(!empty($search_valideur) && $search_valideur != -1) {
|
|||||||
if(!empty($search_statut) && $search_statut != -1) {
|
if(!empty($search_statut) && $search_statut != -1) {
|
||||||
$filter.= " AND cp.statut = '".$db->escape($search_statut)."'\n";
|
$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
|
* Fin des filtres de recherche
|
||||||
@ -252,6 +265,18 @@ if ($id > 0) print '</br>';
|
|||||||
|
|
||||||
|
|
||||||
print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
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 '<table class="noborder" width="100%;">';
|
||||||
print "<tr class=\"liste_titre\">";
|
print "<tr class=\"liste_titre\">";
|
||||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"cp.rowid","",'','',$sortfield,$sortorder);
|
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
|
BoxTitleLastActionsToDo=Last %s actions to do
|
||||||
BoxTitleLastContracts=Last %s contracts
|
BoxTitleLastContracts=Last %s contracts
|
||||||
BoxTitleLastModifiedDonations=Last %s modified donations
|
BoxTitleLastModifiedDonations=Last %s modified donations
|
||||||
BoxTitleLastModifiedExpenses=Last %s modified expenses
|
BoxTitleLastModifiedExpenses=Last %s modified expense reports
|
||||||
BoxGlobalActivity=Global activity (invoices, proposals, orders)
|
BoxGlobalActivity=Global activity (invoices, proposals, orders)
|
||||||
FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Last successfull refresh date: %s
|
FailedToRefreshDataInfoNotUpToDate=Failed to refresh RSS flux. Last successfull refresh date: %s
|
||||||
LastRefreshDate=Last refresh date
|
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>';
|
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||||
print '<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>';
|
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
@ -78,7 +78,7 @@ if (count($listofsearchfields))
|
|||||||
{
|
{
|
||||||
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||||
print '<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>';
|
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user