* Copyright (C) 2003 Éric Seigne * Copyright (C) 2004-2005 Laurent Destailleur * * 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$ * */ /** \file htdocs/contact/index.php \ingroup societe \brief Page liste des contacts \version $Revision$ */ require("./pre.inc.php"); $langs->load("companies"); $langs->load("suppliers"); /* * Sécurité accés client */ if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } llxHeader(); $search_nom=isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"]; $search_prenom=isset($_GET["search_prenom"])?$_GET["search_prenom"]:$_POST["search_prenom"]; $search_societe=isset($_GET["search_societe"])?$_GET["search_societe"]:$_POST["search_societe"]; $search_email=isset($_GET["search_email"])?$_GET["search_email"]:$_POST["search_email"]; $type = isset($_GET["type"])?$_GET["type"]:$_POST["type"]; $view=isset($_GET["view"])?$_GET["view"]:$_POST["view"]; $contactname=isset($_GET["contactname"])?$_GET["contactname"]:$_POST["contactname"]; $sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; $sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; $page = isset($_GET["page"])?$_GET["page"]:$_POST["page"]; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="p.name"; if ($page < 0) { $page = 0 ; } $limit = $conf->liste_limit; $offset = $limit * $page ; if ($type == "f") { $text.=$langs->trans("Suppliers"); } if ($type == "c") { $text.=$langs->trans("Customers"); } if ($view == 'phone') { $text="(Vue Téléphones)"; } if ($view == 'mail') { $text="(Vue EMail)"; } if ($view == 'recent') { $text="(Récents)"; } $titre = $langs->trans("ListOfContacts")." ($text)"; if ($_POST["button_removefilter"] == $langs->trans("RemoveFilter")) { $search_nom=""; $search_prenom=""; $search_societe=""; $search_email=""; } /* * 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) "; $sql .= "WHERE 1=1 "; if ($_GET["userid"]) // statut commercial { $sql .= " AND p.fk_user=".$_GET["userid"]; } if ($search_nom) // filtre sur le nom { $sql .= " AND upper(p.name) like '%".$search_nom."%'"; } if ($search_prenom) // filtre sur le prenom { $sql .= " AND upper(p.firstname) like '%".$search_prenom."%'"; } if ($search_societe) // filtre sur la societe { $sql .= " AND upper(s.nom) like '%".$search_societe."%'"; } if ($search_email) // filtre sur l'email { $sql .= " AND upper(p.email) like '%".$search_email."%'"; } if ($type == "f") // filtre sur type { $sql .= " AND fournisseur = 1"; } if ($type == "c") // filtre sur type { $sql .= " AND client = 1"; } if ($contactname) { $sql .= " AND (p.name like '%".$contactname."%' OR p.firstname like '%".$contactname."%') "; } 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, "index.php", '&begin='.$_GET["begin"].'&view='.$_GET["view"].'&userid='.$_GET["userid"], $sortfield, $sortorder,'',$num); print ''; if ($contactname) { print $langs->trans("Filter")." (".$langs->trans("Lastname")." ".$langs->trans("or")." ".$langs->trans("Firstname")."): $contactname"; } // Ligne des titres print ''; print_liste_field_titre($langs->trans("Lastname"),"index.php","p.name", $begin, "&type=$type&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield); print_liste_field_titre($langs->trans("Firstname"),"index.php","p.firstname", $begin, "&type=$type&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield); print_liste_field_titre($langs->trans("Company"),"index.php","s.nom", $begin, "&type=$type&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield); print ''; if ($_GET["view"] == 'phone') { print ''; print ''; } else { print_liste_field_titre($langs->trans("EMail"),"index.php","p.email", $begin, "&type=$type&view=$view&search_nom=$search_nom&search_prenom=$search_prenom&search_societe=$search_societe&search_email=$search_email", "", $sortfield); } print ''; print "\n"; // Ligne des champs de filtres print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($_GET["view"] == 'phone') { print ''; print ''; } else { print ''; } print ''; print ''; print ''; $var=True; while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); $var=!$var; print ""; print ''; print ''; print ''; print ''; if ($_GET["view"] == 'phone') { print ''; print ''; } else { print ''; } print "\n"; $i++; } print "
'.$langs->trans("Phone").''.$langs->trans("Mobile").''.$langs->trans("Fax").' 
'; print ''; print ''; print ''; print ''; print ''; print ''; print ' '; print ''; print ' '; print ''; print ' '; print ''; print ''; print ''; print ''; print '  '; print '
'; print ''; print img_object($langs->trans("ShowContact"),"contact"); print ' '.$obj->name.''.$obj->firstname.''; print img_object($langs->trans("ShowCompany"),"company"); print ' '.$obj->nom.''.dolibarr_print_phone($obj->phone).' '.dolibarr_print_phone($obj->phone_mobile).' '.dolibarr_print_phone($obj->fax).' '; if (! $obj->email) { print ' '; } elseif (! ValidEmail($obj->email)) { print "Email Invalide !"; } else { print ''.$obj->email.''; } print '
"; $db->free(); } else { dolibarr_print_error($db); } print '
'; /* * TODO A virer ? * PhProjekt */ if (2==1 && (strlen($_GET["search_nom"]) OR strlen($_GET["search_prenom"]))) { $sortfield = "p.nachname"; $sortorder = "ASC"; $sql = "SELECT p.vorname, p.nachname, p.firma, p.email"; $sql .= " FROM phprojekt.contacts as p"; $sql .= " WHERE upper(p.nachname) like '%".$_GET["search_nom"]."%'"; $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit + 1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows(); $i = 0; 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($langs->trans("Name"),"projekt.php","lower(p.name)", $begin); print ""; print_liste_field_titre($langs->trans("Fristname"),"projekt.php","lower(p.firstname)", $begin); print ""; print_liste_field_titre($langs->trans("Company"),"projekt.php","lower(s.nom)", $begin); print ''.$langs->trans("Phone").'PortableFaxemail
'; print ''; print img_file(); print ' '.$obj->nachname.''.$obj->vorname.''; print "idp\">$obj->firma'.dolibarr_print_phone($obj->phone).' '.dolibarr_print_phone($obj->phone_mobile).' '.dolibarr_print_phone($obj->fax).' '.$obj->email.' '; if (!valid_email($obj->email)) { print "Email Invalide !"; } print '
"; $db->free(); } else { dolibarr_print_error($db); } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>