<?php
require_once __DIR__ . '/includes/settings_helpers.php';
settings_require_auth();
settings_ensure_tables($conn);
settings_get_current_org($conn);
$templates = [
    ['Payslip Notification', 'This email will be sent when you pay your employees.'],
    ['Payslip Notification (For Portal Disabled Employees Only)', ''],
    ['Off Cycle & One-Time Payrolls Payslip Notification', 'This email will be sent when you pay your employees through Off Cycle or One-Time Payrolls.'],
    ['Full & Final Settlement Payslip Notification', "This email will be sent once you process the employee's final settlement."],
];
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="<?php echo billing_escape(billing_base_href()); ?>">
  <title>Email Templates | Settings</title>
  <link rel="stylesheet" href="assets/fontawesome/css/all.min.css">
  <link rel="stylesheet" href="assets/font-inter.css">
  <link rel="stylesheet" href="orgprofile.css">
  <style>
    .list-table{width:100%;border-collapse:collapse;margin-top:8px;}
    .list-table th,.list-table td{padding:20px 0;border-top:1px solid var(--border);text-align:left;vertical-align:middle;}
    .list-table th{font-size:13px;text-transform:uppercase;color:#111827;}
    .template-name{color:#2563eb;text-decoration:none;font-size:16px;font-weight:500;}
    .template-copy{margin-top:8px;font-size:15px;color:#374151;line-height:1.5;}
    .edit-ico{width:42px;height:42px;border-radius:50%;background:#f3f4f6;color:#6b7280;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;}
    .top-link{display:flex;justify-content:flex-end;margin-bottom:6px;}
    .top-link a{color:#2563eb;text-decoration:none;font-size:15px;}
  </style>
</head>
<body class="orgprofile-page">
  <?php settings_render_header($_SESSION['org_name'] ?? 'demo', 'dashboard.php', 'fa-envelope'); ?>
  <main class="profile-layout">
    <?php settings_render_sidebar('email_templates'); ?>
    <section class="profile-main">
      <div class="profile-head"><h1>Email Templates</h1></div>
      <div class="profile-card">
        <div class="top-link"><a href="sender_email_preferences.php"><i class="fa-solid fa-gear"></i> Configure Sender Email Preferences</a></div>
        <table class="list-table">
          <thead><tr><th>Template Type</th><th style="width:70px;"></th></tr></thead>
          <tbody>
            <?php foreach ($templates as $template): ?>
              <tr>
                <td>
                  <a class="template-name" href="#"><?php echo htmlspecialchars($template[0]); ?></a>
                  <?php if ($template[1] !== ''): ?><div class="template-copy"><?php echo htmlspecialchars($template[1]); ?></div><?php endif; ?>
                </td>
                <td><a class="edit-ico" href="#"><i class="fa-solid fa-pen"></i></a></td>
              </tr>
            <?php endforeach; ?>
          </tbody>
        </table>
      </div>
    </section>
  </main>
</body>
</html>

