           
<div class="panel panel-default">
    <?php
    $query = $this->main_model->freight_info($freight_id);
    foreach ($query as $row):
        ?>
        <div class="panel-heading">
            <h6 class="panel-title"><i class="fa fa fa-align-justify"></i> Freight Information | Invoice No.: <?php echo $row['invoice_no']; ?></h6>
            <a href="<?php echo site_url('everbright/freight'); ?>" class="pull-right btn btn-circle btn-xs btn-default"><i class="fa fa-step-backward"></i> Back</a>
        </div>

        <div class="panel-body">
            <form action="<?php echo site_url('everbright/freight/edit/' . $row['freight_id']); ?>" method="post" class="form-horizontal validate" role="form"> 

                <div class="row">
                    <!-- Date -->
                    <div class="col-md-6">                   
                        <div class="form-group">
                            <label class="col-sm-4 control-label text-right">Date <span class="mandatory">*</span></label>
                            <div class="col-sm-8">
                                <input type="text" class="required form-control datepicker" placeholder="Date" name="date" value="<?php echo $row['date']; ?>">
                            </div>
                        </div> 
                    </div> 
                    <!-- Delivery Date -->
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-4 text-right">Delivery Date </label>
                            <div class="col-md-8">
                                <input type="text" class="required form-control datepicker" placeholder="0000-00-00" name="del_date" value="<?php echo $row['del_date']; ?>">
                            </div>
                        </div>
                    </div>                   
                </div> 
                <!-- To --> 
                <div class="form-group">
                    <label class="control-label col-md-2 text-right">To </label>
                    <div class="col-md-10">
                        <textarea type="text" class="form-control" placeholder="To" name="to"><?php echo $row['to']; ?></textarea>
                    </div>
                </div>                 
                <div class="row">
                    <div class="col-md-6">                   
                        <div class="form-group">
                            <label class="col-sm-4 control-label text-right"><span>Job No*</span></label>
                            <div class="col-sm-8">
                                <input type="text" class="required  form-control " value="<?php echo $row['job_no']; ?>"  placeholder="Job No" name="job_no">
                            </div>
                        </div> 
                    </div>
                    <div class="col-md-6">                   
                        <div class="form-group">
                            <label class="col-sm-4 control-label text-right">POL/POD</label>
                            <div class="col-sm-4">
                                <select data-placeholder="(:-- Select Type --:)" name="pol_pod_type" class="select-search1">
                                    <option value=""></option>
                                    <option value="POL" <?php if($row['pol_pod_type']=='POL'): ?>selected="selected"<?php endif; ?>>POL</option>
                                    <option value="POD" <?php if($row['pol_pod_type']=='POD'): ?>selected="selected"<?php endif; ?>>POD</option>
                                </select>                            
                            </div>                            
                            <div class="col-sm-4">
                                <input type="text" class="form-control" value="<?php echo $row['pol_pod']; ?>" placeholder="Name" name="pol_pod">
                            </div>
                        </div> 
                    </div>

                </div>
                <div class="row">
                    <!-- ATTN -->
                    <div class="col-md-6">                   
                        <div class="form-group">
                            <label class="col-sm-4 control-label text-right">ATTN </label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" placeholder="ATTN" name="ATTN" value="<?php echo $row['ATTN']; ?>">
                            </div>
                        </div> 
                    </div> 
                    <!-- SHIPPER -->
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-4 text-right">SHIPPER </label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" placeholder="SHIPPER" name="SHIPPER" value="<?php echo $row['SHIPPER']; ?>">
                            </div>
                        </div>
                    </div>                    
                </div>
                <div class="row">
					<!-- VOL -->
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-4 text-right">VOL </label>
                            <div class="col-md-8">
                                <input type="text"  class="form-control" value="<?php echo $row['vol']; ?>" placeholder="VOL" name="vol">
                            </div>
                        </div>
                    </div>				
                    <!-- Gross Weigth -->
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-4 text-right">Gross Weigth </label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" placeholder="Gross Weigth" name="QTY" value="<?php echo $row['QTY']; ?>">
                            </div>
                        </div>
                    </div>	
                </div>
                <div class="row">
                    <!-- CNTR -->
                    <div class="col-md-6">                   
                        <div class="form-group">
                            <label class="col-sm-4 control-label text-right">CNTR </label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" placeholder="CNTR" name="CNTR" value="<?php echo $row['CNTR']; ?>">
                            </div>
                        </div> 
                    </div> 
                    <!-- LCNO -->
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-4 text-right">L/C No. </label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" placeholder="L/C No." name="LCNO" value="<?php echo $row['LCNO']; ?>">
                            </div>
                        </div>
                    </div>                    
                </div>
                <div class="row">
                    <!-- HBLNO -->
                    <div class="col-md-6">                   
                        <div class="form-group">
                            <label class="col-sm-4 control-label text-right">HBL No. </label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" placeholder="HBLNO" name="HBLNO" value="<?php echo $row['HBLNO']; ?>">
                            </div>
                        </div> 
                    </div> 
                    <!-- MBLNO -->
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-4 text-right">MBL No. </label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" placeholder="MBLNO" name="MBLNO" value="<?php echo $row['MBLNO']; ?>">
                            </div>
                        </div>
                    </div>                    
                </div>
                <div class="row">
                    <!-- HAWABLNO -->
                    <div class="col-md-6">                   
                        <div class="form-group">
                            <label class="col-sm-4 control-label text-right">HAWABL No. </label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" placeholder="HAWABLNO" name="HAWABLNO" value="<?php echo $row['HAWABLNO']; ?>">
                            </div>
                        </div> 
                    </div> 
                    <!-- MAWBLNO -->
                    <div class="col-md-6">
                        <div class="form-group">
                            <label class="control-label col-md-4 text-right">MAWBL No. </label>
                            <div class="col-md-8">
                                <input type="text" class="form-control" placeholder="MAWBLNO" name="MAWBLNO" value="<?php echo $row['MAWBLNO']; ?>">
                            </div>
                        </div>
                    </div>                    
                </div>
                <div class="row">
                    <!-- SHPT EX CGT -->
                    <div class="col-md-6">                   
                        <div class="form-group">
                            <label class="col-md-4 control-label text-right">SHPT EX </label>
                            <div class="col-md-8">
                                <select data-placeholder="(:-- Select SHPT EX --:)" name="SHPT_EX" class="select-search">
                                    <option value=""></option>
                                    <option value="Dhaka" <?php if ($row['SHPT_EX'] == 'Dhaka'): ?>selected="selected"<?php endif; ?>>Dhaka</option>
                                    <option value="Chittagong" <?php if ($row['SHPT_EX'] == 'Chittagong'): ?>selected="selected"<?php endif; ?>>Chittagong</option>
                                    <option value="Mongla" <?php if ($row['SHPT_EX'] == 'Mongla'): ?>selected="selected"<?php endif; ?>>Mongla</option>
                                </select>
                            </div>
                        </div>
                    </div>
                <!-- Commodity -->
                <div class="col-md-6">
                    <div class="form-group">
                        <label class="control-label col-md-4 text-right">Commodity </label>
                        <div class="col-md-8">
                            <input type="text" class="form-control" placeholder="Commodity" name="commodity" value="<?php echo $row['commodity']; ?>">
                        </div>
                    </div>
                </div>
                </div>                
                <!-- Invoice -->
                <div class="form-group">
                    <label class="col-sm-2 control-label text-right">Invoice </label> 
                    <div class="col-sm-9">
                        <div class="row">
                            <div class="col-xs-2"><label class="col-sm-2 control-label text-right">Description</label></div>
                            <div class="col-xs-3"><label class="col-sm-2 control-label text-right">Freight</label></div>
                            <div class="col-xs-3"><label class="col-sm-2 control-label text-right">Exchange</label></div>
                            <div class="col-xs-2"><label class="col-sm-2 control-label text-right">Unit</label></div>
                            <div class="col-xs-2"><label class="col-sm-2 control-label text-right">Amount</label></div>
                        </div>                        
                        <?php
                        $query_fi = $this->main_model->freightinvoice_info($row['freight_id']);
                         $counter=0;
                        foreach ($query_fi as $row_fi):
                           
                            ?>
                            <div class="item_fi mb5">
                                <a class="delete delete_fi btn btn-default" href="javascript:;" title=""><i class="fa fa-times"></i></a>
                                <div class="row">
                                    <div class="col-xs-2"><input type="text" class="form-control" placeholder="Description" name="fi_description[]" value="<?php echo $row_fi['description']; ?>"></div>
                                    <div class="col-xs-3"><input type="text" class="form-control" id="<?php echo $counter.'_freight_rate'?>" placeholder="Freight Rate"  value="<?php echo $row_fi['freight_rate']; ?>" name="freight_rate[]"></div>
                                    <div class="col-xs-3"><input type="text" class="form-control" id="<?php echo $counter.'_exchange_rate' ?>"  placeholder="Exchange Rate"  value="<?php echo $row_fi['exchange_rate']; ?>" name="exchange_rate[]"></div>
                                    <div class="col-xs-2"><input type="text" class="form-control" id="<?php echo $counter.'_fi_unit';?>" placeholder="Unit" oninput="getAmount(this.id)"  name="fi_unit[]" value="<?php echo $row_fi['unit']; ?>"></div>
                                    <div class="col-xs-2"><input type="text" class="form-control" id="<?php echo $counter.'_fi_amount';?>" placeholder="Amount"  name="fi_amount[]" value="<?php echo $row_fi['amount']; ?>" ></div>
                                </div>                                    
                            </div>
                        <?php $counter++; endforeach; ?>
                        <a id="add_fi" class="btn btn-default" href="javascript:;" title="Add Row"><i class="fa fa-plus"></i></a>
                    </div>
                </div> 
                <script type="text/javascript">
                    dynamic_id=1;
                    $(document).ready(function () {
                        $("#add_fi").click(function () {
                            $(".item_fi:last").after('<div class="item_fi mb5"><a class="delete delete_fi btn btn-default" href="javascript:;" title=""><i class="fa fa-times"></i></a><div class="row"><div class="col-xs-2"><input type="text" class="form-control" placeholder="Description" name="fi_description[]"></div><div class="col-xs-3"><input type="text" class="form-control" id="' + dynamic_id + '_freight_rate_edit" placeholder="Freight Rate" name="freight_rate[]"></div><div class="col-xs-3"><input type="text" class="form-control" placeholder="Exchange Rate" id="' + dynamic_id + '_exchange_rate_edit" name="exchange_rate[]"></div><div class="col-xs-2"><input type="text" class="form-control" id="' + dynamic_id + '_fi_unit_edit" placeholder="Unit" oninput="getAmountEdit(this.id)" name="fi_unit[]"></div><div class="col-xs-2"><input type="text" class="form-control" id="' + dynamic_id + '_fi_amount_edit" placeholder="Amount" name="fi_amount[]"></div></div></div>');
                            dynamic_id++;
                            if ($(".delete_fi").length > 0)
                                $(".delete_fi").show();
                        });
                        $(".delete_fi").live('click', function () {
                            $(this).parents('.item_fi').remove();
                            if ($(".delete_fi").length < 2)
                                $(".delete_fi").hide();
                        });
                    });
                </script>
                <script type="text/javascript">
                function getAmount(received_id)
                {
//                    alert(received_id);
                    str_array = received_id.split('_');
                    auto_id = str_array[0];
                    freight_rate = auto_id + '_freight_rate';
                    exchange_rate = auto_id + '_exchange_rate';
                    fi_unit = auto_id + '_fi_unit';
                    fi_amount = auto_id + '_fi_amount';
                    document.getElementById(fi_amount).value = (document.getElementById(freight_rate).value * document.getElementById(exchange_rate).value * document.getElementById(fi_unit).value).toFixed(3);
                }
                function getAmountEdit(received_id)
                {
                    str_array = received_id.split('_');
                    auto_id = str_array[0];
                    freight_rate = auto_id + '_freight_rate_edit';
                    exchange_rate = auto_id + '_exchange_rate_edit';
                    fi_unit = auto_id + '_fi_unit_edit';
                    fi_amount = auto_id + '_fi_amount_edit';
                    document.getElementById(fi_amount).value = (document.getElementById(freight_rate).value * document.getElementById(exchange_rate).value * document.getElementById(fi_unit).value).toFixed(3); 
                }

            </script>

                <div class="form-actions text-right">
                    <button type="submit" value="Update" class="btn btn-primary"><i class="fa fa-check"></i> Update</button>
                </div>

            </form> 

        </div>

    <?php endforeach; ?>

</div>
