<!DOCTYPE html>
<html lang="en">
  <?php include "head.php";
  header("Cache-Control: no-cache, must-revalidate");
  include "dbconfig.php";
  ?>
 <?php

$company_id=$_GET['company_id'];

$query ="SELECT * from employees where id=".$company_id;
$res=$con->query($query);

$driver_data= mysqli_fetch_assoc($res);

$query1 ="SELECT * from debtors where source_id=".$company_id;
$res1=$con->query($query1);

$driver_data1= mysqli_fetch_assoc($res1);
  ?> 
   <body>

  <div class="container-fluid">
  <div class="col-md-3"></div>
    <div class="panel col-md-6" style="background-color: #e9e9e9;box-shadow: 5px 5px 5px;">
                    
                     <div class="panel-body">
                    
                  
                     <form method="post" id="new_company_form" action="" enctype="multipart/form-data">
                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                           <h2>Customer Details</h2>
                           <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
                             <div class="form-group">
                                 <label for="first_name">Customer Name</label>
                        <input type="text" id="name" name="name" required value="<?php echo $driver_data['first_name'];?>"  placeholder="Driver Name" class="form-control radius" />
                              <input type="hidden" name="id" name="id" value="<?php echo $driver_data['id'];?>"/>
                              </div>
                              <div class="form-group">
                                 <label for="phone">Phone</label>
                                 <input type="text" id="phone" name="phone" required value="<?php echo $driver_data['phone'];?>"  placeholder="Phone" class="form-control radius" />
                              </div>
                              <div class="form-group">
                                 <label for="email">Email Address</label>
                                 <input type="text" id="email" name="email" required value="<?php echo $driver_data['email'];?>"  placeholder="Email Address" class="form-control radius" />
                              </div>
                           </div>
                           <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
                              <div class="form-group">
                                 <label for="address">Address</label>
                                 <input type="text" id="address1" name="address1" required value="<?php echo $driver_data['address'];?>"  placeholder="Address" class="form-control radius" />
                              </div>
                              <div class="form-group">
                                 <label for="post_code">Post Code</label>
                                 <input type="text" id="post_code" name="post_code" required value="<?php echo $driver_data['post_code'];?>"  placeholder="Post Code" class="form-control radius" />
                              </div>
							   <div class="form-group">
                                 <label for="post_code">Opening Balance</label>
                                 <input type="number" id="balance" name="balance" placeholder="0" value="<?php echo $driver_data1['balance'];?>"  class="form-control radius" />
                              </div>
<div id="loader"><img src="images/image_loader.gif"/></div>
							                 
               <div class="form-group pull-right">
                  <input type="submit" class="btn btn-primary" value="Update Details" />
               </div> 
                           </div>

                        </div>
                       
               </form>
           
     
    </div>
</div>
<script type="text/javascript">
$(document).ready(function () {
	$('#loader').hide();
});


// function to post data
$(document).ready(function (e) {
	 
	
	$("#new_company_form").on('submit',(function(e) {
		//$('#new_company_form').validate();
		e.preventDefault();
		$('#loader').show();
		
		var url11 = 'ajax/update_supplier.php?'+new Date().getTime();
		$.ajax({
			
        	url: url11,
			type: "POST",
			data:  new FormData(this),
			contentType: false,
    	    cache: false,
			processData:false,
			success: function(data)
		    { 
			//alert(data);
			if(data=='success'){
		alert("Customer Details Successfully Updated");
		$('#loader').delay(500).fadeOut("slow");
		var url1 = 'list_suppliers.php?'+new Date().getTime();
		window.location.replace(url1);
			}else{
				alert("Customer Was not Added");
				$('#loader').delay(500).fadeOut("slow");
				}
					
				
			//$("#gallery").html(data);
			
				
				
		    },
		  	error: function() 
	    	{
	    	} 	        
	   });
	}));
});
function addcar() {
      var form=$('#new_car_form');
      var url1 = 'ajax/create_car.php?'+new Date().getTime();
                $.ajax({
                    type: "POST",
                    url: url1,
              data: form.serialize(),
                    success: function(data) {
						
                     alert("Car Added");
		   			
                }
            });
}
$('#mot_date').datepicker({
	
    	onSelect: function() {
			
                $( "#mot_date" ).datepicker( "option", "dateFormat","yy-mm-dd");
		
        }
        });
	$('#insurance_date').datepicker({
	
    	onSelect: function() {
			
                $( "#insurance_date" ).datepicker( "option", "dateFormat","yy-mm-dd");
		
        }
        });	
</script>
   </body>
</html>
