Skip to content

Commit

Permalink
Type fix with use od contact roles
Browse files Browse the repository at this point in the history
  • Loading branch information
Vítězslav Dvořák committed Nov 21, 2023
1 parent 70f3aa2 commit cea4134
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/AbraFlexi/Adresar.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public function getNotificationEmailAddress(string $purpose = '')
}
} else {
if (array_key_exists('primarni', $kontakt) && ($kontakt['primarni'] == 'true') && strlen(trim($kontakt['email']))) {
$candidates = $kontakt['email'];
$candidates[] = $kontakt['email'];
break;
}
}
}
if (count($candidates)) {
$email = implode(',', $candidates);
$email = implode(',', array_unique($candidates));
}
}
}
Expand Down Expand Up @@ -105,7 +105,7 @@ public function getCellPhoneNumber(string $purpose = '')
}
}
if (count($candidates)) {
$mobil = implode(',', $candidates);
$mobil = implode(',', array_unique($candidates));
}
}
}
Expand Down
19 changes: 15 additions & 4 deletions src/AbraFlexi/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
*
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
*/
trait email
{
trait email {

/**
* Get recipient for documnet.
*
Expand All @@ -48,8 +48,7 @@ trait email
*
* @return string
*/
public function getEmail(string $purpose = '')
{
public function getEmail(string $purpose = '') {
if (empty($this->getDataValue('kontaktEmail'))) {
$addresser = new Adresar($this->getDataValue('firma'), array_merge(['detail' => 'custom:email'], $this->getConnectionOptions()));
if (empty($addresser->getDataValue('email'))) {
Expand All @@ -63,4 +62,16 @@ public function getEmail(string $purpose = '')

return $email;
}

/**
* Document type To Purpose
*
* @param \AbraFlexi\RO $document
*
* @return string Contact role Fak|Obj|Nab|Ppt|Skl|Pok or ''
*/
public static function docTypeToPurpose($document) {
$purposeRaw = substr(str_replace('AbraFlexi\\', '', get_class($document)), 0, 2);
return array_search($purposeRaw, ['Fak','Obj','Nab','Ppt','Skl','Pok']) === false ? '' : $purposeRaw ;
}
}

0 comments on commit cea4134

Please sign in to comment.