Compare commits

..

14 Commits

7 changed files with 246 additions and 220 deletions

View File

@ -14,8 +14,15 @@ if($_SESSION["user_type"]!="admin"){
header("location: login.php?alert=Only admins allowed here!");
}
$all_orders = getAllOrder();
date_default_timezone_set('Asia/Manila');
$currentDate = date('m-d-Y');
$all_orders = getAllOrder();
$all_customers = getAllCustomers();
$all_vendors = getAllVendors();
$allSignups = array_merge($all_customers, $all_vendors);
?>
@ -107,7 +114,7 @@ date_default_timezone_set('Asia/Manila');
</div>
</li>
<li>
<a href="user-profile.html">
<a href="#">
<i class="mdi mdi-account"></i> My Profile
</a>
</li>
@ -707,8 +714,19 @@ date_default_timezone_set('Asia/Manila');
<div class="col-xl-3 col-sm-6 p-b-15 lbl-card">
<div class="card card-mini dash-card card-1">
<div class="card-body">
<h2 class="mb-1">1,503</h2>
<p>Daily Signups</p>
<?php
$signupCount = 0;
foreach ($allSignups as $signup) {
$signupDate = date('m-d-Y', strtotime($signup['createdAt']));
if ($signupDate === $currentDate) {
$signupCount++;
}
}
?>
<h2 class="mb-1"><?php echo $signupCount; ?></h2>
<!-- <h2 class="mb-1">1,503</h2> -->
<p>Today's Signups</p>
<span class="mdi mdi-account-arrow-left"></span>
</div>
</div>
@ -716,9 +734,17 @@ date_default_timezone_set('Asia/Manila');
<div class="col-xl-3 col-sm-6 p-b-15 lbl-card">
<div class="card card-mini dash-card card-2">
<div class="card-body">
<h2 class="mb-1">79,503</h2>
<p>Daily Visitors</p>
<span class="mdi mdi-account-clock"></span>
<?php
$userCount = 0;
foreach ($allSignups as $signup) {
$userCount++;
}
?>
<h2 class="mb-1"><?php echo $userCount; ?></h2>
<!-- <h2 class="mb-1">79,503</h2> -->
<p>Total Users</p>
<span class="mdi mdi-account-multiple"></span>
</div>
</div>
</div>
@ -726,18 +752,19 @@ date_default_timezone_set('Asia/Manila');
<div class="card card-mini dash-card card-3">
<div class="card-body">
<?php
$currentDate = date('m-d-Y'); // Get current date
// Get current date
$orderCount = 0; // Initialize order count
$dailyRevenue = 0;
foreach ($all_orders as $x => $val) {
foreach (array_reverse($all_orders) as $x => $val) {
$paymentStatus = strtolower($val['payment']['status']);
$returnStatus = strtolower($val['return_order']['status']);
$orderStatus = strtolower($val['status']);
$formattedOrderDate = date('m-d-Y', strtotime($val['order_date']));
if ($formattedOrderDate == $currentDate) {
$orderCount++;
if($paymentStatus == "paid"){
$dailyRevenue += $val['total_amount'];
if($paymentStatus == "paid" && (!$returnStatus || $orderStatus != "returned" )){
$dailyRevenue += $val['total_amount'];
} // Increment order count for each order on the current date
}
}
@ -745,7 +772,7 @@ date_default_timezone_set('Asia/Manila');
$finalDailyRevenue = number_format($dailyRevenue, 2, '.', ',');
?>
<h2 class="mb-1"><?php echo $orderCount; ?></h2>
<p>Today's Order</p>
<p>Today's Orders</p>
<span class="mdi mdi-package-variant"></span>
</div>
</div>
@ -766,7 +793,6 @@ date_default_timezone_set('Asia/Manila');
<!-- Sales Graph -->
<div id="user-acquisition" class="card card-default">
<div class="card-header">
<h2>Sales Report</h2>
</div>
<div class="card-body">
@ -1023,26 +1049,31 @@ date_default_timezone_set('Asia/Manila');
style="width:100%">
<thead>
<tr>
<th>Order ID</th>
<th>Payment Method</th>
<th>Customer Name</th>
<th class="d-none d-lg-table-cell">Vendor Name</th>
<th class="d-none d-lg-table-cell">Total Amount</th>
<th class="d-none d-lg-table-cell">Order Date</th>
<th>Status</th>
<th></th>
<th>Return Status</th>
</tr>
</thead>
<tbody>
<?php
$iterationCount = 0;
$ordersDisplayed = false;
foreach (array_reverse($all_orders) as $x => $val) {
$paymentStatus = strtolower($val['payment']['status']);
$formattedOrderDate = date('m-d-Y', strtotime($val['order_date']));
$orderId = $val['_id'];
$paymentMethod = $val['payment_method'];
$customerName = $val['customer'][0]['name'];
$vendorName = $val['items'][0]['vendor_name'];
$totalAmount = $val['total_amount'];
$orderStatus = strtoupper($val['status']);
$returnStatus = strtoupper($val['return_order']['status']);
$statusClass = '';
if ($orderStatus === 'UNPAID' || $orderStatus === 'RETURNED') {
@ -1059,23 +1090,34 @@ date_default_timezone_set('Asia/Manila');
}
if ($formattedOrderDate == $currentDate) {
$ordersDisplayed = true;
$displayDate = date('m-d-Y, g:i A', strtotime($val['order_date']));
?>
<tr>
<td><?php echo $orderId ?></td>
<td><?php echo $paymentMethod ?></td>
<td><?php echo $customerName ?></td>
<td><?php echo $vendorName ?></td>
<td><?php echo $totalAmount ?></td>
<td> <?php echo number_format($totalAmount, 2, '.', ',') ?></td>
<td><?php echo $displayDate ?></td>
<td><span style="color: <?php echo $statusClass; ?>"><?php echo $orderStatus ?></span></td>
<td><?php echo $returnStatus?: "NONE" ?></td>
</tr>
<?php
$iterationCount++;
if ($iterationCount >= 8) {
break;
}
$iterationCount++;
if ($iterationCount >= 8) {
break;
}
}
}
if (!$ordersDisplayed) {
?>
<tr>
<td class="align-self-center">No Recent Orders Yet.</td>
</tr>
<?php
}
?>
</tbody>
@ -1086,12 +1128,16 @@ date_default_timezone_set('Asia/Manila');
</div>
<div class="row">
<div class="col-xl-5">
<div class="col-xl-6">
<!-- New Customers -->
<div class="card ec-cust-card card-table-border-none card-default">
<div class="card-header justify-content-between ">
<?php
$weekAgoDate = date('m-d-Y', strtotime('-7 days'));
?>
<h2>New Customers</h2>
<div>
<div> From <?php echo $weekAgoDate; ?> to <?php echo $currentDate; ?></div>
<!-- <div>
<button class="text-black-50 mr-2 font-size-20">
<i class="mdi mdi-cached"></i>
</button>
@ -1106,220 +1152,139 @@ date_default_timezone_set('Asia/Manila');
<li class="dropdown-item"><a href="#">Something else here</a></li>
</ul>
</div>
</div>
</div> -->
</div>
<div class="card-body pt-0 pb-15px">
<table class="table ">
<tbody>
<?php
$iterationCount = 0;
$customersDisplayed = false;
foreach (array_reverse($all_customers) as $x => $val) {
$formattedSignupDate = date('m-d-Y', strtotime($val['createdAt']));
$imageUrl = $val['customer_image'];
$fullName = $val['first_name'] . ' ' . $val['last_name'];
$email = $val['user_email'];
if ($formattedSignupDate >= $weekAgoDate && $formattedSignupDate <= $currentDate) {
$customersDisplayed = true;
?>
<tr>
<td>
<div class="media">
<div class="media-image mr-3 rounded-circle">
<a href="profile.html"><img loading="lazy"
class="profile-img rounded-circle w-45"
src="assets/img/user/u1.jpg"
alt="customer image"></a>
<img loading="lazy"
class="profile-img rounded-circle w-45"
src="<?php echo $imageUrl !== null ? $imageUrl : 'assets/img/user/u1.jpg'; ?>"
alt="customer image">
</div>
<div class="media-body align-self-center">
<a href="profile.html">
<h6 class="mt-0 text-dark font-weight-medium">Selena
Wagner</h6>
</a>
<small>@selena.oi</small>
<h6 class="mt-0 text-dark font-weight-medium"><?php echo $fullName; ?></h6>
<small><?php echo $email; ?></small>
</div>
</div>
</td>
<td>2 Orders</td>
<td class="text-dark d-none d-md-block">$150</td>
</tr>
<tr>
<td>
<div class="media">
<div class="media-image mr-3 rounded-circle">
<a href="profile.html"><img loading="lazy"
class="profile-img rounded-circle w-45"
src="assets/img/user/u2.jpg"
alt="customer image"></a>
</div>
<div class="media-body align-self-center">
<a href="profile.html">
<h6 class="mt-0 text-dark font-weight-medium">Walter
Reuter</h6>
</a>
<small>@walter.me</small>
</div>
</div>
</td>
<td>5 Orders</td>
<td class="text-dark d-none d-md-block">$200</td>
</tr>
<tr>
<td>
<div class="media">
<div class="media-image mr-3 rounded-circle">
<a href="profile.html"><img loading="lazy"
class="profile-img rounded-circle w-45"
src="assets/img/user/u3.jpg"
alt="customer image"></a>
</div>
<div class="media-body align-self-center">
<a href="profile.html">
<h6 class="mt-0 text-dark font-weight-medium">Larissa
Gebhardt</h6>
</a>
<small>@larissa.gb</small>
</div>
</div>
</td>
<td>1 Order</td>
<td class="text-dark d-none d-md-block">$50</td>
</tr>
<tr>
<td>
<div class="media">
<div class="media-image mr-3 rounded-circle">
<a href="profile.html"><img loading="lazy"
class="profile-img rounded-circle w-45"
src="assets/img/user/u4.jpg"
alt="customer image"></a>
</div>
<div class="media-body align-self-center">
<a href="profile.html">
<h6 class="mt-0 text-dark font-weight-medium">Albrecht
Straub</h6>
</a>
<small>@albrech.as</small>
</div>
</div>
</td>
<td>2 Orders</td>
<td class="text-dark d-none d-md-block">$100</td>
</tr>
<tr>
<td>
<div class="media">
<div class="media-image mr-3 rounded-circle">
<a href="profile.html"><img loading="lazy"
class="profile-img rounded-circle w-45"
src="assets/img/user/u5.jpg"
alt="customer image"></a>
</div>
<div class="media-body align-self-center">
<a href="profile.html">
<h6 class="mt-0 text-dark font-weight-medium">Leopold
Ebert</h6>
</a>
<small>@leopold.et</small>
</div>
</div>
</td>
<td>1 Order</td>
<td class="text-dark d-none d-md-block">$60</td>
</tr>
<tr>
<td>
<div class="media">
<div class="media-image mr-3 rounded-circle">
<a href="profile.html"><img loading="lazy"
class="profile-img rounded-circle w-45"
src="assets/img/user/u3.jpg"
alt="customer image"></a>
</div>
<div class="media-body align-self-center">
<a href="profile.html">
<h6 class="mt-0 text-dark font-weight-medium">Larissa
Gebhardt</h6>
</a>
<small>@larissa.gb</small>
</div>
</div>
</td>
<td>1 Order</td>
<td class="text-dark d-none d-md-block">$50</td>
<td><?php echo $formattedSignupDate?></td>
</tr>
<?php
$iterationCount++;
if ($iterationCount >= 8) {
break;
}
}
}
if (!$customersDisplayed) {
?>
<tr>
<td class="align-self-center">No new customers in the past week</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-xl-7">
<!-- Top Products -->
<div class="card card-default ec-card-top-prod">
<div class="card-header justify-content-between">
<h2>Top Products</h2>
<div>
<button class="text-black-50 mr-2 font-size-20"><i
class="mdi mdi-cached"></i></button>
<div class="col-xl-6">
<!-- New Customers -->
<div class="card ec-cust-card card-table-border-none card-default">
<div class="card-header justify-content-between ">
<?php
$weekAgoDate = date('m-d-Y', strtotime('-7 days'));
?>
<h2>New Vendors</h2>
<div> From <?php echo $weekAgoDate; ?> to <?php echo $currentDate; ?></div>
<!-- <div>
<button class="text-black-50 mr-2 font-size-20">
<i class="mdi mdi-cached"></i>
</button>
<div class="dropdown show d-inline-block widget-dropdown">
<a class="dropdown-toggle icon-burger-mini" href="#" role="button"
id="dropdown-product" data-bs-toggle="dropdown" aria-haspopup="true"
id="dropdown-customar" data-bs-toggle="dropdown" aria-haspopup="true"
aria-expanded="false" data-display="static">
</a>
<ul class="dropdown-menu dropdown-menu-right">
<li class="dropdown-item"><a href="#">Update Data</a></li>
<li class="dropdown-item"><a href="#">Detailed Log</a></li>
<li class="dropdown-item"><a href="#">Statistics</a></li>
<li class="dropdown-item"><a href="#">Clear Data</a></li>
<li class="dropdown-item"><a href="#">Action</a></li>
<li class="dropdown-item"><a href="#">Another action</a></li>
<li class="dropdown-item"><a href="#">Something else here</a></li>
</ul>
</div>
</div>
</div> -->
</div>
<div class="card-body mt-10px mb-10px py-0">
<div class="row media d-flex pt-15px pb-15px">
<div
class="col-lg-3 col-md-3 col-2 media-image align-self-center rounded">
<a href="#"><img loading="lazy" src="assets/img/products/p1.jpg" alt="customer image"></a>
</div>
<div class="col-lg-9 col-md-9 col-10 media-body align-self-center ec-pos">
<a href="#">
<h6 class="mb-10px text-dark font-weight-medium">Baby cotton shoes</h6>
</a>
<p class="float-md-right sale"><span class="mr-2">58</span>Sales</p>
<p class="d-none d-md-block">Statement belting with double-turnlock hardware
adds “swagger” to a simple.</p>
<p class="mb-0 ec-price">
<span class="text-dark">$520</span>
<del>$580</del>
</p>
</div>
</div>
<div class="row media d-flex pt-15px pb-15px">
<div
class="col-lg-3 col-md-3 col-2 media-image align-self-center rounded">
<a href="#"><img loading="lazy" src="assets/img/products/p2.jpg" alt="customer image"></a>
</div>
<div class="col-lg-9 col-md-9 col-10 media-body align-self-center ec-pos">
<a href="#">
<h6 class="mb-10px text-dark font-weight-medium">Hoodies for men</h6>
</a>
<p class="float-md-right sale"><span class="mr-2">20</span>Sales</p>
<p class="d-none d-md-block">Statement belting with double-turnlock hardware
adds “swagger” to a simple.</p>
<p class="mb-0 ec-price">
<span class="text-dark">$250</span>
<del>$300</del>
</p>
</div>
</div>
<div class="row media d-flex pt-15px pb-15px">
<div
class="col-lg-3 col-md-3 col-2 media-image align-self-center rounded">
<a href="#"><img loading="lazy" src="assets/img/products/p3.jpg" alt="customer image"></a>
</div>
<div class="col-lg-9 col-md-9 col-10 media-body align-self-center ec-pos">
<a href="#">
<h6 class="mb-10px text-dark font-weight-medium">Long slive t-shirt</h6>
</a>
<p class="float-md-right sale"><span class="mr-2">10</span>Sales</p>
<p class="d-none d-md-block">Statement belting with double-turnlock hardware
adds “swagger” to a simple.</p>
<p class="mb-0 ec-price">
<span class="text-dark">$480</span>
<del>$654</del>
</p>
</div>
</div>
<div class="card-body pt-0 pb-15px">
<table class="table ">
<tbody>
<?php
$iterationCount = 0;
$vendorsDisplayed = false;
foreach (array_reverse($all_vendors) as $x => $val) {
$formattedSignupDate = date('m-d-Y', strtotime($val['createdAt']));
$imageUrl = $val['vendor_image'];
$shopName = $val['user_login'];
$fullName = $val['first_name'] . ' ' . $val['last_name'];
$email = $val['user_email'];
if ($formattedSignupDate >= $weekAgoDate && $formattedSignupDate <= $currentDate) {
$vendorsDisplayed = true;
?>
<tr>
<td>
<div class="media">
<div class="media-image mr-3 rounded-circle">
<img loading="lazy"
class="profile-img rounded-circle w-45"
src="<?php echo $imageUrl !== null ? $imageUrl : 'assets/img/user/u1.jpg'; ?>"
alt="customer image">
</div>
<div class="media-body align-self-center">
<h6 class="mt-0 text-dark font-weight-medium"><?php echo $shopName; ?></h6>
<small><?php echo $fullName; ?> || </small>
<small><?php echo $email; ?></small>
</div>
</div>
</td>
<td><?php echo $formattedSignupDate?></td>
</tr>
<?php
$iterationCount++;
if ($iterationCount >= 8) {
break;
}
}
}
if (!$vendorsDisplayed) {
?>
<tr>
<td class="align-self-center">No new vendors in the past week</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
@ -1333,7 +1298,7 @@ date_default_timezone_set('Asia/Manila');
<p>
Copyright &copy; <span id="ec-year"></span><a class="text-primary"
href="https://themeforest.net/user/ashishmaraviya" target="_blank"> Ekka Admin Dashboard</a>. All Rights Reserved.
</p>
</p>
</div>
</footer>

View File

@ -14,7 +14,7 @@ if ($_SESSION["user_type"] != "admin") {
header("location: login.php?alert=Only admins allowed here!");
}
$orders = getAllOrder();
$allorders = json_encode($orders, true);
// $allorders = json_encode($orders, true);
?>
<!DOCTYPE html>
@ -24,9 +24,9 @@ $allorders = json_encode($orders, true);
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Ekka - Admin Dashboard HTML Template.">
<meta name="description" content="oBanana B2B - Admin Dashboard">
<title>Ekka - Admin Dashboard HTML Template.</title>
<title>oBanana B2B - Admin Dashboard</title>
<!-- GOOGLE FONTS -->
<link rel="preconnect" href="https://fonts.googleapis.com">
@ -82,7 +82,8 @@ $allorders = json_encode($orders, true);
<table id="responsive-data-table" class="table" style="width:100%">
<thead>
<tr>
<th>Date</th>
<th>Updated Date</th>
<th>Order Date</th>
<th>Customer</th>
<th>Vendor</th>
<th>Product</th>
@ -102,6 +103,7 @@ $allorders = json_encode($orders, true);
?>
<tr>
<td><?php echo date('Y-m-d', strtotime($order['updatedAt'])) ?></td>
<td><?php echo date('Y-m-d', strtotime($order['order_date'])) ?></td>
<td><?php echo $order['customer'][0]['name'] ?></td>
<td><?php echo $order['items'][0]['vendor_name'] ?></td>
<td><?php echo $order['items'][0]['product']['name'] ?></td>

View File

@ -2010,3 +2010,48 @@ function updatePayout($token, $payoutId)
return $response;
}
function getAllCustomers ()
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://" . $_SESSION["data_endpoint"] . "/api/v1/customers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'X-Api-Key: {{apiKey}}'
),
));
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response, true);
return $json;
}
function getAllVendors ()
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://" . $_SESSION["data_endpoint"] . "/api/v1/vendors",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'X-Api-Key: {{apiKey}}'
),
));
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response, true);
return $json;
}

