
<script src="assets/js/vendors.bundle.js"></script>
<script src="assets/js/app.bundle.js"></script>
<script src="assets/js/formplugins/select2/select2.bundle.js"></script>
<script src="assets/js/notifications/sweetalert2/sweetalert2.bundle.js"></script>
<script src="assets/js/notifications/toastr/toastr.js"></script>
<script>
<?php if($user_ex_lim_details): ?>
<?php foreach($user_ex_lim_details as $ex): ?>
    <?php if($ex['state']=="Limit"): ?>
        <?php $get_class = array_map('trim', explode('.', $ex['action_link']));
        $class = $get_class[0];
        ?>
        $('.<?php echo $class ?>').addClass("d-none");
    <?php endif ?>
<?php endforeach ?>
<?php endif ?>
/* Activate smart panels */
$('#js-page-content').smartPanel();
 /* defined datas */
 function fetchNotification(){
     $.post('controller/notificationCode.php?fetchNotification',function(serverResponse){
        $('.update-notification').html(serverResponse); 
     });
 }
 function fetchNotificationCounter(){
     $.post('controller/notificationCode.php?fetchNotificationCounter',function(serverResponse){
        $('.update-notification-counter').html(serverResponse);
     });
 }
 $(window).scroll(function(){
    fetchNotification();
    fetchNotificationCounter();
});

$('.update-notification-counter').click(function(){
    fetchNotification();
    fetchNotificationCounter();
});

$('#search-field').keypress(function (e) {
 var key = e.which;
 if(key == 13)  // the enter key code
  {
    var invoice_no = $('#search-field').val();
    
    var serverData = {
        invoice_no:invoice_no,
        search_invoice:''
    }
    $.post('controller/requestCode.php',serverData,function(serverResponse){
        if(serverResponse){
            console.log(serverResponse)
            var response = JSON.parse(serverResponse);
            if(response.data=="success"){
                window.location.replace('invoice.php?view_invoice=&&id='+invoice_no+'');
            }else if(response.data=="null"){
                toastr.warning('Invoice Not Found!', 'Admin');
                toastr.clear()
            }else{
                toastr.error('Internal Error!', 'Admin');
                toastr.clear()
            }
        }
    });
    return false;
  }
});   


</script>
