<?
session_start();
ob_start();
error_reporting(0);
ini_set('display_errors', 0); // Value 0 Not Show Error,1 Show Error 
ini_set('magic_quotes_gpc', 'Off');
ini_set('register_globals', 'Off');
ini_set('date.timezone', 'Asia/Bangkok');
include 'include/db.php';
include 'include/connect.php';
if($_SESSION['admin_id'] == "")
	{
		header("location:login.php");
		exit();
	}
$lic = $_SESSION['admin_status'];
 if($lic == '0') {
 	$lic_n = 'administrator';
 } else if ($lic == '1') {
 	$lic_n = 'Sales department';
 } else {
 	$lic_n = 'Accounting department';
 }


?>
<html class="fixed">
	<head>

		<!-- Basic -->
		<meta charset="UTF-8">
        <title>IMAGINETOUR SYSTEM</title>
		<meta name="keywords" content="IMAGINETOUR System" />
		<meta name="description" content="IMAGINETOUR Backend sys">
		<meta name="author" content="dev">

		<!-- Mobile Metas -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <link rel="icon" type="image/png" sizes="192x192"  href="https://www.imaginetourservice.com/newimagine/images/IMAGINETOUR_LOGO.png">
		<!-- Web Fonts  --  >
		<link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">
		<link href="https://fonts.googleapis.com/css2?family=Kanit:ital,wght@0,100;0,200;0,300;0,400;0,600;0,700;1,100;1,200;1,300;1,600&display=swap" rel="stylesheet">
		Vendor CSS -->
		<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.css" />
		<link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.css" />
		<link rel="stylesheet" href="assets/vendor/magnific-popup/magnific-popup.css" />
		<link rel="stylesheet" href="assets/vendor/bootstrap-datepicker/css/datepicker3.css" />

         <link rel="stylesheet" href="assets/vendor/pnotify/pnotify.custom.css" />
         <!--  <script src="https://cdn.ckeditor.com/4.10.0/standard-all/ckeditor.js"></script> -->
         <!-- <script src="https://cdn.ckeditor.com/4.18.0/standard-all/ckeditor.js"></script> -->
         <script src="https://cdn.ckeditor.com/ckeditor5/34.0.0/classic/ckeditor.js"></script>
		<!-- Specific Page Vendor CSS -->
		<link rel="stylesheet" href="assets/vendor/jquery-ui/css/ui-lightness/jquery-ui-1.10.4.custom.css" />
		<link rel="stylesheet" href="assets/vendor/bootstrap-multiselect/bootstrap-multiselect.css" />
		<link rel="stylesheet" href="assets/vendor/morris/morris.css" />

		<!-- Theme CSS -->
		<link rel="stylesheet" href="assets/stylesheets/theme.css" />

		<!-- Specific Page Vendor CSS -->
		<link rel="stylesheet" href="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.css" />
		<!-- Specific Page Vendor CSS -->
		<link rel="stylesheet" href="assets/vendor/select2/select2.css" />
		<link rel="stylesheet" href="assets/vendor/jquery-datatables-bs3/assets/css/datatables.css" />
		<!-- Skin CSS -->
		<link rel="stylesheet" href="assets/stylesheets/skins/default.css" />

		<!-- Theme Custom CSS -->
		<link rel="stylesheet" href="assets/stylesheets/theme-custom.css">
<!-- BEST Custom CSS -->
		<link rel="stylesheet" href="static/css/bestcustom.css?v2">
		<!-- Head Libs -->
		<script src="assets/vendor/modernizr/modernizr.js"></script>
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.css" integrity="sha512-bYPO5jmStZ9WI2602V2zaivdAnbAhtfzmxnEGh9RwtlI00I9s8ulGe4oBa5XxiC6tCITJH/QG70jswBhbLkxPw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
		<script src="https://kit.fontawesome.com/38ee4ea884.js" crossorigin="anonymous"></script>
        
      <!--  loader -->
		<link rel="stylesheet" type="text/css" href="static/cssload/effect2.css" />
		<script src="static/js/modernizr.custom.js"></script>
		<link href="static/css/sweetalert.css?v=1" rel="stylesheet">
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-print-css/css/bootstrap-print.min.css" media="print">
		<script src='https://kit.fontawesome.com/a076d05399.js' crossorigin='anonymous'></script>

	</head>
	<body class="demo-2"id="ip-container" class="ip-container">
		<div>
		<!-- initial header -->
