{extends file=$smarty.const.SMARTY_LAYOUT_DASHBOARD_WIDGET_DEFAULT}

{block name="content"}
	{$customerEntity = $widget['data']['customerEntity']}

	{if $customerEntity}
		<table class="simpleList entityData w100p">
			<tbody>
				<tr>
					{************* GENERAL DETAILS *************}
					<td>
						<table class="tableBox w100p">
							<thead>
								<tr>
									<th colspan="2" class="generalInfo">{$widgetLang['options']['columnsList']['generalDetails']}</th>
								</tr>
							</thead>
							<tbody>

								{**** ID ****}
								<tr>
									<td class="label">{$widgetLang['columns']['id']}:</td>
									<td class="value">{$customerEntity->getId()}</td>
								</tr>

								{**** NAME ****}
								<tr>
									<td class="label">{$widgetLang['columns']['name']}:</td>
									<td class="value">{customerLabel ref=$customerEntity->getId()}</td>
								</tr>

								{**** CORPORATE ****}
								{$idCorporate = $customerEntity->idCorporate}
								<tr>
									<td class="label">{$widgetLang['columns']['company']}:</td>
									<td class="value">
									{if $idCorporate}
										{corporateLabel ref=$idCorporate}
									{else}
										-
									{/if}</td>
								</tr>

								{**** DEPARTMENT ****}
								{$department = $customerEntity->department}
								<tr>
									<td class="label">{$widgetLang['columns']['department']}:</td>
									<td class="value">{$department|default:"-"}</td>
								</tr>

								{**** TYPE ****}
								{$typeName = $customerEntity->typeName}
								<tr>
									<td class="label">{$widgetLang['columns']['type']}:</td>
									<td class="value">{$typeName|default:"-"}</td>
								</tr>

								{**** TITLE ****}
								{$titleName = $customerEntity->titleName}
								<tr>
									<td class="label">{$widgetLang['columns']['title']}:</td>
									<td class="value">{$titleName|default:"-"}</td>
								</tr>

								{**** ID PARENT ****}
								{$idParent = $customerEntity->idParent}
								<tr>
									<td class="label">{$widgetLang['columns']['idParent']}:</td>
									<td class="value">{if $idParent}{customerLabel ref=$idParent}{else}-{/if}</td>
								</tr>

								{**** LOCKED ****}
								<tr>
									<td class="label">{$widgetLang['columns']['locked']}:</td>
									<td class="value">
										{if $customerEntity->locked}
											{$_LANG['yes']}
										{else}
											{$_LANG['no']}
										{/if}
									</td>
								</tr>

								{**** SEGMENT ****}
								{$idSegment = $customerEntity->idSegment}
								<tr>
									<td class="label">{$widgetLang['columns']['segment']}:</td>
									<td class="value">
										{if $idSegment}
											{customerSegmentLabel ref=$idSegment}
										{else}
											-
										{/if}
									</td>
								</tr>

								{**** FLAG ****}
								{$flagName = $customerEntity->flagName}
								<tr>
									<td class="label">{$widgetLang['columns']['flag']}:</td>
									<td class="value">{$flagName|default:"-"}</td>
								</tr>
							</tbody>
						</table>

						{**** FREQUENT BUYER CARDS ****}
						{$fbCardsList = $customerEntity->frequentBuyerCards}
						{if $fbCardsList}
							<table class="tableBox w100p">
								<thead>
									<tr>
										<th colspan="2" class="frequentBuyerCards">{$widgetLang['columns']['frequentBuyerCard']}</th>
									</tr>
								</thead>
								<tbody>
									{foreach $fbCardsList as $idCard => $card}
									<tr>
										<td class="label fbCard">{$card['cardNumber']}</td>
										<td class="value fbCard">
										{$separator=""}
										{foreach $card['idSuppliers'] as $idSupp}
											{$separator}
											{supplierLabel ref=$idSupp}
											{$separator=","}
										{/foreach}
										</td>
									</tr>
									{/foreach}
								</tbody>
							</table>
						{/if}
					</td>

					<td>
						{************* PERSONAL INFORMATION *************}
						<table class="tableBox w100p">
							<thead>
								<tr>
									<th colspan="2" class="personalInfo">{$widgetLang['columns']['personalDetails']}</th>
								</tr>
							</thead>
							<tbody>

								{**** BIRTHDAY ****}
								{$birthday = $customerEntity->birthday}
								<tr>
									<td class="label">{$widgetLang['columns']['birthday']}:</td>
									<td class="value">
										{if $birthday && $birthday != '0000-00-00'}
											{$birthday|dateTimeFormat}
										{else}
											-
										{/if}
									</td>
								</tr>

								{**** ID SERIES ****}
								{$ID_series = $customerEntity->ID_series}
								<tr>
									<td class="label">{$widgetLang['columns']['ID_series']}:</td>
									<td class="value">{$ID_series|default:"-"}</td>
								</tr>

								{**** ID NUMBER ****}
								{$ID_number = $customerEntity->ID_number}
								<tr>
									<td class="label">{$widgetLang['columns']['ID_number']}:</td>
									<td class="value">{$ID_number|default:"-"}</td>
								</tr>

								{**** ID RELEASE DATE ****}
								{$ID_releaseDate = $customerEntity->ID_releaseDate}
								<tr>
									<td class="label">{$widgetLang['columns']['ID_releaseDate']}:</td>
									<td class="value">
										{if $ID_releaseDate && $ID_releaseDate != '0000-00-00'}
											{$ID_releaseDate|dateTimeFormat}
										{else}
											-
										{/if}
									</td>
								</tr>

								{**** ID RELEASE BY ****}
								{$ID_releaseBy = $customerEntity->ID_releaseBy}
								<tr>
									<td class="label">{$widgetLang['columns']['ID_releaseBy']}:</td>
									<td class="value">{$ID_releaseBy|default:"-"}</td>
								</tr>

								{**** ID EXPIRE DATE ****}
								{$ID_expireDate = $customerEntity->ID_expireDate}
								<tr>
									<td class="label">{$widgetLang['columns']['ID_expireDate']}:</td>
									<td class="value">
										{if $ID_expireDate && $ID_expireDate != '0000-00-00'}
											{$ID_expireDate|dateTimeFormat}
										{else}
											-
										{/if}
									</td>
								</tr>

								{**** PNC ****}
								{$PNC = $customerEntity->PNC}
								<tr>
									<td class="label">{$widgetLang['columns']['PNC']}:</td>
									<td class="value">{$PNC|default:"-"}</td>
								</tr>
							</tbody>
						</table>

						{*********************** CONTACT DETAILS ****************************************}
						<table class="tableBox w100p">
							<thead>
								<tr>
									<th colspan="2" class="contactDetails">{$widgetLang['columns']['contact']}</th>
								</tr>
							</thead>
							<tbody>

								{**** ADDRESS ****}
								{$address = $customerEntity->address}
								<tr>
									<td class="label">{$widgetLang['columns']['address']}:</td>
									<td class="value">{$address|default:"-"}</td>
								</tr>

								{**** DELIVERY ADDRESS ****}
								{$deliveryAddress = $customerEntity->deliveryAddress}
								<tr>
									<td class="label">{$widgetLang['columns']['deliveryAddress']}:</td>
									<td class="value">{$deliveryAddress|default:"-"}</td>
								</tr>

								{**** COMPOSED ADDRESS ****}
								{$composedAddress = $customerEntity->composedAddress}
								<tr>
									<td class="label">{$widgetLang['columns']['composedAddress']}:</td>
									<td class="value">{$composedAddress|default:"-"}</td>
								</tr>

								{**** COMPOSED DELIVERY ADDRESS ****}
								{$composedDeliveryAddress = $customerEntity->composedDeliveryAddress}
								<tr>
									<td class="label">{$widgetLang['columns']['composedDeliveryAddress']}:</td>
									<td class="value">{$composedDeliveryAddress|default:"-"}</td>
								</tr>

								{**** ZIP CODE ****}
								{$zipCode = $customerEntity->zipCode}
								<tr>
									<td class="label">{$widgetLang['columns']['zipCode']}:</td>
									<td class="value">{$zipCode|default:"-"}</td>
								</tr>

								{**** TELEPHONE ****}
								{$telephone = $customerEntity->telephone}
								<tr>
									<td class="label">{$widgetLang['columns']['telephone']}:</td>
									<td class="value">{$telephone|default:"-"}</td>
								</tr>

								{**** TELEPHONE MOBILE ****}
								{$telephoneMobile = $customerEntity->telephoneMobile}
								<tr>
									<td class="label">{$widgetLang['columns']['telephoneMobile']}:</td>
									<td class="value">{$telephoneMobile|default:"-"}</td>
								</tr>

								{**** EMAIL ****}
								{$email = $customerEntity->email}
								<tr>
									<td class="label">{$widgetLang['columns']['email']}:</td>
									<td class="value">{$email|default:"-"}</td>
								</tr>
							</tbody>
						</table>
					</td>
					<td>
						{************************* BANK DETAILS  ****************************}
						<table class="tableBox w100p">
							<thead>
								<tr>
									<th colspan="2" class="bankInfo">{$widgetLang['columns']['bankDetails']}</th>
								</tr>
							</thead>
							<tbody>

								{**** BANK ACCOUNT ****}
								{$bankAccount = $customerEntity->bankAccount}
								<tr>
									<td class="label">{$widgetLang['columns']['bankAccount']}:</td>
									<td class="value">{$bankAccount|default:"-"}</td>
								</tr>

								<tr>
									{$idBank = $customerEntity->idBank}
									<td class="label">{$widgetLang['columns']['bank']}:</td>
									<td class="value">
										{if $idBank}
											{bankLabel ref=$idBank}
										{else}
											-
										{/if}
									</td>
								</tr>
							</tbody>
						</table>

						{************************* CLIENT DEBIT/CREDIT  ****************************}
						<table class="tableBox w100p">
							<thead>
								<tr>
									<th colspan="3" class="clientDebitBalance">{$widgetLang['columns']['debitCredit']}</th>
								</tr>
							</thead>

							<tbody>
								{****************** DEBIT ********************}
								{if $customerEntity->equivDebitBalance}
									<tr>
										<td class="label">{$widgetLang['columns']['debitBalance']}</td>
										<td class="label bold">
											{$currency=sprintf("%s (%s)", $widget['data']['defaultCurrency'], $widgetLang['columns']['equivalent'])}
											&raquo; {$currency}
										</td>
										<td class="value bold">{$customerEntity->equivDebitBalance|priceFormat:$widget['data']['defaultCurrency']:true}</td>
									</tr>
									{foreach $customerEntity->debitBalanceDetails as $currency => $value}
										<tr>
											<td class="label">&nbsp;</td>
											<td class="label bold">&raquo; {$currency}:</td>
											<td class="value">{$value|priceFormat:$currency:1}</td>
										</tr>
									{/foreach}
								{else}
									<tr><td>-</td></tr>
								{/if}

								{****************** CREDIT ********************}
								{if $customerEntity->equivCreditBalance}
									<tr>
										<td class="label">{$widgetLang['columns']['creditBalance']}</td>
										<td class="label bold">
											{$currency=sprintf("%s (%s)", $widget['data']['defaultCurrency'], $widgetLang['columns']['equivalent'])}
											&raquo; {$currency}
										</td>
										<td class="value bold">{$customerEntity->equivCreditBalance|priceFormat:$widget['data']['defaultCurrency']:true}</td>
									</tr>
									{foreach $customerEntity->creditBalanceDetails as $currency => $value}
										<tr>
											<td class="label">&nbsp;</td>
											<td class="label bold">&raquo; {$currency}:</td>
											<td class="value">{$value|priceFormat:$currency:1}</td>
										</tr>
									{/foreach}
								{else}
									<tr><td>-</td></tr>
								{/if}


								{****************** OPERATIONAL BALANCE ********************}
								{if $customerEntity->equivOperationalBalance}
									<tr>
										<td class="label">{$widgetLang['columns']['operationalBalance']}</td>
										<td class="label bold">
											{$currency=sprintf("%s (%s)", $widget['data']['defaultCurrency'], $widgetLang['columns']['equivalent'])}
											&raquo; {$currency}
										</td>
										<td class="value bold">{$customerEntity->equivOperationalBalance|priceFormat:$widget['data']['defaultCurrency']:true}</td>
									</tr>
									{foreach $customerEntity->operationalBalanceDetails as $currency => $value}
										<tr>
											<td class="label">&nbsp;</td>
											<td class="label bold">&raquo; {$currency}:</td>
											<td class="value">{$value|priceFormat:$currency:1}</td>
										</tr>
									{/foreach}
								{else}
									<tr><td>-</td></tr>
								{/if}

							</tbody>
						</table>
					</td>
				</tr>
			</tbody>
		</table>
	{else}
		<div class="messageDivContainer layout-inline">
			{message type='warning' message=$widget['data']['errorMessage']}
		</div>
	{/if}
{/block}