<div class="clearfix"></div>

  <div class="content-wrapper">

    <div class="container-fluid">

       <div class="row pt-2 pb-2">

        <div class="col-sm-9">

			<h4 class="page-title">Approved KYC Distributors</h4>

	   	</div>

     </div>

    <!-- End Breadcrumb-->

      <div class="row">

			

            <div class="col-lg-12">

               <div class="card">

                    <div class="card-header">Listed Distributors</div>

                    <div class="card-body">

                         <table class="table table-condensed table-bordered" id="default-datatable">

                            <thead><tr><th>S.No.</th><th>Firm Name</th><th>City</th><th>Contact/Address</th><th>Action</th></tr></thead>

                            <tbody>

                                <?php $i=1;foreach($agents as $c){?>

                            	<tr><td><?php echo $i;?></td>

                                <td><?php echo $c->firm_name.'<br/>'.$c->ag_name;?><br/>

                                <label class="badge badge-success"><?php echo $c->ag_username;?></label><br/>

                                <label class="badge badge-default">Reg. <?php echo date("d-m-Y",strtotime($c->ag_reg_date));?></label><br/>
                                <label class="badge badge-info"><?php echo 'KAD00'.$c->ag_id;?></label></td>

                                <td><?php echo $c->city_name.'<br/>'.$c->state_name;?><br/>
                                
                                <label class="badge badge-warning"><?php echo $c->fname;?></label></td>

                                <td><i class="fa fa-phone"></i> <?php echo $c->ag_mobile;?><br/>


                                    <i class="fa fa-map-marker"></i> <?php echo $c->ag_address;?></td>

                                <td>

                                <!-- <a target="_blank" href="<?php //echo base_url().'admin/agent_collection/'.$c->ag_id;?>" class="btn btn-sm btn-primary"><i class="fa fa-inr"></i> Orders</a>-->
<a title="<?php echo $c->firm_name;?>" href="<?php echo $c->ag_id;?>" data-toggle="modal" data-target="#myModalv" class="btn btn-sm btn-success view_details">View</a>
                                 <a href="#" class="btn btn-sm btn-dark change_pass" data-toggle="modal" data-target="#myModalp" id="<?php echo $c->ag_id;?>"><i class="fa fa-lock"></i></a>
                                 <a href="#" class="btn btn-sm btn-primary addmoney" data-toggle="modal" data-target="#wallet_modal" id="<?php echo $c->ag_id;?>"><i class="fa fa-credit-card"></i> Wallet</a>

                                <a href="<?php echo base_url().'admin/distributors/'.$c->ag_id;?>" class="btn btn-sm btn-warning"><i class="fa fa-edit"></i></a>

                                <a href="#" id="<?php echo $c->ag_id.'-'.$c->ag_city;?>" class="btn btn-sm btn-danger comp_delete"><i class="fa fa-trash-o"></i></a>

                                

                                <?php if($c->ag_status==""){$st="Disable";}else{$st="Enable";}?>

                                    <a href="<?php echo $c->ag_id;?>" class="btn btn-sm btn-default enable"><?php echo $st;?></a>

                                </td></tr>

                            	<?php $i++;}?>

                            </tbody>

                        </table>

                        <div id="myModalv" class="modal fade" role="dialog">
                            <div class="modal-dialog modal-lg">
                            <!-- Modal content-->
                            <div class="modal-content">
                              <div class="modal-header">
                                <h4 class="modal-title pfirm_name">View Details</h4>
                                <button type="button" class="close" data-dismiss="modal">&times;</button>
                              </div>
                              <div class="modal-body view_detail_div">
                                
                              </div>
                            </div>
                            </div>
                            </div>
                            
                            <div id="wallet_modal" class="modal fade" role="dialog">
                                <div class="modal-dialog modal-lg">
                                <!-- Modal content-->
                                    <div class="modal-content">
                                      <div class="modal-header">
                                        <h4 class="modal-title pfirm_name">Distributor Wallet</h4>
                                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                                      </div>
                                      <div class="modal-body wallet_div row">
                                        
                                      </div>
                                    </div>
                                </div>
                            </div>

                        <div id="myModalp" class="modal fade" role="dialog">

                          <div class="modal-dialog modal-sm">

                            <!-- Modal content-->

                            <div class="modal-content">

                              <div class="modal-header">

                                <h4 class="modal-title">Change Password</h4>

                                <button type="button" class="close" data-dismiss="modal">&times;</button>

                              </div>

                              <div class="modal-body">

                                <form action="" method="post" id="update_password">

                                    <input type="hidden" name="emp_id" id="emp_id" value="" />

                                    <div class="form-group">

                                        <label>New Password</label>

                                        <input type="password" name="pass" id="pass" class="form-control" />

                                    </div>

                                    <div class="form-group">

                                        <label>Confirm Password</label>

                                        <input type="password" name="cpass" id="cpass" class="form-control" />

                                    </div>

                                    <button type="submit" class="btn btn-warning">Change Password</button>

                                    <button type="button" class="btn btn-light pull-right" data-dismiss="modal">Close</button>

                                </form>

                              </div>

                            </div>

                        

                          </div>

                        </div>

                    </div>

                    

               </div>                  

            </div>

            

        </div><!--End Row-->

	  

	  <!--End Row-->



    </div>

    <!-- End container-fluid-->

    

    </div><!--End content-wrapper-->

   <!--Start Back To Top Button-->

    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>

    <!--End Back To Top Button-->

	

	<!--Start footer-->

	<footer class="footer">

      <div class="container">

        <div class="text-center">

          Copyright © 2022

        </div>

      </div>

    </footer>

	<!--End footer-->

   

  </div><!--End wrapper-->





  <!-- Bootstrap core JavaScript-->

  

  <script src="<?php echo base_url();?>adminassets/plugins/bootstrap-datatable/js/jquery.dataTables.min.js"></script>

  <script src="<?php echo base_url();?>adminassets/plugins/bootstrap-datatable/js/dataTables.bootstrap4.min.js"></script>

  <script>

  function isNumberKey(evt){

		var charCode = (evt.which) ? evt.which : evt.keyCode

		return !(charCode > 31 && (charCode < 48 || charCode > 57));

	}

