{extends file=$smarty.const.SMARTY_LAYOUT_MAIN_POPUP_FORM}


{block name="buttons"}
	<div class="buttons layout-M-M-M-M">
		{if $form}

			<button type="button" id="back"
				onclick="window.location = MVC.appUrl('Documents/Generate/', 'index', { 'pivot': '{$pivot}', 'idPivot': '{$idPivot}' } );"
			>{$lang['index']['buttons']['back']}</button>

			<button type="button" id="preview" class="button-popupSubmit" data-postAction='preview'>{$lang['index']['buttons']['preview']}</button>

			<button type="button" id="ok" class="button-popupSubmit" data-postAction='generate'>{$lang['index']['buttons']['generate']}</button>

			<button type="button" id="print" class="button-popupSubmit" data-postAction='print'>{$lang['index']['buttons']['print']}</button>
		{/if}
	</div>
{/block}

{block name="js" append}
	<script type='text/javascript'>
		MVC.scheduleOnLoad(function() {
			$$('div.buttons').first().on('click', 'button.button-popupSubmit', function(evt, elm) {
				var element = evt.element;
				var form = $('{$form->getId()}');
				form.down('#postAction').value = elm.readAttribute('data-postAction');
				form.fire('form:doSubmit');
			});
		});
	</script>
{/block}

