<? 
require_once "include/application.php"; 
require_once "include/function.php";
require_once "include/parameter.php";



if($btnAdd){
	
	$sql="
		update `ivc_reservation` set irs_status='C',
		`irs_cancel_remark` = \"$cremark\" ,
		`irs_cancelby`='".$_SESSION["egoUser"]."' 
		 where irs_id='$id'
	";
	@mysql_query($sql) or die(mysql_error());

	print("<script type='text/javascript'>alert('Reservation is cancel.')</script>");
	print("<script type='text/javascript'>location.href='reservCancel.php'</script>");
	
}
$sql="select * from ivc_reservation left join ivc_members on irs_memberno=im_formno left join 
	ivc_products on im_scheme=ip_id left join ivc_rooms on ip_room = ir_id 	where irs_id='$id' and irs_status='Y' ";
	$result=mysql_query($sql);	
	while($myrow=MySQL_fetch_array($result,MYSQL_ASSOC))
	{
		$reserv=$myrow["irs_for"];
		$gname=$myrow["irs_guestname"];
		$gic=$myrow["irs_guestic"];
		$gcontact=$myrow["irs_guestcontact"];
		$gemail=$myrow["irs_guestemail"];
		$adult=$myrow["irs_adult1"];
		$child=$myrow["irs_child1"];
		$remark=$myrow["irs_remark"];
		$ivcremark=$myrow["irs_ivcremark"];
		$rooms=$myrow["irs_room1"];
		$bookingno=$myrow["irs_bookingno"];        		
		$cardno=$myrow["im_cardno"];
		$no=$myrow["irs_memberno"];
	
		$name=$myrow["im_name"];
		$scheme=$myrow["ip_code"]." - ".$myrow["ip_name"];
		$roomtype=$myrow["ir_type"]." - ".$myrow["ir_descr"];
		$ic=$myrow["im_ic"];
		$email=$myrow["im_email"];
		$home=$myrow["im_phome"];
		$mobile=$myrow["im_mobile"];
		$fax=$myrow["im_fax"];

		$freemaint=$myrow["im_freemaint"];
		$exp=window_date($myrow["im_expired"]);
		$program=$myrow["im_program"];
		$nationality=$myrow["im_nationality"];        
		
		$cin=window_date($myrow["irs_confirm_cin"]);
		$cout=window_date($myrow["irs_confirm_cout"]);
		
	}

	$sql="select * from ivc_yearly_ent where ye_memberno='$no' 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"];
		$entnights=$myrow["ye_night"];
	}
	$bal=$entnights -reserv_num($no,$st,$ye);
	$yrexp=window_date($ye);
	
	
	

	

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="sddm.css" >
<script src="include/validation.js" type="text/javascript"></script>


<title><? echo TITLE?></title></head>
<body>

<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#f1efd8">
  <tr>
    <td  colspan="2" align="center"><? require_once "include/header.php"; ?></td>
  </tr>
  <tr>
    <td colspan="2" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td width="185" valign="top" bgcolor="e6f3f9">
	