<style>
	@keyframes rotate {
	100% {
		transform: rotate(360deg)
	}
}
	@media print {
  a[href]:after {
    content: none !important;
  }
     .no-print, .no-print *
    {
        display: none !important;
    }
}
</style>
<header class="ip-header d-none">
				<div class="ip-loader">
					<svg class="ip-inner" width="300px" height="300px" viewBox="0 0 80 80">
						<path class="ip-loader-circlebg" d="M40,10C57.351,10,71,23.649,71,40.5S57.351,71,40.5,71 S10,57.351,10,40.5S23.649,10,40.5,10z"/>
						<path id="ip-loader-circle" class="ip-loader-circle" d="M40,10C57.351,10,71,23.649,71,40.5S57.351,71,40.5,71 S10,57.351,10,40.5S23.649,10,40.5,10z"/>
					</svg>
				</div>
</header>


		<section class="body">
			<!-- start: header -->
			<header class="header">
				<div class="logo-container">
					<a href="#" class="logo">
						<img src="../img/IMAGINETOUR_LOGO.png" height="58" alt="" />
					</a>
					<div class="visible-xs toggle-sidebar-left bg-danger" data-toggle-class="sidebar-left-opened" data-target="html" data-fire-event="sidebar-left-opened">
						<i class="fa fa-bars" aria-label="Toggle sidebar" style="line-height: 2.3;"></i>
					</div> 
				</div>
			<div class="menu_header_center text-danger">
		   </div>
				<!-- start: search & user box -->
				<div class="header-right">
							<!-- <h2>Dashboard</h2> -->
				<span class="separator"></span>
		         <i class="fa fa-search text-dark bell-not" aria-hidden="true" data-toggle='modal' data-target='#book' style="vertical-align:middle;"></i>
				<span class="separator"></span>
		          <a href="?url=booking"> <i class="fa fa-bell text-dark bell-not" aria-hidden="true" style="vertical-align:middle;" style="position:relative;">
		           	<span class="count animate__pulse" style="z-index: 2000;
    font-size: 14px;
    padding: 5px 6px;
    background-color: red;
    border-radius: 5px;
    font-weight: bold;
    margin-top: -21px;
    margin-left: -12px;
    position: absolute;
    animation-iteration-count: infinite;
    animation-duration: 0.9s;
    color: rgb(255, 255, 255);"></span>
    </i></a>

					<span class="separator"></span>
			
					<div id="userbox" class="userbox">
						<a href="#" data-toggle="dropdown">
							<figure class="profile-picture">
							<!-- 	<img src="<?=$picadmin;?>"class="img-circle"/> -->
					<?/*
                      $picadmin = 'static/picadmin/'.$_SESSION[admin_un].'.jpg';
                       if (file_exists($picadmin)) {
                           echo "<img src= 'static/picadmin/$_SESSION[admin_un].jpg' class='img-circle'>";
                       } else {
                          echo "<img src= 'https://www.best-consortium.com/static/img/IMAGINETOUR_logo.5487bad.svg' class='img-circle'>";
                       }*/
					?>

							</figure>
							<div class="profile-info" data-lock-name="<?=$_SESSION['admin_nickname'];?>">
								<span class="name"><?=$_SESSION['admin_nickname'];?></span>
								<span class="role"><?=$lic_n;?></span>
							</div>

						</a>
			
						<div class="dropdown-menu">
							<ul class="list-unstyled">
								<li class="divider"></li>
								<li>
									<a role="menuitem" tabindex="-1" href="pages-user-profile.html"><i class="fa fa-user"></i> My Profile</a>
								</li>
								<li>
									<a role="menuitem" tabindex="-1" href="#" id="logout_btn"><i class="fa fa-power-off text-danger"></i> Logout</a>
								</li>
							</ul>
						</div>
					</div>
				</div>
				<!-- end: search & user box -->
			</header>
			<!-- end: header -->

			<div class="inner-wrapper">
				<!-- start: sidebar -->
				<aside id="sidebar-left" class="sidebar-left">
		
					<div class="nano">
						<div class="nano-content">
							<nav id="menu" class="nav-main" role="navigation">
								<?include 'menu/menu.php';?>
							</nav>
						</div>
				
					</div>
				
				</aside>
				<!-- end: sidebar -->

				<section role="main" class="content-body">
					<header class="page-header">
			     <? include ('breadcrumbs.php');?>
					</header>
                 <? include ('content.php');?>
					
				</section>
			</div>
		</section>
