29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/vcard.class.php';
34 $user2 =
new User($db);
41 if ($user->socid > 0) {
42 $socid = $user->socid;
48 $result = $user2->fetch($id);
58 $result = $company->fetch($user2->socid);
63 $v->setProdId(
'Dolibarr '.DOL_VERSION);
65 $v->setUid(
'DOLIBARR-USERID-'.$user2->id);
66 $v->setName($user2->lastname, $user2->firstname,
"", $user2->civility_code,
"");
67 $v->setFormattedName($user2->getFullName($langs, 1));
69 $v->setPhoneNumber($user2->office_phone,
"TYPE=WORK;VOICE");
70 $v->setPhoneNumber($user2->personal_mobile,
"TYPE=HOME;VOICE");
71 $v->setPhoneNumber($user2->user_mobile,
"TYPE=CELL;VOICE");
72 $v->setPhoneNumber($user2->office_fax,
"TYPE=WORK;FAX");
74 $country = $user2->country_code ? $user2->country :
'';
76 $v->setAddress(
"",
"", $user2->address, $user2->town, $user2->state, $user2->zip, $country,
"TYPE=WORK;POSTAL");
77 $v->setLabel(
"",
"", $user2->address, $user2->town, $user2->state, $user2->zip, $country,
"TYPE=WORK");
79 $v->setEmail($user2->email,
"TYPE=WORK");
80 $v->setNote($user2->note_public);
81 $v->setTitle($user2->job);
85 $v->setURL($company->url,
"TYPE=WORK");
86 if (!$user2->office_phone) {
87 $v->setPhoneNumber($company->phone,
"TYPE=WORK;VOICE");
89 if (!$user2->office_fax) {
90 $v->setPhoneNumber($company->fax,
"TYPE=WORK;FAX");
93 $v->setAddress(
"",
"", $company->address, $company->town, $company->state, $company->zip, $company->country,
"TYPE=WORK;POSTAL");
97 if (empty(trim($company->email))) {
99 } elseif (empty(trim($user2->email))) {
101 $v->setEmail($company->email,
"TYPE=WORK");
103 $tmpuser2 = explode(
"@", trim($user2->email));
104 $tmpcompany = explode(
"@", trim($company->email));
106 if (strtolower(end($tmpuser2)) == strtolower(end($tmpcompany))) {
108 $v->setEmail($user2->email,
"TYPE=WORK");
111 $v->setEmail($company->email,
'INTERNET');
114 $v->setEmail($company->email,
"TYPE=WORK");
117 $v->setEmail($user2->email,
'INTERNET');
122 if ($company->typent_code !=
'TE_PRIVATE') {
123 $v->setOrg($company->name);
128 $v->setPhoneNumber($user2->personal_mobile,
"TYPE=HOME;VOICE");
130 $v->setBirthday($user2->birth);
137 $output = $v->getVCard();
139 $filename = trim(urldecode($v->getFileName()));
144 header(
"Content-Disposition: attachment; filename=\"".$filename.
"\"");
145 header(
"Content-Length: ".
dol_strlen($output));
146 header(
"Connection: close");
147 header(
"Content-Type: text/x-vcard; name=\"".$filename.
"\"");
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
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.