<?php
ob_start();
error_reporting(0);
include("connect.php");
session_start(); 
$ver = $_SESSION["admin_id"];
$dis_id = $_SESSION["manager_id"];
$user_type = $_SESSION["user_type"];
$user_session = $_SESSION["user_session"];
if(!isset($_SESSION["admin_id"])){
   header('location:http://www.btcover.appexperts.net');
}
date_default_timezone_set('Asia/Calcutta');
	$cdate  = date("Y-m-d");
?>
<!DOCTYPE html>
<html dir="ltr" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon.png">
    <title>BTCOVER : Admin Dashboard</title>
    <!-- Custom CSS -->
    <link rel="stylesheet" type="text/css" href="assets/extra-libs/multicheck/multicheck.css">
    <link href="assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.css" rel="stylesheet">
    <link href="dist/css/style.min.css" rel="stylesheet">
	<script>
		 function calCommission(str)
			 {
				 
				 var cdate1=document.getElementByName('cdate1').value;
				 var cdate2=document.getElementByName('cdate2').value;
				 var agent_id=document.getElementById('agent_id').value;
				alert(str);
				var req=new XMLHttpRequest();
			 req.open("POST","http://localhost/insurancedb/calculate_agent_commission.php?agent_id="+agent_id+"&cdate1="+cdate1+"&cdate2"+cdate2,true);
			 req.send();
			 
			 req.onreadystatechange=function()
			 {
				 if(req.readyState == 4 && req.status == 200)
				 {
					 alert(req.readyState);
			 document.getElementById("paid").innerHTML=req.responseText;
	
			 }
			  }
			
			
			 }
		</script>
		<script>
		function setagentid(str)
		{
			document.getElementById('agent_id').value=str;
		}
		</script>
</head>

