<div id="primary_header">
	<h1>Account Profile</h1>
</div>

<div id="primary_content">
    <div id="primary_content_inner">

        <?php if(isset($this->expiryMsg)): ?>
        <div class="warning"><?php echo $this->expiryMsg ?></div>
        <?php endif; ?>

		<form id="settingsForm" method="post" action="<?php echo $this->appBaseUrl; ?>/admin/appliance/serversmtpsettings">

		<table class="settings">

			<tr>
				<td class="label"><?php echo $this->translate('Account Username') ?></td>
				<td><?php echo $this->userData['Username']; ?></td>
			</tr>

			<tr>
				<td class="label"><?php echo $this->translate('Administrator Full Name') ?></td>
				<td><?php echo $this->userData['Fullname'] ?></td>
			</tr>

			<tr>
				<td class="label"><?php echo $this->translate('Company Name') ?></td>
				<td><?php echo $this->userData['Company'] ?></td>
			</tr>


		</table>

		<div class="divider"></div>

		<table class="settings">

			<tr class="heading">
				<td class="label"><?php echo $this->translate('Graph Summary') ?></td>
				<td><small><?php echo $this->translate('Snapshot of recent activity for logins and email messages received') ?></small></td>
			</tr>

			<tr>
				<td class="label"><?php echo $this->translate('Login Activity') ?></td>
				<td>
					
					<div class='statBlock'>
						<div id="loginGraphTotalSubadmin" class='statGraphSmall' logtype=''></div>
					</div>					
					
				</td>
			</tr>

			<tr>
				<td class="label"><?php echo $this->translate('Received Messages') ?></td>
				<td>
					
					<div class='statBlock'>
						<div id="recvGraphTotalSubadmin" class='statGraphSmall' logtype=''></div>
					</div>
					
				</td>
			</tr>

		</table>

		<div class="divider"></div>

		<table class="settings">

			<!-- Disk usage heading -->
			<tr class="heading">
				<td class="label"><?php echo $this->translate('Disk Quota Usage') ?></td>
				<td><small><?php echo $this->translate('The amount of disk space allocated for user accounts') ?></small></td>
			</tr>

			<tr>
				<td class="label"><?php echo $this->translate('Disk Space Allocated') ?></td>
				<td><?php echo ($this->userData['NumQuota'] != 0 ? $this->userData['NumQuota'] . " " . $this->translate('MB') : $this->translate('Unlimited')); ?></td>
			</tr>

			<tr>
				<td class="label"><?php echo $this->translate('User Disk Space Allocated') ?></td>
				<td><?php echo $this->currentQuota; ?> <?php echo $this->translate('MB') ?></td>
			</tr>

			<?php if($this->userData['NumQuota'] != 0) :?>

			<tr>
				<td class="label"><?php echo $this->translate('Disk space Remaining') ?></td>
				<td><?php echo $this->availQuota; ?> <?php echo $this->translate('MB') ?></td>
			</tr>

			<tr>
				<td class="label"><?php echo $this->translate('Percentage Used') ?></td>
				<td>
					<div class='statTable'>
					<table border="0" cellspacing="0" cellpadding="0" height='26' class='statContent'>
					<tr>
						<td class='used' width="<?php echo ($this->usedDiskPercentage==0?'1':$this->usedDiskPercentage) ?>%">
<?php //if < 30% then show the text in the 'avail' td, else in the 'used' td ?>
<?php						if( $this->usedDiskPercentage >= 30 ) : ?>
							<span class='statData'><?php echo $this->usedDiskPercentage ?>% <?php echo $this->translate('Used') ?></span>
<?php						endif ?>							
						</td>
<?php 						if( $this->usedDiskPercentage != '100') :?>
						<td class='avail'>
<?php 							if( $this->usedDiskPercentage < 30 ) : ?>
							<span class='statData'><?php echo $this->usedDiskPercentage ?>% <?php echo $this->translate('Used') ?></span>
<?php 							endif ?>								
						</td>
