<?php


include("../include/config.php");
include_once("../include/functions/import.php");
include_once("../include/functions/admin.php");
verify_login_admin();
        
		
if($_REQUEST['update'] == "success")
{
	$message = "Series Successfully Deleted";
	Stemplate::assign('message',$message);
	STemplate::display("administrator/show_message.tpl");
}

// DELETE BEGIN
if($_REQUEST[delete]=="true")
{
	$SID = $_REQUEST['SID'];
	if (is_numeric($SID))
	{

		$sql="DELETE FROM videos_series WHERE SID='".mysql_real_escape_string($SID)."'";
		$conn->Execute($sql);
		$sql="UPDATE videos SET SID='0' WHERE SID='".mysql_real_escape_string($SID)."'";
		$conn->Execute($sql);
		header("location: listseries.php?update=success");
	}
}
// DELETE END

// SORT BEGIN
if($_REQUEST['sortby']=="name")
{
	$sort =" order by name";
}
elseif($_REQUEST['sortby']=="description")
{
	$sort =" order by description";
}
else
{
	$sort =" order by SID";
}

if($_REQUEST['sorthow']=="desc")
{
	$sorthow ="desc";
}
else
{
	$sorthow ="asc";
}
// SORT END

$query="SELECT * FROM videos_series $sort $sorthow";
$executequery = $conn->Execute($query);
$total = $executequery->recordcount()+0;
$series = $executequery->getrows();

STemplate::assign('total',$total+0);
STemplate::assign('series',$series);

Stemplate::assign('error',$error);
STemplate::display("administrator/listseries.tpl");
?>