Update vcard.php

This commit is contained in:
Anthony Berton 2022-01-28 10:30:41 +01:00 committed by GitHub
parent 5ff37febe3
commit 8c38125e79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,9 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2021-2022 Anthony Berton <anthony.berton@bb2a.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -64,27 +65,27 @@ $v->setUid('DOLIBARR-USERID-'.$user2->id);
$v->setName($user2->lastname, $user2->firstname, "", $user2->civility_code, "");
$v->setFormattedName($user2->getFullName($langs, 1));
$v->setPhoneNumber($user2->phone_pro, "TYPE=WORK;VOICE");
//$v->setPhoneNumber($user2->phone_perso,"TYPE=HOME;VOICE");
$v->setPhoneNumber($user2->phone_mobile, "TYPE=CELL;VOICE");
$v->setPhoneNumber($user2->fax, "TYPE=WORK;FAX");
$v->setPhoneNumber($user2->office_phone, "TYPE=WORK;VOICE");
$v->setPhoneNumber($user2->personal_mobile,"TYPE=HOME;VOICE");
$v->setPhoneNumber($user2->user_mobile, "TYPE=CELL;VOICE");
$v->setPhoneNumber($user2->office_fax, "TYPE=WORK;FAX");
$country = $user2->country_code ? $user2->country : '';
$v->setAddress("", "", $user2->address, $user2->town, $user2->state, $user2->zip, $country, "TYPE=WORK;POSTAL");
$v->setLabel("", "", $user2->address, $user2->town, $user2->state, $user2->zip, $country, "TYPE=WORK");
$v->setEmail($user2->email);
$v->setEmail($user2->email, "TYPE=WORK");
$v->setNote($user2->note);
$v->setTitle($user2->poste);
// Data from linked company
if ($company->id) {
$v->setURL($company->url, "TYPE=WORK");
if (!$user2->phone_pro) {
if (!$user2->office_phone) {
$v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
}
if (!$user2->fax) {
if (!$user2->office_fax) {
$v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
}
if (!$user2->zip) {
@ -96,16 +97,16 @@ if ($company->id) {
// was set before, don't set twice
} elseif (empty(trim($user2->email))) {
// when user e-mail is empty, use only company e-mail
$v->setEmail($company->email);
$v->setEmail($company->email, "TYPE=WORK");
} elseif (strtolower(end(explode("@", $user2->email))) == strtolower(end(explode("@", $company->email)))) {
// when e-mail domain of user and company are the same, use user e-mail at first (and company e-mail at second)
$v->setEmail($user2->email);
$v->setEmail($user2->email, "TYPE=WORK");
// support by Microsoft Outlook (2019 and possible earlier)
$v->setEmail($company->email, 'INTERNET');
} else {
// when e-mail of user and company complete different use company e-mail at first (and user e-mail at second)
$v->setEmail($company->email);
$v->setEmail($company->email, "TYPE=WORK");
// support by Microsoft Outlook (2019 and possible earlier)
$v->setEmail($user2->email, 'INTERNET');
@ -118,7 +119,7 @@ if ($company->id) {
}
// Personal informations
$v->setPhoneNumber($user2->phone_perso, "TYPE=HOME;VOICE");
$v->setPhoneNumber($user2->personal_mobile, "TYPE=HOME;VOICE");
if ($user2->birth) {
$v->setBirthday($user2->birth);
}