<?php 
session_start();
include '../db.php';
include("../all_query.php");
error_reporting(0);
include('common_header_file.php');

 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-buttons-bs5/buttons.bootstrap5.css">


   
   
  <link rel="stylesheet" href="../assets/vendor/libs/select2/select2.css" />

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

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
   
   
    <!--! 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" />
<link rel="stylesheet" href="../assets/vendor/libs/sweetalert2/sweetalert2.css" />



	 
	  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.min.js" integrity="sha384-FzT3vTVGXqf7wRfy8k4BiyzvbNfeYjK+frTVqZeNDFl8woCbF0CYG6g2fMEFFo/i" crossorigin="anonymous"></script>
   <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-JAW99MJVpJBGcbzEuXk4Az05s/XyDdBomFqNlM3ic+I=" crossorigin="anonymous"></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 -->

      

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

        <!-- Content -->
		
		
		<div class="col-md" style="padding:10px;">
      
    <div class="accordion mt-3" id="accordionExample">
	
	
	<?php

     $type_i = 0;
	 
	 
	 if($_SESSION['login_as'] == 'admin')
	 {
	 
	 $customerTypeQ = mysqli_query($conn,"select *from `customer_type`  ");
	 
	 }
	 else
	 {
		 $advisor = $_SESSION['login_name'];
		 
	   $customerTypeQ = mysqli_query($conn,"select *from `customer_type` where id in (select customer_type_id from advisors where name = '$advisor' )   ");
		 
		 
	 }
	 

      while($typeData = mysqli_fetch_assoc($customerTypeQ))
	  {
		  
		  
		 $type_i++;
	?>
	
	
	
	
	  <script>
  
  $( document ).ready(function() {
  // Handler for .ready() called.
  
    getDashboardView("<?php echo $typeData['name']; ?>");
  
});
   </script>
   
   
     <script>
  
  
 
 function getDashboardView(customer_type){
	  
	//alert('a');
	
		
	 
    $.ajax({
      type: "GET",
      url: 'get_dashboard_view_ajax.php',
      data: ({customer_type:customer_type}),
      success: function(data) {
		
		
			document.getElementById('table_data_here_'+customer_type).innerHTML=data;
			
			
				var c=0;
				
				 
  
			
			
		 }
		  // <- this turns it into synchronous

		  }
	   );
	   
	}


  
  </script>
	
	
	
	
	
	
	
	
	
	
	
	

	
	
	
	
	
      <div class="card accordion-item <?php if($type_i=='1') { echo "active"; } ?> ">
        <h2 class="accordion-header" id="headingOne_<?php echo $typeData['name']; ?>">
          <button type="button" class="accordion-button collapsed" data-bs-toggle="collapse" data-bs-target="#accordionOne_<?php echo $typeData['name']; ?>" aria-expanded="false" aria-controls="accordionOne_<?php echo $typeData['name']; ?>">
           <?php echo $typeData['name']; ?>  Dashboard  
          </button>
        </h2>

        <div id="accordionOne_<?php echo $typeData['name']; ?>" class="accordion-collapse collapse <?php if($type_i=='1') { echo "show"; } ?>" data-bs-parent="#accordionExample" style="">
          <div class="accordion-body">
            
		 <div class="card-body1 loading">
	 	 <div id="table_data_here_<?php echo $typeData['name']; ?>">
		 
		  <table class="loading" ><tr><td></td></tr></table>
		  
		  
		   </div>
		 </div>	
		 
			
			
			
			
          </div>
        </div>
      </div>
	  
	  
	  <?php }  ?>
	  
	  
	  
       </div>
    </div>
  
        
          
		  
		  
		  <!---------   Case Forward Type ----------------->
		  
		  
		  
		  <?php  if($_SESSION['login_as'] == 'admin') { ?>
		  
		  <table class="table table-bordered text-center" style="tex">
		  
		  <thead>
		  <tr>
		    <th>Type</th>
		    <th>Pending</th>
		    <th>Actioned</th>
		  </tr>
			</thead>
			
			<?php $typeQ = mysqli_query($conn,"select *from `case_forward_type`");
			while($typeData = mysqli_fetch_assoc($typeQ) )
			{
				$forward_type = $typeData['name'];
				
				
				$pendingQ = mysqli_query($conn,"select *from `case_forward` where forward_type = '$forward_type' and forward_status = 'Pending' ");
				
				$pending = mysqli_num_rows($pendingQ);
				
				$actionedQ = mysqli_query($conn,"select *from `case_forward` where forward_type = '$forward_type' and forward_status = 'Done' ");
				$actioned = mysqli_num_rows($actionedQ);
				
				
				
			?> 
			
			<tr>
			<td><?php echo $forward_type; ?></td>
			
			
			<td><span  onclick="getCaseForward('0','','Pending','<?php echo $forward_type; ?>','Pending')" data-bs-toggle="modal" data-bs-target="#dashboardBreakupModal" style="cursor:pointer;" class="badge  bg-warning"><?php echo  $pending;  ?></span></span></td>
			
			
		  <td><span  onclick="getCaseForward('0','','Done','<?php echo $forward_type; ?>','Done')" data-bs-toggle="modal" data-bs-target="#dashboardBreakupModal" style="cursor:pointer;" class="badge  bg-success"><?php echo  $actioned;  ?></span></span></td>
			
			</tr>
			
			<?php } ?>
			
			
		  
		  
		  </table>
		  
		  <?php } ?>
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
		  
  
          
      
         </div>
        <!-- Content wrapper -->
		
		
		
	 



	 
  <script>
  
  
  
  var list_for = ''; 
  var advisor = ''; 
  var customer_type = ''; 
  
 
 function fetchAllParty(page,keyword,key_for,sale_user,customer_type1){
	 
	 if(key_for!='')
	 {
		 list_for = key_for;
	 }
	 
	 if(sale_user!='')
	 {
		 
		 advisor = sale_user;
	 }
	 
	  if(customer_type1!='')
	 {
		 
		 customer_type = customer_type1;
	 }
 
	  
	//alert('a');
	
	document.getElementById('dashboard_breakup_title').innerHTML = advisor + ' -  '+ key_for;
		
		
	var outstanding_slab = document.getElementById('outstanding_slab').value;	
		
		
	 $('#add-row').addClass('loading');
	 
    $.ajax({
      type: "GET",
      url: 'get_account_holder_table_ajax.php',
      data: ({page:page,keyword:keyword,key_for:list_for,advisor:advisor,customer_type:customer_type,outstanding_slab:outstanding_slab}),
      success: function(data) {
		
	    document.getElementById('dashboard_breakup_table_data_here').innerHTML=data;
			
			
				var c=0;
				
				 
  
			
			
		 }
		  // <- this turns it into synchronous

		  }
	   );
	   
	}


  
  </script>
	
	
	
	
	
	
	 
  <script>
  
  
   

 function getCaseForward(page,keyword,key_for,forward_type,forward_status){
	  
	//alert('a');
	
	document.getElementById('dashboard_breakup_title').innerHTML = forward_type + ' -  '+ forward_status;
		 
		 document.getElementById('outstanding_slab').style.display='none';
		 document.getElementById('search_area').style.display='none';
		  
		
	 $('#add-row').addClass('loading');
	 
    $.ajax({
      type: "GET",
      url: 'get_case_forward_table_ajax.php',
      data: ({page:page,keyword:keyword,key_for:'',forward_type:forward_type,forward_status:forward_status}),
      success: function(data) {
	
	   document.getElementById('dashboard_breakup_table_data_here').innerHTML=data;
			   
				  
		 }
		  // <- this turns it into synchronous

		  }
	   );
	   
	}


  
  </script>
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
		
		
			<div class="modal fade" id="dashboardBreakupModal" tabindex="-1" aria-hidden="true">
            <div class="modal-dialog modal-fullscreen" role="document">
              <div class="modal-content">
                <div class="modal-header">
				 <h6 id="dashboard_breakup_title"></h6>
				
                   <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
				
			<?php if($_SESSION['login_as'] == 'advisor') {   ?>
                 <a onclick="pauseFromCall(this);"   style=" color:white;   margin: 5px;" class="btn btn-sm btn-danger pause_button"><?php if($selfadvisorData['is_paused'] == 'on') { echo "Paused | Start Now"; } else { echo "Pause"; } ?></a>
				 
				 <a onclick="freeFromCall();" style=" color:white;   margin: 5px;" class="btn btn-sm btn-warning">Free</a>
			
			
				<?php } ?>
				
				
				
				  <select onchange="fetchAllParty(0,'','','','');"  id="outstanding_slab" name="outstanding_slab" >
				  <option value=''>All</option>
				  <option value='HIGHEST'>HIGHEST</option>
				  <option value='HIGH'>HIGH</option>
				  <option value='MEDIUM'>MEDIUM</option>
				  <option value='LOW'>LOW</option>
				  </select>
				
				   <p id="search_area" align="right"> Search: <input value="" onkeyup="fetchAllParty(0,this.value,'','','');" type="text" id="search_party"/></p>
		   
		   
				 <div class="card-body1 loading">
				 <div id="dashboard_breakup_table_data_here">
				 
				  <table class="loading" ><tr><td></td></tr></table>
				  
				  
				   </div>
				 </div>	
		 
		 
                </div>
                <div class="modal-footer">
                  <button type="button" class="btn btn-label-secondary" data-bs-dismiss="modal">Close</button>
                 </div>
              </div>
            </div>
          </div>
		
		
		
		
		
		
		
		
		
		
      </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>
	 
	   <script src="../assets/vendor/libs/sweetalert2/sweetalert2.js"></script>


  <!-- endbuild -->

  <!-- Vendors JS -->
  <script src="../assets/vendor/libs/moment/moment.js"></script>
<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-buttons/datatables-buttons.js"></script>
<script src="../assets/vendor/libs/datatables-buttons-bs5/buttons.bootstrap5.js"></script>

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

  <!-- Page JS -->
  <script src="../assets/js/app-invoice-list.js"></script>
</body>

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