<?= message_box('success'); ?>
<?= message_box('error'); ?>

<?php
$created = can_action('152', 'created');
$edited = can_action('152', 'edited');
$deleted = can_action('152', 'deleted');
?>

<div class="space-y-4">
	<div class="rounded-2xl border border-border bg-card shadow-sm">
		<div class="table-responsive p-4">
			<table class="table table-striped DataTables" id="DataTables" width="100%">
				<thead>
					<tr>
						<th><?= lang('reference_no') ?></th>
						<th><?= lang('supplier') ?></th>
						<th><?= lang('purchase_date') ?></th>
						<th><?= lang('due_amount') ?></th>
						<th><?= lang('status') ?></th>
						<th><?= lang('tags') ?></th>
						<?php $show_custom_fields = custom_form_table(20, null);
						if (!empty($show_custom_fields)) {
							foreach ($show_custom_fields as $c_label => $v_fields) {
								if (!empty($c_label)) {
						?>
						<th><?= $c_label ?> </th>
						<?php }
							}
						}
						?>
						<?php if (!empty($edited) || !empty($deleted)) { ?>
						<th class="col-options no-sort text-right"><?= lang('action') ?></th>
						<?php } ?>
					</tr>
				</thead>
				<tbody></tbody>
			</table>
		</div>
	</div>
</div>

<script>
	list = base_url + "admin/purchase/purchaseList";
	window.erpDatatablePreload = window.erpDatatablePreload || {};
	window.erpDatatablePreload.DataTables = window.erpDatatablePreload.DataTables || {};
	<?php if (!empty($datatable_preload)) { ?>
	window.erpDatatablePreload.DataTables["list"] = <?= json_encode($datatable_preload, JSON_UNESCAPED_SLASHES) ?>;
	<?php } ?>
</script>
