<div class="page-header">
    <h3 class="page-title">
        <span class="page-title-icon bg-gradient-info text-white mr-2">
            <i class="fa fa-cubes"></i>
        </span>
        My Orders
    </h3>
</div>
<?php if($this->session->flashdata('response')!==null):?>
<div class="alert alert-<?=$this->session->flashdata('type')?> alert-dismissible fade show" role="alert">
    <?=$this->session->flashdata('response')?>
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
</div>
<?php endif?>

<div class="row">
    <div class="col-md-12 grid-margin stretch-card p-0 m-0">

        <div class="card border10 shadow">
            <div class="card-body p-3">
                <h4 class="card-title">My Order History</h4>
                <div class="table-responsive">
                    <table class="table table-borderless table-striped table-hover shadow">
                        <thead>
                            <tr>
                                <th>Order ID</th>
                                <th>Total Item</th>
                                <th>Paid Amount</th>
                                <th>Order Request</th>
                                <th>Status</th>
                                <th>Details</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if($orders !== null):?>

                            <?php foreach ($orders as $order): ?>
                            <tr>
                                <td>#<?= $order->invoice_id ?></td>
                                <td><?=$order->quantity?>/=</td>
                                <td>৳ <?=number_format($order->price-$order->blance_use + $order->shipping,2)?></td>
                                <td>
                                    <?= nice_date($order->created_at, 'd-m-y h:i:a') ?>
                                </td>
                                <td>
                                    <span
                                        class="badge <?php if($order->status == 3){echo 'badge-danger';}elseif($order->status == 1){echo 'badge-info';}elseif($order->status == 0){echo 'badge-warning';}elseif($order->status == 2){echo 'badge-success';}?>">
                                        <?php if($order->status==1):?>
                                        Approved
                                        <?php elseif($order->status==2):?>
                                        Delivered
                                        <?php elseif($order->status==0):?>
                                        Pending
                                        <?php elseif($order->status==3):?>
                                        Cancel
                                        <?php endif;?>
                                    </span>

                                </td>
                                <td>
                                    <a class="badge badge-primary"
                                        href="<?=base_url('OrderCtrl/userOrderDetails?order_id='.$order->id)?>">Details</a>
                                    <?php if($order->status==0):?>
                                    <a class="badge badge-danger"
                                        href="<?=base_url('OrderCtrl/cancel_order?order_id='.$order->id)?>"
                                        onclick="confirm('Are you sure cancel your order?')">Cancel</a>
                                    <?php endif?>
                                </td>

                            </tr>
                            <?php endforeach;?>
                            <?php endif?>

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>