<?php

/*
osCommerce, Open Source E-Commerce Solutions 
http://www.oscommerce.com 

Copyright (c) 2003 osCommerce 

osCommRes, Services Oline 
http://www.oscommres.com 
Copyright (c) 2005 osCommRes 

Freeway eCommerce 
http://www.zac-ware.com/freeway 
Copyright (c) 2007 ZacWare

Released under the GNU General Public License
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );
  require('includes/application_top.php');
  require('includes/classes/split_page_results_event.php');
  tep_get_last_access_file();require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();
  $command=(isset($HTTP_GET_VARS['command'])?$HTTP_GET_VARS['command']:'');
  $flag=(isset($HTTP_GET_VARS['flag'])?$HTTP_GET_VARS['flag']:'');
  $page=(isset($HTTP_GET_VARS['page'])?$HTTP_GET_VARS['page']:'');
  $id=(isset($HTTP_GET_VARS['id'])?$HTTP_GET_VARS['id']:'');
  if($command!='') {
  	echo $command . '#'. $id . '#';
  	switch($command){
		case 'get_details':
		case 'expand':
			echo  do_get_details();
		break;
		case 'change_status':
			if($flag=='Y')
				$cactive=tep_image(DIR_WS_IMAGES . "template/icon_active.gif",'Inactive','','',' onClick="javascript:change_status(\'N\','.$id .');"');
			else 
				$cactive=tep_image(DIR_WS_IMAGES . "template/icon_inactive.gif",'Inactive','','',' onClick="javascript:change_status(\'Y\','.$id .');"');	
			tep_db_query("update " . TABLE_COUPONS . " set coupon_active='" . $flag . "' where coupon_id='" . $id . "'");
			echo $cactive;
		break;
		case 'show_details':
			echo show_customer_details();
		break;
		case 'page_navigation':
			get_coupon_details();
			break;
		case 'show_mail_history':
			echo show_mail_history($id);
			break;
		case 'show_mail_content':
			echo show_mail_content($id);
			break;
  	}
	exit;
  }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/http.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script language="javascript">
var prev_id='';
var page_id=1;
var prev_page_id='';
var close_obj=false;
var row_expand=false;

function do_close(id) {
	var head=document.getElementById('head_' + id);
	var data=document.getElementById('data_' + id);
	if(data.style.display=='' && data.innerHTML!='' && close_obj==false)  {
		data.style.display="none";
		data.innerHTML='';
		head.style.display='';
		row_expand=false;
		prev_id='';
	}
	close_obj=false;
}

function do_page_fetch(action,id){
	var data=document.getElementById('data_' + id);
	var head=document.getElementById('head_' + id);
	var command='';
	command="<?php echo tep_href_link(FILENAME_DISCOUNT_COUPONS);?>" + '?command=' + action+'&id=' + id;
	switch(action){
		case 'get_details':
		case 'expand':
			if(!data || !head)
				return;
				if(prev_id!=id) {
					row_expand=false;
					close_obj=false;
				}
			if(data.style.display=="none" && row_expand==false) {
				row_expand=true;
				data.style.display="";
				head.style.display="none";
				data.innerHTML=document.getElementById('loading').innerHTML;
				if(prev_id!='') {
					document.getElementById('data_' + prev_id).style.display="none";
					document.getElementById('head_' + prev_id).style.display="";
				}
				
			}
			prev_id=id;
			
		break;
		case 'show_details':
			document.getElementById('cust_details').style.display="";
			document.getElementById('email_details').style.display='none';
			document.getElementById('cust_details').innerHTML=document.getElementById('loading').innerHTML;
		break;
		case 'expand_order': 
			location.href="<?php echo tep_href_link(FILENAME_ORDERS,'return=sdc')?>" + '&page=' + page_id +'&oID=' + id + '&id=' + prev_id;
			return;
		break;
		case 'show_mail':
			location.href="<?php echo tep_href_link(FILENAME_GV_MAIL,'top=1')?>"+ '&page=' + page_id +'&id=' + prev_id;
			return;
		break;
		case 'show_mail_history':
			document.getElementById('email_details').style.display='';
			document.getElementById('cust_details').style.display='none';
			document.getElementById('email_details').innerHTML=document.getElementById('loading').innerHTML;
			command='<?php echo tep_href_link(FILENAME_DISCOUNT_COUPONS,'command=show_mail_history'); ?>'+ '&id=' + id;
			break;
		case 'show_email_content':
			document.getElementById('pop_email_display').style.display='';
			document.getElementById('pop_email_display').innerHTML='<span class="smallText">loading...</span>';
			command='<?php echo tep_href_link(FILENAME_DISCOUNT_COUPONS,'command=show_mail_content&id='); ?>'+id;
			break;
		case 'coupon_warning':
			alert('<?php echo TEXT_USERS_COUPON_EXCEEDS; ?>');
			return;
			break;
		
			
	}
	do_get_command(command);
}
function close_mail_content(){
	document.getElementById('pop_email_display').innerHTML='';
	document.getElementById('pop_email_display').style.display='none';
}
function do_result(result){
	var spl_array=Array();
	spl_array=result.split("#");
	switch (spl_array[0]){
		case 'get_details':
			document.getElementById('data_' + spl_array[1]).innerHTML=spl_array[2];
		break;
		case 'change_status':
			document.getElementById('status').innerHTML=spl_array[2];
		break;
		case 'show_details':
			document.getElementById('cust_details').style.display="";
			document.getElementById('cust_details').innerHTML=spl_array[2];
		break;
		case 'expand':
			document.getElementById('data_' + spl_array[1]).innerHTML=spl_array[2];
			do_page_fetch('show_details',spl_array[1]);
		break;
		case 'page_navigation':
			document.getElementById('ajx_details').innerHTML=spl_array[2];
			break;
		case 'show_mail_history':
			document.getElementById('email_details').innerHTML=spl_array[2];
			break;
		case 'show_mail_content':
			document.getElementById('pop_email_display').style.display='';
			document.getElementById('pop_email_display').innerHTML=spl_array[2];
			break;
			
	}
}
function change_status(flag,id){
	var command='';
	close_obj=true;
	command="<?php echo tep_href_link(FILENAME_DISCOUNT_COUPONS,'command=change_status');?>" + '&id=' + id + '&flag=' + flag;
	do_get_command(command);
}
	function do_page_navigation(value,params,name,plink){ 
	if(params=='page_navigation' && document.getElementById("page_''") && plink!=''){
		 page_id = parseInt(document.getElementById("page_''").options[document.getElementById("page_''").selectedIndex].value);
		if(plink=='next')
			page_id=page_id+1;
		else if(plink=='prev')
			page_id=page_id-1;
	}
	prev_page_id=page_id;
	prev_id='';
	command='<?php echo tep_href_link(FILENAME_DISCOUNT_COUPONS);?>' + '?command=page_navigation&page=' + page_id;
	do_get_command(command);
}

</script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
    <tr> 
<!-- body_text //-->
		<td width="100%" valign="top">
			<table border="0" width="100%" cellspacing="0" cellpadding="0">
			<tr>
			<td class="main">
			<?php
			echo "<div align='center' id='pop_email_display' style='position:absolute;display:none;width:500px;height:280px;z-index:999;border:1px solid;border-color:#CCCCCC;background-color:#FFFFFF;padding:1px;'>sdsdfsd </div>";
			?>
			</td>
			</tr>
				<tr>
					<td valign="top">
						<form name="frm_discout" action="<?php echo FILENAME_DISCOUNT_COUPON;?>" >
						<table border="0" width="100%" cellspacing="0" cellpadding="2">
							<tr class="dataTableHeadingRow">
								<td class="dataTableHeadingContent" width="25%"><?php echo TABLE_HEADING_COUPON_NAME; ?></td>
								<td class="dataTableHeadingContent"  width="25%" align="right"><?php echo TABLE_HEADING_COUPON_AMOUNT; ?></td>
								<td class="dataTableHeadingContent" width="25%" align="center"><?php echo TABLE_HEADING_COUPON_CODE; ?></td>
								<td class="dataTableHeadingContent"  width="25%" align="right"><?php echo TABLE_HEADING_CREATE_DATE; ?></td>	
							</tr>
							<tr>
								<td id="ajx_details" colspan="4">
							<?php get_coupon_details();?>
								</td>
							</tr>	
						</table>
						</form>
					</td>
				</tr>
</table>
		</td>
<!-- body_text_eof //-->
    </tr>
</table>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php');
function get_coupon_details(){
global $id,$languages_id,$currencies,$page;
	echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
 			//if($id!='')
			//	$where=" and c.coupon_id='" . $id . "'";
			$gv_query_raw = "select c.coupon_amount, c.coupon_code,c.coupon_active, c.coupon_id, cd.coupon_name,c.date_created from " . TABLE_COUPONS . " c, " . TABLE_COUPONS_DESCRIPTION . " cd where c.coupon_id = cd.coupon_id and cd.language_id='" . $languages_id . "'" . $where;
			//echo $gv_query_raw;
			$gv_split = new splitPageResultsEvent($page, MAX_DISPLAY_SEARCH_RESULTS, $gv_query_raw, $gv_query_numrows);
			$gv_query = tep_db_query($gv_query_raw); $class_name='dataTableRowOdd';
			while ($gv_list = tep_db_fetch_array($gv_query)) {
			$class_name=($class_name=='dataTableRowOdd')?'dataTableRowEven':'dataTableRowOdd';
				echo '  <tr  class="'.$class_name.'"  height="20" onmouseover="rowOverEffect(this);" onmouseout="rowOutEffect(this);" onclick="javascript:if(document.getElementById(\'data_'.$gv_list['coupon_id'].'\').style.display==\'none\') do_page_fetch(\'get_details\',' . $gv_list['coupon_id'] . ')">' . "\n";
				if($gv_list['coupon_active']=='Y')
					$cactive=tep_image(DIR_WS_IMAGES . "template/icon_active.gif");
				else 	$cactive=tep_image(DIR_WS_IMAGES . "template/icon_inactive.gif",'Inactive');
				//else 	$cactive=tep_image(DIR_WS_IMAGES . "template/icon_inactive.gif",'Inactive','','',' onClick="javascript:do_page_fetch(\'change_status\','.$gv_list['id'] .');"');

		?><td colspan="4"> 
		<div id="loading" style="display:none"><div style="height:30px;margin-left:30px"><img src="images/24-1.gif"></div></div>
			<div id="head_<?php echo $gv_list['coupon_id']; ?>" >
				<table border="0" cellpadding="0" cellspacing="0" width="100%">
					<tr>
						<td class="dataTableContent" align="left" width="25%"><?php echo $cactive . '&nbsp;'. $gv_list['coupon_name']; ?></td>
						<td class="dataTableContent" align="right" width="25%"><?php echo $currencies->format($gv_list['coupon_amount']); ?></td>
						<td class="dataTableContent"  align="center" width="25%"><?php echo $gv_list['coupon_code']; ?></td>
						<td class="dataTableContent" align="right" width="25%"><?php echo format_date($gv_list['date_created']); ?></td>
					</tr>
				</table>
			</div>
			<div id="data_<?php echo $gv_list['coupon_id']; ?>" style="display:none" class="openContent"></div>
		  </td> 
		</tr> 
		<?php
			 } if(!tep_db_num_rows($gv_query)){ ?>
		<tr height="10"></tr><tr class="main"><td class="main" colspan="4" align="center"><?php echo TEXT_NO_RESULTS_FOUND ; ?></td></tr>
		<?php } ?>
		<tr>
			<td colspan="5">
				<table border="0" width="100%" cellspacing="0" cellpadding="2">
					<tr id="fst_nav">
						<td class="smallText" valign="top"><?php echo $gv_split->display_count($gv_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $page, TEXT_DISPLAY_NUMBER_OF_DISCOUNT_COUPONS); ?></td>
						<td class="smallText" align="right"><?php echo $gv_split->display_script_links($gv_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $page,'page_navigation','do_page_navigation(\'\'','\'\'');?></td>
					</tr>
				</table>
			</td>
		</tr>
		</table>
<?php }							

function do_get_details(){
	global $id,$languages_id,$currencies;
	
	//Code to check the Uses Per Coupon
	$uses_per_coupon=0; $customers_use_coupon=0; $coupon_redeem_total=0;
	$coupon_use_query=tep_db_query("select uses_per_coupon,coupon_flag from ".TABLE_COUPONS." where coupon_id='$id'");
	if($coupon_use_array=tep_db_fetch_array($coupon_use_query))
		$uses_per_coupon=$coupon_use_array['uses_per_coupon'];
	$customers_use_coupon_query=tep_db_query("select count(*) as total from ".TABLE_COUPON_DISCOUNT_EMAIL." where coupon_id='$id'");
	if($customers_use_coupon_array=tep_db_fetch_array($customers_use_coupon_query))
		$customers_use_coupon=$customers_use_coupon_array['total'];
	$coupon_redeem_total_query=tep_db_query("select count(*) as total from ".TABLE_COUPON_REDEEM_TRACK." where coupon_id='$id'");
	if($coupon_redeem_total_array=tep_db_fetch_array($coupon_redeem_total_query))
		$coupon_redeem_total=$coupon_redeem_total_array['total'];

	
	$coupon_query=tep_db_query("select c.coupon_active,cd.coupon_name,c.coupon_amount,c.coupon_code from " . TABLE_COUPONS . " c , " . TABLE_COUPONS_DESCRIPTION . " cd where c.coupon_id=cd.coupon_id and cd.language_id='" . $languages_id ."' and c.coupon_id='" . $id ."'");
	$coupon_result=tep_db_fetch_array($coupon_query);
	if($coupon_result['coupon_active']=='Y')
		$cactive=tep_image(DIR_WS_IMAGES . "template/icon_active.gif",'Inactive','','',' onClick="javascript:change_status(\'N\','.$id.');"');
	else $cactive=tep_image(DIR_WS_IMAGES . "template/icon_inactive.gif",'Inactive','','',' onClick="javascript:change_status(\'Y\','.$id .');"');
	$result='<table cellpadding="0" cellspacing="0" border="0" width="100%" class="openContent" align="center">';
	$result.='<tr class="openContent_top" onClick="do_close(\''.$id . '\');"><td   colspan="2" class="inner_title" >&nbsp;<span id="status">' . $cactive . '</span>'. tep_draw_separator('pixel_trans.gif','10','10') . $coupon_result['coupon_name'] . '</td></tr>';
	$result.='<tr><td align="right"><table cellpadding="5" cellspacing="5" width="80%" >';
	$result.='<tr><td class="main" width="100">' .TEXT_COUPON_NAME. '</td><td class="main" width="150">' . $coupon_result['coupon_name']  . '</td></tr>';
	$result.='<tr><td class="main" wdith="100">' .TEXT_COUPON_CODE. '</td><td class="main" width="150">' . $coupon_result['coupon_code']  . '</td></tr>';
	$result.='<tr><td class="main" width="100">' .TEXT_COUPON_AMOUNT. '</td><td class="main" width="150">' . $currencies->format($coupon_result['coupon_amount'])  . '</td></tr>';
	$result.='</table></td><td align="left"><table cellpadding="5" cellspacing="5" border="0" width="100%">';
	$condition_string=($coupon_use_array['coupon_flag']=='U' || $uses_per_coupon > ($customers_use_coupon+$coupon_redeem_total))?'<a href="javascript:do_page_fetch(\'show_mail\',\'' . $id . '\');">':'<a href="javascript:do_page_fetch(\'coupon_warning\',\'' . $id . '\');">';
	$result.='<tr><td><a href="javascript:do_page_fetch(\'show_details\',\'' . $id . '\');">' . tep_image_button('button_usage.gif','Usage') . '</a>&nbsp;'.$condition_string. tep_image_button('button_email.gif','Mail').'</a>&nbsp;<a href="javascript:do_page_fetch(\'show_mail_history\',\'' . $id . '\');">' . tep_image_button('button_email_history.gif','Mail History') . '</a></td></tr>' ;
	$result.='</table></td></tr><tr><td colspan="2"><div id="cust_details" style="display:none;" width="100%"></div><div id="email_details" style="display:none;"></div></td></tr></table>';
	return $result;
}
function show_customer_details(){
	global $id,$currencies;
	//echo "select o.customers_name,o.date_purchased,o.orders_id,ot.value from " . TABLE_ORDERS . " o , " . TABLE_ORDERS_TOTAL . " ot, ". TABLE_COUPON_REDEEM_TRACK . " ct where ot.orders_id=o.orders_id and ot.class='ot_total' and ct.order_id=o.orders_id and ct.order_id!=0 and ct.coupon_id='" . $id ."' order by o.orders_id";
	$customer_query=tep_db_query("select o.customers_name,o.date_purchased,o.orders_id,ot.value from " . TABLE_ORDERS . " o , " . TABLE_ORDERS_TOTAL . " ot, ". TABLE_COUPON_REDEEM_TRACK . " ct where ot.orders_id=o.orders_id and ot.class='ot_total' and ct.order_id=o.orders_id and ct.order_id!=0 and ct.coupon_id='" . $id ."' order by o.orders_id");
	$result='<table cellpadding="2" cellspacing="0" border="0" width="100%">';
		$result.='<tr class="dataTableHeadingRow" height="20"><td width="250">'. TABLE_HEADING_CUSTOMER_NAME . '</td>';
		$result.='<td width="100">' . TABLE_HEADING_DATE . '</td>';
		$result.='<td width="100" align="right">' . TABLE_HEADING_AMOUNT . '</td></tr>';
		$result.='<tr><td colspan="3">'.((tep_db_num_rows($customer_query)>8)?'<div style="height:150px; overflow:auto;">':'<div>').'<table cellpadding="2" cellspacing="0" width="100%" border="0">' ;
	if(tep_db_num_rows($customer_query)>0){
	$class='dataTableRowOdd';
		while($customer_result=tep_db_fetch_array($customer_query)) { 
			$class=($class=='dataTableRowodd')?'dataTableRowEven':'dataTableRowOdd';
			$result.='<tr class="'.$class.'" onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);" onclick="javascript:do_page_fetch(\'expand_order\',\''. $customer_result['orders_id'] . '\');" height="20"><td  class="main" width="250">' . $customer_result['customers_name'] . '</td><td class="main" width="100" align="left">' . format_date($customer_result['date_purchased']) . '</td><td class="main" width="100" align="right">' . $currencies->format($customer_result['value']) .'</td></tr>';
		}
	} else $result.='<tr><td align="center" class="main">' . TEXT_NO_CUSTOMERS . '</td></tr>';
		$result.='<tr><td>' . tep_draw_separator('pixel_trans.gif','15','15') . '</td></tr>';
		$result.='</table></div></td></tr></table>';
	return $result;
}
function show_mail_history($coupon_id){ $result='';
	$show_email_history_query=tep_db_query("select cde.discount_coupon_id,cde.discount_coupon_code,cde.date_sent,c.customers_firstname,c.customers_lastname,c.customers_email_address from ".TABLE_COUPON_DISCOUNT_EMAIL." cde, ".TABLE_CUSTOMERS." c where c.customers_id=cde.customer_id and cde.coupon_id='$coupon_id'");
	//echo "select cde.discount_coupon_id,cde.discount_coupon_code,cde.date_sent,c.customers_firstname,c.customers_lastname,c.customers_email_address from ".TABLE_COUPON_DISCOUNT_EMAIL." cde, ".TABLE_CUSTOMERS." c where c.customers_id=cde.customer_id and cde.coupon_id='$coupon_id'";
	

	$coupon_flag_query=tep_db_query("select coupon_flag from ".TABLE_COUPONS." where coupon_id='$coupon_id'");
	$coupon_flag_array=tep_db_fetch_array($coupon_flag_query);
	$result='<table width="100%" cellpadding="0" cellspacing="0" border="0">';	
		$result.='<tr class="dataTableHeadingRow" height="20"><td width="25%">'. TABLE_HEADING_CUSTOMER_NAME . '</td>';
		$result.='<td width="25%">'.TABLE_HEADING_CUSTOMER_EMAIL.'</td>';
		$result.='<td width="25%">'.TEXT_HEADING_DISCOUNT_COUPON_CODE.'</td>';
		$result.='<td width="25%">' . TEXT_HEADING_DATE_SEND . '</td></tr>';
if($coupon_flag_array['coupon_flag']=='U'){
		$result.='</td></tr></table>'.((tep_db_num_rows($show_email_history_query)>8)?'<div style="height:150px; overflow:auto;">':'').'<table cellpadding="0" cellspacing="0" width="100%" border="0">' ;
		if(tep_db_num_rows($show_email_history_query)>0){
		$class='dataTableRowOdd';
		while($show_email_array=tep_db_fetch_array($show_email_history_query)) { 
			$class=($class=='dataTableRowodd')?'dataTableRowEven':'dataTableRowOdd';
			$result.='<tr class="'.$class.'" onMouseOver="rowOverEffect(this);" onMouseOut="rowOutEffect(this);" onclick="javascript:do_page_fetch(\'show_email_content\',\''. $show_email_array['discount_coupon_id'] . '\');" height="20">
			<td  class="main" width="210">' . $show_email_array['customers_firstname'] .'&nbsp;'.$show_email_array['customers_lastname']. '</td>
			<td class="main" width="215">' . $show_email_array['customers_email_address'] . '</td>
			<td class="main" width="210">' . $show_email_array['discount_coupon_code'] .'</td>
			<td class="main" width="200">'.format_date($show_email_array['date_sent']).'</td> </tr>';
		}
		} else $result.='<tr><td align="center" class="main">' . TEXT_NO_EMAIL_HISTORY . '</td></tr>';
		$result.='</table>'.((tep_db_num_rows($show_email_history_query)>8)?'</div>':'').'<br>';
}else
	$result.='<tr><td colspan="4" class="main" style="padding-bottom:10px;" align="center">'.( ($coupon_flag_array['coupon_flag']=='C')?TEXT_EMAIL_ALL_CUSTOMERS:TEXT_EMAIL_NEWS_LETTER).'</td></tr>';

		return $result;

}
function show_mail_content($discount_coupon_id){
	$result="";
	$customers_query=tep_db_query("select customers_firstname,customers_lastname from ".TABLE_CUSTOMERS." c, ".TABLE_COUPON_DISCOUNT_EMAIL." cde where c.customers_id=cde.customer_id and cde.discount_coupon_id='$discount_coupon_id'");
	$customers_array=tep_db_fetch_array($customers_query);
	$result.='<table width="100%" cellpadding="0" cellspacing="0" border="0">
			  <tr height="10px;" class="dataTableHeadingRow">
			  <td class="dataTableHeadingContent">'.$customers_array['customers_firstname'].'&nbsp;'.$customers_array['customers_lastname'].'</td>
			  <td align="right"><a href="javascript: void close_mail_content();">'.tep_image(DIR_WS_IMAGES.'template/img_closel.gif','Close','','','').'</a></td>
			  </tr>
			  <tr>
			  <td colspan="2" style="padding-top:10px;" class="main">	
	';
	$show_mail_content_query=tep_db_query("select content from ".TABLE_COUPON_DISCOUNT_EMAIL." where discount_coupon_id='$discount_coupon_id'");
	
	if(tep_db_num_rows($show_mail_content_query)>0){
	$show_mail_content_array=tep_db_fetch_array($show_mail_content_query);
	$result.=(strlen($show_mail_content_array['content'])>0)?$show_mail_content_array['content']:TEXT_NO_MAIL_CONTENT;
	}else
		$result.=TEXT_NO_MAIL_CONTENT;
	
	$result.='</td></tr></table>';	
	return $result;
}
?>
<script>
	<?php if($HTTP_GET_VARS['id']!=''){?>
		do_page_fetch('expand','<?php echo $HTTP_GET_VARS['id'];?>');
	<?php }?>
	<?php if($HTTP_GET_VARS['coupon_id']!=''){ ?>
		do_page_fetch('get_details','<?php echo $HTTP_GET_VARS['coupon_id']; ?>');
	<?php } ?>
</script>