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

   1  <?php
   2  /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2003      Éric Seigne          <erics@rycks.com>
   4   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   5   *
   6   * This program is free software; you can redistribute it and/or modify
   7   * it under the terms of the GNU General Public License as published by
   8   * the Free Software Foundation; either version 2 of the License, or
   9   * (at your option) any later version.
  10   *
  11   * This program is distributed in the hope that it will be useful,
  12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14   * GNU General Public License for more details.
  15   *
  16   * You should have received a copy of the GNU General Public License
  17   * along with this program; if not, write to the Free Software
  18   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19   *
  20   * $Id: contact.php,v 1.25 2005/08/21 19:12:28 rodolphe Exp $
  21   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/contact.php,v $
  22   *
  23   */
  24  
  25  /**
  26          \file       htdocs/comm/contact.php
  27          \ingroup    commercial
  28          \brief      Liste des contacts
  29          \version    $Revision: 1.25 $
  30  */
  31  
  32  require ("./pre.inc.php");
  33  
  34  if (!$user->rights->societe->lire) accessforbidden();
  35  
  36  $langs->load("companies");
  37  
  38  llxHeader('','Contacts');
  39  
  40  $sortfield=isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
  41  $sortorder=isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
  42  $page=$_GET["page"];
  43  
  44  $socid=$_GET["socid"];
  45  $type=$_GET["type"];
  46  
  47  
  48  /*
  49   * Sécurité accés client
  50   */
  51  if ($user->societe_id > 0) 
  52  {
  53    $action = '';
  54    $socid = $user->societe_id;
  55  }
  56  
  57  
  58  if (! $sortfield) $sortfield="p.name";
  59  if (! $sortorder) $sortorder="ASC";
  60  if ($page == -1) { $page = 0 ; }
  61  $limit = $conf->liste_limit;
  62  $offset = $limit * $page ;
  63  
  64  
  65  if ($type == "c")
  66  {
  67    $label = $langs->trans("Customers");
  68    $urlfiche="fiche.php";
  69  }
  70  if ($type == "p")
  71  {
  72    $label = $langs->trans("Prospects");
  73    $urlfiche="prospect/fiche.php";
  74  }
  75  if ($type == "f")
  76  {
  77    $label = $langs->trans("Suppliers");
  78    $urlfiche="fiche.php";
  79  }
  80  
  81  /*
  82   * Mode liste
  83   *
  84   */
  85  
  86  $sql = "SELECT s.idp, s.nom,  st.libelle as stcomm";
  87  $sql .= ", p.idp as cidp, p.name, p.firstname, p.email, p.phone ";
  88  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
  89  $sql .= " , ".MAIN_DB_PREFIX."socpeople as p";
  90  $sql .= " , ".MAIN_DB_PREFIX."c_stcomm as st";
  91  $sql .= " WHERE s.fk_stcomm = st.id AND s.idp = p.fk_soc";
  92  
  93  if ($type == "c") $sql .= " AND s.client = 1";
  94  if ($type == "p") $sql .= " AND s.client = 2";
  95  if ($type == "f") $sql .= " AND s.fournisseur = 1";
  96  
  97  
  98  if (strlen($stcomm))
  99  {
 100    $sql .= " AND s.fk_stcomm=$stcomm";
 101  }
 102  
 103  if (strlen($begin)) // filtre sur la premiere lettre du nom
 104  {
 105    $sql .= " AND upper(p.name) like '$begin%'";
 106  }
 107  
 108  if (trim($_GET["search_nom"]))
 109  {
 110    $sql .= " AND p.name like '%".trim($_GET["search_nom"])."%'";
 111  }
 112  
 113  if (trim($_GET["search_prenom"]))
 114  {
 115    $sql .= " AND p.firstname like '%".trim($_GET["search_prenom"])."%'";
 116  }
 117  
 118  if (trim($_GET["search_societe"]))
 119  {
 120    $sql .= " AND s.nom like '%".trim($_GET["search_societe"])."%'";
 121  }
 122  
 123  if ($_GET["contactname"]) // acces a partir du module de recherche
 124  {
 125    $sql .= " AND ( p.name like '%".strtolower($_GET[contactname])."%' OR lower(p.firstname) like '%".strtolower($_GET[contactname])."%') ";
 126    $sortfield = "p.name";
 127    $sortorder = "ASC";
 128  }
 129  
 130  if ($socid) {
 131    $sql .= " AND s.idp = $socid";
 132  }
 133  
 134  $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($limit+1, $offset);
 135  
 136  $result = $db->query($sql);
 137  if ($result) 
 138  {
 139    $num = $db->num_rows();
 140    
 141    print_barre_liste($langs->trans("ListOfContacts").($label?" (".$label.")":""),$page, "contact.php", "&amp;type=$type",$sortfield,$sortorder,"",$num);
 142    
 143    print '<table class="liste" width="100%">';
 144    print '<tr class="liste_titre">';
 145    print_liste_field_titre($langs->trans("Lastname"),"contact.php","p.name", $begin,"&amp;type=$type","",$sortfield);
 146    print_liste_field_titre($langs->trans("Firstname"),"contact.php","p.firstname", $begin,"&amp;type=$type","",$sortfield);
 147    print_liste_field_titre($langs->trans("Company"),"contact.php","s.nom", $begin,"&amp;type=$type","",$sortfield);
 148    print '<td class="liste_titre">'.$langs->trans("Email").'</td>';
 149    print '<td class="liste_titre">'.$langs->trans("Phone").'</td>';
 150    print "</tr>\n";
 151  
 152    print '<form action="contact.php?type='.$_GET["type"].'" method="GET">';
 153    print '<tr class="liste_titre">';
 154    print '<td class="liste_titre"><input class="flat" name="search_nom" size="12" value="'.$_GET["search_nom"].'"></td>';
 155    print '<td class="liste_titre"><input class="flat" name="search_prenom" size="12"  value="'.$_GET["search_prenom"].'"></td>';
 156    print '<td class="liste_titre"><input class="flat" name="search_societe" size="12"  value="'.$_GET["search_societe"].'"></td>';
 157    print '<td class="liste_titre">&nbsp;</td>';
 158    print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt='.$langs->trans("Search").'></td>';
 159    print "</tr>\n";
 160    print '</form>';
 161  
 162    $var=True;
 163    $i = 0;
 164    while ($i < min($num,$limit))
 165      {
 166        $obj = $db->fetch_object();
 167      
 168        $var=!$var;
 169  
 170        print "<tr $bc[$var]>";
 171        print '<td><a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'&socid='.$obj->idp.'">'.img_object($langs->trans("ShowContact"),"contact");
 172        print '</a>&nbsp;<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->cidp.'&socid='.$obj->idp.'">'.$obj->name.'</a></td>';
 173        print "<td>$obj->firstname</TD>";
 174        
 175        print '<td><a href="contact.php?type='.$type.'&socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a>&nbsp;';
 176        print "<a href=\"".$urlfiche."?socid=$obj->idp\">$obj->nom</a></td>\n";
 177        
 178        print '<td><a href="action/fiche.php?action=create&actionid=4&contactid='.$obj->cidp.'&socid='.$obj->idp.'">'.$obj->email.'</a>&nbsp;</td>';
 179        
 180        print '<td><a href="action/fiche.php?action=create&actionid=1&contactid='.$obj->cidp.'&socid='.$obj->idp.'">'.dolibarr_print_phone($obj->phone).'</a>&nbsp;</td>';
 181        
 182        print "</tr>\n";
 183        $i++;
 184      }
 185    print "</table></p>";
 186    $db->free();
 187  }
 188  else
 189  {
 190      dolibarr_print_error($db);
 191  }
 192  
 193  $db->close();
 194  
 195  llxFooter("<em>Derni&egrave;re modification $Date: 2005/08/21 19:12:28 $ r&eacute;vision $Revision: 1.25 $</em>");
 196  ?>


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