$(document).ready(function(){

	$(".view_details").click(function(e){e.preventDefault();
		var id=$(this).attr("href");
		var title=$(this).attr("title");
		$('.pfirm_name').text(title);
		$.ajax({
			 type: "POST",
			 url: '<?php echo base_url();?>admin/ajax_view_details',
			 data: {id:id},
			 success: function(res){//alert(res);
				$(".view_detail_div").html(res);
			 }
		 });
	});

	$(".view_bank").click(function(){

		var id=$(this).attr("id");

		$.ajax({

			 type: "POST",

			 url: '<?php echo base_url();?>admin/ajax_view_bank',

			 data: {id:id},

			 success: function(res){

				$(".view_bankdiv").html(res);

			 }

		});

	});
	
	$(".addmoney").click(function(e){e.preventDefault();



			var id=$(this).attr("id");



			 //$("#userid").val(id);



			// $("#bankdetails").html("Loading Details...");



			$.ajax({



					 type: "POST",



					 url: '<?php echo base_url();?>admin/user_wallet',



					 data: {id:id},



					 success: function(res){
						 //alert(res);

							

						 $(".wallet_div").html(res);



						}



					 });



		});

	$("#update_password").submit(function(e){e.preventDefault();

			var pass=$("#pass").val();

			var cpass=$("#cpass").val();

			if(pass.length<6 || pass!=cpass){alert("Please Enter Same Password and must be of atleast 6 characters.");return false;}

			var formdata=$(this).serialize();

			$.ajax({

				 type: "POST",

				 url: '<?php echo base_url();?>admin/ajax_update_password',

				 data: {formdata:formdata},

				 success: function(res){//alert(res);

				 	alert(res);

					//$("#emps_list").html(res);

				 }

			 });

		});

	$(".enable").click(function(e){e.preventDefault();

			var st=$(this).text();

			var id=$(this).attr("href");

			if(st=="Enable"){

			$(this).text("Disable");

			}else{

			$(this).text("Enable");	

			}

			$.ajax({

							 type: "POST",

							 url: '<?php echo base_url();?>admin/agent_enable',

							 data: {id:id,st:st},

							 success: function(response){

								 //alert(response);

							 }

							 });

		});

	$(".change_pass").click(function(e){e.preventDefault();

			var id=$(this).attr("id");

			$("#emp_id").val(id);

		});

$(".comp_delete").click(function(e){e.preventDefault();

	if(!confirm("Sure you want to delete?")){

		  return false;

		}

		var id=$(this).attr("id");$(this).closest("tr").remove();

		$.ajax({

			 type: "POST",

			 url: '<?php echo base_url();?>admin/ajax_agent_delete',

			 data: {id:id},

			 success: function(response){

				 //alert(response);

			 }

		});

	});

	

	$(".agent_areas").click(function(){

		var id=$(this).attr("id");

		$.ajax({

			 type: "POST",

			 url: '<?php echo base_url();?>admin/ajax_agent_areas',

			 data: {id:id},

			 success: function(res){

				$(".agent_areas_div").html(res);

			 }

		});

	});

});

</script>

	<script>

	$(document).ready(function(){$('#default-datatable').DataTable();

		$(".city_delete").click(function(e){e.preventDefault();

				if(!confirm("Sure you want to delete?")){

					  return false;

				}

				var id=$(this).attr("id");$(this).closest("tr").remove();

				$.ajax({

					 type: "POST",

					 url: '<?php echo base_url();?>admin/ajax_city_delete',

					 data: {id:id},

					 success: function(response){

						 //alert(response);

					 }

				});

			});

		});

</script>

	<!-- simplebar js -->

  <script src="<?php echo base_url();?>adminassets/js/sidebar-menu.js"></script>

  <script src="<?php echo base_url();?>adminassets/js/app-script.js"></script>

  <!-- Custom scripts -->



    

	

</body>

</html>

