<?php
session_start();
include "connect.php";
$currentpage=752;
$activepage="royalty_income";

if(!isset($_SESSION['admin_login'])){ header("location:index.php");}
$user = "right";
$q_sql="SELECT * FROM `user_tbl` WHERE id <> 1";
$q_query=mysqli_query($conn,$q_sql." ORDER BY id DESC");

if(isset($_GET['block_id'])){
	
	$q_sql_update = "UPDATE `user_tbl` SET `pay_status`= 0 WHERE id = '".$_GET['block_id']."' ";
				 $q_query_update = mysqli_query($conn,$q_sql_update);
if($q_query_update){				 
				  echo "<script>alert('Block member!');   window.location = 'view_member.php'; </script>";		
				//header("location:home.php");			
		}else{
		 echo "<script>alert('Error!');   window.location = 'view_member.php'; </script>";		 
		}
}

if(isset($_GET['approve_id'])){
	
	$q_sql_update = "UPDATE `user_tbl` SET `pay_status`= 1 WHERE id = '".$_GET['approve_id']."' ";
				 $q_query_update = mysqli_query($conn,$q_sql_update);
if($q_query_update){
	$c_date= date('d-m-Y');
	
	$direct_member = 0;
	$direct_member_up = 0;
			   $q_sql_agent = "SELECT * FROM `user_tbl` WHERE pay_status = 1 ORDER BY `user_tbl`.`id` ASC";
				$q_query_agent = mysqli_query($conn,$q_sql_agent);
				 $total_num = mysqli_num_rows($q_query_agent); 
				while($row_agent = mysqli_fetch_array($q_query_agent)){
						$direct_member_up = 0;
					$q_sql_agent1 = "SELECT * FROM `user_tbl` WHERE pay_status = 1 AND id > '".$row_agent['id']."'"; 
				        $q_query_agent1 = mysqli_query($conn,$q_sql_agent1);
				          $member_num = mysqli_num_rows($q_query_agent1); //die;
						  
						  $q_sql_agent2 = "SELECT * FROM `user_tbl` WHERE pay_status = 1 AND user_refferal_code = '".$row_agent['user_unique_id']."'"; 
				        $q_query_agent2 = mysqli_query($conn,$q_sql_agent2);
				          $direct_num = mysqli_num_rows($q_query_agent2); //die;
						  $member_num = $member_num -  $direct_num; 
						  
				         if($member_num >= 50 && $direct_num >= 5){
						 // if($direct_member_up >= 2){
							  if($row_agent['rank_date3'] == ""){
					 $query_sel2 = "UPDATE `user_tbl` SET `status` = 1,`rank` = 3,`rank_date3` = '$c_date' WHERE id = '".$row_agent['id']."'"; 
			        $result_sel2 = mysqli_query($conn,$query_sel2);
							  }
						 // }
					   }else  if($member_num >= 25 && $direct_num >= 2){
						  //if($direct_member_up >= 2){
							  if($row_agent['rank_date2'] == ""){
					 $query_sel2 = "UPDATE `user_tbl` SET `status` = 1,`rank` = 2,`rank_date2` = '$c_date' WHERE id = '".$row_agent['id']."'"; 
			        $result_sel2 = mysqli_query($conn,$query_sel2);
							 }
						// }
					   }else if($member_num >= 10){
						   if($row_agent['rank_date'] == ""){
					 $query_sel2 = "UPDATE `user_tbl` SET `status` = 1,`rank` = 1,`rank_date` = '$c_date' WHERE id = '".$row_agent['id']."'"; 
			        $result_sel2 = mysqli_query($conn,$query_sel2);
						   }
				       }
					
				
				} 
				
				 			 echo "<script>alert('Approved member!');   window.location = 'view_member.php'; </script>";		
				//header("location:home.php");			
		}else{
		 echo "<script>alert('Error!');   window.location = 'view_member.php'; </script>";		 
		}
}
/*
 function team_list_member($user_unique_id,$conn,$sno,$co){ // find chain
					  $sno = $sno+1;
			  $q_sql_agent = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent = mysqli_query($conn,$q_sql_agent);
				while($row_agent = mysqli_fetch_array($q_query_agent)){
				
				if($row_agent['rank'] == 1){
				$GLOBALS['co2'] = $GLOBALS['co2'] + 1;
				}
				 $user_unique_id = $row_agent['user_unique_id'];
				 $q_sql_agent1 = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent1 = mysqli_query($conn,$q_sql_agent1);
				if(mysqli_num_rows($q_query_agent1) > 0){
				   team_list_member($user_unique_id,$conn,$sno,$co);
				}
			}
				 // number
  } // end while 
				   
function team_list_gold($user_unique_id,$conn,$sno,$co){ // find chain
					  $sno = $sno+1;
			  $q_sql_agent = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent = mysqli_query($conn,$q_sql_agent);
				while($row_agent = mysqli_fetch_array($q_query_agent)){
				
				if($row_agent['rank'] == 4){
				$GLOBALS['co3'] = $GLOBALS['co3'] + 1;
				}
				 $user_unique_id = $row_agent['user_unique_id'];
				 $q_sql_agent1 = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent1 = mysqli_query($conn,$q_sql_agent1);
				if(mysqli_num_rows($q_query_agent1) > 0){
				   team_list_gold($user_unique_id,$conn,$sno,$co);
				}
			}
				 // number
				   } // end while
	*/
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>:: Right Choices | View Member ::</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<?php include "common/CSS_link.php";?>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="js/jquery-ui.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.3.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
    $('#MyTable').DataTable( {
        initComplete: function () {
            this.api().columns().every( function () {
                var column = this;
                var select = $('<select><option value=""></option></select>')
                    .appendTo( $(column.footer()).empty() )
                    .on( 'change', function () {
                        var val = $.fn.dataTable.util.escapeRegex(
                            $(this).val()
                        );
                //to select and search from grid
                        column
                            .search( val ? '^'+val+'$' : '', true, false )
                            .draw();
                    } );
 
                column.data().unique().sort().each( function ( d, j ) {
                    select.append( '<option value="'+d+'">'+d+'</option>' )
                } );
            } );
        }
    } );
} );
</script>
<script>
  var dateToday = new Date(); 
	$( function() {	
    $( ".datepicker" ).datepicker({
    dateFormat: 'yy-mm-dd'   
	});
  } ); 
 
    
