diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index d80cf395e9b..5dfc56cb4d8 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -47,7 +47,9 @@ if ($contact->socid) // We create VCard $v = new vCard(); +$v->setProdId('Dolibarr '.DOL_VERSION); +$v->setUid('DOLIBARR-CONTACTID-'.$contact->id); $v->setName($contact->name, $contact->firstname, "", "", ""); $v->setFormattedName($contact->fullname); @@ -56,10 +58,12 @@ $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->setAddress("", "", $contact->address, $contact->ville, "", $contact->cp, ($contact->pays_code?$contact->pays:''), "WORK;POSTAL"); +$v->setEmail($contact->email,'internet,pref'); $v->setNote($contact->note); +$v->setTitle($contact->poste); + // Data from linked company if ($company->id) { @@ -67,6 +71,9 @@ if ($company->id) 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"); + if ($company->email != $contact->email) $v->setEmail($company->email,'internet'); + // Si contact lié à un tiers non de type "particulier" + if ($contact->typent_code != 'TE_PRIVATE') $v->setOrg($company->nom); } // Personal informations diff --git a/htdocs/lib/vcard/vcard.class.php b/htdocs/lib/vcard/vcard.class.php index 09abfbe09c6..03e6c29c641 100644 --- a/htdocs/lib/vcard/vcard.class.php +++ b/htdocs/lib/vcard/vcard.class.php @@ -1,7 +1,7 @@ properties["EMAIL;INTERNET"] = $address; + function setEmail($address,$type="internet,pref") { + $this->properties["EMAIL;TYPE=".$type] = $address; } /** @@ -211,12 +215,47 @@ class vCard { $this->properties["NOTE;ENCODING=QUOTED-PRINTABLE"] = quoted_printable_encode($note); } -/** - \brief mise en forme de l'url - \param url - \param type -*/ + /** + \brief mise en forme de la fonction + \param title + */ + function setTitle($title) { + $this->properties["TITLE;ENCODING=QUOTED-PRINTABLE"] = quoted_printable_encode($title); + } + + /** + \brief mise en forme de la societe + \param org + */ + function setOrg($org) { + $this->properties["ORG;ENCODING=QUOTED-PRINTABLE"] = quoted_printable_encode($org); + } + + + /** + \brief mise en forme du logiciel generateur + \param prodid + */ + function setProdId($prodid) { + $this->properties["PRODID;ENCODING=QUOTED-PRINTABLE"] = quoted_printable_encode($prodid); + } + + + /** + \brief mise en forme du logiciel generateur + \param uid + */ + function setUID($uid) { + $this->properties["UID;ENCODING=QUOTED-PRINTABLE"] = quoted_printable_encode($uid); + } + + + /** + \brief mise en forme de l'url + \param url + \param type + */ function setURL($url, $type="") { // $type may be WORK | HOME $key = "URL"; @@ -230,7 +269,7 @@ class vCard { function getVCard() { $text = "BEGIN:VCARD\r\n"; - $text.= "VERSION:2.1\r\n"; + $text.= "VERSION:3.0\r\n"; foreach($this->properties as $key => $value) { $text.= "$key:$value\r\n"; }