[ 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/compta/ -> clients.php (source)

   1  <?php
   2  /* Copyright (C) 2003-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/09/24 22:28:19 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/clients.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/compta/clients.php
  25          \ingroup    compta
  26          \brief      Page accueil des clients
  27          \version    $Revision: 1.32 $
  28  */
  29   
  30  require_once ("./pre.inc.php");
  31  
  32  $user->getrights("societe");
  33  
  34  if (! $user->rights->societe->lire)
  35    accessforbidden();
  36  
  37  require_once (DOL_DOCUMENT_ROOT."/contact.class.php");
  38  require_once (DOL_DOCUMENT_ROOT."/actioncomm.class.php");
  39  if ($conf->webcal->enabled) require_once(DOL_DOCUMENT_ROOT."/lib/webcal.class.php");
  40  
  41  $langs->load("companies");
  42  
  43  $page=$_GET["page"];
  44  $sortorder=$_GET["sortorder"];
  45  $sortfield=$_GET["sortfield"];
  46  
  47  if (! $sortorder) $sortorder="ASC";
  48  if (! $sortfield) $sortfield="nom";
  49  if ($page == -1) { $page = 0 ; }
  50  $offset = $conf->liste_limit * $page ;
  51  $pageprev = $page - 1;
  52  $pagenext = $page + 1;
  53  
  54  
  55  llxHeader();
  56  
  57  // Sécurité accés client
  58  if ($user->societe_id > 0) 
  59  {
  60    $action = '';
  61    $socidp = $user->societe_id;
  62  }
  63  
  64  if ($action == 'attribute_prefix')
  65  {
  66    $societe = new Societe($db, $socid);
  67    $societe->attribute_prefix($db, $socid);
  68  }
  69  
  70  if ($action == 'recontact')
  71  {
  72    $dr = mktime(0, 0, 0, $remonth, $reday, $reyear);
  73    $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $user->login ."')";
  74    $result = $db->query($sql);
  75  }
  76  
  77  if ($action == 'note')
  78  {
  79    $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='$note' WHERE idp=$socid";
  80    $result = $db->query($sql);
  81  }
  82  
  83  if ($action == 'stcomm')
  84  {
  85    if ($stcommid <> 'null' && $stcommid <> $oldstcomm)
  86      {
  87        $sql = "INSERT INTO ".MAIN_DB_PREFIX."socstatutlog (datel, fk_soc, fk_statut, author) ";
  88        $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $user->login . "')";
  89        $result = @$db->query($sql);
  90        
  91        if ($result)
  92      {
  93        $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=$stcommid WHERE idp=$socid";
  94        $result = $db->query($sql);
  95      }
  96        else
  97      {
  98        $errmesg = "ERREUR DE DATE !";
  99      }
 100      }
 101  
 102    if ($actioncommid)
 103      {
 104        $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm (datea, fk_action, fk_soc, fk_user_author) VALUES ('$dateaction',$actioncommid,$socid,'" . $user->id . "')";
 105        $result = @$db->query($sql);
 106        
 107        if (!$result)
 108      {
 109        $errmesg = "ERREUR DE DATE !";
 110      }
 111      }
 112  }
 113  
 114  /*
 115   * Recherche
 116   *
 117   */
 118  if ($mode == 'search') {
 119    if ($mode-search == 'soc') {
 120      $sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s ";
 121      $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'";
 122    }
 123        
 124    if ( $db->query($sql) ) {
 125      if ( $db->num_rows() == 1) {
 126        $obj = $db->fetch_object();
 127        $socid = $obj->idp;
 128      }
 129      $db->free();
 130    }
 131  }
 132  
 133  
 134  
 135  /*
 136   * Mode Liste
 137   *
 138   */
 139  
 140  $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, s.code_compta ";
 141  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st WHERE s.fk_stcomm = st.id AND s.client=1";
 142  
 143  if (strlen($stcomm))
 144  {
 145    $sql .= " AND s.fk_stcomm=$stcomm";
 146  }
 147  
 148  if ($socname)
 149  {
 150    $sql .= " AND lower(s.nom) like '%".strtolower($socname)."%'";
 151    $sortfield = "lower(s.nom)";
 152    $sortorder = "ASC";
 153  }
 154  
 155  if ($_GET["search_nom"])
 156  {
 157    $sql .= " AND lower(s.nom) like '%".strtolower($_GET["search_nom"])."%'";
 158  }
 159  
 160  if ($_GET["search_compta"])
 161  {
 162    $sql .= " AND s.code_compta like '%".$_GET["search_compta"]."%'";
 163  }
 164  
 165  if ($_GET["search_code_client"])
 166  {
 167    $sql .= " AND s.code_client like '%".$_GET["search_code_client"]."%'";
 168  }
 169  
 170  if (strlen($begin))
 171  {
 172    $sql .= " AND upper(s.nom) like '$begin%'";
 173  }
 174  
 175  if ($user->societe_id)
 176  {
 177    $sql .= " AND s.idp = " .$user->societe_id;
 178  }
 179  
 180  $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
 181  
 182  $result = $db->query($sql);
 183  if ($result)
 184  {
 185    $num = $db->num_rows();
 186    $i = 0;
 187    
 188    if ($action == 'facturer') {
 189        print_barre_liste("Liste des clients facturables", $page, "clients.php","",$sortfield,$sortorder,'',$num);
 190    }
 191    else {
 192        print_barre_liste($langs->trans("ListOfCustomers"), $page, "clients.php","",$sortfield,$sortorder,'',$num);
 193    }
 194    
 195    print '<table class="liste" width="100%">';
 196    print '<tr class="liste_titre">';
 197  
 198    print_liste_field_titre($langs->trans("Company"),"clients.php","s.nom","","",'valign="center"',$sortfield);
 199    print_liste_field_titre($langs->trans("Town"),"clients.php","s.ville","","",'valign="center"',$sortfield);
 200    print_liste_field_titre($langs->trans("AccountancyCode"),"clients.php","s.code_compta","","",'align="left"',$sortfield);
 201    print_liste_field_titre($langs->trans("CustomerCode"),"clients.php","s.code_client","","",'align="left"',$sortfield);
 202    print_liste_field_titre($langs->trans("DateCreation"),"clients.php","datec",$addu,"",'align="center"',$sortfield);
 203    print '<td class="liste_titre">&nbsp;</td>';
 204    print "</tr>\n";
 205  
 206    // Lignes des champs de filtre
 207    print '<form method="GET" action="clients.php">';
 208    print '<tr class="liste_titre">';
 209  
 210    print '<td align="left" class="liste_titre">';
 211    print '<input class="flat" type="text" name="search_nom" value="'.$_GET["search_nom"].'"></td>';
 212  
 213    print '<td class="liste_titre">&nbsp;</td>';
 214  
 215    print '<td align="left" class="liste_titre">';
 216    print '<input class="flat" type="text" size="10" name="search_compta" value="'.$_GET["search_compta"].'">';
 217    print '</td>';
 218  
 219    print '<td align="left" class="liste_titre">';
 220    print '<input class="flat" type="text" size="10" name="search_code_client" value="'.$_GET["search_code_client"].'">';
 221    print '</td>';
 222  
 223    print '<td align="right" colspan="2" class="liste_titre">';
 224    print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" alt="'.$langs->trans("Search").'">';
 225    print '</td>';
 226    print "</tr>\n";
 227    print '</form>';
 228  
 229    $var=True;
 230  
 231    while ($i < min($num,$conf->liste_limit))
 232      {
 233        $obj = $db->fetch_object();
 234        
 235        $var=!$var;
 236  
 237        print "<tr $bc[$var]>";
 238        print '<td><a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">';
 239        print img_object($langs->trans("ShowCustomer"),"company");
 240        print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
 241        print '<td>'.$obj->ville.'&nbsp;</td>';
 242        print '<td align="left">'.$obj->code_compta.'&nbsp;</td>';
 243        print '<td align="left">'.$obj->code_client.'&nbsp;</td>';
 244        print '<td align="center">'.dolibarr_print_date($obj->datec).'</td>';
 245        print '<td align="center">';
 246        if (defined("MAIN_MODULE_DOSSIER") && MAIN_MODULE_DOSSIER == 1)
 247      {
 248        print '<a href="'.DOL_URL_ROOT.'/dossier/client/fiche.php?id='.$obj->idp.'">';
 249        print img_folder();
 250        print '</a>';
 251      }
 252        else
 253      {
 254        print "&nbsp;";
 255      }
 256  
 257  
 258        print "</td></tr>\n";
 259        $i++;
 260      }
 261    print "</table>";
 262    $db->free();
 263  }
 264  else
 265  {
 266    dolibarr_print_error($db);
 267  }
 268  
 269  $db->close();
 270  
 271  llxFooter("<em>Derni&egrave;re modification $Date: 2005/09/24 22:28:19 $ r&eacute;vision $Revision: 1.32 $</em>");
 272  ?>


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