<!-- <script>
	    CKEDITOR.replace( 'editor1' );
</script>
      <script> 
    CKEDITOR.replace( 'hilight', {
      height: 250,
      extraPlugins: 'colorbutton,colordialog',
      removeButtons: 'PasteFromWord'
    } );
     CKEDITOR.replace( 'condition_plus', {
      height: 250,
      extraPlugins: 'colorbutton,colordialog',
      removeButtons: 'PasteFromWord'
    } );
     CKEDITOR.replace( 'condition_no', {
      height: 250,
      extraPlugins: 'colorbutton,colordialog',
      removeButtons: 'PasteFromWord'
    } );

          </script> -->

		<script src="assets/vendor/jquery/jquery.js"></script>
		<script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
		<script src="assets/vendor/bootstrap/js/bootstrap.js"></script>
		<script src="assets/vendor/nanoscroller/nanoscroller.js"></script>
		<script src="assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
		<script src="assets/vendor/magnific-popup/magnific-popup.js"></script>
		<script src="assets/vendor/jquery-placeholder/jquery.placeholder.js"></script>


	<!-- Specific Page Vendor -->
		<script src="assets/vendor/select2/select2.js"></script>
		<script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
		<script src="assets/vendor/jquery-datatables/extras/TableTools/js/dataTables.tableTools.min.js"></script>
		<script src="assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>

		<!-- Theme Base, Components and Settings -->
		<script src="assets/javascripts/theme.js"></script>
		<!-- Theme Custom -->
		<script src="assets/javascripts/theme.custom.js"></script>
		<script src="assets/vendor/pnotify/pnotify.custom.js"></script>
		<script src="static/js/best_custom.js?v=1.44"></script>

		<!-- Theme Initialization Files -->
		<script src="assets/javascripts/theme.init.js"></script>

		<script src="js/jquery.cleditor.min.js"></script>

		<script src="js/jquery.cleditor.extimage.js"></script>

		<script src="js/tinymce/tinymce.min.js"></script>
        
	<!-- Specific Page Vendor -->
		<script src="assets/vendor/jquery-autosize/jquery.autosize.js"></script>
		<script src="assets/vendor/bootstrap-fileupload/bootstrap-fileupload.min.js"></script>
		<!-- Examples -->
				<script src="assets/vendor/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
		<script src="assets/vendor/bootstrap-timepicker/js/bootstrap-timepicker.js"></script>

		<script src="assets/javascripts/tables/examples.datatables.default.js"></script>
		<script src="assets/javascripts/tables/examples.datatables.row.with.details.js"></script>
		<script src="assets/javascripts/tables/examples.datatables.tabletools.js"></script>
     
        <script src="static/js/jquery.ui.widget.js"></script>
        <script src="static/js/jquery.fileupload.js"></script>

        <script src="static/js/sweetalert2.min.js?v=1.2"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.min.js"></script>

    <!--    	<script src="static/js/classie.js"></script>
		<script src="static/js/pathLoader.js"></script>
		<script src="static/js/main.js"></script> -->
</div>


<div class="modal fade " tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="book">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">
  <section class="panel">
       <form  class="form-horizontal form-bordered" style="margin:0;" method="post" action="?url=maindatabase">
            <div class="form-group row m-auto" style="margin:auto;">
                        <label class="col-md-12 control-label" for="inputDefault"><h5 style="margin:0;font-size: 18px;line-height: 3;text-align:center;">ค้นหาใบจองของคุณที่เดินทาง</h5></label>
                        <div class="col-md-12">
                          <label>วันเริ่มต้น</label>
                         <input class="form-control" type="date" id="m1" name="m1" value="" style="margin-bottom:5px;">
                        </div>
                        <div class="col-md-12">
                          <label>วันสินสุด</label>
                         <input class="form-control" type="date" id="m2" name="m2" value="" style="margin-bottom:5px;">
                        </div>
                      <div class="col-md-12">
                <div class="form-actions">
                  <button type="submit" id="PackageBT" class="btn btn-danger btn-block" style="line-height: 3;margin-top: 20px;margin-bottom: 20px;">ค้นหาใบจองง <i class="fa-solid fa-magnifying-glass"></i></button>
                </div>
                </div>
            </div>
   </form>
  </section>

    </div>
  </div>
</div>

	</body>
</html>

