<?php 
  include '../../connection.php';
$id = $_GET['page'];
  $query = "SELECT 
tbl_transaction.UniqueID,
tbl_transaction.resident_id,
tbl_transaction.respondent,
tbl_transaction.incident_address,
tbl_transaction.complaint_type_id,
tbl_transaction.description,
tbl_transaction.status,
tbl_transaction.incident_date,
tbl_transaction.date_created,
tbl_resident.first_name,
tbl_resident.middle_name,
tbl_resident.last_name
FROM `tbl_transaction` 
LEFT JOIN tbl_resident ON tbl_transaction.resident_id = tbl_resident.resident_id WHERE tbl_transaction.UniqueID = '$id'";
$query_result = $conn->query($query);
$row = $query_result->fetch_assoc();
?>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Summon Form</title>

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">

  <style>
    body {
      font-family: 'Times New Roman', Times, serif;
      background: #fff;
      color: #000;
      margin: 40px;
      line-height: 1.5;
      font-size: 16px;
    }

  /*  p {
      font-size: 16px;
      text-align: justify;
      margin-bottom: 0.5rem;
    }*/

    .table-borderless td {
      border: none !important;
    }

    hr {
      border-top: 3px solid #000;
      margin: 10px 0 25px 0;
    }

    .text-center p {
      text-align: center;
    }

    .signature-line {
      display: inline-block;
      border-bottom: 1px solid #000;
      width: 180px;
      margin-bottom: 5px;
    }

    @media print {
      body {
        margin: 20mm;
      }
      .btn, .no-print {
        display: none;
      }
    }
  </style>
</head>

<body>
<div class="container">
<!-- HEADER -->
<div class="row">
 <div class="col-2 text-right">
  <img src="../../images/logo.jfif" alt="Barangay Logo"
       style="height: 90px; width: 90px; object-fit: cover; display: block; margin-left: auto;">
</div>

  <div class="col-8 text-center">
          <!-- Header Text -->
 <p style="font-weight: bold; margin-bottom: 5px; line-height: 1.4;">
            Republic of the Philippines <br>
            Province of Sultan Kudarat <br>
            Municipality of President Quirino <br>
            <span style="font-size: 20px; text-transform: uppercase;">BARANGAY TUAL</span>
          </p>
          <p style="font-weight: bold; font-size: 17px; margin-top: 8px;">
            OFFICE OF THE LUPONG TAGAPAMAYAPA
          </p>
  </div>
</div>

  


<hr style="border-top: 3px solid #000; margin-top: 5px; margin-bottom: 25px;">


  <!-- CASE DETAILS -->
  <div class="row mb-3">
    <div class="col-8"></div>
    <div class="col-4">
      <p style="font-weight: bold;">
        Brgy. Case No.: 35-23 <br>
        For: Conference <br>
        Remarks: __________________
      </p>
    </div>
  </div>

  <!-- PARTIES -->
  <div class="row mb-3">
    <div class="col-12 text-left">
      <p><strong class="text-uppercase"><?= $row['last_name'] ?> , <?= $row['first_name'] ?> <?= $row['middle_name'] ?></strong><br>Complainant</p>
      <p class="text-center"><strong>— Against —</strong></p>
      <p><strong class="text-uppercase"><?= $row['respondent'] ?></strong><br>Respondent</p>
    </div>
  </div>

  <!-- SUMMONS -->
  <h5 class="text-center font-weight-bold mb-3">SUMMONS</h5>

  <p><strong>To: The Respondent</strong></p>
  <?php
  date_default_timezone_set('Asia/Manila'); // ✅ Set your timezone
// Get today's date or specify a date
$date = new DateTime(); // or new DateTime('2023-12-21');

// Extract parts
$day = $date->format('j');          // Day of the month (no leading zero)
$month = $date->format('F');        // Full month name (e.g. December)
$year = $date->format('Y');         // Year (e.g. 2023)

// Function to get ordinal suffix (st, nd, rd, th)
function getOrdinal($number) {
    if (!in_array(($number % 100), [11, 12, 13])) {
        switch ($number % 10) {
            case 1:  return 'st';
            case 2:  return 'nd';
            case 3:  return 'rd';
        }
    }
    return 'th';
}

// Combine into full format
$formatted_date = $day . getOrdinal($day) . " day of " . $month . ", " . $year;
$time = $date->format('h:i A');
$time = str_replace(['AM', 'PM'], ['A.M.', 'P.M.'], $time);
echo $formatted_date;
?>
  <p>
    You are hereby summoned to appear before me in person, together with your witnesses, 
    on the <strong><?=  $formatted_date ?></strong> at about 
    <strong><?= $time ?></strong> at the Barangay Hall, then and there to answer to a complaint 
    made before me, a copy of which is attached hereto, for mediation/conciliation of your dispute 
    with the complainant.
  </p>

  <p>
    You are hereby warned that if you refuse or willfully fail to appear in obedience to this summons, 
    <strong>FAIL NOT</strong> or else face punishment as for contempt of court.
  </p>

  <p>
    This <strong><?=  $formatted_date ?></strong> 
    at Tual, President Quirino, Sultan Kudarat.
  </p>

  <div class="text-right mt-4">
    <p><strong>ELMER S. JANOLINO</strong><br><small>Punong Barangay</small></p>
  </div>

  <!-- OFFICER'S RETURN -->
  <hr style="border-top: 2px dotted #000;">
  <p class="text-center font-weight-bold">OFFICER’S RETURN</p>

  <p>
    I served this summon upon respondent __________________ on the ____ day of _________, ____ by:
  </p>

  <p>_____________________ 1. Handing to him/them said summon/s in person</p>
  <p>_____________________ 2. Handing to him/them said summon/s and they refused to receive it</p>
  <p>_____________________ 3. Leaving said summons at his dwelling with __________________, 
     a person of suitable age and discretion residing therein</p>
  <p>_____________________ 4. Leaving said summons at his office/place of business with __________________, 
     a competent person in charge thereof.</p>

  <!-- SIGNATURE SECTION -->
  <div class="row mt-4">
    <div class="col-sm-6 text-center">
      <p><strong>Received by Respondent/s or Representative/s</strong></p>
      <p>________________ Signature</p>
      <p>________________ Signature</p>
      <p>________________ Signature</p>
      <p>________________ Signature</p>
      <p>________________ Signature</p>
    </div>
    <div class="col-sm-6 text-center">
      <p><strong>Officer</strong></p>
      <p>________________ Date</p>
      <p>________________ Date</p>
      <p>________________ Date</p>
      <p>________________ Date</p>
      <p>________________ Date</p>
    </div>
  </div>

</div>

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
<script>
  // window.print();
</script>
</body>
</html>