function isNumber(evt) {
	var iKeyCode = (evt.which) ? evt.which : evt.keyCode
	if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57)){
		return false;
	}
	return true;
} 

	$(document).ready(function (e){
		$("#editUser").on('submit',(function(e){
			e.preventDefault();
			var url = $(this).attr('action');			
			console.log(url);			
				$.ajax({
					url: url,
					type: "POST",
					data:  new FormData(this),
					contentType: false,
					cache: false,
					processData:false,
						success: function(data){										
						$('#ajax_edit').html(data);	
						setTimeout('window.location.reload();',4000); 
						
						},
					error: function(){} 	        
				});
			}));
		});

$(function() {

	$(".name").focus();
	var clients = [
	<?php						
		$q_pps=mysqli_query($conn,"SELECT * FROM user_tbl");
		while($r_pps=mysqli_fetch_array($q_pps)){
	?>
	  {        
        label: "<?php echo $r_pps['user_name'];?>",        
        icon: "<?php echo $r_pps['user_id'];?>"
      },
	<?php	}	?>
	 ];
    $( ".name" ).autocomplete({
      minLength: 0,
      source: clients,
      focus: function( event, ui ) {
        $( ".name" ).val( ui.item.label );
		return false;
      },
      select: function( event, ui ) {			
        $( ".name" ).val( ui.item.label );        
        return false;
      }
    })
    .autocomplete( "instance" )._renderItem = function( ul, item ) {		
	 return $( "<li>" )
       .append( "<a>" + item.label + "<br><span style='color:#808080; font-size:10px;'>" + item.icon + "</span></a>" )
	    //.append( "<a>" + item.label + "</a>" )
        .appendTo( ul );
		};
  });

