jun-branch #45
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
$_SESSION["is_test"]=false;
|
||||
$_SESSION["test_email_rcpt"]="";
|
||||
$_SESSION["is_test"]=true;
|
||||
$_SESSION["test_email_rcpt"]="junjihadbarroga@gmail.com";
|
||||
$_SESSION["sales_email"]="sales@obanana.com";
|
||||
$_SESSION["data_endpoint"]="api.obanana.com";
|
||||
$_SESSION["data_endpoint"]="api.obanana.shop";
|
||||
$_SESSION["transfer_fee"]=0.02;
|
||||
if ($_SESSION["is_test"]){
|
||||
$_SESSION["obpay"]="web.obanana.io/test";
|
||||
$_SESSION["obpay_gate"]="gate.obanana.io/api";
|
||||
|
|
|
@ -117,7 +117,7 @@ if($_SESSION["user_type"]!="admin"){
|
|||
<a href="javascript:0"> <i class="mdi mdi-settings-outline"></i> Setting </a>
|
||||
</li>
|
||||
<li class="dropdown-footer">
|
||||
<a href="/logout.php"> <i class="mdi mdi-logout"></i> Log Out </a>
|
||||
<a href="../logout.php"> <i class="mdi mdi-logout"></i> Log Out </a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
include "../functions.php";
|
||||
|
||||
$payout_id = $_GET['payout_id'];
|
||||
$payoutbyId = getPayout($_SESSION["token"], $payout_id);
|
||||
$payoutData = json_decode($payoutbyId, true);
|
||||
$payout_vendor_id = $payoutData['vendor_details'][0]['vendor_id'];
|
||||
echo $payout_vendor_id;
|
||||
if (isset($payoutData['transaction_logs']) && is_array($payoutData['transaction_logs'])) {
|
||||
$orderIds = array();
|
||||
foreach ($payoutData['transaction_logs'] as $transaction) {
|
||||
if (isset($transaction['orderId'])) {
|
||||
$orderIds[] = $transaction['orderId'];
|
||||
}
|
||||
}
|
||||
editOrderPayoutStatus($_SESSION["token"], $orderIds);
|
||||
updatePayout($_SESSION["token"],$payout_id);
|
||||
} else {
|
||||
echo "No transaction logs found.";
|
||||
}
|
||||
|
||||
header("location: vendor-profile.php?id=$payout_vendor_id");
|
||||
|
||||
?>
|
|
@ -99,183 +99,179 @@ $users = getUsers();
|
|||
</div>
|
||||
|
||||
<div class="row">
|
||||
<?php
|
||||
$totalUsers = count($users);
|
||||
$usersPerPage = 20;
|
||||
$totalPages = ceil($totalUsers / $usersPerPage);
|
||||
$currentPage = isset($_GET['page']) ? $_GET['page'] : 1;
|
||||
$start = ($currentPage - 1) * $usersPerPage;
|
||||
$end = $start + $usersPerPage - 1;
|
||||
<?php
|
||||
$totalUsers = count($users);
|
||||
$usersPerPage = 20;
|
||||
$totalPages = ceil($totalUsers / $usersPerPage);
|
||||
$currentPage = isset($_GET['page']) ? $_GET['page'] : 1;
|
||||
$start = ($currentPage - 1) * $usersPerPage;
|
||||
$end = $start + $usersPerPage - 1;
|
||||
|
||||
for ($x = $start; $x <= $end && $x < $totalUsers; $x++) {
|
||||
$user = $users[$x];
|
||||
// $customerUser = getCustomerbyLoginId($user['_id']);
|
||||
// $vendorUser = getVendorbyLoginId($user['_id']);
|
||||
?>
|
||||
<div class="col-lg-6 col-xl-4 mb-24px">
|
||||
<div class="ec-user-card card card-default p-4">
|
||||
<a href="javascript:0" class="view-detail" id="modalTrigger-<?php echo $user['_id']; ?>"><i class="mdi mdi-eye-plus-outline"></i></a>
|
||||
<!-- <a href="javascript:0" data-bs-toggle="modal" data-bs-target="#modalContact-<?php echo $user['_id']; ?>" class="view-detail"><i class="mdi mdi-eye-plus-outline"></i></a> -->
|
||||
<a href="javascript:0" class="media text-secondary">
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/7/7e/Circle-icons-profile.svg" class="mr-3 img-fluid" alt="Avatar Image">
|
||||
<div class="media-body">
|
||||
<h5 class="mt-0 mb-2 text-dark"><?php echo $user['username'] ?></h5>
|
||||
<div class="icon">
|
||||
<li class="d-flex mb-1">
|
||||
<i class="mdi mdi-account-key" style="font-size: 20px;"></i>
|
||||
<span><?php echo $user['user_type'] ?></span>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
for ($x = $start; $x <= $end && $x < $totalUsers; $x++) {
|
||||
$user = $users[$x];
|
||||
?>
|
||||
<div class="col-lg-6 col-xl-4 mb-24px">
|
||||
<div class="ec-user-card card card-default p-4">
|
||||
<a href="javascript:0" class="view-detail" id="modalTrigger-<?php echo $user['_id']; ?>"><i class="mdi mdi-eye-plus-outline"></i></a>
|
||||
<!-- <a href="javascript:0" data-bs-toggle="modal" data-bs-target="#modalContact-<?php echo $user['_id']; ?>" class="view-detail"><i class="mdi mdi-eye-plus-outline"></i></a> -->
|
||||
<a href="javascript:0" class="media text-secondary">
|
||||
<img src="https://upload.wikimedia.org/wikipedia/commons/7/7e/Circle-icons-profile.svg" class="mr-3 img-fluid" alt="Avatar Image">
|
||||
<div class="media-body">
|
||||
<h5 class="mt-0 mb-2 text-dark"><?php echo $user['username'] ?></h5>
|
||||
<div class="icon">
|
||||
<li class="d-flex mb-1">
|
||||
<i class="mdi mdi-account-key" style="font-size: 20px;"></i>
|
||||
<span><?php echo $user['user_type'] ?></span>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="modal fade modal-contact-detail" id="modalContact-<?php echo $user['_id']; ?>" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header justify-content-end border-bottom-0">
|
||||
<!-- Modal -->
|
||||
<?php foreach ($users as $user) { ?>
|
||||
<div class="modal fade modal-contact-detail" id="modalContact-<?php echo $user['_id']; ?>" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header justify-content-end border-bottom-0">
|
||||
<button type="button" class="btn-close-icon" data-bs-dismiss="modal" aria-label="Close">
|
||||
<i class="mdi mdi-close"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body pt-0">
|
||||
<div class="row no-gutters">
|
||||
<div class="col-md-12">
|
||||
<div class="profile-content-left px-4">
|
||||
<form action="user-card-action.php" method="post">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="text-dark font-weight-medium pt-3 mb-2">Email</label>
|
||||
<input type="text" name="username" class="form-control" value="<?php echo $user['username']; ?>" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="text-dark font-weight-medium pt-3 mb-2">User Type</label>
|
||||
<select class="form-select" name="user_type">
|
||||
<option value="">Select User Type</option>
|
||||
<option value="admin" <?php echo ($user['user_type'] === 'admin') ? 'selected' : ''; ?>>admin</option>
|
||||
<option value="vendor" <?php echo ($user['user_type'] === 'vendor') ? 'selected' : ''; ?>>vendor</option>
|
||||
<option value="customer" <?php echo ($user['user_type'] === 'customer') ? 'selected' : ''; ?>>customer</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<input type="hidden" name="_id" class="form-control" value="<?php echo $user['_id']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<button type="button" class="btn-close-icon" data-bs-dismiss="modal" aria-label="Close">
|
||||
<i class="mdi mdi-close"></i>
|
||||
</button>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
<?php foreach ($users as $user) { ?>
|
||||
registerModalTrigger('<?php echo $user['_id']; ?>');
|
||||
<?php } ?>
|
||||
});
|
||||
|
||||
<div class="modal-body pt-0">
|
||||
<div class="row no-gutters">
|
||||
<div class="col-md-12">
|
||||
<div class="profile-content-left px-4">
|
||||
<form action="user-card-action.php" method="post">
|
||||
<div class="row">
|
||||
function registerModalTrigger(userId) {
|
||||
var modalTrigger = document.getElementById('modalTrigger-' + userId);
|
||||
var sessionToken = '<?php echo isset($_SESSION["token"]) ? $_SESSION["token"] : ""; ?>';
|
||||
var email = '<?php echo isset($_SESSION["email"]) ? $_SESSION["email"] : ""; ?>';
|
||||
var password = '<?php echo isset($_SESSION["password"]) ? $_SESSION["password"] : ""; ?>';
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="text-dark font-weight-medium pt-3 mb-2">Email</label>
|
||||
<input type="text" name="username" class="form-control" value="<?php echo $user['username']; ?>" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="text-dark font-weight-medium pt-3 mb-2">User Type</label>
|
||||
<select class="form-select" name="user_type">
|
||||
<option value="">Select User Type</option>
|
||||
<option value="admin" <?php echo ($user['user_type'] === 'admin') ? 'selected' : ''; ?>>admin</option>
|
||||
<option value="vendor" <?php echo ($user['user_type'] === 'vendor') ? 'selected' : ''; ?>>vendor</option>
|
||||
<option value="customer" <?php echo ($user['user_type'] === 'customer') ? 'selected' : ''; ?>>customer</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<input type="hidden" name="_id" class="form-control" value="<?php echo $user['_id']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
if (modalTrigger) {
|
||||
modalTrigger.addEventListener('click', function() {
|
||||
renewToken(sessionToken, email, password, userId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
<?php foreach ($users as $user) { ?>
|
||||
registerModalTrigger('<?php echo $user['_id']; ?>');
|
||||
<?php } ?>
|
||||
});
|
||||
function renewToken(sessionToken, email, password, userId) {
|
||||
login(email, password, sessionToken, function() {
|
||||
showTheModal(userId);
|
||||
});
|
||||
}
|
||||
|
||||
function registerModalTrigger(userId) {
|
||||
var modalTrigger = document.getElementById('modalTrigger-' + userId);
|
||||
var sessionToken = '<?php echo isset($_SESSION["token"]) ? $_SESSION["token"] : ""; ?>';
|
||||
var email = '<?php echo isset($_SESSION["email"]) ? $_SESSION["email"] : ""; ?>';
|
||||
var password = '<?php echo isset($_SESSION["password"]) ? $_SESSION["password"] : ""; ?>';
|
||||
function login(username, password, sessionToken, callback) {
|
||||
fetch("https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/login", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Api-Key": "{{apiKey}}"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: username,
|
||||
password: password
|
||||
})
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
throw new Error("Unable to login");
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
// Update the session token on the server side
|
||||
fetch("update-token-session.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
token: data.token
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.status === 'success') {
|
||||
// Update the session token in the client-side variable
|
||||
sessionToken = data.token;
|
||||
console.log("New Token:", sessionToken);
|
||||
callback();
|
||||
} else {
|
||||
throw new Error("Unable to update session token");
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error:", error.message);
|
||||
});
|
||||
}
|
||||
|
||||
if (modalTrigger) {
|
||||
modalTrigger.addEventListener('click', function() {
|
||||
// Renew the login token before showing the modal
|
||||
renewToken(sessionToken, email, password, userId);
|
||||
});
|
||||
}
|
||||
}
|
||||
function showTheModal(userId) {
|
||||
// Add your logic here to show the modal
|
||||
// You may need to trigger it manually if using Bootstrap modal
|
||||
$('#modalContact-' + userId).modal('show');
|
||||
}
|
||||
</script>
|
||||
|
||||
function renewToken(sessionToken, email, password, userId) {
|
||||
// Add your logic here to renew the login token
|
||||
login(email, password, sessionToken, function() {
|
||||
// Callback function after renewing the token, e.g., show the modal
|
||||
showTheModal(userId);
|
||||
});
|
||||
}
|
||||
<!-- Pagination Links -->
|
||||
<div class="pagination">
|
||||
<?php
|
||||
for ($page = 1; $page <= $totalPages; $page++) {
|
||||
echo '<a href="?page=' . $page . '">' . $page . '</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
function login(username, password, sessionToken, callback) {
|
||||
fetch("https://<?php echo $_SESSION["data_endpoint"]; ?>/api/v1/login", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Api-Key": "{{apiKey}}"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: username,
|
||||
password: password
|
||||
})
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
throw new Error("Unable to login");
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
// Update the session token on the server side
|
||||
fetch("update-token-session.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
token: data.token
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => {
|
||||
if (result.status === 'success') {
|
||||
// Update the session token in the client-side variable
|
||||
sessionToken = data.token;
|
||||
console.log("New Token:", sessionToken);
|
||||
callback();
|
||||
} else {
|
||||
throw new Error("Unable to update session token");
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error:", error.message);
|
||||
});
|
||||
}
|
||||
|
||||
function showTheModal(userId) {
|
||||
// Add your logic here to show the modal
|
||||
// You may need to trigger it manually if using Bootstrap modal
|
||||
$('#modalContact-' + userId).modal('show');
|
||||
}
|
||||
</script>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<!-- Pagination Links -->
|
||||
<div class="pagination">
|
||||
<?php
|
||||
for ($page = 1; $page <= $totalPages; $page++) {
|
||||
echo '<a href="?page=' . $page . '">' . $page . '</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<!-- Contact Modal -->
|
||||
|
||||
|
|
|
@ -2,30 +2,91 @@
|
|||
include "../functions.php";
|
||||
|
||||
if(isset($_SESSION["vendorId"])){
|
||||
if(isset($_GET["id"])){
|
||||
$_SESSION["vendorId"]=$_GET["id"];
|
||||
}
|
||||
if(isset($_GET["id"])){
|
||||
$_SESSION["vendorId"]=$_GET["id"];
|
||||
}
|
||||
} else {
|
||||
if(isset($_GET["id"])){
|
||||
$_SESSION["vendorId"]=$_GET["id"];
|
||||
} else {
|
||||
header("location: vendor-card.php");
|
||||
}
|
||||
if(isset($_GET["id"])){
|
||||
$_SESSION["vendorId"]=$_GET["id"];
|
||||
} else {
|
||||
header("location: vendor-card.php");
|
||||
}
|
||||
}
|
||||
|
||||
$_SESSION["url"] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
|
||||
if ($_SESSION["userId"] <> "") {
|
||||
$_SESSION["isLoggedIn"] = true;
|
||||
//$customer_data = getCustomerbyLoginId($_SESSION["userId"]);
|
||||
|
||||
} else {
|
||||
$_SESSION["isLoggedIn"] = false;
|
||||
header("location: login.php");
|
||||
header("location: login.php");
|
||||
}
|
||||
|
||||
if($_SESSION["user_type"]!="admin"){
|
||||
header("location: login.php?alert=Only admins allowed here!");
|
||||
header("location: login.php?alert=Only admins allowed here!");
|
||||
}
|
||||
|
||||
$vendor = getVendorbyId($_SESSION["vendorId"]);
|
||||
$array = json_decode($vendor,true);
|
||||
|
||||
$selectedBankAccount = null;
|
||||
foreach ($array['bank_acount_details'] as $bankAccount) {
|
||||
if ($bankAccount['bank_payout']) {
|
||||
$selectedBankAccount = $bankAccount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($selectedBankAccount === null && !empty($array['bank_acount_details'])) {
|
||||
$selectedBankAccount = $array['bank_acount_details'][0];
|
||||
}
|
||||
$selectedBankAccountJSON = json_encode($selectedBankAccount);
|
||||
|
||||
|
||||
$shopOrders = getOrderbyVendorId($_SESSION["vendorId"]);
|
||||
$vendorOrderss = json_decode($shopOrders);
|
||||
if (is_array($vendorOrderss)) {
|
||||
$vendorOrders = json_decode($shopOrders);
|
||||
} elseif (is_object($vendorOrderss) && property_exists($vendorOrderss, 'message')) {
|
||||
$vendorOrders = [];
|
||||
} else {
|
||||
echo "Unknown type or no 'message' property found.";
|
||||
}
|
||||
|
||||
$allPayouts = getAllPayout($_SESSION["token"]);
|
||||
$vendorPayouts = json_decode($allPayouts,true);
|
||||
|
||||
|
||||
$filteredPayouts = [];
|
||||
foreach ($vendorPayouts as $payout) {
|
||||
if ($payout['vendor_details'][0]['vendor_id'] == $_SESSION["vendorId"]) {
|
||||
$filteredPayouts[] = $payout;
|
||||
}
|
||||
}
|
||||
|
||||
$token = $_SESSION["token"];
|
||||
|
||||
$token_parts = explode(".", $token);
|
||||
$token_payload = base64_decode($token_parts[1]);
|
||||
$token_data = json_decode($token_payload);
|
||||
|
||||
$expiration_time = $token_data->exp;
|
||||
$issued_at_time = $token_data->iat;
|
||||
|
||||
$renewal_time = $issued_at_time + 3300;
|
||||
|
||||
|
||||
if (time() >= $renewal_time) {
|
||||
$token = loginRenew($_SESSION["email"], $_SESSION["password"], $token);
|
||||
$_SESSION["token"] = $token;
|
||||
}
|
||||
// $token = loginRenew($_SESSION["email"], $_SESSION["password"], $token);
|
||||
// $_SESSION["token"] = $token;
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
|
||||
|
@ -128,6 +189,18 @@ $array = json_decode($vendor,true);
|
|||
|
||||
<div class="contact-info pt-4">
|
||||
<h5 class="text-dark">Contact Information</h5>
|
||||
<?php
|
||||
//echo date('Y-m-d H:i:s', $issued_at_time) . "<br>";
|
||||
//echo date('Y-m-d H:i:s', $expiration_time) . "<br>";
|
||||
//echo date('Y-m-d H:i:s', $renewal_time) . "<br>";
|
||||
//echo date('Y-m-d H:i:s', time()) . "<br>";
|
||||
|
||||
|
||||
?>
|
||||
<?php echo $_SESSION["token"] ?><br>
|
||||
<?php // echo $_SESSION["email"] ?> <br>
|
||||
<?php // echo "Updated token: " . $token; ?>
|
||||
<?php // echo $_SESSION["password"] ?>
|
||||
<p class="text-dark font-weight-medium pt-24px mb-2">Email address</p>
|
||||
<p><?php echo $array["user_email"]; ?></p>
|
||||
<p class="text-dark font-weight-medium pt-24px mb-2">Phone Number</p>
|
||||
|
@ -214,176 +287,168 @@ $array = json_decode($vendor,true);
|
|||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
<td>ObananaPay</td>
|
||||
<td>₱230</td>
|
||||
<td>
|
||||
<span class="badge badge-success">Paid</span>
|
||||
</td>
|
||||
<td><span class="badge badge-warning">No</span></td>
|
||||
<td>
|
||||
<a class="text-dark" href=""> Coach Swagger</a>
|
||||
</td>
|
||||
<td>Oct 20, 2018</td>
|
||||
<td class="text-right">
|
||||
<div
|
||||
class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini"
|
||||
href="" role="button"
|
||||
id="dropdown-recent-order1"
|
||||
data-bs-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right"
|
||||
aria-labelledby="dropdown-recent-order1">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Details</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$totalOrders = count($vendorOrders);
|
||||
for ($i = 0; $i < $totalOrders; $i++) {
|
||||
$order = $vendorOrders[$i];
|
||||
$orderArray = json_encode($order, true);
|
||||
$orderItems = json_decode($orderArray, true);
|
||||
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
<td>ObananaPay</td>
|
||||
<td>₱550</td>
|
||||
<td>
|
||||
<span class="badge badge-success">Paid</span>
|
||||
</td>
|
||||
<td><span class="badge badge-warning">No</span></td>
|
||||
<td>
|
||||
<a class="text-dark" href=""> Toddler Shoes, Gucci Watch</a>
|
||||
</td>
|
||||
<td>Nov 15, 2018</td>
|
||||
<td class="text-right">
|
||||
<div
|
||||
class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini"
|
||||
href="" role="button"
|
||||
id="dropdown-recent-order1"
|
||||
data-bs-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right"
|
||||
aria-labelledby="dropdown-recent-order1">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Details</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
if ($orderItems['payment']['status'] === 'PAID') {
|
||||
foreach ($orderItems['items'] as $item) {
|
||||
$isPayoutCompleted = !empty($orderItems['payout_status']);
|
||||
?>
|
||||
<tr>
|
||||
<td><input type="checkbox" <?php echo $isPayoutCompleted ? 'disabled' : ''; ?>></td>
|
||||
<td><?php echo $orderItems['payment_method']; ?></td>
|
||||
<td><?php echo $item['price']; ?></td>
|
||||
<td>
|
||||
<span class="badge badge-success"><?php echo $orderItems['payment']['status']; ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge badge-warning"><?php echo $isPayoutCompleted ? 'Yes' : 'No'; ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<a class="text-dark" href=""><?php echo $item['product']['name']; ?></a>
|
||||
</td>
|
||||
<td><?php echo $orderItems['updatedAt']; ?></td>
|
||||
<td hidden><?php echo $orderItems['_id']; ?></td>
|
||||
<td class="text-right">
|
||||
<div class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini" href="" role="button" id="dropdown-recent-order1" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdown-recent-order1">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Details</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
<td>ObananaPay</td>
|
||||
<td>₱325</td>
|
||||
<td>
|
||||
<span class="badge badge-success">Paid</span>
|
||||
</td>
|
||||
<td><span class="badge badge-warning">No</span></td>
|
||||
<td>
|
||||
<a class="text-dark" href=""> Hat Black Suits</a>
|
||||
</td>
|
||||
<td>Nov 18, 2018</td>
|
||||
<td class="text-right">
|
||||
<div
|
||||
class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini"
|
||||
href="" role="button"
|
||||
id="dropdown-recent-order1"
|
||||
data-bs-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right"
|
||||
aria-labelledby="dropdown-recent-order1">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Details</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><input type="checkbox"></td>
|
||||
<td>PayMongo</td>
|
||||
<td>₱200</td>
|
||||
<td>
|
||||
<span class="badge badge-success">Paid</span>
|
||||
</td>
|
||||
<td><span class="badge badge-warning">No</span></td>
|
||||
<td>
|
||||
<a class="text-dark" href=""> T100 Power Bank</a>
|
||||
</td>
|
||||
<td>Nov 20, 2018</td>
|
||||
<td class="text-right">
|
||||
<div
|
||||
class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini"
|
||||
href="" role="button"
|
||||
id="dropdown-recent-order1"
|
||||
data-bs-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right"
|
||||
aria-labelledby="dropdown-recent-order1">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Details</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><input type="checkbox" disabled></td>
|
||||
<td>ObananaPay</td>
|
||||
<td>₱150</td>
|
||||
<td>
|
||||
<span class="badge badge-success">Paid</span>
|
||||
</td>
|
||||
<td><span class="badge badge-success">Yes</span></td>
|
||||
<td>
|
||||
<a class="text-dark" href=""> Vodka Milk Tea</a>
|
||||
</td>
|
||||
<td>Dec 11, 2018</td>
|
||||
<td class="text-right">
|
||||
<div
|
||||
class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini"
|
||||
href="" role="button"
|
||||
id="dropdown-recent-order1"
|
||||
data-bs-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right"
|
||||
aria-labelledby="dropdown-recent-order1">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Details</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end mt-5">
|
||||
<button type="submit" class="btn btn-primary mb-2 btn-pill">Create Payout from Selected</button>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end mt-5">
|
||||
<button type="button" class="btn btn-primary mb-2 btn-pill" onclick="createPayout()">Create Payout from Selected</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function createPayout() {
|
||||
var rows = document.querySelectorAll("#recent-orders tbody tr");
|
||||
var selectedBank = JSON.parse('<?php echo $selectedBankAccountJSON; ?>');
|
||||
var selectedOrders = [];
|
||||
var grossAmount = 0;
|
||||
var totalIndividualFee = 0;
|
||||
var feesDeductionAdjustment = <?php echo $_SESSION["transfer_fee"] ?>;
|
||||
var feesPercentage = (feesDeductionAdjustment * 100) + '%';
|
||||
const token = '<?php echo $_SESSION["token"] ?>';
|
||||
const vendorId = '<?php echo ($array['_id']); ?>';
|
||||
const vendorName = '<?php echo ($array['user_login']); ?>';
|
||||
rows.forEach(function(row) {
|
||||
var checkbox = row.querySelector("input[type=checkbox]");
|
||||
if (checkbox && checkbox.checked) {
|
||||
var amount = parseFloat(row.cells[2].innerText);
|
||||
var orderId = row.cells[7].innerText;
|
||||
grossAmount += amount;
|
||||
var individualFee = amount * <?php echo $_SESSION["transfer_fee"] ?>;
|
||||
totalIndividualFee += individualFee;
|
||||
// feesDeductionAdjustment += individualFee;
|
||||
var breakdownItem = {
|
||||
Type: "Payment",
|
||||
Transaction_date: row.cells[6].innerText,
|
||||
Gross_Amount: amount,
|
||||
Fee: individualFee,
|
||||
Net_Amount: amount - individualFee,
|
||||
Description: row.cells[5].querySelector("a").innerText,
|
||||
orderId: orderId
|
||||
};
|
||||
|
||||
selectedOrders.push(breakdownItem);
|
||||
}
|
||||
});
|
||||
|
||||
var netAmount = grossAmount - (grossAmount * feesDeductionAdjustment);
|
||||
|
||||
var fees_breakdown = {
|
||||
transfer_fee: totalIndividualFee, };
|
||||
|
||||
|
||||
var postData = {
|
||||
gross_amount: grossAmount.toFixed(2),
|
||||
fees_deduction_adjustment: feesPercentage,
|
||||
net_amount: netAmount.toFixed(2),
|
||||
breakdown: fees_breakdown,
|
||||
bank_information: [
|
||||
selectedBank
|
||||
],
|
||||
transaction_logs: selectedOrders,
|
||||
vendor_details: [
|
||||
{ vendor_id: vendorId,
|
||||
vendor_name: vendorName}
|
||||
],
|
||||
status: "PENDING",
|
||||
created_by: "Sample User",
|
||||
};
|
||||
|
||||
fetch('https://api.obanana.shop/api/v1/payouts/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
"Authorization": "Bearer " + token,
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
throw new Error('Failed to create payout');
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
console.log('Payout created successfully');
|
||||
selectedOrders.forEach(order => {
|
||||
var orderId = order.orderId;
|
||||
fetch(`https://api.obanana.shop/api/v1/orders/${orderId}`, {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
"Authorization": "Bearer " + token,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
payout_status: {
|
||||
payout_id: data._id,
|
||||
status: "Processing"
|
||||
}
|
||||
})
|
||||
})
|
||||
.then(response => {
|
||||
// if (!response.ok) {
|
||||
// console.error(`Failed to update payout status for order ${orderId}`);
|
||||
// }
|
||||
if (!response.ok) {
|
||||
console.error(`Failed to update payout status for order ${orderId}`);
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(`Error updating payout status for order ${orderId}:`, error);
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -418,14 +483,21 @@ $array = json_decode($vendor,true);
|
|||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
$totalPayoutOrders = count($filteredPayouts);
|
||||
for ($i = 0; $i < $totalPayoutOrders; $i++) {
|
||||
$order_payouts = $filteredPayouts[$i];
|
||||
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td>₱1,230</td>
|
||||
<td>EastWest</td>
|
||||
<td>**** **** 1234</td>
|
||||
<td>Jon-Jon Manaay</td>
|
||||
<td>Oct 20, 2018</td>
|
||||
<td><?php echo $order_payouts['gross_amount']?></td>
|
||||
<td><?php echo $order_payouts['bank_information'][0]['bank_name']?></td>
|
||||
<td><?php echo $order_payouts['bank_information'][0]['bank_account_number']?></td>
|
||||
<td><?php echo $order_payouts['bank_information'][0]['bank_account_name']?></td>
|
||||
<td><?php echo date('F j Y', strtotime($order_payouts['createdAt'])); ?></td>
|
||||
<td>
|
||||
<span class="badge badge-success">Deposited</span>
|
||||
<span class="badge badge-success"><?php echo $order_payouts['status']?></span>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div
|
||||
|
@ -442,40 +514,14 @@ $array = json_decode($vendor,true);
|
|||
<li class="dropdown-item">
|
||||
<a href="#">Details</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>₱2,340</td>
|
||||
<td>EastWest</td>
|
||||
<td>**** **** 1234</td>
|
||||
<td>Jon-Jon Manaay</td>
|
||||
<td>Oct 27, 2018</td>
|
||||
<td>
|
||||
<span class="badge badge-warning">Processing</span>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div
|
||||
class="dropdown show d-inline-block widget-dropdown">
|
||||
<a class="dropdown-toggle icon-burger-mini"
|
||||
href="" role="button"
|
||||
id="dropdown-recent-order1"
|
||||
data-bs-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
data-display="static"></a>
|
||||
<ul class="dropdown-menu dropdown-menu-right"
|
||||
aria-labelledby="dropdown-recent-order1">
|
||||
<li class="dropdown-item">
|
||||
<a href="#">Details</a>
|
||||
<a href="payout_deposit_action.php?payout_id=<?php echo urlencode($order_payouts['_id']); ?>">Deposit</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -533,7 +579,7 @@ $array = json_decode($vendor,true);
|
|||
<div class="col-xl-12">
|
||||
|
||||
<!-- Notification Table -->
|
||||
<div class="card card-default mb-24px">
|
||||
<!-- <div class="card card-default mb-24px">
|
||||
<div class="card-header justify-content-between mb-1">
|
||||
<h2>Latest Notifications</h2>
|
||||
<div>
|
||||
|
@ -685,7 +731,7 @@ $array = json_decode($vendor,true);
|
|||
|
||||
</div>
|
||||
<div class="mt-3"></div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -909,6 +955,12 @@ $array = json_decode($vendor,true);
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<!-- Bank Details -->
|
||||
|
||||
<!-- Bank Details -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -916,7 +968,23 @@ $array = json_decode($vendor,true);
|
|||
<div class="tab-pane fade" id="settings" role="tabpanel"
|
||||
aria-labelledby="settings-tab">
|
||||
<div class="tab-pane-content mt-5">
|
||||
<form>
|
||||
|
||||
<table style="width:100%; border-collapse: collapse;">
|
||||
<tr>
|
||||
<td style="border: 1px solid #dddddd; background-color: #f7f7f7; padding: 8px; font-weight: 700;">Bank Name</td>
|
||||
<td style="border: 1px solid #dddddd; padding: 8px;font-weight: 500;"><?php echo $selectedBankAccount['bank_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #dddddd; background-color: #f7f7f7; padding: 8px;font-weight: 700;">Account Number</td>
|
||||
<td style="border: 1px solid #dddddd; padding: 8px;font-weight: 500;"><?php echo $selectedBankAccount["bank_account_number"] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="border: 1px solid #dddddd; background-color: #f7f7f7; padding: 8px;font-weight: 700;">Account Name</td>
|
||||
<td style="border: 1px solid #dddddd; padding: 8px;font-weight: 500;"><?php echo $selectedBankAccount["bank_account_name"] ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- <form>
|
||||
<div class="form-group row mb-6">
|
||||
<label for="coverImage"
|
||||
class="col-sm-4 col-lg-2 col-form-label">User Image</label>
|
||||
|
@ -984,7 +1052,7 @@ $array = json_decode($vendor,true);
|
|||
class="btn btn-primary mb-2 btn-pill">Update
|
||||
Profile</button>
|
||||
</div>
|
||||
</form>
|
||||
</form> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
122
functions.php
122
functions.php
|
@ -360,6 +360,36 @@ function login($username, $password)
|
|||
$token = json_decode($response, true);
|
||||
return $token["token"];
|
||||
}
|
||||
|
||||
function loginRenew($username, $password, $token)
|
||||
{
|
||||
$curl = curl_init();
|
||||
$array = array(
|
||||
"username" => $username,
|
||||
"password" => $password
|
||||
);
|
||||
$json = json_encode($array);
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://" . $_SESSION["data_endpoint"] . "/api/v1/login",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => $json,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json',
|
||||
'X-Api-Key: {{apiKey}}'
|
||||
),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
$token = json_decode($response, true);
|
||||
return $token["token"];
|
||||
}
|
||||
|
||||
function forgot_password($email)
|
||||
{
|
||||
if ($_SESSION["is_test"] == true && $_SESSION["test_email_rcpt"] != "") {
|
||||
|
@ -1858,3 +1888,95 @@ function getAllPayout($token)
|
|||
|
||||
return $response;
|
||||
}
|
||||
|
||||
function getPayout($token, $id)
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://" . $_SESSION["data_endpoint"] . "/api/v1/payouts/{$id}",
|
||||
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}}',
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $token
|
||||
),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
function editOrderPayoutStatus($token, $orderIds)
|
||||
{
|
||||
$curl = curl_init();
|
||||
foreach ($orderIds as $orderId) {
|
||||
$data = array(
|
||||
'payout_status' => array(
|
||||
'payout_id' => $orderId,
|
||||
'status' => 'Deposited'
|
||||
)
|
||||
);
|
||||
|
||||
$params3 = json_encode($data);
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://" . $_SESSION["data_endpoint"] . "/api/v1/orders/" . $orderId,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'PATCH',
|
||||
CURLOPT_POSTFIELDS => $params3,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Accept: application/json',
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $token
|
||||
),
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
}
|
||||
curl_close($curl);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function updatePayout($token, $payoutId)
|
||||
{
|
||||
$curl = curl_init();
|
||||
$data = array(
|
||||
'status' => "Deposited",
|
||||
);
|
||||
|
||||
$params = json_encode($data);
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => "https://" . $_SESSION["data_endpoint"] . "/api/v1/payouts/" . $payoutId, // Corrected URL to include $payoutId
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'PATCH',
|
||||
CURLOPT_POSTFIELDS => $params, // Send the payload data
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'X-Api-Key: {{apiKey}}', // Make sure to replace {{apiKey}} with an actual API key if needed
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $token
|
||||
),
|
||||
));
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue