Skip to content
Code-Schnipsel Gruppen Projekte
Commit 100b7b96 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: ERP Address has its own address template

Übergeordneter b3a1198e
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
<i>ERP ADDRESS</i><br /><br />
<address class="vcard">
<div class="adr">
{if $Address->getAttribute('company')}
<div class="company">
{$Address->getAttribute('company')}
</div>
{/if}
<div class="salutation">{$salutation} {$firstname} {$lastname}</div>
<div class="street-address">{$street_no}</div>
{if !empty($country)}
<div class="locality">
<span class="postal-country">{$country}-</span>
<span class="postal-code">{$zip}</span>
<span class="postal-city">{$city}</span>
</div>
{else}
<div class="locality">
<span class="postal-code">{$zip}</span>
<span class="postal-city">{$city}</span>
</div>
{/if}
{if $Address->getAttribute('company') && $Countries->existsCountryCode($Address->getAttribute('company'))}
{assign var=Country value=$Address->getCountry()}
{if $Country->getCountry()}
<div class="country-name">{$Country->getName()}</div>
{/if}
{/if}
</div>
</address>
......@@ -30,4 +30,76 @@ public function __construct($data = [], $User = null)
$this->id = (int)$data['id'];
}
}
/**
* Return the address as HTML display
*
* @param array $options - options ['mail' => true, 'tel' => true]
* @return string - HTML <address>
*/
public function getDisplay($options = []): string
{
try {
$Engine = QUI::getTemplateManager()->getEngine(true);
} catch (QUI\Exception $Exception) {
QUI\System\Log::writeDebugException($Exception);
return '';
}
$isCompany = false;
if ($this->User->isCompany()) {
$isCompany = $this->User->isCompany();
}
$salutation = $this->emptyStringCheck($this->getAttribute('salutation'));
$street_no = $this->emptyStringCheck($this->getAttribute('street_no'));
$zip = $this->emptyStringCheck($this->getAttribute('zip'));
$city = $this->emptyStringCheck($this->getAttribute('city'));
$country = $this->emptyStringCheck($this->getAttribute('country'));
$firstname = $this->getAttribute('firstname');
$lastname = $this->getAttribute('lastname');
if (empty($firstname) && $this->User) {
$firstname = $this->User->getAttribute('firstname');
}
if (empty($lastname) && $this->User) {
$lastname = $this->User->getAttribute('lastname');
}
$Engine->assign([
'User' => $this->User,
'Address' => $this,
'Countries' => new QUI\Countries\Manager(),
'options' => $options,
'isCompany' => $isCompany,
'salutation' => $salutation,
'firstname' => $this->emptyStringCheck($firstname),
'lastname' => $this->emptyStringCheck($lastname),
'street_no' => $street_no,
'zip' => $zip,
'city' => $city,
'country' => $country,
]);
return $Engine->fetch(\dirname(__FILE__).'/Address.html');
}
/**
* @param $value
* @return string
*/
protected function emptyStringCheck($value): string
{
if (empty($value)) {
return '';
}
return $value;
}
}
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren