{extends file=$smarty.const.SMARTY_LAYOUT_MAIN_WINDOW}

{block name="template-head" append}
	{$JS->loadGroup("inputs")}
	{$CSS->loadGroup("inputs")}
{/block}

{block name="css"}
	{$CSS->load("{asset path="_css/index.css"}")}
{/block}

{block name="content"}
	{block name="statusDetails"}
		<div class="statusDetails">
			<fieldset>
				<legend>
					<b>{$lang['index']['fieldset']['statusDetails']}</b>
				</legend>

				<div>
					{$lang['index']['field']['status']}: <b> {$status} </b>
				</div>
				{if $status == "blocked"}
					<div>
						{$lang['index']['field']['blockedUntil']}: <b> {$blockedUntil|dateTimeFormat:'dateWithHMS'} </b>
					</div>
					<div>
						{$lang['index']['field']['blockingApp']}: <b> {$blockingApp} </b>
					</div>
				{/if}
				<div>
					{$lang['index']['field']['transCount1']}: <b> {$transactionsCountMainQueue} </b>
				</div>
				<div>
					{$lang['index']['field']['transCount2']}: <b> {$transactionsCountFastQueue} </b>
				</div>
				<div>
					{$lang['index']['field']['oldestTransactionDateTime']}: <b> {$oldestTransactionDateTime|dateTimeFormat:'dateWithHMS'|default:'-'} </b>
				</div>
			</fieldset>
		</div>
	{/block}
	<br />
	{block name="stopStart"}
		<div class="stopStart">
			<fieldset>
				<label class="reportsDataDescription">
					{$lang['index']['description']['stop']['firstPart']}
					<br />
					{$lang['index']['description']['stop']['secondPart']}
				</label>
				<br> 
				{if $status == "stopped"}
					<button class="reportsDatabtn" type="button" id="startReportsDataCron" >{$lang['index']['buttons']['start']}</button>
				{else}
					<button class="reportsDatabtn" type="button" id="stopReportsDataCron">{$lang['index']['buttons']['stop']}</button>
				{/if}
			</fieldset>
		</div>
	{/block}
	<br>
	{block name="disable"}
		<div class="disable">
			<fieldset>
				<label class="reportsDataDescription">
					{$lang['index']['description']['disable']['firstPart']}
					<br />
					{$lang['index']['description']['disable']['secondPart']}
				</label>
				<br>
				{if $status == "disabled"}
					<button class="reportsDatabtn" onclick="Popup2.create().setId('enableRD').setUrl(MVC.appUrl('Admin/ReportsDataStatus/Disable', 'index', { 'operation': 'enable' })).setDimensions(500, 300).show();">{$lang['index']['buttons']['enable']}</button>
				{else}
					<button class="reportsDatabtn" onclick="Popup2.create().setId('disableRD').setUrl(MVC.appUrl('Admin/ReportsDataStatus/Disable', 'index', { 'operation': 'disable' })).setDimensions(530, 300).show();">{$lang['index']['buttons']['disable']}</button>
				{/if}
			</fieldset>
		</div>
	{/block}
	
	{block name="resync"}
		<div class="resync">
			<fieldset>
				<label class="reportsDataDescription">
					{$lang['index']['description']['resync']['firstPart']}
					<br />
					{$lang['index']['description']['resync']['secondPart']}
				</label>
				<br>
				<button class="reportsDatabtn" onclick="Popup2.create().setId('resyncRD').setUrl(MVC.appUrl('Admin/ReportsDataStatus/Resync', 'index')).setDimensions(750, 500).show();">{$lang['index']['buttons']['resync']}</button>
			</fieldset>
		</div>
	{/block}
{/block}


{block name="js" append}
	<script type="text/javascript">
		MVC.scheduleOnLoad(function(){
			if (document.getElementById('stopReportsDataCron')) { 
				document.getElementById('stopReportsDataCron').observe('click', function() {
					(new _alertConfirm())
					.setContent("{$_LANG['Admin']['ReportsDataStatus']['stop']['confirm']}")
					.onAccept(function() { document.location = MVC.appUrl('Admin/ReportsDataStatus', 'stop'); } )
					.show()
					.fadeBackground()
				});
			}
			
			if (document.getElementById('startReportsDataCron')) { 
				document.getElementById('startReportsDataCron').observe('click', function() {
					(new _alertConfirm())
					.setContent("{$_LANG['Admin']['ReportsDataStatus']['start']['confirm']}")
					.onAccept(function() { document.location = MVC.appUrl('Admin/ReportsDataStatus', 'start'); } )
					.show()
					.fadeBackground()
				});
			}
		});
	</script>
{/block}

