28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/vcard.class.php';
39$result =
restrictedArea($user,
'contact', $id,
'socpeople&societe');
42$result = $contact->fetch($id);
51 $result = $company->fetch($contact->socid);
56$v->setProdId(
'Dolibarr '.DOL_VERSION);
58$v->setUid(
'DOLIBARR-CONTACTID-'.$contact->id);
59$v->setName($contact->lastname, $contact->firstname,
"", $contact->civility,
"");
60$v->setFormattedName($contact->getFullName($langs, 1));
62$v->setPhoneNumber($contact->phone_pro,
"TYPE=WORK;VOICE");
64$v->setPhoneNumber($contact->phone_mobile,
"TYPE=CELL;VOICE");
65$v->setPhoneNumber($contact->fax,
"TYPE=WORK;FAX");
67$country = $contact->country_code ? $contact->country :
'';
69$v->setAddress(
"",
"", $contact->address, $contact->town, $contact->state, $contact->zip, $country,
"TYPE=WORK;POSTAL");
70$v->setLabel(
"",
"", $contact->address, $contact->town, $contact->state, $contact->zip, $country,
"TYPE=WORK");
72$v->setEmail($contact->email);
73$v->setNote($contact->note);
74$v->setTitle($contact->poste);
78 $v->setURL($company->url,
"TYPE=WORK");
79 if (!$contact->phone_pro) {
80 $v->setPhoneNumber($company->phone,
"TYPE=WORK;VOICE");
83 $v->setPhoneNumber($company->fax,
"TYPE=WORK;FAX");
86 $v->setAddress(
"",
"", $company->address, $company->town, $company->state, $company->zip, $company->country,
"TYPE=WORK;POSTAL");
90 if (empty(trim($company->email))) {
92 } elseif (empty(trim($contact->email))) {
94 $v->setEmail($company->email);
96 $tmpcontact = explode(
"@", trim($contact->email));
97 $tmpcompany = explode(
"@", trim($company->email));
99 if (strtolower(end($tmpcontact)) == strtolower(end($tmpcompany))) {
101 $v->setEmail($contact->email);
104 $v->setEmail($company->email,
'INTERNET');
107 $v->setEmail($company->email);
110 $v->setEmail($contact->email,
'INTERNET');
115 if ($company->typent_code !=
'TE_PRIVATE') {
116 $v->setOrg($company->name);
121$v->setPhoneNumber($contact->phone_perso,
"TYPE=HOME;VOICE");
122if ($contact->birthday) {
123 $v->setBirthday($contact->birthday);
131$output = $v->getVCard();
133$filename = trim(urldecode($v->getFileName()));
138header(
"Content-Disposition: attachment; filename=\"".$filename.
"\"");
139header(
"Content-Length: ".
dol_strlen($output));
140header(
"Connection: close");
141header(
"Content-Type: text/x-vcard; name=\"".$filename.
"\"");
Class to manage third parties objects (customers, suppliers, prospects...)
Class to buld vCard files.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.