<?php
if(!isset($options,$record,$errors,$formTitle,$submitLabel))exit;
$input='mt-2 w-full rounded-xl border border-slate-200 bg-white px-4 py-3 text-sm font-semibold text-slate-700 outline-none focus:border-brand-500 focus:ring-4 focus:ring-brand-100';
?>
<?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"><i class="fa-solid fa-circle-exclamation mr-2"></i><?=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"><?=$formTitle?></h2><p class="mt-1 text-sm text-slate-400">Fields and sequence follow the legacy monthly earning configuration.</p></div>
  <form method="post" class="grid gap-5 p-6 md:grid-cols-2 xl:grid-cols-6">
    <input type="hidden" name="_csrf" value="<?=h(csrf_token())?>">
    <label class="text-sm font-bold text-slate-700">Employee Name <span class="text-red-500">*</span><select required name="empid" class="<?=$input?>"><option value="">Select Employee</option><?php foreach($options['employees'] as $o):?><option value="<?=(int)$o['id']?>" <?=(int)($record['empid']??0)===(int)$o['id']?'selected':''?>><?=h($o['name'])?></option><?php endforeach;?></select></label>
    <label class="text-sm font-bold text-slate-700">Month <span class="text-red-500">*</span><select required name="month" class="<?=$input?>"><option value="">Select Month</option><?php foreach($options['months'] as $o):?><option value="<?=(int)$o['id']?>" <?=(int)($record['month']??0)===(int)$o['id']?'selected':''?>><?=h($o['name'])?></option><?php endforeach;?></select></label>
    <label class="text-sm font-bold text-slate-700">Year <span class="text-red-500">*</span><select required name="year" class="<?=$input?>"><option value="">Select Year</option><?php foreach($options['years'] as $o):?><option value="<?=(int)$o['id']?>" <?=(int)($record['year']??0)===(int)$o['id']?'selected':''?>><?=h($o['name'])?></option><?php endforeach;?></select></label>
    <label class="text-sm font-bold text-slate-700">OT / Allowance <span class="text-red-500">*</span><select required name="type" class="<?=$input?>"><option value="">Select Deduction Type</option><?php foreach($options['components'] as $o):?><option value="<?=(int)$o['id']?>" <?=(int)($record['component']??0)===(int)$o['id']?'selected':''?>><?=h($o['name'])?></option><?php endforeach;?></select></label>
    <label class="text-sm font-bold text-slate-700">Select Type <span class="text-red-500">*</span><select required name="s_type" class="<?=$input?>"><option value="">Select Type</option><?php foreach($options['types'] as $o):?><option value="<?=(int)$o['id']?>" <?=(int)($record['s_type']??0)===(int)$o['id']?'selected':''?>><?=h($o['name'])?></option><?php endforeach;?></select></label>
    <label class="text-sm font-bold text-slate-700">Amount <span class="text-red-500">*</span><input required type="number" min="0" step="0.01" name="grosspay" value="<?=h((string)($record['grosspay']??''))?>" class="<?=$input?>"></label>
    <div class="flex gap-3 md:col-span-2 xl:col-span-6"><button class="rounded-xl bg-brand-600 px-7 py-3 text-sm font-bold text-white"><i class="fa-solid fa-floppy-disk mr-2"></i><?=$submitLabel?></button><a href="/salary-config/additional-rate-configuration.php" class="rounded-xl border border-slate-200 px-7 py-3 text-sm font-bold text-slate-600">Cancel</a></div>
  </form>
</section>
