<?php
declare(strict_types=1);ini_set('display_errors','0');header('Cache-Control: private, no-store, no-cache, must-revalidate, max-age=0');header('Pragma: no-cache');
require_once __DIR__.'/../../includes/console_shell.php';require_login();$pageLink='reports/mis/daily-not-logged-out-report.php';require_acl('can_view',$pageLink);require_once __DIR__.'/daily-not-logged-out-report-common.php';date_default_timezone_set('Asia/Kolkata');
$errors=[];$rows=[];try{$scope=dnlo_scope($con);$options=dnlo_options($con,$scope);$filters=dnlo_filters($_GET);$errors=dnlo_validate($filters,$options);if(!$errors)$rows=dnlo_report($con,$filters,$scope);}catch(Throwable $e){$scope=$scope??['restricted'=>true,'terminals'=>[]];$options=$options??['shifts'=>[],'departments'=>[],'locations'=>[],'subbranches'=>[],'show_subbranch'=>false,'company'=>APP_NAME,'export'=>false];$filters=dnlo_filters($_GET);$errors[]='Unable to generate the Daily Not Logged Out Report.';}
$more=$filters['shift']||$filters['department']||$filters['branch']||$filters['terminal']||$filters['subbranch'];$input='mt-1 w-full rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm outline-none focus:border-brand-500 focus:ring-2 focus:ring-brand-100';$sel=fn($a,$b)=>$a==$b?'selected':'';console_header('Daily Not Logged Out Report',$pageLink);?>
<div class="mb-6"><div class="mb-2 flex items-center gap-2 text-xs font-semibold text-slate-500"><span>Reports</span><i class="fa-solid fa-chevron-right text-[9px]"></i><span>MIS Report</span><i class="fa-solid fa-chevron-right text-[9px]"></i><span class="text-brand-600">Daily Not Logged Out Report</span></div><h1 class="text-2xl font-bold text-slate-900">Daily Not Logged Out Report</h1><p class="mt-1 text-sm text-slate-500">Employees whose selected-day attendance record has no logout.</p></div>
<?php foreach($errors as$e):?><div class="mb-4 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm font-semibold text-red-700"><?=h($e)?></div><?php endforeach;?>
<form method="get" id="dnlo-form" class="no-print mb-6 rounded-2xl border border-slate-200 bg-white p-5 shadow-sm"><div class="grid gap-4 md:grid-cols-2 xl:grid-cols-5"><label class="text-sm font-bold">Date<input required type="date" name="filter_date" value="<?=h($filters['date'])?>" class="<?=$input?>"></label></div><div class="mt-4 flex flex-wrap items-center justify-between gap-3"><button type="button" id="dnlo-more" class="rounded-lg border border-slate-200 px-4 py-2.5 text-sm font-bold"><i class="fa-solid fa-sliders mr-2"></i><span><?=$more?'Hide Additional Filters':'Use Additional Filters'?></span></button><div class="flex flex-wrap gap-2"><button class="rounded-lg bg-red-500 px-5 py-2.5 text-sm font-bold text-white"><i class="fa-solid fa-filter mr-2"></i>Go</button><button formaction="/reports/mis/daily-not-logged-out-report-print.php" formtarget="_blank" class="rounded-lg bg-red-500 px-5 py-2.5 text-sm font-bold text-white"><i class="fa-solid fa-print mr-2"></i>Print</button><?php if($options['export']):?><button formaction="/reports/mis/daily-not-logged-out-report-export.php" class="rounded-lg bg-emerald-600 px-5 py-2.5 text-sm font-bold text-white"><i class="fa-solid fa-file-excel mr-2"></i>Export to XLS</button><?php endif;?></div></div><div id="dnlo-extra" class="mt-4 <?=$more?'':'hidden'?> border-t border-slate-100 pt-4"><div class="grid gap-4 md:grid-cols-2 xl:grid-cols-5"><label class="text-sm font-bold">Select Shift<select name="filter_shift" class="<?=$input?>"><option value="0">-All-</option><?php foreach($options['shifts']as$o):?><option value="<?=$o['id']?>" <?=$sel($filters['shift'],$o['id'])?>><?=h($o['name'])?></option><?php endforeach;?></select></label><label class="text-sm font-bold">Select Department<select name="filter_dept" class="<?=$input?>"><option value="0">-All-</option><?php foreach($options['departments']as$o):?><option value="<?=$o['id']?>" <?=$sel($filters['department'],$o['id'])?>><?=h($o['name'])?></option><?php endforeach;?></select></label><label class="text-sm font-bold">Branch Location<select name="filter_branchlocation" class="<?=$input?>"><option value="0">Select Location</option><?php foreach($options['locations']as$o):?><option value="<?=$o['id']?>" <?=$sel($filters['branch'],$o['id'])?>><?=h($o['name'])?></option><?php endforeach;?></select></label><label class="text-sm font-bold">Select Terminal Location<select name="filter_orglocation" class="<?=$input?>"><option value="0">-All-</option><?php foreach($options['locations']as$o):?><option value="<?=$o['id']?>" <?=$sel($filters['terminal'],$o['id'])?>><?=h($o['name'])?></option><?php endforeach;?></select></label><?php if($options['show_subbranch']):?><label class="text-sm font-bold">Sub Branch Location<select name="filt_subbranch" class="<?=$input?>"><option value="0">-Select Location-</option><?php foreach($options['subbranches']as$o):?><option value="<?=$o['id']?>" <?=$sel($filters['subbranch'],$o['id'])?>><?=h($o['name'])?></option><?php endforeach;?></select></label><?php endif;?></div></div></form>
<section class="overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm"><div class="p-5 text-center"><b><?=h((string)$options['company'])?></b><h2 class="text-lg font-bold">Daily Not Logged Out Report</h2><div class="mt-1 text-sm font-semibold text-slate-500">Date: <?=h(date('d-m-Y',strtotime($filters['date'])))?></div></div><?php dnlo_render($rows);?></section>
<script>const b=document.getElementById('dnlo-more'),x=document.getElementById('dnlo-extra'),f=document.getElementById('dnlo-form');b?.addEventListener('click',()=>{const o=x.classList.contains('hidden');x.classList.toggle('hidden');b.querySelector('span').textContent=o?'Hide Additional Filters':'Use Additional Filters';});f?.querySelectorAll('input,select').forEach(el=>el.addEventListener('change',()=>document.querySelector('section')?.classList.add('hidden')));</script><?php console_footer();
