<link rel="stylesheet" href="<?= base_url('assets/css/bootstrap-min.css') ?>">
<link rel="stylesheet" href="<?= base_url('assets/css/bootstrap-formhelpers-min.css') ?>" media="screen">
<link rel="stylesheet" href="<?= base_url('assets/css/bootstrapValidator-min.css') ?>" />
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" />
<link rel="stylesheet" href="<?= base_url('assets/css/bootstrap-side-notes.css') ?>" />
<style type="text/css">
.col-centered {
    display: inline-block;
    float: none;
    text-align: left;
    margin-right: -4px;
}

.row-centered {
    margin-left: 9px;
    margin-right: 9px;
}
</style>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<section class="h-100 new-bg py-5">
    <div class="container">
        <div class="row row-centered">

            <div class="col-md-12 mx-auto">
                <div class="page-header">
                    <h2 class="best-mobile2-title gdfg">
                        My Orders
                    </h2>
                </div>

                <fieldset>

                    <table class="table">
                        <thead>
                            <tr>
                                <th scope="col">Order ID</th>
                                <th scope="col">Products</th>
                                <th scope="col">Amount Paid</th>
                                <th scope="col">Order Date</th>
                                <th scope="col">Status</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                                foreach($orders as $key => $order) {
                            ?>
                            <tr>
                                <td><?=$order['orderId']?></td>
                                <td>
                                    <?php
                                        $count = 1;
                                        foreach($order['orderedProducts'] as $id => $product) {
                                    ?>
                                    <?=$count?>: <a href="<?=base_url()?>site/productdetails/<?=$product['id']?>"><?=$product['name']?></a><br><br>
                                    <?php
                                        $count++; }
                                    ?>
                                </td>
                                <td>$<?=$order['totalAmount']?></td>
                                <td><?=date('Y-m-d', $order['orderDate'])?></td>
                                <td><?=$order['orderStatus']?></td>
                            </tr>
                            <?php
                                }
                            ?>
                        </tbody>
                    </table>
                </fieldset>
            </div>
        </div>
    </div>
</section>