<?php
include("postget.php");
include_once("common.php");
$pagetitle = _COUNTRIES;

checklevel(4,$_REQUEST['clientid']);


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


graybutton("countries_C.php",_ADD_COUNTRY);

graybutton("countries_S.php",_ADD_STATE);


print("<table class='table table-striped'><tr><thead>

	<th>".ucfirst(_COUNTRIES)." / ".ucfirst(_STATES)."</th> 
	<th width='1%'>".ucfirst(_PHONE_CODE)."</th>
	<th width='1%'>".ucfirst(_OPTIONS)."</th>
	</tr></thead><tbody>");


$cat = query("SELECT * FROM hd_countries ORDER by country",0);
while($rowC=mysql_fetch_array($cat)) {
	print("<tr class='row1'>");
	print("<td> ");
	bandera($rowC['countrycode']);
	print(" <b>
	<a href='".$PHP_SELF."?c=".$rowC[id]."#".$rowC[id]."'>".ucfirst($rowC[country])."</a>
	<a name='".$rowC[id]."' id='".$rowC[id]."'></a> (".strtoupper($rowC[countrycode]).") 
	</b> </td>");
	print("<td align='center'>".$rowC[phonecode]."</td>");
	print("<td align='center'>");
	print("<a href='".$serverurl."/countries_C.php?id=$rowC[id]'><img class='sprites edit' src='images/transparent.gif' border='0' title='"._EDIT."'></a>");
	print("<a href='".$serverurl."/countries_del.php?id=$rowC[id]&w=C&text=$rowC[country]'><img class='sprites del' src='images/transparent.gif' border='0' title='"._DELETE."'></a>");
	print("</td>");
	print("</tr>");

	if ($_REQUEST['c']==$rowC[id]) {
		$item = query("SELECT * FROM hd_countries_states WHERE country=".$rowC[id]." ORDER by state",0);
		while($rowS=mysql_fetch_array($item)) {
			print("<tr class='row2'>");
			print("<td>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<a href='".$serverurl."/countries_S.php?id=$rowS[id]'>".$rowS[state]."</a>");
			print("</td>");
			print("<td align='center'>");
			print("<a href='".$serverurl."/countries_S.php?id=$rowS[id]'><img class='sprites edit' src='images/transparent.gif' border='0' title='"._EDIT."'></a>");
			print("<a href='".$serverurl."/countries_del.php?id=$rowS[id]&w=S&text=$rowS[state]'><img class='sprites del' src='images/transparent.gif' border='0' title='"._DELETE."'></a>");
			print("</td>");
			print("</tr>");
		}
	}
}

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


graybutton("countries_C.php",_ADD_COUNTRY);
graybutton("countries_S.php",_ADD_STATE);

echo '
</div>
</div>
';

include("foot_template.php");
?>
	
