30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/vcard.class.php';
49$result =
restrictedArea($user,
'contact', $id,
'socpeople&societe');
52$result = $contact->fetch($id);
61 $result = $company->fetch($contact->socid);
66$v->setProdId(
'Dolibarr '.DOL_VERSION);
68$v->setUid(
'DOLIBARR-CONTACTID-'.$contact->id);
69$v->setName($contact->lastname, $contact->firstname,
"", $contact->civility,
"");
70$v->setFormattedName($contact->getFullName($langs, 1));
72$v->setPhoneNumber($contact->phone_pro,
"TYPE=WORK;VOICE");
74$v->setPhoneNumber($contact->phone_mobile,
"TYPE=CELL;VOICE");
75$v->setPhoneNumber($contact->fax,
"TYPE=WORK;FAX");
77$country = $contact->country_code ? $contact->country :
'';
79$v->setAddress(
"",
"", $contact->address, $contact->town, $contact->state, $contact->zip, $country,
"TYPE=WORK;POSTAL");
81$v->setLabel(
"",
"", $contact->address, $contact->town, $contact->state, $contact->zip, $country,
"TYPE=WORK");
83$v->setEmail($contact->email);
84$v->setNote($contact->note);
85$v->setTitle($contact->poste);
89 $v->setURL($company->url,
"TYPE=WORK");
90 if (!$contact->phone_pro) {
91 $v->setPhoneNumber($company->phone,
"TYPE=WORK;VOICE");
94 $v->setPhoneNumber($company->fax,
"TYPE=WORK;FAX");
97 $v->setAddress(
"",
"", $company->address, $company->town, $company->state, $company->zip, $company->country,
"TYPE=WORK;POSTAL");
101 if (empty(trim($company->email))) {
103 } elseif (empty(trim($contact->email))) {
105 $v->setEmail($company->email);
107 $tmpcontact = explode(
"@", trim($contact->email));
108 $tmpcompany = explode(
"@", trim($company->email));
110 if (strtolower(end($tmpcontact)) == strtolower(end($tmpcompany))) {
112 $v->setEmail($contact->email);
115 $v->setEmail($company->email,
'INTERNET');
118 $v->setEmail($company->email);
121 $v->setEmail($contact->email,
'INTERNET');
126 if ($company->typent_code !=
'TE_PRIVATE') {
127 $v->setOrg($company->name);
132$v->setPhoneNumber($contact->phone_perso,
"TYPE=HOME;VOICE");
133if ($contact->birthday) {
134 $v->setBirthday($contact->birthday);
142$output = $v->getVCard();
144$filename = trim(urldecode($v->getFileName()));
149header(
"Content-Disposition: attachment; filename=\"".$filename.
"\"");
150header(
"Content-Length: ".
dol_strlen($output));
151header(
"Connection: close");
152header(
"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.