<?PHP
include "../inc/var.php";
include "../inc/connect.php";
include $server_inc."/whm_functions.php";
include $server_inc."/client_functions.php";
include $server_inc."/login_functions.php";

// Start Form Handler

if (isset($delete))
	{
	mysql_query("delete from plan_specs where pid='".addslashes(trim($delete))."'");
	}

// End Form Handler

include $server_admin_inc."/header.php";

echo("
	<table width='725' cellpadding='0' cellspacing='0' border='0'>
		<tr>
			<td width='1%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='375'></td>
			<td width='99%' align='left' valign='top'>
			<table width='100%' cellpadding='4' cellspacing='1' border='0'>
	<form action='".$PHP_SELF."' method='POST'>
	".((isset($pid))?"<input type='hidden' name='pid' value='".trim($pid)."'>":"")."
	<input type='hidden' name='sid' value='".trim($sid)."'>
<table width='100%' border='0' cellspacing='1' cellpadding='2'>
		<tr>
			<td align='center' valign='top' bgcolor='#E5E7E9'><b>#</b></td>
			<td align='left' valign='top' bgcolor='#E5E7E9'>&nbsp;<b>Package Group</b></td>
			<td align='left' valign='top' bgcolor='#E5E7E9'>&nbsp;<b>Package Name</b></td>
			<td align='left' valign='top' bgcolor='#E5E7E9'>&nbsp;<b>Web Space</b></td>
			<td align='left' valign='top' bgcolor='#E5E7E9'>&nbsp;<b>Bandwidth</b></td>
			<td align='center' valign='top' bgcolor='#E5E7E9'><b>Edit</b></td>
			<td align='center' valign='top' bgcolor='#E5E7E9'><b>Delete</b></td>
			<td align='center' valign='top' bgcolor='#E5E7E9'><b>Plan Link</b></td>
		</tr>
	");

$x=1;
$y=1;
$row=mysql_query("select plan_specs.pid, plan_specs.package_name, plan_specs.web_space, plan_specs.bandwidth, plan_groups.name, plan_groups.gid, plan_specs.dedicated from plan_specs, plan_groups where plan_specs.gid=plan_groups.gid order by plan_groups.name, plan_specs.package_name asc");
while ($rs=mysql_fetch_row($row))
	{
	if ($y==1) {$bgcolor="#F2F4F6"; $y=0;} else {$bgcolor="#ECEEF0"; $y=1;}
	$cct0=mysql_fetch_row(mysql_query("select count(*) from hosting_order where pid='".addslashes(trim($rs[0]))."' and status='1'"));
	$total_active_with_this_package=$cct0[0];
	$cct1=mysql_fetch_row(mysql_query("select count(*) from hosting_order where pid='".addslashes(trim($rs[0]))."' and status='0'"));
	$total_pending_with_this_package=$cct1[0];
	echo("
		<tr>
			<td align='center' valign='top' bgcolor='#E5E7E9'><b>".$x.".</b></td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;".stripslashes($rs[4])."</td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;".stripslashes($rs[1])."</td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;".$rs[2]." ".(($rs[6]==1)?"GB":"MB")."</td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;".$rs[3]." ".(($rs[6]==1)?"GB":"MB")."</td>
			<td align='center' valign='top' bgcolor='".$bgcolor."'>[ <a href='".$http_admin."/plan_build".(($rs[6]==1)?"_dedicated":"").".php?pid=".$rs[0]."&sid=".trim($sid)."'>edit</a> ]</td>
			<td align='center' valign='top' bgcolor='".$bgcolor."'>[ <a href='".$PHP_SELF."?delete=".$rs[0]."&sid=".trim($sid)."'>delete</a> ]</td>
			<td align='center' valign='top' bgcolor='".$bgcolor."'>[ <a href='".$http_web."/step_one.php?gid=".$rs[5]."' target='_blank'>plan link</a> ]</td>
		</tr>
		<tr>
				<td colspan='8' align='left' valign='top' bgcolor='#E5E7E9' style='padding-left:25'>
				<img src='".$http_images."/drop_arrow.gif'>Total Active Accounts on this package: <b>[ ".$total_active_with_this_package." ]</b>    Total Pending: <b>[ ".$total_pending_with_this_package." ]</b>
				</td>
		</tr>
		");
	$x++;
	}

$uy=1;
$row=mysql_query("select pid, package_name, web_space, bandwidth from plan_specs where gid='0' order by package_name asc");
while ($rs=mysql_fetch_row($row))
	{
	if ($uy==1) {$bgcolor="#F2F4F6"; $uy=0;} else {$bgcolor="#ECEEF0"; $uy=1;}
	echo("
		<tr>
			<td align='center' valign='middle' bgcolor='".$bgcolor."'><a href='".$http_admin."/plan_build.php?pid=".$rs[0]."'><img border='0' src='".$http_images."/".(($uy==1)?"exec_ECEEF0.gif":"exec_F2F4F6.gif")."' alt='Click for Details'></a></td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;Undefined</td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;".stripslashes($rs[1])."</td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;".$rs[2]." ".(($rs[6]==1)?"GB":"MB")."</td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;".$rs[3]." ".(($rs[6]==1)?"GB":"MB")."</td>
			<td align='center' valign='top' bgcolor='".$bgcolor."'>[ <a href='".$http_admin."/plan_build".(($rs[6]==1)?"_dedicated":"").".php?pid=".$rs[0]."'>edit</a> ]</td>
			<td align='center' valign='top' bgcolor='".$bgcolor."'>[ <a href='".$PHP_SELF."?delete=".$rs[0]."'>delete</a> ]</td>
			<td align='center' valign='top' bgcolor='".$bgcolor."'>[ <a href='".$http_web."/step_one.php?gid=".$rs[5]."' target='_blank'>plan link</a> ]</td>
		</tr>
		");
	}
echo("
		<tr>
			<td colspan='6'><img src='".$http_images."/space.gif' width='1' height='8'></td>
		</tr>
</table>
<BR><b><font color='red'> DO NOT DELETE</font> any packages with at least one active account</b>
</form>
			</table>
			</td>
		</tr>
	</table>
	");
// End Main Process
mysql_close($dblink);
include $server_admin_inc."/footer.php";
?>