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

   1  <?php
   2  /* Copyright (C) 2001-2004 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: societe.php,v 1.45 2005/11/22 22:30:02 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/societe.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/societe.php
  25          \ingroup    societe
  26          \brief      Page des societes
  27          \version    $Revision: 1.45 $
  28  */
  29   
  30  require_once ("./pre.inc.php");
  31  
  32  if (!$user->rights->societe->lire)
  33    accessforbidden();
  34  
  35  include_once (DOL_DOCUMENT_ROOT."/contact.class.php");
  36  
  37  $langs->load("companies");
  38  $langs->load("customers");
  39  $langs->load("suppliers");
  40  
  41  
  42  // Sécurité accés client
  43  $socid=0; 
  44  if ($user->societe_id > 0) 
  45  {
  46      $action = '';
  47      $socid = $user->societe_id;
  48  }
  49  
  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  
  54  $socname=isset($_GET["socname"])?$_GET["socname"]:$_POST["socname"];
  55  $sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
  56  $sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
  57  $page=isset($_GET["page"])?$_GET["page"]:$_POST["page"];
  58  
  59  if (! $sortorder) $sortorder="ASC";
  60  if (! $sortfield) $sortfield="nom";
  61  
  62  if ($page == -1) { $page = 0 ; }
  63  
  64  $offset = $conf->liste_limit * $page ;
  65  $pageprev = $page - 1;
  66  $pagenext = $page + 1;
  67  
  68  
  69  /*
  70   * Actions
  71   *
  72   */
  73   
  74  // Recherche
  75  $mode=isset($_GET["mode"])?$_GET["mode"]:$_POST["mode"];
  76  $modesearch=isset($_GET["mode-search"])?$_GET["mode-search"]:$_POST["mode-search"];
  77  
  78  if ($mode == 'search')
  79  {
  80      $_POST["search_nom"]="$socname";
  81  
  82      $sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s ";
  83      $sql .= " WHERE s.nom like '%".$socname."%'";
  84  
  85      $result=$db->query($sql);
  86      if ($result)
  87      {
  88          if ($db->num_rows($result) == 1)
  89          {
  90              $obj = $db->fetch_object($result);
  91              $socid = $obj->idp;
  92              header("location: soc.php?socid=$socid");
  93              exit;
  94          }
  95          $db->free($result);
  96      }
  97      // Sécurité accès client
  98      if ($user->societe_id > 0) 
  99      {
 100          $action = '';
 101          $socid = $user->societe_id;
 102      }
 103  }
 104  
 105  
 106  llxHeader();
 107  
 108  // As-t-on cliqué sur purge des criètres de recherche
 109  if (isset($_POST["button_removefilter_x"]))
 110  {
 111      $socname="";
 112      $search_nom="";
 113      $search_ville="";
 114  }
 115  
 116  
 117  /*
 118   * Mode Liste
 119   *
 120   */
 121  
 122  $title=$langs->trans("ListOfCompanies");
 123  
 124  $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.client, s.fournisseur";
 125  $sql.= ", s.siren";
 126  $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
 127  $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
 128  $sql.= " WHERE s.fk_stcomm = st.id";
 129  if ($user->societe_id > 0)
 130  {
 131    $sql .= " AND s.idp = " . $user->societe_id;
 132  }
 133  
 134  if ($socname)
 135  {
 136    $search_nom=$socname;
 137  }
 138  
 139  if (strlen($stcomm)) {
 140    $sql .= " AND s.fk_stcomm=$stcomm";
 141  }
 142  
 143  if ($search_nom) {
 144    $sql .= " AND (s.nom LIKE '%".$search_nom."%' OR s.code_client LIKE '%".$search_nom."%')";
 145  }
 146  
 147  if ($search_ville) {
 148    $sql .= " AND s.ville LIKE '%".$search_ville."%'";
 149  }
 150  
 151  if ($_POST["search_siren"]) {
 152    $sql .= " AND s.siren LIKE '%".$_POST["search_siren"]."%'";
 153  }
 154  
 155  $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
 156  
 157  $result = $db->query($sql);
 158  if ($result)
 159  {
 160    $num = $db->num_rows($result);
 161    $i = 0;
 162  
 163    $params = "&amp;socname=$socname";
 164  
 165    print_barre_liste($title, $page, "societe.php",$params,$sortfield,$sortorder,'',$num);
 166      
 167    // Lignes des titres
 168    print '<table class="liste" width="100%">';
 169    print '<tr class="liste_titre">';
 170    print_liste_field_titre($langs->trans("Company"),"societe.php","s.nom", $params,"&search_nom=$search_nom&search_ville=$search_ville","",$sortfield);
 171    print_liste_field_titre($langs->trans("Town"),"societe.php","s.ville",$params,"&search_nom=$search_nom&search_ville=$search_ville",'',$sortfield);
 172    print_liste_field_titre($langs->trans("SIREN"),"societe.php","s.siren",$params,"&search_nom=$search_nom&search_ville=$search_ville",'',$sortfield);
 173    print '<td class="liste_titre" colspan="2" align="center">&nbsp;</td>';
 174    print "</tr>\n";
 175  
 176    // Lignes des champs de filtre
 177    print '<form method="post" action="societe.php" name="formfilter">';
 178    print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
 179    print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 180    print '<tr class="liste_titre">';
 181    print '<td class="liste_titre" valign="right">';
 182    print '<input class="flat" type="text" name="search_nom" value="'.stripslashes($search_nom).'">';
 183    print '</td><td class="liste_titre" valign="right">';
 184    print '<input class="flat" type="text" name="search_ville" value="'.stripslashes($search_ville).'">';
 185    print '</td><td class="liste_titre" valign="right">';
 186    print '<input class="flat" size="10" type="text" name="search_siren" value="'.$_POST["search_siren"].'">';
 187    print '</td><td class="liste_titre" colspan="2" align="right">';
 188    print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
 189    print '&nbsp; ';
 190    print '<input type="image" class="liste_titre" name="button_removefilter" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" alt="'.$langs->trans("RemoveFilter").'">';
 191    print '</td>';
 192    print "</tr>\n";
 193    print '</form>';
 194  
 195    $var=True;
 196  
 197    while ($i < min($num,$conf->liste_limit))
 198      {
 199        $obj = $db->fetch_object();    
 200        $var=!$var;    
 201        print "<tr $bc[$var]><td>";
 202        print "<a href=\"soc.php?socid=$obj->idp\">";
 203        print img_object($langs->trans("ShowCompany"),"company");
 204        print "</a>&nbsp;<a href=\"soc.php?socid=$obj->idp\">".stripslashes($obj->nom)."</a></td>\n";
 205        print "<td>".$obj->ville."&nbsp;</td>\n";
 206        print "<td>".$obj->siren."&nbsp;</td>\n";
 207        print '<td align="center">';
 208        if ($obj->client==1)
 209      {
 210        print "<a href=\"comm/fiche.php?socid=$obj->idp\">".$langs->trans("Customer")."</a>\n";
 211      }
 212        elseif ($obj->client==2)
 213      {
 214        print "<a href=\"comm/prospect/fiche.php?id=$obj->idp\">".$langs->trans("Prospect")."</a>\n";
 215      }
 216        else
 217      {
 218        print "&nbsp;";
 219      }
 220        print "</td><td align=\"center\">";
 221        if ($obj->fournisseur)
 222      {
 223        print '<a href="'.DOL_URL_ROOT.'/fourn/fiche.php?socid='.$obj->idp.'">'.$langs->trans("Supplier").'</a>';
 224      }
 225        else
 226      {
 227        print "&nbsp;";
 228      }
 229        
 230        print '</td></tr>'."\n";
 231        $i++;
 232      }
 233  
 234    print "</table>";
 235    $db->free();
 236  }
 237  else
 238  {
 239    dolibarr_print_error($db);
 240  }
 241  
 242  $db->close();
 243  
 244  llxFooter('$Date: 2005/11/22 22:30:02 $ - $Revision: 1.45 $');
 245  ?>


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