$(function() {

	$("#name123").focus();
	var clients = [
	<?php						
		$q_pps123=mysqli_query($conn,"SELECT * FROM company_tbl GROUP BY company_id,company_name ASC LIMIT 10");
		while($r_pps123=mysqli_fetch_array($q_pps123)){
	?>
	  {        
        label: "<?php echo $r_pps123['company_id'];?>",
		icon: "<?php echo $r_pps123['company_name'];?>",
      },
	<?php	}	?>
	<?php						
		$q_pps=mysqli_query($conn,"SELECT * FROM user_tbl GROUP BY user_id,user_name ASC LIMIT 10");
		while($r_pps=mysqli_fetch_array($q_pps)){
	?>
	  {               
        label: "<?php echo $r_pps['user_id'];?>",
		icon: "<?php echo $r_pps['user_name'];?>",
      },
	<?php	}	?>
	 ];
    $( "#name123" ).autocomplete({
      minLength: 0,
      source: clients,
      focus: function( event, ui ) {
        $( "#name123" ).val( ui.item.label );
		return false;
      },
      select: function( event, ui ) {			
        $( "#name123" ).val( ui.item.label );        
        return false;
      }
    })
    .autocomplete( "instance" )._renderItem = function( ul, item ) {		
	 return $( "<li>" )
       .append( "<a>" + item.label + "<br><span style='color:#808080; font-size:10px;'>" + item.icon + "</span></a>" )
	   // .append( "<a>" + item.icon + "</a>" )
        .appendTo( ul );
		};
  });  
