<?php
if($_GET)
{
    $port_of_dis_id     =   $_GET['port_of_dis_id'];
}
else
{
    $port_of_dis_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="port_of_dis_search" name="port_of_dis_search" action="<?php echo base_url();?>General_masters/port_of_dis" method="get">
     <div class="row"> 
        <div class="col-md-5">
            <div class="form-group">
                <label>Port Name</label>
                <select class="form-control select2" id="port_of_dis_id" name="port_of_dis_id">
                	<option value="">Select Port Name</option>
                  	<?php foreach($port_of_dis_drpdwn as $row)
                  	{?>
                  		<option value="<?php echo $row['port_of_dis_id'];?>" <?php if($row['port_of_dis_id']==$port_of_dis_id)echo "selected";?>><?php echo $row['port_of_dis_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_port_of_dis" class="btn btn-block btn-info"><b>New Port Of Discharge</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>Port Name</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['port_of_dis_name'];?></td>
	    			
	    			<td><?php echo $row['port_of_dis_shrt_code'];?></td>
	    			
	    			<td><a href="<?php echo base_url();?>General_masters/edit_port_of_dis/<?php echo $row['port_of_dis_id'];?>"><i class="fa fa-edit"></i></a></td>
	    		</tr>
        	<?php }
        }?>
        </tbody>
    </table>
</div>
<!-- /.box-body -->
<script type="text/javascript">
    $(function()
    {
        setTimeout(port_of_dis_select);
    });
    function port_of_dis_select()
    {
        $("#port_of_dis_id").select2({
            ajax: { 
                dataType: 'json', 
                url: '<?php echo base_url();?>General_masters/get_port_of_dis',
                cache: true,
                data: function (params) 
                    {
                        return {
                            q: params.term
                        }
                    }
            }
        });
    }
</script>