<?php 
$total = $z->select("SELECT COUNT(ID) as total FROM tracks WHERE status=?", array("yes"), "s")->row->total; 
$start = 0; $limit = 50;
if(isset($_GET['start'])){ 
	$ostart = $_GET['start'];
	$start = $limit * $ostart - $limit;	
}
$list = $z->select("SELECT * FROM tracks WHERE status=? ORDER BY ID DESC LIMIT ?,?", array("yes",$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>Tracks</li>
</ul>
<h2 class="size24 fontl cfff titleb">Tracks <span class="que-count">(<?php echo number_format($total); ?>)</span><?php echo $pageLabel; ?></h2>
<a href="<?php echo baseurl; ?>admin/upload" class="noul size14 fontn cfff abs anim bnp-new"><div class="ibl icon-plus ico"></div>Upload Track</a>

<?php if($list->count > 0 && $list->result=="ok"){
	echo '<ol class="trackList ibl">';
	for($n = 0; $n < count($list->fetch); $n++):
		echo $z->trackItemAdmin($list->fetch[$n]);
	endfor;
	echo '</ol>';
	$pagin = '<ol class="pages ibl">';
	$fresh_start = isset($_GET['start']) ? $_GET['start'] : 1;	
	$next = $fresh_start+1;
	$prev = $fresh_start-1;
	$prevlink = baseurl.'admin/tracks/p'.$prev;
	$link_first = baseurl.'admin/tracks';
	$nextlink = baseurl.'admin/tracks/p'.$next;
	$link_last = baseurl.'admin/tracks/p'.ceil($total/$limit); 
	$link_i = baseurl.'admin/tracks/p';
	$pagin .= $z->pagination($total, $limit, $start, $fresh_start, $link_first, $prevlink, $prev, $next, $nextlink, $link_last, $link_i, '');		
	$pagin .= '</ol>';
	echo $pagin;
}else{ 
	echo '<div class="emptyTracks rel size40 cfff fontl"><div class="icon-puzzle ico"></div>You haven\'t uploaded any track yet..</div>';
} ?>