<style>

	.customer-contact {
		display: flex;
	}

</style>

<TABLE class="lmsbox-inner" id="table">
	<colgroup>
		<col style="width: 1%;">
		<col style="width: 99%;">
	</colgroup>
    <THEAD>
	<TR>
		<TD>
			{icon name="customer"}
		</TD>
		<TD>
			<strong>{$customerinfo.customername|escape}
			{if $customerinfo.altname}[{$customerinfo.altname|escape}]{/if}
			({$customerinfo.id|string_format:"%04d"})
			{if $customerinfo.deleted} <span class="alert">({trans("deleted customer")})</span>{/if}</strong>
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	<TR>
		<TD>
			{icon name="customer-status-{$_CSTATUSES[$customerinfo.status].alias}"}
		</TD>
		<TD class="bold">
			{$_CSTATUSES[$customerinfo.status].singularlabel}
		</TD>
	</TR>
	<TR>
		<TD>
			{icon name="home"}
		</TD>
		<TD class="nobr">
			{if $customerinfo.postoffice && $customerinfo.postoffice != $customerinfo.city && $customerinfo.street}{$customerinfo.city}, {/if}{$customerinfo.address}<BR>
			{$customerinfo.zip} {if $customerinfo.postoffice}{$customerinfo.postoffice}{else}{$customerinfo.city}{/if}
		</TD>
	</TR>
{if $customerinfo.post_name != "" || $customerinfo.post_address != ""}
	<TR>
		<TD>
			{icon name="mail"}
		</TD>
		<TD class="nobr">
			{if $customerinfo.post_name != ""}{$customerinfo.post_name|escape}{/if}
			{if $customerinfo.post_address != ""}{if $customerinfo.post_name != ""}<BR>{/if}
				{if $customerinfo.post_postoffice && $customerinfo.post_postoffice != $customerinfo.post_city && $customerinfo.post_street}{$customerinfo.post_city}, {/if}
				{$customerinfo.post_address}
			{/if}
			<br>
			{$customerinfo.post_zip} {if $customerinfo.post_postoffice}{$customerinfo.post_postoffice}{else}{$customerinfo.post_city}{/if}
		</TD>
	</TR>
{/if}


	{foreach $customerinfo.addresses as $address}
		{if $address.location_address_type >= $smarty.const.LOCATION_ADDRESS}
			<tr>
				<td>
					{if $address.location_address_type == $smarty.const.LOCATION_ADDRESS}
						{icon name="customer-location"}
					{else}
						{icon name="default-customer-location"}
					{/if}
				</td>
				<td class="nobr">
					{if $address.location_name != ""}{$address.location_name|escape}<br>{/if}
					{$address.location|escape}
				</td>
			</tr>
		{/if}
	{/foreach}
{foreach $_CUSTOMERCONTACTTYPES as $type => $properties}
	{if isset($customerinfo[$type|cat:"s"])}
		<TR>
			<TD></TD>
			<TD class="customer-contact">
				<fieldset style="width: auto;">
					<legend class="bold nobr">
						{icon name="{$properties.ui.legend.icon}"}
						{$properties.ui.legend.text}
					</legend>
					<TABLE>
						{foreach $customerinfo[$type|cat:"s"] as $contact}
							<TR{if ($contact.type & $smarty.const.CONTACT_DISABLED) == $smarty.const.CONTACT_DISABLED} class="blend"{/if}>
								<TD class="customer-contact">
									<div>
										{if isset($properties.formatter)}{call_user_func($properties['formatter'], $contact)}{else}{$contact.contact|escape}{/if}
										{if $contact.typestr}[{$contact.typestr}]{/if}
										{if $contact.name} ({$contact.name|trunescape:40}){/if}
									</div>
								</TD>
							</TR>
						{/foreach}
					</TABLE>
				</fieldset>
			</TD>
		</TR>
	{/if}
{/foreach}

{if !ConfigHelper::checkPrivilege('hide_customer_sensitive_data')}
	{if $customerinfo.icn != ""}
		<tr>
			<td>
				{icon name="user-id-number"}
			</td>
			<td class="nobr">
				{trans("Identity type:")}: {trans($_IDENTITY_TYPES[$customerinfo.ict])}
			</td>
		</tr>
		<tr>
			<td>
				{icon name="user-id-number"}
			</td>
			<td class="nobr">
				{trans("Identity number:")}: {$customerinfo.icn|escape}
				{if $customerinfo.icexpires !== ''}
					{if $customerinfo.icexpires > 0}
						{textformat assign="icexpires"}
							{strip}
								<span{if $customerinfo.icexpires - time() < 31 * 86400} class="lms-ui-alert bold"{/if}>
									{$customerinfo.icexpires|date_format:"Y-m-d"}
								<span>
							{/strip}
						{/textformat}
						({t a=$icexpires}expires $a{/t})
					{elseif $customerinfo.icexpires === '0'}
						({trans("never expires")})
					{/if}
				{/if}
			</td>
		</tr>
	{/if}
	{if $customerinfo.ssn != ""}
		<tr>
			<td>
				{icon name="user-id-number"}
			</td>
			<td class="nobr">
				{trans("SSN")}: {$customerinfo.ssn|escape}
			</td>
		</tr>
	{/if}
{/if}
{if $customerinfo.ten != ""}
	<TR>
		<TD>
			{icon name="user-id-number"}
		</TD>
		<TD class="nobr">
			{trans("TEN")}: {$customerinfo.ten}
		</TD>
	</TR>
{/if}
{if $customerinfo.regon != ""}
	<TR>
		<TD>
			{icon name="user-id-number"}
		</TD>
		<TD class="nobr">
			{trans("REGON")}: {$customerinfo.regon}
		</TD>
	</TR>
{/if}
{if $customerinfo.rbe != ""}
	<TR>
		<TD>
			{icon name="user-id-number"}
		</TD>
		<TD class="nobr">
			{trans("RBE")}: {$customerinfo.rbe|escape}
		</TD>
	</TR>
{/if}
{if $customergroups}
	<TR>
		<TD>
			{icon name="customergroup"}
		</TD>
		<TD>
			{foreach from=$customergroups item=customergroup name=customergroup}
				{$customergroup.name}{if !$smarty.foreach.customergroup.last},{/if}
			{/foreach}
		</TD>
	</TR>
{/if}
{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_finances')}
	<TR>
		<TD>
			{icon name="money"}
		</TD>
		<TD class="nobr">
			<strong>{trans("Balance:")}</strong>
			{if $customerinfo.balance < 0}<span class="lms-ui-alert">{$customerinfo.balance|money_format}</span>{else}{$customerinfo.balance|default:"0"|money_format}{/if}
		</TD>
	</TR>
{/if}
    </TBODY>
</TABLE>
