HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: /var/www/javago-portal-updates/public/assets/js/cafe/dashboard/order-history.js
$(document).ready(function () {
    let tmp = false;
    let orderHistory = $("#order_history").DataTable({
        dom:
            "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
            "<'table-responsive'tr>" +
            "<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count  mb-sm-0 mb-3'i><'dt--pagination'p>>",
        oLanguage: {
            oPaginate: {
                sPrevious:
                    '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>',
                sNext: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>',
            },
            // "sInfo": "Showing page _PAGE_ of _PAGES_",
            sSearch:
                '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
            sSearchPlaceholder: "Search...",
            sLengthMenu: "Results :  _MENU_",
        },
        stripeClasses: [],
        lengthMenu: [
            [5, 10, 20, 25, 30, 35],
            [5, 10, 20, 25, 30, 35],
        ],
        pageLength: 5,
        // "info": false,
        processing: true,
        serverSide: true,
        ajax: {
            type: "POST",
            url: getData,
            data: function (data) {
                data.cafe = true;
                data.user = "";
                data.orderFrom = $(
                    "#filter_form input[name='order_from']"
                ).val();
                data.orderTo = $("#filter_form input[name='order_to']").val();
                data.today = true;
            },
        },
        fnDrawCallback: function () {
            if (!tmp) {
                $("#filter_form input").each(function () {
                    $(this).val("");
                });
            }
        },
        columns: [
            {
                data: "DT_RowIndex",
                name: "DT_RowIndex",
                orderable: false,
                searchable: false,
            },
            {
                data: "order_number",
                name: "order_number",
                orderable: false,
                // searchable: false
            },
            {
                data: "user_name",
                name: "users.name",
                orderable: false,
                // searchable: false
            },
            {
                data: "order_amount",
                name: "order_amount",
                orderable: false,
                searchable: false,
            },
            {
                data: "order_time",
                name: "order_time",
                orderable: false,
                searchable: false,
            },
            {
                data: "order_item_array",
                name: "order_item_array",
                orderable: false,
                searchable: false,
            },
            {
                data: "status",
                orderable: false,
                searchable: false,
            },
            {
                data: "order_completed",
                name: "order_completed",
                orderable: false,
                searchable: false,
            },
            {
                data: "estimated_arival_time",
                name: "estimated_arival_time",
                orderable: false,
                searchable: false,
            },
            {
                data: "action",
                orderable: false,
                searchable: false,
            },
        ],
        order: [[1, ""]],
    });

    // $("#filter_form").submit(function () {
    $("#filter-save").click(function () {
        tmp = true;
        orderHistory.draw();
        // return false;
    });

    $("#order_from").flatpickr({
        altInput: true,
        altFormat: "d-m-Y",
        dateFormat: "Y-m-d",
    });

    $("#order_to").flatpickr({
        altInput: true,
        altFormat: "d-m-Y",
        dateFormat: "Y-m-d",
    });

    $("#order_from").change((e) => {
        let elementValue = e.target.value;
        let orderFrom = moment(elementValue).format("YYYY-MM-DD");
        let date = new Date(orderFrom);
        let minDate1 = moment(date.setDate(date.getDate() + 1)).format(
            "YYYY-MM-DD"
        );
        $("#order_to").flatpickr({
            minDate: minDate1,
            altInput: true,
            altFormat: "d-m-Y",
            dateFormat: "Y-m-d",
        });
    });
});