<?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();require_acl('can_view','reports/attendance/daily-status-report.php');require_once __DIR__.'/daily-status-report-common.php';try{$o=dsr_options($con);$f=dsr_filters($_GET);$e=dsr_validate($f,$o);if($e){http_response_code(400);exit('Invalid report filters.');}$rows=dsr_report($con,$f);}catch(Throwable $x){http_response_code(500);exit('Unable to generate export.');}function dsx($v):string{$v=(string)$v;if(preg_match('/^[=+\-@]/',$v))$v="'".$v;return h($v);}header('Content-Type: application/vnd.ms-excel; charset=UTF-8');header('Content-Disposition: attachment; filename="Daily Status Report.xls"');header('X-Content-Type-Options: nosniff');echo "\xEF\xBB\xBF";?><html><head><meta charset="utf-8"></head><body><h2>Daily Status Report - Dated on <?=dsx(date('d-m-Y',strtotime($f['date'])))?></h2><table border="1"><thead><tr><?php foreach(['Sr No','Employee Name','Designation','Branch','Schedule Shift','Total Working Hrs.','Present Working Hrs.','Total Hrs.','Extra/Lost hrs','Status','Late Mark']as$h):?><th><?=dsx($h)?></th><?php endforeach;?></tr></thead><tbody><?php foreach($rows as$i=>$r):?><tr><td><?=$i+1?></td><td><?=dsx($r['employee']['name'])?></td><td><?=dsx($r['employee']['designation_name']?:$r['employee']['designation'])?></td><td><?=dsx($r['employee']['branch_name'])?></td><td><?=dsx($r['schedule']?($r['schedule']['shift_type']?:$r['schedule']['shortname']):'Not assigned')?></td><td><?=dsx(dal_hhmm($r['scheduled']))?></td><td><?=dsx(implode(' / ',$r['punches']))?></td><td><?=dsx(dal_hhmm($r['worked']))?></td><td><?=dsx($r['extra']?'E : + '.dal_hhmm($r['extra']):($r['loss']?'L : - '.dal_hhmm($r['loss']):'-'))?></td><td><?=dsx($r['status'])?></td><td><?=dsx(($r['late']?dal_hhmm($r['late']):'-').($r['approved']?' LM approval':''))?></td></tr><?php endforeach;?></tbody></table></body></html>
