<?php
$response = Http::post(config('app.backendapi') . 'setting/site-setting-list', [
    'data' => [
        'storeId' => config('app.storeId'),
    ],
]);
$details = $response->json();
$data = '';
if (isset($details['errorNode']['errorCode']) && $details['errorNode']['errorCode'] == 0) {
    $data = $details['data']['details'];
}
?>
<footer>
    <div class="container">
        <div class="row p-3 p-md-0 text-left">
            <div class="col-md-3 text-left p-text">
                <h2 class=" title-bx1">Important Link</h2>
                <ul class="area8">
                    <li>
                        <a href="http://vidyasagar.ac.in/"><img src="<?php echo e(asset('assets/image/logo-f.png')); ?>"></a>
                    </li>
                    <li>
                        <a href="https://www.wbbpe.org/"><img src="<?php echo e(asset('assets/image/logo-f1.png')); ?>"></a>
                    </li>
                    <li>
                        <a href="https://www.wbuttepa.ac.in/"><img src="<?php echo e(asset('assets/image/logo-f2.jpg')); ?>"></a>
                    </li>
                </ul>
            </div>
            <div class="Links" style="display:none;"></div>
            <div class="col-md-3 ul-link" id="NavBarIudyogFooter">
                <h2 class="title-bx1">Useful Links</h2>
                <ul>
                    <li>Home</li>
                    <li>About Us</li>
                    <li>Administration</li>
                    <li>Management</li>
                    <li>Mission and Vision</li>
                    <li>Non Teaching</li>
                    <li>Teachers</li>
                </ul>
            </div>
            <div class="col-md-3 ul-link ">
                <h2 class="title-bx1">Colleges</h2>
                <p>Rishi Aurobindo Institute of Teacher Education
                    CMC Vellore, Vellore
                    Indian Institute of Technology, Roorkee
                    Indian Institute of Management, Bangalore
                    SRM University, Amaravati
                    Bharathiar University, Coimbatore
                    Indian Institute of Management, Bangalore
                    SRM University, Amaravati</p>
            </div>
            <div class="col-md-3 ">
                <h2 class="title-bx1">Get in Touch</h2>
                <div class="col-md-12 px-0">
                    <p><?php echo e($data['address']); ?></p>
                    <ul class="f-share">
                        <li><a href="<?php echo e($data['facebookLink']); ?>"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div class="footer-areain">
        <div class="container">
            <div class="row justify-content-center">
			<div class="text-center">
                <a>Copyright © 2022 S<?php echo e(__('kultikri-college')); ?></a> All Rights Reserved
                <a>Powered By</a>
                <a href="http://www.iudyog.com/" target="_blank"><?php echo e(__('iUdyog')); ?></a>
            </div>
                
            </div>
        </div>
    </div>
</footer>
<script src="<?php echo e(asset('js/script.js')); ?>"></script>
<script src="<?php echo e(asset('js/jquery.min.js')); ?>"></script><!-- JQUERY.MIN JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.0/socket.io.js"></script>
<script src="<?php echo e(asset('js/bootstrap.min.js')); ?> "></script>
<script src="<?php echo e(asset('js/popper.min.js')); ?>"></script>
<script src="<?php echo e(asset('js/owl.carousel.js')); ?>"></script>
<script src="<?php echo e(asset('js/lightboxJS/js/lightbox.js')); ?>"></script>
<script src="https://www.rabedc.com/js/slick/slick.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $.ajax({
            url: "<?php echo e(route('allMenu')); ?>",
            data: {
                _token: "<?php echo e(csrf_token()); ?>"
            },
            type: "POST",
            success: function(res) {
                if (res.success) {
                    $('#navbarSupportedContent').html(res.topMenu);
                    if (res.footerMenu != '') {
                        $('#NavBarIudyogFooter').html(res.footerMenu);
                    }
                }
            }
        });
    });
    function sendmsg() {
        var name = $('#name').val();
        var phone = $('#phone').val();
        var email = $('#email').val();
        var msg = $('#msg').val();
        $.ajax({
            url: "<?php echo e(route('sendmsg')); ?>",
            data: {
                _token: "<?php echo e(csrf_token()); ?>",
                name: name,
                phone: phone,
                email: email,
                msg: msg
            },
            type: "POST",
            success: function(res) {
                if (res.success) {
                    $('#success').html(res.msg);
                }
            }
        });
    }
