From fe2f54dcb2cbc33ac8f30f2cb39f55da53d0ae41 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Jul 2007 23:05:45 +0000 Subject: [PATCH] Gere plus d'info sur la vcard --- ChangeLog | 1 + htdocs/contact/vcard.php | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c17c5b4516..ff08973d19c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -24,6 +24,7 @@ English Dolibarr changelog - Some bugs fixes. - Traduction more complete. - Better code comments for Doxygen documentation. +- Better support of vcard export format. ***** Changelog for 2.1 compared to 2.0.1 ***** diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index f58323e2105..d80cf395e9b 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -29,30 +29,49 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); +require_once(DOL_DOCUMENT_ROOT."/societe.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/vcard/vcard.class.php"); $contact = new Contact($db); -$contact->fetch($_GET["id"]); +$result=$contact->fetch($_GET["id"]); +$physicalperson=1; -// On crée car la VCard +$company = new Societe($db); +if ($contact->socid) +{ + $result=$company->fetch($contact->socid); + //print "ee"; +} +// We create VCard $v = new vCard(); -$v->setName($contact->name, $contact->firstname, "", ""); +$v->setName($contact->name, $contact->firstname, "", "", ""); +$v->setFormattedName($contact->fullname); -$v->setPhoneNumber($contact->phone_perso, "PREF;HOME;VOICE"); - -if ($contact->birthday) $v->setBirthday($contact->birthday); - -$v->setAddress("", "", $contact->address, $contact->ville, "", $contact->cp, $contact->pays); +// By default, all informations are for work (except phone_perso and phone_mobile) +$v->setPhoneNumber($contact->phone_pro, "PREF;WORK;VOICE"); +$v->setPhoneNumber($contact->phone_mobile, "CELL;VOICE"); +$v->setPhoneNumber($contact->fax, "WORK;FAX"); +$v->setAddress("", "", $contact->address, $contact->ville, "", $contact->cp, $contact->pays, "WORK;POSTAL"); $v->setEmail($contact->email); +$v->setNote($contact->note); -//$v->setNote("You can take some notes here.\r\nMultiple lines are supported via \\r\\n."); -//$v->setURL("http://www.thomas-mustermann.de", "WORK"); +// Data from linked company +if ($company->id) +{ + $v->setURL($company->url, "WORK"); + if (! $contact->phone_pro) $v->setPhoneNumber($company->tel, "WORK;VOICE"); + if (! $contact->fax) $v->setPhoneNumber($company->fax, "WORK;FAX"); + if (! $contact->cp) $v->setAddress("", "", $company->adresse, $company->ville, "", $company->cp, $company->pays_code, "WORK;POSTAL"); +} +// Personal informations +$v->setPhoneNumber($contact->phone_perso, "HOME;VOICE"); +if ($contact->birthday) $v->setBirthday($contact->birthday); $db->close();