{extends file=$smarty.const.SMARTY_LAYOUT_CONTENT_LIST_TABLE_CURRENT_DATA}

{block name="listing-tr-extraData"}
	data-orderId="{$rowFields['idImportedOrder']}"
{/block}

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

{block name="listing-td-content-idSystem"}
	<div class="system">
		{importedOrdersSystemLabel ref=$rowFields['idSystem']}
	</div>

	<div class="serviceType">
		<span>
			{serviceTypeLabel ref=$rowFields['serviceCode']}
			{if $rowFields['isPackage']}<span class="red">[{$lang['index']['others']['package_parent']}]</span>{/if}
			{if $rowFields['idImportedServicePackage']}
				<span class="grey">[{$lang['index']['others']['package_child']}]</span>
			{/if}
		</span>
	</div>

	<div class="serviceStatus">
		<span class="systemStatus systemStatus-{$rowFields['systemStatus']}">{$rowFields['systemStatus']}</span>

		{if $rowFields['systemStatus']=='refunded'}
			<span class='orderDate'>{$rowFields['cancelDate']|dateTimeFormat}</span>
		{/if}
	</div>

	{if $rowFields['entity']->idImportedServiceReissued}
		<div class="reissue">
			{$lang['index']['listing']['reissueOf']} {importedServiceLabel ref=$rowFields['entity']->idImportedServiceReissued format="%offerConfirmationNumber%"}
		</div>
	{/if}
{/block}

{block name="listing-td-content-tickets"}
	{if $rowFields['entity']->object} {* this should never happen - we had some issues with imported tickets stored in imported services table but they did not appear in the serialized object *}
		{if $rowFields['entity']->object->chosenOffer}
			{$tickets=$rowFields['entity']->object->chosenOffer->ticketNumbers}
			{if $tickets}
				{$ticket=$tickets|reset}
				<div>
					{$ticket['number']}
					{if $rowFields['entity']->object->chosenOffer->ticketDate}
						/ {$rowFields['entity']->object->chosenOffer->ticketDate|dateTimeFormat}
					{/if}
				</div>
			{/if}
		{/if}
	{/if}
	<span class='orderDate'>{$rowFields['orderDate']|dateTimeFormat}</span>
	{if $rowFields['offerExternalSystemReservationId']}
		<div>
			<b>{$rowFields['offerExternalSystemReservationId']}</b>
		</div>
	{/if}
{/block}

{block name="listing-td-content-processStatus"}
	<div>{$_LANG['importedService']['statusName'][$rowFields['processStatus']]}</div>
	{if $rowFields['idServiceTinaInitial']}
		{if \Entity\Service::select($rowFields['idServiceTinaInitial'])->recordExists()}
			<div tooltip="{$lang['index']['others']['tinaServiceInitial']}">[{serviceLabel ref=$rowFields['idServiceTinaInitial']}]</div>
		{else}
			<div tooltip="{$lang['index']['others']['tinaServiceInitial']}">[<i>{$rowFields['idServiceTinaInitial']}</i>]</div>
		{/if}
	{/if}
{/block}

{block name="listing-td-content-passengers"}
	{if $rowFields['entity']->object} {* this should never happen - we had some issues with imported tickets stored in imported services table but they did not appear in the serialized object *}
		{$passengers=(array)$rowFields['entity']->object->passengers}
		{if $passengers}
            {$firstPassenger=$passengers|reset}
            {if $firstPassenger->firstNameLocal && $firstPassenger->lastNameLocal}
                <div>{nameFormat firstName=$firstPassenger->firstNameLocal lastName=$firstPassenger->lastNameLocal}</div>
            {else}
                <div>{nameFormat firstName=$firstPassenger->firstNameStandard lastName=$firstPassenger->lastNameStandard}</div>
            {/if}
        {/if}
	{/if}
	<div>
		{if $rowFields['idCorporateOwner']}
			{corporateLabel ref=$rowFields['idCorporateOwner']}
		{else}
			{$rowFields['ownerCorporate']}
		{/if}
	</div>
{/block}

{block name="listing-td-content-interval"}
	{if $rowFields['startDate'] && $rowFields['endDate'] && $rowFields['startDate']!=$rowFields['endDate']}
		<span class="date">{$rowFields['startDate']|dateTimeFormat}</span>
		&raquo
		<span class="date">{$rowFields['endDate']|dateTimeFormat}</span>
	{elseif $rowFields['startDate']}
		<span class="date">{$rowFields['startDate']|dateTimeFormat}</span>
	{/if}

	{if $rowFields['destinationCityId'] || $rowFields['destinationCountryCode']}
		<div>
			{cityLabel ref=$rowFields['destinationCityId']}
			{if $rowFields['destinationCountryCode']}
				({countryLabel ref=$rowFields['destinationCountryCode']})
			{/if}
		</div>
	{/if}


{/block}

{block name="listing-td-content-prices"}
	{function name="printPrice" label="" currency="" amount="" VAT="" total=false highlight=false}
		<strong>{$amount|priceFormat:$currency}</strong>
	{/function}

	{if (float)$rowFields['offerTotalValue']}
		{printPrice label=$lang['index']['listing']['prices']['servicePriceTotal']
			amount=$rowFields['offerTotalValue']
			currency=$rowFields['offerTotalCurrency']}
	{/if}

	{if $rowFields['idOfferSupplier']}
		<div>
			{supplierLabel ref=$rowFields['idOfferSupplier']}
		</div>
	{/if}
{/block}

{block name="listing-td-content-order"}
	<div><span class="remoteLoadLink" onclick="RemoteLoad.loadEntity(this, 'importedOrder', '{$rowFields['idImportedOrder']}');">{$rowFields['idImportedOrder']}</span></div>
	{if $rowFields['importedOrderIdExtSys']}
		<div tooltip="{$lang['index']['others']['impOrdExtSysIdTooltip']}"><i>{$rowFields['importedOrderIdExtSys']}</i></div>
	{/if}
{/block}

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

{block name="listing-td-content-addTime"}
	<div>
		{$rowFields['addTime']|dateTimeFormat:'dateWithHMS'}
	</div>
	<div>
		[{importedServiceLabel ref=$rowFields['id']}]
	</div>
{/block}