<?php 						endif ?>
					</tr>
					</table>	
					</div>
					
				</td>
			</tr>
			<?php endif ?>

			</table>
			
			<!-- divider -->
			<div class="divider"></div>
			
			<table class="settings">
			<!-- mem usage header -->
			<tr class="heading">
				<td class="label"><?php echo $this->translate('User Quota') ?></td>
				<td><small><?php echo $this->translate('Find the number of accounts used on the system and user quota remaining') ?></small></td>
			</tr>

			<?php if($this->userData['NumUsers'] == '16777215') :?>
			<tr>
				<td class="label"><?php echo $this->translate('Total Users') ?></td>
				<td><?php echo $this->translate('Unlimited') ?></td>
			</tr>

			<tr>
				<td class="label"><?php echo $this->translate('Users Used') ?></td>
				<td><?php echo $this->activeUsers ?> <?php echo $this->translate('users') ?></td>
			</tr>
				
			<?php else :?>
			<tr>
				<td class="label"><?php echo $this->translate('Total Users') ?></td>
				<td><?php echo $this->userData['NumUsers']; ?> <?php echo $this->translate('users') ?></td>
			</tr>

			<tr>
				<td class="label"><?php echo $this->translate('Users Used') ?></td>
				<td><?php echo $this->activeUsers ?> <?php echo $this->translate('users') ?></td>
			</tr>

			<tr>
				<td class="label"><?php echo $this->translate('Users Available') ?></td>
				<td><?php echo $this->availUsers ?> <?php echo $this->translate('users') ?></td>
			</tr>
			
			<tr>
				<td class="label"><?php echo $this->translate('Percentage Used') ?></td>
				<td>
					<div class='statTable'>
					<table border="0" cellspacing="0" cellpadding="0" height='26' class='statContent'>
						<tr>
							<td class='used' width="<?php echo ($this->usedUserPercentage==0?'1':$this->usedUserPercentage) ?>%">
<?php //if < 30% then show the text in the 'avail' td, else in the 'used' td ?>
<?php						if( $this->usedUserPercentage >= 30 ) : ?>
								<span class='statData'><?php echo $this->usedUserPercentage ?>% <?php echo $this->translate('Used') ?></span>
<?php						endif ?>							
							</td>
<?php 						if( $this->usedUserPercentage != '100') :?>
							<td class='avail' width="<?php echo $this->availUserPercentage; ?>%">
<?php 							if( $this->usedUserPercentage < 30 ) : ?>
								<span class='statData'><?php echo $this->usedUserPercentage ?>% <?php echo $this->translate('Used') ?></span>
<?php 							endif ?>								
							</td>
<?php 						endif ?>
					</tr>
					</table>	
					</div>
				</td>
			</tr>
			<?php endif ?>
			
			</table>

		</form>
		</div>


		</div>

<script type="text/javascript">
$(function() {
    $('#subadminGraph .statGraph,.statGraphSmall').html("<div id='loading' style='top: 50%; position: relative;left: 50%;'><h1 class='loading-text'><img class='loadingimg' src='<?php echo $this->siteBaseUrl; ?>images/25.gif' width='28' height='28'/><span class='loading'><?php echo $this->translate('Loading...')?></span></h1></div>");


    // Launch an ajax query for each graph
	$('#subadminGraph .statGraphSmall').each(function(n){
		var myid = this.id;
		var myrecord = this;
		var data = [];
		//$.plot($(this), data, optionsSmall);

		var url;
		
		if(myid == 'recvGraphTotalSubadmin')
		url = "<?php echo $this->moduleBaseUrl ?>/graph/json/view/month/log/Log_RecvMail/compact/1/type/" + $(this).attr('logtype');
		else
		url = "<?php echo $this->moduleBaseUrl ?>/graph/json/view/month/log/Log_Login/compact/1/type/" + $(this).attr('logtype');
		
		$.ajax({
            url: url,
            method: 'GET',
            dataType: 'json',
            success: function(graphdata, type) {
			onDataReceivedSmall2(graphdata, myid, 1	 );
				}
        });

		// Now, bind when the user clicks!
		$(myrecord).bind('click', function() {
			if(myid == 'recvGraphTotalSubadmin')
			$("#secondary", "#Dashboard").tabs('select', 2);
			else
			$("#secondary", "#Dashboard").tabs('select', 1);
			
		});

	});
	
    // bind to the form's submit event and cancel legacy submit 
    $('#settingsForm').submit(function() {              
		if( $("#settingsForm").attr("action") == false ) {
			alert('Form submission aborted: Action must be set');
			return false;
		}
	 	$.php($("#settingsForm").attr("action"),$("#settingsForm").serializeArray());
        return false; 
    });

});

</script>
