<?php
if($_GET)
{
    $consignor_id     =   $_GET['consignor_id'];
}
else
{
    $consignor_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="consignor_search" name="consignor_search" action="<?php echo base_url();?>General_masters/consignor" method="get">
    <div class="row"> 
        <div class="col-md-5">
            <div class="form-group">
                <label>Shipper/Exporter Name</label>
                <select class="form-control select2" id="consignor_id" name="consignor_id">
                	<option value="">Select Shipper/Exporter</option>
                  	<?php foreach($consignor_drpdwn as $row)
                  	{?>
                  		<option value="<?php echo $row['consignor_id'];?>" <?php if($row['consignor_id']==$consignor_id)echo "selected";?>><?php echo $row['consignor_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_consignor" class="btn btn-block btn-info"><b style="margin-left: -9px;">New Shipper/Exporter</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>Shipper/Exporter Name</th>
                <th>Contact Person</th>
               <!--  <th>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['consignor_name'];?></td>
	    			 
	    			<td><?php  echo $row['consignor_con_person'];?></td>
	    		<!-- <td><?php  echo $row['consignor_con_no'];?></td> -->
	    			<td><a href="<?php echo base_url();?>General_masters/edit_consignor/<?php echo $row['consignor_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()
    {
        $("#consignor_id").select2({
            ajax: { 
                dataType: 'json', 
                url: '<?php echo base_url();?>General_masters/get_consignorsearch',
                cache: true,
                data: function (params) 
                    {
                        return {
                            q: params.term
                        }
                    }
            }
        });
    }
</script>