<?php
include 'back/auth-core.php';
include 'back/admin-core.php';
//include 'back/transaction-status.php';
?>
<!DOCTYPE html>
<html dir="ltr">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <!-- Favicon -->
    <link rel="apple-touch-icon" sizes="180x180" href="app-assets/favicon/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="app-assets/favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="app-assets/favicon/favicon-16x16.png">
    <link rel="manifest" href="app-assets/favicon/site.webmanifest.txt">
    <link rel="mask-icon" href="app-assets/favicon/safari-pinned-tab.svg" color="#0010f7">
    <meta name="msapplication-TileColor" content="#0010f7">
    <meta name="theme-color" content="#ffffff">

    <!-- Font -->
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&amp;display=swap" rel="stylesheet" />

    <!-- Plugin -->
    <link rel="stylesheet" type="text/css" href="app-assets/css/plugin/swiper-bundle.min.css">
    <link rel="stylesheet" type="text/css" href="app-assets/icons/iconly/index.min.css">
    <link rel="stylesheet" type="text/css" href="app-assets/icons/remix-icon/index.min.css">
    <link rel="stylesheet" type="text/css" href="app-assets/css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="app-assets/css/colors.css">

    <!-- Base -->
    <link rel="stylesheet" type="text/css" href="app-assets/css/base/typography.css">
    <link rel="stylesheet" type="text/css" href="app-assets/css/base/base.css">

    <!-- Theme -->
    <link rel="stylesheet" type="text/css" href="app-assets/css/theme/colors-dark.css">
    <link rel="stylesheet" type="text/css" href="app-assets/css/theme/theme-dark.css">
    <link rel="stylesheet" type="text/css" href="app-assets/css/custom-rtl.css">

    <!-- Layouts -->
    <link rel="stylesheet" type="text/css" href="app-assets/css/layouts/sider.css">
    <link rel="stylesheet" type="text/css" href="app-assets/css/layouts/header.css">
    <link rel="stylesheet" type="text/css" href="app-assets/css/layouts/page-content.css">
    <link rel="stylesheet" type="text/css" href="app-assets/css/components.css">
    <!-- Customizer -->
    <link rel="stylesheet" type="text/css" href="app-assets/css/layouts/customizer.css">

    <!-- Custom -->
    <link rel="stylesheet" type="text/css" href="assets/css/style.css">

    <title> Commissions </title>

</head>

