Merge pull request #15245 from frederic34/patch-10

fix vcard birthday of member
This commit is contained in:
Laurent Destailleur 2020-11-01 13:53:14 +01:00 committed by GitHub
commit 4f09b87ec5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com> * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -39,8 +40,7 @@ $result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objc
$result = $adherent->fetch($id); $result = $adherent->fetch($id);
if ($result <= 0) if ($result <= 0) {
{
dol_print_error($adherent->error); dol_print_error($adherent->error);
exit; exit;
} }
@ -48,8 +48,7 @@ if ($result <= 0)
$physicalperson = 1; $physicalperson = 1;
$company = new Societe($db); $company = new Societe($db);
if ($adherent->socid) if ($adherent->socid) {
{
$result = $company->fetch($adherent->socid); $result = $company->fetch($adherent->socid);
} }
@ -72,37 +71,35 @@ $v->setAddress("", "", $adherent->address, $adherent->town, $adherent->state, $a
$v->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK"); $v->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK");
$v->setEmail($adherent->email); $v->setEmail($adherent->email);
$v->setNote($adherent->note); $v->setNote($adherent->note_public);
$v->setTitle($adherent->poste); $v->setTitle($adherent->poste);
// Data from linked company // Data from linked company
if ($company->id) if ($company->id) {
{
$v->setURL($company->url, "TYPE=WORK"); $v->setURL($company->url, "TYPE=WORK");
if (!$adherent->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); if (!$adherent->phone_pro) {
if (!$adherent->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
if (!$adherent->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); }
if (!$adherent->fax) {
$v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
}
if (!$adherent->zip) {
$v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL");
}
// when company e-mail is empty, use only adherent e-mail // when company e-mail is empty, use only adherent e-mail
if (empty(trim($company->email))) if (empty(trim($company->email))) {
{
// was set before, don't set twice // was set before, don't set twice
} } elseif (empty(trim($adherent->email))) {
// when adherent e-mail is empty, use only company e-mail // when adherent e-mail is empty, use only company e-mail
elseif (empty(trim($adherent->email)))
{
$v->setEmail($company->email); $v->setEmail($company->email);
} } elseif (strtolower(end(explode("@", $adherent->email))) == strtolower(end(explode("@", $company->email)))) {
// when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second) // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second)
elseif (strtolower(end(explode("@", $adherent->email))) == strtolower(end(explode("@", $company->email))))
{
$v->setEmail($adherent->email); $v->setEmail($adherent->email);
// support by Microsoft Outlook (2019 and possible earlier) // support by Microsoft Outlook (2019 and possible earlier)
$v->setEmail($company->email, 'INTERNET'); $v->setEmail($company->email, 'INTERNET');
} } else {
// when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second) // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second)
else {
$v->setEmail($company->email); $v->setEmail($company->email);
// support by Microsoft Outlook (2019 and possible earlier) // support by Microsoft Outlook (2019 and possible earlier)
@ -115,7 +112,9 @@ if ($company->id)
// Personal informations // Personal informations
$v->setPhoneNumber($adherent->phone_perso, "TYPE=HOME;VOICE"); $v->setPhoneNumber($adherent->phone_perso, "TYPE=HOME;VOICE");
if ($adherent->birthday) $v->setBirthday($adherent->birthday); if ($adherent->birth) {
$v->setBirthday($adherent->birth);
}
$db->close(); $db->close();