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

$current_pg = 6;

$all_bonus = $basicFunctn->selectWhereDlt($user->referrer_bonus_tb, 'referrer_id', $user_logged['unique_id']);
// $full_name = explode('++', $user_logged['full_name']);
// $first_name = $full_name[0];
// $last_name = $full_name[1];
// $date_joined = explode(',', $user_logged['created_at']);

// print_r($all_investments);
// die();



?>

<body>
    <!-- BEGIN LOADER -->
    <div id="load_screen">
        <div class="loader">
            <div class="loader-content">
                <div class="spinner-grow align-self-center"></div>
            </div>
        </div>
    </div>
    <!--  END LOADER -->

    <!--  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 AREA  -->
        <div id="content" class="main-content">
            <div class="layout-px-spacing">

                <div class="row layout-spacing">

                    <!-- Content -->
                    <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 layout-top-spacing">

                        <!-- <div class="user-profile layout-spacing"> -->
                        <div class="widget-content widget-content-area">
                            <div class="table-responsive">
                                <table class="table table-hover mb-4">
                                    <thead>
                                        <tr>
                                            <th>S/N</th>
                                            <th>Transaction Id</th>
                                            <th>Investor Name</th>
                                            <th>Currency</th>
                                            <th>Amount($)</th>
                                            <th>Date Created</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php  
                                     if(count($all_bonus)>0){ 
                                    $i = 1;
                                    foreach ($all_bonus as $e) { 
                                        $coin = $basicFunctn->getDataDlt($e['coin_id'],$basicFunctn->currencies_tb);
                                        $the_user = $basicFunctn->getDataDlt($e['investor_id'],$basicFunctn->user_tb);
                                        $full_name = explode('++',$the_user['full_name']);
                                        $first_name = $full_name[0];
                                        $last_name = $full_name[1];
                                        ?>
                                        <tr>
                                            <td><?php print $i; ?></td>
                                            <td><?php print $e['unique_id']; ?></td>
                                            <td class="text-capitalize"><?php print $first_name.' '.$last_name; ?></td>
                                            <td><?php print $coin['name']; ?></td>
                                            <td><?php print $e['amt_in_usd']; ?></td>
                                            <td><?php print $e['created_at']; ?></td>
                                        </tr>
                                    <?php $i++; }
                                         } else{ ?>
                                         <tr> 
                                             <td class="text-center" colspan="10"> No Records Found </td> 
                                         </tr>
                                    <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <!-- </div> -->

                    </div>

                </div>
            </div>
            <?php require_once('footer.php'); ?>
        </div>
        <!--  END CONTENT AREA  -->
    </div>
    <?php require_once('footer-links.php'); ?>
    <script>
        $('.edit_user_btn').click(async function(e) {
            e.preventDefault();
            let edit_user_form = $('.edit_user_form').serializeArray();
            let form_data = set_form_data(edit_user_form);
            // console.log(edit_user_form);return;
            let returned = await ajaxRequest('ajax.php', form_data);
            // console.log(returned);return;
            throwSweetalert(returned, 'profile', 1);
        });
    </script>