 <?php 
 if($_POST)
 {
	
	$branch_name 			=		set_value('branch_name',$_POST['branch_name']);
	$branch_pol			    =		set_value('branch_pol',$_POST['branch_pol']);
	$branch_shrt_code		=		set_value('branch_shrt_code',$_POST['branch_shrt_code']);
	$branch_bill_no		    =		set_value('branch_bill_no',$_POST['branch_bill_no']);
	
	
}
else
{
	
	$branch_name			=		$edit_branch->branch_name;
	$branch_pol			    =		$edit_branch->branch_pol;
	$branch_shrt_code		=		$edit_branch->branch_shrt_code;
	$branch_bill_no		=		$edit_branch->branch_bill_no;
}
 ?>
 <div class="box-body"><?php echo validation_errors();?>
 	<div style="color:red;" class="error"><strong><?php if($this->session->flashdata('error')){ echo $this->session->flashdata('error');} ?></strong></div>
    <form role="form" id="edit_branch" name="edit_branch" action="<?php echo base_url();?>General_masters/edit_branch/<?php echo $branch_id;?>" method="post">
    	<input type="hidden" id="branch_id" name="branch_id" value="<?php echo $branch_id;?>">
    	<div class="col-md-4">
            
	        <div class="form-group">
	            <label>Branch Name</label><?php echo form_error('branch_name');?>
	            <input type="text" class="form-control" placeholder="Enter Branch Name..." id="branch_name" name="branch_name" value="<?php echo $branch_name;?>">
	        </div>
	        <div class="form-group">
	            <label>Place Of Loading</label><?php echo form_error('branch_pol');?>
	            <input type="text" class="form-control" placeholder="Enter Place Of Loading..." id="branch_pol" name="branch_pol" value="<?php echo $branch_pol;?>">
	        </div>
	    </div>
    	<div class="col-md-4">
	        <div class="form-group">
	            <label>Short Code</label><?php echo form_error('branch_shrt_code');?>
	            <input type="text" class="form-control" placeholder="Enter Short Code..." id="branch_shrt_code" name="branch_shrt_code" value="<?php echo $branch_shrt_code;?>">
	        </div>

	        <div class="form-group">
	            <label>Bill Increment No</label><?php echo form_error('branch_bill_no');?>
	            <input type="text" class="form-control" placeholder="Enter Bill Increment No..." id="branch_bill_no" name="branch_bill_no" value="<?php echo $branch_bill_no;?>">
	        </div>
	       
            <div class="form-group">
            <div class="col-md-6"></div>
            	<div class="col-md-6"><input type="submit" id="submit" name="submit" class="btn btn-info" value="Save">
            	<a href="<?php echo base_url()?>General_masters/branch"><button type="button" class="btn btn-warning">Cancel</button></a></div>
            </div>
	    </div>
    	<div class="col-md-4 form-group has-warning">
    		<h4><label>Recently Listed Branch</label></h4>
    		<div class="box box-warning">
			    <table class="table table-bordered table-hover">
			        <thead>
			            <tr>
			                <th>Name</th>
			                <th>Place Of Loading</th>
			                <th>Short Code</th>
			            </tr>
			        </thead>
			        <tbody>
	        			<?php if(count($recent_list)!=0)
	        			{
	        				foreach($recent_list as $row)
	        				{?>
		    					<tr>
		    						<td><a href="<?php echo base_url();?>General_masters/edit_branch/<?php echo $row['branch_id'];?>"><strong><?php echo $row['branch_name'];?></strong></a></td>
		    						<td><?php echo $row['branch_pol'];?></td>
		    						<td><?php echo $row['branch_shrt_code'];?></td>
		    					</tr>
	        				<?php }
	        			}
	        			else
	        			{?>
	        				<tr><td colspan="3">Data Not Found</td></tr>
	        			<?php }?>
			        </tbody>
			    </table>
			    <a class="text-red" href="<?php echo base_url();?>General_masters/branch"><strong>View All Branch Lists</strong></a>
		    </div>
	    </div>
	</form>
    <!-- /.box-body -->
</div>

<script type="text/javascript">
	$(function()
	{
		setTimeout(company_select);
	});
	function company_select()
	{
		$("#branch_cmp_id").select2({
			ajax: { 
				dataType: 'json', 
				url: '<?php echo base_url();?>General_masters/get_company',
				cache: true,
				data: function (params) 
					{
						return {
							q: params.term
						}
					}
			}
		});
	}
</script>