<?php $this->load->view('includes/head') ?>
<?php $this->load->view('includes/topbar') ?>
<?php $this->load->view('includes/header') ?>
<style>
    :root {
        --main-color-new-theme: #76020f;
        --main-color-new-theme-light: #ebd503;
    }

    .card-title {
        font-size: 1rem !important;
        margin-bottom: 0rem !important;
        line-height: 1 !important;
    }

    .card-text {
        font-size: 1rem !important;
        font-weight: bolder !important;
    }

    h4,
    .h4 {
        font-size: calc(.7rem + 0.3vw) !important;
        font-weight: 900 !important;
    }

    .btn-toggle {
        display: inline-block;
        padding: 8px 16px;
        background-color: var(--main-color-new-theme);
        /* Bootstrap red */
        color: #fff;
        border: none;
        border-radius: 4px;
        cursor: pointer;
    }

    input[type="checkbox"]:checked+label.btn-toggle {
        background-color: #28a745;
        /* Bootstrap green */
    }

    .btn-toggle i {
        margin-right: 5px;
    }

    .body,
    p,
    label,
    span {
        font-family: sans-serif !important;
        /* color: black !important; */
    }

    .mdtp__time_holder span,
    .mdtp__digit.active span,
    .mdtp__am.active,
    .mdtp__pm.active {
        color: white !important;
    }

    label {
        font-weight: 600 !important;
        font-size: 16px;
    }

    h4 {
        font-family: sans-serif !important;
        font-weight: 700 !important;
        color: black !important;
        font-size: 16px !important;
    }

    .form-control {
        border: 1px solid #80808045 !important;
    }

    .hidden-div {
        display: none;
    }

    .form-control:disabled,
    .form-control[readonly] {
        /* background-color: #dbdbdb !important; */
        opacity: 1;
    }

    .btn-toggle {
        font-weight: 600 !important;
        font-size: 14px;
        color: white !important;
    }

    .card-title {
        font-family: sans-serif !important;
    }
</style>
<style>
    @media only screen and (max-width:768px) {


        .img-div {
            width: 30% !important;
        }

        .details-div {
            width: 70% !important;
        }
    }
</style>
<script type="text/javascript" src="<?php echo base_url('admin_assets/js/sweetalert2.all.min.js') ?>"></script>
<link href="<?php echo base_url('assets/css/lightbox.min.css'); ?>" rel="stylesheet" />
<script src="<?php echo base_url('assets/js/lightbox-plus-jquery.min.js'); ?>"></script>


<link href="<?php echo base_url('admin_assets/css/sweetalert2.min.css') ?>" rel="stylesheet">
<style>
    .notifyjs-bootstrap-base {
        color: black !important;
    }
</style>
<?php
$fgh = getFullPaymentSettings();

$dsbj = $fgh['result']['data'][0]['paymentGatewayoffon'];

foreach ($dsbj as $key => $dd) {
    if ($dd['source'] == 'WEBSITE') {
        $paymentSeverOn   = $dd['isenable'];
        $paymentSeverText = $dd['desc'];
    }
}

$paymentSetting = @getPaymentGatewaySettings();

$header_data    = getWebSyncsData('Header Settings', 'headerSettings', '');
$currencySymbol = getCurrencySymbol(); ?>

<link rel="stylesheet" type="text/css" href="<?php echo base_url('assets/css/services-cart.css') ?>">

