<?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/additional-rate-configuration.php';
$acl=acl_for($pageLink);
if((int)(current_user()['role_id']??0)===1)$acl['can_view']=true;
if(empty($acl['can_view'])){http_response_code(403);exit('Access denied.');}
require_once __DIR__.'/additional-rate-configuration-common.php';
$errors=[];$access=gsr_access($con);$options=arc_options($con,$access);$filters=arc_filters($options,$errors);$rows=$errors?[]:arc_list($con,$access,$filters);
?><!doctype html><html><head><meta charset="utf-8"><title>Additional Rate Configuration</title><style>body{font:12px Arial;color:#172033;padding:20px}h1{text-align:center;font-size:22px}table{width:100%;border-collapse:collapse}th,td{border:1px solid #94a3b8;padding:8px;text-align:left}th{background:#f1f5f9;font-weight:700}.right{text-align:right}.error{color:#b91c1c}@media print{button{display:none}body{padding:0}}</style></head><body><button onclick="window.print()">Print</button><h1>Additional Rate Configuration List</h1><?php if($errors):?><p class="error"><?=h(implode(' ',$errors))?></p><?php else:?><table><thead><tr><?php foreach(['Sr No','Employee Name','OT / Allowance','Month','Year','Type','Amount'] as $heading):?><th class="<?=$heading==='Amount'?'right':''?>"><?=h($heading)?></th><?php endforeach;?></tr></thead><tbody><?php foreach($rows as $i=>$row):?><tr><td><?=$i+1?></td><td><?=h($row['employee_name'])?></td><td><?=h($row['component_name']??'-')?></td><td><?=h($row['month_name']??gsr_month_name($row['month']))?></td><td><?=h((string)$row['year'])?></td><td><?=h(arc_type_label((int)$row['s_type']))?></td><td class="right"><?=number_format((float)$row['grosspay'],2)?></td></tr><?php endforeach;?><?php if(!$rows):?><tr><td colspan="7" style="text-align:center">No records found.</td></tr><?php endif;?></tbody></table><script>window.addEventListener('load',()=>window.print())</script><?php endif;?></body></html>
