<style type="text/css">
body .modal {
	/* new custom width */
	width: 750px;
	/* must be half of the width, minus scrollbar on the left (30px) */
	margin-left: -375px;
}
</style>
<form role="form" class="form-horizontal" id="create_brand_form" action="#" method="post">
  <input type="hidden" value="<?php echo $type;?>" name="type" id="type"/>
  <input type="hidden" value="<?php echo $brand_id;?>" name="brand_id" id="brand_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="modal-body" style="padding: 30px">
    <div id="error"></div>
    
    <div class="form-group" <?php if(!isset($brand['brand_code'])) echo "style=\"display:none\"" ?>>
      <h5>Code *</h5>
      <input type="text" class="form-control" name="brand_code" id="brand_code" <?php echo (isset($brand['brand_code']))?'value="'.$brand['brand_code'].'"':null;?> <?php if (isset($type)) if($type=='E') echo 'readonly';?>>
    </div>
    <div class="form-group">
      <h5>Name *</h5>
      <input type="text" class="form-control" name="brand_name" id="brand_name" <?php echo (isset($brand['brand_name']))?'value="'.$brand['brand_name'].'"':null;?>>
    </div>
    
  </div>
  <div class="modal-footer">
    <input type="submit" name="add_category" value="<?php echo $btnText; ?>" class="btn btn-primary">
  </div>
</form>
<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY VALIDATION --> 
<script src="<?php echo asset_url(); ?>js/form-validation-create_brand.js"></script> 
<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY  VALIDATION--> 

<script>
			jQuery(document).ready(function() {
				FormValidator.init();
				//$(".search-select").select2();
				$('#route_id').select2();
				$('#country_id').select2();
			});
		</script> 
<script type="text/javascript">
function insertCustomerData(){
var type=$('#type').val();
var brand_id=$('#brand_id').val();
var brand_name=$('#brand_name').val();
var brand_code=$('#brand_code').val();
				 
	$.post( "<?php echo base_url('brands/save_brand'); ?>", {type:type, brand_id:brand_id, brand_name:brand_name, brand_code:brand_code })
	  .done(function( data ) {
		
	  var obj = jQuery.parseJSON(data);
	 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 {
	  // alert(obj.type); //last id
	  
	  /**/
	  if($('#brand_id')){
		  var data = {
	
		id: obj.id,
	
		text: $('#brand_name').val()+' / '+$('#brand_phone').val()
	
		};
	
		var newOption = new Option(data.text, data.id, false, true);
	
		$('#brand_id').append(newOption).trigger('change');
	
		$('#add_item').focus();
	  }
	  else loadGrid();
	  /**/
	  
	  $('div#ajax-modal').modal('hide');
	  // load brand data
		
	}
	  
loadGrid();
	  });
return false;
}
    </script>