* Copyright (C) 2004-2006 Laurent Destailleur * * 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. * * $Id$ * $Source$ */ /** \file htdocs/comm/clients.php \ingroup commercial, societe \brief Liste des clients \version $Revision$ */ require("./pre.inc.php"); if (!$user->rights->societe->lire) accessforbidden(); // Sécurité accés client if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } $page=$_GET["page"]; $sortorder=$_GET["sortorder"]; $sortfield=$_GET["sortfield"]; if ($page == -1) { $page = 0 ; } $offset = $conf->liste_limit * $_GET["page"] ; $pageprev = $_GET["page"] - 1; $pagenext = $_GET["page"] + 1; $search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"]; $search_ville=isset($_GET["search_ville"])?$_GET["search_ville"]:$_POST["search_ville"]; $search_code=isset($_GET["search_code"])?$_GET["search_code"]:$_POST["search_code"]; $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"; if (!$user->rights->commercial->client->voir) $sql .= ", sc.fk_soc, sc.fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st"; if (!$user->rights->commercial->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE s.fk_stcomm = st.id AND s.client=1"; if ($socid) $sql .= " AND s.idp = $socid"; if ($user->societe_id) $sql .= " AND s.idp = " .$user->societe_id; if (!$user->rights->commercial->client->voir) $sql .= " AND s.idp = sc.fk_soc AND sc.fk_user = " .$user->id; if ($search_nom) $sql .= " AND s.nom like '%".addslashes(strtolower($search_nom))."%'"; if ($search_ville) $sql .= " AND s.ville like '%".addslashes(strtolower($search_ville))."%'"; if ($search_code) $sql .= " AND s.code_client like '%".addslashes(strtolower($search_code))."%'"; if ($socname) { $sql .= " AND lower(s.nom) like '%".addslashes(strtolower($socname))."%'"; $sortfield = "lower(s.nom)"; $sortorder = "ASC"; } if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="s.nom"; $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit +1, $offset); /* * Affichage liste */ llxHeader(); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $param = "&search_nom=".$search_nom."&search_code=".$search_code."&search_ville=".$search_ville; print_barre_liste($langs->trans("ListOfCustomers"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num); $i = 0; print '
'."\n"; print ''."\n"; print ''; print_liste_field_titre($langs->trans("Company"),"clients.php","s.nom",$param,"","",$sortfield); print_liste_field_titre($langs->trans("Town"),"clients.php","s.ville",$param,"","",$sortfield); print_liste_field_titre($langs->trans("CustomerCode"),"clients.php","s.code_client",$param,"","",$sortfield); print_liste_field_titre($langs->trans("DateCreation"),"clients.php","datec",$param,"",'align="center"',$sortfield); print ''; print "\n"; print ''; print ''; print ''; print "\n"; $var=True; while ($i < min($num,$conf->liste_limit)) { $obj = $db->fetch_object($result); $var=!$var; print ""; print ''; print ''; print ''; print ''; print '\n"; $i++; } //print_barre_liste($langs->trans("ListOfCustomers"), $page, $_SERVER["PHP_SELF"],'',$sortfield,$sortorder,'',$num); print "
 
'; print ''; print ''; print ''; print ''; print ''; print ' 
'; print img_object($langs->trans("ShowCustomer"),"company"); print ' '.stripslashes($obj->nom).''.$obj->ville.''.$obj->code_client.''.dolibarr_print_date($obj->datec).''; if (defined("MAIN_MODULE_DOSSIER") && MAIN_MODULE_DOSSIER == 1) { print ''; print img_folder(); print ''; } else { print " "; } print "
\n"; print "
\n"; $db->free($result); } else { dolibarr_print_error($db); } $db->close(); llxFooter('$Date$ - $Revision$'); ?>