<?if ($_GET['url'] == 'tour_edit' || $_GET['url'] == 'tour_a'  || $_GET['url'] == 'maindatabase') {
	// code...
}else{?>
<script type='text/javascript'>
			tinymce.init({
			  selector: 'textarea',
			  setup: function (editor) {
		      	editor.on('change', function () {
		      		editor.save();
		        });
		      },
		      relative_urls: false,
		      remove_script_host : false,
			  height: 500,
			  plugins: [
			    'advlist autolink lists link image charmap print preview hr anchor pagebreak',
			    'searchreplace wordcount visualblocks visualchars code fullscreen',
			    'insertdatetime media nonbreaking save table contextmenu directionality',
			    'emoticons template paste textcolor colorpicker textpattern responsivefilemanager imagetools codesample toc'
			  ],
			  toolbar1: 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
			  toolbar2: 'responsivefilemanager | print preview media | forecolor backcolor emoticons | codesample',
			  image_advtab: true,
			  templates : [{title: 'Description Detail', description: 'All day', url: 'daytemplate.html'}],
			  external_filemanager_path:'filemanager/',
		      filemanager_title:'Responsive Filemanager' ,
		      external_plugins: { 'filemanager' : 'plugins/responsivefilemanager/plugin.min.js'}
			 });
		</script>
<?}?>
<script type="text/javascript">
var date_add = function(date1,separate,format,targetObj,
addDate,addMonth,addYear
){
    separate = typeof separate !== 'undefined' ? separate : '-';
    format = typeof format !== 'undefined' ? format : 'dmy';
    targetObj = typeof targetObj !== 'undefined' ? targetObj : null;
    addDate = typeof addDate !== 'undefined' ? addDate : null;
    addMonth = typeof addMonth !== 'undefined' ? addMonth : null;
    addYear = typeof addYear !== 'undefined' ? addYear : null;
    var s_date=date1;
    var arr_s_date = s_date.split(separate);
    var new_s_date = arr_s_date[format.indexOf('m')]
    +'/'+arr_s_date[format.indexOf('d')]
    +'/'+arr_s_date[format.indexOf('y')];
    var e_date = new Date(new_s_date);
    if(addDate){
        e_date.setDate(e_date.getDate() + addDate);
    }
    if(addMonth){
        e_date.setMonth(e_date.getMonth() + addMonth);
    }
    if(addYear){
        e_date.setFullYear(e_date.getFullYear() + addYear);
    }        
    function pad(s) { return (s < 10) ? '0' + s : s; }
    var new_t_date = [];
    new_t_date[0]=(format.charAt(0)=='d')?pad(e_date.getDate()):
    (format.charAt(0)=='m')?pad(e_date.getMonth()+1):e_date.getFullYear();
    new_t_date[1]=(format.charAt(1)=='d')?pad(e_date.getDate()):
    (format.charAt(1)=='m')?pad(e_date.getMonth()+1):e_date.getFullYear();
    new_t_date[2]=(format.charAt(2)=='d')?pad(e_date.getDate()):
    (format.charAt(2)=='m')?pad(e_date.getMonth()+1):e_date.getFullYear();
    var returnValue=[new_t_date[0],new_t_date[1],new_t_date[2]].join(separate);    
    if(targetObj){
        document.getElementById(targetObj).value = returnValue;
    }else{
        return returnValue;
    }
    return [new_t_date[0],new_t_date[1],new_t_date[2]].join(separate);              
}  
 
     
$(function(){
    $("#datego,#dateback").datetimepicker({    
        format:'d-m-Y', // รูปแบบวันที่   
        formatDate:'d-m-Y',  
        timepicker:false,     
        closeOnDateSelect:true, 
    }); 
     
});
</script>       


