<link rel="icon" href="<?php echo base_url(); ?>assets/icon.ico" type="image/icon"/>
<!-- Fonts and icons -->
<script src="<?php echo base_url(); ?>assets/ap_assets/js/plugin/webfont/webfont.min.js"> </script>
<script>
	WebFont.load({
		google: {"families":["Lato:300,400,700,900"]},
		custom: {"families":["Flaticon", "Font Awesome 5 Solid", "Font Awesome 5 Regular", "Font Awesome 5 Brands", "simple-line-icons"], urls: ['<?php echo base_url(); ?>assets/ap_assets/css/fonts.min.css']},
		active: function() {
			sessionStorage.fonts = true;
		}
	});
</script>

<!-- CSS Files -->
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/ap_assets/css/bootstrap.min.css" />
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/ap_assets/css/atlantis.min.css" />
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/ap_assets/css/custom.css" />

<!--   Core JS Files   -->
<script src="<?php echo base_url(); ?>assets/ap_assets/js/core/jquery.3.2.1.min.js"></script>
<script src="<?php echo base_url(); ?>assets/ap_assets/js/core/popper.min.js"></script>
<script src="<?php echo base_url(); ?>assets/ap_assets/js/core/bootstrap.min.js"></script>

<!-- jQuery UI -->
<script src="<?php echo base_url(); ?>assets/ap_assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
<script src="<?php echo base_url(); ?>assets/ap_assets/js/plugin/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js"></script>

<!-- jQuery Scrollbar -->
<script src="<?php echo base_url(); ?>assets/ap_assets/js/plugin/jquery-scrollbar/jquery.scrollbar.min.js"></script>


<!-- Chart JS -->
<!--<script src="<?php //echo base_url(); ?>assets/ap_assets/js/plugin/chart.js/chart.min.js"></script>-->
<!-- jQuery Sparkline -->
<!--<script src="<?php //echo base_url(); ?>assets/ap_assets/js/plugin/jquery.sparkline/jquery.sparkline.min.js"></script>-->
<!-- Chart Circle -->
<!--<script src="<?php //echo base_url(); ?>assets/ap_assets/js/plugin/chart-circle/circles.min.js"></script>-->

<!-- Datatables -->
<script src="<?php echo base_url(); ?>assets/ap_assets/js/plugin/datatables/datatables.min.js"></script>

<!-- Bootstrap Notify -->
<script src="<?php echo base_url(); ?>assets/ap_assets/js/plugin/bootstrap-notify/bootstrap-notify.min.js"></script>


<!-- jQuery Vector Maps -->
<!--<script src="<?php //echo base_url(); ?>assets/ap_assets/js/plugin/jqvmap/jquery.vmap.min.js"></script>-->
<!--<script src="<?php //echo base_url(); ?>assets/ap_assets/js/plugin/jqvmap/maps/jquery.vmap.world.js"></script>-->

<!-- Sweet Alert -->
<!--<script src="<?php //echo base_url(); ?>assets/ap_assets/js/plugin/sweetalert/sweetalert.min.js"></script>-->

<!-- Atlantis JS -->
<script src="<?php echo base_url(); ?>assets/ap_assets/js/atlantis.min.js"></script>


<!-- Select2  -->
<script src="<?php echo base_url(); ?>assets/ap_assets/select2/select2.min.js" ></script>
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/ap_assets/select2/select2.min.css" />


<!--ckeditor 4-->
<script src="<?php echo base_url(); ?>assets/ap_assets/editor_ckediter/ckeditor.js"></script>

<!--font awesome 5-->
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" />

<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />

<script type="text/javascript">
//reference 
    // https://www.daterangepicker.com/#examples
$(function() {
  $('#daterange_By').daterangepicker({
        autoUpdateInput: false,
        locale: {
          cancelLabel: 'Clear',
          format: 'DD-MM-YYYY',
        },
        ranges: {
        'Today': [moment(), moment()],
        'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
        'Last 7 Days': [moment().subtract(6, 'days'), moment()],
        'Last 30 Days': [moment().subtract(29, 'days'), moment()],
        'This Month': [moment().startOf('month'), moment().endOf('month')],
        'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
    },
  });
  $('#daterange_By').on('apply.daterangepicker', function(ev, picker) {
      $(this).val(picker.startDate.format('DD-MM-YYYY') + ' - ' + picker.endDate.format('DD-MM-YYYY'));
  });
  $('#daterange_By').on('cancel.daterangepicker', function(ev, picker) {
      $(this).val('');
  });
});

function openInNewTabWithNoopener(val) {
    const aTag = document.createElement('a');
    aTag.rel = 'noopener';
    aTag.target = "_blank";
    aTag.href = val;
    aTag.click();
}
</script>



<!--custom style-->
<style>
    .table-hover tbody tr:hover
    {
        background-color: #dde1e5;
    }
    .main-panel-custom
    {
        background-color: #DEE2E6;height: auto;
    }
</style>


<!-- page js functions -->
<script type="text/javascript">