<body >
    <main class="hp-bg-color-dark-90 d-flex min-vh-100">
        <?php include 'aside.php'; ?>

        <div class="hp-main-layout">
            <?php include 'top-nav.php'; ?>
            <?php include 'mobile-nav.php'; ?>

            <div class="hp-main-layout-content">
                <div class="row mb-32 gy-32">

                  <div class="col-12">
                      <div class="row align-items-center justify-content-between g-24">
                          <div class="col-12 col-md-6">
                              <h3> Commissions </h3>
                          </div>

                      </div>
                  </div>

                  <div class="col-12">
                      <div class="row g-32">
                          <div class="col-6 col-md-6 col-xl-6">
                              <div class="card">
                                  <div class="card-body">
                                      <div class="row g-16">
                                          <div class="col-6 hp-flex-none w-auto">
                                              <div class="avatar-item d-flex align-items-center justify-content-center avatar-lg bg-primary-4 hp-bg-color-dark-primary rounded-circle">
                                                  <i class="iconly-Light-People text-primary hp-text-color-dark-primary-2" style="font-size: 24px;"></i>
                                              </div>
                                          </div>

                                          <div class="col">
                                              <h3 class="mb-4 mt-8"> 0 </h3>
                                              <p class="hp-p1-body mb-0 text-black-80 hp-text-color-dark-30"> Total Paid Commission </p>
                                          </div>
                                      </div>
                                  </div>
                              </div>
                          </div>

                          <div class="col-6 col-md-6 col-xl-6">
                              <div class="card">
                                  <div class="card-body">
                                      <div class="row g-16">
                                          <div class="col-6 hp-flex-none w-auto">
                                              <div class="avatar-item d-flex align-items-center justify-content-center avatar-lg bg-primary-4 hp-bg-color-dark-primary rounded-circle">
                                                  <i class="iconly-Light-Category text-primary hp-text-color-dark-primary-2" style="font-size: 24px;"></i>
                                              </div>
                                          </div>

                                          <div class="col">
                                              <h3 class="mb-4 mt-8">NGN 0.00 </h3>
                                              <p class="hp-p1-body mb-0 text-black-80 hp-text-color-dark-30"> Paid Commssions </p>
                                          </div>
                                      </div>
                                  </div>
                              </div>
                          </div>

                      </div>
                  </div>

                  <div class="col-12">
                      <div class="hp-faq-tabs bg-white hp-bg-dark-100 rounded py-12 px-24">
                          <ul class="nav nav-pills hp-overflow-x-auto flex-nowrap">
                              <li class="nav-item me-4">
                                  <a class="nav-link py-4 <?php if($status=='SUCCESS') { echo 'active';} ?>" href="commissions.php?status=SUCCESS" >
                                      <span class="d-flex align-items-center">
                                          Paid
                                      </span>
                                  </a>
                              </li>

                              <li class="nav-item me-4">
                                  <a class="nav-link py-4 <?php if($status=='PENDING') { echo 'active';} ?>" href="commissions.php?status=PENDING" >
                                      <span class="d-flex align-items-center">
                                           Unpaid
                                      </span>
                                  </a>
                              </li>
                          </ul>
                      </div>
                  </div>

                  <div class="col-12">
                      <div class="card">
                          <div class="card-body">
                              <div class="row justify-content-between">
                                  <div class="col pe-md-32 pe-md-120">
                                      <h4> Commissions </h4>
                                  </div>

                                  <div class="col-12 mt-16 table-responsive">
                                      <table class="table table-hover table-striped">
                                          <thead>
                                              <tr>
                                                  <th scope="col"> Property ID </th>
                                                  <th scope="col"> Tenant Name </th>
                                                  <th scope="col"> Email </th>
                                                  <th scope="col"> Phone </th>
                                                  <th scope="col"> Rent </th>
                                                  <th scope="col"> Transaction ID </th>
                                                  <th scope="col"> Commmission </th>
                                                  <th scope="col"> Agent Name </th>
                                                  <th scope="col"> Status </th>
                                              </tr>
                                          </thead>
                                          <tbody>
                                            <?php
                                               if($page_total>0) {
                                                 foreach($transaction_results as $singleTransaction) {

                                                   $TransactionID =  $singleTransaction['id'];
                                                   $TransactionReference =  $singleTransaction['reference'];
                                                   $merchantName =  $singleTransaction['merchantName'];
                                                   $merchantEmail =  $singleTransaction['merchantEmail'];
                                                   $amountNGN =  $singleTransaction['amountNGN'];
                                                   $amountRMD =  $singleTransaction['amountRMB'];
                                                   $amountUSD =  $singleTransaction['amountUSD'];
                                                   $paymentType =  $singleTransaction['paymentType'];
                                                   $customerEmail =  $singleTransaction['customerEmail'];
                                                   $transactionStatus =  $singleTransaction['status'];
                                                   $expires =  $singleTransaction['expires'];
                                                   $created =  $singleTransaction['created'];
                                                   $updated =  $singleTransaction['updated'];

                                                   $expires = date('D d M h:ia', strtotime($expires));
                                                   $created = date('D d M h:ia', strtotime($created));
                                                   $updated = date('D d M h:ia', strtotime($updated));

                                                   echo '
                                                    <tr>
                                                      <td> '.$merchantName.' </td>
                                                      <td> '.$merchantEmail.' </td>
                                                      <td> '.$customerEmail.' </td>
                                                      <td> NGN '.$amountNGN.' </td>
                                                      <td><a href="transaction-data.php?ref='.$TransactionID.'">'.$TransactionID.' </a> </td>
                                                      <td> '.$updated.' </td>
                                                    </tr>
                                                    ';

                                                 }
                                               }else {
                                                 echo '<tr>
                                                         <td colspan="9" style="text-align:center"> No Data Available </td>
                                                       </tr>';
                                               }
                                            ?>
                                          </tbody>
                                      </table>
                                  </div>
                                  </div>
                              </div>
                          </div>
                      </div>
                  </div>


                </div>
            </div>

        </div>
    </main>

    <?php include 'theme.php'; ?>

    <div class="scroll-to-top">
        <button type="button" class="btn btn-primary btn-icon-only rounded-circle hp-primary-shadow">
            <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" height="16px" width="16px" xmlns="http://www.w3.org/2000/svg">
                <g>
                    <path fill="none" d="M0 0h24v24H0z"></path>
                    <path d="M13 7.828V20h-2V7.828l-5.364 5.364-1.414-1.414L12 4l7.778 7.778-1.414 1.414L13 7.828z"></path>
                </g>
            </svg>
        </button>
    </div>

    <!-- Plugin -->
    <script src="app-assets/js/plugin/jquery.min.js"></script>
    <script src="app-assets/js/plugin/bootstrap.bundle.min.js"></script>
    <script src="app-assets/js/plugin/swiper-bundle.min.js"></script>
    <script src="app-assets/js/plugin/jquery.mask.min.js"></script>
    <script src="app-assets/js/plugin/autocomplete.min.js"></script>
    <script src="app-assets/js/plugin/moment.min.js"></script>

    <!-- Layouts -->
    <script src="app-assets/js/layouts/header-search.js"></script>
    <script src="app-assets/js/layouts/sider.js"></script>
    <script src="app-assets/js/components/input-number.js"></script>

    <!-- Base -->
    <script src="app-assets/js/base/index.js"></script>
    <!-- Customizer -->
    <script src="app-assets/js/customizer.js"></script>

    <!-- Custom -->
    <script src="assets/js/main.js"></script>
</body>

</html>