<script type="text/javascript">
var date_iv_add = function(date1,separate,format,targetObj,
addDate,addMonth,addYear
){
    separate = typeof separate !== 'undefined' ? separate : '-';
    format = typeof format !== 'undefined' ? format : 'dmy';
    targetObj = typeof targetObj !== 'undefined' ? targetObj : null;
    addDate = typeof addDate !== 'undefined' ? addDate : null;
    addMonth = typeof addMonth !== 'undefined' ? addMonth : null;
    addYear = typeof addYear !== 'undefined' ? addYear : null;
    var s_date=date1;
    var arr_s_date = s_date.split(separate);
    var new_s_date = arr_s_date[format.indexOf('m')]
    +'/'+arr_s_date[format.indexOf('d')]
    +'/'+arr_s_date[format.indexOf('y')];
    var e_date = new Date(new_s_date);
    if(addDate){
        e_date.setDate(e_date.getDate() + addDate);
    }
    if(addMonth){
        e_date.setMonth(e_date.getMonth() + addMonth);
    }
    if(addYear){
        e_date.setFullYear(e_date.getFullYear() + addYear);
    }        
    function pad(s) { return (s < 10) ? '0' + s : s; }
    var new_t_date = [];
    new_t_date[0]=(format.charAt(0)=='d')?pad(e_date.getDate()):
    (format.charAt(0)=='m')?pad(e_date.getMonth()+1):e_date.getFullYear();
    new_t_date[1]=(format.charAt(1)=='d')?pad(e_date.getDate()):
    (format.charAt(1)=='m')?pad(e_date.getMonth()+1):e_date.getFullYear();
    new_t_date[2]=(format.charAt(2)=='d')?pad(e_date.getDate()):
    (format.charAt(2)=='m')?pad(e_date.getMonth()+1):e_date.getFullYear();
    var returnValue=[new_t_date[0],new_t_date[1],new_t_date[2]].join(separate);    
    if(targetObj){
        document.getElementById(targetObj).value = returnValue;
    }else{
        return returnValue;
    }
    return [new_t_date[0],new_t_date[1],new_t_date[2]].join(separate);              
}  
 
     
$(function(){
    $("#date1,#date2").datetimepicker({    
        format:'d/m/Y', // รูปแบบวันที่   
        formatDate:'d/m/Y',  
        timepicker:false,     
        closeOnDateSelect:true, 
    }); 
     
});
</script>   

 <script>
    // Add an event listener to the start date input
    document.getElementById('startDate').addEventListener('input', function() {
      // Get the value of the start date input
      const startDateValue = this.value;

      // Set the minimum value of the end date input to the selected start date
      document.getElementById('endDate').min = startDateValue;

      // If the end date is less than the start date, reset it
      if (document.getElementById('endDate').value < startDateValue) {
        document.getElementById('endDate').value = startDateValue;
      }
    });
  </script>




<script type="text/javascript">
$(document).ready(function(){
  var rows = 1;
  $("#createRows").click(function(){
            var tr = "<tr>";
            tr = tr + "<td ><input  type='text'  name='periodid"+rows+"' id='periodid"+rows+"' size='5' hidden ";
  tr = tr + "<td> <div class='input-daterange input-group' data-plugin-datepicker='' style='margin: auto;'><span class='input-group-addon'><i class='fa fa-calendar'></i></span> <input type='text' class='form-control' name='start"+rows+"' id='start"+rows+"'><span class='input-group-addon'>to</span><input type='text' class='form-control' name='end"+rows+"' id='end"+rows+"'></div></td>";
            tr = tr + "<td><input type='text' name='single"+rows+"' id='single"+rows+"' size='15'></td>";
            tr = tr + "<td><input type='text' name='adult"+rows+"' id='adult"+rows+"' size='5'></td>";
            tr = tr + "<td><input type='text' name='child"+rows+"' id='child"+rows+"' size='5'></td>";
            tr = tr + "<td><input type='text' name='nobed"+rows+"' id='nobed"+rows+"' size='5'></td>";
            tr = tr + "</tr>";
            $('#dataTable > tbody:last').append(tr);
          
            $('#hdnCount').val(rows);
            rows = rows + 1;
    });

    $("#deleteRows").click(function(){
        if ($("#dataTable tr").length != 1) {
           $("#dataTable tr:last").remove();
        }
    });

    $("#clearRows").click(function(){
        rows = 1;
        $('#hdnCount').val(rows);
        $('#dataTable > tbody:last').empty(); // remove all
    });

  });
</script>



