<?php 
session_start();
include '../db.php';
include("../all_query.php");
error_reporting(0); 
set_time_limit(0);
ini_set('max_execution_time', 0);

 if(isset($_SESSION['loan_crm_username']) && isset($_SESSION['loan_crm_password']))
{
	
		 
		
		
	
	?>
	
	
<!DOCTYPE html>
 
<html lang="en" class="light-style layout-navbar-fixed layout-menu-fixed " dir="ltr" data-theme="theme-bordered" data-assets-path="../assets/" data-template="vertical-menu-template-bordered">
 
<head>
   <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />

    <title>CRM</title>
    
     <meta name="description" content="Start your development with a Dashboard for Bootstrap 5" />
    <meta name="keywords" content="dashboard, bootstrap 5 dashboard, bootstrap 5 design, bootstrap 5">
    <!-- Canonical SEO -->
    <link rel="canonical" href="https://1.envato.market/frest_admin">
    
    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="https://pixinvent.com/demo/frest-clean-bootstrap-admin-dashboard-template/assets/img/favicon/favicon.ico" />

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com/">
    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&amp;family=Rubik:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&amp;display=swap" rel="stylesheet">

    <!-- Icons -->
    <link rel="stylesheet" href="../assets/vendor/fonts/boxicons.css" />
    <link rel="stylesheet" href="../assets/vendor/fonts/fontawesome.css" />
    <link rel="stylesheet" href="../assets/vendor/fonts/flag-icons.css" />

    <!-- Core CSS -->
    <link rel="stylesheet" href="../assets/vendor/css/rtl/core.css" class="template-customizer-core-css" />
    <link rel="stylesheet" href="../assets/vendor/css/rtl/theme-bordered.css" class="template-customizer-theme-css" />
    <link rel="stylesheet" href="../assets/css/demo.css" />

    <!-- Vendors CSS -->
    <link rel="stylesheet" href="../assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" />
    <link rel="stylesheet" href="../assets/vendor/libs/typeahead-js/typeahead.css" />
    <link rel="stylesheet" href="../assets/vendor/libs/datatables-bs5/datatables.bootstrap5.css">
<link rel="stylesheet" href="../assets/vendor/libs/datatables-responsive-bs5/responsive.bootstrap5.css">
<link rel="stylesheet" href="../assets/vendor/libs/datatables-checkboxes-jquery/datatables.checkboxes.css">
<link rel="stylesheet" href="../assets/vendor/libs/datatables-buttons-bs5/buttons.bootstrap5.css">
<link rel="stylesheet" href="../assets/vendor/libs/flatpickr/flatpickr.css" />
<!-- Row Group CSS -->
<link rel="stylesheet" href="../assets/vendor/libs/datatables-rowgroup-bs5/rowgroup.bootstrap5.css">
<!-- Form Validation -->
<link rel="stylesheet" href="../assets/vendor/libs/formvalidation/dist/css/formValidation.min.css" />


    <!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
    <!--? Template customizer: To hide customizer set displayCustomizer value false in config.js.  -->
     <!--? Config:  Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file.  -->
    <script src="../assets/js/config.js"></script>
	
	
	 <link rel="stylesheet" href="../assets/vendor/libs/toastr/toastr.css" />
	 <link rel="stylesheet" href="../assets/vendor/libs/animate-css/animate.css" />




    
    <!-- Page CSS -->
    	 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
   
   
   
   
  <link rel="stylesheet" href="../assets/vendor/libs/select2/select2.css" />

		 
	  <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.min.js" integrity="sha384-FzT3vTVGXqf7wRfy8k4BiyzvbNfeYjK+frTVqZeNDFl8woCbF0CYG6g2fMEFFo/i" crossorigin="anonymous"></script>
   <script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-JAW99MJVpJBGcbzEuXk4Az05s/XyDdBomFqNlM3ic+I=" crossorigin="anonymous"></script>
	
	
	
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
  

  
  
  
    <!-- Helpers -->
    <script src="../assets/vendor/js/helpers.js"></script>

 
    <script src="../assets/js/config.js"></script>
    
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async="async" src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
    <script>
    window.dataLayer = window.dataLayer || [];

    function gtag() {
      dataLayer.push(arguments);
    }
    gtag('js', new Date());
    gtag('config', 'GA_MEASUREMENT_ID');
    </script>
    <!-- Custom notification for demo -->
    <!-- beautify ignore:end -->

</head>
<body>

	 




  <!-- Layout wrapper -->
<div class="layout-wrapper layout-content-navbar  ">
  <div class="layout-container">

    
    




<!-- Menu -->

<?php include('left_sidebar.php'); ?>

<!-- / Menu -->

    

    <!-- Layout container -->
    <div class="layout-page">
      
      



<!-- Navbar -->

  
<?php include('header.php'); ?>



  
<!-- / Navbar -->
   
   <script>
   $(document).ready(function(){

     $('#myTable').DataTable( {
			  "ordering": false,
        dom: 'Bfrtip',

        buttons: 
		[
			
	  	  
	  {
        extend: 'copy',
       
		
      } , 
	  {
        extend: 'csv',
       
		
      } ,			
	  {
        extend: 'excel',
      
		
      },			
	  {
        extend: 'pdf',
       
		
      } , {
        extend: 'print',
		       

		
      } 
	  
	  
	  
	  ]
    } );
});
   </script>

      
 <script>
   
   	 $(function () {
 initSelect2();
});

</script>
      <!-- Content wrapper -->
      <div class="content-wrapper">

          <!-- Content -->
        
          <div class="container-xxl flex-grow-1 container-p-y">
            
            
<h4 class="py-3 breadcrumb-wrapper mb-4">
  <span class="text-muted fw-light"> Report / </span> <?php echo  strtoupper(str_replace('_',' ',$_GET['type']));  ?> <?php if(isset($_GET['sub_type'])) { echo  "-".strtoupper(str_replace('_',' ',$_GET['sub_type'])); }  ?>
</h4>

 
					   
	   
	<!-- Invoice List Table -->
	<div class=" ">


   <script>
 
 function deleteSelected(table)
 {
	 
	 if(confirm('Are you sure?'))
	 {
		   var dataArr = [];
		   
		 $("input:checkbox[name=delete_checkbox]:checked").each(function(){
    dataArr.push($(this).val());
});
		 
		 
		  var jsonString = JSON.stringify(dataArr);
		  
		  
		   if(dataArr.length == 0)
			  
			  {
				  toastr.warning("Please Select Record!"); 
			  }
			  else {
				  
				  
		    $.ajax({
      type: "POST",
      url: 'delete_records_ajax.php',
	    data: {record_ids:jsonString,table:table},
      success: function(data) {
	
	    // toastr.warning(data.trim()); 
		  
		 window.location="";
		 
		
		 }
		  // <- this turns it into synchronous

		  }
	   );
			  }
		  
		  
	 }
	 
	 
 }
 
 
 
 function selectAll()
 {
	 
	 if($("input:checkbox[name=delete_checkbox]").prop('checked') == true)
	 {
		  $("input:checkbox[name=delete_checkbox]").prop('checked', false);
	 }
	 
	 else{
	 $("input:checkbox[name=delete_checkbox]").prop('checked', true);
	 }
 }


</script>	





			 						
									
								 <!---  TABLE HERE  -->
  
<?php $pg=0; if(isset($_GET['page'])) { $pg=$_GET['page']; } ?>
  
  <script>
  
  $( document ).ready(function() {
  // Handler for .ready() called.
  
  <?php if($_GET['type']!='apr') {  ?>
  //showReport();

  <?php } ?>
  
});
   </script>
  
  <script>
  
  
 
 function showReport(){
	  
	//alert('a');
	
	
	 <?php if($_GET['type'] == 'acr' || $_GET['type'] == 'attendance'   ) { ?> 
	 
	  var from_date = '';
	  var to_date	  = '';
	  var month = document.getElementById('month').value;
	  
	 
	<?php } else {  ?>
	
	
	  var from_date = document.getElementById('from_date').value;
	  var to_date	  = document.getElementById('to_date').value;
	  var month = '';
	  
	<?php } ?>

 
    document.getElementById('report_spinner').style.display = 'block';
    document.getElementById('report_data_here').innerHTML='';
	
		
	  
    $.ajax({
      type: "GET",
      url: "get_<?php echo $_GET['type']; ?>_report_ajax.php?sub_type=<?php if(isset($_REQUEST['sub_type'])) { echo $_REQUEST['sub_type']; } ?>",
      data: ({from_date:from_date,to_date:to_date,month:month}),
      success: function(data) {
		
			document.getElementById('report_data_here').innerHTML=data;
			 document.getElementById('report_spinner').style.display = 'none';
			 
			 
			
     $('#myTable').DataTable( {
			  "ordering": false,
        dom: 'Bfrtip',
		paging: false,
        buttons: 
		[
			
	  	  
	  {
        extend: 'copy',
       
		
      } , 
	  {
        extend: 'csv',
       
		
      } ,			
	  {
        extend: 'excel',
      
		
      },			
	  {
        extend: 'pdf',
       
		
      } , {
        extend: 'print',
		       

		
      } 
	  
	  
	  
	  ]
    } ); 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			 
			
		 }
		  // <- this turns it into synchronous

		  }
	   );
	   
	}


  
  </script>





				<div class="row">
				
				 <?php if($_GET['type'] == 'acr' || $_GET['type'] == 'attendance'   ) { 
				 
				 ?>
				 <div class="col-md-3"> <input class="form-control" type="month" id="month" value="<?php echo date('Y-m'); ?>" ></div>
				
				 <?php
				 
				 } else { 

					

				 ?>
				 
				<div class="col-md-3"> <input class="form-control" type="date" id="from_date" value="<?php echo date('Y-m-d'); ?>" ></div>
				<div class="col-md-3"> <input  class="form-control" type="date" id="to_date" value="<?php echo date('Y-m-d'); ?>" ></div>
				
				<?php } ?>
		
				<div class="col-md-3"> <button onclick="showReport();" class="btn btn-primary">View</button></div>
				
				</div>

 
				  <Br/>
		  


   	          <center>
				<div id="report_spinner" style="display:none;" class="spinner-border spinner-border-lg text-primary" role="status">
				<span class="visually-hidden">Loading...</span>
				</div>
				  </center>
				  
				   
				  <Br/>
		  
				 
         <div  id="report_data_here" >
		 
		 </div>	
		 
 
			 

            
          </div>
          <!-- / Content -->
        
          
 
          
      
         </div>
        <!-- Content wrapper -->
      </div>
      <!-- / Layout page -->
    </div>

    
    
    
  </div>
  <!-- / Layout wrapper -->

 

 <!-- Core JS -->
  <!-- build:js assets/vendor/js/core.js -->
  <script src="../assets/vendor/libs/jquery/jquery.js"></script>
  <script src="../assets/vendor/libs/popper/popper.js"></script>
  <script src="../assets/vendor/js/bootstrap.js"></script>
  <script src="../assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>
  <script src="../assets/vendor/libs/hammer/hammer.js"></script>
  <script src="../assets/vendor/libs/i18n/i18n.js"></script>
  <script src="../assets/vendor/libs/typeahead-js/typeahead.js"></script>
  
  <script src="../assets/vendor/js/menu.js"></script>
  <script src="../assets/vendor/libs/select2/select2.js"></script>
  
    <script src="../assets/vendor/libs/toastr/toastr.js"></script>

     <script src="../assets/js/ui-toasts.js"></script>


  <!-- endbuild -->

  <!-- Vendors JS -->
  <script src="../assets/vendor/libs/datatables/jquery.dataTables.js"></script>
<script src="../assets/vendor/libs/datatables-bs5/datatables-bootstrap5.js"></script>
<script src="../assets/vendor/libs/datatables-responsive/datatables.responsive.js"></script>
<script src="../assets/vendor/libs/datatables-responsive-bs5/responsive.bootstrap5.js"></script>
<script src="../assets/vendor/libs/datatables-checkboxes-jquery/datatables.checkboxes.js"></script>
<script src="../assets/vendor/libs/datatables-buttons/datatables-buttons.js"></script>
<script src="../assets/vendor/libs/datatables-buttons-bs5/buttons.bootstrap5.js"></script>
<script src="../assets/vendor/libs/jszip/jszip.js"></script>
<script src="../assets/vendor/libs/pdfmake/pdfmake.js"></script>
<script src="../assets/vendor/libs/datatables-buttons/buttons.html5.js"></script>
<script src="../assets/vendor/libs/datatables-buttons/buttons.print.js"></script>
<!-- Flat Picker -->
<script src="../assets/vendor/libs/moment/moment.js"></script>
<script src="../assets/vendor/libs/flatpickr/flatpickr.js"></script>
<!-- Row Group JS -->
<script src="../assets/vendor/libs/datatables-rowgroup/datatables.rowgroup.js"></script>
<script src="../assets/vendor/libs/datatables-rowgroup-bs5/rowgroup.bootstrap5.js"></script>
<!-- Form Validation -->
<script src="../assets/vendor/libs/formvalidation/dist/js/FormValidation.min.js"></script>
<script src="../assets/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js"></script>
<script src="../assets/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js"></script>

  <!-- Main JS -->
  <script src="../assets/js/main.js"></script>

  <!-- Page JS -->
  <script src="../assets/js/tables-datatables-basic.js"></script>
</body>

 
</html>
  <?php  }  else { header("Location:login.php");  } ?>