* 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$ * */ /** \file htdocs/contact/fiche.php \ingroup societe \brief Onglet général d'un contact \version $Revision$ */ require("./pre.inc.php"); require_once("../contact.class.php"); require (DOL_DOCUMENT_ROOT."/lib/vcard/vcard.class.php"); $langs->load("companies"); $error = array(); if ($_GET["action"] == 'create_user' && $user->admin) { // Recuperation contact actuel $contact = new Contact($db); $result = $contact->fetch($_GET["id"]); // Creation user $nuser = new User($db); $nuser->nom = $contact->nom; $nuser->prenom = $contact->prenom; $nuser->create_from_contact($contact); } if ($_POST["action"] == 'add') { if (! $_POST["name"] && ! $_POST["firstname"]) { array_push($error,'Le champ nom ou prénom est obligatoire.'); $_GET["action"]="create"; } 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 ($_POST["action"] == 'confirm_delete' AND $_POST["confirm"] == 'yes') { $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) { $error = $contact->error; } } /* * * */ llxHeader(); $form = new Form($db); // Affiche les erreurs if (sizeof($error)) { print "
"; print join("
",$error); print "
\n"; } /* * Onglets */ if ($_GET["id"] > 0) { // Si edition contact deja existant $contact = new Contact($db); $return=$contact->fetch($_GET["id"], $user); if ($return < 0) { dolibarr_print_error('',$contact->error); } $h=0; $head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("General"); $hselected=$h; $h++; $head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("PersonalInformations"); $h++; $head[$h][0] = DOL_URL_ROOT.'/contact/vcard.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("VCard"); $h++; $head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"]; $head[$h][1] = $langs->trans("Info"); $h++; dolibarr_fiche_head($head, $hselected, $contact->firstname.' '.$contact->name); } /* * Confirmation de la suppression du contact * */ if ($_GET["action"] == 'delete') { $form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],"Supprimer le contact","Êtes-vous sûr de vouloir supprimer ce contact ?","confirm_delete"); 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) { /* On remplit avec le numéro de la société par défaut */ if (strlen(trim($contact->phone_pro)) == 0) { $contact->phone_pro = $objsoc->tel; } print ''; print ''; print ''; } else { print ''; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "
'.$langs->trans("Company").''.$objsoc->nom.'
'.$langs->trans("Company").''; print $form->select_societes('','socid'); print '
'.$langs->trans("UserTitle").''; print $form->select_civilite($obj->civilite); print '
'.$langs->trans("Lastname").''.$langs->trans("Firstname").'Tel Pro
Poste/FonctionTel Perso
'.$langs->trans("Address").'Portable
'.$langs->trans("Zip").' / '.$langs->trans("Town").' '; print ''.$langs->trans("Fax").'
'.$langs->trans("Email").'
Jabberid
'.$langs->trans("Note").'
Contact facturation

"; print "
"; } elseif ($_GET["action"] == 'edit') { /* * Fiche en mode edition * */ 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 ''; print "
'.$langs->trans("Company").''.$objsoc->nom.'
'.$langs->trans("UserTitle").''; print $form->select_civilite($contact->civilite_id); print '
'.$langs->trans("Lastname").''.$langs->trans("Firstname").'Tel Pro
Poste/FonctionTel Perso
'.$langs->trans("Address").'Portable
'.$langs->trans("Zip").' / '.$langs->trans("Town").' '; print ''.$langs->trans("Fax").'
'.$langs->trans("EMail").'
Jabberid
'.$langs->trans("Note").''; print '
Contact facturation

"; print "
"; } else { /* * Visualisation de la fiche * */ 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 "
'.$langs->trans("Company").' : '.$objsoc->nom_url.'
Titre : '.$contact->civilite."
"; print '
'; if ($contact->name || $contact->firstname) { print $langs->trans("Name").' : '.$contact->name.' '.$contact->firstname ."
"; } if ($contact->poste) print 'Poste : '.$contact->poste ."
"; if ($contact->email) { print $langs->trans("EMail").' : '.$contact->email ."
"; if (!ValidEmail($contact->email)) { print "".$langs->trans("ErrorBadEMail",$contact->email)."
"; } /* * Pose des problèmes en cas de non connexion au Réseau * et en cas ou la fonction checkdnsrr n'est pas disponible dans php * (cas fréquent sur certains hébergeurs) */ /* if (!check_mail($contact->email)) { print "Email invalide, nom de domaine incorrecte !
"; } */ } if ($contact->address || $contact->ville) { print 'Adresse : '.$contact->address ."
"; print 'Adresse : '.$contact->cp . " ".$contact->ville ."
"; } if ($contact->jabberid) print 'Jabber : '.$contact->jabberid ."
"; if($contact->user_id) print 'Utilisateur avec accés : Fiche utilisateur
'; 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 $langs->trans("Fax").' : '.$contact->fax."
"; print '
'; print nl2br($contact->note); print '

"; print ""; // Barre d'actions if ($user->societe_id == 0) { print '
'; print ''.$langs->trans('Edit').''; if ($contact->user_id == 0 && $user->admin) { print 'Créer un compte'; } print ''.$langs->trans('Delete').''; print "

"; } // Historique des actions vers ce contact print_titre ("Historique des actions pour ce contact"); print ''; print ""; print ""; print ""; $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid "; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u "; $sql .= " WHERE fk_contact = ".$contact->id; $sql .= " AND u.rowid = a.fk_user_author"; $sql .= " AND c.id=a.fk_action "; if ($contactid) { $sql .= " AND fk_contact = $contactid"; } $sql .= " ORDER BY a.datea DESC, a.id DESC"; if ( $db->query($sql) ) { $i = 0 ; $num = $db->num_rows(); $tag = True; while ($i < $num) { $obj = $db->fetch_object(); $var=!$var; print ""; print ""; if ($obj->propalrowid) { print ""; } else { print ""; } print ""; print "\n"; $i++; $tag = !$tag; } } else { dolibarr_print_error($db); } print "
".$langs->trans("Date")."".$langs->trans("Actions")."".$langs->trans("CreatedBy")."
". strftime("%d %b %Y %H:%M", $obj->da) ."propalrowid\">$obj->libelle$obj->libelle$obj->code 
"; } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>