<?
require('include/configure.php');
require('include/database.php');
require('include/function.php');

	$ret=get_data("im_formno","ivc_members","where im_cardno='$sMemberID'");



	$sql="select ye_expiry,ye_night,ye_start from ivc_yearly_ent left join ivc_members on im_formno=ye_memberno where im_cardno='$sMemberID' and ye_expiry >= '".date("Y-m-d")."' order by ye_expiry limit 1";
	$result=mysql_query($sql) or die(mysql_error());
	while($myrow=MySQL_fetch_array($result,MYSQL_ASSOC))
	{
		$ye=$myrow["ye_expiry"];
		$st=$myrow["ye_start"];
		$entnight=$myrow["ye_night"];
	}


	$tot_night=reserv_num($ret["im_formno"],$st,$ye);

	$sql="select ip_code,ip_name,im_expired,im_entnight,ir_type,ir_descr,im_formno,im_name,im_ic,im_phome,im_mobile,
	im_fax,im_scheme,im_email,im_freemaint,im_program,ip_adult,ip_child  
	from ivc_members left join ivc_products on im_scheme=ip_id left join ivc_rooms on ip_room = ir_id where im_cardno ='$sMemberID'";
	$result=mysql_query($sql) or die(mysql_error());
	if(mysql_num_rows($result)==0)echo "1";	
	else{
		while($myrow=MySQL_fetch_array($result,MYSQL_ASSOC))
		{
			$tot=$entnight - $tot_night;
			echo $myrow["im_name"]."|".$myrow["ip_code"]." - ".$myrow["ip_name"]."|".$myrow["ir_type"]." - ".$myrow["ir_descr"]."|".$myrow["im_ic"]."|".$myrow["im_phome"]."|".$myrow["im_mobile"]
			."|".$myrow["im_fax"]."|".$myrow["im_email"]."|".$myrow["im_entnight"]."|".$myrow["im_freemaint"]."|".$myrow["im_expired"]."|$tot|".$myrow["im_formno"]."|".$myrow["im_program"]."|$ye|".$myrow["ip_adult"]."|".$myrow["ip_child"];
		}
	}


	
?>
 