<?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/mis/monthly-not-logged-out-report.php');require_once __DIR__.'/monthly-not-logged-out-report-common.php';date_default_timezone_set('Asia/Kolkata');try{if(!mnlo_export_enabled($con)){http_response_code(403);exit('Export is not enabled.');}$scope=dnlo_scope($con);$options=mnlo_options($con,$scope);$filters=mnlo_filters($_GET);$errors=mnlo_validate($filters,$options);if($errors){http_response_code(400);exit('Invalid report filters.');}$rows=mnlo_report($con,$filters,$scope);}catch(Throwable $e){http_response_code(500);exit('Unable to generate export.');}function mnlox($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="Monthly Not Loggedout Report.xls"');header('X-Content-Type-Options:nosniff');echo"\xEF\xBB\xBF";?><html><head><meta charset="utf-8"></head><body><h2><?=mnlox($options['company'])?></h2><h3>Monthly Not Loggedout Report - <?=mnlox(date('d-m-Y',strtotime($filters['from'])))?> to <?=mnlox(date('d-m-Y',strtotime($filters['to'])))?></h3><table border="1"><thead><tr><th>Sr No</th><th>Employee Name</th><th>Date</th><th>Not Logged Out Count</th></tr></thead><tbody><?php foreach($rows as$i=>$r):?><tr><td><?=$i+1?></td><td><?=mnlox($r['name'])?></td><td><?=mnlox(implode(' / ',array_map(fn($d)=>date('d',strtotime((string)$d)),$r['dates'])))?></td><td><?=(int)$r['missing_count']?></td></tr><?php endforeach;?></tbody></table></body></html>
