<?php
if($_GET)
{
    $consignee_id     =   $_GET['consignee_id'];
}
else
{
    $consignee_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="ledgergroup_search" name="ledgergroup_search" action="<?php echo base_url();?>General_masters/consignee" method="get">
    <div class="row"> 
        <div class="col-md-5">
            <div class="form-group">
                <label>consignee Name</label>
                <select class="form-control select2" id="consignee_id" name="consignee_id">
                	<option value="">Select consignee</option>
                  	<?php foreach($consignee_drpdwn as $row)
                  	{?>
                  		<option value="<?php echo $row['consignee_id'];?>" <?php if($row['consignee_id']==$consignee_id)echo "selected";?>><?php echo $row['consignee_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_consignee" class="btn btn-block btn-info"><b>New consignee</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>consignee Name</th>
                <th>consignee Contact Person</th>
                <th>consignee Contact Number</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['consignee_name'];?></td>
	    			 
	    			<td><?php  echo $row['consignee_con_person'];?></td>
	    		<td><?php  echo $row['consignee_con_no'];?></td>
	    			<td><a href="<?php echo base_url();?>General_masters/edit_consignee/<?php echo $row['consignee_id'];?>"><i class="fa fa-edit"></i></a></td>
	    		</tr>
        	<?php }
        }?>
        </tbody>
    </table>
</div>
<!-- /.box-body -->
<script type="text/javascript">
    $(function()
    {
        setTimeout(ledger_select);
    });
    function ledger_select()
    {
        $("#consignee_id").select2({
            ajax: { 
                dataType: 'json', 
                url: '<?php echo base_url();?>General_masters/get_consigneesearch',
                cache: true,
                data: function (params) 
                    {
                        return {
                            q: params.term
                        }
                    }
            }
        });
    }
</script>