<?php
session_start();
require('app/functions.php');

?>






<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="bootstrap-5.2.2-dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script src="bootstrap-5.2.2-dist/js/bootstrap.bundle.min.js"></script>
  <script src="js/index.js"></script>
  <!-- <link href="css/index.css" rel="stylesheet"> -->
  <link rel="stylesheet" href="css/monitor-header.css">
  <style>


  </style>


  <title></title>
</head>

<body>
  <div class="header-white-color">
  </div>
  <div class="header-container">
    <a href="https://platinumkaraoke.com">
      <img class="header-logo" src="img/PlatinumNewLogowhite.png" alt=""></a>
  </div>

  <div class="container ">
    <!-- <img src="img/pk gray.png" class="bg-body"> -->
    <div class="watermark-container">
      <img class="watermark" src="img/pk gray.png" alt="">
    </div>
    <div class="body-layout">



      <div class="h1">
        <h1>
          Repair Service Monitoring
        </h1>
      </div>



      <form method="Post" role="form" class="form-horizontal">
        <div class="para-1">
          <p> Please enter the service form reference number below and click <label for="search">"Search"</label>. </p>
        </div>


        <div class="para-2">
          <p> The service form reference number can be found in your receipt.</p>
        </div>
        <div class="para-3">
          <p class="p-ref-num"> Repair Order Form Reference Number: <br>
            <span>(Example: 10357)</span>
          </p>
        </div>
        <div class="search-button-container">

          <input class="search-reference" type="text" name="search" id="search" for="submit" placeholder="Reference Number" autofocus>
          <button class="search-button" id="submit" name="submit">Search</button>
        </div>
      </form>



      <div class="php-query">
        <div class="table-grid">
          <?php

          // connecting to database
          require('app/config.php');
          $search = filter_input(INPUT_POST, 'search', FILTER_VALIDATE_INT);
          if (empty($search)) {
            die();
          }
          if (is_post()) {
            $query = "Select * from tbl_service_monitor where ref_no = $search";
            $result = mysqli_query($connection, $query);
            if (!$result) {
              die("Retrieving Query Error" . $query);
            }
            $record = mysqli_num_rows($result);

            if ($record < 1) {
              echo '<span style="color:red;">no result(s) found!</span>';
            } else {
              // echo $record; 
              while ($row = mysqli_fetch_array($result)) : ?>
                <table class="table table-striped">
                  <thead>
                    <tr>
                      <th colspan="2">
                        <div class="form-group d-flex justify-content-center">
                          <h2>Customer Record</h2>
                        </div>
                      </th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td><strong>Full Name : </strong></td>
                      <td style="color: #20B944;font-weight: bold">
                        <?= $row['customer_name'] ?>
                      </td>
                    </tr>
                    <tr>
                      <td><strong>Reference Number : </strong></td>
                      <td style="color: #20B944;font-weight: bold">
                        <?= $row['ref_no'] ?>
                      </td>
                    </tr>
                    <tr>
                      <td><strong>Date Received : </strong></td>
                      <td style="color: #20B944;font-weight: bold">
                        <?= $row['date_received'] ?>
                      </td>
                    </tr>
                    <tr>
                      <td><strong>Item Status : </strong></td>
                      <td style="color: #20B944;font-weight: bold">
                        <?= $row['status'] ?>
                      </td>
                    </tr>

                  </tbody>
                </table>
          <?php endwhile;
            }
          } ?>
        </div>
      </div>



      <!-- footer -->
    </div>
  </div>
</body>

</html>