</script>
<style>
[class*=" pe-7s-"], [class^=pe-7s-] {
    display: inline-block;
    font-family: Pe-icon-7-stroke;
    speak: none;
    font-style: normal;
    font-weight: 400;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
user agent stylesheet
i, cite, em, var, address, dfn {
    font-style: italic;
}
.content-header .header-icon {
    font-size: 55px;
    color: #37a000;
    width: 68px;
    float: left;
    margin-top: -4px;
    line-height: 0;
}
.link {padding: 10px 15px;background: transparent;border:#bccfd8 1px solid;border-left:0px;cursor:pointer;color:#607d8b}
.disabled {cursor:not-allowed;color: #bccfd8;}
.current {background: #bccfd8;}
.first{border-left:#bccfd8 1px solid;}
.question {font-weight:bold;}
.answer{padding-top: 10px;}
#pagination{margin-top: 20px;padding-top: 30px;border-top: #F0F0F0 1px solid;}
.dot {padding: 10px 15px;background: transparent;border-right: #bccfd8 1px solid;}
#overlay {background-color: rgba(0, 0, 0, 0.6);z-index: 999;position: absolute;left: 0;top: 0;width: 100%;height: 100%;display: none;}
#overlay div {position:absolute;left:50%;top:50%;margin-top:-32px;margin-left:-32px;}
.page-content {padding: 20px;margin: 0 auto;}
.pagination-setting {padding:10px; margin:5px 0px 10px;border:#bccfd8  1px solid;color:#607d8b;}
</style>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
  <header class="main-header">
    <?php include "common/header.php";?>
  </header> 
  <aside class="main-sidebar">    
    <section class="sidebar">
      <?php include "common/LEFT_sidebar.php";?>
  </aside>  
  <div class="content-wrapper">    
    <section class="content-header">
	<div class="header-icon">
	 <i class="fa fa-file-text-o" style="color:#37a000; font-size:50px;"></i>
	    </div>
      <h1 style="fonyt-family:'Alegreya Sans',sans-serif; margin: 0; font-size: 24px">Royalty Income<br><span style="font-size: 13px; display: inline-block; padding-left: 4px; font-weight: 600; color: #7a7a7a;">Royalty Income</span></h1>
      <ol class="breadcrumb">
        <li><a href="home.php"><i class="fa fa-dashboard"></i>Home</a></li>        
        <li class="active" style="color:#37a000; font-weight:bold;">Royalty Income</li>
      </ol>
    </section>    
    <section class="invoice">      
      <div class="row">
        <div class="col-xs-12">
          
			<!--<div style="clear:both;">
				<div style="float:left;"><input type="text" class="form-control name" id='name' placeholder="Name"  name="name"> </div>
				<div style="float:left;">&nbsp;<button class="btn btn-sm btn-primary" type="submit" id='item-search' style="margin-top:2px;"><i class="fa fa-search"></i></button></div>
				
				<div style="float:left; margin-left:10px;"><input type="text" class="form-control" id='name123' placeholder="Name"  name="name"> </div>
				<div style="float:left;">&nbsp;<button class="btn btn-sm btn-success" type="submit" id='item-search123' style="margin-top:2px;"><i class="fa fa-search"></i></button></div>
			</div>
			
            <div class="form-inline" role="form">				
			<div style="display: inline-block" class="pull-right">
			<div class="form-group">
				<label>From</label>
				<input type="text" class="form-control datepicker" id='from' placeholder="Start date"  name="from">
			</div>
			<div class="form-group">
				<label>To</label>
				<input type="text" class="form-control datepicker" id='to' placeholder="End date"  name="to">                         
				<button class="btn btn-sm btn-primary" style="" type="submit" id='date-search'>Search</button>
			</div> 
			</div>                       
            </div>   -->
        </div>        
      </div>     
      <div class="row">
        <div class="col-xs-12 table-responsive">
		<div id="result" style="margin:15px 0;"></div>
          <table id="MyTable" class="table" border="1" style="width:1200px;" >
            
            <thead style="font-family:sans; background:#008080; color:#fff;">
			 <tr>
                                                <th>#</th>
                                               <th>Joined on</th>
                                                <th>Active on</th>
                                                <th>Time on</th>
                                                <th>Member Id</th>
                                                <th>Member Name</th>
                                                <th>Status</th>
                                                <th>Package</th>
                                                <th>Total</th>
                                                <th>Details</th>
                                            </tr>
                                        </thead>
                                        <tbody>
									<?php $co1 = 1; 
									 $sno = 1; 
								
				while($row = mysqli_fetch_array($q_query)){
					$q_sql_agent1 = "SELECT active_tbl_details.* FROM `active_tbl_details`  WHERE active_tbl_details.user_id = '".$row['id']."'";
				$q_query_agent1 = mysqli_query($conn,$q_sql_agent1);
				$row_agent1 = mysqli_fetch_array($q_query_agent1);
				$row_num1 = mysqli_num_rows($q_query_agent1);
				
				?>
				 <tr>			       
			  <td><?php echo $sno;?></td>					  
			    <td><?php echo $row['c_date'];?></td>
			  <td><?php echo $row_agent1['c_date'];?></td>
			  <td><?php echo $row_agent1['c_time'];?></td>
			  <td><?php echo $row['user_unique_id'];?></td>
			  <td><?php echo $row['name']." ".$row['last'];?></td>
			<td><?php if($row_num1 > 0 ){ echo "Active"; }else{ echo "Inactive"; }?></td>
			 <td class="text-left"><?php if($row['rank'] == 0){ echo "0"; }
			  else if($row['rank'] == 1){ echo "555"; } 
			  else if($row['rank'] == 2){ echo "1000"; } 
			  else if($row['rank'] == 3){ echo "2000"; } 
			  else if($row['rank'] == 4){ echo "3000"; } 
			  else if($row['rank'] == 5){ echo "5000"; } 
			  else if($row['rank'] == 6){ echo "10000"; } 
			  else if($row['rank'] == 7){ echo "20000"; } 
			  else if($row['rank'] == 8){ echo "30000"; }
				else if($row['rank'] == 9){ echo "Level-9"; }
				else if($row['rank'] == 10){ echo "Level-10"; }
				else if($row['rank'] == 11){ echo "Level-11"; }
				else if($row['rank'] == 12){ echo "Level-12"; }
				else if($row['rank'] == 13){ echo "Level-13"; }
				else if($row['rank'] == 14){ echo "Level-14"; }
				else if($row['rank'] == 15){ echo "Level-15"; }			  ?></td>
				<td class="text-left"><?php
					$royalty_comm = 0;
					
					if($row['royalty_rank'] == 1){ 
					if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date']))) <= date('Y-m-d')){
				  $num = round((strtotime(date('Y-m-d')) - strtotime('+1 days',strtotime($row['rank_date'])))/(24 * 60 * 60)) + 1;
				if($num > 300){
				$num = 300;
				}					
			$royalty_comm = $royalty_comm + round(($num)*50*85/100);
			  
			  } }else if($row['royalty_rank'] == 2){ 
					if($row['rank_date'] !=""){
					
					if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date']))) <= date('Y-m-d')){
				  $num = round((strtotime($row['rank_date2']) - strtotime('+1 days',strtotime($row['rank_date'])))/(24 * 60 * 60)) + 1;
				if($num > 300){
				$num = 300;
				}					
				$royalty_comm = $royalty_comm + round(($num)*50*85/100);
			  
			  }
			  if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date2']))) <= date('Y-m-d')){
				  $num2 = round((strtotime(date('Y-m-d')) - strtotime('+1 days',strtotime($row['rank_date2'])))/(24 * 60 * 60)) + 1;
				if($num2 > (300 - $num - 1)){
				$num2 = (300 - $num - 1);
				}					
				$royalty_comm = $royalty_comm + round(($num2)*125*85/100);
			   } 
			   }else{  
			   if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date2']))) <= date('Y-m-d')){
				  $num = round((strtotime(date('Y-m-d')) - strtotime('+1 days',strtotime($row['rank_date2'])))/(24 * 60 * 60)) + 1;
				if($num > 300){
				$num = 300;
				}					
				$royalty_comm = $royalty_comm + round(($num)*125*85/100);
			  
			  } }  }else if($row['royalty_rank'] == 3){ 
					if($row['rank_date'] !="" && $row['rank_date2'] !=""){
					
					if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date']))) <= date('Y-m-d')){
				  $num = round((strtotime($row['rank_date2']) - strtotime('+1 days',strtotime($row['rank_date'])))/(24 * 60 * 60)) + 1;
				if($num > 300){
				$num = 300;
				}					
				$royalty_comm = $royalty_comm + round(($num)*50*85/100);
			  
			  }

			  if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date2']))) <= date('Y-m-d',strtotime($row['rank_date3']))){
				  $num2 = round((strtotime($row['rank_date3']) - strtotime('+1 days',strtotime($row['rank_date2'])))/(24 * 60 * 60)) + 1;
				if($num2 > 300 - $num){
				$num2 = 300 - $num;
				}					
				$royalty_comm = $royalty_comm +  round(($num2)*125*85/100);
			  
			  }
			  
			  if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date3']))) <= date('Y-m-d')){
				  $num3 = round((strtotime(date('Y-m-d')) - strtotime('+1 days',strtotime($row['rank_date3'])))/(24 * 60 * 60)) + 1;
				if($num3 > (300 - $num - $num2 - 2)){
				$num3 = (300 - $num - $num2 - 2);
				}					
			$royalty_comm = $royalty_comm +   round(($num3)*200*85/100);
			  
			  }
			  
			  }else{

			  if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date3']))) <= date('Y-m-d')){
				  $num = round((strtotime(date('Y-m-d')) - strtotime('+1 days',strtotime($row['rank_date3'])))/(24 * 60 * 60)) + 1;
				if($num > 300){
				$num = 300;
				}					
				$royalty_comm = $royalty_comm + round(($num)*200*85/100);
			  
			  } }  }else if($row['royalty_rank'] == 4){ 
					if($row['rank_date'] !="" && $row['rank_date2'] !="" && $row['rank_date3'] !=""){
					
					if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date']))) <= date('Y-m-d')){
				  $num = round((strtotime($row['rank_date2']) - strtotime('+1 days',strtotime($row['rank_date'])))/(24 * 60 * 60)) + 1;
				if($num > 300){
				$num = 300;
				}					
				$royalty_comm = $royalty_comm +  round(($num)*50*85/100);
			  
			  }
			  
			  if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date2']))) <= date('Y-m-d',strtotime($row['rank_date3']))){
				  $num2 = round((strtotime($row['rank_date3']) - strtotime('+1 days',strtotime($row['rank_date2'])))/(24 * 60 * 60)) + 1;
				if($num2 > 300 - $num){
				$num2 = 300 - $num;
				}					
				$royalty_comm = $royalty_comm + round(($num2)*125*85/100);
			  
			  }
			  if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date3']))) <= date('Y-m-d',strtotime($row['rank_date4']))){
				  $num3 = round((strtotime($row['rank_date4']) - strtotime('+1 days',strtotime($row['rank_date3'])))/(24 * 60 * 60)) + 1;
				if($num3 > 300 - $num - $num2){
				$num3 = 300 - $num - $num2;
				}					
				$royalty_comm = $royalty_comm + round(($num3)*200*85/100);
			  
			  }
			   if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date4']))) <= date('Y-m-d')){
				  $num4 = round((strtotime(date('Y-m-d')) - strtotime('+1 days',strtotime($row['rank_date4'])))/(24 * 60 * 60)) + 1;
				if($num4 > (300 - $num - $num2 - $num3 - 3)){
				$num4 = (300 - $num - $num2 - $num3 - 3);
				}					
			$royalty_comm = $royalty_comm + round(($num4)*300*85/100);
			  
			  } }else{
				  if(date('Y-m-d',strtotime('+1 days',strtotime($row['rank_date4']))) <= date('Y-m-d')){
				  $num = round((strtotime(date('Y-m-d')) - strtotime('+1 days',strtotime($row['rank_date4'])))/(24 * 60 * 60)) + 1;
				if($num > 300){
				$num = 300;
				}					
				$royalty_comm = $royalty_comm + round(($num)*300*85/100);
			  
			  } }  }
			   
				echo round($royalty_comm*85 /100);

				 ?></td>
				  <td class="text-left"><a class="btn btn-success"  href="indivisual_royalty_income.php?member_id=<?php echo $row['id']; ?>" >View Commission</a></td>
            </tr>
			
			
			
			<?php 
				 $sno =  $sno +1;
			  }
			?>
                                 </tbody>
          </table>	
						
        </div>       
      </div>        
       
      
	  <div class="row no-print">
	   <div class="box box-primary" style="box-shadow:none; border:none;">
            <div class="box-header ">
              <h3 class="box-title"></h3>
            </div>   
            <div class="box-body" style="height:550px;">             
            </div>     
          </div>
	  </div>
	   <div class="modal fade" id="modal-container-666931" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header" style="background:#605ca8; color:#FFF;">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="color:#FFF;">×</button>
				<h4 class="modal-title" id="myModalLabel">Edit User ID : <span id="user_id123"style="font-weight:bold;"></span>(<span id="user_type123" style="font-size:12px; font-style:italic; color:#f39c12; "></span>)</h4>
			</div>
			<div class="modal-body">
				<div id='ajax_edit'></div>                        
				<form class="form-horizontal" role="form" id="editUser" action="ajax/user.php" method="POST" enctype="multipart/form-data" >
					<input type="hidden" name="edit_user" value="User" />			
				<div class="form-group">					
					<div class="col-sm-6">
					<label class="control-label">Company ID</label>
						<input type="text" class="form-control" name="company_id" id="company_id123" placeholder="Company ID" readonly autocomplete="off">
					</div>
					<div class="col-sm-6">
					<label class="control-label">DOJ <span style="color:red;">*</span></label>
						<input type="text" class="form-control" name="doj" id="doj123" value="<?php echo date("d/m/Y");?>" autocomplete="off" readonly required>
					</div>					
				</div>				
				<div class="form-group">					
					<div class="col-sm-12">
						<label class="control-label">Name <span style="color:red;">*</span></label>						
						<input type="text" class="form-control" name="user_name" id="user_name123" placeholder="Name" autocomplete="off" required>
					</div>					
				</div>
				<div class="form-group">					
					<div class="col-sm-4">
						<label class="control-label">Address <span style="color:red;">*</span></label>
						<textarea class="form-control" name="user_address" id="user_address123" placeholder="Address" required></textarea>
					</div>
					<div class="col-sm-4">
						<label class="control-label">State <span style="color:red;">*</span></label>
						<input type="text" class="form-control" name="state_name" id="state_name123" placeholder="" autocomplete="off">
						
					</div>
					<div class="col-sm-4">
					<label class="control-label">Pincode</label>
						<input type="text" class="form-control" name="user_pin" id="user_pin123" placeholder="Pincode" autocomplete="off">
					</div>
				</div>
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label">Phone (primary) <span style="color:red;">*</span></label>
						<input type="text" class="form-control" name="user_phone" id="user_phone123" placeholder="Phone Number" autocomplete="off" onkeypress="javascript:return isNumber(event)" required>
					</div>
					<div class="col-sm-6">
						<label class="control-label">Phone (Alternate)</label>
						<input type="text" class="form-control" name="user_phone1" id="user_phone1123" placeholder="Phone Number" onkeypress="javascript:return isNumber(event)" autocomplete="off">
					</div>					
				</div>
				<div class="form-group">					
					<div class="col-sm-6">
					<label class="control-label">Gender</label>
						<select name="user_gender" id="user_gender123" class="form-control">
							<option value="Male">Male</option>
							<option value="Female">Female</option>
							<option value="Others">Others</option>
						</select>
					</div>					
					<div class="col-sm-6">
					<label class="control-label">Email ID <span style="color:red;">*</span></label>
						<input type="email" class="form-control" name="user_email" id="user_email123" placeholder="Email ID" autocomplete="off" readonly required>
					</div>
				</div>
				<div class="form-group">					
					<div class="col-sm-4">
						<label class="control-label">Aadhar No.</label>
						<input type="text" class="form-control" name="aadhar_no" id="aadhar_no123" placeholder="Aadhar No" autocomplete="off">
					</div>
					<div class="col-sm-4">
						<label class="control-label">PAN No.</label>
						<input type="text" class="form-control" name="pan_no" id="pan_no123" placeholder="PAN No" autocomplete="off">
					</div>
					<div class="col-sm-4">
						<label class="control-label">DOB</label>
						<input type="text" class="form-control datepicker1" name="dob" id="dob123" placeholder="DOB" autocomplete="off">
					</div>
				</div>
				<div class="form-group">					
					<div class="col-sm-4">
						<label class="control-label">Nominee Name</label>
						<input type="text" class="form-control" name="nominee_name" id="nominee_name123" placeholder="Nominee Name" autocomplete="off">
					</div>
					<div class="col-sm-4">
						<label class="control-label">Nominee Age </label>
						<input type="text" class="form-control" name="nominee_age" id="nominee_age123" placeholder="Age" autocomplete="off" onkeypress="javascript:return isNumber(event)">
					</div>
					<div class="col-sm-4">
						<label class="control-label">Relation</label>
						<input type="text" class="form-control" name="nominee_relation" id="nominee_relation123" placeholder="Relation" autocomplete="off">
					</div>
				</div>
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label">Father/Husband Name</label>
						<input type="text" class="form-control" name="user_fa_hus" id="user_fa_hus123" placeholder="Father/Husband Name" autocomplete="off">
					</div>
					<div class="col-sm-6">
						<label class="control-label">Occupation</label>
						<input type="text" class="form-control" name="user_fa_occupation" id="user_fa_occupation123" placeholder="Occupation" autocomplete="off">
					</div>					
				</div>				
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label">Bank Name</label>
						<input type="text" class="form-control" name="bank_name" id="bank_name123" placeholder="Bank Name" autocomplete="off">
					</div>
					<div class="col-sm-6">
						<label class="control-label">Account No.</label>
						<input type="text" class="form-control" name="account_no" id="account_no123" placeholder="Account No." autocomplete="off">
					</div>					
				</div>
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label">A/c Holder Name</label>
						<input type="text" class="form-control" name="account_name" id="account_name123" placeholder="A/c Holder Name" autocomplete="off">
					</div>
					<div class="col-sm-6">
						<label class="control-label">IFSC code</label>
						<input type="text" class="form-control" name="ifsc_code" id="ifsc_code123" placeholder="IFSC code" autocomplete="off">
					</div>					
				</div>				
				<div class="form-group">
					<div class="col-sm-4">
						<label class="control-label">Registration Fee</label>
						<div class="input-group col-sm-offset-0 col-sm-12" >
						<div class="input-group-addon">
							<strong>Rs.</strong>
						</div>
						<input type="text" class="form-control" name="registration_fee" id="registration_fee123" placeholder="0.00" onkeypress="javascript:return isNumber(event)">				 
						</div>
					</div>
				  <div class="col-sm-4">
					 <label class="control-label">Area of Operation</label>
					<input type="text" class="form-control" name="user_area" id="user_area123" placeholder="Area1,Area2,Area3.." >
				  </div>
				  <div class="col-sm-4">
					 <label class="control-label">Location/Landmark</label>
					<input type="text" class="form-control" name="user_location" id="user_location123" placeholder="Location/Landmark" >
				  </div>
				</div>
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label">Password <span style="color:red;">*</span></label>
						<input type="text" class="form-control" name="user_password" id="user_password123" placeholder="Password" autocomplete="off" required>
					</div>
									
				</div>
				<input type="hidden" name="id" id="u_id" value=""/>
				  <div class="form-group">					
					<div class="col-sm-6">
					<div class=" col-sm-12">
					<label class="control-label">&nbsp;&nbsp;&nbsp;	</label>
					<label class="control-label">&nbsp;&nbsp;&nbsp;	</label> </div>
					  <button type="submit" class="btn btn-success" name="submit" id="new_submit">Update</button>
				 
					</div>				
				</div>                       
			</form>
			</div>
			</div>                    
		</div>
	</div>       
    
    </section>
    <div class="clearfix"></div>
  </div>
  <footer class="main-footer">
    <?php include "common/footer.php";?>
  </footer>
