<?php
	$roomId = $_GET['room'];
	$getDate = $_GET['date'] ? $_GET['date'] : header("Location: ?pagecontent=report_availability_monthly&date=".date("Y-m-d"));
	$getMonth = date_format(date_create($getDate),"m");
	$getYear = date_format(date_create($getDate),"Y");
	$getTotalDays = cal_days_in_month(CAL_GREGORIAN,$getMonth,$getYear);
?>
<!-- page content -->
<div class="right_col" role="main">
  <div class="">
	<div class="page-title">
	  <div class="title_left">
		<h3>ROOM AVAILABILITY FOR <?php echo date_format(date_create(date("Y-m-d")),"M Y"); ?></h3>
	  </div>

	  
	</div>

	<div class="clearfix"></div>

	<div class="row">

	  <div class="clearfix"></div>

	  <div class="col-md-12 col-sm-12 col-xs-12">
		<div class="x_panel">
		  <div class="x_title">
			<h2>Availability Sheet</h2>
			<ul class="nav navbar-right panel_toolbox">
			  <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
			  </li>
			  <li class="dropdown">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
				<ul class="dropdown-menu" role="menu">
				  <li><a href="#">Settings 1</a>
				  </li>
				  <li><a href="#">Settings 2</a>
				  </li>
				</ul>
			  </li>
			  <li><a class="close-link"><i class="fa fa-close"></i></a>
			  </li>
			</ul>
			<div class="clearfix"></div>
		  </div>
		  <div class="x_content">

			  <style>
				  .hover:hover{background-color:#D0D0D0;}
				  
				  tbody{
					  td{
						  &:hover{
							  &:before{background-color:#D0D0D0;}
						  }
					  }
				  }
			  </style>
			<table class="table table-bordered">
			  <thead>
				<tr>
				  <th>Room/Date</th>
					<?php for($i=1; $i<=$getTotalDays; $i++){
						$sheetDate = $getYear."-".$getMonth."-".$i; ?>
				  <th style="<?php if($sheetDate==$getDate){echo "background-color:lightyellow;";} ?>"><a href=""><?php echo $i; ?></a></th>
					<?php } $sheetDate=""; //clear ?>
				</tr>
			  </thead>
			  <tbody>
				  <?php
					$result = mysqli_query($conn, "SELECT * FROM rooms WHERE r_status=1 ORDER BY p_id ASC");
					while($row = mysqli_fetch_assoc($result)){
                        if(filterRoomAdmin($row['r_id'],$_SESSION['admin'][0])==true){continue;};

						$rowRoomId = $row['r_id'];
				  ?>
				<tr class="hover">
				  <td><a href=""><?php echo getDetailByTable('properties',$row['p_id'])['pty_code']; ?> <?php echo $row['r_no']; ?></a></td>
					
					<?php for($i=1; $i<=$getTotalDays; $i++){
						$sheetDate = $getYear."-".$getMonth."-".$i;
					  	//$colSpanNo = getRVByDateRoom($rowRoomId,$sheetDate)['rv_night'];
					  	//$i = $i + ($colSpanNo - 1);
					?>
				  <td colspan="<?php //echo $colSpanNo; ?>" style="white-space:nowrap; overflow:hidden; max-width:40px; <?php if(getRVByDateRoom($rowRoomId,$sheetDate)){echo 'background-color:lightgreen; font-weight:bold;';} ?> <?php if($sheetDate==$getDate){echo 'background-color:lightyellow; font-weight:bold;';} ?>"><a style=" " href="?pagecontent=reservation_communication&rv=<?php echo getRVByDateRoom($rowRoomId,$sheetDate)['rv_id']; ?>"><?php echo getRVByDateRoom($rowRoomId,$sheetDate)['rv_guest']; ?></a></td>
					<?php } $sheetDate=""; //clear ?>
					
				</tr>
				  <?php } ?>
				  
				  
			  </tbody>
			</table>

		  </div>
		</div>
	  </div>

	</div>
  </div>
</div>
<!-- /page content -->
