29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/vcard.class.php';
40$result =
restrictedArea($user,
'contact', $id,
'socpeople&societe');
43$result = $contact->fetch($id);
52 $result = $company->fetch($contact->socid);
57$v->setProdId(
'Dolibarr '.DOL_VERSION);
59$v->setUid(
'DOLIBARR-CONTACTID-'.$contact->id);
60$v->setName($contact->lastname, $contact->firstname,
"", $contact->civility,
"");
61$v->setFormattedName($contact->getFullName($langs, 1));
63$v->setPhoneNumber($contact->phone_pro,
"TYPE=WORK;VOICE");
65$v->setPhoneNumber($contact->phone_mobile,
"TYPE=CELL;VOICE");
66$v->setPhoneNumber($contact->fax,
"TYPE=WORK;FAX");
68$country = $contact->country_code ? $contact->country :
'';
70$v->setAddress(
"",
"", $contact->address, $contact->town, $contact->state, $contact->zip, $country,
"TYPE=WORK;POSTAL");
72$v->setLabel(
"",
"", $contact->address, $contact->town, $contact->state, $contact->zip, $country,
"TYPE=WORK");
74$v->setEmail($contact->email);
75$v->setNote($contact->note);
76$v->setTitle($contact->poste);
80 $v->setURL($company->url,
"TYPE=WORK");
81 if (!$contact->phone_pro) {
82 $v->setPhoneNumber($company->phone,
"TYPE=WORK;VOICE");
85 $v->setPhoneNumber($company->fax,
"TYPE=WORK;FAX");
88 $v->setAddress(
"",
"", $company->address, $company->town, $company->state, $company->zip, $company->country,
"TYPE=WORK;POSTAL");
92 if (empty(trim($company->email))) {
94 } elseif (empty(trim($contact->email))) {
96 $v->setEmail($company->email);
98 $tmpcontact = explode(
"@", trim($contact->email));
99 $tmpcompany = explode(
"@", trim($company->email));
101 if (strtolower(end($tmpcontact)) == strtolower(end($tmpcompany))) {
103 $v->setEmail($contact->email);
106 $v->setEmail($company->email,
'INTERNET');
109 $v->setEmail($company->email);
112 $v->setEmail($contact->email,
'INTERNET');
117 if ($company->typent_code !=
'TE_PRIVATE') {
118 $v->setOrg($company->name);
123$v->setPhoneNumber($contact->phone_perso,
"TYPE=HOME;VOICE");
124if ($contact->birthday) {
125 $v->setBirthday($contact->birthday);
133$output = $v->getVCard();
135$filename = trim(urldecode($v->getFileName()));
140header(
"Content-Disposition: attachment; filename=\"".$filename.
"\"");
141header(
"Content-Length: ".
dol_strlen($output));
142header(
"Connection: close");
143header(
"Content-Type: text/x-vcard; name=\"".$filename.
"\"");
Class to manage third parties objects (customers, suppliers, prospects...)
Class to build vCard files.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.