<?if($_GET['url'] == 'maindatabase'){?>

	<script>
              $(document).ready(function() {
    dataTable = $("#datatable-database").DataTable({
      
    });
    $('.status-dropdown').on('change', function(e){
      var status = $(this).val();
      $('.status-dropdown').val(status)
      console.log(status)
      //dataTable.column(6).search('\\s' + status + '\\s', true, false, true).draw();
      dataTable.column(1).search(status).draw();
    })

     $('.status-iv').on('change', function(e){
      var status = $(this).val();
      $('.status-iv').val(status)
      console.log(status)
      //dataTable.column(6).search('\\s' + status + '\\s', true, false, true).draw();
      dataTable.column(2).search(status).draw();
    })


    });
</script>

<?}else{?>
<script type="text/javascript">
	$(document).ready(function() {
    dataTable = $("#datatable-iv").DataTable({
      
    });
  
  
  
  /*dataTable.columns().every( function () {
        var that = this;
 
        $('input', this.footer()).on( 'keyup change', function () {
            if ( that.search() !== this.value ) {
                that.search(this.value).draw();
            }
        });
      });*/
  
  

    $('.filter-checkbox').on('change', function(e){
      var searchTerms = []
      $.each($('.filter-checkbox'), function(i,elem){
        if($(elem).prop('checked')){
          searchTerms.push("^" + $(this).val() + "$")
        }
      })
      dataTable.column(5).search(searchTerms.join('|'), true, false, true).draw();
    });
  
      $('.filter-checkbox-iv').on('change', function(e){
      var searchTerms = []
      $.each($('.filter-checkbox-iv'), function(i,elem){
        if($(elem).prop('checked')){
          searchTerms.push("^" + $(this).val() + "$")
        }
      })
      dataTable.column(13).search(searchTerms.join('|'), true, false, true).draw();
    });

    $('.status-dropdown').on('change', function(e){
      var status = $(this).val();
      $('.status-dropdown').val(status)
      console.log(status)
      //dataTable.column(6).search('\\s' + status + '\\s', true, false, true).draw();
      dataTable.column(6).search(status).draw();
    })

    $('.date-dropdown').on('change', function(e){
      var date = $(this).val();
      $('.date-dropdown').val(date)
      console.log(date)
      //dataTable.column(6).search('\\s' + status + '\\s', true, false, true).draw();
      dataTable.column(3).search(date).draw();
    })

     $('.datego-dropdown').on('change', function(e){
      var date = $(this).val();
      $('.datego-dropdown').val(date)
      console.log(date)
      //dataTable.column(6).search('\\s' + status + '\\s', true, false, true).draw();
      dataTable.column(7).search(date).draw();
    })

     $('.wholesale-dropdown').on('change', function(e){
      var date = $(this).val();
      $('.wholesale-dropdown').val(date)
      console.log(date)
      //dataTable.column(6).search('\\s' + status + '\\s', true, false, true).draw();
      dataTable.column(4).search(date).draw();
    })

     $('.datego2-dropdown').on('change', function(e){
      var date = $(this).val();
      $('.datego2-dropdown').val(date)
      console.log(date)
      //dataTable.column(6).search('\\s' + status + '\\s', true, false, true).draw();
      dataTable.column(5).search(date).draw();
    })


      $('.filter-checkbox-api').on('change', function(e){
      var searchTerms = []
      $.each($('.filter-checkbox-api'), function(i,elem){
        if($(elem).prop('checked')){
          searchTerms.push("^" + $(this).val() + "$")
        }
      })
      dataTable.column(7).search(searchTerms.join('|'), true, false, true).draw();
    });

});
	$(document).ready(function(){
	$('#example').dataTable({
  'iDisplayLength': 100
});
});

</script>
<?}?>

<script>
$('img[data-enlargeable]').addClass('img-enlargeable').click(function() {
  var src = $(this).attr('src');
  var modal;

  function removeModal() {
    modal.remove();
    $('body').off('keyup.modal-close');
  }
  modal = $('<div>').css({
    background: 'RGBA(0,0,0,.5) url(' + src + ') no-repeat center',
    backgroundSize: 'contain',
    width: '100%',
    height: '100%',
    position: 'fixed',
    zIndex: '10000',
    top: '0',
    left: '0',
    cursor: 'zoom-out'
  }).click(function() {
    removeModal();
  }).appendTo('body');
  //handling ESC
  $('body').on('keyup.modal-close', function(e) {
    if (e.key === 'Escape') {
      removeModal();
    }
  });
});
</script>

<?echo "<script type='text/javascript'>
		$('ul.nav-main li .nav-children li a').each(function(){
		
			if($(this).attr('data-link')=='".$link."') {
				
				$(this).parent().addClass('active');
				
			}
	
		});
		$('ul.nav-main li .nav-children li a').each(function(){
		
			if($(this).attr('data-link')=='".$link."') {
				
				$(this).parent().addClass('active');
				$(this).parent().parent().show();
				
			}
	
		});";?>
		</script>