<?php
include("postget.php");
include_once("common.php");
checklevel(4,$_REQUEST['clientid']);
if(!$id){print("No id Specified.");exit();}
if($choice=='yes')
{
	if ($_REQUEST['w']=="C") {
		$query = "SELECT * FROM hd_manuals_manuals WHERE id='".$id."'";
		$result = mysql_query ($query);
		$data = mysql_fetch_array ($result);
		$order = $data['position'];
		$query = "UPDATE hd_manuals_manuals SET position = position-1 WHERE position >'".$order."' AND langs LIKE '%".$currentlang."%'";
		$result = mysql_query ($query);
		$query = "DELETE FROM hd_manuals_manuals WHERE id='".$id."'";
	
	}elseif ($_REQUEST['w']=="S") {
		$query = "SELECT * FROM hd_manuals_chapters WHERE id='".$id."'";
		$result = mysql_query ($query);
		$data = mysql_fetch_array ($result);
		$order = $data['position'];
		$query = "UPDATE hd_manuals_chapters SET position = position-1 WHERE position >'".$order."' AND category = '".$data['category']."' AND langs LIKE '%".$currentlang."%'";
		$result = mysql_query ($query);
		$query = "DELETE FROM hd_manuals_chapters WHERE id='".$id."'";
	
	}elseif ($_REQUEST['w']=="I") {
		$query = "SELECT * FROM hd_manuals_pages WHERE id='".$id."'";
		$result = mysql_query ($query);
		$data = mysql_fetch_array ($result);
		$order = $data['position'];
		$query = "UPDATE hd_manuals_pages SET position = position-1 WHERE position >'".$order."' AND category = '".$data['category']."' AND subcategory = '".$data['subcategory']."' AND langs LIKE '%".$currentlang."%'";
		$result = mysql_query ($query);
		$query = "DELETE FROM hd_manuals_pages WHERE id='".$id."'";
	}



	if(!mysql_query($query,$db_link)){
		messagetop(_ERROR,mysql_error(),'manuals_ad.php',0); 
	}else{
		messagetop(_THE_CHANGES_WHERE_MADE_SUCCESSFULLY,'','manuals_ad.php',1);
	}

}else{
	
	include("head_template.php");
	echo '
<div class="container">
	<div class="row">


<table width="98%" class="table table-bordered">
		<tr>
		<td align="center" width="100%">
';
	echo ucfirst(_MANUALS);
echo '
		</td>
		</tr>
';	
echo '
			<tr valign="top">
				<td>

';


	print("<h2>"._DELETE." '".$_REQUEST['text']."'?</h2><br>");


	print("<br><table cellspacing='0' cellpadding='0' border='0'><tr>");
	redbutton("manuals_del.php?id=".$id."&w=".$w."&choice=yes",_DELETE);
	yellowbutton("manuals_ad.php",_RETURN);
	print("</tr></table>");

echo '
		</td>
		</tr>
		</table>
</div>
</div>
';
	include("foot_template.php");
}

?>