{extends file=$smarty.const.SMARTY_LAYOUT_MAIN_WINDOW}

{block name="template-head" append}

	{$JS->loadGroup("listing", [ 'defer'=>false ])}
	{$CSS->loadGroup("listing")}

	{$JS->loadGroup("inputs")}
	{$CSS->loadGroup("inputs")}

	{$JS->loadGroup("optionsBox.icons")}
	{$CSS->loadGroup("optionsBox.icons")}

	{$JS->loadGroup("utils.views.objectexplorer")}
	{$CSS->loadGroup("utils.views.objectexplorer")}

	{$CSS->load("ModulesAbstract/ImportedOrdersFileManager/View/_css/index.css")}
	{$JS->load("ModulesAbstract/ImportedOrdersFileManager/View/_js/index.js")}
{/block}

{block name="engine-content"}
	<div id="pageContent">
		{block name="windowHeader"}
			<div class="window-header">
				<div class="section">
					<span class="current">
						{$pageTitle}
					</span>
				</div>
			</div>
		{/block}

		{block name="content"}
			<div id="filesystemScanner" class="layoutStandard">
				{*************************** FOLDERS ***************************}
				<div class="folders">
					<div class="title">
						<span>{$absLang['folderLabel']}</span>
					</div>

					<div class="browser">
						{if $autoOpen}
							{render action='displayFoldersRecursively' params=['folderPath'=>'/', 'autoOpen'=>$autoOpen, 'autoOpenPaths' =>$autoOpenPaths]}
						{else}
							{render action='displayFolder' params=['folderPath'=>'/']}
						{/if}
					</div>
				</div>

				{********************** FILES ***********************************}
				<div class="files">
					<div class="title">
						<span>{$absLang['fileLabel']}</span>
					</div>


					{***************************** FILTERS ****************************************}
					<div class="filters">
						<form id="formFilters" class="form" method="post" action="" onSubmit="$(this).fire('form:doSubmit'); return false;">
							<table>
								<tr class="simpleFilters visible">
									<td class="value">
										<input class="inputElement" type="text" name="filters[filename]" placeholder="{$absLang['filtersFileName']}" value="{$autoOpenFileName}"></input>

										{block name="fileParsed"}
											<select name="filters[fileParsed]">
												<option value="all">{$absLang['filtersFileParsed']['options']['all']}</option>
												<option value="yes">{$absLang['filtersFileParsed']['options']['yes']}</option>
												<option value="no">{$absLang['filtersFileParsed']['options']['no']}</option>
												<option value="content:match">{$absLang['filtersFileParsed']['options']['content:match']}</option>
											</select>
										{/block}
									</td>
									<td class="button">
										<button type="button">{$absLang['submitFilters']}</button>
									</td>
								</tr>

								<tr class="advancedFilters hidden">
									<td class="value">
										<textarea name="filters[advanced]"></textarea>
									</td>
									<td class="button">
										<button type="button">{$absLang['submitFilters']}</button>
									</td>
								</tr>
							</table>
						</form>
					</div>

					<div class="browser">
						{if $autoOpen}
							{$folderPath = $autoOpenPaths|end}
							{render action='displayFilesPaginated' params=['folderPath'=>$folderPath, 'resultsPerPage' => $resultsPerPage, 'autoOpen'=>$autoOpen, 'filters'=>['filename' => $autoOpenFileName]]}
						{else}
							{$folderPath = '/'}
							{render action='displayFilesPaginated' params=['folderPath'=>'/', 'resultsPerPage' => $resultsPerPage]}
						{/if}
					</div>
				</div>
			</div>

			<div id="fileDetailsContainer" class="layoutStandard">
				<div class="fileDetails">
					{if $autoOpen}
						{render action='displayHumanReadableFile' params=['filePath' =>$autoOpen, 'autoOpen'=>$autoOpen]}
					{/if}
				</div>
			</div>
		{/block}
	</div>
{/block}

{block name="js" append}
	<script type="text/javascript">
		MVC.scheduleOnLoad(function(){
			importedOrdersFileManager = new _importedOrdersFileManager({
				'resultsPerPage': "{$resultsPerPage|json_encode}",
				'currentPage': "{$currentPage|json_encode}"
			});
			importedOrdersFileManager.initialize();
			importedOrdersFileManager.resizeFilesListPaginated();
			importedOrdersFileManager.resizeFileDetailsContainer();
		});
	</script>
{/block}
