<?php
session_start();
include "connect.php";
$currentpage=8;
$activepage="Credit";

if(!isset($_SESSION['admin_login'])){ header("location:index.php");}
$user = "dochcare";
$q_sql="SELECT balance_request_tbl.*,user_tbl.name,user_tbl.user_unique_id,bank_details.bank_name,bank_details.acc_no FROM `balance_request_tbl` JOIN user_tbl ON user_tbl.id = balance_request_tbl.user_id JOIN bank_details ON bank_details.id = balance_request_tbl.bank_id";
$q_query=mysqli_query($conn,$q_sql." WHERE balance_request_tbl.status = 0 ORDER BY balance_request_tbl.id DESC");

	if (isset($_REQUEST['idd']) && $_REQUEST['active'] == 'true') {
    $query_service = "UPDATE `balance_request_tbl` SET `status`= 1 WHERE id ='".$_REQUEST['idd']."'";
     
        $result_service = mysqli_query($conn,$query_service);
		
		if($result_service){
			$query_sel = "SELECT * FROM `balance_request_tbl` WHERE id ='".$_REQUEST['idd']."'";
			$result_sel = mysqli_query($conn,$query_sel);
			$row_sel = mysqli_fetch_array($result_sel);
			$user_id = $row_sel['user_id'];
			$amt = $row_sel['amt'];
			
			$query_sel1 = "SELECT * FROM `user_wallet` WHERE user_id = '$user_id'";
			$result_sel1 = mysqli_query($conn,$query_sel1);
			$num = mysqli_num_rows($result_sel1);
			if($num == 0){
			$query_sel2 = "INSERT INTO `user_wallet`(`id`, `user_id`, `amt`) VALUES (NULL,'$user_id','$amt')";
			$result_sel2 = mysqli_query($conn,$query_sel2);
			}else{
			$query_sel2 = "UPDATE `user_wallet` SET `amt` = amt  + $amt WHERE user_id = '$user_id'";
			$result_sel2 = mysqli_query($conn,$query_sel2);
			}
			echo "<script>alert('Credit request approved successfully. ');   window.location = 'credit_request.php'; </script>";
			// header("location:view_branch.php");
		}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>:: ACMEKEY | Company Info ::</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="js/jquery.com_ui.css">
<script src="js/jquery-1.10.2.js"></script>
<script src="js/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="js/jquery.com_ui.css">
<script src="js/jquery-1.10.2.js"></script>
<script src="js/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<style>

/*.frmSearch {border: 1px solid #a8d4b1;background-color: #c6f7d0;margin: 2px 0px;padding:40px;border-radius:4px;}*/
#country-list{float:left;list-style:none;margin-top:-3px;padding:0;width:90%;position: absolute; z-index:800;}
#country-list li{padding: 10px; background: #008B8B; color:#fff; border-bottom: #bbb9b9 1px solid;}
#country-list li:hover{background:#f39c12;cursor: pointer; color:#000;}
#search-box{padding: 10px;border: #a8d4b1 1px solid;border-radius:4px;}
</style>


<script>
$( function() {
$( ".datepicker1" ).datepicker({ dateFormat: 'dd/mm/yy' });
} );

$( function() {
$( ".datepicker2" ).datepicker({ dateFormat: 'yy-mm-dd' });
} );
</script>
<script>
$(function() {

	$("#dist_name").focus();
	var clients = [
	<?php						
		$q_pps=mysqli_query($conn,"SELECT * FROM district_cnf_tbl ORDER BY dist_name ASC");
		while($r_pps=mysqli_fetch_array($q_pps)){
	?>
	  {        
        label: "<?php echo $r_pps['dist_name'];?>",
        desc: "<?php echo $r_pps['cnf_id'];?>",
        icon: "<?php echo $r_pps['id'];?>"
      },
	<?php	}	?>
	 ];
    $( "#dist_name" ).autocomplete({
      minLength: 0,
      source: clients,
      focus: function( event, ui ) {
        $( "#dist_name" ).val( ui.item.label );
		return false;
      },
      select: function( event, ui ) {			
        $( "#dist_name" ).val( ui.item.label );
		$( "#cnf_id" ).val( ui.item.desc );
		$( "#district_cnf_id" ).val( ui.item.icon );
        return false;
      }
    })
    .autocomplete( "instance" )._renderItem = function( ul, item ) {
		$( "#district_cnf_id" ).val('0');
	 return $( "<li>" )
       // .append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
	    .append( "<a>" + item.label + "<br>" + item.desc + "</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;
}

</style>
<script>
function check_user(str){

	$.ajax({
		type: "POST",
		url: "ajax/user.php",
		data: { exist_user : str} ,
		success: function(data){
				$('#checkUser').html(data);
			if(data!="User not found.")	{
			document.getElementById("new_submit").disabled=false;
		}else{
			document.getElementById("new_submit").disabled=true;
		}
		}		
	});
}

function get_type(str){	
	var uid = str.substr(0,1);
	if(uid=="c"){		
		document.getElementById("user_type_D").checked="checked";
		document.getElementById("text_chnge").innerHTML="CNF ID *";
		document.getElementById("new_submit").disabled=false;
		var res = "FC"+Date.now();
		   $('#user_id').val(res);	   
	}else if(uid=="d"){		
		document.getElementById("user_type_R").checked="checked";
		document.getElementById("text_chnge").innerHTML="Distributor ID *";
		document.getElementById("new_submit").disabled=false;
		var res = "R"+Date.now();
		   $('#user_id').val(res);
	}else if(uid=="c"){		
		document.getElementById("user_type_SD").checked="checked";
		document.getElementById("text_chnge").innerHTML="Company ID *";
		document.getElementById("new_submit").disabled=false;
		var res = "SD"+Date.now();
		   $('#user_id').val(res);
	
	}else{
		
	}	
	
		/*$.ajax({
		type: "POST",
		url: "ajax/user.php",
		data: { exist_user : str} ,
		
		success: function(data){			
				$('#checkUser').html(data);
					
			if(data!="User not found.")	{
			document.getElementById("new_submit").disabled=false;
		}else{
			document.getElementById("new_submit").disabled=true;
		}
		}		
	});*/
	
	
	
}
  $(document).ready(function () {
  $(".user_type").change(function () {

      var str = $('.user_type:checked').val();
     
	  if(str=="CNF"){
		  document.getElementById("text_chnge").innerHTML="Master Company ID *";
		  document.getElementById("company_id").value="C142354520";
		  document.getElementById("u_name").value="ACMEKEY";
		  document.getElementById("u_type").value="COMPANY";
		  document.getElementById("new_submit").disabled=false;
		  document.getElementById("dist_change").style.display="block";
		  document.getElementById("text_chnge1").innerHTML="CNF Company Name *";
		  document.getElementById("text_chnge2").innerHTML="CNF Type *";
		   var res = "SD"+Date.now();
		   $('#user_id').val(res);
	  }else if(str=="FRANCHAISE"){		  
		  document.getElementById("text_chnge").innerHTML="CNF ID *";
		  document.getElementById("company_id").value="";
		  document.getElementById("u_name").value="";
		  document.getElementById("u_type").value="CNF";
		  document.getElementById("new_submit").disabled=false;
		  document.getElementById("dist_change").style.display="none";
		  document.getElementById("text_chnge1").innerHTML="Franchaise Name *";
		  document.getElementById("text_chnge2").innerHTML="Franchaise Type *";
			var res = "FC"+Date.now();
			$('#user_id').val(res);
	  }else if(str=="RETAILER"){
		  document.getElementById("text_chnge").innerHTML="Distributor ID *";
		  document.getElementById("company_id").value="";
		  document.getElementById("u_name").value="";
		  document.getElementById("u_type").value="Distributor";
		  document.getElementById("new_submit").disabled=false;
		  var res = "R"+Date.now();
			$('#user_id').val(res);
	  }else{
		   document.getElementById("new_submit").disabled=true;
	  }
	  
  });
  });
  function isNumber(evt) {
        var iKeyCode = (evt.which) ? evt.which : evt.keyCode
        if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57)){
            return false;
		}
        return true;
    }	

</script>
<script>
$(document).ready(function(){
	$("#company_id").keyup(function(){
		var u_type=$('#u_type').val();	
		var z = $("#company_id").val();
		if(z=="cn"){
			$.ajax({
			type: "POST",
			url: "ajax/get_user1.php",
			data:'keyword='+$(this).val()+'&u_type='+u_type,			
			success: function(data){
				$("#suggesstion-box").show();
				$("#suggesstion-box").html(data);			
				$("#company_id").css("background","#FFF");	
				
			}
			});
	
		}else{
			$.ajax({
			type: "POST",
			url: "ajax/get_user.php",
			data:'keyword='+$(this).val()+'&u_type='+u_type,			
			success: function(data){
				$("#suggesstion-box").show();
				$("#suggesstion-box").html(data);			
				$("#company_id").css("background","#FFF");	
				
			}
			});
		}
	
	
	
	
	});
});

function selectCountry(val,val1) {
$("#company_id").val(val);
$("#u_name").val(val1);
$("#suggesstion-box").hide();
}

/*function check_pan(pan){
	var regExp = /[a-zA-z]{5}\d{4}[a-zA-Z]{1}/;	 
	if (pan.length == 10 ) { 
		if( pan.match(regExp) ){ 
			document.getElementById("pan_match").innerHTML='<span style="color:green; font-size:12px;">PAN number verified.</span>';			
		}else {
			document.getElementById("pan_match").innerHTML='<span style="color:red; font-size:12px;">* Not a valid PAN number.</span>';	     
		} 
 }else{ 
	document.getElementById("pan_match").innerHTML='<span style="color:red; font-size:12px;">* Please enter 10 digits for a valid PAN number.</span>';
            
	} 
}*/
</script>
</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">Company Info<br><span style="font-size: 13px; display: inline-block; padding-left: 4px; font-weight: 600; color: #7a7a7a;">Company Info</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;">Company Info</li>
      </ol>
    </section>       
    <section class="invoice">           
      <div class="row">
	  <!--<div class="col-xs-8">
		<div class="modal-body" style="">
			<div id='msg'></div>                        
			<form class="form-horizontal" role="form" id="addCompany" action="ajax/master.php" method="POST" enctype="multipart/form-data" >
				<input type="hidden" name="add_company" value="AddCompany" />
				
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label" id="text_chnge1">Company Name <span style="color:red;">*</span></label>						
						<input type="text" class="form-control" name="company_name" id="company_name" placeholder="Name" autocomplete="off" required>
					</div>
					<div class="col-sm-6">
					<label class="control-label">Estd. Date <span style="color:red;">*</span></label>
						<input type="text" class="form-control datepicker2" name="estd_date" id="estd_date" value="<?php echo date("Y-m-d");?>" autocomplete="off" required>
					</div>
				</div>				
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label" id="text_chnge2">Company Type <span style="color:red;">*</span></label>	
						<select class="form-control" name="company_type" id="company_type">
							<option value="Proprietorship">Proprietorship</option>
							<option value="Partnership">Partnership</option>
							<option value="Private Ltd">Private Limited</option>
							<option value="Limited">Limited</option>
						</select>						
					</div>
					<div class="col-sm-6">
					<label class="control-label">CIN/License No.<span style="color:red;">*</span></label>
						<input type="text" class="form-control" name="license_no" id="license_no" autocomplete="off" required>
					</div>
				</div>
				<div class="form-group">					
					
					<div class="col-sm-6">
					<label class="control-label">Contact Person 1 </label>
						<input type="text" class="form-control" name="contact1_person" id="contact1_person" autocomplete="off">
					</div>
					<div class="col-sm-6">
						<label class="control-label">Phone (Primary) </label>
						<input type="text" class="form-control" name="contact1_phone" id="contact1_phone" placeholder="Phone Number" maxlength="10" min="10" autocomplete="off" onkeypress="javascript:return isNumber(event)">
					</div>
				</div>
				<div class="form-group">					
					
					<div class="col-sm-6">
					<label class="control-label">Contact Person 2 </label>
						<input type="text" class="form-control" name="contact2_person" id="contact2_person" autocomplete="off" />
					</div>
					<div class="col-sm-6">
						<label class="control-label">Phone (Primary) </label>
						<input type="text" class="form-control" name="contact2_phone" id="contact2_phone" placeholder="Phone Number" maxlength="10" min="10" autocomplete="off" onkeypress="javascript:return isNumber(event)" />
					</div>
				</div>
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label">Phone (Alternate)</label>
						<input type="text" class="form-control" name="alternate_phone" id="alternate_phone" placeholder="Phone Number" maxlength="10" min="10" onkeypress="javascript:return isNumber(event)" autocomplete="off">
					</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="company_email" id="company_email" placeholder="Email ID" autocomplete="off" required />
					</div>
				</div>
				<div class="form-group" id="dist_change" style="display:block;">
					<div class="col-sm-6">
						<label class="control-label">State </label>
						<select class="form-control" name="stateID" id="stateID" onChange="lfn_ShowDistrict(this.value);">
							<option>---Select State---</option>
							<?php
								$q_state=mysqli_query($conn,"SELECT * FROM state_tbl");
								while($r_state=mysqli_fetch_array($q_state)){
							?>
								`<option value="<?php echo $r_state['stateID'];?>"><?php echo $r_state['stateName'];?></option>
								<?php } ?>
						</select>
					</div>
					<div class="col-sm-6">
						<label class="control-label">District </label>						
						<select class="form-control" name="districtID" id="districtID" >
							<option>---Select State---</option>
							<?php
								$q_district=mysqli_query($conn,"SELECT * FROM district_tbl");
								while($r_district=mysqli_fetch_array($q_district)){
							?>
								`<option value="<?php echo $r_district['districtID'];?>"><?php echo $r_district['districtName'];?></option>
								<?php } ?>
						</select>
					</div>
					
				</div>
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label">Address</label>
						<input type="text" class="form-control" name="company_address" id="company_address" placeholder="Address" autocomplete="off">
						
					</div>
					
					<div class="col-sm-6">
					<label class="control-label">Pin Code</label>
						<input type="text" class="form-control" name="company_pin" id="company_pin" placeholder="Pincode" maxlength="6" min="6"  onkeypress="javascript:return isNumber(event)" autocomplete="off">
					</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_no" placeholder="Aadhar No" maxlength="12" min="12"  onkeypress="javascript:return isNumber(event)" 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_no"  style="text-transform:uppercase;" autocomplete="off">
						<p id="pan_match"></p>
					</div>
					<div class="col-sm-4">
						<label class="control-label">GST No. <span style="color:red;">*</span></label>						
						<input type="text" class="form-control" name="company_gst" id="company_gst" autocomplete="off" required>
					</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_name" 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_no" 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_name" 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_code" placeholder="IFSC code" autocomplete="off">
					</div>					
				</div>				
				
				
				
				  	
			  <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">Submit</button>
				 
					</div>				
				</div>
				
					
			</form>
		</div>
                    
	  </div>-->
        
		
		
		
		<div class="col-xs-12 table-responsive">
		<div id="result" style="margin:15px 0;"></div>
		
          <table class="table table-bordered table-sm">
            <thead style="font-family:sans; background:#008080; color:#fff;">
			 <tr>
                                                <th>#</th>
                                                <th>Member Name</th>
                                                <th>Member Id</th>
                                                <th>Amount</th>
                                                <th>Bank name</th>
                                                <th>Account</th>
                                                <th>Tnx No</th>
                                                <th>Action</th>
                                                <th>Action</th>
                                            </tr>
                                        </thead>
             <tbody>
									<?php $co1 = 1; 
									 //$sno = 1; 
									
									//$flag = 1; ?>
            <?php 
				while($row=mysqli_fetch_array($q_query)){
				
				?>
				
				  <tr>			       
			  <td><?php echo $co1 ?></td>
              <td><?php echo $row['name'];?></td>
			  <td><?php echo $row['user_unique_id'];?></td>
			  <td><?php echo $row['amt'];?></td>
			  <td><?php echo $row['bank_name'];?></td>
			  <td><?php echo $row['acc_no'];?></td>
			  <td><?php echo $row['txn_number'];?></td>
			  <td class="text-left"><a class="btn btn-success"  href="credit_request.php?active=true&idd=<?php echo $row['id']; ?>" >Approve</a></td>
			  <td class="text-left"><a class="btn btn-danger" db_id ='<?php echo $co1; ?>' href="#modal-container-666931" role="button" onclick="get_CompData('<?php echo $co1; ?>');" data-toggle="modal" >Rejection</a>
			  </td>
			   
            </tr>
			
			
				<?php 
				$co1 = $co1 + 1;
				   } // end while 
			?>
           
                                 </tbody>
          </table>			  
        </div>        
      </div>  
    </section>
    <div class="clearfix"></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 Company : <span id="edit123"style="font-weight:bold;"></span>(<span id="company_id123" 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="editComp" action="ajax/master.php" method="POST" enctype="multipart/form-data" >
					<input type="hidden" name="edit_company" value="EditCompany" />			
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label" id="text_chnge1">Company Name <span style="color:red;">*</span></label>						
						<input type="text" class="form-control" name="company_name" id="company_name123" placeholder="Name" autocomplete="off" required>
					</div>
					<div class="col-sm-6">
					<label class="control-label">Estd. Date <span style="color:red;">*</span></label>
						<input type="text" class="form-control datepicker2" name="estd_date" id="estd_date123" value="<?php echo date("Y-m-d");?>" autocomplete="off" required>
					</div>
				</div>				
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label" id="text_chnge2">Company Type <span style="color:red;">*</span></label>	
						<select class="form-control" name="company_type" id="company_type123">
							<option value="Proprietorship">Proprietorship</option>
							<option value="Partnership">Partnership</option>
							<option value="Private Ltd">Private Limited</option>
							<option value="Limited">Limited</option>
						</select>						
					</div>
					<div class="col-sm-6">
					<label class="control-label">CIN/License No.<span style="color:red;">*</span></label>
						<input type="text" class="form-control" name="license_no" id="license_no123" autocomplete="off" required>
					</div>
				</div>
				<div class="form-group">					
					
					<div class="col-sm-6">
					<label class="control-label">Contact Person 1 </label>
						<input type="text" class="form-control" name="contact1_person" id="contact1_person123" autocomplete="off">
					</div>
					<div class="col-sm-6">
						<label class="control-label">Phone (Primary) </label>
						<input type="text" class="form-control" name="contact1_phone" id="contact1_phone123" placeholder="Phone Number" maxlength="10" min="10" autocomplete="off" onkeypress="javascript:return isNumber(event)">
					</div>
				</div>
				<div class="form-group">					
					
					<div class="col-sm-6">
					<label class="control-label">Contact Person 2 </label>
						<input type="text" class="form-control" name="contact2_person" id="contact2_person123" autocomplete="off" />
					</div>
					<div class="col-sm-6">
						<label class="control-label">Phone (Primary) </label>
						<input type="text" class="form-control" name="contact2_phone" id="contact2_phone123" placeholder="Phone Number" maxlength="10" min="10" autocomplete="off" onkeypress="javascript:return isNumber(event)" />
					</div>
				</div>
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label">Phone (Alternate)</label>
						<input type="text" class="form-control" name="alternate_phone" id="alternate_phone123" placeholder="Phone Number" maxlength="10" min="10" onkeypress="javascript:return isNumber(event)" autocomplete="off">
					</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="company_email" id="company_email123" placeholder="Email ID" autocomplete="off" required />
					</div>
				</div>
				<div class="form-group" id="dist_change" style="display:block;">
					<div class="col-sm-6">
						<label class="control-label">State </label>
						<select class="form-control" name="stateID" id="stateID123" onChange="lfn_ShowDistrict(this.value);">
							<option>---Select State---</option>
							<?php
								$q_state=mysqli_query($conn,"SELECT * FROM state_tbl");
								while($r_state=mysqli_fetch_array($q_state)){
							?>
								`<option value="<?php echo $r_state['stateID'];?>"><?php echo $r_state['stateName'];?></option>
								<?php } ?>
						</select>
					</div>
					<div class="col-sm-6">
						<label class="control-label">District </label>						
						<select class="form-control" name="districtID" id="districtID123" >
							<option>---Select State---</option>
							<?php
								$q_district=mysqli_query($conn,"SELECT * FROM district_tbl");
								while($r_district=mysqli_fetch_array($q_district)){
							?>
								`<option value="<?php echo $r_district['districtID'];?>"><?php echo $r_district['districtName'];?></option>
								<?php } ?>
						</select>
					</div>
					
				</div>
				<div class="form-group">					
					<div class="col-sm-6">
						<label class="control-label">Address</label>
						<input type="text" class="form-control" name="company_address" id="company_address123" placeholder="Address" autocomplete="off">
						<!--<textarea class="form-control" name="user_address" id="user_address" placeholder="Address" required></textarea>-->
					</div>
					
					<div class="col-sm-6">
					<label class="control-label">Pin Code</label>
						<input type="text" class="form-control" name="company_pin" id="company_pin123" placeholder="Pincode" maxlength="6" min="6"  onkeypress="javascript:return isNumber(event)" autocomplete="off">
					</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" maxlength="12" min="12"  onkeypress="javascript:return isNumber(event)" 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"  style="text-transform:uppercase;" autocomplete="off">
						<p id="pan_match"></p>
					</div>
					<div class="col-sm-4">
						<label class="control-label">GST No. <span style="color:red;">*</span></label>						
						<input type="text" class="form-control" name="company_gst" id="company_gst123" autocomplete="off" required>
					</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>
				<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="submit">Update</button>
				 
					</div>
				  
				</div>                          
			</form>
			</div>
			</div>                    
		</div>
	</div>       
       
  <footer class="main-footer">
    <?php include "common/footer.php";?>
  </footer>
</body>
</html>     
 <script>  	
	$(document).ready(function (e){
		$("#addCompany").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){	
						$('#msg').html(data);	                  
						$('#addCompany')[0].reset();
						setTimeout('window.location.reload();',1000);
						},
					error: function(){} 	        
				});
			
			
			}));
		});
