<?php
require_once 'includes/config.php';
require_once 'includes/functions.php';

session_start();
if (empty($_SESSION['authenticated'])) {
    header("Location: signin.php");
    exit();
}

require_once __DIR__ . '/db.php';

$result = $conn->query("SELECT * FROM organizations ORDER BY id DESC LIMIT 1");
$row = $result ? $result->fetch_assoc() : null;
$orgName = $_SESSION['org_name'] ?? ($row['organisation_name'] ?? 'demo');
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Salary Revision Letter</title>
  <link rel="stylesheet" href="salary_revision.css">
  <link rel="stylesheet" href="assets/font-inter.css">
  <link rel="stylesheet" href="assets/fontawesome/css/all.min.css">
</head>
<body class="sr-settings-page">
  <header class="sr-settings-top">
    <div class="sr-settings-brand">
      <div class="sr-settings-logo"><i class="fa-regular fa-file-lines"></i></div>
      <div>
        <div class="sr-settings-title">All Settings</div>
        <div class="sr-settings-sub"><?php echo htmlspecialchars($orgName); ?></div>
      </div>
    </div>
    <div class="sr-settings-search">
      <i class="fa-solid fa-magnifying-glass"></i>
      <input type="text" placeholder="Search settings ( / )">
    </div>
    <a class="sr-settings-close" href="salary_revision.php">Close Settings <span class="sr-close-x">×</span></a>
  </header>

  <div class="sr-settings-layout">
    <aside class="sr-settings-sidebar">
      <div class="sr-sidebar-group-title">Organisation Settings</div>
      <nav class="sr-settings-nav">
        <a class="sr-settings-link" href="orgprofile.php"><i class="fa-solid fa-chevron-right"></i>Organisation</a>
        <a class="sr-settings-link" href="#"><i class="fa-solid fa-chevron-right"></i>Users and Roles</a>
        <a class="sr-settings-link" href="#"><i class="fa-solid fa-chevron-right"></i>Taxes</a>
        <a class="sr-settings-link" href="#"><i class="fa-solid fa-chevron-right"></i>Setup &amp; Configurations</a>
      </nav>

      <div class="sr-settings-parent active"><i class="fa-solid fa-chevron-down"></i>Customisations</div>
      <div class="sr-settings-subnav">
        <a href="#">Email Templates</a>
        <a href="sender_email_preferences.php">Sender Email Preferences</a>
        <a href="salary_templates.php">Salary Templates</a>
        <a href="salary_revision_template.php" class="active">PDF Templates</a>
        <a href="reporting_tags.php">Reporting Tags</a>
      </div>

      <div class="sr-sidebar-group-title">Module Settings</div>
      <nav class="sr-settings-nav">
        <a class="sr-settings-link" href="#"><i class="fa-solid fa-chevron-right"></i>General</a>
        <a class="sr-settings-link" href="#"><i class="fa-solid fa-chevron-right"></i>Payments</a>
      </nav>
    </aside>

    <main class="sr-template-main">
      <aside class="sr-template-nav">
        <h2>PDF Templates</h2>
        <div class="sr-template-group-label">PAYSLIP</div>
        <a href="#">Regular Payslips</a>
        <a href="#">Final Settlement Payslip</a>
        <div class="sr-template-group-label">LETTER TEMPLATES</div>
        <a href="#">Salary Certificate</a>
        <a href="#" class="active">Salary Revision Letter</a>
        <a href="#">Bonus Letter</a>
      </aside>

      <section class="sr-template-panel">
        <h1>Salary Revision Letter</h1>
        <div class="sr-enable-banner">
          <div class="sr-enable-copy">
            <div class="sr-enable-icon"><i class="fa-regular fa-file-lines"></i></div>
            <div>
              <strong>Configure Salary Revision Letter Template</strong>
              <p>By configuring the Salary Revision Letter template, you can ensure that the Salary Revision Letter you send to your employees meet your organisational requirements.</p>
            </div>
          </div>
          <button class="sr-primary-btn" type="button">Enable Now</button>
        </div>

        <div class="sr-template-preview">
          <h3>Standard Template</h3>
          <div class="sr-preview-card">
            <div class="sr-preview-badge">Z</div>
            <div class="sr-preview-lines">
              <span class="w-40"></span>
              <span class="w-70"></span>
              <span class="w-100"></span>
              <span class="w-100"></span>
              <span class="w-90"></span>
              <span class="w-100"></span>
              <span class="w-100"></span>
              <span class="w-85"></span>
            </div>
            <div class="sr-preview-ribbon">DEFAULT</div>
          </div>
        </div>
      </section>
    </main>
  </div>
</body>
</html>
