<link rel="stylesheet" href="<?php echo base_url(); ?>assets/ecommerce/scss/style.css" />
<div class="user-profile mt-5 mb-5">
    <div class="container">
        <div class="row justify-content-between">
            <div class="col-lg-12">
                <div class="alert alert-success alert-dismissible" role="alert" <?php if($this->session->flashdata('message')==''){ ?> style="display:none" <?php } ?> >
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                    <?php echo $this->session->flashdata('message'); ?>
                </div>
                <div class="alert alert-danger alert-dismissible" role="alert" <?php if($this->session->flashdata('emessage')==''){ ?> style="display:none" <?php } ?> >
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                    <?php echo $this->session->flashdata('emessage'); ?>
                </div>
            </div>
        </div>
        <div class="row justify-content-between ">
            <div class="col-lg-5 col-md-5 col-12 px-lg-5 account-sidebar">
                <?php $ad['active']=2; $this->load->view('user-sidebar',$ad); ?>
            </div>
            <div class="col-lg-7 col-md-7 col-12 px-md-5">
              <div class="order-history">
                <div class="row align-items-center">
                    <div class="col-12">
                        <div class="address-card mb-3">
                          <div class="address-card-header">
                            <div class="row">
                              <div class="col-lg-5 col-md-5 col-sm-5">
                                <p><?php echo "#".$invoice['orderid']; ?></p>
                              </div>
                              <div class="col-lg-7 col-md-7 col-sm-7">
                                <p class="text-end">
                                  Order Placed: <?php echo date("d M Y",strtotime($invoice['order_time'])); ?>
                                </p>
                              </div>
                            </div>
                          </div>
                          <?php $order_status = $this->config->item("order_status"); ?>
                          <div class="address-card-body d-flex align-items-center justify-content-between">
                            <div class="info-user pt-2 w-100">
                                <div class="more-info-user pt-3">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <h4>Shiping Details</h4>
                                            <p class="mb-1">Name : <?php echo $invoice['bname']; ?></p>
                                            <p class="mb-1">Email : <?php echo $invoice['bemail']; ?></p>
                                            <!-- <p class="mb-1">Mobile No. : <?php //echo $invoice['bmobile_no']; ?></p> -->
                                            <p class="mb-1">Address : <?php echo $invoice['baddress1']; ?></p>
                                            <p class="mb-1">Unit No. : <?php echo $invoice['baddress2']; ?></p>
                                            <!-- <p class="mb-1">Country : <?php //echo $invoice['bcountry']; ?></p> -->
                                            <!-- <p class="mb-1">City : <?php //echo $invoice['bcity']; ?></p>
                                            <p class="mb-1">State : <?php //echo $invoice['bstate']; ?></p> -->
                                            <p class="mb-1">Pincode : <?php echo $invoice['bpincode']; ?></p>
                                        </div>
                                        <div class="col-md-6">
                                            <h4>Payment Method</h4>
                                            <p>
                                                <?php if($invoice['payment_method']==1 || $invoice['payment_method']=='COD'){ ?>
                                                    Cash On Delivery.
                                                <?php } ?>
                                                <?php if($invoice['payment_method']==2 || $invoice['payment_method']=='paynow'){ ?>
                                                    PayNow (Txnid - <?php echo $invoice['txn_id']; ?>).
                                                    <?php if($invoice['payment_status']=='Pending'){ ?>
                                                            Your payment confirmation under process
                                                    <?php } ?>
                                                <?php } ?>
                                                <?php if($invoice['payment_method']==3 || $invoice['payment_method']=='omise'){ ?>
                                                    Omise  (Txnid - <?php echo $invoice['txn_id']; ?>).
                                                <?php } ?>
                                            </p>
                                            <h4>Order Status</h4>
                                            <p><?php echo (array_key_exists($invoice['order_status'], $order_status)?$order_status[$invoice['order_status']]:""); ?></p>
                                        </div>
                                    </div>
                                </div>
                                <hr>
                                <div class="table-content tabl-bder table-responsive">
                                    <table class="table table-hover">
                                        <thead>
                                            <tr>
                                                <th class="no-print">Image</th>
                                                <th class="print-size" style="width:300px;">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']; 
                                                        }
                                                        $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: 50px;" class="no-print">
                                                        <img src="<?php echo base_url($value['product_photos']); ?>" style=" width:50px;">
                                                    </td>
                                                    <td>
                                                        <?php echo $value['product_name']; ?>
                                                    </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 echo $value['qty']; ?>
                                                    </td>
                                                    <?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 } ?>
                                                </tr>
                                            <?php endforeach; } ?>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="grand-total-wrap">
                                    <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>
                                            <td>Coupon (<?php echo $invoice['coupon_code']; ?>)</td>
                                            <?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>
                                                <td style="width:50%">Suntexnology Discount :</td>
                                                <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%">Delivery 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>
                                                <td style="width:50%">Birthday Month Discount :</td>
                                                <td>
                                                    -$ <?php echo number_format($invoice['birthday_discount'],2); ?>
                                                </td>
                                            </tr> 
                                        <? } ?>
                                        <?php if(isset($invoice['use_coins_amount']) && $invoice['use_coins_amount']>0){ ?>
                                           <tr>
                                                <td style="width:50%">Redemption Voucher :</td>
                                                <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>
                                            <th>Grand Total:</th>
                                            <?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>
        </div>
    </div>
</div>
<!-- orders1 end -->