{extends file=$smarty.const.SMARTY_LAYOUT_DASHBOARD_WIDGET_DEFAULT}

{block name="localCSS" append}
	<style>
		div.dashboard.container-extern >div.dashboard.container-intern table.entityData table.tableBox td.value.orderProgressBar div.progressbar-container {
			width: 20%;
			float:right;
		}
	</style>

{/block}

{block name="content"}
	{if $widget['data']['errorMessage']}
		<div class="messageDivContainer layout-inline">
			{message type='warning' message=$widget['data']['errorMessage']}
		</div>
	{else}
		{$orderEntity = \Entity\Order::select($widget['data']['orderId'])}
		<table class="simpleList entityData w100p">
			<tbody>
				<tr>
					{************************ GENERAL DETAILS ***************************}
					<td>
						<table class="tableBox w100p">
							<thead>
								<tr>
									<th colspan="2" class="generalInfo">{$widgetLang['columnsList']['generalDetails']}</th>
								</tr>
							</thead>
							<tbody>

								{*********** ID ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['id']}:</td>
									<td class="value">{orderLabel ref=$widget['data']['orderId']}</td>
								</tr>
								
								{*********** CONVERTED ID ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['convertedId']}:</td>
									<td class="value">{$orderEntity->convertedId}</td>
								</tr>

								{*********** ORDER NUMBER ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['number']}:</td>
									<td class="value">{$orderEntity->reservationNumber}</td>
								</tr>

								{*********** ORDER DATE ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['date']}:</td>
									<td class="value">{$orderEntity->date|dateTimeFormat}</td>
								</tr>

								{*********** ORDER TYPE ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['type']}:</td>
									<td class="value">{$orderEntity->resTypeName|default:"-"}</td>
								</tr>

								{*********** SERVICES TYPE ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['servicesType']}:</td>
									<td class="value">{$orderEntity->servicesTypeName}</td>
								</tr>

								{*********** FLAG ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['flag']}:</td>
									<td class="value">{$orderEntity->flagName}</td>
								</tr>

								{*********** PERIOD ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['period']}:</td>
									<td class="value">{$orderEntity->startDate|dateTimeFormat} &raquo {$orderEntity->endDate|dateTimeFormat}</td>
								</tr>

								{*********** OWNER PASSENGER ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['ownerPassenger']}:</td>
									<td class="value">{customerLabel ref=$orderEntity->idCustomerOwner}</td>
								</tr>

								{*********** OWNER COMPANY ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['ownerCompany']}:</td>
									<td class="value">
										{if $orderEntity->idCorporateOwner}
											{corporateLabel ref=$orderEntity->idCorporateOwner}
										{else}
											-
										{/if}
									</td>
								</tr>

								{*********** STATUS ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['status']}:</td>
									<td class="value">{$orderEntity->statusOpName} / {$orderEntity->statusFinName}</td>
								</tr>

								{*********** RESPONSIBLE ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['responsible']}:</td>
									<td class="value">{userLabel ref=$orderEntity->idUser} / {officeLabel ref=$orderEntity->idOffice}</td>
								</tr>

								{*********** PROGRESS ******}
								<tr>
									<td class="label">{$widgetLang['columnsList']['progress']}:</td>
									<td class="value orderProgressBar">
										{if $widget['data']['maxScore']}
											{$percent = $widget['data']['totalScore'] / $widget['data']['maxScore']}
										{else}
											{$percent = 0}
										{/if}
										{progressbar value=$percent
												label=sprintf("%s%%", round($percent*100))
												tooltip="
													<div>{$widgetLang['tooltip']['noServices']}: <b>{$widget['data']['serviceStatistics']['noServices']}</b></div>
													<div>{$widgetLang['tooltip']['noServicesNp']}: <b>{$widget['data']['serviceStatistics']['noServicesNp']}</b></div>
													<div>{$widgetLang['tooltip']['noServicesOK']}: <b>{$widget['data']['serviceStatistics']['noServicesOk']}</b></div>
													<div>{$widgetLang['tooltip']['noServicesTi']}: <b>{$widget['data']['serviceStatistics']['noServicesTi']}</b></div>
													<div>{$widgetLang['tooltip']['noServicesTiAndCashed']}: <b>{$widget['data']['serviceStatistics']['noServicesTiAndCashed']}</b></div>
													<div>{$widgetLang['tooltip']['noServicesBalanced']}: <b>{$widget['data']['serviceStatistics']['noServicesBalanced']}</b></div>
													<div>{$widgetLang['tooltip']['noServicesXX']}: <b>{$widget['data']['serviceStatistics']['noServicesXX']}</b></div>
												"}

									</td>
								</tr>

							</tbody>
						</table>
					</td>
				</tr>
			</tbody>
		</table>
	{/if}
{/block}