<?php
if($_GET)
{
    $cmp_id     =   $_GET['cmp_id'];
}
else
{
    $cmp_id     =   '';
}
?>
<div style="color:green;text-align:center" class="success"><strong><?php if($this->session->flashdata('msg')){ echo $this->session->flashdata('msg');} ?></strong></div>
<div class="box-body">
	<form role="form" id="company_search" name="company_search" action="<?php echo base_url();?>General_masters/company" method="get">
    <!-- <div class="row"> 
        <div class="col-md-5">
            <div class="form-group">
                <label>Company</label>
                <select class="form-control select2" id="cmp_id" name="cmp_id">
                	<option value="">Select Company</option>
                  	<?php foreach($company_drpdwn as $row)
                  	{?>
                  		<option value="<?php echo $row['cmp_id'];?>" <?php if($row['cmp_id']==$cmp_id)echo "selected";?>><?php echo $row['cmp_name'];?></option>
                  	<?php }?>
                </select>
            </div>
        </div>
        <div class="col-md-5">
            <div class="form-group">
            </div>
        </div>
        <div class="col-md-2">
            <div class="form-group">
              	<button class="btn btn-block btn-warning"><b>Search</b></button>
              	<a href="<?php echo base_url();?>General_masters/add_company" class="btn btn-block btn-info"><b>New Company</b></a>
            </div>
        </div>
    </div> -->
    </form>
</div>
<!-- /.box-header -->
<div class="box-body"> 
     <table id="example2" class="table table-bordered table-hover">
        <thead>
            <tr>
                <th style="width: 10px">#</th>
                <th>Name</th>
                <th>Place Of Loading</th>
                <th>Short Code</th>
              
                <th>Edit</th>
            </tr>
        </thead>
        <tbody>
        <?php $page_num=0;if(count($table_rows)!=0)
        {
        	$count	=	1;
        	foreach($table_rows as $row)
        	{?>
	    		<tr>
	    			<td><?php echo $count++;?></td>
	    			<td><?php echo $row['cmp_name'];?></td>
	    			<td><?php echo $row['cmp_pol'];?></td>
	    			<td><?php echo $row['cmp_shrt_code'];?></td>
	    			
	    			<td><a href="<?php echo base_url();?>General_masters/edit_company/<?php echo $row['cmp_id'];?>"><i class="fa fa-edit"></i></a></td>
	    		</tr>
        	<?php }
        }?>
        </tbody>
    </table>
</div>
<!-- /.box-body -->
<script type="text/javascript">
    $(function()
    {
        setTimeout(company_select);
    });
    function company_select()
    {
        $("#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>