From 0da7c26b1e2c54121dac9bf3a1afd4b6f3c76468 Mon Sep 17 00:00:00 2001 From: Philippe Grand Date: Sun, 12 Jun 2011 21:25:59 +0000 Subject: [PATCH] enhancements & uniformize code --- htdocs/comm/prospect/prospects.php | 43 +++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/prospect/prospects.php b/htdocs/comm/prospect/prospects.php index c51c70d5422..1ba4d97c6b5 100644 --- a/htdocs/comm/prospect/prospects.php +++ b/htdocs/comm/prospect/prospects.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2011 Philippe Grand * * 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 @@ -37,12 +38,16 @@ $socid = GETPOST("socid",'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe',$socid,''); -$socname=GETPOST("socname",'alpha'); -$stcomm=GETPOST("stcomm",'int'); +$socname = GETPOST("socname",'alpha'); +$stcomm = GETPOST("stcomm",'int'); +$search_nom = GETPOST("search_nom"); +$search_ville = GETPOST("search_ville"); +$search_departement = GETPOST("search_departement"); +$search_datec = GETPOST("search_datec"); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); +$page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; @@ -51,7 +56,7 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="s.nom"; $search_level_from = GETPOST("search_level_from","alpha"); -$search_level_to = GETPOST("search_level_to","alpha"); +$search_level_to = GETPOST("search_level_to","alpha"); // If both parameters are set, search for everything BETWEEN them if ($search_level_from != '' && $search_level_to != '') @@ -161,7 +166,7 @@ $htmlother=new FormOther($db); $sql = "SELECT s.rowid, s.nom, s.ville, s.datec, s.datea, s.status as status,"; $sql.= " st.libelle as stcomm, s.prefix_comm, s.fk_stcomm, s.fk_prospectlevel,"; $sql.= " d.nom as departement"; -// Updated by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/enhance-prospect-searching.html) +// Updated by Matelli // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; // We'll need these fields in order to filter by categ @@ -181,8 +186,10 @@ if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed tab if ($search_categ) $sql.= " AND s.rowid = cs.fk_societe"; // Join for the needed table to filter by categ if (isset($stcomm) && $stcomm != '') $sql.= " AND s.fk_stcomm=".$stcomm; -if ($_GET["search_nom"]) $sql .= " AND s.nom like '%".$db->escape(strtolower($_GET["search_nom"]))."%'"; -if ($_GET["search_ville"]) $sql .= " AND s.ville like '%".$db->escape(strtolower($_GET["search_ville"]))."%'"; +if ($search_nom) $sql .= " AND s.nom like '%".$db->escape(strtolower($search_nom))."%'"; +if ($search_ville) $sql .= " AND s.ville like '%".$db->escape(strtolower($search_ville))."%'"; +if ($search_departement) $sql .= " AND d.nom like '%".$db->escape(strtolower($search_departement))."%'"; +if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'"; // Insert levels filters if ($search_levels) { @@ -233,8 +240,8 @@ if ($resql) llxHeader('',$langs->trans("ThirdParty"),$help_url); } - $param='&stcomm='.$stcomm.'&search_nom='.urlencode($_GET["search_nom"]).'&search_ville='.urlencode($_GET["search_ville"]); - // Added by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/enhance-prospect-searching.html) + $param='&stcomm='.$stcomm.'&search_nom='.urlencode($search_nom).'&search_ville='.urlencode($search_ville); + // Added by Matelli // Store the status filter in the URL if (isSet($search_cstc)) { @@ -296,18 +303,18 @@ if ($resql) print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; - print ' '; + print ''; + print ''; print ''; - print ''; - print ' '; + print ''; + print ''; print ''; - // Added by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/enhance-prospect-searching.html) + // Added by Matelli print ''; // Generate in $options_from the list of each option sorted $options_from = ''; @@ -364,7 +371,7 @@ if ($resql) $var=!$var; - print ""; + print ''; print ''; $prospectstatic->id=$obj->rowid; $prospectstatic->nom=$obj->nom; @@ -421,4 +428,4 @@ else $db->close(); llxFooter('$Date$ - $Revision$'); -?> +?> \ No newline at end of file