Skip to content
Snippets Groups Projects
Commit 88a7c9c5 authored by Rodolphe Quiedeville's avatar Rodolphe Quiedeville
Browse files

Ajout formulaire de recherche

parent 9f0d557e
Branches
No related tags found
No related merge requests found
<?php <?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 ric Seigne <erics@rycks.com> * Copyright (C) 2003 ric Seigne <erics@rycks.com>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* *
...@@ -39,7 +39,7 @@ $user->getrights('commande'); ...@@ -39,7 +39,7 @@ $user->getrights('commande');
$user->getrights('projet'); $user->getrights('projet');
llxHeader(); llxHeader('','Contacts Clients');
$sortorder=$_GET["sortorder"]; $sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"]; $sortfield=$_GET["sortfield"];
...@@ -59,9 +59,6 @@ if ($user->societe_id > 0) ...@@ -59,9 +59,6 @@ if ($user->societe_id > 0)
} }
if ($sortorder == "") if ($sortorder == "")
{ {
$sortorder="ASC"; $sortorder="ASC";
...@@ -76,20 +73,22 @@ $limit = $conf->liste_limit; ...@@ -76,20 +73,22 @@ $limit = $conf->liste_limit;
$offset = $limit * $page ; $offset = $limit * $page ;
if ($type == "c") { if ($type == "c")
{
$label = " clients"; $label = " clients";
$urlfiche="fiche.php"; $urlfiche="fiche.php";
} }
if ($type == "p") { if ($type == "p")
{
$label = " prospects"; $label = " prospects";
$urlfiche="prospect/fiche.php"; $urlfiche="prospect/fiche.php";
} }
if ($type == "f") { if ($type == "f")
{
$label = " fournisseurs"; $label = " fournisseurs";
$urlfiche="fiche.php"; $urlfiche="fiche.php";
} }
/* /*
* *
* Mode liste * Mode liste
...@@ -97,22 +96,20 @@ if ($type == "f") { ...@@ -97,22 +96,20 @@ if ($type == "f") {
* *
*/ */
$sql = "SELECT s.idp, s.nom, st.libelle as stcomm, p.idp as cidp, p.name, p.firstname, p.email, p.phone "; $sql = "SELECT s.idp, s.nom, st.libelle as stcomm";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."socpeople as p, ".MAIN_DB_PREFIX."c_stcomm as st"; $sql .= ", p.idp as cidp, p.name, p.firstname, p.email, p.phone ";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."socpeople as p";
$sql .= " , ".MAIN_DB_PREFIX."c_stcomm as st";
$sql .= " WHERE s.fk_stcomm = st.id AND s.idp = p.fk_soc"; $sql .= " WHERE s.fk_stcomm = st.id AND s.idp = p.fk_soc";
if ($type == "c") { if ($type == "c") $sql .= " AND s.client = 1";
$sql .= " AND s.client = 1"; if ($type == "p") $sql .= " AND s.client = 2";
} if ($type == "f") $sql .= " AND s.fournisseur = 1";
if ($type == "p") {
$sql .= " AND s.client = 2";
}
if ($type == "f") {
$sql .= " AND s.fournisseur = 1";
}
if (strlen($stcomm)) { if (strlen($stcomm))
{
$sql .= " AND s.fk_stcomm=$stcomm"; $sql .= " AND s.fk_stcomm=$stcomm";
} }
...@@ -121,6 +118,21 @@ if (strlen($begin)) // filtre sur la premiere lettre du nom ...@@ -121,6 +118,21 @@ if (strlen($begin)) // filtre sur la premiere lettre du nom
$sql .= " AND upper(p.name) like '$begin%'"; $sql .= " AND upper(p.name) like '$begin%'";
} }
if (trim($_GET["search_nom"]))
{
$sql .= " AND p.name like '%".trim($_GET["search_nom"])."%'";
}
if (trim($_GET["search_prenom"]))
{
$sql .= " AND p.firstname like '%".trim($_GET["search_prenom"])."%'";
}
if (trim($_GET["search_societe"]))
{
$sql .= " AND s.nom like '%".trim($_GET["search_societe"])."%'";
}
if ($_GET[contactname]) // acces a partir du module de recherche if ($_GET[contactname]) // acces a partir du module de recherche
{ {
$sql .= " AND ( lower(p.name) like '%".strtolower($_GET[contactname])."%' OR lower(p.firstname) like '%".strtolower($_GET[contactname])."%') "; $sql .= " AND ( lower(p.name) like '%".strtolower($_GET[contactname])."%' OR lower(p.firstname) like '%".strtolower($_GET[contactname])."%') ";
...@@ -132,7 +144,7 @@ if ($socid) { ...@@ -132,7 +144,7 @@ if ($socid) {
$sql .= " AND s.idp = $socid"; $sql .= " AND s.idp = $socid";
} }
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset); $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($limit+1, $offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
...@@ -146,9 +158,20 @@ if ($result) ...@@ -146,9 +158,20 @@ if ($result)
print_liste_field_titre($langs->trans("Lastname"),"contact.php","lower(p.name)", $begin,"&amp;type=$type"); print_liste_field_titre($langs->trans("Lastname"),"contact.php","lower(p.name)", $begin,"&amp;type=$type");
print_liste_field_titre($langs->trans("Firstname"),"contact.php","lower(p.firstname)", $begin,"&amp;type=$type"); print_liste_field_titre($langs->trans("Firstname"),"contact.php","lower(p.firstname)", $begin,"&amp;type=$type");
print_liste_field_titre($langs->trans("Company"),"contact.php","lower(s.nom)", $begin,"&amp;type=$type"); print_liste_field_titre($langs->trans("Company"),"contact.php","lower(s.nom)", $begin,"&amp;type=$type");
print '<td>'.$langs->trans("Lastname").'</td>'; print '<td>'.$langs->trans("Email").'</td>';
print '<td>'.$langs->trans("Phone").'</td>'; print '<td>'.$langs->trans("Phone").'</td>';
print "</tr>\n"; print "</tr>\n";
print '<form action="contact.php?type='.$_GET["type"].'" method="GET">';
print '<tr class="liste_titre">';
print '<td><input name="search_nom" size="12" value="'.$_GET["search_nom"].'"></td>';
print '<td><input name="search_prenom" size="12" value="'.$_GET["search_prenom"].'"></td>';
print '<td><input name="search_societe" size="12" value="'.$_GET["search_societe"].'"></td>';
print '<td>&nbsp;</td>';
print '<td><input type="submit"</td>';
print "</tr>\n";
print '</form>';
$var=True; $var=True;
$i = 0; $i = 0;
while ($i < min($num,$limit)) while ($i < min($num,$limit))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment