<?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";

if (isset($delete))
	{
	# loop plans db
	$q="select ";
	$q.="rid, ";
	$q.="pid, ";
	$q.="package_name ";
	$q.="from ";
	$q.="plan_specs";
	
	$ctr=mysql_query($q);
	while ($ct=mysql_fetch_row($ctr))
		{
		if ($ct[0]==$delete)
			{
			@$e0.="&nbsp;-&nbsp;<a href='".$http_admin."/plan_build.php?sid=".$sid."&pid=".$ct[1]."'>".stripslashes(trim($ct[2]))."</a><br>";
			}
		}

	if (!isset($e0))
		{
		$query="delete ";
		$query.="from ";
		$query.="reseller_profile ";
		$query.="where ";
		$query.="rid='".addslashes(trim($delete))."'";

		mysql_query($query);
		}
	}

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'>
	");
if (isset($e0))
	{
	echo("
			<table width='100%' cellpadding='2' cellspacing='1' border='0'>
				<tr>
					<td align='left' valign='middle'><font color='#990000'><b>ERROR:</b> Please delete this reseller profile from the following package(s) first:</font></td>
				</tr>
				<tr>
					<td align='left' valign='middle'>".$e0."</td>
				</tr>
				<tr>
					<td colspan='2' align='left' valign='middle'><hr color='#F3F3F3'></td>
				</tr>
			</table>
		");
	}
echo "<table width='100%' cellpadding='2' cellspacing='1' border='0'>";
$buffer=("
				<tr>
					<td align='center' valign='middle' bgcolor='#E5E7E9'><b>#</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Reseller Profile Name</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Actions</b></td>
				</tr>
	");
$y=0;
$p=0;

$query0="select ";
$query0.="profile_name, ";	// 0
$query0.="rid ";	// 1
$query0.="from ";
$query0.="reseller_profile ";
$query0.="order by profile_name asc";

$row0=mysql_query($query0);
while ($rs0=mysql_fetch_row($row0))
	{
	if ($y==0) { $y=1; $bgcolor="#F2F4F6"; } else { $y=0; $bgcolor="#ECEEF0"; }

	$profile_name=stripslashes(trim($rs0[0]));	
	$rid=stripslashes(trim($rs0[1]));	

	$buffer.=("
				<tr>
					<td align='center' valign='middle' bgcolor='#E5E7E9'><b>".($p+=1)."</b></td>
					<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;<a href='".$http_admin."/reseller_profile.php?sid=".$sid."&rid=".$rid."&back=5'>".$profile_name."</a></td>
					<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;[<a href='".$http_admin."/reseller_profile.php?sid=".$sid."&rid=".$rid."&back=5'>edit</a>]&nbsp;&nbsp;[<a href='".$http_admin."/reseller_profile_edit.php?sid=".$sid."&delete=".$rid."'>delete</a>]</td>
				</tr>
		");
	}
if ($p==0)
	{
	echo("
				<tr>
					<td colspan='3' align='left' valign='middle'><img src='".$http_images."/error_arrow.gif'> No reseller profiles found in the database. <a href='".$http_admin."/reseller_profile.php?sid=".$sid."'>Click here</a> to add a profile now.</td>
				</tr>
		");
	}
else
	{
	echo $buffer;
	}
echo("		
			</table>
			</td>
			</tr>
		</table>
		");

include $server_admin_inc."/footer.php";
mysql_close($dblink);
?>