<main id="main">
    <!-- ======= Coming Soon ======= -->
    <?php
    // echo '<pre>';
    // print_r(SettingsApi()['result']['data'][0]['membershipSettings']);

    if ((@$this->uri->segment(3) == 'outside-temple' || @$this->uri->segment(3) == 'inside-temple') && $this->session->userdata('logged_in') == 1 && $this->session->userdata('userType') == 'Devotee') {
        $parts     = explode(" ", @$userDetails->refDataName);
        $lastname  = array_pop($parts);
        $firstname = implode(" ", $parts);

        $enable_service_request_form = true;
    } else if (@$this->uri->segment(3) == 'aparakarya' && $this->session->userdata('logged_in') == 1 && $this->session->userdata('userType') == 'Devotee') {

        $parts     = explode(" ", @$userDetails->refDataName);
        $lastname  = array_pop($parts);
        $firstname = implode(" ", $parts);

        $enable_service_request_form = true;
    } else {
        $enable_service_request_form = false;
    }

    if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('userType') == 'Devotee') {
        $enable_service_request_btnlink = true;
    } else {
        $enable_service_request_btnlink = false;
    }

    ?>
    <style>
        .row {
            margin-right: 0px !important;
            margin-left: 0px !important;
        }
    </style>
    <?php
    $currencySymbol = getCurrencySymbol();
    $session_data   = $this->session->userdata('prasadam_cart') ?? [];
    if (! isset($session_data['ids'])) {
        $session_data['ids'] = [];
    }
    $cart_count   = count($session_data['ids']);
    $addressLine1 = @$userDetails->addressLine1;
    $addressLine2 = @$userDetails->addressLine2;
    $cityTypes    = @$userDetails->cityTypes;
    $county       = @$userDetails->county;
    $stateTypes   = @$userDetails->stateTypes;
    $zip          = @$userDetails->zip;
    // var_dump($userDetails);

    $setting = SettingsApi();

    $formAction         = $setting['result']['data'][0]['serviceRequestSettings']['bookingTypes'];
    $formAction         = 'REQUEST WITH PAYMENT';
    $membershipDiscount = $setting['result']['data'][0]['membershipSettings']['membershipDiscount'];
    $discountType       = $setting['result']['data'][0]['membershipSettings']['discountType'];
    ?>
    <div class="container-fluid pb-5">

        <div class="row">


            <!-- <div class="col-sm-12 mt-3 mb-5"> -->
            <div class="col-sm-12">

                <div class="header-body">
                    <?php
                    if ($this->uri->segment('1') == 'checkout_prasadam') {

                    ?>
                        <style>
                            p {
                                font-size: 17px !important;
                            }

                            .order-summary-card {
                                background: linear-gradient(to bottom, #fefefe, #f5f5f5);
                                border-radius: 10px;
                                transition: all 0.3s ease-in-out;
                            }

                            .order-summary-card:hover {
                                box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
                                transform: scale(1.01);
                            }

                            .order-summary-card h4 {
                                font-weight: bold;
                                color: var(--main-color-new-theme);
                            }

                            .btn-outline-danger {
                                color: var(--main-color-new-theme);
                                border: var(--bs-btn-border-width) solid var(--main-color-new-theme);
                            }

                            .btn-outline-danger:hover,
                            .btn-outline-danger::after {
                                color: white;
                                background-color: var(--main-color-new-theme);
                            }

                            @media only screen and (max-width:768px) {}
                        </style>
                        <!-- <form action="<?php echo base_url('Prasadam/AddToCart') ?>" id="addForm" method="post"> -->
                        <form id="addForm">
                            <!-- flex-column-reverse  flex-md-row-->
                            <div class="row">
                                <!-- REVIEW CART COLUMN order-1 order-md-2-->
                                <div class="col-md-4  mb-3">
                                    <div class="card order-summary-card shadow-sm border-0">

                                        <div class="p-3 bg-light rounded-top">
                                            <h4 class="mb-2 text-center text-danger">🛒 Order Summary</h4>
                                            <hr>
                                        </div>

                                        <?php
                                        $TotalAmt = 0;
                                        if (! empty($session_data['ids'])) {
                                            foreach ($session_data['ids'] as $i => $id) {
                                                $TotalAmt += (float) @$session_data['serviceAmount'][$i] * (float) $session_data['qty'][$i];
                                        ?>
                                                <div class="col-12 mb-3 px-2">
                                                    <div class="card border-light shadow-sm h-100">
                                                        <div class="row g-0 align-items-center">

                                                            <!-- Image Section -->
                                                            <div class="col-4 col-md-3 d-flex align-items-center justify-content-center p-2">
                                                                <img src="<?php echo ApiBaseUrl()['url'] . $session_data['image'][$i] ?>"
                                                                    class="img-fluid rounded"
                                                                    alt="<?php echo $session_data['serviceName'][$i] ?>"
                                                                    style="max-width: 90px;">
                                                            </div>

                                                            <!-- Details Section -->
                                                            <div class="col-8 col-md-9">
                                                                <div class="card-body p-2">
                                                                    <h6 class="card-title mb-1 fw-bold text-truncate">
                                                                        <?php echo $session_data['serviceName'][$i] ?>
                                                                    </h6>
                                                                    <p class="mb-0 small text-muted">
                                                                        Unit Price:
                                                                        <span class="fw-semibold text-dark">
                                                                            <?php echo $currencySymbol . price_format((float) @$session_data['serviceAmount'][$i] * (float) $session_data['qty'][$i], 2) ?>
                                                                        </span>
                                                                    </p>
                                                                    <p class="mb-0 small text-muted" style="line-height: 1;">
                                                                        <?php echo @$session_data['trayType'][$i] ? 'Tray Type: <span class="fw-semibold text-dark">' . $session_data['trayType'][$i] . '</span>' : '&nbsp;' ?>
                                                                    </p>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                        <?php
                                            }
                                        }
                                        ?>


                                        <div class="p-3 bg-white rounded-bottom">
                                            <div class="mb-2">
                                                <label for="etKitchenTIp" class="form-label">Kitchen Tip</label>
                                                <input type="text" class="form-control" name="etKitchenTIp" placeholder="Kitchen Tip" id="etKitchenTIp">
                                            </div>

                                            <input type="hidden" name="totalPrice" id="totalPrice" value="<?php echo $TotalAmt ?>">
                                            <h5 class="text-end" id="totalPriceH">
                                                <strong>Total: <?php echo $currencySymbol . price_format($TotalAmt, 2) ?></strong>
                                            </h5>

                                            <!-- <div class="d-grid mt-3">
                                                <a href="<?php echo base_url('prasadam') ?>" class="btn btn-outline-danger loader" onclick="loader.on();">🔄 Review Cart</a>
                                            </div> -->
                                        </div>
                                    </div>
                                </div>

                                <!-- CHECKOUT FORM COLUMN order-2 order-md-1-->
                                <div class="col-md-8 ">
                                    <div class="card">
                                        <div class="row" style="margin-right: 0px!important;margin-left: 0px!important;">
                                            <div class="col-sm-12 pt-3 pb-3">
                                                <h4>Checkout</h4>
                                                <hr>
                                                <div class="row">
                                                    <div class="col-sm-6">
                                                        <p><i class="fa fa-user"></i> <?php echo @$userDetails->refDataName ?></p>
                                                        <p><i class="fa fa-envelope" aria-hidden="true"></i> <?php echo base64_decode(@$userDetails->email) ?></p>
                                                        <p><i class="fa fa-mobile" aria-hidden="true"></i> <?php echo base64_decode(@$userDetails->phone) ?></p>
                                                        <!-- <p><i class="fa fa-phone" aria-hidden="true"></i> 7394023582</p> -->
                                                    </div>
                                                    <div class="col-sm-6">
                                                        <h3 class="" style="font-size: 17px;color:var(--main-color-new-theme);">Home Address</h3>
                                                        <p><?php echo @$userDetails->addressLine1 ?><?php echo @$userDetails->addressLine2 ? ', ' . $userDetails->addressLine2 : '' ?></p>
                                                        <p><?php echo @$userDetails->cityTypes ?> <?php echo @$userDetails->stateTypes ? ', ' . $userDetails->stateTypes : '' ?></p>
                                                        <p><?php echo @$userDetails->zip ?></p>
                                                    </div>
                                                    <!-- <div class="col-sm-3">
                                                        <h3 class="" style="font-size: 17px;color:var(--main-color-new-theme);">Billing Address</h3>
                                                       <p><?php echo @$userDetails->addressLine1 ?><?php echo @$userDetails->addressLine2 ? ', ' . $userDetails->addressLine2 : '' ?></p>
                                                        <p><?php echo @$userDetails->cityTypes ?> <?php echo @$userDetails->stateTypes ? ', ' . $userDetails->stateTypes : '' ?></p>
                                                        <p><?php echo @$userDetails->zip ?></p>
                                                    </div> -->
                                                </div>
                                                <hr>


                                                <div class="row">
                                                    <div class="col-sm-12">
                                                        <div class="mb-3 mt-3">
                                                            <label for="delivery">Pickup/Delivery:</label>
                                                            <input type="radio" class="form-radio" name="delivery" value="Carry Out" required> <span>Carry Out</span>&nbsp;
                                                            <input type="radio" class="form-radio" name="delivery" value="Delivery" required> <span>Delivery</span>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-6">

                                                        <label for="deliveryDate">Pickup/Delivery Date <span class="text-danger">*</span> </label>
                                                        <input type="text" class="form-control datepicker" readonly id="deliveryDate" placeholder="Pickup Date" name="deliveryDate" required>

                                                    </div>
                                                    <div class="col-sm-6">

                                                        <label for="deliveryTime">Pickup/Delivery Time <span class="text-danger">*</span></label>
                                                        <input type="text" class="form-control" id="deliveryTime" placeholder="Pickup Time" name="deliveryTime" required>

                                                    </div>
                                                    <div class="col-sm-12 hidden-div">
                                                        <div class="mb-3 mt-3">
                                                            <label for="Copyhomeadd">Copy Home address from Delivery:</label>
                                                            <input type="radio" class="form-radio" name="Copyhomeadd" value="Yes"> <span>Yes</span>&nbsp;
                                                            <input type="radio" class="form-radio" name="Copyhomeadd" value="No"> <span>No</span>
                                                        </div>
                                                    </div>

                                                    <div class="col-sm-6 hidden-div">

                                                        <label for="address">Address <span class="text-danger">*</span> </label>
                                                        <input type="text" class="form-control" id="address" placeholder="Address" name="address">

                                                    </div>
                                                    <div class="col-sm-6 hidden-div">

                                                        <label for="city">City <span class="text-danger">*</span></label>
                                                        <input type="text" class="form-control" id="city" placeholder="City" name="City">

                                                    </div>

                                                    <div class="col-sm-6 mt-2 hidden-div">

                                                        <label for="state">State <span class="text-danger">*</span> </label>
                                                        <input type="text" class="form-control" id="state" placeholder="State" name="state">

                                                    </div>
                                                    <div class="col-sm-6 mt-2 hidden-div">

                                                        <label for="zipcode">Zip Code <span class="text-danger">*</span></label>
                                                        <input type="text" class="form-control" id="zipcode" placeholder="Zipcode" name="zipcode">

                                                    </div>
                                                    <div class="col-sm-12 mt-3 text-center">
                                                        <button type="button" onclick="submitForm();" class="btn" style="background:var(--main-color-new-theme);color:white;">Send Request</button>
                                                    </div>
                                                </div>



                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>

                        </form>
                    <?php
                    } else {
                    ?>
                        <style>
                            .prasadam-item {
                                display: flex;
                                /* flex-direction: column; */
                                /* border: 1px solid #ddd; */
                                border: 2px solid var(--main-color-new-theme);
                                border-radius: 10px;
                                background: #fff;
                                overflow: hidden;
                                transition: all 0.3s ease;
                                flex-wrap: wrap;
                                margin-bottom: 15px;
                                width: -webkit-fill-available;

                            }

                            .prasadam-item:hover {
                                /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
                                transform: translateY(-3px); */
                            }

                            .prasadam-img {
                                flex: 0 0 80px;
                                display: flex;
                                justify-content: center;
                                align-items: center;
                                padding: 10px;
                            }

                            .prasadam-img img {
                                max-width: 60px;
                                max-height: 60px;
                                border-radius: 6px;
                            }

                            .prasadam-details {
                                flex: 1;
                                padding: 10px;
                                display: flex;
                                flex-direction: column;
                                justify-content: center;
                            }

                            .prasadam-details h5 {
                                font-size: 1rem;
                                margin: 0 0 5px 0;
                                font-weight: 600;
                                color: var(--main-color-new-theme);
                            }

                            .minp {
                                font-size: 13px;
                                margin: 0 0 4px 0;
                            }

                            .qty-counter {
                                display: flex;
                                align-items: center;
                                gap: 5px;
                                margin-top: 5px;
                            }

                            .qty-btn {
                                background: #fff;
                                border: 1px solid #ccc;
                                width: 25px;
                                height: 27px;
                                font-size: 18px;
                                text-align: center;
                                line-height: 25px;
                                cursor: pointer;
                                border-radius: 5px;
                                color: var(--main-color-new-theme);
                                padding: 0;
                            }

                            .qty-input {
                                width: 50px;
                                text-align: center;
                                border: 1px solid #ccc;
                                height: 30px;
                                font-weight: 800;
                                border-radius: 5px;
                                color: var(--main-color-new-theme);
                            }

                            /* ✅ Price Box */
                            .prasadam-price {
                                background: var(--main-color-new-theme);
                                color: #fff;
                                width: 100%;
                                display: flex;
                                flex-direction: row;
                                /* justify-content: space-between; */
                                justify-content: flex-end;
                                align-items: center;
                                padding: 8px 12px;
                                border-top: 1px solid #fff;
                            }

                            .prasadam-price span {
                                font-weight: bold;
                                font-size: 1rem;
                            }

                            .prasadam-price input[type="checkbox"] {
                                width: 22px;
                                height: 22px;
                                accent-color: gold;
                                cursor: pointer;
                            }


                            /* ✅ Mobile view: Price bottom full width */
                            @media (max-width: 768px) {
                                .prasadam-price {
                                    width: 100%;
                                    flex-direction: row;
                                    /* justify-content: space-between; */
                                    justify-content: flex-end;
                                    align-items: center;
                                    padding: 8px 12px;
                                    border-top: 1px solid #fff;
                                }
                            }


                            /* Mobile view: move price box to bottom full width */
                            @media (max-width: 768px) {

                                .mb2P {
                                    /* margin-bottom: 2.5rem !important; */
                                    margin-top: 1rem !important;
                                }
                            }

                            @media screen and (max-width: 992px) and (min-width: 300px) {
                                .col-md-4 {
                                    margin-top: 7px !important;
                                }

                                .price-span {
                                    background: #000030;
                                    padding: 5px 14px;
                                    color: white;
                                    margin: 1px 30px;
                                    border-radius: 6px;
                                    font-size: 14px;
                                    font-weight: 1000;
                                }
                            }

                            .search-container {
                                position: relative;
                                display: flex;
                                align-items: center;
                                margin-top: 1rem !important;
                                /* margin-top: 4rem !important; */
                            }

                            .search-icon {
                                cursor: pointer;
                                font-size: 24px;
                                padding: 10px;
                            }

                            .active-btn {
                                background: var(--main-color-new-theme) !important;
                                border-color: #fcfcfc !important;
                                color: #fcfcfc !important;
                            }

                            .search-input {
                                width: 0;
                                padding: 0;
                                /*opacity: 0;*/
                                transition: all 0.3s ease;
                                border: 1px solid #ccc;
                            }

                            .search-input.open {
                                /* width: 200px; */
                                padding: 5px 5px 5px 39px;
                                opacity: 1;
                            }

                            #search_col {
                                display: flex;
                                align-items: center;
                                justify-content: end;
                            }

                            .top-bar {
                                display: flex;
                                align-items: center;
                                justify-content: flex-end;
                                /* Badi screen par right side */
                                gap: 20px;
                                /* Elements ke beech spacing */
                                padding: 10px;
                                flex-wrap: wrap;
                            }

                            .search-container {
                                display: flex;
                                align-items: center;
                            }

                            .search-icon {
                                font-size: 24px;
                                cursor: pointer;
                            }

                            .paymentBtn {
                                padding: 10px 20px;
                                font-size: 16px;
                            }


                            @media only screen and (max-width: 399px) {
                                .custom-btn {
                                    font-size: 12px !important;

                                }
                            }

                            .amount-input-donations::placeholder {
                                color: #d6fff7 !important;
                            }

                            /* Choti screen par search icon center me dikhane ke liye */
                            @media (max-width: 768px) {
                                .top-bar {
                                    flex-direction: column;
                                    /* Mobile view me vertical layout */
                                    align-items: center;
                                    /* Center me dikhane ke liye */
                                    margin-top: -26px;
                                    width: 100% !important;
                                }


                                .search-container {
                                    justify-content: center;
                                }
                            }

                            .minp {
                                font-size: 14px !important;
                                line-height: 1;
                                margin-bottom: 0rem !important;
                                margin-left: 5px !important;
                            }

                            #foodMenuCategorySearch {
                                height: 37px;
                                border-radius: 7px;
                                color: var(--main-color-new-theme);
                            }
                        </style>
                        <style>
                            .collapse.in {
                                display: inline !important;
                            }

                            #myTab ::-webkit-scrollbar {
                                display: none !important;
                            }

                            #myTab {
                                overflow: hidden;
                            }

                            select:hover {
                                border-top: 1px solid black;
                                cursor: pointer;
                            }
                        </style>
                   
                            <div class="row px-0 mx-0">
                                <div class="col-md-4  px-4" style="display: flex;align-items: flex-end;">
                                    <div class="row m-0 p-0">
                                        <div class="col-md-12 m-0 p-0">

                                            <div class="px-2">
                                               <h5> <b>Day: </b><?= @$this->input->get('selectdate') ? date('D', strtotime($this->input->get('selectdate'))) : date('D'); ?>,<?= @$this->input->get('selectdate') ?date('m Y', strtotime($this->input->get('selectdate'))): date('m Y'); ?> </h5> 
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div class="d-flex justify-content-end align-items-end" id="RightField">
                                        <div class="top-bar">
                                            <!-- 🔍 Search Icon -->
                                            <!-- <div class="search-container">
                                            <span class="search-icon" id="searchIcon">🔍</span>
                                             <input type="search" name="q" id="search" class="search-input search-text searchKey d-none" placeholder="Search..." autocomplete="off">
                                            </div> -->
                                            <div class="text-white px-4 mb2P">
                                                <div class="row">
                                                    <div class="col-md-9 text-start text-dark">
                                                        <span class="fw-bold" style="padding-left: 42px;">Total Amount</span>
                                                    </div>
                                                </div>



                                                <!-- 🛒 Cart -->
                                                <span style="position: relative;">
                                                    <a href="javaScript:void(0)" onclick="ViewCart()">
                                                        <i class="fa fa-shopping-cart fa-2x" style="color:#000030;"></i>

                                                        <span class="cart-count text-dark" style="font-size: 20px !important;">
                                                            <?php echo $cart_count ?>
                                                        </span>
                                                    </a>
                                                </span>

                                                <!-- 💰 Total Price -->
                                                <label class="label label-primary price-span">
                                                    <?php echo $currencySymbol; ?>&nbsp;<span class="allPrice"><?php echo number_format(@$session_data['totalPrice'] ?? 0, 2); ?></span>
                                                </label>


                                                <a href="javaScript:void(0)" class="btn btn-success paymentBtn" onclick="ValidateCheckout();loader.on();">
                                                    <?php echo isset($GeneralSettings['payNowText']) && $GeneralSettings['payNowText'] != '' ?
                                                        $GeneralSettings['payNowText'] : 'Proceed To Checkout'; ?>
                                                </a>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                    
                        <div class="bg-image shadow-1-strong">
                            <div class="row">
                                <div class="col-md-12 mx-auto p-0">
                                    <div class="row m-0 p-0">
                                        <!--=========================================================================-->
                                        <div class="justify-content-center align-items-center filter-tab  p-0" style="overflow:hidden">
                                            <!-- ============================== -->
                                            <div class="tab-content responsive-container" id="myTabContent">
                                                <ul class="nav nav-tabs mt-2" id="myTab" role="tablist" style="margin-bottom: 12px; ">

                                                    <?php if (! empty($fooItemsList)) {
                                                        foreach ($fooItemsList as $key => $val) {
                                                    ?>


                                                            <li class="nav-item" role="presentation" style="margin-right: 10px;margin-top: 7px;">


                                                                <?php
                                                                $isActive    = ($key == 0);
                                                                $buttonStyle = $isActive
                                                                    ? "background: var(--main-color-new-theme) !important; color: white !important;"
                                                                    : "background: white; color: black;";
                                                                ?>
                                                                <div class="frame" style="">
                                                                    <button class="custom-btn btn-15 <?php echo ($isActive) ? 'active' : ''; ?>"
                                                                        id="home-tab<?php echo $key; ?>"
                                                                        data-bs-toggle="tab"
                                                                        data-bs-target="#home-tab-pane<?php echo $key; ?>"
                                                                        type="button"
                                                                        role="tab"
                                                                        aria-controls="home-tab-pane<?php echo $key; ?>"
                                                                        aria-selected="<?php echo ($isActive) ? 'true' : 'false'; ?>"
                                                                        style="font-weight:700; font-size:16px; background-size:cover; border-radius:5px !important; padding:12px 23px; box-shadow:1px 1px 10px #b5b5b5; margin-bottom:10px; <?php echo $buttonStyle; ?>">
                                                                        <?php echo $val ?>
                                                                    </button>
                                                                </div>



                                                            </li>

                                                    <?php }
                                                    } ?>
                                                </ul>
                                                <div class="tab-content" id="myTabContent">

                                                    <?php if (! empty($fooItemsList)) {
                                                        foreach ($fooItemsList as $key => $val) { ?>


                                                            <div class="tab-pane table-responsive fade  panettttttttt<?php echo $key; ?> show <?php echo ($key == 0) ? 'active' : ''; ?>" id="home-tab-pane<?php echo $key; ?>" role="tabpanel" aria-labelledby="home-tab<?php echo $key; ?>" tabindex="0">
                                                                <style type="text/css">
                                                                    .amount-input-donations::placeholder {
                                                                        color: #d6fff7 !important;
                                                                        /* Replace 'your_color_here' with your desired color */
                                                                        font-size: 15px !important;
                                                                        /* Replace with your desired font-size */
                                                                        font-weight: bold !important;
                                                                        /* Replace with your desired font-weight */
                                                                    }
                                                                </style>

                                                                <div class="row g-3 " id="searchHere">

                                                                    <?php
                                                                    foreach ($groupedMenu[$val] as $item) {
                                                                        // foreach ($dailyMenu as $item) {
                                                                        $index = array_search($item->_id, $session_data['ids']);
                                                                    ?>
                                                                        <div class="col-md-3 col-sm-6 d-flex serviceSearch <?php echo preg_replace('/[^A-Za-z0-9_]/', '_', $item->refDataCode) ?>">
                                                                            <p class="RefDataNameDetails d-none"><?php echo $item->refDataName ?></p>
                                                                            <div class="prasadam-item h-100">

                                                                                <!-- Left Image -->
                                                                                <div class="prasadam-img">
                                                                                    <img src="<?php echo ApiBaseUrl()['url'] . $item->image ?>" alt="<?php echo $item->refDataName ?>">
                                                                                </div>

                                                                                <!-- Middle Details -->
                                                                                <div class="prasadam-details">

                                                                                    <h5><?php echo $item->refDataName ?>


                                                                                        <?php
                                                                                        if (! empty(trim(@$item->description))) {
                                                                                        ?>
                                                                                            <span>
                                                                                                <a href="#more<?php echo @$item->_id ?>" data-toggle="collapse" class="eye-toggle" aria-expanded="false" style="padding-left: 13px;"><i class="fa fa-eye" style="color:green"></i></a>
                                                                                            </span>

                                                                                            <span class="collapse fw-normal" id="more<?php echo @$item->_id ?>" data-item-id="<?php echo @$item->_id ?>" style="padding-left: 13px;color: black !important;">
                                                                                                <br> <?php echo @$item->description ?>
                                                                                            </span>
                                                                                        <?php
                                                                                        }
                                                                                        ?>
                                                                                    </h5>
                                                                                    <!-- <p class="minp"><b>Uni: <?php echo @$item->AvailableCount ?></b></p> -->
                                                                                    <!-- <p class="minp text-danger"><b><?php echo @$item->description ?></b></p> -->


                                                                                    <?php
                                                                                    $unitPrice = (float) $item->unitPrice;
                                                                                    ?>
                                                                                    <?php
                                                                                    $trayDesc = '';
                                                                                    $isTraySelected = 'NO';
                                                                                    $SelectedTray = '';
                                                                                    if (isset($item->{'Child Grid'}) && ! empty(@$item->{'Child Grid'})) {
                                                                                        $isTraySelected = 'YES';
                                                                                    ?>
                                                                                        <p class="minp mt-1">
                                                                                            <select style="width: 80%;height: 26px;" id="trayType_<?php echo $item->_id ?>" onchange="ChangeTrayType(this.value,'<?php echo $item->_id ?>')">
                                                                                                <option value="" selected>--select--</option>
                                                                                                <?php
                                                                                                foreach ($item->{'Child Grid'} as $i => $trayType) {
                                                                                                    $trayDesc = @$trayType->quantity . '' . @$trayType->UOM;
                                                                                                    if (isset($trayType->desc) && ! empty($trayType->desc)) {
                                                                                                        $trayDesc .= '<br>' . $trayType->desc;
                                                                                                    }
                                                                                                    $isSelected = 0;

                                                                                                    if ($index !== false && isset($session_data['trayType'][$index]) && $session_data['trayType'][$index] == $trayType->trayType) {
                                                                                                        $isSelected = 1;
                                                                                                        $SelectedTray = $trayType->trayType;
                                                                                                    }
                                                                                                    if ($i == 0) {
                                                                                                        // $unitPrice = (float) $trayType->unitPrice;
                                                                                                    }
                                                                                                    if ($isSelected) {
                                                                                                        $unitPrice = (float) $trayType->unitPrice;
                                                                                                    }
                                                                                                    //$unitPrice =  $isSelected ? (float)$trayType->unitPrice : ($i == 0 ? (float)$trayType->unitPrice : (float)$item->unitPrice);
                                                                                                    // echo $isSelected ? 'selected' : '' . ($i == 0 ? 'selected' : '')
                                                                                                ?>
                                                                                                    <option value="<?php echo $trayType->trayType ?>" unitPrice="<?php echo @$trayType->unitPrice ?>" quantity="<?php echo trim($trayType->quantity) ?>" UOM="<?php echo $trayType->UOM ?>" desc="<?php echo @$trayType->desc ?>" <?php echo $isSelected ? 'selected' : '' ?>><?php echo $trayType->trayType ?></option>
                                                                                                <?php
                                                                                                }
                                                                                                ?>
                                                                                            </select>
                                                                                        </p>
                                                                                    <?php
                                                                                    } else {
                                                                                        echo "<p class='minp text-danger mb-1' style='margin-bottom:10px!important;'>&nbsp;</p>";
                                                                                    }

                                                                                    if (! empty(@$trayDesc)) {
                                                                                    ?>
                                                                                        <p class="minp text-danger d-none" id="typetrayQty_<?php echo $item->_id ?>"><b>Quantity: <?php echo @$trayDesc ?></b></p>
                                                                                    <?php
                                                                                    } else {
                                                                                        echo "<p class='minp text-danger d-none'>&nbsp;</p>";
                                                                                    }
                                                                                    ?>
                                                                                    <div class="qty-counter">
                                                                                        <button type="button" class="qty-btn" onclick="quantityMinusFunction('<?php echo $item->_id ?>')">-</button>
                                                                                        <input type="text" class="qty-input"  id="quantity-input<?php echo $item->_id ?>" name="qty[<?php echo $item->_id ?>]" value="<?php echo ($index !== false ? ($session_data['qty'][$index]) : '1') ?>" oninput="this.value = this.value.replace(/[^0-9]/g, '');addTocart();" />
                                                                                        <button type="button" class="qty-btn" onclick="quantityPlusFunction('<?php echo $item->_id ?>')">+</button>
                                                                                    </div>
                                                                                </div>

                                                                                <!-- Price bottom full width -->
                                                                                <div class="prasadam-price">
                                                                                    <input type="hidden" value="<?= @$this->input->get('selectdate')??date("m/d/Y") ?>" id="startDate_<?php echo $item->_id ?>">
                                                                                    <span id="Totalprice_<?php echo $item->_id ?>">$ <?php echo ($index !== false ? number_format(((float) $session_data['qty'][$index] * (float) $unitPrice), 2) : number_format((float) $unitPrice, 2)) ?></span>&nbsp;&nbsp;
                                                                                    <input type="checkbox" id="chk_<?php echo $item->_id ?>" <?php echo ($index !== false ? 'checked' : '') ?> name="services_id[]" value="<?php echo $item->_id ?>" data-id="<?php echo $item->_id ?>" isTraySelected="<?= $isTraySelected ?>" data-category="<?php echo @$item->rentalCategory ?>" data-service-type="<?php echo $item->refDataCode ?>" data-start-time="<?php echo @$item->startTime ?>" data-start-date="<?php echo @$item->startDate ?>" data-service-name="<?php echo $item->refDataName ?>" data-price="<?php echo @$unitPrice ?>" data-end-date="<?php echo @$item->endDate ?>" data-end-time="<?php echo @$item->endTime ?>" data-description="<?php echo replaceSingleQuotesWithBackticks(@$item->shortDescription) ?>" data-image="<?php echo @$item->image ?>" data-BookingLimitPerDay="<?php echo @$BookingLimitPerDay ?>" onchange="addTocart()" name="services_id[]" available_count="<?php echo @$item->AvailableCount ?>" data-servicedesc="<?php echo (in_array($item->_id, $session_data['ids']) ? @$session_data['service_desc'][array_search($item->_id, $session_data['ids'])] : '') ?>" is_membership_discount="<?php echo @$item->membershipDiscount ?>" membership_discount_amt="<?php echo @$item->membershipAmount ?>" traytype="<?= @$SelectedTray ?>">
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    <?php
                                                                    }
                                                                    ?>


                                                                </div>

                                                                <div id="emptyServices" style="padding: 4px 66px; font-size: 21px; font-weight: 700;"></div>
                                                            </div>
                                                    <?php }
                                                    } ?>
                                                </div>
                                            </div>
                                        </div>
                                        <!--=========================================================================-->

                                    </div>
                                </div>
                            </div>
                        </div>





                    <?php
                    }
                    ?>
                </div>


            </div>

        </div>
    </div>
    <!-- End Main content-->

