* Copyright (C) 2003 Éric Seigne * * 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$ * */ require("./pre.inc.php"); /* * Sécurité accés client */ if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } llxHeader(); if ($sortorder == "") { $sortorder="ASC"; } if ($sortfield == "") { $sortfield="p.name"; } if ($page < 0) { $page = 0 ; } $limit = $conf->liste_limit; $offset = $limit * $page ; if ($_GET["view"] == 'phone') { $titre = "Liste des contacts (Vue téléphone)"; } else { $titre = "Liste des contacts"; } /* * * Mode liste * * */ $sql = "SELECT s.idp, s.nom, p.idp as cidp, p.name, p.firstname, p.email, p.phone, p.phone_mobile, p.fax "; $sql .= "FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (s.idp = p.fk_soc)"; if (strlen($_GET["userid"])) // statut commercial { $sql .= " WHERE p.fk_user=".$_GET["userid"]; } if (strlen($_GET["begin"])) // filtre sur la premiere lettre du nom { $sql .= " WHERE upper(p.name) like '".$_GET["begin"]."%'"; } if ($contactname) // acces a partir du module de recherche { $sql .= " AND ( lower(p.name) like '%".strtolower($contactname)."%' OR lower(p.firstname) like '%".strtolower($contactname)."%') "; $sortfield = "lower(p.name)"; $sortorder = "ASC"; } if ($socid) { $sql .= " AND s.idp = $socid"; } if($_GET["view"] == "recent") { $sql .= " ORDER BY p.datec DESC " . $db->plimit( $limit + 1, $offset); } else { $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1, $offset); } $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; print_barre_liste($titre ,$page, $PHP_SELF, '&begin='.$_GET["begin"].'&view='.$_GET["view"].'&userid='.$_GET["userid"], $sortfield, $sortorder,'',$num); print "
"; print "| *\n| "; for ($ij = 65 ; $ij < 91; $ij++) { print ""; if ($_GET["begin"] == chr($ij) ) { print ">" . chr($ij) . "<" ; } else { print chr($ij); } print " | "; } print "
"; if ($sortorder == "DESC") { $sortorder="ASC"; } else { $sortorder="DESC"; } print '

'; print ''; print ''; if ($_GET["view"] == 'phone') { print ''; print ''; } else { print ''; } print "\n"; $var=True; while ($i < min($num,$limit)) { $obj = $db->fetch_object( $i); $var=!$var; print ""; print ''; print ""; print '\n"; print ''; if ($_GET["view"] == 'phone') { print ''; print ''; } else { print ''; } print "\n"; $i++; } print "
'; print_liste_field_titre("Nom",$PHP_SELF,"lower(p.name)", $begin); print ""; print_liste_field_titre("Prénom",$PHP_SELF,"lower(p.firstname)", $begin); print ""; print_liste_field_titre("Société",$PHP_SELF,"lower(s.nom)", $begin); print 'TéléphonePortableFaxemail
'; print ''; print img_file(); print ' '.$obj->name.'$obj->firstname'; if ($obj->nom) { print 'Filtre '; } print "idp\">$obj->nom'.$obj->phone.' '.$obj->phone_mobile.' '.$obj->fax.' '.$obj->email.' 
"; $db->free(); } else { print $db->error(); print "
".$sql; } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>