<?php
$title = 'Overview';
require_once('header-links.php');
// require_once('../admin/lib/table-traits.php'); 
// require_once('../admin/lib/basic-function.php'); 
// require_once('../admin/lib/user-functions.php'); 

$current_pg = 1;

// $all_deposits = $basicFunctn->selectWhereDlt($basicFunctn->transaction_tb,'user_id',$user_logged['unique_id']);
$purchases = $basicFunctn->selectWhere($basicFunctn->purchase_tb, 'user_id', $user_logged['unique_id']);


?>

<body>

    <!--  BEGIN NAVBAR  -->
    <?php require_once('header.php'); ?>
    <!--  END NAVBAR  -->

    <!--  BEGIN MAIN CONTAINER  -->
    <div class="main-container" id="container">

        <div class="overlay"></div>
        <div class="search-overlay"></div>

        <!--  BEGIN SIDEBAR  -->
        <?php require_once('sidebar.php'); ?>
        <!--  END SIDEBAR  -->

        <!--  BEGIN CONTENT PART  -->
        <div id="content" class="main-content">
            <div class="layout-px-spacing">
                <div class="row layout-top-spacing">
                    <div class="col-md-6 flex flex-col gap-4">

                        <div style="padding: 2px 32px;" class="widget widget-card-four">
                            <div class="widget-content">
                                <div class="w-content ">
                                    <div class="p-auto">
                                        <div class="s-icon icon-red">
                                            <i class="bx bx-wallet-alt"></i>
                                        </div>
                                    </div>
                                    <div class="s-info">
                                        <h6 class="value"><?php print number_format($wallet->get_balance($user_logged['unique_id'])); ?> $</h6>
                                        <hp>Account Balance</hp>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div style="padding: 2px 32px;margin-top: 5px;" class="widget widget-card-four">
                            <div class="widget-content">
                                <div class="w-content ">
                                    <div class="p-auto">
                                        <div class="s-icon icon-yellow">
                                            <i class="bx bx-purchase-tag"></i>
                                        </div>
                                    </div>
                                    <div class="s-info">
                                        <h6 class="value"> <?php print number_format($purchase->total_purchase_amount($user_logged['unique_id'])); ?> $</h6>
                                        <hp>Total Orders</hp>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-6 flex flex-col gap-4">
                        <div style="padding: 2px 32px;" class="widget widget-card-four">
                            <div class="widget-content">
                                <div class="w-content ">
                                    <div class="p-auto">
                                        <div class="s-icon icon-violet">
                                            <i class="bx bx-credit-card-alt"></i>
                                        </div>
                                    </div>
                                    <div class="s-info">
                                        <h6 class="value"> <?php print number_format($purchase->pending_purchase_amount($user_logged['unique_id'])); ?> $</h6>
                                        <hp>Pending Orders</hp>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <a href="deposit">
                            <div style="padding: 2px 32px;margin-top: 3notpx;" class="widget widget-card-four">
                                <div class="widget-content">
                                    <div class="w-content ">
                                        <div class="p-auto">
                                            <div class="s-icon icon-purple">
                                                <i class="bx bx-wallet"></i>
                                            </div>
                                        </div>
                                        <div class="s-info">
                                            <!-- <h6 class="value">$ 45,141</h6> -->
                                            <h6>My Wallet</h6>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </a>
                    </div>
                </div>


                <div class="widget-content searchable-container grid">
                    
                    <!-- <div class="row">
                        <div class="col-xl-4 col-lg-5 col-md-5 col-sm-7 filtered-list-search layout-spacing align-self-center">
                            <form class="form-inline my-2 my-lg-0">
                                <div class="">
                                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search">
                                        <circle cx="11" cy="11" r="8"></circle>
                                        <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
                                    </svg>
                                    <input type="text" class="form-control product-search" id="input-search" placeholder="Search Deposits...">
                                </div>
                            </form>
                        </div>

                        <div class="col-xl-8 col-lg-7 col-md-7 col-sm-5 text-sm-right text-center layout-spacing align-self-center">
                            <div class="d-flex justify-content-sm-end justify-content-center">

                                <div class="switch align-self-center">
                                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-list view-list active-view">
                                        <line x1="8" y1="6" x2="21" y2="6"></line>
                                        <line x1="8" y1="12" x2="21" y2="12"></line>
                                        <line x1="8" y1="18" x2="21" y2="18"></line>
                                        <line x1="3" y1="6" x2="3" y2="6"></line>
                                        <line x1="3" y1="12" x2="3" y2="12"></line>
                                        <line x1="3" y1="18" x2="3" y2="18"></line>
                                    </svg>
                                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-grid view-grid">
                                        <rect x="3" y="3" width="7" height="7"></rect>
                                        <rect x="14" y="3" width="7" height="7"></rect>
                                        <rect x="14" y="14" width="7" height="7"></rect>
                                        <rect x="3" y="14" width="7" height="7"></rect>
                                    </svg>
                                </div>
                            </div>

                        </div>
                    </div> -->

                    <div class="searchable-items grid">
                        <div class="items items-header-section">
                            <div class="item-content">
                                <div class=" text-left">
                                    <h4>Order ID</h4>
                                </div>
                                <div class="user-email text-left">
                                    <h4>Product</h4>
                                </div>
                                <div class="user-email text-left">
                                    <h4>Purchase Time</h4>
                                </div>
                                <div class="user-location text-left">
                                    <h4 style="margin-left: 0;">Status</h4>
                                </div>
                                <div class="user-phone text-left">
                                    <h4 style="margin-left: 3px;">Amount</h4>
                                </div>
                            </div>
                        </div>
                        <?php foreach ($purchases as $e) {
                            $product = ($basicFunctn->selectWhere($basicFunctn->product_tb, 'unique_id', $e['product_id'])[0]);
                            $subcategory = ($basicFunctn->selectWhere($user->subcategory_tb, 'unique_id', $product['subcategory_id']))[0]; ?>

                            <div class="items">
                                <div class="item-content  text-center">
                                    <div class="user-profile">
                                        <div class="user-meta-info text-center">

                                            <p class="user-work" data-occupation="Web Developer">
                                                <i style="font-size: 16px;" class="bx bx-radio-circle-marked"></i>
                                                &nbsp;<?php print $e['unique_id']; ?>
                                            </p>
                                        </div>
                                    </div>
                                    <div class="user-email text-center">
                                        <p class="info-title">Product: </p>
                                        <p class="usr-email-addr text-capitalize" data-email="alan@mail.com"><?php print $subcategory['name']; ?></p>
                                    </div>
                                    <div class="user-email text-center">
                                        <p class="info-title">Time: </p>
                                        <p class="usr-email-addr" data-email="alan@mail.com"><?php print $e['created_at']; ?></p>
                                    </div>
                                    <div class="user-location text-center">
                                        <p class="info-title">Status: </p>
                                        <p class="usr-location text-capitalize" data-location="Boston, USA">
                                            <?php if ($e['status'] == 'pending') { ?>
                                                <span class="text-warning">
                                                    <?php print $e['status']; ?>
                                                </span>
                                            <?php } elseif ($e['status'] == 'confirmed') { ?>
                                                <span class="text-success">
                                                    <?php print $e['status']; ?>
                                                </span>
                                            <?php } elseif ($e['status'] == 'completed') { ?>
                                                <span class="text-danger">
                                                    <?php print $e['status']; ?>
                                                </span>
                                            <?php } ?>
                                        </p>
                                    </div>
                                    <div class="user-phone text-center">
                                        <p class="info-title">Amount: </p>
                                        <p class="usr-ph-no" data-phone="+1 (070) 123-4567"> $<?php print $product['price']; ?></p>
                                    </div>
                                </div>
                            </div>
                        <?php } ?>
                    </div>

                </div>

            </div>

            <?php require_once('footer.php'); ?>
        </div>
        <!--  END CONTENT PART  -->
    </div>
    <?php require_once('footer-links.php'); ?>