{extends file=$smarty.const.SMARTY_LAYOUT_MAIN_POPUP_FORM}

{block name="template-head" append}
	{$JS->load("{asset path="_js/offerStuff.js"}")}
	{$JS->load("{asset path="_js/utils.js"}")}
{/block}

{block name="js" append}
	<script language="javascript">

		// after customer/corporate insert - fill the autocomplete field
		MVC.pageRefresh = function (module, action, windowName, execOutput) {

			if (module=='Partners/Customers' && windowName=='customerInsert' && execOutput['psgIdx']!=null) {
				$('importedPassenger_'+execOutput['psgIdx']+'__title_').value = execOutput['name'];
				$('importedPassenger_'+execOutput['psgIdx']+'_').value = execOutput['id'];
			}

			if (module=='Partners/Corporates' && windowName=='corporateInsert' && execOutput['corpIdx']!=null) {
				$('importedCorporate_'+execOutput['corpIdx']+'__title_').value = execOutput['name'];
				$('importedCorporate_'+execOutput['corpIdx']+'_').value = execOutput['id'];
			}
		}

		{* auto-submit the form *}
		{if $autoSubmit}
			$('serviceForm').submit();
		{/if}

	</script>
{/block}


{block name="buttons"}
	<div class="buttons {if $idImportedService and !$idOrder}layout-S-L-L{elseif $idImportedService and $idOrder}layout-S-L{elseif $idImportedService and !$idOrder}layout-S-L{else}layout-L{/if}">
		{if $form}
			{if $idImportedService}
				<button class="button-back" type="button"
					onclick="window.location = MVC.appUrl('Orders/ImportedOrders/ProcessServicesList', 'index', { 'idOrder': '{$idOrder}'});">{$_LANG['back']}</button>
			{/if}

			{$form->renderButton('insert')}
		{/if}
	</div>
{/block}


