Sh3ll
OdayForums


Server : Apache
System : Linux 145.162.205.92.host.secureserver.net 5.14.0-611.45.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 1 05:56:53 EDT 2026 x86_64
User : tradze ( 1001)
PHP Version : 8.1.34
Disable Function : NONE
Directory :  /home/tradze/www/storage/framework/views/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/tradze/www/storage/framework/views/6276c2580c55a0e36610c89147b2ec9167cff515.php
<!DOCTYPE html>
<html lang="en">
<head>
    <title>Tradze, <?php echo $__env->yieldContent('title'); ?></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE"/>
    <meta property="og:title" content="<?php echo $__env->yieldContent('meta_title'); ?>">
    <meta property="og:description" content="<?php echo $__env->yieldContent('meta_description'); ?>">

    <!-- Global styles START -->
<?php echo $__env->make('frontend_new.partials.core-css', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<!-- Global styles END -->

    <!-- Start css page -->

    <link rel="stylesheet" href="<?php echo e(asset('/themes/frontend_new/assets/plugins/owl.carousel/owl-carousel/owl.theme.css')); ?>" type="text/css" media="screen"/>
    <link rel="stylesheet" href="<?php echo e(asset('/themes/frontend_new/assets/plugins/owl.carousel/owl-carousel/owl.carousel.css')); ?>" type="text/css" media="screen"/>

    <link rel="stylesheet" href="<?php echo e(asset('/themes/frontend_new/assets/plugins/FlipClock/compiled/flipclock.css')); ?>" type="text/css" media="screen">
    <link rel="stylesheet" href="<?php echo e(asset('/themes/frontend_new/assets/css/bootstrap-css/bootstrap-datepicker.css')); ?>" type="text/css" media="screen">
    <link rel="stylesheet" href="<?php echo e(asset('/themes/frontend_new/assets/css/css-carousel-treatments.css')); ?>" type="text/css" media="screen"/>

    <link rel="stylesheet"  href="<?php echo e(asset('/themes/frontend/assets/css/typehead-bootstrap3.css')); ?>" type="text/css" media="screen">

    <link rel="stylesheet" href="<?php echo e(asset('/themes/frontend_new/assets/css/css-top-contact.css')); ?>" type="text/css" media="screen"/>
    <link rel="stylesheet" href="<?php echo e(asset('/themes/frontend_new/assets/css/build.css')); ?>" type="text/css" media="screen"/>
    <link rel="stylesheet" href="<?php echo e(asset('/themes/frontend_new/assets/css/css-book-massage-now.css')); ?>" type="text/css" media="screen"/>

    <link rel="stylesheet" href="<?php echo e(asset('/themes/frontend_new/assets/css/css-book-massage.css')); ?>" type="text/css" media="screen"/>
    <link rel="stylesheet" href="<?php echo e(asset('/themes/frontend_new/assets/css/css-book-massage-later-NEW.css')); ?>" type="text/css" media="screen"/>


    <?php echo $__env->yieldContent('css_page'); ?>
</head>
<body class="no_testimonials_page">
<style>
.cmn_background_cover{ 
    background-image: url("<?php echo e(asset('/themes/frontend_new/assets/img/booking_now_with_text.jpg')); ?>");
        padding: 30px 0;
}
.cmn_background_page{
    padding-top: 0px;
    padding-bottom: 0px;
}
</style>
<?php /*start header*/ ?>
<?php echo $__env->make('frontend_new.partials.header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php /*end start header*/ ?>

<?php /*start contact top*/ ?>
<?php echo $__env->make('frontend_new.partials.contact-top', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php /*end contact top*/ ?>

<?php /*start page container*/ ?>
<a href="<?php echo e(route('bookings.book_a_massage')); ?>" class="back-button">
    <button  class="btn-back"><i class="fa fa-arrow-left"></i></button>
</a>
<?php if(isset($user_count) && $user_count > 0): ?>
<a href="javascript:void(0);">
    <div class="booking_banner booking_banner_cover"> 
        
        <div class="container">
            
            <?php /*start pate-content*/ ?>
            <div class="page-content">

            <?php /*start inject page content*/ ?>
                <?php echo $__env->yieldContent('content'); ?>
            <?php /*end inject page content*/ ?>

            </div>
            <?php /*start page-content*/ ?>

        </div>
        
        <?php /*end page container*/ ?>
    </div>
</a>    
<?php else: ?>
<a href="<?php echo e(route('bookings.book_later')); ?>">
     <div class="booking-banner-main">
           <img width="100%" src="<?php echo e(asset('/themes/frontend_new/assets/img/booking-banner-one.jpg')); ?>"/>
        </div>
 </a>       
<!-- <div class="booking_banner booking_banner_cover cmn_background_cover"> 
 -->
 <?php endif; ?>
     <!-- start buttons massage now & later-->
    <!-- <img class="booking_banner_img" width="100%" src="<?php echo e(asset('/themes/frontend_new/assets/img/message_background_cover.jpg')); ?>"/> -->
    

<div class="modal fade modal-sm-width" id="info-therapist" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>

            <div class="modal-body">
                <?php /*load ajax therapis info*/ ?>
            </div>
        </div>
    </div>
</div>

<!-- Booking Request Modal -->
<div class="modal fade" id="bookingModal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content text-center p-4">
      <div class="spinner-border text-primary mb-3" role="status">
        <span class="sr-only">Loading...</span>
      </div>
      <h5>Please wait for the service provider to accept or reject.</h5>
      <p class="mt-2">Time remaining: <span id="bookingTimer">60</span> sec</p>
    </div>
  </div>
</div>

<?php /*start footer*/ ?>
<?php echo $__env->make('frontend_new.partials.footer', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php /*end footer*/ ?>

<?php echo e(csrf_field()); ?>


<?php /*start core js*/ ?>
<?php echo $__env->make('frontend_new.partials.core-js', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php /*end core js*/ ?>

<?php /*page scripts*/ ?>
<script src="<?php echo e(asset('/themes/frontend_new/assets/plugins/FlipClock/compiled/flipclock.js')); ?>"></script>
<script src="<?php echo e(asset('/themes/frontend_new/assets/js/bootstrap-datepicker.js')); ?>"></script>
<script src="<?php echo e(asset('/themes/frontend_new/assets/js/typeahead.bundle.js')); ?>"></script>

<script type="text/javascript">
    $(document).ready(function () {
        var CSRF_TOKEN = $('input[name="_token"]').val();
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': CSRF_TOKEN
            }
        });

        //find address
        var addressList = new Bloodhound({
            datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
            queryTokenizer: Bloodhound.tokenizers.whitespace,
        //  limit: 20,
        //  sufficient: 40,
            remote: {
                url: 'getaddresslist/',
                replace: function(url, uriEncodedQuery) {
                    var res = url + encodeURIComponent(uriEncodedQuery);
                    return res;
                }
            }
        });
        addressList.initialize();
        console.log(addressList);

        var addAddress = $('.typeahead').typeahead(null, {
            name: 'address',
            displayKey: 'StreetAddress',
            source: addressList,
            hint: false,
            highlight: false,
            minLength: 2,
            limit: 1000,
            templates: {
                empty: [
                    '<div class="row">' +
                    '<div class="col-md-16 text-center text-danger">' +
                    '<i class="fa fa-exclamation-triangle "></i> The Postcode is not found!' +
                    '</div>'+
                    '</div>'

                ],
                suggestion: function (data){
                    if (data.Error){
                        return '<div><i class="fa fa-info-circle"></i> '+data.Cause+'</div>'
                    }
                    else
                        return '<div><i class="fa fa-map-marker"></i> '+data.StreetAddress+' - '+data.Place+'</span></div>'
                }
            }
        });

        //get postcode address and checkit into bd
        addAddress.on('typeahead:selected',function(evt,data){
            console.log(data);
            if (data.Error){
                return false;
            }

            // $.ajax({
            //     method: "POST",
            //     url: "<?php echo e(route('bookings.getaddressdetails')); ?>",
            //     cache: false,
            //     data: { id:data.Id },
            //     dataType: "json",
            // })
            //     .done(function(addr) {

            //         var completeAddress = addr.Line1+' '+addr.Line2+' '+addr.Line3;
                    var completeAddress = data.Place;
            // alert(completeAddress);
                    $.ajax({
                        method: "POST",
                        url: "<?php echo e(route('bookings.setpostcode')); ?>",
                        cache: false,
                        // data: { postcode:addr.Postcode, address: completeAddress },
                        data: { address: completeAddress },
                        dataType: "json",
                    })
                        .error(function(data){
                            var response = jQuery.parseJSON(data.responseText);
                            $('#modalInfo').find('.modal-title').text('ERROR');
                            $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>"+response.message+"</h5>");
                            $('#modalInfo').modal('show');
                        })
                        .done(function(data) {
                            selecttype();
                            load_hours(date);
                            $('#modalInfo').find('.modal-title').text('SUCCESS');
                            $('#modalInfo').find('.modal-body').html("<h5 class='text-success'>"+data.message+"</h5>");
                            $('#modalInfo').modal('show');
                        });
                //});
        });

        var reservedTime = "300";

        //date
        if ($("#datepicker").length>0){
            <?php if(isset($booking['date'])): ?>
            $("#datepicker").datepicker().datepicker("setDate", new Date('<?php echo e($booking['date']); ?>'));
            var date = $('#datepicker').datepicker('getFormattedDate',"yyyy-mm-dd");
                    <?php else: ?>
            var date = $('#datepicker').datepicker('getFormattedDate',"yyyy-mm-dd");
            <?php endif; ?>

        }
        else{
            var date = '<?php echo e(\Carbon\Carbon::now()->format('Y-m-d')); ?>';
        }

        //select no of therapists
        selecttype();

        // POPOVER FOCAL POINT
        $('[data-toggle="popover"]').popover();

        $(".focalpoint").click(function(){
            $(this).toggleClass('selected');

            var selectedfp=[];
            $(".focalpoint.selected").each(function(i,el){
                selectedfp.push($(el).attr('focal_point'));
            });

            $.ajax({
                method: "POST",
                url: "<?php echo e(route('bookings.setfocalpoints')); ?>",
                cache: false,
                data: { fp:selectedfp },
                dataType: "json",
            })

        });

        //add to basket
        $("body").on('click','.reservation-button, .checkout-button', function(){
            var url = $(this).attr('url');
            var toUrl = '<?php echo e(route("bookings.basket.checkout")); ?>';
            var bigContainer = $('.light-bg');

            $.ajax({
                method: "GET",
                url: url,
                cache: false,
                beforeSend: function(){
                    bigContainer.addClass('blocked');
                }
            })
                .error(function(data){
                    load_hours(date);
                    displayTherapists();
                    bigContainer.removeClass('blocked');
                    var response = jQuery.parseJSON(data.responseText);
                    $('#modalInfo').find('.modal-title').text('ERROR');
                    $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>"+response.message+"</h5>");
                    $('#modalInfo').modal('show');
                })
                .done(function(data) {

                    window.location.href = toUrl;
                });
        });

        $('body').on('click','.pick-a-day-selected-teharpist', function () {
            console.log("here");
            var date = $(this).attr('date');
            var thId = $(this).attr('thId');
            var calendar = $('#selected-teharpist-calendar-dates');
            var calendarDates = calendar.find('.item');

            calendarDates.each(function () {
                if($(this).hasClass('active-item'))
                {
                    $(this).removeClass('active-item');
                }
                if($(this).attr('date') == date)
                {
                    $(this).addClass('active-item');
                }
            })

            load_therapist_hours(date,thId);
        });

         //select an hour
        $("body").on('click', '.selecthour-therapist', function () {

            if ($(this).hasClass('disable-hour')) {
                event.preventDefault(); // Prevent the default action
                // Optionally, you can also stop the event from propagating
                // event.stopPropagation();
                return;
            }
            var hour_val = $(this).attr('hour-val');
            var therapist = $(this).attr('therapist');
            var date = $(this).attr('date');

            var timeline = $('#timeline-therapist-hours');
            var timelineHours = timeline.find('.item_hour');

            $.ajax({
                method: "POST",
                url: "<?php echo e(route('bookings.settherapisthour')); ?>",
                cache: false,
                data: {'thID': therapist,'date': date,'hour': hour_val},
                dataType: "json",
            })
                .error(function (data) {
                    var response = jQuery.parseJSON(data.responseText);
                })
                .done(function (data) {
                    timelineHours.each(function () {
                        if($(this).hasClass('active-hour'))
                        {
                            $(this).removeClass('active-hour');
                        }
                        if($(this).attr('hour-val') == hour_val)
                        {
                            $(this).addClass('active-hour');
                        }
                    })

                    $('#info-therapist').find('#modal-booking-action').html(data.partial_button_book_therapist);
                    $('#info-therapist').find('#modal-booking-action').show('fade');
                });
        });

        //book a therapist modal
        // $("body").on('click', '.book-therapist-now-modal', function () {

        //     var massageTableStatus = document.getElementById('message_table_status_value').value;
        //     var isMassageStatus = document.getElementById('is_message_value').value;
        //     // console.log(massageTableStatus, isMassageStatus);
        //    if (massageTableStatus == 0) {
        //             // var confirmed = confirm('Please note: This practitioner does not provide Equipment/Massage Table, you can book with a practitioner that provides Equipment (Please check service provider profile). Alternatively if you do not require Equipment/ Massage Table please continue. ');
        //             // var confirmed = confirm('<span style="font-weight: bold;">Please note:</span> This practitioner does not provide <span style="font-weight: bold;">Equipment/Massage Table,</span> you can book with a practitioner that provides Equipment <span style="font-weight: bold;">(Please check service provider profile).</span> Alternatively if you do not require <span style="font-weight: bold;">Equipment/ Massage Table</span> please continue. ');
                    
        //     }
        //     // console.log("booking done");
        //     // return;
        //     $.ajax({
        //         method: "POST",
        //         url: "<?php echo e(route('bookings.settherapists-modal')); ?>",
        //         cache: false,
        //         data: {'thID': $(this).attr('therapist'),'date': $(this).attr('date'),'hour': $(this).attr('hour')},
        //         dataType: "json",
        //     })
        //         .error(function (data) {
        //             var response = jQuery.parseJSON(data.responseText);
        //         })
        //         .done(function (data) {
        //             $.ajax({
        //                 method: "GET",
        //                 url: "<?php echo e(route('bookings.basket.add')); ?>",
        //                 cache: false,
        //                 dataType: "json",
        //             })
        //                 .error(function (data) {
        //                     var response = jQuery.parseJSON(data.responseText);
        //                     $('#info-therapist').modal('hide');
        //                     $('#modalInfo').find('.modal-title').text('ERROR');
        //                     $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>" + response.message + "</h5>");
        //                     $('#modalInfo').modal('show');
        //                 })
        //                 .done(function (data) {
        //                     if(data.message)
        //                     {
        //                         console.log(data.message);
        //                         // $('#modalInfo').find('.modal-title').text('SUCCESS');
        //                         // $('#modalInfo').find('.modal-body').html("<h5 class='text-success'>" + data.message + "</h5>");
        //                         // $('#modalInfo').modal('show');

        //                         setTimeout(
        //                             function()
        //                             {
        //                                 var url_checkout ="<?php echo e(route('bookings.basket.checkout')); ?>";
        //                                 window.location.replace(url_checkout);
        //                             }, 2000);
        //                     }
        //                 });
        //         });

        // });

        // COUNTER
        var clock = $('.clock-01').FlipClock(reservedTime, {
            countdown: true,
            clockFace: 'MinuteCounter',
            autoStart: false,
        });
        var clock2 = $('.clock-02').FlipClock(reservedTime, {
            countdown: true,
            clockFace: 'MinuteCounter',
            autoStart: false,
        });

        // DATE PICKER
        $('#datepicker').datepicker({
            startDate: '+1d',
        });

        displayTherapists();

        // CUSTOM RADIO BUTTONS
        function changeState(el) {
            if (el.readOnly) el.checked = el.readOnly = false;
            else if (!el.checked) el.readOnly = el.indeterminate = true;
        }

        //select massage info:location, duration, massage type
        $("#validpostalcode").click(function(){
            var postalcode = $("#postalcode");
            $.ajax({
                method: "POST",
                url: "<?php echo e(route('bookings.setpostcode')); ?>",
                cache: false,
                data: { postcode:postalcode.val() },
                dataType: "json",
            })
                .error(function(data){
                    var response = jQuery.parseJSON(data.responseText);
                    $('#modalInfo').find('.modal-title').text('ERROR');
                    $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>"+response.message+"</h5>");
                    $('#modalInfo').modal('show');
                })
                .done(function(data) {
                    selecttype();
                    load_hours(date);
                    $('#modalInfo').find('.modal-title').text('SUCCESS');
                    $('#modalInfo').find('.modal-body').html("<h5 class='text-success'>"+data.message+"</h5>");
                    $('#modalInfo').modal('show');
                });
        });

        $("#duration").change(function(){
            $.ajax({
                method: "POST",
                url: "<?php echo e(route('bookings.setduration')); ?>",
                cache: false,
                data: { duration:$(this).val() },
                dataType: "json",
            })
                .error(function(data){
                    var response = jQuery.parseJSON(data.responseText);
                })
                .done(function(data){
                    load_hours(date);
                });

        });

        $("#massage").change(function(){
            $.ajax({
                method: "POST",
                url: "<?php echo e(route('bookings.setmassage')); ?>",
                cache: false,
                data: { massage:$(this).val() },
                dataType: "json",
            })
                .error(function(data){
                    var response = jQuery.parseJSON(data.responseText);
                })
                .done(function(data){
                    load_hours(date);
           load_therapists();
           displayTherapists();
                });

        });

        //select an hour
        $("body").on('click','.selecthour', function(){
            $.ajax({
                method: "POST",
                url: "<?php echo e(route('bookings.sethour')); ?>",
                cache: false,
                data: { hour:$(this).val() },
                dataType: "json",
            })
                .error(function(data){
                    var response = jQuery.parseJSON(data.responseText);
                })
                .done(function(data){
                    load_therapists();
                    displayTherapists();
                });
        });

    //select a therapist
    // $("body").on('click','.therapist', function(){
    //     $.ajax({
    //             method: "POST",
    //             url: "<?php echo e(route('bookings.settherapistsnow')); ?>",
    //             cache: false,
    //             data: { 'thID':$(this).attr('therapist'),'hour': $(this).attr('hour')},
    //             dataType: "json",
    //         }).error(function(data){
    //             load_hours(date);
    //             var response = jQuery.parseJSON(data.responseText);
    //             $('#modalInfo').find('.modal-title').text('ERROR');
    //             $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>"+response.message+"</h5>");
    //             $('#modalInfo').modal('show');
    //         })
    //         .done(function(data){
    //             date = selectdate();
    //             load_hours(date);
    //             $.ajax({
    //                  method: "GET",
    //                  url: "<?php echo e(route('bookings.basket.add')); ?>",
    //                  cache: false,
    //                  dataType: "json",
    //             })
    //             .error(function (data) {
    //                 var response = jQuery.parseJSON(data.responseText);
    //                 $('#modalInfo').find('.modal-title').text('ERROR');
    //                 $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>" + response.message + "</h5>");
    //                 $('#modalInfo').modal('show');
    //             })
    //             .done(function (data) {
    //                 if(data.message)
    //                 {
    //                     console.log(data.message);
    //                     // $('#modalInfo').find('.modal-title').text('SUCCESS');
    //                     // $('#modalInfo').find('.modal-body').html("<h5 class='text-success'>" + data.message + "</h5>");
    //                     // $('#modalInfo').modal('show');
    //                     setTimeout(
    //                         function()
    //                         {
    //                             var url_checkout ="<?php echo e(route('bookings.basket.checkout')); ?>";
    //                             window.location.replace(url_checkout);
    //                         }, 2000);
    //                 }
    //         });
    //     });
    // });

    let bookingInterval;

    $("body").on('click', '.book-therapist-now', function() {

        $.ajax({
                method: "POST",
                url: "<?php echo e(route('bookings.askForBooking')); ?>",
                cache: false,
                data: {
                    'thID': $(this).attr('therapist'),
                    'customerID': "<?php echo e(Auth::id()); ?>",
                    'clickedFrom':"",
                    'hour': $(this).attr('hour')
                },
                dataType: "json",
            }).done(function(data) {
            // Show modal
                $("#bookingModal").modal({
                    backdrop: 'static',
                    keyboard: false
                }).modal('show');

                // Start 20s countdown
                let timeLeft = 60;
                $("#bookingTimer").text(timeLeft);

            // clear old intervals if any
            if (bookingInterval) {
                clearInterval(bookingInterval);
            }

            bookingInterval = setInterval(function() {
                timeLeft--;
                $("#bookingTimer").text(timeLeft);

                if (timeLeft <= 0) {
                    clearInterval(bookingInterval);
                    $("#bookingModal").modal("hide");
                    // trigger expire if no response in 60s
                    socket.emit("expire-req", { req_id:data.req_id,'status': 'EXPIRED' ,msg: "Request expired",customer_id: `<?php echo e(Auth::id()); ?>`});
                    
                }
            }, 1000);
            })
            .fail(function(data) {
                alert("Something went wrong!");
        });
    });

       // Close modal only when socket events come
    socket.on("respond-book-request-client", function(data) {
        clearInterval(bookingInterval);
        let providerId = data.provider_id
        let hour = data.hour
        $("#bookingModal").modal("hide");
        if (data.status === "accepted") {
            console.log(data)
            Swal.fire({
                icon: 'success',
                title: 'Available!',
                text: 'The service provider is available.',
                confirmButtonText: 'Book Service',
                customClass: {
                    popup: 'my-swal'
                }
            }).then((result) => {
            if (result.isConfirmed) {
            // Call your function here
            $.ajax({
                method: "POST",
                url: "<?php echo e(route('bookings.settherapistsnow')); ?>",
                cache: false,
                data: { 'thID':providerId,'hour': hour},
                dataType: "json",
            }).error(function(data){
                load_hours(date);
                var response = jQuery.parseJSON(data.responseText);
                $('#modalInfo').find('.modal-title').text('ERROR');
                $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>"+response.message+"</h5>");
                $('#modalInfo').modal('show');
            })
            .done(function(data){
                date = selectdate();
                load_hours(date);
                $.ajax({
                     method: "GET",
                     url: "<?php echo e(route('bookings.basket.add')); ?>",
                     cache: false,
                     dataType: "json",
                })
                .error(function (data) {
                    var response = jQuery.parseJSON(data.responseText);
                    $('#modalInfo').find('.modal-title').text('ERROR');
                    $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>" + response.message + "</h5>");
                    $('#modalInfo').modal('show');
                })
                .done(function (data) {
                    if(data.message)
                    {
                        console.log(data.message);
                        // $('#modalInfo').find('.modal-title').text('SUCCESS');
                        // $('#modalInfo').find('.modal-body').html("<h5 class='text-success'>" + data.message + "</h5>");
                        // $('#modalInfo').modal('show');
                        setTimeout(
                            function()
                            {
                                var url_checkout ="<?php echo e(route('bookings.basket.checkout')); ?>";
                                window.location.replace(url_checkout);
                            }, 2000);
                    }
            });
        });
                }
        });
            // var has_message_table = document.getElementById('has_message_table_'+$(this).attr('therapist')).value;
          
        } else if (data.status === "declined") {
        Swal.fire({
            icon: 'error',
            title: 'Declined!',
            text: 'The service provider is not available.',
            confirmButtonText: 'OK',
            customClass: {
                popup: 'my-swal'
            }
        });
        }
    });


    $("body").on('click', '.book-therapist-now-modal', function () {

        $.ajax({
            method: "POST",
            url: "<?php echo e(route('bookings.askForBooking')); ?>",
            cache: false,
            data: {
                'thID': $(this).attr('therapist'),
                'customerID': "<?php echo e(Auth::id()); ?>",
                'clickedFrom':"profileModal",
                'date': $(this).attr('date'),
                'hour': $(this).attr('hour')
            },
            dataType: "json",
        }).done(function(data) {
        // Show modal
            $("#bookingModal").modal({
                backdrop: 'static',
                keyboard: false
            }).modal('show');
        
            // Start 20s countdown
            let timeLeft = 60;
            $("#bookingTimer").text(timeLeft);
        
        // clear old intervals if any
        if (bookingInterval) {
            clearInterval(bookingInterval);
        }
    
        bookingInterval = setInterval(function() {
            timeLeft--;
            $("#bookingTimer").text(timeLeft);
        
            if (timeLeft <= 0) {
                clearInterval(bookingInterval);
                $("#bookingModal").modal("hide");
                // trigger expire if no response in 60s
                socket.emit("expire-req", { req_id:data.req_id,'status': 'EXPIRED' ,msg: "Request expired",customer_id: `<?php echo e(Auth::id()); ?>`});
            }
        }, 1000);
        })
        .fail(function(data) {
            alert("Something went wrong!");
        });

        // var massageTableStatus = document.getElementById('message_table_status_value').value;
        // var isMassageStatus = document.getElementById('is_message_value').value;
            
        // $.ajax({
        //         method: "POST",
        //         url: "<?php echo e(route('bookings.settherapists-modal')); ?>",
        //         cache: false,
        //         data: {'thID': $(this).attr('therapist'),'date': $(this).attr('date'),'hour': $(this).attr('hour')},
        //         dataType: "json",
        //     })
        //         .error(function (data) {
        //             var response = jQuery.parseJSON(data.responseText);
        //         })
        //         .done(function (data) {
        //             $.ajax({
        //                 method: "GET",
        //                 url: "<?php echo e(route('bookings.basket.add')); ?>",
        //                 cache: false,
        //                 dataType: "json",
        //             })
        //                 .error(function (data) {
        //                     var response = jQuery.parseJSON(data.responseText);
        //                     $('#info-therapist').modal('hide');
        //                     $('#modalInfo').find('.modal-title').text('ERROR');
        //                     $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>" + response.message + "</h5>");
        //                     $('#modalInfo').modal('show');
        //                 })
        //                 .done(function (data) {
        //                     if(data.message)
        //                     {
        //                         console.log(data.message);
        //                         // $('#modalInfo').find('.modal-title').text('SUCCESS');
        //                         // $('#modalInfo').find('.modal-body').html("<h5 class='text-success'>" + data.message + "</h5>");
        //                         // $('#modalInfo').modal('show');

        //                         setTimeout(
        //                             function()
        //                             {
        //                                 var url_checkout ="<?php echo e(route('bookings.basket.checkout')); ?>";
        //                                 window.location.replace(url_checkout);
        //                             }, 2000);
        //                     }
        //                 });
        //         });
    });

    // Close modal only when socket events come (model)
    socket.on("respond-book-request-client-modal", function(data) {
        clearInterval(bookingInterval);
        let providerId = data.provider_id
        console.log(data)
        $("#bookingModal").modal("hide");
        if (data.status === "accepted") {
        
            Swal.fire({
                icon: 'success',
                title: 'Available!',
                text: 'The service provider is available.',
                confirmButtonText: 'Book Service',
                customClass: {
                    popup: 'my-swal'
                }
            }).then((result) => {
                if (result.isConfirmed) {
                    var massageTableStatus = document.getElementById('message_table_status_value').value;
                    var isMassageStatus = document.getElementById('is_message_value').value;

                    $.ajax({
                        method: "POST",
                        url: "<?php echo e(route('bookings.settherapists-modal')); ?>",
                        cache: false,
                        data: {'thID': providerId,'date': data.date,'hour': data.hour},
                        dataType: "json",
                    })
                    .error(function (data) {
                            var response = jQuery.parseJSON(data.responseText);
                        })
                        .done(function (data) {
                            $.ajax({
                                method: "GET",
                                url: "<?php echo e(route('bookings.basket.add')); ?>",
                                cache: false,
                                dataType: "json",
                            })
                                .error(function (data) {
                                    var response = jQuery.parseJSON(data.responseText);
                                    $('#info-therapist').modal('hide');
                                    $('#modalInfo').find('.modal-title').text('ERROR');
                                    $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>" + response.message + "</h5>");
                                    $('#modalInfo').modal('show');
                                })
                                .done(function (data) {
                                    if(data.message)
                                    {
                                        console.log(data.message);
                                        // $('#modalInfo').find('.modal-title').text('SUCCESS');
                                        // $('#modalInfo').find('.modal-body').html("<h5 class='text-success'>" + data.message + "</h5>");
                                        // $('#modalInfo').modal('show');
                                    
                                        setTimeout(
                                            function()
                                            {
                                                var url_checkout ="<?php echo e(route('bookings.basket.checkout')); ?>";
                                                window.location.replace(url_checkout);
                                            }, 2000);
                                    }
                                });
                        });
                        }
                    });
            // var has_message_table = document.getElementById('has_message_table_'+$(this).attr('therapist')).value;
          
        } else if (data.status === "declined") {
        Swal.fire({
            icon: 'error',
            title: 'Declined!',
            text: 'The service provider is not available.',
            confirmButtonText: 'OK',
            customClass: {
                popup: 'my-swal'
            }
        });
        }
    });

    socket.on("expire-req-client", function(data) {
        clearInterval(bookingInterval);
        updateBookReq(data.req_id,'EXPIRED');
        $("#bookingModal").modal("hide");
        Swal.fire({
            icon: 'warning',
            title: 'Request Expired',
            text: 'Your booking request has expired.',
            confirmButtonText: 'OK',
            customClass: {
                popup: 'my-swal'
            }
        });
    });

    function updateBookReq(reqId,status){
        fetch("<?php echo e(route('bookings.update.book.request')); ?>", {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "X-CSRF-TOKEN": $('input[name="_token"]').val()
            },
            body: JSON.stringify({
                req_id: reqId,
                status: 'EXPIRED'
            }),
            cache: "no-cache"
        })
        .then(response => response.json())
        .then(result => {
            console.log("Success:", result);
        })
        .catch(error => {
            console.error("Error:", error);
        });
    }

        //select a therapist
        $("body").on('click','.thNo', function(){
            selecttype();
        });

          //view therapist info
        $("body").on('click','.see-therapist-info, .see-availablility', function () {
            var bigContainer = $('.light-bg');
            var thId = $(this).attr('therapist');
            $.ajax({
                method: "POST",
                url: "<?php echo e(route('bookings.view-therapist-info')); ?>",
                cache: false,
                data: {'thID': thId,'availability': $(this).attr('availability')},
                beforeSend: function () {},
                dataType: "json",
            })
                .done(function (data) {
                    bigContainer.removeClass('blocked');
                    $('#info-therapist').find('.modal-body').html("<span><i class='fa fa-spin fa-spinner fa-4x'></i></span>");
                    $('#info-therapist').find('.modal-body').html(data.partial);
                    $('[data-toggle="tooltip"]').tooltip();

                    // if(!data.availability)
                    // {
                        $('#info-therapist').find('#modal-booking-action').hide();
                    // }
                    $('#info-therapist').modal('show');

                    $(".owl-select-date-tab").owlCarousel({
                        autoPlay: false, //Set AutoPlay to 3 seconds
                        navigation: true,
                        pagination: false,
                        itemsCustom: [
                            [0, 3],
                            [450, 3],
                            [600, 3],
                            [700, 4],
                            [1000, 6],
                            [1200, 5],
                            [1400, 5],
                            [1600, 6]
                        ],
                    });
                    load_therapist_hours(data.selected_date,thId);
                });
        });
    });

      //load therapist hours
    function load_therapist_hours(date,thId) {
        var hours = $("#therapist-hours");
        console.log("here 2");
        //get hours
        $.ajax({
            method: "POST",
            url: "<?php echo e(route('bookings.gettherapisthours')); ?>",
            data: {'thID': thId,'date': date},
            cache: false,
            beforeSend: function () {
                hours.html("<span><i class='fa fa-spin fa-spinner fa-4x'></i></span>");
            },
            dataType: "html",
        })
            .done(function (data) {
                var data = JSON.parse(data);
                console.log(data.hours_count);
                hours.hide(0);
                if(data.hours_count > 0) {
                    console.log("inside condition");
                    hours.html(data.partial_therapist_hours);
                } else {
                    console.log("inside condition 2");
                    hours.html(data.partial_therapist_hours);
                    $('#info-therapist').find('#modal-booking-action').html('');
                }
                hours.fadeIn();
            });
    }

    function selectdate(){
        //date
        if ($("#datepicker-later").length>0){
                    <?php /*<?php if(isset($booking['date'])): ?>*/ ?>
                    <?php /*console.log('aici');*/ ?>
                    <?php /*$("#datepicker-later").datepicker().datepicker("setDate", new Date('<?php echo e($booking['date']); ?>'));*/ ?>
                    <?php /*var date = $('#datepicker-later').datepicker('getFormattedDate',"yyyy-mm-dd");*/ ?>
                    <?php /*<?php else: ?>*/ ?>
            var date = $('#datepicker-later').datepicker('getFormattedDate',"yyyy-mm-dd");
            <?php /*<?php endif; ?>*/ ?>

        }
        else{
            var date = '<?php echo e(\Carbon\Carbon::now()->format('Y-m-d')); ?>';
        }

        return date;
    }

    function selecttype(){

        var el_val = "1_th";

        $.ajax({
            method: "POST",
            url: "<?php echo e(route('bookings.settherapistsno')); ?>",
            cache: false,
            data: { 'thNo':el_val },
            dataType: "json",
        })
            .error(function(data){
                var response = jQuery.parseJSON(data.responseText);
            })
            .done(function(data){
                load_therapists();
                displayTherapists();
            });
    }

    function displayTherapists(){
        var therapistsnfo = $("#therapists_info");
        $.ajax({
            method: "GET",
            url: "<?php echo e(route('bookings.selectedtherapists')); ?>",
            cache: false,
            beforeSend: function() {
                therapistsnfo.html("<span class='text-white'><i class='fa fa-spin fa-spinner fa-4x'></i></span>");
            },
            dataType: "html",
        })
            .done(function(data){
                // therapistsnfo.hide(0);
                // therapistsnfo.html(data);
                // therapistsnfo.fadeIn();
            });
    }

    //add to basket
    $("body").on('click','.checkout-pay, .add-basket', function(){
        var url = $(this).attr('url');
        var toUrl = '<?php echo e(route("bookings.basket.checkout")); ?>';
        var bigContainer = $('.light-bg');

        $.ajax({
            method: "GET",
            url: url,
            cache: false,
            beforeSend: function(){
                bigContainer.addClass('blocked');
            }
        })
            .error(function(data){
                bigContainer.removeClass('blocked');
                var response = jQuery.parseJSON(data.responseText);
                $('#modalInfo').find('.modal-title').text('ERROR');
                $('#modalInfo').find('.modal-body').html("<h5 class='text-danger'>"+response.message+"</h5>");
                $('#modalInfo').modal('show');
            })
            .done(function(data) {

                window.location.href = toUrl;
            });
    });


    //load hours
    function load_hours(date){
        load_therapists();
    } //end load hours

    //load therapists
    function load_therapists(){
        var therapists = $("#therapists");
        $.ajax({
            method: "GET",
            url: "<?php echo route('bookings.gettherapistsnow'); ?>",
            cache: false,
            beforeSend: function() {
                therapists.html("<span class='text-white'><i class='fa fa-spin fa-spinner fa-4x'></i></span>");
            },
            dataType: "html",
        })
            .done(function(data) {
                console.log(data);
                therapists.hide(0);
                therapists.html(data);
                therapists.fadeIn();
                $('[data-toggle="tooltip"]').tooltip();
            });
    } //end load therapists
</script>
<?php /*end scripts*/ ?>

<?php /*start custom scripts*/ ?>
<?php echo $__env->yieldContent('custom_scripts'); ?>
<?php /*end custom scripts*/ ?>
<script type="text/javascript">
        var date = "<?php echo e($today); ?>";
        $(document).ready(function () {

            //initialize tooltip
            $('[data-toggle="tooltip"]').tooltip();

            //select hours and therapists
            load_hours(date);
        });
</script>
<?php /*Page JS*/ ?>
<script type="text/javascript" src="<?php echo e(asset('/themes/frontend_new/assets/plugins/owl.carousel/owl-carousel/owl.carousel.js')); ?>"></script>
<script>
    $(document).ready(function () {
        $(".owl-treatments").owlCarousel({
            autoPlay: 3000, //Set AutoPlay to 3 seconds
            navigation: false,
            pagination: true,
            itemsCustom: [
                [0, 2],
                [450, 2],
                [600, 3],
                [700, 4],
                [1000, 5],
                [1200, 6],
                [1400, 6],
                [1600, 7]
            ],
        });

        $(".owl-social").owlCarousel({
            autoPlay: 3000, //Set AutoPlay to 3 seconds
            navigation: false,
            pagination: true,
            itemsCustom: [
                [0, 2],
                [450, 2],
                [600, 3],
                [700, 3],
                [1000, 4],
                [1200, 5],
                [1400, 5],
                [1600, 5]
            ],
        });

        $(".owl-event").owlCarousel({
            autoPlay: 3000, //Set AutoPlay to 3 seconds
            navigation: true,
            pagination: false,
            itemsCustom: [
                [0, 1],
                [450, 1],
                [600, 3],
                [700, 3],
                [1000, 4],
                [1200, 4],
                [1400, 5],
                [1600, 5]
            ],
        });
    });
</script>
</body>
</html>

ZeroDay Forums Mini