<?php
require_once __DIR__ . '/includes/settings_helpers.php';
settings_require_auth();
settings_ensure_tables($conn);
settings_get_current_org($conn);
$tab = trim((string) ($_GET['tab'] ?? 'fbp'));
$validTabs = ['fbp' => 'Flexible Benefit Plan', 'reimbursement' => 'Reimbursement Claims', 'it_declaration' => 'Income Tax Declaration', 'poi' => 'Proof Of Investments'];
if (!isset($validTabs[$tab])) {
    $tab = 'fbp';
}
?>
<!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>Claims and Declarations | 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>
    .claim-tabs{display:flex;gap:34px;border-bottom:1px solid var(--border);margin-bottom:24px;flex-wrap:wrap;}
    .claim-tabs a{padding:0 0 14px;color:#2563eb;text-decoration:none;font-size:16px;}
    .claim-tabs a.active{color:#111827;border-bottom:3px solid #3b82f6;font-weight:600;}
    .hero-card{max-width:1140px;border:1px solid var(--border);border-radius:16px;background:#fff;min-height:430px;padding:42px 38px;text-align:center;display:flex;align-items:center;justify-content:center;}
    .hero-ill{font-size:120px;color:#c7d2fe;margin-bottom:18px;line-height:1;}
    .hero-title{font-size:22px;font-weight:700;margin-bottom:14px;}
    .hero-copy{max-width:840px;margin:0 auto;font-size:16px;line-height:1.6;color:#374151;}
    .outline-btn{display:inline-flex;align-items:center;justify-content:center;border:1px solid #c8ccd6;border-radius:10px;background:#fff;color:#111827;text-decoration:none;padding:12px 16px;font-size:15px;font-weight:500;margin-top:24px;}
    .info-copy{font-size:16px;line-height:1.65;color:#111827;max-width:1100px;margin-bottom:16px;}
    .help-line{display:flex;gap:10px;align-items:flex-start;color:#374151;font-size:15px;line-height:1.55;margin-bottom:10px;}
    .help-line a{color:#2563eb;text-decoration:none;}
    .subtle-rule{border-top:1px solid var(--border);margin:26px 0;padding-top:24px;}
    .checks{display:grid;gap:16px;max-width:820px;}
    .checks label{display:grid;grid-template-columns:18px 1fr;gap:12px;align-items:start;font-size:15px;line-height:1.5;}
    .checks input{width:20px;height:20px;accent-color:#3b82f6;margin-top:2px;}
    .month-row{display:grid;grid-template-columns:minmax(0,1fr) 240px;gap:28px;align-items:center;max-width:1040px;}
    .month-box select{width:100%;height:50px;border:1px solid #d7dce7;border-radius:10px;padding:0 14px;font-size:15px;background:#fff;}
    .pill-link{display:inline-flex;align-items:center;gap:10px;background:#eff6ff;color:#2563eb;text-decoration:none;padding:12px 16px;border-radius:999px;font-size:15px;}
    .top-right{display:flex;justify-content:flex-end;margin-bottom:12px;}
  </style>
</head>
<body class="orgprofile-page">
  <?php settings_render_header($_SESSION['org_name'] ?? 'demo', 'dashboard.php', 'fa-file-circle-check'); ?>
  <main class="profile-layout">
    <?php settings_render_sidebar('claims_declarations'); ?>
    <section class="profile-main">
      <div class="profile-head"><h1>Claims and Declarations</h1></div>
      <div class="profile-card">
        <div class="claim-tabs">
          <?php foreach ($validTabs as $tabKey => $label): ?>
            <a class="<?php echo $tabKey === $tab ? 'active' : ''; ?>" href="claims_declarations.php?tab=<?php echo urlencode($tabKey); ?>"><?php echo htmlspecialchars($label); ?></a>
          <?php endforeach; ?>
        </div>
        <?php if ($tab === 'fbp'): ?>
          <div class="hero-card"><div><div class="hero-ill"><i class="fa-regular fa-folder-open"></i></div><div class="hero-title">No Active FBP component</div><div class="hero-copy">Your organization does not have an active FBP component associated to an employee. Mark a reimbursement as FBP component under Settings &gt; Salary Components &gt; Reimbursements and associate it to the employee's salary.</div></div></div>
        <?php elseif ($tab === 'reimbursement'): ?>
          <div class="hero-card"><div><div class="hero-ill"><i class="fa-regular fa-file-lines"></i></div><div class="hero-title">No Active Reimbursement</div><div class="hero-copy">Employees can get tax exemptions on producing necessary bills. You can enable a reimbursement component under Settings &gt; Salary Components &gt; Reimbursements and associate it to the employee's salary.</div></div></div>
        <?php elseif ($tab === 'it_declaration'): ?>
          <div class="info-copy">Employees can declare their tax saving investments and expense details through the employee portal once you enable this option.</div>
          <div class="help-line"><span style="color:#fb923c;"><i class="fa-solid fa-circle-info"></i></span><span>Learn how to manage investment declarations. <a href="#">IT Declaration Help Document</a></span></div>
          <div class="help-line" style="padding-left:18px;border-left:2px solid #f4e5c1;margin-left:10px;"><span>Help your employees submit IT Declaration on time. <a href="#">Download and share</a> this IT Declaration ebook.</span></div>
          <div class="hero-card" style="min-height:380px;"><div><div class="hero-ill"><i class="fa-regular fa-folder-open"></i></div><div class="hero-title">IT Declaration is Locked</div><div class="hero-copy">You are yet to enable the submission of IT Declaration for your employees through their respective portals. Release IT Declaration or submit it on their behalf under Employees &gt; Employee profile &gt; Investments &gt; IT Declaration.</div><a class="outline-btn" href="#">Release IT Declaration</a></div></div>
          <div class="subtle-rule"><h2 style="font-size:18px;margin:0 0 18px;">Other Configurations</h2><div class="checks"><label><input type="checkbox" checked><span>Allow employees to switch tax regimes</span></label><label><input type="checkbox"><span>Allow TDS modification to exceed the current fiscal year's calculated tax amount <i class="fa-solid fa-circle-info" style="color:#9ca3af;"></i></span></label></div><div style="margin-top:24px;"><a class="save-btn" href="claims_declarations.php?tab=it_declaration">Save</a></div></div>
        <?php else: ?>
          <div class="top-right"><a class="pill-link" href="#"><i class="fa-solid fa-circle-info"></i> View Employees yet to submit POI</a></div>
          <div class="info-copy">Employees can submit the necessary supporting documents for their declared investments through the employee portal once you enable this option.</div>
          <div class="help-line"><span style="color:#fb923c;"><i class="fa-solid fa-circle-info"></i></span><span>Learn how to manage investment proofs. <a href="#">POI Help Document</a></span></div>
          <div class="help-line" style="padding-left:18px;border-left:2px solid #f4e5c1;margin-left:10px;"><span>Help your employees submit POI on time. <a href="#">Download and share</a> this POI ebook.</span></div>
          <div class="hero-card" style="min-height:440px;"><div><div class="hero-ill"><i class="fa-regular fa-folder-open"></i></div><div class="hero-title">POI is Locked</div><div class="hero-copy">You are yet to enable submission of investment proofs for your employees through their respective portals. Release POI or submit it on their behalf under Employees &gt; Employee profile &gt; Investments &gt; Proof of Investments.</div><a class="outline-btn" href="#">Release Proof Of Investments</a></div></div>
          <div class="subtle-rule">
            <div class="month-row">
              <div><h2 style="font-size:18px;margin:0 0 8px;">Process payroll with approved POI amount from</h2><div class="section-copy" style="color:#16a34a;">The approved POI amount will be considered for the payroll from <mark style="background:#fef3c7;">March</mark> onwards to calculate and deduct income tax amount in subsequent payrolls.</div></div>
              <div class="month-box"><select><option>March</option><option>April</option><option>May</option></select><div class="section-copy" style="margin-top:8px;">for upcoming years.</div></div>
            </div>
            <div class="subtle-rule" style="margin-top:28px;"><h2 style="font-size:18px;margin:0 0 18px;">Other Configurations</h2><div class="checks"><label><input type="checkbox" checked><span>Allow employees to switch tax regimes</span></label><label><input type="checkbox"><span>Allow TDS modification during Payroll</span></label><label><input type="checkbox"><span>Mandate investment proof attachments for POI submission</span></label><label><input type="checkbox"><span>Mandate reviewer comments for partial investment amount approval</span></label></div><div style="margin-top:24px;"><a class="save-btn" href="claims_declarations.php?tab=poi">Save</a></div></div>
          </div>
        <?php endif; ?>
      </div>
    </section>
  </main>
</body>
</html>

