
<style type="text/css">
    .page-header{border: none;}
    .panel-title{line-height: 1;}
    .print-logo{display:none;}
    .print-visible{display:none;}
    @media print
    {    
        .no-print, .no-print *
        {
            display: none !important;
        }
        .print-visible{display:block !important;}
        .print-logo{display:block !important;text-align:center;margin-left:45%;}
        .text-center{text-align:center !important;}
        .invoice-col{width:50% !important;float:left !important;}
        .table > tbody > tr > td, .jsgrid-table > tbody > tr > td, .table > tbody > tr > th, .jsgrid-table > tbody > tr > th, .table > tfoot > tr > td, .jsgrid-table > tfoot > tr > td, .table > tfoot > tr > th, .jsgrid-table > tfoot > tr > th, .table > thead > tr > td, .jsgrid-table > thead > tr > td, .table > thead > tr > th, .jsgrid-table > thead > tr > th{padding:8px !important;}
        .pt-25{padding-top:0px;}
        .panel-heading{padding:0px;}
        .print-size{width: 400px !important;}
    }
</style>
<!-- Main Content -->

<div class="page-wrapper">

    <div class="container-fluid pt-25">

        <div class="row">

            <div class="col-md-12">

                <div class="alert alert-success alert-dismissible" role="alert" <?php if($this->session->flashdata('message')==''){ ?> style="display:none" <?php } ?> >

                    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>

                    <?php echo $this->session->flashdata('message'); ?>

                </div>

            </div>

        </div>

        <!-- Row -->
       <?php //echo "<pre>"; print_r($invoice); ?>
        <div class="row">
            <div class="col-md-12">
                <h4 class="page-header" style="margin-top:0px;">
                    <span>Invoice <small><?php echo "#".$invoice['invoice_no']; ?></small></span>
                    <?php if($invoice['order_status']==5){ ?>
                       <span class="pull-right no-print"> Order Is Cancelled </span>
                    <?php }else if($invoice['order_status']==4){ ?>
                        <span class="pull-right no-print"> Order Is Completed</span>
                    <?php }else if($invoice['order_status']==6){ ?>
                        <span class="pull-right no-print"> Order Is Refunded</span>
                    <?php }else if($invoice['order_status']==7){ ?>
                        <span class="pull-right no-print"> Order Is Faild</span>
                    <?php }else{ ?>
                        <a href="#" data-toggle="modal" data-target="#orderCancleModal" class="btn btn-warning pull-right no-print">Cancel Order</a>
                    <?php } ?>
                    <div class="print-visible" style="float:right;">Order date: <span class="right"><strong><?php echo date("d M Y",strtotime($invoice['order_time'])); ?></strong></span></div>
                    <!-- <span class="badge badge-danger ">Unpaid</span> -->
                    <!-- <span class="badge badge-warning">Pending</span> -->
                    <small class="no-print txt-dark" style="font-size: 14px;"><?php echo date("d M Y",strtotime($invoice['order_time'])); ?></small>
                </h4>
            </div>

        </div>
        <div class="row">

            <div class="col-sm-12 print-visible">

                <div class="panel panel-default card-view">

                    <div class="panel-heading">
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="btn btn-primary pull-right no-print" onclick="javascript:window.print();">PRINT</span>
                        <!-- <a class="btn btn-info pull-right no-print" href="<?php //echo base_url(A."/downloadOrderInvoicePdf?orderid=".$invoice['orderid']); ?>" style="margin-right:10px;">Download GST PDF</a>   -->                
                        <div class="clearfix"></div>
                    </div>

                    <div class="panel-wrapper collapse in">

                        <div class="panel-body">                                                      
                            <div class="row invoice-info">

                                <div class="col-sm-4 col-md-4 invoice-col">

                                  <h4>Shipping Details</h4>

                                  <address>

                                    <strong>Contact Name :</strong> <?php echo $invoice['bname']; ?><br/>

                                    <strong>Email :</strong> <?php echo $invoice['bemail']; ?><br/>

                                    <strong>Mobile No. :</strong> <?php echo $invoice['bmobile_no']; ?><br>

                                    <strong>Address :</strong> <?php echo $invoice['baddress1']; ?><br/>

                                    <strong>Unit No. :</strong> <?php echo $invoice['baddress2']; ?><br/>

                                    <strong>Country :</strong> <?php echo $invoice['bcountry']; ?><br/>

                                    <!-- <strong>City:</strong> <?php //echo $invoice['bcity']; ?><br/>

                                    <strong>State:</strong> <?php //echo $invoice['bstate']; ?><br/> -->

                                    <strong>Pincode:</strong> <?php echo $invoice['bpincode']; ?><br/>

                                  </address>

                                </div>

                                <div class="col-sm-4 col-md-4 invoice-col">

                                  <?php if($invoice['payment_status']=='Pending'){ ?>
                                    <!-- <form id="paymentStatusForm" action="<?php //echo base_url(A.'/updateOrderPaymentStatus'); ?>" method="post">
                                        <input type="hidden" name="orderid" value="<?php //echo $invoice['orderid']; ?>" />
                                        <label>Payment Status</label>
                                        <select name="payment_status" class="form-control" id="changePaymentStatus">
                                            <option value="Pending">Pending</option>
                                            <option value="Complete">Complete</option>
                                        </select>
                                    </form> -->
                                    Payment Status - Pending
                                  <?php }else{ ?>
                                    Payment Status - Completed
                                  <?php } ?><br><br>
                                    <?php if($invoice['payment_method']==1 || $invoice['payment_method']=='COD'){ ?>
                                        Payment via  -  Cash On Delivery.
                                    <?php } ?>
                                    <?php if($invoice['payment_method']==2 || $invoice['payment_method']=='paynow'){ ?>
                                        Payment via  -  Online (Txnid - <?php echo $invoice['txn_id']; ?>).
                                    <?php } ?>
                                    <?php if($invoice['payment_method']==3 || $invoice['payment_method']=='omise'){ ?>
                                        Payment via  - Omise  (Txnid - <?php echo $invoice['txn_id']; ?>).
                                    <?php } ?>

                                </div>

                                <div class="col-sm-4 col-md-4 invoice-col no-print">
                                    <div><strong>Order date :</strong> <span class="right"><strong><?php echo date("d M Y",strtotime($invoice['order_time'])); ?></strong></span></div>
                                    <?php if($invoice['out_of_stock']!=''){ ?>                   
                                        <div><strong>IF UNCONTACTABLE :</strong> <span class="right"><strong><?php echo $invoice['out_of_stock']; ?></strong></span></div>
                                    <?php } ?>                                    
                                    <br>
                                    <?php $order_status = $this->config->item("order_status"); ?>
                                    <div>Order status:
                                        <span class="right">
                                        <form action="<?php echo base_url(A.'/updateOrderStatus'); ?>" method="post">
                                            <input type="hidden" name="orderid" value="<?php echo $invoice['orderid']; ?>" />
                                            <input type="hidden" name="profileid" value="<?php echo $invoice['profileid']; ?>" />
                                            <input type="hidden" name="bmobile_no" value="<?php echo $invoice['bmobile_no']; ?>" />
                                            <div class="form-group">
                                                <select name="order_status" class="form-control">
                                                    <option value="">Select Order Status</option>                   
                                                    <?php if($invoice['order_status']==5){ ?>
                                                        <option selected disabled>Order Canceled</option> 
                                                    <?php } ?>

                                                    <?php if(!empty($order_status)){ foreach ($order_status as $key => $value) : ?>
                                                        <?php if($key!=5){ ?>
                                                            <option value="<?php echo $key; ?>" <?php if($key==$invoice['order_status']){ ?> selected="selected" <?php } ?> ><?php echo $value; ?></option>
                                                        <?php } ?>
                                                    <?php endforeach; } ?>

                                                </select>
                                            </div>
                                            <!-- <div class="form-group">
                                                <input type="text" name="status_date" class="form-control start_dt" placeholder="Date" />
                                            </div>
                                            <div class="form-group">
                                                <input type="text" name="link" class="form-control" placeholder="Link" />
                                            </div>
                                            <div class="form-group">
                                                <textarea class="form-control" name="message" placeholder="Message"></textarea>
                                            </div> -->
                                            <div class="form-group">
                                                <input type="submit" value="Submit" class="btn btn-primary" />
                                            </div>                                            
                                        </form>

                                        </span><br>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12">
                                    <table class="table table-hover">
                                        <thead>
                                            <tr>
                                                <th class="no-print">Image</th>
                                                <th class="print-size">Product Name</th>
                                                <th>Price</th>
                                                <th>Quantity</th>
                                                <th>Subtotal</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php $Subtotal = $amount = $shipping = array();
                                                if(!empty($cart)){ 
                                                    foreach($cart as $key => $value):
                                                        $price = 0; 
                                                        if($value['product_sale_price']!='' && $value['product_sale_price']>0){
                                                            $price = (($value['product_sale_price']*$value["qty"]));
                                                            $sprice = $value['product_sale_price'];
                                                        }else{
                                                           $price = (($value['product_price']*$value["qty"]));
                                                           $sprice = $value['product_price']; 
                                                        }
                                                        $price = $value['subtotal'];
                                                        $pcoupon_amount = $value['product_coupon_amount'];
                                                        $price = $price-$pcoupon_amount;
                                                        $amount[] = $price;
                                                        if($value['size']!="" && $value['size']!="undefined"){
                                                            $size = '<span class="c-p-size"><span>Size : </span> <button class="btn" type="button" style="padding:6px 8px;line-height: 10px;border:1px solid #ddd;border-radius:0px;background:#fff;color:#000;" disabled>'.$value["size"].'</button></span><br>';
                                                        }else{
                                                            $size = "";
                                                        }
                                                        if($value['color']!="" && $value['color']!="undefined"){
                                                            $color = '<span class="c-p-color"><span>Color : <button type="button" style="width:20px;height:20px;border:none;border-radius:50px;background-color:#'.$value["color"].'" disabled>&nbsp;</button></span></span>';
                                                        }else{
                                                            $color = "";
                                                        }
                                                    ?>
                                                <tr>
                                                    <td style="width: 100px;" class="no-print">
                                                        <img src="<?php echo base_url($value['product_photos']); ?>" style=" width:100px;">
                                                    </td>
                                                    <td><?php echo $value['product_name']; ?>
                                                        <?php if($pcoupon_amount>0){ ?>
                                                          <p>Coupon Code : <?php echo $value['product_coupon_code']; ?></p>
                                                          <p>Coupon Amount : <span class="price">$<?php echo number_format(($pcoupon_amount),2); ?></span></p>
                                                        <?php } ?>
                                                    </td>
                                                    <td>
                                                        <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                            $ <?php echo number_format($sprice/$invoice['usd_rate'],2); ?>
                                                        <?php }else{ ?>
                                                            $ <?php echo number_format($sprice,2); ?>
                                                        <?php } ?>
                                                    </td>
                                                    <td>
                                                        <?php if($value['shop_rewards']==0){ ?>
                                                            <?php echo $value['qty']; ?>
                                                        <?php } ?>
                                                    </td>
                                                    <?php if($value['shop_rewards']==0){ ?>
                                                        <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                            <td>$ <?php echo number_format($price/$invoice['usd_rate'],2); ?></td>
                                                        <?php }else{ ?>
                                                            <td>$ <?php echo number_format($price,2); ?></td>
                                                        <?php } ?>
                                                    <?php }else{ ?>
                                                        <td><?php echo $price; ?> Points</td>
                                                    <?php } ?>
                                                </tr>
                                            <?php endforeach; } ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-6">
                                   
                                </div>
                                <div class="col-xs-6">
                                    <br /><br />
                                    <div class="table-responsive">
                                        <table class="table">
                                            <tr>
                                                <td style="width:50%">Subtotal:</td>
                                                <td>
                                                    <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                        $ <?php echo number_format($invoice['subtotal']/$invoice['usd_rate'],2); ?>
                                                    <?php }else{ ?>
                                                        $ <?php echo number_format($invoice['subtotal'],2); ?>
                                                    <?php } ?>
                                                </td>
                                            </tr>
                                            <?php
                                                if(isset($invoice['coupon_amount']) && $invoice['coupon_amount']!="" && $invoice['coupon_amount']!=0){  ?>
                                            <tr>
                                                <th>Coupon</th>
                                                <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                    <td> - $ <?php echo number_format($invoice['coupon_amount']/$invoice['usd_rate'],2); ?></td>
                                                <?php }else{ ?>
                                                    <td> - $ <?php echo number_format($invoice['coupon_amount'],2); ?></td>
                                                <?php } ?>
                                            </tr>
                                            <?php } ?>
                                            <?php if(isset($invoice['first_order']) && $invoice['first_order']!=0){ ?>
                                               <tr>
                                                    <th style="width:50%">Pet Mart Discount :</th>
                                                    <td>
                                                        <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                           -  $ <?php echo number_format($invoice['first_order']/$invoice['usd_rate'],2); ?>
                                                       <?php }else{ ?>
                                                           -  $ <?php echo number_format($invoice['first_order'],2); ?>
                                                       <?php } ?>
                                                    </td>
                                                </tr> 
                                            <? } ?>
                                            <?php if(isset($invoice['delivery_charge']) && $invoice['delivery_charge']!=0){ ?>
                                               <tr>
                                                    <td style="width:50%">Shiping Charge :</td>
                                                    <td>
                                                        <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                            $ <?php echo number_format($invoice['delivery_charge']/$invoice['usd_rate'],2); ?>
                                                        <?php }else{ ?>
                                                            $ <?php echo number_format($invoice['delivery_charge'],2); ?>
                                                        <?php } ?>
                                                    </td>
                                                </tr> 
                                            <? } ?>
                                            <?php if(isset($invoice['birthday_discount']) && $invoice['birthday_discount']>0){ ?>
                                               <tr>
                                                    <th style="width:50%">Birthday Month Discount :</th>
                                                    <td>
                                                        -$ <?php echo number_format($invoice['birthday_discount'],2); ?>
                                                    </td>
                                                </tr> 
                                            <? } ?>
                                            <?php if(isset($invoice['use_coins_amount']) && $invoice['use_coins_amount']>0){ ?>
                                               <tr>
                                                    <th style="width:50%">Redemption Voucher :</th>
                                                    <td>
                                                        -$ <?php echo number_format($invoice['use_coins_amount'],2); ?>
                                                    </td>
                                                </tr> 
                                            <? } ?>
                                            <?php 
                                                $tamt = ($invoice['grandtotal']);
                                                $inclusive = ($tamt/(107))*7; 
                                            ?>
                                            <tr>
                                                <td>Price Before GST:</td>
                                                <td>$ <?php echo number_format(($tamt-$inclusive),2); ?></td>
                                            </tr>
                                            <tr>
                                                <td>GST (7% Included):</td>
                                                <td>$ <?php echo number_format($inclusive,2); ?></td>
                                            </tr>
                                            <tr>
                                                <td>Grand Total:</td>
                                                <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                    <td>$ <?php echo number_format(($invoice['grandtotal']/$invoice['usd_rate']),2);?></td>
                                                <?php }else{ ?>
                                                    <td>$ <?php echo number_format(($invoice['grandtotal']),2);?></td>
                                                <?php } ?>
                                            </tr>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>  
            </div>

            <div class="col-sm-12 no-print">
                <div class="row">
                    <div class="col-md-8">
                        <div class="panel card-view">
                            <div class="row">
                                <div class="panel-heading">                                
                                <h6 class="panel-title txt-dark row "> Order details <span class="badge badge-primary pull-right no-print" onclick="javascript:window.print();">Print </span></h6>
                                <hr>                                
                                <p class="text-right">
                                    <?php if($invoice['payment_method']==1 || $invoice['payment_method']=='COD'){ ?>
                                        Payment via  :  Cash On Delivery.
                                    <?php } ?>
                                    <?php if($invoice['payment_method']==2 || $invoice['payment_method']=='paynow'){ ?>
                                        Payment via  :  Online (Txnid - <?php echo $invoice['txn_id']; ?>).
                                    <?php } ?>
                                    <?php if($invoice['payment_method']==3 || $invoice['payment_method']=='omise'){ ?>
                                        Payment via  :s Omise  (Txnid - <?php echo $invoice['txn_id']; ?>).
                                    <?php } ?>
                                </p>
                                <!-- <p class="text-right">Order Type: <span class="badge badge-info">Delivery</span></p> -->
                                <hr>
                            </div>
                            </div>
                            <div class="panel-wrapper collapse in ">
                                <div class="panel-body">
                                    <div class="col-md-12">
                                        <table class="table table-hover">
                                            <thead>
                                                <tr>
                                                    <th class="no-print">Image</th>
                                                    <th class="print-size">Product Name</th>
                                                    <th>Price</th>
                                                    <th>Quantity</th>
                                                    <th>Subtotal</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php $Subtotal = $amount = $shipping = array();
                                                    if(!empty($cart)){ 
                                                        foreach($cart as $key => $value):
                                                            $price = 0; 
                                                            if($value['product_sale_price']!='' && $value['product_sale_price']>0){
                                                                $price = (($value['product_sale_price']*$value["qty"]));
                                                                $sprice = $value['product_sale_price'];
                                                            }else{
                                                               $price = (($value['product_price']*$value["qty"]));
                                                               $sprice = $value['product_price']; 
                                                            }
                                                            if($value['shop_rewards']==0){
                                                                $price = $value['subtotal'];
                                                            }
                                                            $pcoupon_amount = $value['product_coupon_amount'];
                                                            $price = $price-$pcoupon_amount;
                                                            $amount[] = $price;
                                                            if($value['size']!="" && $value['size']!="undefined"){
                                                                $size = '<span class="c-p-size"><span>Size : </span> <button class="btn" type="button" style="padding:6px 8px;line-height: 10px;border:1px solid #ddd;border-radius:0px;background:#fff;color:#000;" disabled>'.$value["size"].'</button></span><br>';
                                                            }else{
                                                                $size = "";
                                                            }
                                                            if($value['color']!="" && $value['color']!="undefined"){
                                                                $color = '<span class="c-p-color"><span>Color : <button type="button" style="width:20px;height:20px;border:none;border-radius:50px;background-color:#'.$value["color"].'" disabled>&nbsp;</button></span></span>';
                                                            }else{
                                                                $color = "";
                                                            }
                                                        ?>
                                                    <tr>
                                                        <td style="width: 100px;" class="no-print">
                                                            <img src="<?php echo base_url($value['product_photos']); ?>" style=" width:100px;">
                                                        </td>
                                                        <td><?php echo $value['product_name']; ?>
                                                            <?php if($pcoupon_amount>0){ ?>
                                                              <p>Coupon Code : <?php echo $value['product_coupon_code']; ?></p>
                                                              <p class="text-danger">Coupon Amount : <span class="price">$<?php echo number_format(($pcoupon_amount),2); ?></span></p>
                                                            <?php } ?>
                                                        </td>
                                                        <td>
                                                            <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                                $ <?php echo number_format($sprice/$invoice['usd_rate'],2); ?>
                                                            <?php }else{ ?>
                                                                $ <?php echo number_format($sprice,2); ?>
                                                            <?php } ?>
                                                        </td>
                                                        <td>
                                                            <?php if($value['shop_rewards']==0){ ?>
                                                                <?php echo $value['qty']; ?>
                                                            <?php } ?>
                                                        </td>
                                                        <?php if($value['shop_rewards']==0){ ?>
                                                            <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                                <td>$ <?php echo number_format($price/$invoice['usd_rate'],2); ?></td>
                                                            <?php }else{ ?>
                                                                <td>$ <?php echo number_format($price,2); ?></td>
                                                            <?php } ?>
                                                        <?php }else{ ?>
                                                            <td><?php echo $price; ?> Points</td>
                                                        <?php } ?>
                                                    </tr>
                                                <?php endforeach; } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="col-sm-6"></div>
                                    <div class="col-sm-6">
                                        <div class="table-responsive">
                                        <table class="table">
                                            <tr>
                                                <td style="width:50%">Subtotal:</td>
                                                <td>
                                                    <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                        $ <?php echo number_format($invoice['subtotal']/$invoice['usd_rate'],2); ?>
                                                    <?php }else{ ?>
                                                        $ <?php echo number_format($invoice['subtotal'],2); ?>
                                                    <?php } ?>
                                                </td>
                                            </tr>
                                            <?php
                                                if(isset($invoice['coupon_amount']) && $invoice['coupon_amount']!="" && $invoice['coupon_amount']!=0){  ?>
                                            <tr>
                                                <th>Coupon</th>
                                                <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                    <td> - $ <?php echo number_format($invoice['coupon_amount']/$invoice['usd_rate'],2); ?></td>
                                                <?php }else{ ?>
                                                    <td> - $ <?php echo number_format($invoice['coupon_amount'],2); ?></td>
                                                <?php } ?>
                                            </tr>
                                            <?php } ?>
                                            <?php if(isset($invoice['first_order']) && $invoice['first_order']!=0){ ?>
                                               <tr>
                                                    <th style="width:50%">Pet Mart Discount :</th>
                                                    <td>
                                                        <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                           -  $ <?php echo number_format($invoice['first_order']/$invoice['usd_rate'],2); ?>
                                                       <?php }else{ ?>
                                                           -  $ <?php echo number_format($invoice['first_order'],2); ?>
                                                       <?php } ?>
                                                    </td>
                                                </tr> 
                                            <? } ?>
                                            <?php if(isset($invoice['delivery_charge']) && $invoice['delivery_charge']!=0){ ?>
                                               <tr>
                                                    <td style="width:50%">Shiping Charge :</td>
                                                    <td>
                                                        <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                            $ <?php echo number_format($invoice['delivery_charge']/$invoice['usd_rate'],2); ?>
                                                        <?php }else{ ?>
                                                            $ <?php echo number_format($invoice['delivery_charge'],2); ?>
                                                        <?php } ?>
                                                    </td>
                                                </tr> 
                                            <? } ?>
                                            <?php if(isset($invoice['birthday_discount']) && $invoice['birthday_discount']>0){ ?>
                                               <tr>
                                                    <th style="width:50%">Birthday Month Discount :</th>
                                                    <td>
                                                        -$ <?php echo number_format($invoice['birthday_discount'],2); ?>
                                                    </td>
                                                </tr> 
                                            <? } ?>
                                            <?php if(isset($invoice['use_coins_amount']) && $invoice['use_coins_amount']>0){ ?>
                                               <tr>
                                                    <th style="width:50%">Redemption Voucher :</th>
                                                    <td>
                                                        -$ <?php echo number_format($invoice['use_coins_amount'],2); ?>
                                                    </td>
                                                </tr> 
                                            <? } ?>
                                            <?php 
                                                $tamt = ($invoice['grandtotal']);
                                                $inclusive = ($tamt/(107))*7; 
                                            ?>
                                            <tr>
                                                <td>Price Before GST:</td>
                                                <td>$ <?php echo number_format(($tamt-$inclusive),2); ?></td>
                                            </tr>
                                            <tr>
                                                <td>GST (7% Included):</td>
                                                <td>$ <?php echo number_format($inclusive,2); ?></td>
                                            </tr>
                                            <tr>
                                                <td>Grand Total:</td>
                                                <?php if($invoice['payment_currency']=='USD' && $invoice['usd_rate']!=0){ ?>
                                                    <td>$ <?php echo number_format(($invoice['grandtotal']/$invoice['usd_rate']),2);?></td>
                                                <?php }else{ ?>
                                                    <td>$ <?php echo number_format(($invoice['grandtotal']),2);?></td>
                                                <?php } ?>
                                            </tr>
                                        </table>
                                    </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                    </div>
                    <div class="col-md-4">
                        <div class="panel card-view">
                            <div class="panel-heading">
                                <h6 class="panel-title txt-dark">Payment Status</h6>      
                                <hr>                          
                            </div>
                            <div class="panel-wrapper collapse in">
                                <div class="panel-body">
                                     <?php if($invoice['payment_status']=='Pending'){ ?>
                                        <form id="paymentStatusForm" action="<?php echo base_url(A.'/updateOrderPaymentStatus'); ?>" method="post">
                                            <input type="hidden" name="orderid" value="<?php echo $invoice['orderid']; ?>" />
                                            <select name="payment_status" class="form-control" id="changePaymentStatus">
                                                <option value="Pending">Pending</option>
                                                <option value="Complete">Complete</option>
                                            </select>
                                        </form>
                                      <?php }else{ ?>
                                        Payment Status - Completed
                                      <?php } ?>
                                </div>
                            </div>
                        </div>
                        <div class="panel card-view">
                            <div class="panel-heading">
                                <h6 class="panel-title txt-dark">Order status</h6>
                                <hr>
                            </div>
                            <div class="panel-wrapper collapse in">
                                <div class="panel-body">                                    
                                    <?php if($invoice['out_of_stock']!=''){ ?>                   
                                        <div><strong>IF UNCONTACTABLE :</strong> <span class="right"><strong><?php echo $invoice['out_of_stock']; ?></strong></span></div>
                                    <?php } ?>                                                                        
                                    <div>
                                        <span class="right">
                                        <form action="<?php echo base_url(A.'/updateOrderStatus'); ?>" method="post">
                                            <input type="hidden" name="orderid" value="<?php echo $invoice['orderid']; ?>" />
                                            <input type="hidden" name="profileid" value="<?php echo $invoice['profileid']; ?>" />
                                            <input type="hidden" name="bmobile_no" value="<?php echo $invoice['bmobile_no']; ?>" />
                                            <div class="form-group ">
                                                <select name="order_status" class="form-control">
                                                    <option value="">Select Order Status</option>                   
                                                    <?php if($invoice['order_status']==5){ ?>
                                                        <option selected disabled>Order Canceled</option> 
                                                    <?php } ?>

                                                    <?php if(!empty($order_status)){ foreach ($order_status as $key => $value) : ?>
                                                        <?php if($key!=5){ ?>
                                                            <option value="<?php echo $key; ?>" <?php if($key==$invoice['order_status']){ ?> selected="selected" <?php } ?> ><?php echo $value; ?></option>
                                                        <?php } ?>
                                                    <?php endforeach; } ?>

                                                </select>
                                            </div>
                                            <!-- <div class="form-group">
                                                <input type="text" name="status_date" class="form-control start_dt" placeholder="Date" />
                                            </div>
                                            <div class="form-group">
                                                <input type="text" name="link" class="form-control" placeholder="Link" />
                                            </div>
                                            <div class="form-group">
                                                <textarea class="form-control" name="message" placeholder="Message"></textarea>
                                            </div> -->
                                            <div class="form-group mb-0">
                                                <input type="submit" value="Submit" class="btn btn-primary" />
                                            </div>                                            
                                        </form>

                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="panel card-view">
                            <div class="panel-heading">
                                <h6 class="panel-title txt-dark">Customer</h6>      
                                <hr>                          
                            </div>
                            <div class="panel-wrapper collapse in ">
                                <div class="panel-body">
                                    <p class="mb-0"><?php echo $invoice['bname']; ?></p>
                                    <hr>
                                    <p><strong>Contact Information</strong></p>
                                    <p><strong class="mr-10"><i class="fa fa-envelope"></i></strong> <?php echo $invoice['bemail']; ?></p>
                                    <p><strong class="mr-10"><i class="fa fa-phone-square"></i></strong> <?php echo $invoice['bmobile_no']; ?></p>
                                    <hr>
                                    <p><strong>Delivery Information </strong></p>
                                    <p>Name : <?php echo $invoice['bname']; ?></p>
                                    <p>Contact : <?php echo $invoice['bmobile_no']; ?></p>
                                    <p><strong>Address :</strong> <?php echo $invoice['baddress1']; ?> <br/><strong>Unit No. :</strong> <?php echo $invoice['baddress2']; ?> <br/> <?php echo $invoice['bcountry']; ?> <br><?php echo $invoice['bpincode']; ?></p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>