</main>
<div class="modal fade" id="membershipModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true" data-keyboard="false" data-backdrop="static">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">


            <div class="modal-header text-center">
                <h5 class="modal-title bottomborder modatTitle">CHECKOUT</h5>
                <button type="button" class="btn-close modalCloseBtn <?php echo @$modalClbtn; ?>" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <div class="container">
                    <img src="<?php echo ApiBaseUrl()['url'] . @$header_data[0]['leftImage'] ?>" class="img-fluid mb-4" height="100px" width="100px" style="display: block;margin-left: auto;margin-right: auto;">
                    <div class="row d-flex justify-content-center align-items-center">
                        <div class="col-xl-12">
                            <div class="row g-0">
                                <div class="col-xl-12">
                                    <div class="row">
                                        <div class="col-md-12 mb-4">
                                            <table class="table table-responsive table-bordered text-center">
                                                <thead>
                                                    <tr>
                                                        <th>
                                                            <h5 class="h5-title">Service Name</h5>
                                                        </th>
                                                        <th>
                                                            <h5 class="h5-title">Amount to Pay</h5>
                                                        </th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr>
                                                        <td id="serviceNameedittable">

                                                        </td>

                                                        <td id="edittable">

                                                        </td>
                                                    </tr>

                                                </tbody>
                                            </table>
                                        </div>
                                        <div class="col-sm-12" id="serviceNameedittableBody">

                                        </div>
                                    </div>

                                    <div class="">
                                        <div class="row">

                                            <div class="col-md-12">


                                                <?php if (isset($paymentSetting) && $paymentSetting == 'PAYPAL' && $paymentSeverOn == 1) { ?>

                                                    <div class="oooooookkakak" id="paypal-button-container-membership"></div>

                                                <?php } else if (isset($paymentSetting) && ($paymentSetting == 'MPI' || $paymentSetting == 'MPITEST') && $paymentSeverOn == 1) { ?>


                                                    <link rel="stylesheet" href="<?php echo base_url('assets/css/mpi-form.css'); ?>">

                                                    <form id="paymentForm" action="https://www.bridgepaynetsecuretx.com/WebSecurity/echo.aspx" method="post" style=" max-width: 500px;margin: auto;">
                                                        <div class="row px-0">
                                                            <div class="col-md-12 px-0">
                                                                <h6 class="text-center">Card Details</h6>
                                                                <div id="card" class="mx-0" style="width: 100%!important;height: 150px;"></div>
                                                                <div id="errorMessage" style="margin-bottom: 10px; color: #c0392b;"></div>
                                                            </div>
                                                            <div class="col-md-12 px-0">
                                                                <!-- <h6 class="text-center">Billing Address</h6> -->
                                                                <input type="text" class="form-control" id="mpi_fname" name="firstname" placeholder="Enter Your Full Name*" required style="width: 100%; margin-bottom: 20px; padding: 12px; border: 1px solid #ccc; border-radius: 3px;    padding-top: 12px!important;" value="<?php echo @$userDetails->refDataName ?>">

                                                                <input type="number" class="form-control" id="mpi_zipcode" name="mpi_zipcode" placeholder="Enter Your Zipcode" style="width: 100%; margin-bottom: 20px; padding: 12px; border: 1px solid #ccc; border-radius: 3px;    padding-top: 12px!important;" value="<?php echo @$userDetails->zip ?>">



                                                                <center>
                                                                    <button type="submit" class="btn btn-success" style="max-width: 500px;margin: auto;border-radius: 4px!important;font-weight: 800;padding: 8px 24px;background: #e78b00;border: 0;text-shadow: 1px 1px 0px black;">PAY NOW</button>
                                                                </center>
                                                            </div>
                                                        </div>

                                                    </form>

                                                    </form>



                                                <?php } else if (isset($paymentSetting) && $paymentSetting == 'CHARGEANYWHERE' && $paymentSeverOn == 1) { ?>


                                                    <iframe id="paymentIframe" title="Payment Page" width="100%" height="600px"></iframe>

                                                <?php } ?>

                                                <button type="button" class="btn PaymentClosebtn btn-danger ms-2" data-dismiss="modal" hidden>CLOSE</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