<? require_once "include/columnLeft.php";
if(array_search("Rooms",$menulist)==false)
		print("<script type='text/javascript'>location.href='index.php'</script>");

 ?>	</td>
    <td width="834" valign="top">
	<form name="form" method="post" action="<?=$PHP_SELF ?>"  ONSUBMIT="return ValidateCancelReservation(this)">
	  <table width="800" height="250" border="0" align="center" cellpadding="0" cellspacing="0">


	  <tr>
        
        <td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="100%" height="30" class="TitleH3">Cancel Reservation <strong><strong><strong><strong><strong><strong><strong><strong><strong>
              <input name="id" type="hidden" id="id" value="<? echo $id ?>" />
            </strong></strong></strong></strong></strong></strong></strong></strong></strong></td>
          </tr>
          <tr>
            <td height="1" bgcolor="#B8ED83"></td>
          </tr>
          <tr>
            <td ><? echo "<div class='Msg'>$action_msg</div>" ?>&nbsp;</td>
          </tr>

        </table>
          <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="53%" valign="top"><table border="0" cellpadding="2" width="100%" cellspacing="1" class="small">
                <tr class="editTbl">
                  <th height="23" align="left" class="TextH1">Booking No :</th>
                  <th height="23" align="left" class="TextH1"><input name="bookingno" type="text" class="info" id="bookingno" onfocus="if(document.images){blur()}" value="<? echo $bookingno ?>" size="30" /></th>
                </tr>
                <tr>
                  <td class="TextH1">Card No. :</td>
                  <td class="TextH1"><input name="cardno" type="text" class="info" id="cardno" onfocus="if(document.images){blur()}" value="<? echo $cardno ?>" size="30" /></td>
                </tr>
                <tr>
                  <td width="151" class="TextH1">Membership No. :</td>
                  <td width="255" class="TextH1"><input name="no" type="text" class="info" id="no" onfocus="if(document.images){blur()}" value="<? echo $no ?>" size="30" /></td>
                </tr>
                <tr>
                  <td class="TextH1">Principal's Name  :</td>
                  <td class="TextH1"><input name="name" type="text" class="info" id="name" onfocus="if(document.images){blur()}" value="<? echo $name ?>" size="30" /></td>
                </tr>
                <tr>
                  <td class="TextH1">Type of Product    :</td>
                  <td class="TextH1"><input name="scheme" type="text" class="info"  onfocus="if(document.images){blur()}" value="<? echo $scheme ?>" size="30" /></td>
                </tr>
                <tr>
                  <td class="TextH1">Rooms    :</td>
                  <td class="TextH1"><input name="roomtype" type="text" class="info" id="roomtype"  onfocus="if(document.images){blur()}" value="<? echo $roomtype ?>" size="30" /></td>
                </tr>
                <tr>
                  <td class="TextH1">NRIC/Passport  :</td>
                  <td class="TextH1"><input name="ic" type="text" class="info"  onfocus="if(document.images){blur()}" value="<? echo $ic ?>" size="30" /></td>
                </tr>
                <tr>
                  <td class="TextH1" >Nationality     :</td>
                  <td ><span class="TextH1">
                    <input name="nationality" type="text" class="info" id="nationality"  onfocus="if(document.images){blur()}" value="<? echo $nationality; ?>" size="30" />
                  </span></td>
                </tr>
                <tr class="editTbl">
                  <th height="23" class="TextH1"><div align="left">Home Contact No. : </div></th>
                  <td class="TextH1"><input name="home" type="text" class="info" id="home"  onfocus="if(document.images){blur()}" value="<? echo $home ?>" size="30" /></td>
                </tr>
                <tr class="editTbl">
                  <th height="23" class="TextH1"><div align="left">Mobile No. :</div></th>
                  <td class="TextH1"><input name="mobile" type="text" class="info"  onfocus="if(document.images){blur()}" value="<? echo $mobile ?>" size="30" /></td>
                </tr>
                <tr class="editTbl">
                  <th height="11" class="TextH1"><div align="left">Fax No. :</div></th>
                  <td class="TextH1"><input name="fax" type="text" class="info"  onfocus="if(document.images){blur()}" value="<? echo $fax ?>" size="30" /></td>
                </tr>
                <tr class="editTbl">
                  <th height="23" class="TextH1"><div align="left">Email : </div></th>
                  <td class="TextH1"><input name="email" type="text" class="info"  onfocus="if(document.images){blur()}" value="<? echo $email ?>" size="30" /></td>
                </tr>
                <tr class="editTbl">
                  <th height="23" class="TextH1"><div align="left"> Program Tenure : </div></th>
                  <td class="TextH1"><input name="program" type="text" class="info"  onfocus="if(document.images){blur()}" value="<? echo $program ?>" size="10" />
                    Year(s ) </td>
                </tr>
                <tr class="editTbl">
                  <th height="23" class="TextH1"><div align="left">Membership Expired : </div></th>
                  <td class="TextH1"><input name="expiry" type="text" class="info" id="expiry"  onfocus="if(document.images){blur()}" value="<? echo $exp ?>" size="10" /></td>
                </tr>
                <tr class="editTbl">
                  <th height="23" class="TextH1"><div align="left"> Annual Entitlement : </div></th>
                  <td class="TextH1"><span id="txtEntNights">
                    <input name="entnights" type="text" class="info"  onfocus="if(document.images){blur()}" value="<? echo $entnights ?>" size="10" />
                    Night(s) </span></td>
                </tr>
                <tr>
                  <td class="TextH1">Free Maintenance Fees :</td>
                  <td class="TextH1"><span id="txtFreeMaint"></span>
                    <input name="freemaint" type="text" class="info"  onfocus="if(document.images){blur()}" value="<? echo $freemaint ?>" size="10" />
                    &nbsp; Year(s ) </td>
                </tr>
                <tr class="editTbl">
                  <th height="23" class="TextH1"><div align="left"> Balance of Nights : </div></th>
                  <td class="TextH1"><input name="bal" type="text" class="info" id="bal"  onfocus="if(document.images){blur()}" value="<? echo $bal ?>" size="4" />
                    end of
                    <input name="yrexp" type="text" class="info"  onfocus="if(document.images){blur()}" value="<? echo $yrexp ?>" size="12" /></td>
                </tr>
                <tr class="editTbl">
                  <th height="23" class="TextH1">&nbsp;</th>
                  <td class="TextH1">&nbsp;</td>
                </tr>
                <tr>
                  <td colspan="2" class="TextH1">IVC Remarks :</td>
                </tr>
                <tr>
                  <td colspan="2" class="TextH1"><textarea name="ivcremark" cols="50" rows="4" id="ivcremark" class="info"  onfocus="if(document.images){blur()}"><? echo $ivcremark ?></textarea></td>
                </tr>
                <tr class="editTbl">
                  <th height="23" colspan="2" class="TextH1">&nbsp;</th>
                </tr>
              </table></td>
              <td width="47%" valign="top"><table width="100%" border="0" cellspacing="1" cellpadding="2">
                <tr>
                  <td colspan="2" class="TextH1">Reservation Request : <? echo $reserv ?></td>
                </tr>
             <?  if($reserv=="Guest"){ ?>
                <tr>
                  <td colspan="2" bgcolor="#3DC3CE" class="TextH1">Guest's Full Name : <? echo $gname ?></td>
                </tr>
                <tr>
                  <td colspan="2" bgcolor="#3DC3CE" class="TextH1">Guest's IC / Passport No : <? echo $gic ?></td>
                </tr>
                <tr>
                  <td colspan="2" bgcolor="#3DC3CE" class="TextH1">Guest's Contact No :    <? echo $gcontact ?>                </td>
                </tr>
                <tr>
                  <td colspan="2" bgcolor="#3DC3CE" class="TextH1">Guest's Email : <? echo $gemail ?>
                    </td>
                </tr>
				<? } ?>
                <tr>
                  <td colspan="2" class="TextH1"><div align="center"></div></td>
                </tr>
                <tr>
                  <td colspan="2" bgcolor="#FF9900" class="TextH1">
                    <div align="center">Reservation</div></td>
                  </tr>
                <tr>
                  <td width="35%" class="TextH1">Check In Date :</td>
                  <td width="65%" class="TextH1"><input name="cin" type="text" class="info" id="cin"  onfocus="if(document.images){blur()}" value="<? echo $cin ?>" size="12" /></td>
                </tr>
                <tr>
                  <td class="TextH1">Check Out Date : </td>
                  <td class="TextH1"><input name="cout" type="text" class="info" id="cout"  onfocus="if(document.images){blur()}" value="<? echo $cout ?>" size="12" /></td>
                </tr>
                <tr>
                  <td class="TextH1">No of Villas : </td>
                  <td class="TextH1"><input name="rooms" type="text" class="info" id="rooms"  onfocus="if(document.images){blur()}" value="<? echo $rooms ?>" size="3" /></td>
                </tr>
                <tr>
                  <td class="TextH1">No of Adults : </td>
                  <td class="TextH1"><input name="adult" type="text" class="info" id="adult"  onfocus="if(document.images){blur()}" value="<? echo $adult ?>" size="3" />
                     &nbsp; No of Childrens : 
                     <input name="child" type="text" class="info" id="child"  onfocus="if(document.images){blur()}" value="<? echo $child ?>" size="3" /></td>
                </tr>
                <tr class="small">
                  <td colspan="2" class="TextH1">Remarks (if any):</td>
                </tr>
                <tr class="small">
                  <td colspan="2" class="TextH1"><textarea name="remark2" cols="50" rows="4" id="remark2" class="info"  onfocus="if(document.images){blur()}"><? echo $remark ?></textarea></td>
                </tr>
                <tr>
                  <td colspan="2" class="TextH1">Cancel Remarks : <span class="require">*</span></td>
                </tr>
                <tr>
                  <td colspan="2" class="TextH1"><textarea name="cremark" cols="50" rows="4" id="cremark" ><? echo $cremark ?></textarea></td>
                </tr>
              </table></td>
            </tr>
          </table>
          <table border="0" cellpadding="2" width="100%" cellspacing="1" class="small">
            <tr>
              <td width="627" height="30" class="text12">&nbsp;</td>
            </tr>
            <tr>
              <td height="1" bgcolor="#999999"></td>
            </tr>
            <tr>
              <td height="30" class="TextH1"><span class="require">* Denotes a require_onced field</span></td>
            </tr>
            <tr>
              <td class="text12"><input name="btnAdd" type="submit" class="btn150" id="btnAdd" value="CANCEL BOOKING" onclick="return confirm('Are you sure ?')"/>
&nbsp;
<input name="btnBack" type="button" class="btn" id="btnBack" onclick="location.href='reservCancel.php'" value="BACK" /></td>
            </tr>
          </table></td>

      </tr>
 
    </table><br />
	</form>	</td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#333333" class="Footer" align="center"><br />
    <? require_once "footer.php"; ?></td>
  </tr>
</table>
</body>
</html>
