<?php
declare(strict_types=1);
ini_set('display_errors','0');
header('Cache-Control: private, no-store, max-age=0');
require_once __DIR__.'/../includes/console_shell.php';
require_login();
$pageLink='salary-config/salary-configuration-report.php';
require_acl('can_view',$pageLink);
require_once __DIR__.'/salary-configuration-report-common.php';

$errors=[];
$access=gsr_access($con);
$options=scr_options($con,$access);
$filters=scr_filters($con,$access,$options,$errors);
$data=$errors?['employees'=>[],'components'=>[],'details'=>[],'componentNames'=>[]]:scr_report($con,$access,$filters);
$query=scr_query($filters);
console_header('Salary Configuration Results',$pageLink);
?>
<div class="mb-6">
  <div class="mb-2 flex items-center gap-2 text-xs font-semibold text-slate-500"><a href="/dashboard.php">Dashboard</a><i class="fa-solid fa-chevron-right text-[9px]"></i><span>Salary Config</span><i class="fa-solid fa-chevron-right text-[9px]"></i><a href="/salary-config/pay-scales.php">Pay Scale Master</a><i class="fa-solid fa-chevron-right text-[9px]"></i><span class="text-brand-600">Salary Configuration Results</span></div>
  <div class="flex flex-wrap items-end justify-between gap-4"><div><h1 class="text-2xl font-bold text-slate-900">Salary Configuration Results</h1><p class="mt-1 text-sm text-slate-500">Review employee Pay Scale component configurations.</p></div><div class="flex flex-wrap gap-2"><a href="/salary-config/salary-configuration-report-filter.php<?=$query?'?'.$query:''?>" class="rounded-xl bg-brand-600 px-6 py-3 text-sm font-bold text-white"><i class="fa-solid fa-plus mr-2"></i>Add</a><a target="_blank" href="/salary-config/salary-configuration-report-print.php?<?=$query?>" class="rounded-xl bg-slate-900 px-6 py-3 text-sm font-bold text-white"><i class="fa-solid fa-print mr-2"></i>Print</a><a href="/salary-config/salary-configuration-report-export.php?<?=$query?>" class="rounded-xl bg-emerald-600 px-6 py-3 text-sm font-bold text-white"><i class="fa-solid fa-file-excel mr-2"></i>Export to XLS</a></div></div>
</div>
<?php if($errors):?><div class="mb-5 rounded-xl border border-red-100 bg-red-50 px-5 py-4 text-sm font-semibold text-red-700"><?=h(implode(' ',$errors))?></div><?php endif;?>
<section class="overflow-hidden rounded-2xl border border-slate-100 bg-white shadow-sm"><div class="border-b border-slate-100 px-6 py-5"><h2 class="text-lg font-bold text-slate-800">Salary Configuration Report</h2><p class="mt-1 text-sm text-slate-400"><?=count($data['employees'])?> matching employees</p></div><?php scr_render_table($data);?></section>
<?php console_footer();