</script>
<script src="<?php echo e(asset('js/script.js')); ?>"></script>
<!-- fontawesome -->
<script src="https://use.fontawesome.com/8ae5a19cac.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        jQuery(document).ready(function() {
            jQuery(".hum-one").click(function() {
                jQuery("html").toggleClass('open-rightmenu');
            });

        });
        jQuery(document).ready(function() {
            jQuery(".bg-menu-r, .close-r").click(function() {
                jQuery("html").removeClass("open-rightmenu");
            });
        });
    });
    $(document).ready(function() {
        $('.search-top').on('click', function(e) {
            $('body').toggleClass("aactive");
            e.preventDefault();
        });
    });
    jQuery(document).ready(function(e) {
        jQuery('.item-head').click(function(e) {
            if (jQuery(this).next('.item-data').css('display') != 'block') {
                jQuery('.active').removeClass('active');
                jQuery(this).next('.item-data').addClass('active')
            } else {
                jQuery('.active').removeClass('active');
            }
        });
    });
    $(document).ready(function() {
        $.ajax({
            url: "<?php echo e(route('allMenu')); ?>",
            data: {
                _token: "<?php echo e(csrf_token()); ?>"
            },
            type: "POST",
            success: function(res) {
                if (res.success) {
                    $('#navbarSupportedContent').html(res.topMenu);
                    if (res.footerMenu != '') {
                        $('#NavBarIudyogFooter').html(res.footerMenu);
                    }
                }
            }
        });
    });
    function sendmsg() {
        var name = document.getElementById("name").value;
        var phone = document.getElementById("phone").value;
        var email = document.getElementById("email").value;
        var message = document.getElementById("msg").value;
        var error_message = document.getElementById("error_message");
        error_message.style.padding = "10px";
        var text;
        var letters = /^[ A-Za-z]+$/;
        if (!name.match(letters)) {
            text = "Please input alphabet characters only";
            error_message.innerHTML = text;
            return false;
        } else if (isNaN(phone) || phone.length != 10) {
            text = "Please Enter valid Phone Number";
            error_message.innerHTML = text;
            return false;
        } else if (email.indexOf("@") == -1 || email.length < 6) {
            text = "Please Enter valid Email";
            error_message.innerHTML = text;
            return false;
        } else if (message.length <= 20) {
            text = "Please Enter More Than 20 Characters";
            error_message.innerHTML = text;
            return false;
        } else {
            error_message.innerHTML = '';
            var name = $('#name').val();
            var phone = $('#phone').val();
            var email = $('#email').val();
            var msg = $('#msg').val();
            $.ajax({
                url: "<?php echo e(route('sendmsg')); ?>",
                data: {
                    _token: "<?php echo e(csrf_token()); ?>",
                    name: name,
                    phone: phone,
                    email: email,
                    msg: msg
                },
                type: "POST",
                success: function(res) {
                    if (res.success) {
                        $('#success').html(res.msg);

                    }
                }
            });
        }
    }
