{extends file=$smarty.const.SMARTY_LAYOUT_DASHBOARD_WIDGET_DEFAULT}

{block name="content"}

	{$colsAssoc=$widget['data']['columnsListAssoc']}

	{if $widget['data']['ordersList']}
		<table class="simpleList w100p">
			<thead>
				<tr>
					{foreach $colsAssoc as $col => $nothing}
						<th>{$_LANG['dashboard']['widgetsList']['App\Dashboard\Widget\ClientLastServices']['options']['columnsList_options'][$col]}</th>
					{/foreach}
				</tr>
			</thead>

			<tbody>
				{foreach $widget['data']['ordersList'] as $row}
					<tr class="{cycle values="odd,even"}">
						{foreach $colsAssoc as $col=>$nothing}
							{if $col=='idService'}
								<td class="left">{serviceLabel ref=$row['idService']}</td>
							{/if}

							{if $col=='orderDetails'}
								<td class="left">
									<table>
										<tbody>
											<tr>
												<td>{$_LANG['dashboard']['widgetsList']['App\Dashboard\Widget\ClientLastServices']['options']['columnsList_options']['orderId']}:</td>
												<td>{orderLabel ref=$row['idOrder'] format=$row['convertedId']}</td>
											</tr>

											<tr>
												<td class="left">{$_LANG['dashboard']['widgetsList']['App\Dashboard\Widget\ClientLastServices']['options']['columnsList_options']['number']}:</td>
												<td>{$row['orderNumber']}</td>

											</tr>

											<tr>
												<td class="left">{$_LANG['dashboard']['widgetsList']['App\Dashboard\Widget\ClientLastServices']['options']['columnsList_options']['date']}:</td>
												<td>{$row['orderDate']|dateTimeFormat}</td>
											</tr>
										</tbody>
									</table>
								</td>
							{/if}

							{if $col=='serviceCode'}
								<td class="center nowrap">{$row['service']}</td>
							{/if}

							{if $col=='servicePeriod'}
								<td class="center nowrap">{$row['startDate']|dateTimeFormat:'date'}&raquo;{$row['endDate']|dateTimeFormat:'date'}</td>
							{/if}

							{if $col=='serviceAddDate'}
								<td class="left">
									{$row['addTime']|dateTimeFormat:'dateWithHMS'}
								</td>
							{/if}

							{if $col=='serviceStatus'}
								<td class="right nowrap">
									{$row['statusOp']} / {$row['statusFin']}
								</td>
							{/if}

							{if $col=='offerTotalValue'}
								<td class="right nowrap">
									{$row['offerTotal']|priceFormat:$row['offerTotalCurrency']}
								</td>
							{/if}

							{if $col=='invoicedValue'}
								<td class="right nowrap">
									{$separator=""}
									{foreach $row['invoiceTotalValue'] as $currency=>$value}
										{if $value>0.0001 || $value<-0.0001}
											{$separator}
											{$value|priceFormat:$currency}
											{$separator=","}
										{/if}
									{/foreach}

									{if !$separator}
										-
									{/if}
								</td>
							{/if}

						{/foreach}
					</tr>

				{/foreach}
			</tbody>
		</table>
	{else}
		{if !$colsAssoc}
			<div class="messageDivContainer layout-inline">
				{message type='info' message=$_LANG['dashboard']['widgetsList']['App\Dashboard\Widget\ClientLastServices']['messages']['noColumnsSelected']}
			</div>
		{elseif $widget['data']['errorMessage']}
			<div class="messageDivContainer layout-inline">
				{message type='warning' message=$widget['data']['errorMessage']}
			</div>
		{else}
			<div class="messageDivContainer layout-inline">
				{message type='info' message=$_LANG['dashboard']['widgetsList']['App\Dashboard\Widget\ClientLastServices']['messages']['noResults']}
			</div>
		{/if}

	{/if}
{/block}
