<form role="form" class="form-horizontal" id="create_driver_form" action="#" method="post">
<input type="hidden" value="<?php echo $type;?>" name="type" id="type"/>
<input type="hidden" value="<?php echo $driver_id;?>" name="driver_id" id="driver_id"/>
<div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title"><?php echo $pageName;?></h4>
            <font style="color:#333;">Please fill in the information below. The field labels marked with * are required input fields.</font>
            </div>
    <div class="col-md-12">
        
    </div>              
            <div class="modal-body">
            <div id="error"></div>
                <div class="row">
                <div class="col-md-12">
                    <div class="col-md-12">
                    <!--<h5>Parent Category *</h5>
                    <p>
                        <div class="form-group">
                            <select id="form-field-select-3" class="form-control search-select">
                                <option value="">&nbsp;</option>
                                <option value="AL">Alabama</option>
                                <option value="AK">Alaska</option>
                                <option value="AZ">Arizona</option>
                             </select>
                        </div>
                    </p>-->
                    <div class="form-group">
                        <h5>
                        <label class="control-label">
							 Code*
						</label></h5>
                            <input type="text" <?php echo (isset($drivers_details['driver_code']))?'value="'.$drivers_details['driver_code'].'"':null;?> class="form-control" name="driver_code" id="driver_code" <?php if (isset($type)) if($type=='E') echo 'readonly';?>>
                    </div>
                    <div class="form-group">
                        <h5>
                        <label class="control-label">
							 Driver Name*
						</label></h5>
                            <input type="text" <?php echo (isset($drivers_details['driver_name']))?'value="'.$drivers_details['driver_name'].'"':null;?> class="form-control" name="driver_name" id="driver_name">
                    </div><div class="form-group">
                        <h5>
                        <label class="control-label">
							 Driver Phone*
						</label></h5>
                            <input type="text" <?php echo (isset($drivers_details['driver_phone']))?'value="'.$drivers_details['driver_phone'].'"':null;?> class="form-control" name="driver_phone" id="driver_phone">
                    </div>
                    <div class="form-group">
                        <h5>
                        <label class="control-label">
							 Extra details*
						</label></h5>
                            <input type="text" <?php echo (isset($drivers_details['driver_description']))?'value="'.$drivers_details['driver_description'].'"':null;?> class="form-control" name="drivers_details" id="drivers_details">
                    </div>
                     <div class="form-group">
                    <label class="control-label">
							 Warehouse*
						</label></h5>
                            <select type="text" value="" class="form-control" name="warehouse_id" id="warehouse_id" >
                           
                          <?php																 
foreach ($warehouse_list as $row)
{?>  
                                                                        
<option value="<?php echo $row->id; ?>" 

<?php // if(isset($driver_id)&&$row->id==$suppliyer['warehouse_id'])echo 'selected="selected"'?>
>

<?php echo $row->name; ?> </option>

<?php }?>
                            
                            
                            
                             </select>
                            </div>
                    
                                                 -   
                    </div>
                </div>
            </div>
            <div class="modal-footer">
            <input type="submit" name="add_category" value="<?php echo $btnText; ?>" class="btn btn-primary">
            </div>
            </div> <!--/.col-md-12-->
</form>

<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY VALIDATION-->
<script src="<?php echo asset_url(); ?>js/form-validation-create_driver.js"></script>
<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY  VALIDATION-->

<script>
   jQuery(document).ready(function() {
        FormValidator.init();
   });
</script>
    
<script type="text/javascript">
function insertDriverData(){
	
var type=$('#type').val();
var driver_name=$('#driver_name').val();
var driver_code=$('#driver_code').val();
var driver_phone=$('#driver_phone').val();
var drivers_details=$('#drivers_details').val();
var driver_id=$('#driver_id').val();
var warehouse_id=$('#warehouse_id').val();
					 
	$.post( "<?php echo base_url('drivers/save_driver'); ?>", {driver_phone:driver_phone,drivers_details:drivers_details,type:type, driver_id:driver_id, driver_name:driver_name, driver_code:driver_code, warehouse_id:warehouse_id })
	.done(function( data ) {
		
	  var obj = jQuery.parseJSON(data);
	   // alert(obj.type); //last id
	   
	   if (obj.status==0) 
	{
		$('div#error').html('<div class="alert alert-block alert-danger fade in"><button type="button" class="close" data-dismiss="alert">×</button><h4 class="alert-heading"><i class="fa fa-times-circle"></i> Error!</h4>'+obj.validation+'</div>');
		$('body').modalmanager('removeLoading');
		$('body').attr('class','');
	}
	 else {
			  /**/
	  if($('#driver_id')){
		  var data = {
	
		id: obj.id,
	
		text: $('#driver_name').val()
	
		};
	
		var newOption = new Option(data.text, data.id, false, true);
	
		$('#driver_id').append(newOption).trigger('change');
	
		$('#customer_id').focus();
	  }
	  else loadGrid();
	  /**/

	  $('div#ajax-modal').modal('hide');
	  // load location data
	  
	  if(obj.type=='E'){
		  
		  displayNotice('page','driver has been updated successfully!')
	  }
	  if(obj.type=='A'){
			displayNotice('page','driver has been added successfully!')    
	  }
	 }
	  });
return false;
}
</script>