<div class="right_col" role="main">

    <div class="">

        <div class="row">

            <div class="col-md-12 col-sm-12 col-xs-12">

                <div class="x_panel">

					<div class="x_title">

						<h2>Profits</h2>

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

					</div>

					<div class="x_content">

						<form class="form-horizontal form-label-left" method="post">

							<div class="form-group">

								<label class="control-label col-md-3 col-sm-3 col-xs-12">Room No</label>

								<div class="col-md-6 col-sm-6 col-xs-12">

									<select class="form-control" name="roomno">

										<option>Choose option</option>

										<?php

											$result=mysqli_query($conn, "SELECT *FROM room") or die (mysql_error());

											while($row = mysqli_fetch_array($result))

											{

										?>

										<option value="<?php echo $row['r_id'];?>"><?php echo $row['r_no'];?></option>

										<?php

											}

										?>

									</select>

								</div>

							</div>

							<div class="item form-group">

								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="month">Month

								</label>

								<div class="col-md-6 col-sm-6 col-xs-12">

									<input id="month" class="form-control col-md-7 col-xs-12" name="month" type="month">

								</div>

							</div>

							<div class="form-group">

								<div class="col-md-6 col-md-offset-3">

									<button id="send" type="submit" class="btn btn-success" name="submit">Submit</button>

								</div>

							</div>

						</form>

					</div>

                </div>

            </div>

        </div>

		

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

		<div class="row">

			<div class="col-md-12 col-sm-12 col-xs-12">

				<div class="x_panel">

					<div class="x_content">

						<h2>Profits List</h2>

						<table id="datatable" class="table table-striped table-bordered">

							<thead>

								<tr>

									<th>Guest</th>

									<th>Check In Date</th>

									<th>Night</th>

									<th>Check Out Date</th>

									<th>Amount</th>

									<th>Tax</th>

									<th>Total</th>

								<!--<th>Reserved ID</th>-->

									<th>Collected</th>

								</tr>

							</thead>

							<tbody>

								<?php

									$result=mysqli_query($conn, "SELECT g.g_full_name AS GuestName, rv.rv_ci_date AS CheckInDate, rv.rv_night AS Night, 

									rv.rv_co_date AS CheckOut, rv.rv_amount AS Amount, rv.rv_tax AS Tax, py.py_amount AS PayAmount, py.rv_id as PayRID FROM reservation AS rv 

									INNER JOIN guest AS g ON rv.g_id=g.g_id INNER JOIN payment AS py ON rv.rv_id=py.rv_id")or die (mysql_error());

									while($row = mysqli_fetch_array($result))

									{

								?>

								<tr>

									<td><?php echo $row['GuestName'];?></a></td>

									<td><?php echo $row['CheckInDate'];?></td>

									<td><?php echo $night=$row['Night'];?></td>

									<td><?php echo $row['CheckOut'];?></td>

									<?php $totalAmount=0;?>

									<td>RM <?php echo $amount=$row['Amount'];

												$totalAmount+=$amount;

											?>

									

									</td>

									<td><?php echo $tax=$row['Tax'];?> %</td>

									<td>RM <?php echo number_format($total = (($amount * $night) * (1.0 + ($tax / 100))),2);?></td>

								<!--<td><?php echo $row['PayRID'];?></td>-->

									<td>RM <?php echo $row['PayAmount'];?></td>

								</tr>

								<?php

									}

								?>

							</tbody>

							<tfoot>

								<tr>

									<td colspan="4" align="right">Total :</td>

									<td>RM <?php echo $TotalAmount;?></td>

									<td>Total :</td>

									<td>RM <?php ?> </td>

									<td>RM <?php ?></td>

								</tr>

							</tfoot>

						</table>

					</div>

				</div>

			</div>

        </div>

    </div>

</div>



