<?php

$edited = can_action('24', 'edited');
$deleted = can_action('24', 'deleted');
?>

<div class="rounded-2xl border border-border bg-card shadow-sm">
	<div class="flex items-center justify-between border-b border-border px-5 py-4">
		<div>
			<h4 class="text-sm font-semibold text-foreground"><?= lang('bank_information') ?></h4>
			<p class="mt-1 text-xs text-muted-foreground"><?= lang('bank') . ' ' . lang('details') . ' ' . lang('for') . ' ' . html_escape($profile_info->fullname) ?></p>
		</div>
		<?php if (!empty($edited)) { ?>
			<?= btn_modal(
				'admin/user/new_bank/' . $profile_info->user_id,
				lang('update'),
				'',
				'md',
				'',
				array('class' => 'text-xs font-semibold text-primary hover:underline')
			) ?>
		<?php } ?>
	</div>

	<div class="p-5">
		<?php $all_bank_info = get_result('tbl_employee_bank', array('user_id' => $profile_info->user_id)); ?>
		<?php if (!empty($all_bank_info)) { ?>
			<div class="overflow-x-auto rounded-xl border border-border">
				<table class="w-full min-w-[720px] divide-y divide-border">
					<thead class="bg-muted/30">
						<tr class="text-left text-xs uppercase tracking-wide text-muted-foreground">
							<th class="px-4 py-3"><?= lang('bank') ?></th>
							<th class="px-4 py-3"><?= lang('name_of_account') ?></th>
							<th class="px-4 py-3"><?= lang('routing_number') ?></th>
							<th class="px-4 py-3"><?= lang('account_number') ?></th>
							<th class="px-4 py-3 hidden-print text-right"><?= lang('action') ?></th>
						</tr>
					</thead>
					<tbody class="divide-y divide-border bg-card">
						<?php foreach ($all_bank_info as $v_bank_info) { ?>
							<tr class="text-sm text-foreground">
								<td class="px-4 py-3 font-medium"><?= html_escape($v_bank_info->bank_name) ?></td>
								<td class="px-4 py-3"><?= html_escape($v_bank_info->account_name) ?></td>
								<td class="px-4 py-3 font-mono text-xs"><?= html_escape($v_bank_info->routing_number) ?></td>
								<td class="px-4 py-3 font-mono text-xs"><?= html_escape($v_bank_info->account_number) ?></td>
								<td class="px-4 py-3 hidden-print">
									<div class="flex justify-end">
										<?php if (!empty($edited)) { ?>
											<?= btn_modal(
												'admin/user/new_bank/' . $v_bank_info->user_id . '/' . $v_bank_info->employee_bank_id,
												'',
												lang('edit'),
												'md',
												'square-pen',
												array('class' => 'inline-flex h-7 w-8 rounded-lg items-center justify-center btn-primary')
											) ?>
										<?php } ?>
										<?php if (!empty($deleted)) { ?>
											<?= btn_delete('admin/user/delete_user_bank/' . $v_bank_info->user_id . '/' . $v_bank_info->employee_bank_id) ?>
										<?php } ?>
									</div>
								</td>
							</tr>
						<?php } ?>
					</tbody>
				</table>
			</div>
		<?php } else { ?>
			<div class="rounded-xl border border-dashed border-border bg-muted/20 px-4 py-8 text-center text-sm text-muted-foreground">
				<?= lang('nothing_to_display') ?>
			</div>
		<?php } ?>
	</div>
</div>
