From 0ead8a2e24996a1920cdd0b2504622e4b0fe38c8 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Fri, 23 Jan 2004 11:32:02 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/contact/fiche.php | 223 +++++++++++++++++++++++++++++++++++++++ htdocs/contact/index.php | 160 ++++++++++++++++++++++++++++ 2 files changed, 383 insertions(+) create mode 100644 htdocs/contact/fiche.php create mode 100644 htdocs/contact/index.php diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php new file mode 100644 index 00000000000..7f69fd80748 --- /dev/null +++ b/htdocs/contact/fiche.php @@ -0,0 +1,223 @@ + + * + * 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"); +require("../contact.class.php"); + +if ($sortorder == "") +{ + $sortfield="lower(s.nom)"; + $sortorder="ASC"; +} + +if ($HTTP_POST_VARS["action"] == 'add') +{ + $contact = new Contact($db); + + $contact->name = $HTTP_POST_VARS["name"]; + $contact->firstname = $HTTP_POST_VARS["firstname"]; + + $contact->poste = $HTTP_POST_VARS["poste"]; + + $contact->fax = $HTTP_POST_VARS["fax"]; + $contact->note = $HTTP_POST_VARS["note"]; + $contact->email = $HTTP_POST_VARS["email"]; + $contact->phone_pro = $HTTP_POST_VARS["phone_pro"]; + $contact->phone_perso = $HTTP_POST_VARS["phone_perso"]; + $contact->phone_mobile = $HTTP_POST_VARS["phone_mobile"]; + + $_GET["id"] = $contact->create($user); +} + +if ($_GET["action"] == 'delete') +{ + $contact = new Contact($db); + + $contact->old_name = $HTTP_POST_VARS["old_name"]; + $contact->old_firstname = $HTTP_POST_VARS["old_firstname"]; + + $result = $contact->delete($_GET["id"]); + + Header("Location: index.php"); + +} + + +if ($action == 'update') +{ + $contact = new Contact($db); + + $contact->old_name = $HTTP_POST_VARS["old_name"]; + $contact->old_firstname = $HTTP_POST_VARS["old_firstname"]; + + $contact->name = $HTTP_POST_VARS["name"]; + $contact->firstname = $HTTP_POST_VARS["firstname"]; + $contact->poste = $poste; + + $contact->phone_pro = $HTTP_POST_VARS["phone_pro"]; + $contact->phone_perso = $HTTP_POST_VARS["phone_perso"]; + $contact->phone_mobile = $HTTP_POST_VARS["phone_mobile"]; + $contact->fax = $HTTP_POST_VARS["fax"]; + $contact->note = $note; + $contact->email = $HTTP_POST_VARS["email"]; + + $result = $contact->update($HTTP_POST_VARS["contactid"]); + +} + +if ($action == 'create_user') +{ + $nuser = new User($db); + $contact = new Contact($db); + $nuser->nom = $contact->nom; + $nuser->prenom = $contact->prenom; + $result = $contact->fetch($contactid); + $nuser->create_from_contact($contact); +} + +/* + * + * + */ + +llxHeader(); + +if ($_GET["action"] == 'create') +{ + print_fiche_titre ("Création d'un nouveau contact"); + + print "
"; + print ''; + print ''; + print ''; + print ''; + + print ''; + + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + print ''; + print ''; + print "
NomPrenomTel Pro
PosteTel Perso
AdresseMobile
CP Ville Fax
Email
"; + print "
"; +} +elseif ($_GET["action"] == 'edit') +{ + + print_fiche_titre ("Edition d'un contact"); + + $contact = new Contact($db); + $contact->fetch($_GET["id"]); + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + print ''; + + print ''; + + print ''; + print "
NomPrenomTel Pro
PosteTel Perso
AdresseMobile
CP Ville Fax
Email
Jabberid
"; + print "
"; +} +else +{ + $contact = new Contact($db); + $contact->fetch($_GET["id"]); + + + print_fiche_titre ("Contact : ". $contact->firstname.' '.$contact->name); + + + print ''; + print ''; + + + + print "
Nom : '.$contact->name.' '.$contact->firstname; + + if ($contact->email) + print '
Email : '.$contact->email; + + print '
'; + + print 'Tel Pro : '.$contact->phone_pro; + + if ($contact->phone_perso) + print '
Tel Perso : '.$contact->phone_perso; + + if($contact->phone_mobile) + print '
Portable : '.$contact->phone_mobile; + + print '
"; + + + if ($user->societe_id == 0) + { + print '

'; + + print ''; + + print ''; + print ''; + print ''; + + print ''; + print "
Editer---Supprimer
"; + } + print "

\n"; + +} + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/contact/index.php b/htdocs/contact/index.php new file mode 100644 index 00000000000..afb4d84ed34 --- /dev/null +++ b/htdocs/contact/index.php @@ -0,0 +1,160 @@ + + * 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 ; + +print_barre_liste("Liste des contacts",$page, $PHP_SELF, '', $sortfield, $sortorder); + +/* + * + * Mode liste + * + * + */ + +$sql = "SELECT s.idp, s.nom, p.idp as cidp, p.name, p.firstname, p.email, p.phone "; +$sql .= "FROM llx_socpeople as p"; +$sql .= " LEFT JOIN llx_societe as s ON (s.idp = p.fk_soc)"; + + +if (strlen($_GET["userid"])) // statut commercial +{ + $sql .= " WHERE p.fk_user=".$_GET["userid"]; +} + +if (strlen($begin)) // filtre sur la premiere lettre du nom +{ + $sql .= " AND upper(p.name) like '$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, $offset); +} +else +{ + $sql .= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset); +} + +$result = $db->query($sql); + +if ($result) +{ + $num = $db->num_rows(); + $i = 0; + + if ($sortorder == "DESC") + { + $sortorder="ASC"; + } + else + { + $sortorder="DESC"; + } + print "

"; + print ""; + print ""; + print ''; + print "\n"; + $var=True; + while ($i < $num) + { + $obj = $db->fetch_object( $i); + + $var=!$var; + + print ""; + + print ''; + print ""; + + print '\n"; + + print ''; + + 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 "emailTéléphone
'; + print ''; + print img_file(); + print ''.$obj->name.'$obj->firstname'; + if ($obj->nom) + { + print 'Filtre '; + } + print "idp\">$obj->nom'.$obj->email.' '.$obj->phone.' 
"; + $db->free(); +} else { + print $db->error(); + print "
".$sql; +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?>