 <?php 
 if($_POST)
 {
	$ledger_id 			        =		set_value('ledger_id',$_POST['ledger_id']);
	$ledger_group_name 			=		set_value('ledger_group_name',$_POST['ledger_group_name']);
	 
}
else
{
	$ledger_id 			        =		$edit_ledgergroup->ledger_id;
	$ledger_group_name			=		$edit_ledgergroup->ledger_group_name;
	 
}
 ?>
 <div class="box-body">
 	<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_ledgergroup" name="edit_ledgergroup" action="<?php echo base_url();?>General_masters/edit_ledgergroup/<?php echo $ledger_id;?>" method="post">
    	<input type="hidden" id="ledger_id" name="ledger_id" value="<?php echo $ledger_id;?>">

    	<div class="col-md-4">
            <div class="form-group">
                <label>Parent Ledger Group Name</label><?php echo form_error('parent_id');?>  
                <select class="form-control select2" id="parent_id" name="parent_id">
                	<option value="">Select Parent Ledger Group Name</option>
                  	<?php foreach($ledger_drpdwn as $row)
                  	{
					
					
					?>
				  	<option value="<?php echo $row['ledger_id'];?>"  <?php if($parent_id==$row['ledger_id'])echo "selected";?> ><?php echo $row['ledger_group_name'];?></option>
                  	<?php }?>                	
                </select>             
            </div>
	        <div class="form-group">
	            <label>Parent Ledger Group Name</label><?php echo form_error('ledger_group_name');?>
	            <input type="text" class="form-control" placeholder="Enter Ledger Group Name..." id="ledger_group_name" name="ledger_group_name" value="<?php echo $ledger_group_name;?>">
	        </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/LedgerGroup"><button type="button" class="btn btn-warning">Cancel</button></a></div>
            </div>   
	        
	    </div>
    	<div class="col-md-4">
	        
	        
	        
	        
	        
            
	    </div>
    	<div class="col-md-4 form-group has-warning">
    		<h4><label>Recently Listed Ledger Group</label></h4>
    		<div class="box box-warning">
			    <table class="table table-bordered table-hover">
			        <thead>
			            <tr>
			                <th>Name</th>
			                <th>Parent 	Ledger Group Name</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_ledgergroup/<?php echo $row['ledger_id'];?>"><strong><?php echo $row['ledger_group_name'];?></strong></a></td>
		    						<td><?php echo $row['parent'];?></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/ledgergroup"><strong>View All Ledger Group 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>