* Copyright (C) 2004 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * * 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"); require (DOL_DOCUMENT_ROOT."/lib/vcard/vcard.class.php"); $error = array(); if ($_POST["action"] == 'add') { if (! $_POST["name"] && ! $_POST["firstname"]) { array_push($error,"Le champ nom ou prénom est obligatoire"); $_GET["id"]=0; // TODO Mettre lien back } else { $contact = new Contact($db); $contact->socid = $_POST["socid"]; $contact->name = $_POST["name"]; $contact->firstname = $_POST["firstname"]; $contact->civilite_id = $_POST["civilite_id"]; $contact->poste = $_POST["poste"]; $contact->address = $_POST["adresse"]; $contact->cp = $_POST["cp"]; $contact->ville = $_POST["ville"]; $contact->email = $_POST["email"]; $contact->phone_pro = $_POST["phone_pro"]; $contact->phone_perso = $_POST["phone_perso"]; $contact->phone_mobile = $_POST["phone_mobile"]; $contact->fax = $_POST["fax"]; $contact->jabberid = $_POST["jabberid"]; $contact->note = $_POST["note"]; $_GET["id"] = $contact->create($user); } } if ($_GET["action"] == 'delete') { $contact = new Contact($db); $contact->old_name = $_POST["old_name"]; $contact->old_firstname = $_POST["old_firstname"]; $result = $contact->delete($_GET["id"]); Header("Location: index.php"); } if ($_POST["action"] == 'update') { $contact = new Contact($db); $contact->old_name = $_POST["old_name"]; $contact->old_firstname = $_POST["old_firstname"]; $contact->socid = $_POST["socid"]; $contact->name = $_POST["name"]; $contact->firstname = $_POST["firstname"]; $contact->civilite_id = $_POST["civilite_id"]; $contact->poste = $_POST["poste"]; $contact->address = $_POST["adresse"]; $contact->cp = $_POST["cp"]; $contact->ville = $_POST["ville"]; $contact->email = $_POST["email"]; $contact->phone_pro = $_POST["phone_pro"]; $contact->phone_perso = $_POST["phone_perso"]; $contact->phone_mobile = $_POST["phone_mobile"]; $contact->fax = $_POST["fax"]; $contact->jabberid = $_POST["jabberid"]; $contact->note = $_POST["note"]; $result = $contact->update($_POST["contactid"], $user); if ($contact->error) { array_push($error,$contact->error); } } if ($_GET["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(); $form = new Form($db); /* * Onglets */ print '
'; if ($_GET["id"] > 0) { # Si edition contact deja existant print 'Général'; print 'Informations personnelles'; print 'VCard'; print 'Info'; } else { print 'Général'; } print '
'; // Affiche les erreurs if (sizeof($error)) { print '

'; print join("
",$error); print '

'; } print '
'; if ($_GET["socid"] > 0) { $objsoc = new Societe($db); $objsoc->fetch($_GET["socid"]); } if ($_GET["action"] == 'create') { // Fiche en mode creation print '
'; print "
"; print ''; print ''; if ($_GET["socid"] > 0) { print ''; print ''; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // print ''; print ''; print ''; print "
Société'.$objsoc->nom.'
Titre'; print $form->select_civilite(); print '
NomPrenomTel Pro
Poste/FonctionTel Perso
AdressePortable
CP Ville Fax
Email
Jabberid
Date de naissance'; // print $form->select_date('','birthday',0,0,1); // print '
Note
"; print "
"; } elseif ($_GET["action"] == 'edit') { // Fiche en mode edition print '
'; $contact = new Contact($db); $contact->fetch($_GET["id"], $user); print '
'; print ''; print ''; print ''; print ''; print ''; if ($_GET["socid"] > 0) { print ''; print ''; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "
Société'.$objsoc->nom.'
Titre'; print $form->select_civilite($contact->civilite_id); print '
NomPrénomTel Pro
Poste/FonctionTel Perso
AdressePortable
CP Ville Fax
Email
Jabberid
Note'; print '
"; print "
"; } else { /* * Visualisation de la fiche * */ $contact = new Contact($db); $contact->fetch($_GET["id"], $user); print_fiche_titre ("Contact : ". $contact->firstname.' '.$contact->name); print ''; if ($contact->socid > 0) { $objsoc = new Societe($db); $objsoc->fetch($contact->socid); print ''; } //TODO Aller chercher le libellé de la civilite a partir de l'id $contact->civilite_id //print ''; if ($contact->note) { print ''; } print "
Société : '.$objsoc->nom_url.'
Titre : '.$contact->civilite."
"; print '
Nom : '.$contact->name.' '.$contact->firstname ."
"; if ($contact->poste) print 'Poste : '.$contact->poste ."
"; if ($contact->email) print 'Email : '.$contact->email ."
"; if ($contact->jabberid) print 'Jabber : '.$contact->jabberid ."
"; print '
'; if ($contact->phone_pro) 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."
"; if($contact->fax) print 'Fax : '.$contact->fax."
"; print '
'; print nl2br($contact->note); print '

"; print "
"; if ($user->societe_id == 0) { print '
'; print 'Editer'; print 'Supprimer'; print "
"; } } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>