</div>
<script>
  $.widget.bridge('uibutton', $.ui.button);
</script>
<script src="assets/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="assets/bower_components/raphael/raphael.min.js"></script>
<script src="assets/bower_components/morris.js/morris.min.js"></script>
<script src="assets/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
<script src="assets/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="assets/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<script src="assets/bower_components/jquery-knob/dist/jquery.knob.min.js"></script>
<script src="assets/bower_components/moment/min/moment.min.js"></script>

<script src="assets/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script src="assets/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<script src="assets/bower_components/fastclick/lib/fastclick.js"></script>
<script src="assets/dist/js/adminlte.min.js"></script>
<script src="assets/dist/js/pages/dashboard.js"></script>
<script src="assets/dist/js/demo.js"></script>
</body>
</html>
<script>
function getresult(e){		
		$.ajax({
		url: "ajax/user_view.php",
		type: "GET",
		data:  {page:e},
		
		success: function(data){
			var res=data.split("$",2);
			$("#response-table").html(res[0]);
			$("#pagi").html(res[1]);			
			},
			error: function() 
			{} 	        
		});
	}
function get_userData(id){
	$.ajax({
		type: "POST",
		url: "ajax/user_view.php",
		data: { id: id, get_userData: "User"} ,
		success: function(data){			
				
			var res=data.split("###",29);				
			document.getElementById('u_id').value=res[0];
			document.getElementById('user_id123').innerHTML=res[1];
			document.getElementById('user_type123').innerHTML=res[2];
			document.getElementById('company_id123').value=res[3];
			document.getElementById('doj123').value=res[4];
			document.getElementById('user_name123').value=res[5];
			document.getElementById('user_address123').value=res[6];
			document.getElementById('state_name123').value=res[7];
			document.getElementById('user_pin123').value=res[8];
			document.getElementById('user_phone123').value=res[9];
			document.getElementById('user_phone1123').value=res[10];
			document.getElementById('user_gender123').value=res[11];
			document.getElementById('user_email123').value=res[12];
			document.getElementById('aadhar_no123').value=res[13];
			document.getElementById('pan_no123').value=res[14];
			document.getElementById('dob123').value=res[15];
			document.getElementById('nominee_name123').value=res[16];
			document.getElementById('nominee_age123').value=res[17];
			document.getElementById('nominee_relation123').value=res[18];
			document.getElementById('user_fa_hus123').value=res[19];
			document.getElementById('user_fa_occupation123').value=res[20];
			document.getElementById('bank_name123').value=res[21];
			document.getElementById('account_no123').value=res[22];
			document.getElementById('account_name123').value=res[23];
			document.getElementById('ifsc_code123').value=res[24];
			document.getElementById('registration_fee123').value=res[25];
			document.getElementById('user_area123').value=res[26];
			document.getElementById('user_location123').value=res[27];
			document.getElementById('user_password123').value=res[28];
			
		}		
	});
}

 $("#item-search").on('click', function (e){
    e.preventDefault();
    var item = $("#name").val();	
    console.log(item);	
        $.ajax({
            type:'POST',
            url:'ajax/user_view.php',
            data:'q='+item
        }).done(function (data){
            $("#response-table").html(data);			
        });
    
});


$("#item-search123").on('click', function (e){
    e.preventDefault();
    var item = $("#name123").val();		
    console.log(item);	
        $.ajax({
            type:'POST',
            url:'ajax/user_view.php',
            data:'q123='+item
        }).done(function (data){
            var res=data.split("$",2);
		$("#response-table").html(res[0]);
		$("#pagi").html(res[1]);			
        });
    
});


$("#date-search").on('click', function (e){	
    e.preventDefault();
    var from = $("#from").val();	
    var to = $("#to").val();
	var e = $("#page_row").val();
	if($("#from").val() !='' && $("#to").val()!=''){	
        $.ajax({
            type:'POST',
            url:'ajax/user_view.php',
            data:'from='+from+'&to='+to+'&page='+e
        }).done(function (data){
          var res=data.split("$",2);
		$("#response-table").html(res[0]);
		$("#pagi").html(res[1]);			
        });
    }else{
            alert("Choose start date & end date.");
        }
});
	
 
</script>