<?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 = "DELETE FROM hd_countries WHERE id='".$id."'";
	}elseif ($_REQUEST['w']=="S") {
		$query = "DELETE FROM hd_countries_states WHERE id='".$id."'";
	}



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



}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%">
';
	print(ucfirst(_COUNTRIES)." > ".ucfirst(_STATES));
echo '
		</td>
		</tr>
';	
echo '
			<tr valign="top">
				<td>

';



	/////////////// clientes en el pais o estado

	if ($_REQUEST['w']=="C") {
		$where = "WHERE country = '".$id."'";
	}elseif ($_REQUEST['w']=="S") {
		$where = "WHERE state = '".$id."'";
	}

	if ($_REQUEST['w']) {
		$query="SELECT clientid, first, last, company FROM hd_clients $where ORDER BY last, first";
		$result=mysql_query($query,$db_link);
		$bgc=true;
		$i = 0;
		print("<table>");
		print("<tr><th colspan='3'>".ucfirst(_CLIENTS)." ".strtolower(_IN)." ".$_REQUEST['text']."</th></tr>");
		while($row = mysql_fetch_array($result)) 	{
			print("<tr><TD><a href='".$serverurl."/tickets.php?clientid=$row[clientid]'>$row[clientid]</a></TD>");
			print("<TD nowrap><a href='".$serverurl."/tickets.php?clientid=$row[clientid]'>$row[last], $row[first]</a></TD>");
			print("<TD>$row[company]</TD>");
			print("</tr>");
			$i++;
		}
		print("</table>");
	}
	if ($i==0) {
		print(""._NONE."");
	}
	////////////////////////////////
	print("<br><br><br><br><table cellspacing='0' cellpadding='0' border='0'><tr>");

	if ($i==0) {
		redbutton("countries_del.php?id=$id&w=$w&choice=yes",_DELETE." ".$_REQUEST['text']);
	}
	yellowbutton("countries.php",_RETURN);

	print("</tr></table>");

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

}



?>