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


// 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='2' cellspacing='1' border='0'>
				<tr>
					<td align='center' valign='middle' bgcolor='#E5E7E9'><b>#</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Coupon Code</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Discount Type</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Discount Amount</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Coupon Expires</b></td>
					<td align='left' valign='middle' bgcolor='#E5E7E9'>&nbsp;<b>Edit Coupon</b></td>
				</tr>
	");

$query="select ";
$query.="coupon_code, ";				// 0
$query.="coupon_discount_type, ";		// 1
$query.="coupon_discount_percent, ";	// 2
$query.="coupon_discount_whole, ";		// 3
$query.="expires, ";					// 4
$query.="aid, ";						// 5
$query.="coupon_terms ";				// 6
$query.="from ";
$query.="addon_specs ";
$query.="where ";
$query.="coupon='1'";

$x=0;
$y=0;
$row=mysql_query($query);
while ($rs=mysql_fetch_row($row))
	{
	if ($y==0) { $bgcolor="#F2F4F6"; $y=1; } else { $bgcolor="#ECEEF0"; $y=0; }
	
	$coupon_code=stripslashes(trim($rs[0]));
	$coupon_discount_type=stripslashes(trim($rs[1]));
	$coupon_discount_percent=stripslashes(trim($rs[2]));
	$coupon_discount_whole=stripslashes(trim($rs[3]));
	$expires=stripslashes(trim($rs[4]));
	$aid=stripslashes(trim($rs[5]));
	$coupon_terms=stripslashes(trim($rs[6]));
		
	echo("
				<tr>
					<td align='center' valign='middle' bgcolor='#E5E7E9'><b>".($x+=1)."</b></td>
					<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;".$coupon_code."</td>
					<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;".(($coupon_terms==1)?"One Time ":"Monthly ")."".(($coupon_discount_type==1)?"Percentage":"Whole Dollar Amount")."</td>
					<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;".(($coupon_discount_type==1)?"".$coupon_discount_percent."%":"".$currency."".$coupon_discount_whole."".$currency_type."")."</td>
					<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;".(($expires==0)?"No Expiration":"".(($expires<=time())?"Expired":"".date("m/d/Y", $expires)."")."")."</td>
					<td align='left' valign='middle' bgcolor='".$bgcolor."'>&nbsp;[<a href='".$http_admin."/coupon_build.php?sid=".$sid."&aid=".$aid."'>click to access</a>]</td>
				</tr>
		");

	unset($coupon_code);
	unset($coupon_discount_type);
	unset($coupon_discount_percent);
	unset($coupon_discount_whole);
	unset($expires);
	unset($aid);
	}
echo("		
			</table>
			</td>
		</tr>
	</table>
	");
include $server_admin_inc."/footer.php";
mysql_close($dblink);
?>