<div id="primary_header">
	<h1><?php print $this->translate('Serial Details')?></h1>
</div>

<div id="primary_content">
	<div id="primary_content_inner">
		<div id="Flash" class="flash_notice"><?php print $this->translate('The settings have been updated') ?></div>

<?php 	if( license::le() ) : ?>
		<div id="licence-error"><img class="regerror" src="<?php echo $this->siteBaseUrl; ?>images/icons/error.png"/><span>Your Atmail license is either not registered or invalid. Use the "Register Serial" button to the left to enter your details</span></div>
<?php 	elseif( $this->global['demo'] == 1 ) : ?>
		<div id="licence-error"><img class="regerror" src="<?php echo $this->siteBaseUrl; ?>images/icons/error.png"/><span>Demo Webadmin version of Atmail - Copy for evaluation use only</span></div>
<?php 	else : ?>
<?php 		if($this->licenseExpired ==1) 
				include('expiry.phtml'); 
?>
		<style type="text/css">
		table.settings.licenses { margin: 0 0 0 43px; width: auto; }
		table.settings.licenses thead td { width: auto; padding: 8px; }
		table.settings.licenses tbody tr:nth-child(odd) { background: #eeeeee; }
		table.settings.licenses tbody td { text-align: right; padding: 8px; }
		table.settings.licenses .buttonLicenseDelete { cursor: pointer; }
		table.settings.licenses .ok { background: #E2F9E3 url(<?php echo Zend_Registry::get('siteBaseUrl'); ?>images/alert-tick.gif) no-repeat scroll 10px 10px; }
		table.settings.licenses .expired { background: #F9E2E2 url(<?php echo Zend_Registry::get('siteBaseUrl'); ?>images/alert-cross.gif) no-repeat scroll 21px 10px; border-color :#CC9999; color: #ED2C2C; padding-left: 40px;}
		</style>
		<table class="settings">
			<tr>
				<td class="label"><?php print $this->translate('Software Product')?></td>
				<td>
					<strong><?php echo ($this->global['install_type'] == 'server') ? 'Atmail Server Edition' : 'Atmail Webmail Client' ?></strong>
				</td>
			</tr>
		</table>
		<table class="settings licenses">
			<thead>
				<tr>
					<td class="label"><?php echo $this->translate("Serial"); ?></td>
					<td class="label"><?php echo $this->translate("Expiry Date"); ?></td>
					<td class="label"><?php echo $this->translate("Serial Type"); ?></td>
					<td class="label"><?php echo $this->translate("Users"); ?></td>
					<td class="label"><?php echo $this->translate("Users Total"); ?></td>
					<td class="label"><?php echo $this->translate("Users Used"); ?></td>
					<td class="label"><?php echo $this->translate("Users Available"); ?></td>
					<td class="label"><?php echo $this->translate("Status"); ?></td>
					<td class="label"><?php echo $this->translate("Action"); ?></td>
				<tr>
			</thead>
			<tbody>
            <?php echo license::details(); ?>
			</tbody>
		</table>
		
<?php 	endif ?>
	</div>
	<script type="text/javascript">
	$(function() 
	{
		
		$('.buttonLicenseDelete', '#License').bind('click', function() 
		{
			if( confirm('Are you sure you want to delete this license.') )
			{

				var _that = this
				$.ajax({
					url: "<?php echo $this->moduleBaseUrl ?>/license/delete/",
					method: 'POST',
					dataType: 'json',
					data: { 'serialKey' : $(this).attr('serialKey') }, 
					success: function(data) 
					{

						if( data.success != undefined && data.success === true )
						{

							$(_that).parent().parent().fadeOut(500, function() 
							{ 

								$(this).remove(); 
								if( $(".expired", ".licenses").length == 0 )
									$('#licence-error', '#details').hide();

							})

						}
						else
							alert('Failed deleting license.')
							
					}
		        });

			}	

		});
		$("BODY").addClass('no_actions');
		$("#search_anything").hide();
		$(".licenses tr:not(:first)").find('td:last').css({'color':'red'})
	});
	</script>
</div>