<!-- Modal T&C -->
<div class="modal modal-lg fade" id="term_and_conditions" tabindex="-1" aria-labelledby="term_and_conditionsLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-scrollable">
        <div class="modal-content">
            <div class="modal-body">

                <div id="rules-regulations">
                    <h2>Terms and Conditions for Use of <?= camelcase(GetProjectName()); ?>'s Akshaya Patra</h2>
                    <ol>
                        <li>
                            Cancellation allowed online until 24 hours before pickup time. Cancellation email should be sent to customer and us. Customer has to call us to cancel within 24 hours of order pickup time. For some items, preparation starts at least 24 hours ahead. So, they have to call us to discuss cancellation within 24 hours of order pickup.
                        </li>


                </div>
                <div class="modal-footer">
                    <div class="row" style="width: 100%;">

                        <div class="col-sm text-start" style="width: 50%;">
                            <input type="button" name="next" class="btn btn-danger" style="width: 100px;height: 45px;border-radius: 5px !important;" id="cancel" value="Cancel" />
                        </div>
                        <div class="col-sm text-end" style="width: 50%;">
                            <input type="button" name="next" class="btn btn-success" id="accept" style="width: 100px;height: 45px;background-color: #198754 !important;border-radius: 5px !important;" value="Accept" />

                        </div>
                    </div>



                </div>
            </div>
        </div>
    </div>

