<?php
include("postget.php");
include_once("common.php");
checklevel(4,$_REQUEST['clientid']);
if(!$id){print("No Period Specified.");exit();}
if($choice=='yes') {
	///////////////////////////// colocar como dept 0 (todos) las canned que tienen este dept.
	$query = "UPDATE hd_tickets_canned SET dept = '0' WHERE dept ='".$id."'";
	$result = mysql_query ($query);

	$query = "SELECT * FROM hd_tickets_dep WHERE depid='".$id."'";
	$result = mysql_query ($query);
	$data = mysql_fetch_array ($result);
	$order = $data['orderby'];
	$query = "UPDATE hd_tickets_dep SET orderby = orderby-1 WHERE orderby >'".$order."'";
	$result = mysql_query ($query);
	$query = "DELETE FROM hd_tickets_dep WHERE depid='".$id."'";
	if(!mysql_query($query,$db_link)){
		messagetop(_ERROR,mysql_error(),'departments.php',0); 
	}else{
		messagetop(_THE_CHANGES_WHERE_MADE_SUCCESSFULLY,'','departments.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(_DEPARTMENTS);
echo '
		</td>
		</tr>
';	
echo '
			<tr valign="top">
				<td>

';


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

	print("<br><table cellspacing='0' cellpadding='0' border='0'><tr>");

	redbutton("departments3.php?id=".$id."&choice=yes",_DELETE);
	yellowbutton("departments.php",_RETURN);
	
	print("</tr></table>");

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

?>