{extends file=$smarty.const.SMARTY_LAYOUT_CONTENT_LIST_TABLE_CURRENT_DATA}

{block name="listing-tr-class"}
	{if $rowFields['blockTime']}
		disabled
	{/if}
{/block}

{block name="listing-tr-extraData" append}data-invoiceNumber="{$rowFields['invoiceNumber']}" data-invoiceDate="{$rowFields['invoiceDate']|date_format:"%d-%m-%Y"}"{/block}

{block name="listing-td-content-invoiceNumber"}
	{if $rowFields['invoiceNumber']}
		<b>{$rowFields['invoiceNumber']}</b>
	{/if}

	<div class="italic invoiceSeriesList">{$rowFields['invoiceSeries']}</div>
{/block}

{block name="listing-td-content-idSupplier"}
	{supplierLabel ref=$rowFields['idSupplier']}
{/block}

{block name="listing-td-content-idUser"}
	{userLabel ref=$rowFields['idUser']}
	<div class="italic grey">[{officeLabel ref=$rowFields['idOffice']}]</div>
{/block}

{block name="listing-td-content-statusOp"}
	{$lang['index']['statusOp'][$rowFields['statusOp']]}
{/block}

{block name="listing-td-content-totalValue"}
	<div class="totalValue">
		<b>
			{if $rowFields['totalValue']<0}
				<span style='color:red;'>{$rowFields['totalValue']|priceFormat:$rowFields['currency']}</span>
			{else}
				{$rowFields['totalValue']|priceFormat:$rowFields['currency']}
			{/if}
		</b>
	</div>

	{$invObj = \Entity\SupplierInvoice::select($rowFields['id'])}
	{progressbar value=$invObj->paidPercentDisplay/100
		label=sprintf("%s%%", $invObj->paidPercentDisplay)
		tooltip="
			{if $rowFields['statusFin']=='n'}
				{$lang['index']['statusFin']['notPayed']}
			{elseif $rowFields['statusFin']=='t'}
				{$lang['index']['statusFin']['t']}
			{elseif $rowFields['statusFin']=='o'}
				<div>{$lang['tooltips']['invoicePayedOver']} <b>({$invObj->paidPercentDisplay}%)</b></div>
				<div>{$lang['tooltips']['invoicePayedOverDiff']}: <b>{($rowFields['payedValue']-$rowFields['totalValue'])|priceFormat:$rowFields['currency']}</b></div>
			{else}
				<div>{$lang['tooltips']['invoicePayedPartial']} <b>({$invObj->paidPercentDisplay}%)</b></div>
				<div>{$lang['tooltips']['invoicePayedPartialDiff']}: <b>{($rowFields['totalValue']-$rowFields['payedValue'])|priceFormat:$rowFields['currency']}</b></div>
			{/if}
	"}
{/block}

{block name="listing-td-content-dueDate"}
	<div
		{if $rowFields['dueDate']<$smarty.const.TODAY_ISO and $rowFields['statusFin']!='t' and $rowFields['voidTime']==0}class="bold red"{/if}
	>
		{if $rowFields['dueDate']}
			{$rowFields['dueDate']|dateTimeFormat}
		{else}
			-
		{/if}
	</div>
{/block}

{block name="listing-td-content-addTime"}
	<div class='date'>
		{$rowFields['addTime']|dateTimeFormat}
	</div>
	<div class='time grey'>
		{$rowFields['addTime']|dateTimeFormat:'timeWithHMS'}
	</div>
	<div>[{supplierInvoiceLabel ref={$rowFields['id']}}]</div>
{/block}