</script>
<div class="page-wraper">
        <div class="chat_tool">
            <div class="chat_window">
                <div class="welcome_page">
                    <div class="chat_win_intro">
                        <h3>Welcome to Chat Tool</h3>
                        <p>
                            Search the Help Center or start a chat. We're here to help you 24x7.
                        </p>
                    </div>

                    <div class="ch_theme_button">
                        <button class="gotoForm">
                            <ion-icon class="ion-android-send n_con_icon"></ion-icon>
                            New Conversation
                        </button>
                    </div>
                </div>
                <div class="user_form">
                    <div class="chat_header">
                        <div class="chat_header_inner">
                            <button class="chat_back_button" data-toggle="tooltip" data-placement="bottom" title="Back">
                                <i class="fa fa-angle-left" aria-hidden="true"></i>
                            </button>
                        </div>
                    </div>
                    <form id="firstForm" method="post" onsubmit="return false">
                        <div class="user_form_inner">
                            <div class="fieldrow">
                                <input class="user_form_input first-not-space" type="text" name="name" placeholder="Name" required />
                                <span class="error_note d-none">Name is required</span>
                            </div>
                            <div class="fieldrow">
                                <input class="user_form_input first-not-space" type="email" name="email" placeholder="Email" required />
                                <span class="error_note d-none">Email is required</span>
                            </div>
                            <div class="fieldrow">
                                <input class="user_form_input first-not-space" type="text" name="contact_no" placeholder="Contact No." required />
                                <span class="error_note d-none">Contact No. is required</span>
                            </div>
                            <div class="fieldrow">
                                <textarea class="user_form_input first-not-space" name="first_message" rows="3" placeholder="write message here..." required></textarea>
                            </div>
                        </div>
                        <div class="ch_theme_button">
                            <button class="chatSMS" type="submit">
                                <ion-icon class="ion-android-send n_con_icon"></ion-icon>
                                Start Chat
                            </button>
                        </div>
                    </form>
                </div>

                <div class="chat_con">
                    <div class="chat_header">
                        <div class="chat_header_inner">
                            <button class="chat_back_button" data-toggle="tooltip" data-placement="bottom" title="Back">
                                <i class="fa fa-angle-left" aria-hidden="true"></i>
                            </button>
                            <!-- <button data-toggle="tooltip" data-placement="bottom" title="Options">
                          <i class="fa fa-ellipsis-v" aria-hidden="true"></i>
                      </button> -->
                        </div>
                    </div>
                    <div class="chat_con_body">
                        <div class="chat_con_inner">

                        </div>
                    </div>
                    <div class="chat_footer">
                        <form class="chat-form" action="">
                            <div class="chat_footer_inner">
                                <input type="text" id="m" class="chat_reply_input first-not-space" placeholder="Write message here..." required />
                                <input type="hidden" name="userId" id="userId" value="">
                                <button class="chat_reply_submit" data-toggle="tooltip" data-placement="bottom" title="Submit">
                                    <ion-icon class="ion-android-send"></ion-icon>
                                </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <button class="call_button">
                <i class="fa fa-comments" aria-hidden="true"></i>
            </button>
        </div>
    </div>
	<script type="text/javascript">
    $(function() {
        $('[data-toggle="tooltip"]').tooltip()
    })

    $(".chat_back_button").click(function() {
        $(".chat_window").slideToggle(200);
    });

    $(function() {
        var pp;
        $(".first-not-space").keydown(function(event) {

                if (($(this).val().length) == 0 && event.keyCode == 32) {
                    return false;
                }
            })
            .keyup(function(event) {
                pp = $(this).val();
                if (pp.charAt(0) == ' ') {
                    var pbb = $.trim(pp);
                    $(this).val(pbb);
                }
            });
    });
</script>