</script>
<script>
$("#modal-container-666931").on('hidden.bs.modal', function(e){window.location.reload();});
</script>
<script>
function get_CompData(id){
	
	$.ajax({
		type: "POST",
		url: "ajax/master.php",
		data: { id: id, get_CompData: "GetCompanyData"} ,
		success: function(data){
			//alert(data);
			var res=data.split("#");				
			document.getElementById('u_id').value=res[0];
			document.getElementById('edit123').innerHTML=res[2];
			document.getElementById('company_id123').innerHTML=res[1];
			document.getElementById('company_name123').value=res[2];
			document.getElementById('estd_date123').value=res[3];
			document.getElementById('company_type123').value=res[4];
			document.getElementById('license_no123').value=res[5];
			document.getElementById('contact1_person123').value=res[6];
			document.getElementById('contact1_phone123').value=res[7];
			document.getElementById('contact2_person123').value=res[8];
			document.getElementById('contact2_phone123').value=res[9];
			document.getElementById('alternate_phone123').value=res[10];
			document.getElementById('company_email123').value=res[11];
			document.getElementById('stateID123').value=res[12];
			document.getElementById('districtID123').value=res[13];
			document.getElementById('company_address123').value=res[14];
			document.getElementById('company_pin123').value=res[15];
			document.getElementById('aadhar_no123').value=res[16];
			document.getElementById('pan_no123').value=res[17];
			document.getElementById('company_gst123').value=res[18];
			document.getElementById('bank_name123').value=res[19];
			document.getElementById('account_no123').value=res[20];
			document.getElementById('account_name123').value=res[21];
			document.getElementById('ifsc_code123').value=res[22];
			
			
		}		
	});
}
function delete_company(id){
	var url = "ajax/master.php";	
	var msg = confirm("Are you sure?");	
	if (msg == true) { 
		$.ajax({
			url: url,
			type:"POST",
			data:'id='+id+'&delete_company=DeleteCompany'
			}).done(function(data){					
			$("#msg").html(data);
			setTimeout('document.location.href="add_company.php"',1000);			
			
		});
	}else{
	 return false;
	}
}
 $("#item-search").on('click', function (e){
    e.preventDefault();
    var item = $("#item").val();	
    console.log(item);	
        $.ajax({
            type:'POST',
            url:'ajax/client.php',
            data:'q='+item
        }).done(function (data){
            $("#response-table").html(data);			
        });
    
});


	$(function(){
        $( "#editComp" ).submit(function( event ) {
           event.preventDefault();
            var url = $(this).attr('action');
            console.log(url);            
            $.ajax({
                url: url,
                data: $("#editComp").serialize(),
                type: $(this).attr('method')
              }).done(function(data) {
                   $("#ajax_edit").html(data);
				   setTimeout('window.location.href="add_company.php"',4000);             
              });
            
        });
    });
</script>
<script>
  $.widget.bridge('uibutton', $.ui.button);
</script>

<script>
function lfn_ShowDistrict(p_stateID)
{
	var url = "ajax/master.php";	
	$.ajax({
		url: url,
		type:"POST",
		data:'id='+p_stateID+'&get_district=GetDistrict'
		}).done(function(data){
		$("#districtID").html(data);
	});
	
}

function lfn_ShowDistrictEdit(p_stateID)
{
	var url = "ajax/master.php";	
	$.ajax({
		url: url,
		type:"POST",
		data:'id='+p_stateID+'&get_district=GetDistrict'
		}).done(function(data){
		$("#districtID1234").html(data);
	});
	
}

</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>
