Fix: La fonction filtre des contacts et societes s'accorde bien avec la fonction tri.

This commit is contained in:
Laurent Destailleur 2004-10-31 14:33:57 +00:00
parent 0872e53267
commit 80698aa6fb
2 changed files with 73 additions and 47 deletions

View File

@ -47,10 +47,17 @@ if ($user->societe_id > 0)
llxHeader();
$search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"];
$search_prenom=isset($_GET["search_prenom"])?$_GET["search_prenom"]:$_POST["search_prenom"];
$search_societe=isset($_GET["search_societe"])?$_GET["search_societe"]:$_POST["search_societe"];
$search_email=isset($_GET["search_email"])?$_GET["search_email"]:$_POST["search_email"];
$view=isset($_GET["view"])?$_GET["view"]:$_POST["view"];
$contactname=isset($_GET["contactname"])?$_GET["contactname"]:$_POST["contactname"];
$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
$page = $_GET["page"];
$sortfield = $_GET["sortfield"];
$sortorder = $_GET["sortorder"];
if ($sortorder == "")
{
@ -65,12 +72,19 @@ if ($page < 0) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
if ($_GET["view"] == 'phone') { $text="(Vue Téléphones)"; }
if ($_GET["view"] == 'mail') { $text="(Vue EMail)"; }
if ($_GET["view"] == 'recent') { $text="(Récents)"; }
if ($view == 'phone') { $text="(Vue Téléphones)"; }
if ($view == 'mail') { $text="(Vue EMail)"; }
if ($view == 'recent') { $text="(Récents)"; }
$titre = "Liste des contacts $text";
if ($_POST["button_removefilter"] == $langs->trans("RemoveFilter")) {
$search_nom="";
$search_prenom="";
$search_societe="";
$search_email="";
}
/*
*
@ -84,26 +98,26 @@ $sql .= "FROM ".MAIN_DB_PREFIX."socpeople as p ";
$sql .= "LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (s.idp = p.fk_soc) ";
$sql .= "WHERE 1=1 ";
if (strlen($_GET["userid"])) // statut commercial
if ($_GET["userid"]) // statut commercial
{
$sql .= " AND p.fk_user=".$_GET["userid"];
}
if (strlen($_GET["search_nom"])) // filtre sur le nom
if ($search_nom) // filtre sur le nom
{
$sql .= " AND upper(p.name) like '%".$_GET["search_nom"]."%'";
$sql .= " AND upper(p.name) like '%".$search_nom."%'";
}
if (strlen($_GET["search_prenom"])) // filtre sur le prenom
if ($search_prenom) // filtre sur le prenom
{
$sql .= " AND upper(p.firstname) like '%".$_GET["search_prenom"]."%'";
$sql .= " AND upper(p.firstname) like '%".$search_prenom."%'";
}
if (strlen($_GET["search_societe"])) // filtre sur la societe
if ($search_societe) // filtre sur la societe
{
$sql .= " AND upper(s.nom) like '%".$_GET["search_societe"]."%'";
$sql .= " AND upper(s.nom) like '%".$search_societe."%'";
}
if (strlen($_GET["search_email"])) // filtre sur l'email
if ($search_email) // filtre sur l'email
{
$sql .= " AND upper(p.email) like '%".$_GET["search_email"]."%'";
$sql .= " AND upper(p.email) like '%".$search_email."%'";
}
if ($contactname)
@ -139,9 +153,9 @@ if ($result)
// Ligne des titres
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Lastname"),"index.php","p.name", $begin, "", "", $sortfield);
print_liste_field_titre($langs->trans("Firstname"),"index.php","p.firstname", $begin, "", "", $sortfield);
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom", $begin, "", "", $sortfield);
print_liste_field_titre($langs->trans("Lastname"),"index.php","p.name", $begin, "&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield);
print_liste_field_titre($langs->trans("Firstname"),"index.php","p.firstname", $begin, "&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield);
print_liste_field_titre($langs->trans("Company"),"index.php","s.nom", $begin, "&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield);
print '<td>'.$langs->trans("Phone").'</td>';
if ($_GET["view"] == 'phone')
@ -157,16 +171,19 @@ if ($result)
print "</tr>\n";
// Ligne des champs de filtres
print '<form method="get" action="index.php">';
print '<form method="post" action="index.php">';
print '<input type="hidden" name="view" value="'.$view.'">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<tr class="liste_titre">';
print '<td>';
print '<input class="flat" type="text" name="search_nom" value="'.$_GET["search_nom"].'">';
print '<input class="flat" type="text" name="search_nom" value="'.$search_nom.'">';
print '</td>';
print '<td>';
print '<input class="flat" type="text" name="search_prenom" value="'.$_GET["search_prenom"].'">';
print '<input class="flat" type="text" name="search_prenom" value="'.$search_prenom.'">';
print '</td>';
print '<td>';
print '<input class="flat" type="text" name="search_societe" value="'.$_GET["search_societe"].'">';
print '<input class="flat" type="text" name="search_societe" value="'.$search_societe.'">';
print '</td>';
print '<td>';
print '&nbsp;';
@ -184,11 +201,14 @@ if ($result)
else
{
print '<td>';
print '<input class="flat" type="text" name="search_email" value="'.$_GET["search_email"].'">';
print '<input class="flat" type="text" name="search_email" value="'.$search_email.'">';
print '</td>';
}
print '<td><input class="button" type="submit" value="'.$langs->trans("Search").'"></td>';
print '<td>';
print '<input type="submit" class="button" name="button_search" value="'.$langs->trans("Search").'">';
print '&nbsp; <input type="submit" class="button" name="button_removefilter" value="'.$langs->trans("RemoveFilter").'">';
print '</td>';
print '</tr>';
print '</form>';

View File

@ -19,7 +19,7 @@
* $Id$
* $Source$
*/
/*!
\file htdocs/societe.php
\ingroup societe
@ -50,10 +50,12 @@ if ($user->societe_id > 0)
llxHeader();
$search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"];
$search_ville=isset($_GET["search_ville"])?$_GET["search_ville"]:$_POST["search_ville"];
$socname=isset($_GET["socname"])?$_GET["socname"]:$_POST["socname"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
$page=$_GET["page"];
if ($sortorder == "") {
@ -79,6 +81,8 @@ $modesearch=isset($_GET["mode-search"])?$_GET["mode-search"]:$_POST["mode-search
if ($mode == 'search')
{
$_POST["search_nom"]="$socname";
$sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s ";
$sql .= " WHERE s.nom like '%".$socname."%'";
@ -100,7 +104,11 @@ if ($mode == 'search')
$socid = $user->societe_id;
}
}
if ($_POST["button_removefilter"] == $langs->trans("RemoveFilter")) {
$socname="";
$search_nom="";
$search_ville="";
}
/*
* Mode Liste
@ -122,12 +130,12 @@ if (strlen($stcomm)) {
$sql .= " AND s.fk_stcomm=$stcomm";
}
if (strlen($_GET["search_nom"])) {
$sql .= " AND s.nom LIKE '%".$_GET["search_nom"]."%'";
if ($search_nom) {
$sql .= " AND s.nom LIKE '%".$search_nom."%'";
}
if (strlen($_GET["search_ville"])) {
$sql .= " AND s.ville LIKE '%".$_GET["search_ville"]."%'";
if ($search_ville) {
$sql .= " AND s.ville LIKE '%".$search_ville."%'";
}
if ($socname)
@ -148,28 +156,26 @@ if ($result)
print_barre_liste($title, $page, "societe.php",$params,$sortfield,$sortorder,'',$num);
if ($title_filtre)
{
print $langs->trans("Filter:")." $title_filtre";
print ' &nbsp; <a href="societe.php">'.$langs->trans("RemoveFilter").'</a>';
}
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Company"),"societe.php","s.nom", $params);
print_liste_field_titre($langs->trans("Town"),"societe.php","s.ville",$params,"",'width="25%"');
print '<td colspan="2" align="center">'.$langs->trans("Cards").'</td>';
print_liste_field_titre($langs->trans("Company"),"societe.php","s.nom", $params,"&search_nom=$search_nom&search_ville=$search_ville","",$sortfield);
print_liste_field_titre($langs->trans("Town"),"societe.php","s.ville",$params,"&search_nom=$search_nom&search_ville=$search_ville",'width="25%"',$sortfield);
print '<td colspan="2" align="center">&nbsp;</td>';
print "</tr>\n";
print '<form method="get" action="societe.php">';
print '<form method="post" action="societe.php">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<tr class="liste_titre">';
print '<td valign="right">';
print '<input type="text" name="search_nom" value="'.$_GET["search_nom"].'">';
print '<input type="text" name="search_nom" value="'.$search_nom.'">';
print '</td>';
print '<td valign="right">';
print '<input type="text" name="search_ville" value="'.$_GET["search_ville"].'">';
print '</td><td colspan="2"><input type="submit"></td>';
print '<input type="text" name="search_ville" value="'.$search_ville.'">';
print '</td><td colspan="2" align="center">';
print '<input type="submit" class="button" name="button_search" value="'.$langs->trans("Search").'">';
print '&nbsp; <input type="submit" class="button" name="button_removefilter" value="'.$langs->trans("RemoveFilter").'">';
print '</td>';
print "</tr>\n";
@ -183,7 +189,7 @@ if ($result)
print "<a href=\"soc.php?socid=$obj->idp\">";
print img_file();
print "</a>&nbsp;<a href=\"soc.php?socid=$obj->idp\">$obj->nom</a></td>\n";
print "<td>".$obj->ville."&nbsp;</TD>\n";
print "<td>".$obj->ville."&nbsp;</td>\n";
print '<td align="center">';
if ($obj->client==1)
{
@ -216,7 +222,7 @@ if ($result)
}
else
{
print $db->error() . ' ' . $sql;
dolibarr_print_error($db);
}
$db->close();