{block name="content"}
	{block name="documentDetails"}
		<fieldset class='default'>
			<legend class="hand">
				{$lang['viewDocument']['document']['legend']}
			</legend>

			<table class="simpleList" width="100%" style="margin: 0px">
				<thead>
					<tr>
						<th class="nowrap left">{$lang['viewDocument']['document']['generalDate']}</th>
						<th class="nowrap left">{$lang['viewDocument']['document']['value']}</th>
						<th class="nowrap left">{$lang['viewDocument']['document']['remarks']}</th>
						<th class="nowrap left">{$lang['viewDocument']['document']['extraInfo']}</th>
						<th class="nowrap left">{$lang['viewDocument']['document']['respUser']}</th>
					</tr>
				</thead>

				<tbody>
					<tr>
						<td>
							<div>
								<b>
								{if $importedDocumentObj->getDocumentCategory() == 'cashing'}
									{\App\Config\CashingDocuments::getInstance()->getName($importedDocumentObj->docType)}
								{else}
									{\App\Config\PaymentDocuments::getInstance()->getName($importedDocumentObj->docType)}
								{/if}
								</b>
								({$importedDocumentObj->getDocumentCategory()})
							</div>
							<div><b>{$lang['viewDocument']['document']['docDate']}</b> : {$importedDocumentObj->docDate}</div>
							<div><b>{$lang['viewDocument']['document']['docNumber']}</b>: {$importedDocumentObj->docNumber}</div>
						</td>

						<td>
							{$importedDocumentObj->value} {$importedDocumentObj->currency}
						</td>

						<td>
							{if $importedDocumentObj->remarks}
								{$importedDocumentObj->remarks|nl2br}
							{else}
								-
							{/if}
						</td>
						<td>
							{if $importedDocumentObj->comments}
								<div>
									<b>{$lang['viewDocument']['document']['comments']}:</b> {$importedDocumentObj->comments}
								</div>
							{/if}
							{if $importedDocumentObj->explanations}
								<div>
									<b>{$lang['viewDocument']['document']['explanations']}:</b> {$importedDocumentObj->explanations}
								</div>
							{/if}
						</td>

						<td>
							{if $importedDocumentObj->getResponsibleUser()}

								{if $importedDocumentObj->getResponsibleUser()->firstName or $importedDocumentObj->getResponsibleUser()->lastName}
									<div>
										<b>{$lang['viewDocument']['document']['userName']}</b> : {$importedDocumentObj->getResponsibleUser()->firstName} {$importedDocumentObj->getResponsibleUser()->lastName}
									</div>
								{/if}
								{if  $importedDocumentObj->getResponsibleUser()->idSystem}
									<div>
										<b>{$lang['viewDocument']['document']['userIdSystem']}</b> : {$importedDocumentObj->getResponsibleUser()->idSystem}
									</div>
								{/if}
								{if  $importedDocumentObj->getResponsibleUser()->idTina}
									<div>
										<b>{$lang['viewDocument']['document']['userIdTina']}</b> : {$importedDocumentObj->getResponsibleUser()->idTina}
									</div>
								{/if}
							{else}
								-
							{/if}
						</td>
					</tr>

				</tbody>
			</table>
		</fieldset>
	{/block}

	{if $client['type'] == 'corporate'}
		{block name="client"}
			<fieldset class='default'>
				<legend class="hand">
					{$lang['viewDocument']['corporate']['legend']}
				</legend>

				<table class="simpleList" width="100%" style="margin: 0px">
					<thead>
						<tr>
							<th class="nowrap left">{$lang['viewDocument']['corporate']['ids']}</th>
							<th class="nowrap left">{$lang['viewDocument']['corporate']['name']}</th>
							<th class="nowrap left">{$lang['viewDocument']['corporate']['generalData']}</th>
						</tr>
					</thead>

					<tbody>
						<tr>
							<td>
								{if $client['systemId']}
									{$client['systemId']}
								{else}
									-
								{/if}
								/
								{if $client['tinaId']}
									{$client['tinaId']}
								{else}
									-
								{/if}
							</td>
							<td>{$client['name']}</td>
							<td>
								{if $client['fiscalCode']}
									<div><b>{$lang['viewDocument']['corporate']['fiscalCode']}</b>: {$client['fiscalCode']}</div>
								{/if}
								{if $client['regNo']}
									<div><b>{$lang['viewDocument']['corporate']['regNo']}</b>: {$client['regNo']}</div>
								{/if}
							</td>
						</tr>
					</tbody>
				</table>

			</fieldset>
		{/block}

	{elseif $client['type']=='customer'}
		{block name="client"}
			<fieldset class='default'>
				<legend class="hand">
					{$lang['viewDocument']['customer']['legend']}
				</legend>

				<table class="simpleList" width="100%" style="margin: 0px">
					<thead>
						<tr>
							<th class="nowrap left">{$lang['viewDocument']['customer']['ids']}</th>
							<th class="nowrap left">{$lang['viewDocument']['customer']['name']}</th>
							<th class="nowrap left">{$lang['viewDocument']['customer']['generalData']}</th>
						</tr>
					</thead>

					<tbody>
						<tr>
							<td>
								{if $client['systemId']}
									{$client['systemId']}
								{else}
									-
								{/if}
								/
								{if $client['tinaId']}
									{$client['tinaId']}
								{else}
									-
								{/if}
							</td>
							<td>{$client['firstName']} {$client['lastName']}</td>
							<td>
								{if $client['PNC']}
									<div><b>{$lang['viewDocument']['customer']['PNC']}</b>: {$client['PNC']}</div>
								{/if}

								{if $client['email']}
									<div><b>{$lang['viewDocument']['customer']['email']}</b>: {$client['email']}</div>
								{/if}

								{if $client['telephone']}
									<div><b>{$lang['viewDocument']['customer']['telephone']}</b>: {$client['telephone']}</div>
								{/if}
							</td>
						</tr>
					</tbody>
				</table>

			</fieldset>
		{/block}

	{elseif $client['type']=='supplier'}
		{block name="client"}
			<fieldset class='default'>
				<legend class="hand">
					{$lang['viewDocument']['supplier']['legend']}
				</legend>

				<table class="simpleList" width="100%" style="margin: 0px">
					<thead>
						<tr>
							<th class="nowrap left">{$lang['viewDocument']['supplier']['ids']}</th>
							<th class="nowrap left">{$lang['viewDocument']['supplier']['name']}</th>
							<th class="nowrap left">{$lang['viewDocument']['supplier']['generalData']}</th>
						</tr>
					</thead>

					<tbody>
						<tr>
							<td>
								{if $client['systemId']}
									{$client['systemId']}
								{else}
									-
								{/if}
								/
								{if $client['tinaId']}
									{$client['tinaId']}
								{else}
									-
								{/if}
							</td>

							<td>
								{$client['name']}
							</td>

							<td>
								{if $client['fiscalCode']}
									<div><b>{$lang['viewDocument']['supplier']['fiscalCode']}</b>: {$client['fiscalCode']}</div>
								{/if}

								{if $client['zipCode']}
									<div><b>{$lang['viewDocument']['supplier']['zipCode']}</b>: {$client['zipCode']}</div>
								{/if}
							</td>
						</tr>
					</tbody>
				</table>

			</fieldset>
		{/block}
	{/if}

	{if $invoicesList}
		{block name="invoices"}
			<fieldset class='default'>
				<legend class="hand">
					{$lang['viewDocument']['invoices']['legend']}
				</legend>

				<table class="simpleList" width="100%" style="margin: 0px">
					<thead>
						<tr>
							<th class="nowrap left">#</th>
							<th class="nowrap left">{$lang['viewDocument']['invoices']['ids']}</th>
							<th class="nowrap left">{$lang['viewDocument']['invoices']['numberDate']}</th>
							<th class="nowrap left">{$lang['viewDocument']['invoices']['dueDate']}</th>
							<th class="nowrap left">{$lang['viewDocument']['invoices']['value']}</th>
						</tr>
					</thead>

					<tbody>
						{foreach from=$invoicesList key=key item=invoice}
							<tr>
								<td>
									{$key+1}
								</td>

								<td>
									{if $invoice['idSystem']}
										{$invoice['idSystem']}
									{else}
										-
									{/if}
									/
									{if $invoice['idTina']}
										{$invoice['idTina']}
									{else}
										-
									{/if}
								</td>

								<td>
									{if $invoice['number']}
										{$invoice['number']}
									{else}
										-
									{/if}
									/
									{if $invoice['date']}
										{$invoice['date']}
									{else}
										-
									{/if}
								</td>

								<td>
									{if $invoice['dueDate']}
										{$invoice['dueDate']}
									{else}
										-
									{/if}
								</td>
								<td>
									{if $invoice['totalValue']}
										{$invoice['totalValue']}
									{else}
										-
									{/if}
									{if $invoice['currency']}
										{$invoice['currency']}
									{/if}
								</td>
							</tr>
						{/foreach}
					</tbody>
				</table>

			</fieldset>
		{/block}
	{/if}

{/block}
