<!DOCTYPE html>
<html lang="en">
  <?php include "head.php";
  
  include "dbconfig.php";
  ?>


   <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>New Customer Regsitration Form</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 placeholder="Company Name" class="form-control radius" />
                              </div>
                              <div class="form-group">
                                 <label for="phone">Phone</label>
                                 <input type="text" id="phone" name="phone" required 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 placeholder="Email Address" class="form-control radius" />
                              </div>
							  <!--div class="form-group">
                                 <label for="client_reference">Client Reference</label>
                                 <input type="text" id="client_reference" name="client_reference" placeholder="Client Reference" 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 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 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" class="form-control radius" />
                              </div>
<div id="loader"><img src="images/image_loader.gif"/></div>
							                 
               <div class="form-group pull-right">
			   <br>
                  <input type="submit" class="btn btn-primary" value="Save" />
               </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();
		
		$.ajax({
			
        	url: "ajax/create_customers.php",
			type: "POST",
			data:  new FormData(this),
			contentType: false,
    	    cache: false,
			processData:false,
			success: function(data)
		    { 
			//alert(data);
			if(data=='success'){
		alert("Customer Added");
		$('#loader').delay(500).fadeOut("slow");
		window.location.replace("list_companies.php");
			}else{
				alert("Customer Was not Added");
				$('#loader').delay(500).fadeOut("slow");
				}
					
				
			//$("#gallery").html(data);
			
				
				
		    },
		  	error: function() 
	    	{
	    	} 	        
	   });
	}));
});
function addcar() {
      var form=$('#new_car_form');
      
                $.ajax({
                    type: "POST",
                    url: "ajax/create_car.php",
              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>