$(document).on('keypress change', ".required", function() {
		var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		var passwordRegex =  /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,20}$/;
		var fieldId = $(this).attr('id');
		var fieldVal = $(this).val();
		if(fieldId.indexOf('email') === -1) {  var checkEmail = false; }else{ var checkEmail = true; }
		if(fieldId.indexOf('userPassword') === -1) {  var checkPassword = false; }else{ var checkPassword = true; }
		 if(checkEmail === true){
			if(!ck_email.test(fieldVal)){
				setMsg(fieldId,'Please enter a valid email id.');
			} else {
				$('#div_'+fieldId).removeClass('has-error').addClass('has-success');$('#err_'+fieldId).html('');
			}  
		}else if(checkPassword === true){
			if(!passwordRegex.test(fieldVal)){
				setMsg(fieldId,'Minimum 8  characters, upper and lowercase letters and numeric digit.');
			}else {
				$('#div_'+fieldId).removeClass('has-error').addClass('has-success');$('#err_'+fieldId).html('');
			} 
		}else{
			if(fieldVal == 0){
				setMsg(fieldId,'');
			}else {
				$('#div_'+fieldId).removeClass('has-error').addClass('has-success');$('#err_'+fieldId).html('');
			}
		}
	});
	
    var ck_email = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    var ck_username = /^[A-Za-z0-9_]{1,20}$/;
   
    function clrErr(){
    	  $(".form-group, .checkbox,.col-xs-8" ).removeClass( "has-error" );
    	   $(".err_msg").hide();
    }

    function validateFormFields(fieldName, errMsg, fieldType,fieldValue=null){
// 		alert(fieldType)
		if(fieldType == 'radioClass'){
			console.log($('.'+fieldName).is(':checked').length);
			if($('.'+fieldName).is(':checked').length  == 0){
				console.log('checked'+fieldType);
				setMsg(fieldName,errMsg);return true;
			}else{
				return false
			}
		}
		else if(fieldType == 'radio' ){
			if($("input[name="+fieldName+"]:checked").length  == 0){
				setMsg(fieldName,errMsg);return true;
			}else{
				return false
			}
		}else if(fieldType == 'checkbox'){
			if($("input[name='"+fieldName+"[]']:checked").length  == 0){
				setMsg(fieldName,errMsg);return true;
			}else{
				return false
			}
		}
		else if(fieldType == 'CKEDITOR'){
		 var fieldText = fieldValue;
 		 if(fieldText == '<p><br></p>' || fieldText == '' || fieldText == '<p></p>'){ 
			setMsg(fieldName,errMsg);return true;
		 }
		}
		else{
		    
			if(($.trim($('#'+fieldName).val()) == '' || $('#'+fieldName).val() == 0)){
				setMsg(fieldName,errMsg);return true;
 			}else if(fieldType == 'validEmail' && !ck_email.test($('#'+fieldName).val())){
				setMsg(fieldName,'Please enter a valid email id.');return true;
			}else if(fieldType == 'validUsername' && !ck_username.test($('#'+fieldName).val())){
				setMsg(fieldName,'Please enter a valid username .');return true;
			}else if(fieldType == 'invalid_url' ){
				setMsg(fieldName,'Please enter a valid URL .');return true;
			}
			else if(fieldType == 'validPass' && !passwordRegex.test($('#'+fieldName).val()) && ($('#'+fieldName).val())){
				setMsg(fieldName,'Minimum 8  characters, upper and lowercase letters and numeric digit!');return true;
			}
		else{
				return false;
			}
		}
	}
	
	function setMsg(fieldId,errMsg){
		$('#div_'+fieldId).removeClass('has-success').addClass('has-error');
		$('#err_'+fieldId).fadeIn();
		$('#err_'+fieldId).html(errMsg);
		$('#'+fieldId).focus();
	}
	
	
	$(function () {
		hideErrorMessages();
// 		$('input[type=checkbox], input[type=radio]').checkator();
	});
	
	function hideErrorMessages(){
 	    $('.alert-hide').delay(6000).fadeOut("slow");       
    }
    
    function doSort(id,url){
	  url = url+'&sortBy='+id;
	  if($( "#sort_"+id ).hasClass( "fa-sort-down" )) url = url+'&sortOrder=desc';
	  else url = url+'&sortOrder=asc';
// 	  console.log(url);console.log(id);
 	  window.location = url;  
    }
    
	$(document).ready(function() {
        $('input:checkbox').click(function(){ 
           	//  $(this).screwDefaultButtons("enable"); 	
        });
  
        $('#checkedAll').change(function(){ 
			if($(this).is(':checked')){ 
 				$('.checkedAll').prop('checked',true); 
				//$('.checkedAll').screwDefaultButtons("enable");
			}else{ 
 				$('.checkedAll').prop('checked',false);
				//$('.checkedAll').screwDefaultButtons("disable"); 	
			}
        });
    });
    
</script>
<style>
.has-error label {
    color: #495057!important;
}
</style>
