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

include $server_admin_inc."/header.php";

$query=array();
$row=array();
$rs=array();

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='2' cellspacing='1' border='0'>
				<tr>
					<td width='90%' align='left' valign='middle'>&nbsp;nav menu</td>
					<td width='10%' align='right' valign='middle'>
					<select name='view' ".$input_style.">
						<option value=''>View Todays Batch</option>
						<option value=''>View All Past Due</option>
						<option value=''>View All Declined</option>
						<option value=''>View All Error</option>
						<option value=''>View All Paid</option>
					</select></td>
				</tr>
			</table>
			<table width='100%' cellpadding='2' cellspacing='1' border='0'>
				<tr>
					<td align='center' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>#</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Client</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Amount</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Recurr</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Account</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Batch</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Account Created</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Batch Created</b></td>
				</tr>
	");
$query[0]="select ";
$query[0].="user.first_name, ";							// 0
$query[0].="user.last_name, ";							// 1
$query[0].="user.email, ";								// 2
$query[0].="hosting_order.oid, ";						// 3
# $query[0].="UNIX_TIMESTAMP(hosting_order.ogcreate), ";	// 4
$query[0].="hosting_order.ogcreate, ";	// 4
$query[0].="hosting_order.total_due_today, ";			// 5
$query[0].="hosting_order.total_due_reoccur, ";			// 6
$query[0].="hosting_order.payment_term, ";				// 7
$query[0].="hosting_order.status, ";					// 8
$query[0].="authnet_batch.batch_status, ";				// 7
$query[0].="authnet_batch.response_reason_text, ";		// 8
$query[0].="authnet_batch.ogcreate, ";					// 9
$query[0].="authnet_batch.bid ";						// 10
$query[0].="from ";
$query[0].="user, hosting_order, authnet_batch ";
$query[0].="where ";
$query[0].="authnet_batch.oid=hosting_order.oid ";
$query[0].="and ";
$query[0].="hosting_order.uid=user.uid ";
$query[0].="order by ";
$query[0].="authnet_batch.bid ";
$query[0].="asc";

$y=1;
$x=1;
$row[0]=mysql_query($query[0]);
while ($rs[0]=mysql_fetch_row($row[0]))
	{
	if ($y==1) {$bgcolor="#F2F4F6"; $y=0;} else {$bgcolor="#ECEEF0"; $y=1;}

	$first_name=stripslashes(trim($rs[0][0]));
	$last_name=stripslashes(trim($rs[0][1]));
	$email=stripslashes(trim($rs[0][2]));
	$oid=stripslashes(trim($rs[0][3]));
	$hosting_order_ogcreate=stripslashes(trim($rs[0][4]));
	$total_due_today=stripslashes(trim($rs[0][5]));
	$total_due_reoccur=stripslashes(trim($rs[0][6]));
	$payment_term=str_replace("-", "_", strtolower(stripslashes(trim($rs[0][7]))));
	$status=stripslashes(trim($rs[0][8]));
	$batch_ogcreate=stripslashes(trim($rs[0][9]));
	$bid=stripslashes(trim($rs[0][10]));
	
	# convert payment term
	if ($payment_term=="monthly") { $payment_term="1"; }
	else if ($payment_term=="quarterly") { $payment_term="3"; }
	else if ($payment_term=="semi_annual") { $payment_term="6"; }
	else if ($payment_term=="annual") { $payment_term="12"; }
	
	if ($status==1) { $amount_due=$total_due_reoccur; }
	else 

	echo("
		<tr>
			<td align='center' valign='middle' bgcolor='#E5E7E9'>".$x++."</td>
			<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;<a href='".$http_admin."/client_view.php?sid=".$sid."&oid=".$oid."'>".$first_name." ".$first_name."</a></td>
			<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;".$currency."".$amount_due."".$currency_type."</td>
			<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;".$currency."".$total_due_reoccur."".$currency_type."</td>
			<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;
		");
	if ($status==0)
		{
		echo "pending";
		}
	else if ($status==2)
		{
		echo "Active";
		}
	else if ($status==3)
		{
		echo "suspended";
		}
	echo("
			</td>
			<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;
		");
	if ($batch_status==1)
		{
		echo "<a href='javascript:void(0)' class='cleanlink3' onmouseover=\"return overlib('".$response_reason_text."', CAPTION, 'Approved');\" onmouseout='nd();'>Approved</a>";
		}
	else if ($batch_status==2)
		{
		echo "<a href='javascript:void(0)' class='cleanlink3' onmouseover=\"return overlib('".$response_reason_text."', CAPTION, 'Declined');\" onmouseout='nd();'>Declined</a>";
		}
	else if ($batch_status==3)
		{
		echo "<a href='javascript:void(0)'class='cleanlink3' onmouseover=\"return overlib('".$response_reason_text."', CAPTION, 'Error');\" onmouseout='nd();'>Error</a>";
		}
	echo("
			</td>
			<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;".date("m/d/Y", $hosting_order_ogcreate)."</td>
			<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;".date("m/d/Y", $batch_ogcreate)."</td>
		</tr>
		");
	
	unset($first_name);
	unset($last_name);
	unset($email);
	unset($oid);
	unset($hosting_order_ogcreate);
	unset($total_due_today);
	unset($total_due_reoccur);
	unset($payment_term);
	unset($status);
	unset($batch_status);
	unset($response_reason_text);
	unset($batch_ogcreate);
	unset($bid);
	}
echo("
			</table>
			</td>
		</tr>
	</table>
	");

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