{extends file=$smarty.const.SMARTY_LAYOUT_MAIN_POPUP}

{block name="template-head" append}
	{$JS->loadGroup("fieldset")}
	{$CSS->loadGroup("fieldset")}
	{$JS->loadGroup("optionsBox.icons")}
	{$CSS->loadGroup("optionsBox.icons")}
	{$JS->loadGroup("remoteLoad")}
	{$CSS->loadGroup("remoteLoad")}
{/block}

{block name="css" append}
	<style type='text/css'>
		fieldset.default {
			margin-bottom: 2em;
		}
	</style>
{/block}

{block name="operations" append}
	{if $filesList}

		<select class="filesList" style="max-width:600px;">
			<option value="">{$lang['viewOrder']['formFields']['defaultFile']}</option>
			{foreach from=$filesList key=indexArray item=files}
				<option value="{$files['file']}"
					{if !$files['fileExists']} class="dummy-file-not-exists" {/if}>

					{if $files['name']}
						{$files['name']} - {$files['time']}
					{else}
						{$files['file']} - {$files['time']}
					{/if}
				</option>
			{/foreach}
		</select>

		<button type="button" id="buttonDownload"
			onclick="
				if ($(this).up('div.engine-header').down('select').value == '') {
					alert('{$lang['viewOrder']['formFields']['invalidFile']}');
				}
				else {
					if ($('buttonDownload').up('div.engine-header').down('select.filesList')[$('buttonDownload').up('div.engine-header').down('select.filesList').selectedIndex].hasClassName('dummy-file-not-exists')){
						alert('{$lang['downloadFile']['errorFile']}');
					}
					else {
						window.location = MVC.appUrl(MVC.CURRENT_MODULE, 'downloadFile', { 'file': $(this).up('div.engine-header').down('select').value, 'idOrder' : {$idOrder}});
					}
				}
			"
		>{$lang['viewOrder']['formFields']['downloadButton']}</button>

	{/if}


	<button type="button" id="viewAllOrderDetails"
		onclick="
			window.location= MVC.appUrl(MVC.CURRENT_MODULE, 'orderDetails', { 'idOrder' : {$idOrder}});
	"
	>{$lang['viewOrder']['formFields']['orderDetails']}</button>

{/block}

{block name="content" prepend}
	{$mvcView->renderImportedOrder($importedOrderObj, $importedServicesList)}
{/block}
