<?php

$_SESSION['redirect'] = $_SERVER['REQUEST_URI'];

$roomId = $_GET['room'];

$date = date("Y-m-d");

$getDate = $_GET['month'] ? $_GET['month'] : header("Location: ?pagecontent=report_profit_room&room=$roomId&month=" . date("Y-m-01"));



// $roomNo = getDetailByTable("rooms",$row['r_no'])['r_no'];

$getHostProfitSharingPercent = getDetailByTable('rooms', $roomId)['r_profit_sharing'];

$getOwnerProfitSharingPercent = (1.0 - $getHostProfitSharingPercent);

?>

<!-- page content -->

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

  <div class="">

    <div class="page-title">

      <div class="title_left">

        <h3>ROOM : <?php echo roomNo($roomId)['pty_title']; ?> (<?php echo roomNo($roomId)['r_no']; ?>)</h3>

        <p><a href="?pagecontent=room_update&room=<?php echo roomNo($roomId)['r_id']; ?>">Update Room Detail</a></p>

      </div>



      <div class="title_right">

        <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">

          <div class="input-group">

            <input type="text" class="form-control" placeholder="Search for...">

            <span class="input-group-btn">

              <button class="btn btn-default" type="button">Go!</button>

            </span>

          </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_title">

            <h2>Monthly Profit List</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">



            <table class="table">

              <thead>

                <tr>

                  <th>#</th>

                  <th>Month</th>

                  <th>Collection</th>

                  <th>Clearance</th>

                  <!-- <th>Unpaid</th> -->

                  <th>Utilities</th>

                  <th>Expenses</th>

                  <th>Pot. Profit</th>

                  <th>Profit</th>

                </tr>

              </thead>

              <tbody>

                <?php $no = 0;

                $totalPotentialProfit = 0;

                $totalLoss = 0;

                $totalProfit = 0;

                $sql = "SELECT DATE_FORMAT(rv_ci_date, '%Y-%m-01') as Months from reservation GROUP BY Months ORDER BY Months DESC";

                $result = mysqli_query($conn, $sql);

                while ($row = mysqli_fetch_assoc($result)) {

                  $totalPaymentsByMonthYear = totalPaymentsByMonthYear($row['Months'], $roomId)['total'];

                  $totalPaidByMonthYear = totalPaidByMonth($roomId, $row['Months']);

                  $totalUtilitiesByMonth = totalUtilities($roomId, $row['Months']);



                  if ($totalPaymentsByMonthYear) {

                    ?>

                    <tr>

                      <th><?php echo ++$no; ?></th>

                      <td><a

                          href="?pagecontent=report_profit_room&room=<?php echo $roomId; ?>&month=<?php echo $row['Months']; ?>"><?php echo date("F Y", strtotime($row['Months'])); ?></a>

                      </td>

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

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

                      <!-- <td>

            <?php

            $totalUnpaid = $totalPaymentsByMonthYear - $totalPaidByMonthYear;



            if ($totalUnpaid > 0) { ?>

                <span style="font-weight: bold; color: red;">RM <?php echo $totalUnpaid; ?></span>

              <?php } else { ?>

                <span style="font-weight: bold; color: blue;">RM <?php echo $totalUnpaid; ?></span>

              <?php }

            ?>

          </td> -->

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

                      <td>RM <?php echo $totalExpenses = totalExpenses($row['Months'], $roomId, 'expenses')['total']; ?></td>

                      <td>RM <?php echo $potentialProfit = $totalPaymentsByMonthYear - $totalUtilitiesByMonth - $totalExpenses;

                      $totalPotentialProfit = $totalPotentialProfit + $potentialProfit; ?></td>

                      <td>

                        <?php

                        $profit = $totalPaidByMonthYear - $totalUtilitiesByMonth;

                        if ($profit > 0) {

                          $totalProfit = $totalProfit + $profit;

                        }

                        if ($profit < 0) {

                          $totalLoss = $totalLoss + $profit;

                        }



                        if ($profit > 0) { ?>

                          <span style="font-weight: bold; color: blue;">RM <?php echo $profit; ?></span>

                        <?php } else { ?>

                          <span style="font-weight: bold; color: red;">RM <?php echo $profit; ?></span>

                        <?php }

                        ?>

                      </td>

                    </tr>

                  <?php }

                  $totalRow = $no;

                  $totalExpenses = 0;

                } ?>

              </tbody>

            </table>



          </div>

        </div>

      </div>



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

        <div class="x_panel">

          <div class="x_title">

            <h2>Summary</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">

            <?php $no = 0; //clear ?>

            <table class="table">

              <thead>

                <tr>

                  <th>#</th>

                  <th>Description</th>

                  <th>RM</th>

                </tr>

              </thead>

              <tbody>

                <tr>

                  <th><?php echo ++$no; ?></th>

                  <td>Total Potential Profit (All Months)</td>

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

                </tr>

                <tr>

                  <th><?php echo ++$no; ?></th>

                  <td>Total Profit (All Months)</td>

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

                </tr>

                <tr>

                  <th><?php echo ++$no; ?></th>

                  <td>Total Loss (All Months)</td>

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

                </tr>

                <tr>

                  <th><?php echo ++$no; ?></th>

                  <td>Average Potential Monthly Profit</td>

                  <td>RM <?php echo bcdiv($totalPotentialProfit / $totalRow, 1, 2); ?></td>

                </tr>

              </tbody>

            </table>



          </div>

        </div>

      </div>



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

        <div class="x_panel">

          <div class="x_title">

            <h2>Earned by Platform for <?php echo date("F Y", strtotime($_GET['month'])); ?></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">

            <?php $no = 0; //clear ?>

            <table class="table">

              <thead>

                <tr>

                  <th>#</th>

                  <th>Platform</th>

                  <th>Earning</th>

                </tr>

              </thead>

              <tbody>

                <?php $no = 0;

                $result = mysqli_query($conn, "SELECT * FROM platforms");

                while ($row = mysqli_fetch_assoc($result)) {

                  ?>

                  <tr>

                    <th><?php echo ++$no; ?></th>

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

                    <td>RM <?php echo totalPaymentsByMonthYear($getDate, $roomId, $row['pt_id'])['total']; ?></td>

                  </tr>

                <?php } ?>

              </tbody>

            </table>



          </div>

        </div>

      </div>



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

        <div class="x_panel">

          <div class="x_title">

            <h2>Month/Year : <?php echo date("F Y", strtotime($_GET['month'])); ?></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">



            <table class="table table-striped">

              <thead>

                <tr>

                  <th>#</th>

                  <th>Description</th>

                  <th>Amount</th>

                </tr>

              </thead>

              <tbody>

                <tr>

                  <th scope="row">1</th>

                  <td>Total Reservation</td>

                  <td><?php echo totalEarnedByMonthYear($getDate, $roomId); ?></td>

                </tr>

                <tr>

                  <th scope="row">1</th>

                  <td>Total Confirmed</td>

                  <td><?php echo totalConfirmedByMonthYear($roomId, $getDate); ?></td>

                </tr>

                <tr>

                  <th scope="row">1</th>

                  <td>Total Cancelled</td>

                  <td><?php echo totalCancelledByMonthYear($roomId, $getDate); ?></td>

                </tr>

                <tr>

                  <th scope="row">2</th>

                  <td>Nights</td>

                  <td><?php echo totalNightsByMonthYear($roomId, $getDate); ?></td>

                </tr>

                <tr>

                  <th scope="row">3</th>

                  <td>Collected Payments</td>

                  <td>RM <?php echo $collectedPayments = totalPaymentsByMonthYear($getDate, $roomId)['total']; ?></td>

                </tr>

                <tr>

                  <th scope="row">4</th>

                  <td>Collected by Owner</td>

                  <td>RM <?php echo totalPaymentsByOwner($roomId, $getDate); ?></td>

                </tr>

                <tr>

                  <th scope="row">5</th>

                  <td>Collected by Host</td>

                  <td>RM <?php echo totalPaymentsByHost($roomId, $getDate); ?></td>

                </tr>

                <tr>

                  <th scope="row">6</th>

                  <td>Total Utilities</td>

                  <td>RM <?php echo $totalUtilities = totalUtilities($roomId, $getDate); ?></td>

                </tr>

                <tr>

                  <th scope="row">7</th>

                  <td>Total Cleaning Fee</td>

                  <td>RM

                    <?php echo $totalCleaningFee = totalCleaningFee($roomId, $getDate) ? totalCleaningFee($roomId, $getDate) : 0; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row">8</th>

                  <td>Profit</td>

                  <td>RM <?php echo $profit = $collectedPayments - $totalUtilities - $totalCleaningFee; ?></td>

                </tr>

                <tr>

                  <th scope="row">9</th>

                  <td>Host Profit Sharing (<?php echo $getHostProfitSharingPercent * 100; ?>%)</td>

                  <td>

                    RM <?php echo $profit * $getHostProfitSharingPercent; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row">10</th>

                  <td>Owner Profit Sharing (<?php echo $getOwnerProfitSharingPercent * 100; ?>%)</td>

                  <td>

                    RM <?php echo $profit * $getOwnerProfitSharingPercent; ?>

                  </td>

                </tr>

                <?php $no = 11;

                $resultUtilityType = mysqli_query($conn, "SELECT * FROM utility_type");

                while ($rowUtilityType = mysqli_fetch_assoc($resultUtilityType)) {

                  ?>

                  <tr>

                    <th scope="row"><?php echo ++$no; ?></th>

                    <td><?php echo $rowUtilityType['uty_title']; ?></td>

                    <td>

                      <?php

                      $utilityType = $rowUtilityType['uty_id'];

                      $amount = utilityAmount($roomId, $getDate, $utilityType);

                      if ($amount) {

                        echo "<a href='?pagecontent=utility_update&room=$roomId&date=$getDate&type=$utilityType&amount=$amount'>RM " . $amount . "</a>";

                      } else {

                        if ($_SESSION['admin']) {

                          echo "<a href='?pagecontent=utility_update&room=$roomId&date=$getDate&type=$utilityType&amount=$amount'><button class='btn btn-xs btn-primary'>Update</button></a>";

                        }

                      }

                      ?>

                    </td>

                  </tr>

                <?php } ?>



              </tbody>

            </table>



          </div>

        </div>

      </div>



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

        <div class="x_panel">

          <div class="x_title">

            <h2>Earning from platform : <?php echo date("F Y", strtotime($_GET['month'])); ?></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">



            <table class="table table-striped">

              <thead>

                <tr>

                  <th>#</th>

                  <th>Description</th>

                  <th>Amount</th>

                </tr>

              </thead>

              <tbody>

                <tr>

                  <th scope="row">1</th>

                  <td>Total Reservation</td>

                  <td><?php echo totalEarnedByMonthYear($getDate, $roomId); ?></td>

                </tr>



                <?php $no = 1;

                $totalEarned = 0;

                $totalPaidByHOST = 0;

                $totalPaidByOWNER = 0;

                // $resultUtilityType = mysqli_query($conn,"SELECT * FROM utility_type");

                // while($rowUtilityType = mysqli_fetch_assoc($resultUtilityType)){

                foreach (platforms() as $item) {

                  ?>

                  <tr>

                    <th scope="row"><?php echo ++$no; ?></th>

                    <td><?php echo $item['title']; ?></td>

                    <td>

                      <?php

                      $typeId = $item['id'];

                      $amount = earningAmount($roomId, $getDate, $typeId);

                      $totalEarned = $totalEarned + $amount;

                      if ($typeId == 1) {

                        $totalDirect = $amount;

                      }

                      if ($amount) {

                        echo "<a href='?pagecontent=earning_update&room=$roomId&date=$getDate&type=$typeId&amount=$amount'>RM " . $amount . "</a>";

                      } else {

                        if ($_SESSION['admin']) {

                          echo "<a href='?pagecontent=earning_update&room=$roomId&date=$getDate&type=$typeId&amount=$amount'><button class='btn btn-xs btn-primary'>Update</button></a>";

                        }

                      }

                      ?>

                    </td>

                  </tr>

                <?php } ?>





                <?php $totalUtilities = 0;

                $resultUtilityType = mysqli_query($conn, "SELECT * FROM utility_type");

                while ($rowUtilityType = mysqli_fetch_assoc($resultUtilityType)) {

                  $utilityType = $rowUtilityType['uty_id'];

                  $amount = utilityAmount($roomId, $getDate, $utilityType);

                  $totalUtilities = $totalUtilities + $amount;

                  $paidBy = utilityAmount2($roomId, $getDate, $utilityType) ? utilityAmount2($roomId, $getDate, $utilityType)['u_paid_by'] : "";

                  if (!$amount) {

                    continue;

                  }

                  ?>

                  <tr>

                    <th scope="row"><?php echo ++$no; ?></th>

                    <td><?php echo $rowUtilityType['uty_title']; ?></td>

                    <td>

                      <?php



                      if ($amount) {

                        echo "<a href='?pagecontent=utility_update&room=$roomId&date=$getDate&type=$utilityType&amount=$amount&paidBy=$paidBy'>RM " . $amount . "</a>";

                      } else {

                        if ($_SESSION['admin']) {

                          echo "<a href='?pagecontent=utility_update&room=$roomId&date=$getDate&type=$utilityType&amount=$amount&paidBy=$paidBy'><button class='btn btn-xs btn-primary'>Update</button></a>";

                        }

                      }

                      ?>



                      <?php switch ($paidBy) {

                        case 1:

                          echo "by OWNER";

                          $totalPaidByOWNER = $totalPaidByOWNER + $amount;

                          break;

                        case 2:

                          echo "by HOST";

                          $totalPaidByHOST = $totalPaidByHOST + $amount;

                          break;

                      } ?>

                    </td>

                  </tr>

                <?php } ?>



                <tr>

                  <th scope="row"><?php echo ++$no; ?></th>

                  <td>Total earned</td>

                  <td>

                    RM <?php echo $totalEarned; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row"><?php echo ++$no; ?></th>

                  <td>Total Utilities</td>

                  <td>

                    RM <?php echo $totalUtilities; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row"><?php echo ++$no; ?></th>

                  <td>Utilities paid by OWNER</td>

                  <td>

                    RM <?php echo $totalPaidByOWNER; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row"><?php echo ++$no; ?></th>

                  <td>Utilities paid by HOST</td>

                  <td>

                    RM <?php echo $totalPaidByHOST; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row"><?php echo ++$no; ?></th>

                  <td>Profit after utilities</td>

                  <td>

                    RM <?php echo $totalAfterUtilities = $totalEarned - $totalUtilities; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row"><?php echo ++$no; ?></th>

                  <td>OWNER Profit (60%)</td>

                  <td>

                    RM <?php echo $totalAfterUtilities * 0.6; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row"><?php echo ++$no; ?></th>

                  <td>HOST Profit (40%)</td>

                  <td>

                    RM <?php echo $totalProfitHost = $totalAfterUtilities * 0.4; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row"><?php echo ++$no; ?></th>

                  <td>HOST Profit + Utilities paid by HOST</td>

                  <td>

                    RM <?php echo $totalProfitHost = $totalProfitHost + $totalPaidByHOST; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row"><?php echo ++$no; ?></th>

                  <td>HOST Profit after DIRECT deduct (RM<?php echo $totalDirect; ?>)</td>

                  <td>

                    RM <?php echo $totalProfitHost = $totalProfitHost - $totalDirect; ?>

                  </td>

                </tr>

                <tr>

                  <th scope="row"><?php echo ++$no; ?></th>

                  <th>Amount OWNER to bank in to HOST</th>

                  <th>

                    RM <?php echo $totalProfitHost; ?>

                  </th>

                </tr>



              </tbody>

            </table>



          </div>

        </div>

      </div>



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

        <div class="x_panel">

          <div class="x_title">

            <h2>Reservation List for <?php echo date("F Y", strtotime($getDate)); ?>



              <?php if ($_SESSION['admin']) { ?>

                <a href="?pagecontent=reservations&room=<?php echo $roomId; ?>&month=<?php echo $getDate; ?>"><button

                    class="btn btn-xs btn-primary">More Report</button></a>

              <?php } ?>



            </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="#">More Report</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">



            <table class="table table-striped">

              <thead>

                <tr>

                  <th>#</th>

                  <th>Reservation No</th>

                  <th>Guest</th>

                  <th>Date</th>

                  <th>Platform</th>

                  <th>Night</th>

                  <th>Amount / Imported</th>

                  <th>Clearance</th>

                </tr>

              </thead>

              <tbody>

                <?php $no = 0;

                $dateStart = $getDate;

                $dateEnd = date('Y-m-31', strtotime($getDate));

                $result = mysqli_query($conn, "SELECT * FROM reservation WHERE rv_ci_date BETWEEN '$dateStart' AND '$dateEnd' AND r_id=$roomId ORDER BY rv_ci_date ASC");

                while ($row = mysqli_fetch_assoc($result)) { ?>

                  <tr style="<?php if ($row['rv_status'] == 1) {

                    echo "background-color:#FFD5CC;";

                  } ?>)">

                    <th scope="row"><?php echo ++$no; ?></th>

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

                    <td><a

                        href="?pagecontent=reservation_update&id=<?php echo $row['rv_id']; ?>&redirect=<?php echo urlencode('?pagecontent=reservations&room=' . $roomId . '&month=' . $dateStart); ?>"><?php echo $row['rv_guest']; ?></a>

                    </td>

                    <td><a

                        href="?pagecontent=reservations&date=<?php echo $row['rv_ci_date']; ?>"><?php echo $row['rv_ci_date']; ?></a>

                    </td>

                    <td><?php echo platformTitle($row['rv_platform']); ?></td>

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

                    <?php if ($row['rv_total'] != $row['rv_total_by_import']) {

                      $setStyle = "color:red; font-weight:bold;";

                    } ?>

                    <td style="<?php echo $setStyle; ?>">RM <?php echo $row['rv_total']; ?> / RM

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

                    <?php $setStyle = ''; ?>

                    <td><a href="?pagecontent=reservation_view&id=<?php echo $row['rv_id']; ?>">RM

                        <?php echo totalPaid($row['rv_id'])['totalPaid']; ?></a></td>

                  </tr>

                <?php } ?>

              </tbody>

            </table>



          </div>

        </div>

      </div>



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

        <div class="x_panel">

          <div class="x_title">

            <h2>Expenses List for <?php echo date("F Y", strtotime($getDate)); ?>



            </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="#">More Report</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">



            <table class="table table-striped">

              <thead>

                <tr>

                  <th>#</th>

                  <th>Title</th>

                  <th>Amount</th>

                </tr>

              </thead>

              <tbody>

                <?php $no = 0;

                $dateStart = $getDate;

                $dateEnd = date('Y-m-31', strtotime($getDate));



                $result = mysqli_query($conn, "SELECT * FROM room_expenses WHERE re_date BETWEEN '$dateStart' AND '$dateEnd' AND r_id=$roomId ORDER BY re_date DESC, re_id DESC");



                while ($row = mysqli_fetch_assoc($result)) { ?>

                  <tr>

                    <th scope="row"><?php echo ++$no; ?></th>

                    <td><?php echo urldecode($row['re_title']); ?></td>

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

                  </tr>

                <?php } ?>

              </tbody>

            </table>



          </div>

        </div>

      </div>



    </div>

  </div>

</div>

<!-- /page content -->