<?php
/*
 **************************************************************************************************
 *    Copyright (c) 2010-2012 Just Another Video script
 *
 * 	  This file is part of Just Another Video Script.
 *    Version 1.4.3
 *    info@justanothervideoscript.com
 **************************************************************************************************
 *    Come to website for support or buying additional plugins/modules.
 *    http://justanothervideoscript.com/
 **************************************************************************************************
 *    By using this software you agree that you have read and acknowledged our End-User License
 *    Agreement available at http://justanothervideoscript.com/license and can be bound by it.
 **********************************************************************************
 */
include_once("adminfunctions.inc");

$db->query("SELECT * FROM category ORDER BY id") ;
$flag = $db->fetchALL() ;
$output = '';


foreach($flag as $value) {
	$catname = str_replace(' ', '-', $value['name']);
	if (file_exists($rootpath.'uploads/category/'.$catname.'.jpg')) {
		$thumb = "<img src='".$sitepath."uploads/category/".$catname.".jpg' width='80px' height='113px'>" ;	
	} else {
		$thumb = "<img src='".$templateimagepath."defaultcat.jpg' width='80px' height='113px'>" ;
	}

	$db->query("SELECT * FROM media WHERE category = '".$value['id']."'") ;
	$videonum = $db->numRows() ;
			

$output .= '<tr class="listingtableheader" id="listingtableheader'.$value['id'].'"><th>'.$value['id'].'</th><th>Name: '.$value['name'].'<br>Num of videos: '.$videonum.'</th><th>'.$thumb.'</th>
		<th class="actions">
			<input type="submit" class="thumbupload" id="cat_thumb'.$value['id'].'" title="Upload category Thumb" value="">
			<input type="submit" class="edit" id="cat_edit'.$value['id'].'" title="Edit category " value="">
			<input type="submit" class="delete" id="cat_delete'.$value['id'].'" title="Delete category" value="">
		</th></tr>';

}


?>
<h2>Categories</h2>

<div class="settings">
	<fieldset>
		<form action="" method="post" enctype="multipart/form-data">
		<table>
		
			<tr>	
				<td><input class="submitbutton" id="cat_add" type="submit" name="submit" value="New Category" /></td>
			</tr>
		
			<tr>
				<td><b>ID:</b></td>
				<td><b>Category info:</b></td>
				<td><b>Cat thumb:</b></td>
				<td><b>Actions:</b></td>
			</tr>
			
			<?=$output ?>

		</table>
		</form>

	</fieldset>
</div>	



