dolibarr/htdocs/comm/clients.php

155 lines
4.3 KiB
PHP
Raw Normal View History

<?php
2004-01-31 13:43:36 +01:00
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2005-01-08 23:10:48 +01:00
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
2002-05-10 14:28:10 +02:00
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
2003-03-23 16:53:03 +01:00
* $Id$
* $Source$
*
2002-05-10 14:28:10 +02:00
*/
2004-12-25 19:44:15 +01:00
2005-01-08 23:10:48 +01:00
/** \file htdocs/comm/clients.php
2004-12-25 19:44:15 +01:00
\ingroup commercial, societe
\brief Liste des clients
\version $Revision$
*/
2003-09-11 18:30:47 +02:00
require("./pre.inc.php");
2003-03-23 16:53:03 +01:00
/*
* S<EFBFBD>curit<EFBFBD> acc<EFBFBD>s client
*/
if ($user->societe_id > 0)
{
$action = '';
$socidp = $user->societe_id;
}
2004-07-30 09:40:08 +02:00
$page=$_GET["page"];
$sortorder=$_GET["sortorder"];
$sortfield=$_GET["sortfield"];
2003-03-23 16:53:03 +01:00
if ($page == -1) { $page = 0 ; }
2002-05-10 14:28:10 +02:00
2004-07-13 19:40:42 +02:00
$offset = $conf->liste_limit * $_GET["page"] ;
$pageprev = $_GET["page"] - 1;
$pagenext = $_GET["page"] + 1;
2002-05-10 14:28:10 +02:00
2004-12-01 16:28:28 +01:00
$sql = "SELECT s.idp, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm, s.code_client ";
2004-10-11 21:30:53 +02:00
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st ";
$sql .= " WHERE s.fk_stcomm = st.id AND s.client=1";
2003-03-23 16:53:03 +01:00
2004-07-30 09:40:08 +02:00
if ($socidp)
{
$sql .= " AND s.idp = $socidp";
}
2004-10-11 21:30:53 +02:00
if ($_GET["search_nom"])
2003-03-23 16:53:03 +01:00
{
2004-10-11 21:30:53 +02:00
$sql .= " AND s.nom like '%".strtolower($_GET["search_nom"])."%'";
2003-03-23 16:53:03 +01:00
}
2002-05-10 14:28:10 +02:00
2004-12-01 16:28:28 +01:00
if ($_GET["search_code"])
{
$sql .= " AND s.code_client like '%".strtolower($_GET["search_code"])."%'";
}
2003-03-23 16:53:03 +01:00
if ($user->societe_id)
{
$sql .= " AND s.idp = " .$user->societe_id;
}
if ($socname)
{
$sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'";
$sortfield = "lower(s.nom)";
$sortorder = "ASC";
}
if ($sortorder == "")
{
$sortorder="ASC";
}
if ($sortfield == "")
{
$sortfield="s.nom";
2003-03-23 16:53:03 +01:00
}
2003-07-10 20:55:16 +02:00
$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit +1, $offset);
2002-05-10 14:28:10 +02:00
2003-03-23 16:53:03 +01:00
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows();
2004-07-30 09:40:08 +02:00
llxHeader();
2004-11-16 22:32:25 +01:00
print_barre_liste("Liste des clients", $page, "clients.php","",$sortfield,$sortorder,"",$num);
2003-07-10 20:55:16 +02:00
2003-03-23 16:53:03 +01:00
$i = 0;
$addu = "&amp;page=$page&amp;begin=$begin&amp;search_nom=".$_GET["search_nom"];
2004-08-23 10:17:11 +02:00
print '<table class="liste">';
print '<tr class="liste_titre">';
2005-01-08 23:12:54 +01:00
print_liste_field_titre($langs->trans("Company"),"clients.php","s.nom",$addu,"","",$sortfield);
2004-12-25 19:44:15 +01:00
print_liste_field_titre($langs->trans("CustomerCode"),"clients.php","s.code_client",$addu,"","",$sortfield);
print_liste_field_titre($langs->trans("Town"),"clients.php","s.ville",$addu,"","",$sortfield);
2004-12-09 10:38:46 +01:00
print "<td>&nbsp;</td></tr>\n";
2004-10-11 21:30:53 +02:00
print '<form method="get" action="clients.php">';
print '<tr class="liste_titre">';
print '<td valign="right">';
2005-01-19 22:53:00 +01:00
print '<input type="text" class="flat" name="search_nom" value="'.stripslashes($_GET["search_nom"]).'">';
2004-12-01 16:28:28 +01:00
print '</td><td valign="right">';
2005-01-19 22:53:00 +01:00
print '<input type="text" class="flat" name="search_code" value="'.$_GET["search_code"].'">';
2005-01-08 23:12:54 +01:00
print '</td><td>&nbsp;</td><td align="center"><input class="button" type="submit" value="'.$langs->trans("Search").'">';
2004-10-11 21:30:53 +02:00
print "</td>";
print "</tr>\n";
2003-03-23 16:53:03 +01:00
$var=True;
2003-07-10 20:55:16 +02:00
while ($i < min($num,$conf->liste_limit))
2003-03-23 16:53:03 +01:00
{
$obj = $db->fetch_object($result);
2002-05-10 14:28:10 +02:00
$var=!$var;
2004-08-23 10:17:11 +02:00
print "<tr $bc[$var]>";
2004-01-31 17:41:29 +01:00
print '<td><a href="fiche.php?socid='.$obj->idp.'">';
print img_file();
2004-12-24 14:22:56 +01:00
print "</a>&nbsp;<a href=\"fiche.php?socid=$obj->idp\">".stripslashes($obj->nom)."</A></td>\n";
2004-12-01 16:28:28 +01:00
print "<td>".$obj->code_client."&nbsp;</td>\n";
2004-02-13 15:08:50 +01:00
print "<td>".$obj->ville."&nbsp;</td>\n";
2004-12-25 19:44:15 +01:00
print '<td align="center"><a href="'.DOL_URL_ROOT.'/dossier/client/fiche.php?id='.$obj->idp.'">';
2004-12-09 10:38:46 +01:00
print img_folder();
print "</a></td></tr>\n";
2002-05-10 14:28:10 +02:00
$i++;
}
2004-08-23 10:17:11 +02:00
print "</table>";
2003-03-23 16:53:03 +01:00
$db->free();
}
else
{
2005-01-08 23:10:48 +01:00
dolibarr_print_error($db);
2003-03-23 16:53:03 +01:00
}
2002-05-10 14:28:10 +02:00
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>