View File

@ -112,9 +112,6 @@ $_SESSION["isVendor"] = false;
<input type="password" name="password" placeholder="Enter your password" required />
</span>
<p><input type="checkbox" required> I accept this Terms & Conditions and Privacy Policy </p>
<span class="ec-login-wrap ec-login-fp">
<label><a href="#">Forgot Password?</a></label>
</span>
<span class="ec-login-wrap ec-login-btn">
<button class="btn btn-primary" type="submit">Register</button>
</span>

View File

@ -19,6 +19,11 @@ if ($_SESSION["userId"] <> "") {
$_SESSION["isLoggedIn"] = false;
header("location: login.php");
}
if ($_SESSION["isCustomer"] == true) {
header("location: user-profile.php");
}
$products = productList();
?>
<!--=========================================================

View File

@ -15,6 +15,11 @@ if ($_SESSION["userId"] <> "") {
$_SESSION["isLoggedIn"] = false;
header("location: login.php");
}
if ($_SESSION["isCustomer"] == true) {
header("location: user-profile.php");
}
if (isset($_GET['id'])) {
$_SESSION['vendorOrderId'] = $_GET['id'];
}

View File

@ -211,9 +211,16 @@ $vendorPayoutData = json_decode($response, true);
$vendorResponse = getVendorbyId($vendorId);
$vendorInformation = json_decode($vendorResponse, true);
$bankAccountNumber = $vendorInformation['bank_acount_details'][0]['bank_account_number'];
$bankDetails = $vendorInformation['bank_acount_details'];
foreach ($bankDetails as $details) {
if ($details['bank_payout'] === true) {
$bankName = $details['bank_name'];
$bankAccountNumber = $details['bank_account_number'];
}
}
$bankNumEnding = substr($bankAccountNumber, -3);
?>
Receipient: Philippine National Bank (PNB) Account ending in <?php echo $bankNumEnding?>
Receipient: <?php echo $bankName; ?> Account ending in <?php echo $bankNumEnding?>
</div>
</div>
</div>