<?php
/**
 * Header filter dropdown for Assign Stock list.
 *
 * NOTE: This partial is rendered into $header_filter_extras_html.
 */
?>

<div class="filtered relative" data-tooltip="<?php echo lang('filter_by'); ?>">
	<button type="button" class="stock_toggle inline-flex items-center gap-2 rounded-xl border border-border bg-card px-3 py-1.5 text-sm font-medium text-slate-600 transition-colors hover:bg-slate-50 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-200 dark:hover:bg-slate-800" aria-haspopup="true" aria-expanded="false">
		<i data-lucide="filter" class="h-4 w-4"></i>
		<?= lang('filter_by') ?>
	</button>
	<ul class="group_ absolute right-0 top-full z-50 mt-2 hidden w-[300px] rounded-2xl border border-border bg-white p-2 shadow-2xl dark:border-slate-700 dark:bg-slate-900">
		<li class="filter_by all_filter rounded-xl" data-filter-id="" data-search-type="">
			<a href="#" class="block rounded-xl px-3 py-2 text-sm text-slate-700 hover:bg-slate-50 dark:text-slate-200 dark:hover:bg-slate-800"><?php echo lang('all'); ?></a>
		</li>
		<li class="my-1 border-t border-border dark:border-slate-700"></li>
		<li class="space-y-1 rounded-xl" id="by_item_name">
			<a href="#" tabindex="-1" class="block rounded-xl px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50 dark:text-slate-200 dark:hover:bg-slate-800"><?php echo lang('by') . ' ' . lang('item_name'); ?></a>
			<ul class="by_item_name max-h-40 space-y-1 overflow-y-auto rounded-xl border border-border bg-slate-50 p-1 dark:border-slate-700 dark:bg-slate-800/40">
				<?php $all_items = get_result('tbl_stock');
				if (!empty($all_items)) { ?>
					<?php foreach ($all_items as $v_items) { ?>
						<li class="filter_by rounded-lg" data-filter-id="<?= $v_items->stock_id ?>" data-search-type="by_item_name">
							<a href="#" class="block rounded-lg px-3 py-2 text-xs text-slate-700 hover:bg-white dark:text-slate-200 dark:hover:bg-slate-900"><?php echo $v_items->item_name; ?></a>
						</li>
					<?php } ?>
				<?php } ?>
			</ul>
		</li>
		<li class="mt-2 space-y-1 rounded-xl" id="by_employee">
			<a href="#" tabindex="-1" class="block rounded-xl px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50 dark:text-slate-200 dark:hover:bg-slate-800"><?php echo lang('by') . ' ' . lang('employee') . ' ' . lang('name'); ?></a>
			<ul class="by_employee max-h-40 space-y-1 overflow-y-auto rounded-xl border border-border bg-slate-50 p-1 dark:border-slate-700 dark:bg-slate-800/40">
				<?php if (!empty($all_employee)) { ?>
					<?php foreach ($all_employee as $dept_name => $v_all_employee) {
						if (!empty($v_all_employee)) {
							foreach ($v_all_employee as $v_employee) { ?>
								<li class="filter_by rounded-lg" data-filter-id="<?= $v_employee->user_id ?>" data-search-type="by_employee">
									<a href="#" class="block rounded-lg px-3 py-2 text-xs text-slate-700 hover:bg-white dark:text-slate-200 dark:hover:bg-slate-900"><?php echo $v_employee->fullname . ' ( ' . $v_employee->designations . ' )'; ?></a>
								</li>
							<?php } ?>
						<?php } ?>
					<?php } ?>
				<?php } ?>
			</ul>
		</li>
	</ul>
</div>
