<div class="container-fluid footer-top">
	<div class="container">
    	<div class="row">
        	<div class="col-md-2">
            	<div class="footer-logo"><img src="images/logo.png" class="img-responsive" /></div>
            </div>
           <!-- <div class="col-md-7 p-o">
            	<div class="footer-box2">
                	<div class="cont-box">
                    	<div class="cont-icons"><span class="fa fa-phone"></span></div>
                        <p>
                        	Informacijas talrunis<br />
                        	<span class="span1">+371 66 164 440</span>
                        </p>
                    </div>
                    <div class="cont-box">
                    	<div class="cont-icons"><span class="fa fa-envelope"></span></div>
                        <p>
                        	E-pasta adrese<br />
                        	<span class="span1">info@efix.lv</span>
                        </p>
                    </div>
                    <div class="cont-box">
                    	<div class="cont-icons"><span class="fa fa-map-marker"></span></div>
                        <p>
                        	Musu ofisa atrasanas vieta<br />
                        	<span class="span1">Ezera iela 28, Ventspils</span>
                        </p>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
            	<div class="footer-social">
                	<ul>
                    	<li><a href="#"><span class="fa fa-twitter"></span></a></li>
                    	<li><a href="#"><span class="fa fa-instagram"></span></a></li>
                    	<li><a href="#"><span class="fa fa-google-plus"></span></a></li>
                    	<li><a href="#"><span class="fa fa-facebook-f"></span></a></li>
                    </ul>
                </div>
            </div>-->
        </div>
    </div>
</div>
<footer>
	<div class="container">
    	<div class="row ft-border">
        	<div class="col-md-3">
            	<p>EFIX C 2018. Visas tiesibas rezervetas.</p>
            </div>
            <div class="col-md-9">
            	<!--<div class="footer-list">
                    <ul>
                        <li><a href="#">Par mums</a></li>
                        <li><a href="#">Kontakti</a></li>
                        <li><a href="#">Piegades nosacijumi</a></li>      
                        <li><a href="#">Garantija</a></li>      
                        <li><a href="#">Lizings </a></li>    
                        <li><a href="#">ka nopirkt</a></li>        
                        <li><a href="#">Lietosanas noteikumi</a></li>     
                        <li><a href="#">Privatuma politika</a></li>
                    </ul>
                </div>-->
            </div>
        </div>
    </div>
</footer>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Zebra_datepicker/2.0.0/css/bootstrap/zebra_datepicker.css" integrity="sha512-g0wc6i41NM+cFE1XCp5p45D2FHSfM8676LFfxGEGFoQbmKxzP3Q/jQnw6V8zJT49IY4YDR2xpRuHGsQxx1gaHw==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="js/function.js"></script>


<?php 
if($_SESSION['user_type'] == 'staff' || $_SESSION['user_type'] == 'admin')
{
    ?>
    <div style="position: fixed;bottom : 0px;width:100%;background-color: white;padding:10px;z-index:10;border-top:1px solid gray;display:none" id="tikcetPopUp">
    <button type="button" id="ticket_popup_close" class="col-xs-12 btn btn-danger" style="margin-bottom: 10px">
        Close
    </button>
    <div class="col-xs-12">
        <div class="row">
            <div class="col-xs-12" style="margin-bottom: 5px">
                <input type="text" class="form-control datepicker" id="date" value="<?php echo date('d M Y') ?>" />
            </div>
            <div class="col-xs-6">
                <input type="number" class="form-control" placeholder="NO. of users" value="1" id="no_of_users"/>
            </div>
            <div class="col-xs-6">
                <select class="form-control" id="operator">
                    <option value="+">+</option>
                    <option value="-">-</option>
                </select>
            </div>
            <div class="col-xs-6">
                <button type="button" class="btn btn-success col-xs-12" id="ticket_users_count_submit" style="margin-top:5px">Submit</button>
            </div>
            <div class="col-xs-6" style="margin-top: 10px">
                No. of existing Users: <span id="user_count"></span><i class="bi bi-arrow-repeat" id="reload_user_ticket" style="cursor: pointer;margin-left: 5px;background-color:white;border:1px solid gray;padding:5px;"></i>
            </div>
        </div>
        
        
    </div>
</div>
<div id="open_ticket_popup" style="cursor:pointer;position: fixed;bottom: 15px;right:0px;border:1px solid gray;background-color: white;padding:5px;border-right: none;border-radius:4px;padding-left:15px">
    S
</div>
    
    <?php
}
?>


<script src="https://cdnjs.cloudflare.com/ajax/libs/Zebra_datepicker/2.0.0/zebra_datepicker.min.js" integrity="sha512-Qnfn6vHrOEl6m6mBMVxKUScok5y+Apdw+3tDNpdeEHlh7/uiZ7+H0VkxLlumrj9ePNcEOA/t5vV/3NgcF44QnQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
    function checkUserTicketNumber()
    {
        var date = $('#date').val();
        $('#user_count').html('<span class="alert alert-warning" style="display:block">Checking</span>');
        $.post('ajax/getTicketCount.php', {date:date}, function(res){
            $('#user_count').text(res.count);
        }, 'json').fail(function(xhr){
            var res = xhr.responseJSON;
            $('#user_count').html('<span class="alert alert-danger" style="display:block">' + res.error_text + '</span>');
        }, 'json');
    }
    
    
    $(document).ready(function() {
        checkUserTicketNumber();
        // assuming the controls you want to attach the plugin to
        // have the "datepicker" class set
        $('input.datepicker').Zebra_DatePicker({
            'format' : 'd M Y'
        });


        $('#open_ticket_popup').click(function(){
            $('#tikcetPopUp').slideDown();
            checkUserTicketNumber();
        });

        $('#ticket_popup_close').click(function(){
            $('#tikcetPopUp').slideUp();
        })

    });


$(document).on('click', '#ticket_users_count_submit', function(e){
    e.preventDefault();
    var noOfUsers = $('#no_of_users').val();
    var date = $('#date').val();
    var operator = $('#operator').val();
    var current = $(this);
    $(current).attr('disabled', 'disabled');
    $('#user_count').html('<span class="alert alert-warning" style="display:block">Inserting....</span>');
    $.post('ajax/insertUserTicket.php', {noOfUsers:noOfUsers, date:date, operator:operator}, function(res){
        $('#user_count').text(res.count);
        $(current).removeAttr('disabled');
    }, 'json').fail(function(xhr){
        $(current).removeAttr('disabled');
            var res = xhr.responseJSON;
           $('#user_count').html('<span class="alert alert-danger" style="display:block">' + res.error_text + '</span>');
            
        }, 'json');
})


$(document).on('blur', '#date', function(){
    console.log('check');
    checkUserTicketNumber();
});


$(document).on('click', '#reload_user_ticket', function(){
    checkUserTicketNumber();;
})
</script>

</body>
</html>
