<!-- linksfoot.php — global footer scripts -->

<script>
// ── Date picker for "dd-mm-yyyy" text fields (class="datepick") ────────────
// These fields are plain <input type="text"> across the app (ledger, bank
// register, cash register, voucher date fields, etc.) with a "dd-mm-yyyy"
// placeholder, but nothing ever attached an actual calendar to them — they
// just behaved like ordinary text boxes. Flatpickr fills that in, formatted
// to match what the server-side d2sql()/date parsing on each page expects.
// Native <input type="date"> fields are skipped since the browser already
// supplies a working picker for those.
document.addEventListener('DOMContentLoaded', function () {
    if (typeof flatpickr === 'undefined') return;
    flatpickr('input.datepick:not([type="date"])', {
        dateFormat: 'd-m-Y',
        allowInput: true,
        disableMobile: true
    });
});
</script>