<div class="modal fade" id="orderCancleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Cancel Order</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
        </div>
        <form action="<?php echo base_url(A.'/cancleOrder'); ?>" method="post">
            <input type="hidden" name="orderid" value="<?php echo $invoice['orderid']; ?>" />
            <input type="hidden" name="profileid" value="<?php echo $invoice['profileid']; ?>" />
            <input type="hidden" name="order_time" value="<?php echo $invoice['order_time']; ?>" />
            <div class="modal-body">
                <div class="form-group">
                    <label>Reson for Cancel Order</label>
                    <textarea class="form-control" placeholder="Enter Reson" name="order_cancle_reson"></textarea>
                </div>
            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">Submit</button>
            </div>
        </form>
    </div>
  </div>
</div>

<script type="text/javascript">
var site_url = "<?php echo base_url(); ?>";
var urlLink = "<?php echo A; ?>";

$("#order_status").on("change",function(){
    var orderid = $(this).attr("data-orderid");
    var mobile_no = $(this).attr("data-mobile-no");
    var profileid = $(this).attr("data-profileid");
    var val = $(this).val();
    $.ajax({
        url: site_url+urlLink+"/updateOrderStatus",
        type: 'POST',
        data: 'orderid='+orderid+'&order_status='+val,
        success: function(data){
            if(data==1)
            {
                alert("order status updated!");                
                location.reload();
            }
        },
    });
});

$('#changePaymentStatus').on('change', function () {
    ok = confirm('Mark payment as completed? You will not be able to reverse this action.');
    if(ok){
        $('#paymentStatusForm').submit();
    }else{
        $(this).val('Pending');
    }
});

</script>