</div>

<input type="hidden" id="includeSankalpamModal" value="<?php echo @$includeSankalpam ?>">
<input type="hidden" id="datesArray" value="">

<?php $this->load->view('includes/footer') ?>

<script type="text/javascript" src="<?php echo base_url('assets/js/paging.js'); ?>"></script>

<script src="https://cdn.jsdelivr.net/gh/dubrox/Multiple-Dates-Picker-for-jQuery-UI@master/jquery-ui.multidatespicker.js"></script>


<?php $this->load->view('includes/script') ?>

<script>
    $(document).on("click", ".custom-btn", function() {
        // Sab buttons se active class hatao
        $(".custom-btn").removeClass("active")
            .css({
                "background": "white",
                "color": "black"
            });

        // Jis button pr click hua usko active karo
        $(this).addClass("active")
            .css({
                "background": "var(--main-color-new-theme)",
                "color": "white"
            });
    });
    $(document).ready(function() {
        // 🔍 Toggle search box
        $("#searchIcon").click(function() {
            $("#search").toggleClass("open");

            if ($("#search").hasClass("open")) {
                $("#search").removeClass("d-none").focus();
            } else {
                $("#search").addClass("d-none").val('');
                $(".serviceSearch").show();
                $("#emptyServices").hide();
            }
        });

        // Click outside → close search
        $(document).click(function(event) {
            if (!$(event.target).closest("#searchIcon, #search").length) {
                $("#search").addClass("d-none").removeClass("open").val('');
                $(".serviceSearch").show();
                $("#emptyServices").hide();
            }
        });

        // 🔹 Original order save
        $(".serviceSearch").each(function(i) {
            $(this).attr("data-order", i);
        });

        $("#search").on("keyup search", function() {
            var value = $(this).val().toLowerCase().trim();
            var noResults = true;

            if (value === "") {
                // ✅ search clear -> sab dikhाओ original order me
                $(".serviceSearch").sort(function(a, b) {
                    return $(a).data("order") - $(b).data("order");
                }).appendTo("#searchHere").show();

                $("#emptyServices").hide();
                return;
            }

            $(".serviceSearch .RefDataNameDetails").each(function() {
                var rowText = $(this).text().toLowerCase();
                var isMatch = rowText.indexOf(value) > -1;

                var $parent = $(this).closest(".serviceSearch");

                if (isMatch) {
                    noResults = false;
                    $parent.show().prependTo("#searchHere"); // match upar
                } else {
                    $parent.hide();
                }
            });

            if (noResults) {
                if ($("#emptyServices").length === 0) {
                    $("#searchHere").append(
                        '<div id="emptyServices" class="text-center w-100 text-danger fw-bold mt-3">Service not found!</div>'
                    );
                }
                $("#emptyServices").show();
            } else {
                $("#emptyServices").hide();
            }
        });

    });

    /* $(document).ready(function() {
         // 🔹 Store original HTML on page load
         var originalHTML = $(".serviceSearch").html();

         // 🔍 Toggle Search Box
         $("#searchIcon").click(function() {
             $("#search").toggleClass("open");

             if ($("#search").hasClass("open")) {
                 $("#search").removeClass("d-none").focus();
             } else {
                 $("#search").addClass("d-none").val('');
                 $(".serviceSearch").html(originalHTML); // reset list
                 $("#emptyServices").hide();
             }
         });

         // Close search if clicked outside
         $(document).click(function(event) {
             if (!$(event.target).closest("#searchIcon, #search").length) {
                 $("#search").addClass("d-none").removeClass("open").val('');
                 $(".serviceSearch").html(originalHTML); // reset list
                 $("#emptyServices").hide();
             }
         });

         // 🔎 Search Filter
         $("#search").on("keyup", function() {
             var value = $(this).val().toLowerCase().trim();
             var $items = $(".serviceSearch .col-md-4, .serviceSearch .col-sm-6");
             var noResults = true;

             var $matches = [];
             var $nonMatches = [];

             $items.each(function() {
                 var rowText = $(this).find(".RefDataNameDetails").text().toLowerCase().trim();
                 var isMatch = rowText.indexOf(value) > -1;

                 if (isMatch) {
                     $matches.push(this);
                     noResults = false;
                 } else {
                     $nonMatches.push(this);
                 }
             });

             var $container = $(".serviceSearch");
             $container.empty();
             $container.append($matches);
             $container.append($nonMatches);

             if (noResults && value !== "") {
                 if ($("#emptyServices").length === 0) {
                     $container.append(
                         '<div id="emptyServices" class="text-center w-100 text-danger fw-bold mt-3">Service not found!</div>'
                     );
                 }
                 $("#emptyServices").show();
             } else {
                 $("#emptyServices").hide();
             }
         }).on("search", function() {
             if ($(this).val() === "") {
                 $(".serviceSearch").html(originalHTML); // reset list
                 $("#emptyServices").hide();
             }
         });
     });*/



    var addressLine1 = '<?php echo $addressLine1 ?>';
    var addressLine2 = '<?php echo $addressLine2 ?>';
    var address = addressLine1 + ', ' + addressLine2;
    var cityTypes = '<?php echo $cityTypes ?>';
    var county = '<?php echo $county ?>';
    var stateTypes = '<?php echo $stateTypes ?>';
    var zip = '<?php echo $zip ?>';

    function addTocart() {

        var totalPrice = 0;
        var sankalpam_data = [];
        var cart_type = 'SERVICES';
        var ids = [];
        var qty = [];
        var ctg = [];
        var serviceTypes = [];
        var serviceCategoryTypes = [];
        var serviceName = [];
        var startDate = [];
        var startTime = [];
        var serviceAmount = [];
        var description = [];
        var image = [];
        var cart_ctg = [];
        var bookingtype = [];
        var includeSankalpam = [];
        var is_date_required = [];
        var isServicePaid = [];
        var is_membership_discount = [];
        var membership_discount_amt = [];
        var service_desc = [];
        var serviceOccurrencesNo = [];
        var fullPackage = [];
        var isDietySelected = [];
        var dietyName = [];
        var disclaimerText = [];
        var traytype = [];

        if ($(this).attr('includeSankalpam') == 'YES') {
            $("#includeSankalpamModal").val($(this).attr('includeSankalpam'));
        }


        sankalpam_data.push($("#includeSankalpamModal").val());

        var noDateSelected = 0;
        var addtoCartStatus = true;


        $('input[name="services_id[]"]:checked').each(function() {
            id = $(this).attr('data-id');

            if ($(this).attr('isTraySelected') == 'YES' && $(this).attr('trayType') == '') {
                $("#trayType_" + id).focus();
                $(this).prop('checked', false);

                $("#trayType_" + id).notify(
                    "Please select tray!", {
                        position: "top"
                    }
                );


                addtoCartStatus = false;
                return false;
            }

            loader.on();

            var init_qty = parseInt($("#quantity-input" + id).val());
            console.log("init_qty: " + init_qty);
            if (init_qty <= 0 || isNaN(init_qty)) {
                $("#quantity-input" + id).val(1);
                init_qty = 1;
                console.log("quantity");
            }
            console.log("init_qty");
            console.log(init_qty);
            var serviceoccurrencesno = '';


            isDietySelected.push('NO');



            disclaimerText.push($(this).attr('disclaimerText'));

            init_qty = (init_qty ? parseInt(init_qty) : 1);
            $("#quantity-input" + id).val(init_qty);
            totalPrice = (parseFloat(totalPrice) + (parseFloat($(this).attr('data-price')) * init_qty));
            console.log("#Totalprice_" + $(this).attr('data-id'));
            $("#Totalprice_" + $(this).attr('data-id')).html("<?php echo $currencySymbol; ?>&nbsp;" + (parseFloat($(this).attr('data-price')) * init_qty).toFixed(2) + "&nbsp;");


            startDate.push($("#startDate_" + id).val());



            isServicePaid.push("YES");



            startTime.push("");

serviceCategoryTypes.push("DAILY ORDERS");

            ctg.push($(this).attr('data-category'));
            traytype.push($(this).attr('trayType'));
            serviceTypes.push($(this).attr('data-service-type'));
            serviceName.push($(this).attr('data-service-name'));
            image.push($(this).attr('data-image'));


            var booking_type = $(this).attr('booking_type');

            bookingtype.push(booking_type);
            description.push($(this).attr('data-description').replace(/['"`]/g, ''));
            cart_ctg.push($(this).attr('cart_category'));

            fullPackage.push('false');
            serviceAmount.push($(this).attr('data-price'));


            ids.push($(this).attr('data-id'));
            includeSankalpam.push($(this).attr('includeSankalpam'));
            qty.push(init_qty);
            is_date_required.push($(this).attr('is_date_required'));
            is_membership_discount.push($(this).attr('is_membership_discount'));
            membership_discount_amt.push($(this).attr('membership_discount_amt'));
            service_desc.push($(this).attr('data-servicedesc'));
            serviceOccurrencesNo.push(serviceoccurrencesno);

        });


        if (addtoCartStatus == false) {
            loader.off();
            return false;
        } else {

            $(".allPrice").text((totalPrice / 1).toFixed(2));
        }

        $.ajax({
            type: "POST",
            url: "<?php echo base_url('Prasadam/addCart'); ?>",
            dataType: 'json',
            data: {
                ids: ids,
                totalPrice: totalPrice,
                qty: qty,
                ctg: ctg,
                serviceTypes: serviceTypes,
                serviceCategoryTypes: serviceCategoryTypes,
                serviceName: serviceName,
                startDate: startDate,
                startTime: startTime,
                serviceAmount: serviceAmount,
                cart_type: cart_type,
                image: image,
                description: description,
                cart_ctg: cart_ctg,
                bookingtype: bookingtype,
                includeSankalpam: includeSankalpam,
                is_date_required: is_date_required,
                is_membership_discount: is_membership_discount,
                membership_discount_amt: membership_discount_amt,
                service_desc: service_desc,
                serviceOccurrencesNo: serviceOccurrencesNo,
                fullPackage: fullPackage,
                dietyName: dietyName,
                isDietySelected: isDietySelected,
                disclaimerText: disclaimerText,
                trayType: traytype
            },
            success: function(result) {
                console.log(result);
                $("#includeSankalpamModal").val(result.includeSankalpam);
                $(".cart-count").text($('input[name="services_id[]"]:checked').length);
                loader.off();
                // reloadCartPreview();
                // updateCartCount();
            }
        });


    }




    function quantityMinusFunction(id) {

        var totalPrice = 0;
        var init_qty = parseInt($('#quantity-input' + id).val());
        if (init_qty > 1) {
            init_qty = init_qty ? parseInt(init_qty) - 1 : 0;

            $('#quantity-input' + id).val(init_qty);
        }

        addTocart();
    }

    function quantityPlusFunction(id) {
        var totalPrice = 0;
        var init_qty = parseInt($('#quantity-input' + id).val());

        init_qty = init_qty ? parseInt(init_qty) + 1 : 0;
        $('#quantity-input' + id).val(init_qty);
        addTocart();

    }

    function reloadCartPreview() {
        $.ajax({
            url: '<?php echo base_url('Prasadam/getTempCart') ?>',
            type: 'GET',
            success: function(response) {
                $('#cart-preview-section').html(response);
            }
        });
    }
    reloadCartPreview();
    $(document).on('click', '.service-delete-row', function(e) {
        e.preventDefault();

        var row_id = $(this).data('row-id');
        var selected_date = $(this).data('selected-date');
        var current_row = $(this).closest('tr');
        var confirmDelete = confirm('Do you want to delete this service from your cart?');

        if (confirmDelete) {
            loader.on();
            $.ajax({
                url: '<?php echo base_url() ?>Prasadam/delete_cart_row',
                method: 'POST',
                data: {
                    row_id: row_id,
                    selected_date: selected_date
                },
                dataType: 'json',
                success: function(response) {
                    if (response.status == 'success') {
                        // remove the deleted row from the DOM
                        current_row.remove();
                        // update the cart amount
                        // var updated_amount = response.updated_amount;
                        // $('#cart-amount').text(updated_amount);
                        location.reload();
                        // loader.off();
                    }
                },
                error: function() {
                    loader.off();
                    alert('Error deleting cart row. Please try again.');
                }
            });
        }
    });

    $(document).ready(function() {
        $('input[name="delivery"]').on('change', function() {
            console.log("etKitchenTIp");
            if ($(this).val() === 'Delivery') {
                $('.hidden-div').css("display", "block");
            } else {
                $('.hidden-div').css("display", "none");
            }
        });

        $('input[name="Copyhomeadd"]').on('change', function() {
            if ($(this).val() === 'Yes') {
                $("#address").val(address);
                $("#address").attr("readonly", true);
                $("#state").removeAttr("required");

                $("#city").val(cityTypes);
                $("#city").attr("readonly", true);
                $("#state").removeAttr("readonly");

                $("#state").val(stateTypes);
                $("#state").attr("readonly", true);
                $("#state").removeAttr("required");

                $("#zipcode").val(zip);
                $("#zipcode").attr("readonly", true);
                $("#state").removeAttr("required");
            } else {
                $("#address").val('');
                $("#address").attr("required", true);
                $("#address").removeAttr("readonly");

                $("#city").val('');
                $("#city").attr("required", true);
                $("#city").removeAttr("readonly");

                $("#state").val('');
                $("#state").attr("required", true);
                $("#state").removeAttr("readonly");

                $("#zipcode").val('');
                $("#zipcode").attr("required", true);
                $("#zipcode").removeAttr("readonly");
            }
        });
    });

    $(document).ready(function() {
        $('#searchByName').on('keyup', function() {
            var input = $(this).val().toLowerCase();

            $('.prasadam-card').each(function() {
                var name = $(this).data('name');

                if (name.includes(input)) {
                    $(this).show();
                } else {
                    $(this).hide();
                }
            });
        });
    });
</script>
<script>
    $(document).ready(function() {
        let baseTotal = parseFloat($('#totalPrice').val()) || 0;

        // Only allow numbers and one decimal point during input
        $('#etKitchenTIp').on('input', function() {
            this.value = this.value
                .replace(/[^0-9.]/g, '') // Remove non-numeric and non-dot
                .replace(/^(\d*\.?\d{0,2}).*$/, '$1'); // Limit to 2 decimal places
        });

        // Format to 2 decimals and update total when user leaves the field
        $('#etKitchenTIp').on('blur', function() {
            let tip = parseFloat(this.value) || 0;
            this.value = tip.toFixed(2); // Format tip to 2 decimals

            let newTotal = baseTotal + tip;

            $('#totalPrice').val(newTotal.toFixed(2)); // hidden input
            $('#totalPriceH').html('<strong>Total: <?php echo $currencySymbol ?>' + newTotal.toFixed(2) + '</strong>'); // visible text
        });
        $(".datepicker").datepicker({
            dateFormat: 'mm/dd/yy', // Month/Day format
            changeMonth: true,
            changeYear: true, // Disable year change
            showButtonPanel: true,
            minDate: 0,

        });
        $('#deliveryTime').mdtimepicker();

        /*  $('#addForm').on('submit', function(e) {
              e.preventDefault(); // Stop default form submit

              let isValid = true;

              // Clear previous error borders
              $('#addForm input').removeClass('is-invalid');

              // Check if any required input is empty
              $('#addForm [required]').each(function() {
                  if (!$(this).val()) {
                      $(this).addClass('is-invalid');
                      isValid = false;
                  }
              });

              if (isValid) {
                  // If all validation passes, submit the form (either via AJAX or normal submit)
                  // this.submit();
                  var frm = $('#addForm');
                  loader.on();
                  $.ajax({
                      type: frm.attr('method'),
                      url: frm.attr('action'),
                      data: frm.serialize(),
                      success: function(data) {
                          loader.off();
                          console.log('Submission was successful.');
                          console.log(data);
                          if (typeof data === 'string') {
                              try {
                                  data = JSON.parse(data); // Manually parse it
                                  console.log('Parsed Data:', data);
                              } catch (e) {
                                  console.log('Error parsing response:', e);
                              }
                          }

                          console.log(data); // Check the parsed data

                          if (data.statusCode) {
                              console.log('Status Code:', data.statusCode); // Expected: "1"
                          } else {
                              console.log('statusCode not found');
                          }

                          if (data.data && data.data.length > 0) {
                              console.log('Invoice No:', data.data[0].invoiceNo); // Expected: 1515
                          }

                          if (data.statusCode == 1) {
                              Swal.fire({
                                  icon: "success",
                                  title: data.data[0].message ?? "Request send successfully!",
                                  html: `<span style='font-weight: 600; display: inline-block; font-size: 22px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;'>Receipt #: ${data.data[0].invoiceNo}</span>`,
                                  confirmButtonText: 'OK',
                                  confirmButtonColor: 'var(--main-color-new-theme)',
                                  customClass: {
                                      popup: 'no-scroll-alert'
                                  }
                              }).then(() => {
                                  window.location.href = "<?php echo base_url() . 'prasadam' ?>";
                              });
                          } else {
                              Swal.fire({
                                  icon: "error",
                                  title: data.data[0].message ?? "Something went wrong!",
                                  html: ``,
                                  confirmButtonText: 'OK',
                                  confirmButtonColor: 'var(--main-color-new-theme)',
                                  customClass: {
                                      popup: 'no-scroll-alert'
                                  }
                              });
                          }



                      },
                      error: function(data) {
                          loader.off();
                          console.log('An error occurred.');
                          console.log(data);
                          Swal.fire({
                              icon: "error",
                              title: "An error occurred.",
                              html: ``,
                              confirmButtonText: 'OK',
                              confirmButtonColor: 'var(--main-color-new-theme)',
                              customClass: {
                                  popup: 'no-scroll-alert'
                              }
                          });
                      },
                  });
              } else {
                  alert("Please fill all required fields.");
              }
          });*/



    });




    $(document).ready(function() {
        // $("#emptyServices").hide();
        $("#emptyServices2").html("");
        $("#foodMenuCategorySearch").on("change", function() {
            // $("#emptyServices2").remove();
            $("#emptyServices2").html("");
            let selectedVal = $(this).val();
            console.log(selectedVal);
            if (selectedVal) {
                // सब hide
                $("#searchHere .serviceSearch").addClass("d-none");
                $("#emptyServices2").html("");
                // attribute selector से safe filter
                // $("#searchHere .serviceSearch[class*='" + selectedVal + "']").show();
                console.log("#searchHere ." + selectedVal);
                let count = $("#searchHere ." + selectedVal).length;
                console.log("Total found: " + count);
                if (count > 0) {
                    $("#searchHere ." + selectedVal).removeClass("d-none");
                } else {
                    $("#emptyServices2").html(
                        '<div class="text-center w-100 text-danger fw-bold">Service not found!</div>'
                    );
                    $("#emptyServices2").css("display", "block");
                    $("#emptyServices2").show();
                }
            } else {
                $("#emptyServices2").html("");
                $("#searchHere .serviceSearch").removeClass("d-none");
            }
        });
    });


    function submitAddForm() {
        let isValid = true;

        // Clear previous error borders
        $('#addForm input').removeClass('is-invalid');

        // Check if any required input is empty
        $('#addForm [required]').each(function() {
            if (!$(this).val()) {
                $(this).addClass('is-invalid');
                isValid = false;
            }
        });

        if (!isValid) {
            alert("Please fill all required fields.");
            return;
        }

        var frm = $('#addForm');
        loader.on();

        const formAction = "<?php echo $formAction ?>";
        console.log("formAction:", formAction);

        // Form data
        let address = $("#address").val();
        let city = $("#city").val();
        let zipcode = $("#zipcode").val();
        let state = $("#state").val();
        let deliveryDate = $("#deliveryDate").val();
        let deliveryTime = $("#deliveryTime").val();
        let delivery = $('[name="delivery"]:checked').val();

        var status = 'TEMP';
        var paymentSource = 'MPI';

        var totalPriceText = $("#totalPrice").val();
        var numericValue = totalPriceText.replace(/[^0-9.]/g, '');
        var totalPrice = parseFloat(numericValue) || 0;

        $.ajax({
            type: "POST",
            url: "<?php echo base_url('Prasadam/AddToCart') ?>",
            data: {
                status: status,
                paymentSource: paymentSource,
                paymentStatus: status,
                transaction_id: '',
                totalPrice: totalPrice,
                etKitchenTIp: etKitchenTIp,
                acharya_sambhavana: 0,
                general_donation: 0,
                deliveryTime: deliveryTime,
                deliveryDate: deliveryDate,
                delivery: delivery,
                address: address,
                city: city,
                state: state,
                zipcode: zipcode,
                formAction: formAction
            },
            success: function(data) {
                loader.off();
                if (typeof data === 'string') {
                    try {
                        data = JSON.parse(data);
                    } catch (e) {}
                }

                if (data.statusCode == 1) {
                    Swal.fire({
                        icon: "success",
                        title: data.data?.[0]?.message ?? "Request send successfully!",
                        html: `<span style='font-weight: 600; display: inline-block; font-size: 22px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;'>Receipt #: ${data.data?.[0]?.invoiceNo}</span>`,
                        confirmButtonText: 'OK',
                        confirmButtonColor: 'var(--main-color-new-theme)',
                        customClass: {
                            popup: 'no-scroll-alert'
                        }
                    }).then(() => {
                        window.location.href = "<?php echo base_url() . 'prasadam' ?>";
                    });
                } else {
                    Swal.fire({
                        icon: "error",
                        title: data.data?.[0]?.message ?? "Something went wrong!",
                        confirmButtonText: 'OK',
                        confirmButtonColor: 'var(--main-color-new-theme)',
                        customClass: {
                            popup: 'no-scroll-alert'
                        }
                    });
                }
            },
            error: function(data) {
                loader.off();
                console.log(data);
                Swal.fire({
                    icon: "error",
                    title: "An error occurred.",
                    confirmButtonText: 'OK',
                    confirmButtonColor: 'var(--main-color-new-theme)',
                    customClass: {
                        popup: 'no-scroll-alert'
                    }
                });
            },
        });
    }


    function submitForm() {
        // ValidateCheckout();
        let isValid = true;
        let msg = '';
        let address = $("#address").val();
        let city = $("#city").val();
        let zipcode = $("#zipcode").val();
        let state = $("#state").val();
        let deliveryDate = $("#deliveryDate").val();
        let deliveryTime = $("#deliveryTime").val();

        if ($('[name="delivery"]:checked').length == 0) {
            isValid = false;
            msg = 'Please select Pickup/Delivery';
            $('[name="delivery"]').first().focus();
        } else {
            if (deliveryDate.length == 0) {
                isValid = false;
                msg = 'Please select Pickup/Delivery Date';
                $("#deliveryDate").focus();
            } else if (deliveryTime.length == 0) {
                isValid = false;
                msg = 'Please select Pickup/Delivery Time';
                $("#deliveryTime").focus();
            } else if ($('[name="delivery"]:checked').val() == 'Delivery') {
                if (address.length == 0) {
                    isValid = false;
                    msg = 'Please fill address';
                    $("#address").focus();
                } else if (city.length == 0) {
                    isValid = false;
                    msg = 'Please fill city';
                    $("#city").focus();
                } else if (state.length == 0) {
                    isValid = false;
                    msg = 'Please fill state';
                    $("#state").focus();
                } else if (zipcode.length == 0) {
                    isValid = false;
                    msg = 'Please fill zipcode';
                    $("#zipcode").focus();
                }
            }
        }




        if (isValid) {
            $('#term_and_conditions').modal('show');


            $('#accept').click(function() {
                $('#term_and_conditions').modal('hide');
                loader.on();
                $.ajax({
                    url: '<?php echo base_url('validate_prasadam_checkout') ?>', // PHP file that checks profile
                    method: 'POST',
                    dataType: 'json',
                    success: function(response) {
                        if (!response) {
                            loader.off();
                            Swal.fire({
                                title: "Oops",
                                text: "Minimum order value must be $10!",
                                icon: "question"
                            });
                        } else {

                            const formAction = "<?php echo $formAction ?>"; // Adjust this as needed
                            if (formAction == "REQUEST WITH PAYMENT" || formAction == "BOOKING WITH PAYMENT") {
                                loader.off();
                                var amt = $("#totalPrice").val();
                                var oldAmt = $("#totalPrice").val();
                                var distAmt = 0;
                                var serviceName = 'Amount To Pay';
                                console.log("serviceName: " + serviceName);
                                $("#serviceNameedittable").html('<h4 id="serviceType">' + serviceName + '</h4><input type="hidden" name="" value="' + serviceName + '" id="serviceType">');
                                $("#edittable").html('<h4 id="servicePrice">$ ' + parseFloat(oldAmt).toFixed(2) + '</h4><input type="hidden" name="" value="' + oldAmt + '" id="serviceAmt"><input type="hidden" name="" value="' + serviceName + '" id="serviceType">');
                                if (oldAmt > amt) {
                                    var distType = '( ' + <?php echo $membershipDiscount ?> + '% )';
                                    if ('<?php echo $discountType ?>' == 'FLAT' || '<?php echo $discountType ?>' == 'SERVICE LEVEL') {
                                        distType = '( $ ' + parseFloat(distAmt).toFixed(2) + ' )';
                                    }
                                    var newRow = '<div class="row"><div class="col-md-6"><h5 class="mb-0" style="font-weight:bold!important;">Subtotal</h5></div><div class="col-md-6 text-end"><span style="font-weight:bold!important;" id="subtle"><?php echo $currencySymbol ?>&nbsp;' + parseFloat(oldAmt).toFixed(2) + '</span></div></div>'
                                    newRow += '<hr><div class="row"><div class="col-md-6"><h5 class="mb-0" style="font-weight:bold!important;font-size: 16px;color:#b00000;"> Membership Discount Applied ' + distType + '</h5></div><div class="col-md-6 text-end"><span style="font-weight:bold!important;color:#b00000;" id="subtle"><?php echo $currencySymbol ?>&nbsp;' + parseFloat(distAmt).toFixed(2) + '</span></div></div>';
                                    newRow += '<hr><div class="row"><div class="col-md-6"><h5 class="mb-0" style="font-weight:bold!important;">Sale Total</h5></div><div class="col-md-6 text-end"><span style="font-weight:bold!important;color:#b00000;" id="subtle"><?php echo $currencySymbol ?>&nbsp;' + parseFloat(amt).toFixed(2) + '</span></div></div><hr>';

                                    $("#serviceNameedittableBody").empty().append(newRow);
                                }
                                $("#membershipModal").modal("show");
                            } else {
                                // $("#addForm").submit();
                                submitAddForm();
                            }
                        }
                    }
                });
            });
        } else {
            $.notify(msg, 'error');
        }

    }

    $('#cancel').click(function() {

        $('#term_and_conditions').modal('hide');
    });

    function ChangeTrayType(traytype, id) {
        // Selected option ka reference lo
        let selectedOption = $("#trayType_" + id + " option:selected");

        // Attributes nikal lo
        let unitPrice = selectedOption.attr("unitPrice");
        let quantity = selectedOption.attr("quantity");
        let UOM = selectedOption.attr("UOM");
        let desc = selectedOption.attr("desc");

        console.log("Tray Type:", traytype);
        console.log("Unit Price:", unitPrice);
        console.log("Quantity:", quantity);
        console.log("UOM:", UOM);
        console.log("Description:", desc);
        $("#chk_" + id).attr("data-price", unitPrice);
        $("#chk_" + id).attr("traytype", traytype);
        $("#Totalprice_" + id).html("$ " + parseFloat(unitPrice).toFixed(2));
        // Example: quantity aur UOM dikhana
        $("#typetrayQty_" + id).html(
            `<b>Quantity: ${quantity} ${UOM}</b><br>${desc ? desc : ""}`
        );
        addTocart();
    }
</script>

<?php

if (isset($paymentSetting) && ($paymentSetting == 'MPITEST' || $paymentSetting == 'MPI') && $paymentSeverOn == 1) { ?>

    <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script> -->



    <?php $mpiTokenPayId = @getclientInfoById()['data'][0]['MPItokenPay'];
    $MpiPayUrl               = base_url('MPI_Payments/Paynow');
    if (isset($mpiTokenPayId) && $mpiTokenPayId != '' && $paymentSetting == 'MPI') {
        $TokenPay = $mpiTokenPayId;
    ?>
        <script type="text/javascript" src="https://www.bridgepaynetsecuretx.com/Bridgepay.WebSecurity/TokenPay/js/tokenPay.js"></script>
    <?php
    } else {
        $TokenPay  = 'tokenpay10579api20211508121542285';
        $MpiPayUrl = base_url('MPI_Payments/PaynowTest');
    ?>
        <script type="text/javascript" src="https://www.bridgepaynetsecuretest.com/WebSecurity/TokenPay/js/tokenPay.js"></script>
    <?php
    }

    ?>
    <script>
        var tokenpay = TokenPay('<?php echo $TokenPay ?>');
        tokenpay.initialize({
            dataElement: '#card',
            errorElement: '#errorMessage',
            amountElement: '#amount',
            useStyles: false,
            useACH: false,
            disableZip: true,
            disableCvv: false
        });

        var form = document.getElementById('paymentForm');
        form.addEventListener('submit', function(event) {


            loader.on();

            const formAction = "<?php echo $formAction ?>";
            console.log("formAction");
            console.log(formAction);

            var formData1 = $("#addForm").serializeArray();
            console.log("Serialized Form Data:", formData1);
            let address = $("#address").val();
            let city = $("#city").val();
            let zipcode = $("#zipcode").val();
            let state = $("#state").val();
            let deliveryDate = $("#deliveryDate").val();
            let deliveryTime = $("#deliveryTime").val();
            let etKitchenTIp = $("#etKitchenTIp").val();
            let delivery = $('[name="delivery"]:checked').val();


            event.preventDefault();
            tokenpay.createToken(function(result) {

                console.log(result);


                var totalPriceText = $("#totalPrice").val();
                var mpi_zipcode = $("#mpi_zipcode").val();
                var mpi_fname = $("#mpi_fname").val();
                var mpi_address = $("#address").val();

                var numericValue = totalPriceText.replace(/[^0-9.]/g, '');
                var numericAmount = parseFloat(numericValue);

                var totolAmt = numericAmount;


                if (result.status == 'auth_success') {


                    var cart_data = '<?php echo json_encode($session_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>';

                    // console.log("cart_data");
                    // console.log(cart_data);
                    $.ajax({
                        url: "<?php echo $MpiPayUrl ?>",
                        type: "POST",
                        dataType: "json",
                        data: {
                            'token': result.token,
                            'totolAmt': totolAmt,
                            'name': mpi_fname,
                            'address': mpi_address,
                            'zipcode': mpi_zipcode,
                            'cart_data': cart_data
                        },
                        success: function(mpicardpayment_response) {

                            console.log(mpicardpayment_response.data);
                            var paymentSource = 'MPI';

                            var status = 'TEMP';

                            var totalPrice = totolAmt;




                            if (mpicardpayment_response.data.responseCode == 00000) {

                                var status = 'COMPLETED';
                                var trnxId = "Payment completed~" + mpicardpayment_response.data.ReferenceNumber + "~" + mpicardpayment_response.data.cardType + "~" + mpicardpayment_response.data.maskedAccountNumber;

                                function responces() {
                                    var status = 'COMPLETED';
                                    var trnxId = "Payment completed~" + mpicardpayment_response.data.ReferenceNumber + "~" + mpicardpayment_response.data.cardType + "~" + mpicardpayment_response.data.maskedAccountNumber;
                                }

                                $.ajax({
                                    url: "<?php echo base_url('Prasadam/AddToCart') ?>",
                                    type: "POST",
                                    dataType: "json",
                                    data: {

                                        'status': status,
                                        'paymentSource': paymentSource,
                                        'paymentStatus': status,
                                        'transaction_id': trnxId,
                                        'totalPrice': totalPrice,
                                        'etKitchenTIp': etKitchenTIp,
                                        'acharya_sambhavana': 0,
                                        'general_donation': 0,
                                        'deliveryTime': deliveryTime,
                                        'deliveryDate': deliveryDate,
                                        'delivery': delivery,
                                        'address': address,
                                        'City': city,
                                        'state': state,
                                        'zipcode': zipcode,
                                        formAction: formAction
                                    },
                                    success: function(addtocart_response) {

                                        console.log(mpicardpayment_response);

                                        if (addtocart_response.statusCode == 1) {




                                            var status = 'COMPLETED';
                                            var trnxId = "Payment completed~" + mpicardpayment_response.data.ReferenceNumber + "~" + mpicardpayment_response.data.cardType + "~" + mpicardpayment_response.data.maskedAccountNumber;

                                            $.ajax({
                                                url: "<?= base_url('Prasadam/updateTransactionStatus') ?>",
                                                type: "POST",
                                                dataType: "json",
                                                data: {
                                                    'status': status,
                                                    'transaction_id': trnxId,
                                                    'paymentDescription': mpicardpayment_response
                                                },
                                                success: function(update_transactionstatus_response) {
                                                    if (update_transactionstatus_response.statusCode == 1) {


                                                        loader.off();



                                                        Swal.fire({
                                                            icon: "success",
                                                            title: "Payment Successfully Processed!",
                                                            html: "<span style='font-weight: 600;margin:5px;padding:5px;font-size: 27px !important;'>Receipt #: " + update_transactionstatus_response.envoiceNo + "</span>",
                                                            confirmButtonText: 'OK',
                                                            confirmButtonColor: 'var(--main-color-new-theme)',
                                                            customClass: {
                                                                popup: 'no-scroll-alert'
                                                            }
                                                        }).then(() => {
                                                            loader.on();
                                                            window.location.href = "<?php echo base_url() . 'akshaya-patra' ?>";
                                                        });

                                                    }

                                                }
                                            });


                                        } else {
                                            swal({
                                                    html: true,
                                                    title: "Something went wrong!",
                                                    text: "",
                                                    type: "error",
                                                    confirmButtonText: 'OK',
                                                    confirmButtonColor: 'var(--main-color-new-theme)',
                                                },
                                                function() {

                                                });

                                            loader.off();
                                        }
                                    }
                                });

                            } else {


                                Swal.fire({
                                    icon: "error",
                                    title: mpicardpayment_response.message,
                                    html: "",
                                    confirmButtonText: 'OK',
                                    confirmButtonColor: 'var(--main-color-new-theme)',
                                }).then(() => {
                                    // window.location.href = "<?php echo base_url() . 'services' ?>";
                                });


                                loader.off();
                            }

                        }
                    });
                } else {
                    alert('Please enter valid details');
                }

            }, function(result) {
                loader.off();
                console.log("error@@@: " + result.token);
            });
        });
    </script>




<?php } ?>