<script>
    var ENDPOINT = "https://wip.tezcommerce.com:3304"
    //var ENDPOINT = "http://localhost:3309"
    var socket = io(ENDPOINT);
    var name = "";
    var store_id = <?php echo env('APP_storeId'); ?>;
    var today = new Date();
    var hour = today.getHours();
    var min = today.getMinutes();

    socket.emit('site visit', {
        "storeId": store_id
    });

    $('#firstForm').submit(function() {
        var values = {};
        $.each($('#firstForm').serializeArray(), function(i, field) {
            values[field.name] = field.value;
        });

        Object.assign(values, {
            storeId: store_id
        });

        socket.emit('joining msg', values);

        name = values.name;
        var firstmessage = "";
        if (values.first_message) {
            firstmessage = '<p>Message:  ' + values.first_message + '</p>';
        }
        $('.chat_con_inner').append($('<div class="chat_messages visitor">').html('<h3>Name:  ' + values.name + '</h3>' + '<p>Email:  ' + values.email + '</p><p>Contact No:  ' + values.contact_no + '</p>' + firstmessage));
        $('.chat_con_inner').append($('<div class="clearfix">'));
        $('#m').val('');
        $(".chat_con").show(0);
        $(".user_form").hide(0);
        $(".welcome_page").hide(0);
    });

    //set cookies
    socket.on('first message', function(msg) {
        console.log(msg);
        $('#userId').val(msg.chatData.id);
        document.cookie = "userId=" + msg.chatData.id;
        if (msg.messageData.length > 0) {
            $('.chat_con_inner').html("");
            $.each(msg.messageData, function(key, val) {
                var chatDate = new Date(val.createdAt);
                var cHour = chatDate.getHours();
                var cMin = chatDate.getMinutes();
                //var cSec = today.getSeconds();
                if (val.type == "receiver") {
                    $('.chat_con_inner').append($('<div class="chat_messages visitor">').html('<h3>' + name + '</h3><p>' + val.message + '</p><span>' + cHour + ':' + cMin + '</span>'));
                    $('.chat_con_inner').append($('<div class="clearfix">'));
                } else {
                    $('.chat_con_inner').append($('<div class="chat_messages">').html('<h3>' + val.adminUserName + '</h3><p>' + val.message + '</p><span>' + cHour + ':' + cMin + '</span>'));
                    $('.chat_con_inner').append($('<div class="clearfix">'));
                }
            });
        }
    });

    $('.chat-form').submit(function(e) {
        e.preventDefault(); // will prevent page reloading
        // socket.emit('chat message', (name + ':  ' + $('#m').val()));
        socket.emit('chat message', ({
            "userId": $('#userId').val(),
            "storeId": store_id,
            "clientMsg": $('#m').val(),
            "senderId": $('#userId').val(),
            "msgSenderName": name,
            "msgType": "receiver"
        }));
        $('#messages').append($('<li id="list">').text($('#m').val()));
        $('.chat_con_inner').append($('<div class="chat_messages visitor">').html('<h3>' + name + '</h3><p>' + $('#m').val() + '</p><span>' + hour + ':' + min + '</span>'));
        $('.chat_con_inner').append($('<div class="clearfix">'));
        $('#m').val('');
        $(".chat_con_body").stop().animate({
            scrollTop: $(".chat_con_body")[0].scrollHeight
        }, 1000);
        return false;
    });

    socket.on('chat message', function(msg) {
        var chatDate = new Date();
        var cHour = chatDate.getHours();
        var cMin = chatDate.getMinutes();
        $('.chat_con_inner').append($('<div class="chat_messages">').html('<h3>' + msg.senderName + '</h3><p>' + msg.message + '</p><span>' + cHour + ':' + cMin + '</span>'));
        $('.chat_con_inner').append($('<div class="clearfix">'));
        $(".chat_con_body").stop().animate({
            scrollTop: $(".chat_con_body")[0].scrollHeight
        }, 1000);
        let x = document.cookie;
        console.log(x);
    });

    $(".call_button").click(function() {

        let getCookie = document.cookie;
        let userId = 0;

        if (getCookie != null && getCookie != "undefined" && getCookie != 0) {
            if (getCookie.includes("userId")) {
                let getCookieArr = getCookie.split(";");
                $.each(getCookieArr, function(key, value) {
                    var strCookie = value.trim();
                    var inCookeArr = strCookie.split("=");
                    if (inCookeArr[inCookeArr.indexOf("userId")] == "userId") {
                        userId = inCookeArr[1];
                    }
                    //   if (inCookeArr[inCookeArr.indexOf("storeId")] == "storeId") {
                    //       storeId = inCookeArr[1];
                    //   }
                });
            }
        }
        console.log(userId);
        console.log(store_id);
        socket.emit('check message', {
            "user_id": userId,
            "store_id": store_id
        });

        $(".chat_window").slideToggle(200);

        socket.on('check client chat data', function(msg) {
            console.log(msg);
            if (getCookie && msg.data.length > 0) {
                $(".welcome_page").hide(0);
                $(".user_form").hide(0);
                console.log("Cookies already have set");
                name = msg.data[0].name;
                $('#userId').val(userId);
                // $('#storeId').val(storeId);
                $('.chat_con_inner').html("");

                var html = "";
                //$.each(msg.data[0].chatmessages, function(key, val) {
                    $.each(msg.data[0].chatMessages, function(key, val) {
                    var chatDate = new Date(val.createdAt);
                    var cHour = chatDate.getHours();
                    var cMin = chatDate.getMinutes();
                    //var cSec = today.getSeconds();
                    if (val.type == "receiver") {
                        $('.chat_con_inner').append($('<div class="chat_messages visitor">').html('<h3>' + name + '</h3><p>' + val.message + '</p><span>' + cHour + ':' + cMin + '</span>'));
                        $('.chat_con_inner').append($('<div class="clearfix">'));
                    } else {
                        $('.chat_con_inner').append($('<div class="chat_messages">').html('<h3>' + val.adminUserName + '</h3><p>' + val.message + '</p><span>' + cHour + ':' + cMin + '</span>'));
                        $('.chat_con_inner').append($('<div class="clearfix">'));
                    }
                });
                $(".chat_con").show(0);

            } else {
                console.log("Cookies have not set");
                $(".user_form").hide(0);
                $(".chat_con").hide(0);
                $(".welcome_page").show(0);
            }
        });
    });

    $(".gotoForm").click(function() {
        $(".user_form").show(0);
        $(".chat_con").hide(0);
        $(".welcome_page").hide(0);
    });
</script><?php /**PATH /var/www/html/websites/kttihs/resources/views/layouts/footer-menu.blade.php ENDPATH**/ ?>