<?php 
$total = $z->select("SELECT COUNT(ID) as total FROM servers WHERE status!=?", array("no"), "s")->row->total; 
$start = 0; $limit = 50;
if(isset($_GET['start'])){ 
	$ostart = $_GET['start'];
	$start = $limit * $ostart - $limit;	
}
$list = $z->select("SELECT * FROM servers WHERE status!=? ORDER BY ID DESC LIMIT ?,?", array("no",$start,$limit), "sss");
$pageLabel = isset($_GET['start']) && $_GET['start'] > 1 ? ' &ndash; Page '.$_GET['start'] : '';
?>
<ul class="ibl dashnav size18 fontl">
	<li><a href="<?php echo baseurl; ?>admin/dashboard" class="noul noulh">Dashboard</a></li>
	<li class="ibl aro">&rsaquo;</li>
	<li>Servers</li>
</ul>
<h2 class="size24 fontl cfff titleb">Data Servers <span class="que-count">(<?php echo number_format($total); ?>)</span><?php echo $pageLabel; ?></h2>
<button class="size14 fontn cfff abs anim bnp-new addNewServer"><div class="ibl icon-plus ico"></div>Add Server</button>

<ol class="serverList">
	<li class="rel head fontb size11">
		<div class="ibl stat col"></div>
		<div class="ibl nam col">Name</div>
		<div class="ibl added col">Modified</div>
		<div class="ibl disk col">Disk Space</div>		
		<div class="ibl acts col"></div>
	</li>
	<?php 
		for($n = 0; $n < count($list->fetch); $n++){
			$ID = $hash->encode($list->fetch[$n]->ID);
			$diskTotal = $z->formatSize($list->fetch[$n]->tspace);
			$diskLeft = $list->fetch[$n]->bspace == 0 ? '0 Byte' : $z->formatSize($list->fetch[$n]->bspace);
			$diskPercent = $list->fetch[$n]->bspace == 0 ? '0' : ($list->fetch[$n]->bspace / $list->fetch[$n]->tspace) * 100; //(($diskTotal - $diskLeft) / $diskTotal) * 100;
			echo '<li class="rel val server'.$ID.' fontb size11">
				
				<div class="ibl stat col"><div class="sts ibl sts-'.$list->fetch[$n]->status.'" title="'.ucfirst($list->fetch[$n]->status).'"></div></div>
				<div class="ibl nam col">
					<h2 class="wordwrap lbl fontb cfff size14">'.stripslashes($list->fetch[$n]->title).'</h2>
					<h2 class="wordwrap c999 addr size13 fontn">'.stripslashes($list->fetch[$n]->address).'</h2>					
				</div>
				<div class="ibl added col">'.date("d M Y", $list->fetch[$n]->added).'</div>
				<div class="ibl disk col">
					<span class="current">'.$diskLeft.' of '.$diskTotal.'</span>
					<div class="rog rel"><div class="res" style="width: '.$diskPercent.'%"></div></div>
				</div>		
				<div class="ibl acts col">';
					if($list->fetch[$n]->locked!='yes'){
						$tspace = (($list->fetch[$n]->tspace / 1024) / 1024) / 1024;
						echo '<a href="javascript:;" class="editServer size12 fontn noul noulh" '
						. 'data-title="'.stripslashes($list->fetch[$n]->title).'" '
						. 'data-address="'.stripslashes($list->fetch[$n]->address).'" '
						. 'data-space="'.$tspace.'" '
						. 'data-status="'.$list->fetch[$n]->status.'" '
						. 'data-id="'.$ID.'">Edit</a>
						&nbsp;&#46;&nbsp;
						<a href="javascript:;" class="rmServer size12 fontn noul noulh" data-id="'.$ID.'">Delete</a>';
					}
				echo '</div><div class="abs covr cover'.$ID.'"></div></li>';
		}
	?>
</ol>