<body>
   
    <div id="main-wrapper">
	 <?php include("header.php"); ?>
    
     <?php include("menu.php"); ?>
	
	
       
      
        <div class="page-wrapper">
		 <div class="page-breadcrumb">
                <div class="row">
                    <div class="col-12 d-flex no-block align-items-center">
                        <h4 class="page-title">Pay Agent Commission</h4>
                        <div class="ml-auto text-right">
                            <nav aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
                                   
                                    <li class="breadcrumb-item active" aria-current="page">Pay Agent Commission</li>
                                </ol>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
           
            <div class="container-fluid" >
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body" style="float:left; width:100%; overflow-Y: auto; height: 500px;">
                                <div class="table-responsive">
                                    <table id="zero_config" class="table table-striped table-bordered">
                                        <thead>
                                            <tr>
											  <th><b>#</b></th>
											    <th><b>Agent Name</b></th>
												 <th><b>Phone No</b></th>
												 <th><b>Code</b></th>
												
												 <th><b>Action</b></th>
											</tr>
                                        </thead>
                                        <tbody>
										  <?php 
									   $c=1;
										if($user_type=='Manager') 
											$selrenew3=mysqli_query($con,"select * from tbl_agent where manager_id='$dis_id'  and status!='Deleted' order by agent_id desc");
										else
											$selrenew3=mysqli_query($con,"select * from tbl_agent where status!='Deleted' and manager_id in (select manager_id from tbl_manager where admin_id='$ver') order by agent_id desc");
										if(mysqli_num_rows($selrenew3)>0)
										{
											while($recset=mysqli_fetch_array($selrenew3))
											{
										?>
										<tr>
										  <td><?php echo $c++; ?></td>
										  <td><?php echo $recset['agent_name']; ?></td>
										  <td><?php echo $recset['agent_phone']; ?></td>
										  <td><?php echo $recset['agent_code']; ?></td>
										  
										  <td>
												<a href="agent-commission-pay2.php?id=<?php echo $recset['agent_id'];?>" style="font-size:12px;padding:1px 5px;" onClick="return confirm('Are you sure to pay commission')" class="btn btn-success">Pay Commission</a>
											
										  </td>
										  
										</tr>
										<?php }} else { ?>
										 <tr>
										  <td colspan='5'>No Data Available</td>
										</tr>
										<?php } ?>
                                        </tbody>
                                       
                                    </table>
									
									
									
									
									
									
									
									
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
             
            </div>
         
            <footer class="footer text-center">
                  2019 &copy; All Rights Reserved by BTCOVER. Designed and Developed by <a href="http://www.belltechnology.in/">Bell Technology</a>.
            </footer>
          
        </div>
      
    </div>
  
   <script src="assets/libs/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="assets/libs/popper.js/dist/umd/popper.min.js"></script>
    <script src="assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="assets/libs/perfect-scrollbar/dist/perfect-scrollbar.jquery.min.js"></script>
    <script src="assets/extra-libs/sparkline/sparkline.js"></script>
    <!--Wave Effects -->
    <script src="dist/js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="dist/js/sidebarmenu.js"></script>
    <!--Custom JavaScript -->
    <script src="dist/js/custom.min.js"></script>
    <!-- This Page JS -->
    <script src="assets/libs/inputmask/dist/min/jquery.inputmask.bundle.min.js"></script>
    <script src="dist/js/pages/mask/mask.init.js"></script>
    <script src="assets/libs/select2/dist/js/select2.full.min.js"></script>
    <script src="assets/libs/select2/dist/js/select2.min.js"></script>
    <script src="assets/libs/jquery-asColor/dist/jquery-asColor.min.js"></script>
    <script src="assets/libs/jquery-asGradient/dist/jquery-asGradient.js"></script>
    <script src="assets/libs/jquery-asColorPicker/dist/jquery-asColorPicker.min.js"></script>
    <script src="assets/libs/jquery-minicolors/jquery.minicolors.min.js"></script>
    <script src="assets/libs/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
    <script src="assets/libs/quill/dist/quill.min.js"></script>
	<script src="assets/libs/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="assets/libs/popper.js/dist/umd/popper.min.js"></script>
    <script src="assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="assets/libs/perfect-scrollbar/dist/perfect-scrollbar.jquery.min.js"></script>
    <script src="assets/extra-libs/sparkline/sparkline.js"></script>
    <!--Wave Effects -->
    <script src="dist/js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="dist/js/sidebarmenu.js"></script>
    <!--Custom JavaScript -->
    <script src="dist/js/custom.min.js"></script>
    <!-- this page js -->
    <script src="assets/extra-libs/multicheck/datatable-checkbox-init.js"></script>
    <script src="assets/extra-libs/multicheck/jquery.multicheck.js"></script>
    <script src="assets/extra-libs/DataTables/datatables.min.js"></script>
	<script>
        /****************************************
         *       Basic Table                   *
         ****************************************/
        $('#zero_config').DataTable();
    </script>
    <script>
        //***********************************//
        // For select 2
        //***********************************//
        $(".select2").select2();

        /*colorpicker*/
        $('.demo').each(function() {
        //
        // Dear reader, it's actually very easy to initialize MiniColors. For example:
        //
        //  $(selector).minicolors();
        //
        // The way I've done it below is just for the demo, so don't get confused
        // by it. Also, data- attributes aren't supported at this time...they're
        // only used for this demo.
        //
        $(this).minicolors({
                control: $(this).attr('data-control') || 'hue',
                position: $(this).attr('data-position') || 'bottom left',

                change: function(value, opacity) {
                    if (!value) return;
                    if (opacity) value += ', ' + opacity;
                    if (typeof console === 'object') {
                        console.log(value);
                    }
                },
                theme: 'bootstrap'
            });

        });
        /*datwpicker*/
        jQuery('.mydatepicker').datepicker();
        jQuery('#datepicker-autoclose').datepicker({
            autoclose: true,
            todayHighlight: true
        });
        var quill = new Quill('#editor', {
            theme: 'snow'
        });

    </script>

    <script>
        /****************************************
         *       Basic Table                   *
         ****************************************/
        $('#zero_config').DataTable();
    </script>

</body>

</html>