[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/comm/ -> clients.php (source)

   1  <?php
   2  /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: clients.php,v 1.32 2005/08/21 19:09:05 rodolphe Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/clients.php,v $
  21   *
  22   */
  23  
  24  /**
  25     \file       htdocs/comm/clients.php
  26     \ingroup    commercial, societe
  27     \brief      Liste des clients
  28     \version    $Revision: 1.32 $
  29  */
  30  
  31  require ("./pre.inc.php");
  32  
  33  if (!$user->rights->societe->lire) accessforbidden();
  34  
  35  // Sécurité accés client
  36  if ($user->societe_id > 0) 
  37  {
  38    $action = '';
  39    $socidp = $user->societe_id;
  40  }
  41  
  42  $page=$_GET["page"];
  43  $sortorder=$_GET["sortorder"];
  44  $sortfield=$_GET["sortfield"];
  45  
  46  if ($page == -1) { $page = 0 ; }
  47  $offset = $conf->liste_limit * $_GET["page"] ;
  48  $pageprev = $_GET["page"] - 1;
  49  $pagenext = $_GET["page"] + 1;
  50  
  51  $search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"];
  52  $search_ville=isset($_GET["search_ville"])?$_GET["search_ville"]:$_POST["search_ville"];
  53  $search_code=isset($_GET["search_code"])?$_GET["search_contract"]:$_POST["search_code"];
  54  
  55  
  56  $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 ";
  57  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st ";
  58  $sql .= " WHERE s.fk_stcomm = st.id AND s.client=1";
  59  
  60  if ($socidp)           $sql .= " AND s.idp = $socidp";
  61  if ($user->societe_id) $sql .= " AND s.idp = " .$user->societe_id;
  62  
  63  if ($search_nom)   $sql .= " AND s.nom like '%".strtolower($search_nom)."%'";
  64  if ($search_ville) $sql .= " AND s.ville like '%".strtolower($search_ville)."%'";
  65  if ($search_code)  $sql .= " AND s.code_client like '%".strtolower($search_code)."%'";
  66  
  67  if ($socname)
  68  {
  69    $sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'";
  70    $sortfield = "lower(s.nom)";
  71    $sortorder = "ASC";
  72  }
  73  
  74  if (! $sortorder) $sortorder="ASC";
  75  if (! $sortfield) $sortfield="s.nom";
  76  
  77  $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit +1, $offset);
  78  
  79  
  80  $result = $db->query($sql);
  81  if ($result)
  82  {
  83    $num = $db->num_rows($result);
  84  
  85    llxHeader();
  86  
  87    print_barre_liste($langs->trans("ListOfCustomers"), $page, "clients.php","",$sortfield,$sortorder,"",$num);
  88  
  89    $i = 0;
  90    
  91    $addu = "&amp;search_nom=".$search_nom."&amp;search_code=".$search_code."&amp;search_ville=".$search_ville;
  92    print '<table class="liste">';
  93    print '<tr class="liste_titre">';
  94    print_liste_field_titre($langs->trans("Company"),"clients.php","s.nom",$addu,"","",$sortfield);
  95    print_liste_field_titre($langs->trans("Town"),"clients.php","s.ville",$addu,"","",$sortfield);
  96    print_liste_field_titre($langs->trans("CustomerCode"),"clients.php","s.code_client",$addu,"","",$sortfield);
  97    print_liste_field_titre($langs->trans("DateCreation"),"clients.php","datec",$addu,"",'align="center"',$sortfield);
  98    print '<td class="liste_titre">&nbsp;</td>';
  99    print "</tr>\n";
 100  
 101    print '<form method="get" action="clients.php">';
 102    print '<tr class="liste_titre">';
 103    print '<td class="liste_titre" valign="right">';
 104    print '<input type="text" class="flat" name="search_nom" value="'.stripslashes($search_nom).'">';
 105    print '</td><td class="liste_titre" valign="right">';
 106    print '<input type="text" class="flat" name="search_ville" value="'.$search_ville.'" size="10">';
 107    print '</td><td class="liste_titre" valign="right">';
 108    print '<input type="text" class="flat" name="search_code" value="'.$search_code.'" size="10">';
 109    print '</td><td class="liste_titre">&nbsp;</td>';
 110    print '<td class="liste_titre" align="center"><input class="liste_titre" type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
 111    print "</td>";
 112    print "</tr>\n";
 113    print '</form>';
 114    
 115    $var=True;
 116  
 117    while ($i < min($num,$conf->liste_limit))
 118      {
 119        $obj = $db->fetch_object($result);
 120        
 121        $var=!$var;
 122  
 123        print "<tr $bc[$var]>";
 124        print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">';
 125        print img_object($langs->trans("ShowCustomer"),"company");
 126        print '</a>&nbsp;<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.stripslashes($obj->nom).'</a></td>';
 127        print '<td>'.$obj->ville.'</td>';
 128        print '<td>'.$obj->code_client.'</td>';
 129        print '<td align="center">'.dolibarr_print_date($obj->datec).'</td>';
 130        print '<td align="center">';
 131        if (defined("MAIN_MODULE_DOSSIER") && MAIN_MODULE_DOSSIER == 1)
 132      {
 133        print '<a href="'.DOL_URL_ROOT.'/dossier/client/fiche.php?id='.$obj->idp.'">';
 134        print img_folder();
 135        print '</a>';
 136      }
 137        else
 138      {
 139        print "&nbsp;";
 140      }
 141        print "</td></tr>\n";
 142        $i++;
 143      }
 144    print "</table>";
 145    $db->free($result);
 146  }
 147  else
 148  {
 149    dolibarr_print_error($db);
 150  }
 151  
 152  $db->close();
 153  
 154  llxFooter('$Date: 2005/08/21 19:09:05 $ - $Revision: 1.32 $');
 155  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics