CMXX - Myaccount
This commit is contained in:
@@ -1,129 +0,0 @@
|
||||
<?php
|
||||
defined('admin') or exit;
|
||||
// SQL query that will get all orders and sort by the date created
|
||||
$stmt = $pdo->prepare('SELECT t.*, COUNT(ti.id) AS total_products FROM transactions t JOIN transactions_items ti ON ti.txn_id = t.txn_id WHERE cast(t.created as DATE) = cast(now() as DATE) GROUP BY t.id, t.txn_id, t.payment_amount, t.payment_status, t.created, t.payer_email, t.first_name, t.last_name, t.address_street, t.address_city, t.address_state, t.address_zip, t.address_country, t.account_id, t.payment_method, t.discount_code, t.shipping_method, t.shipping_amount ORDER BY t.created DESC');
|
||||
$stmt->execute();
|
||||
$orders = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
// Get the orders statistics
|
||||
$stmt = $pdo->prepare('SELECT SUM(payment_amount) AS earnings FROM transactions WHERE payment_status = "Completed" AND cast(created as DATE) = cast(now() as DATE)');
|
||||
$stmt->execute();
|
||||
$order_stats = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
// Get the total number of accounts
|
||||
$stmt = $pdo->prepare('SELECT COUNT(*) AS total FROM accounts');
|
||||
$stmt->execute();
|
||||
$accounts = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
// Get the total number of products
|
||||
$stmt = $pdo->prepare('SELECT COUNT(*) AS total FROM products');
|
||||
$stmt->execute();
|
||||
$products = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
?>
|
||||
<?=template_admin_header('Dashboard', 'dashboard')?>
|
||||
|
||||
<div class="content-title">
|
||||
<div class="title">
|
||||
<i class="fa-solid fa-gauge-high"></i>
|
||||
<div class="txt">
|
||||
<h2>Dashboard</h2>
|
||||
<p>View statistics, today's transactions, and more.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dashboard">
|
||||
<div class="content-block stat">
|
||||
<div class="data">
|
||||
<h3>New Orders</h3>
|
||||
<p><?=number_format(count($orders))?></p>
|
||||
</div>
|
||||
<i class="fas fa-shopping-cart"></i>
|
||||
<div class="footer">
|
||||
<i class="fa-solid fa-rotate fa-xs"></i>Total orders for today
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-block stat">
|
||||
<div class="data">
|
||||
<h3>New Sales</h3>
|
||||
<p><?=currency_code?><?=number_format($order_stats['earnings'] ?? 0, 2)?></p>
|
||||
</div>
|
||||
<i class="fas fa-coins"></i>
|
||||
<div class="footer">
|
||||
<i class="fa-solid fa-rotate fa-xs"></i>Total earnings for today
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-block stat">
|
||||
<div class="data">
|
||||
<h3>Total Accounts</h3>
|
||||
<p><?=number_format($accounts['total'])?></p>
|
||||
</div>
|
||||
<i class="fas fa-users"></i>
|
||||
<div class="footer">
|
||||
<i class="fa-solid fa-rotate fa-xs"></i>Total accounts
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-block stat">
|
||||
<div class="data">
|
||||
<h3>Total Products</h3>
|
||||
<p><?=number_format($products['total'])?></p>
|
||||
</div>
|
||||
<i class="fas fa-boxes"></i>
|
||||
<div class="footer">
|
||||
<i class="fa-solid fa-rotate fa-xs"></i>Total products
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-title">
|
||||
<div class="title">
|
||||
<i class="fa-regular fa-rectangle-list alt"></i>
|
||||
<div class="txt">
|
||||
<h2>Today's Transactions</h2>
|
||||
<p>List of transactions for today.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-block">
|
||||
<div class="table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>#</td>
|
||||
<td>Customer</td>
|
||||
<td class="responsive-hidden">Email</td>
|
||||
<td class="responsive-hidden">Products</td>
|
||||
<td>Total</td>
|
||||
<td class="responsive-hidden">Method</td>
|
||||
<td class="responsive-hidden">Status</td>
|
||||
<td class="responsive-hidden">Date</td>
|
||||
<td>Actions</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($orders)): ?>
|
||||
<tr>
|
||||
<td colspan="9" style="text-align:center;">There are no recent orders</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($orders as $order): ?>
|
||||
<tr>
|
||||
<td><?=$order['id']?></td>
|
||||
<td><?=htmlspecialchars($order['first_name'], ENT_QUOTES)?> <?=htmlspecialchars($order['last_name'], ENT_QUOTES)?></td>
|
||||
<td class="responsive-hidden"><?=htmlspecialchars($order['payer_email'], ENT_QUOTES)?></td>
|
||||
<td class="responsive-hidden"><?=$order['total_products']?></td>
|
||||
<td><?=currency_code?><?=number_format($order['payment_amount'], 2)?></td>
|
||||
<td class="responsive-hidden"><?=$order['payment_method']?></td>
|
||||
<td class="responsive-hidden"><span class="status <?=strtolower($order['payment_status'])?>"><?=$order['payment_status']?></span></td>
|
||||
<td class="responsive-hidden"><?=date('F j, Y', strtotime($order['created']))?></td>
|
||||
<td><a href="index.php?page=order&id=<?=$order['id']?>" class="link1">View</a> <a href="index.php?page=order_manage&id=<?=$order['id']?>" class="link1">Edit</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?=template_admin_footer()?>
|
||||
@@ -3,15 +3,15 @@ defined('admin') or exit;
|
||||
// Capture post data
|
||||
if (isset($_POST['emailtemplate'], $_POST['emailtemplate2'])) {
|
||||
// Save templates
|
||||
file_put_contents(dirname(__FILE__,-1).'/custom/mail/order-details-template.php', $_POST['emailtemplate']);
|
||||
file_put_contents(dirname(__FILE__,-1).'/custom/mail/order-notification-template.php', $_POST['emailtemplate2']);
|
||||
file_put_contents('../custom/email/order-details-template.php', $_POST['emailtemplate']);
|
||||
file_put_contents('../custom/email/order-notification-template.php', $_POST['emailtemplate2']);
|
||||
header('Location: index.php?page=emailtemplates&success_msg=1');
|
||||
exit;
|
||||
}
|
||||
// Read the order details template PHP file
|
||||
$contents = file_get_contents(dirname(__FILE__,-1).'/custom/mail/order-details-template.php');
|
||||
$contents = file_get_contents('../custom/email/order-details-template.php');
|
||||
// Read the order notification template PHP file
|
||||
$contents2 = file_get_contents(dirname(__FILE__,-1).'/custom/mail/order-notification-template.php');
|
||||
$contents2 = file_get_contents('../custom/email/order-notification-template.php');
|
||||
// Handle success messages
|
||||
if (isset($_GET['success_msg'])) {
|
||||
if ($_GET['success_msg'] == 1) {
|
||||
|
||||
@@ -15,6 +15,16 @@ include '../custom/settings/config.php';
|
||||
include '../functions.php';
|
||||
// Connect to MySQL database
|
||||
$pdo = pdo_connect_mysql();
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
//LOGIN TO API
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
$data = json_encode(array("clientID" => clientID, "clientsecret" => clientsecret), JSON_UNESCAPED_UNICODE);
|
||||
$responses = ioAPIv2('/v2/authorization', $data,'');
|
||||
//Decode Payload
|
||||
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = '400';}
|
||||
$clientsecret = $responses['token'];
|
||||
|
||||
// If the user is not logged-in redirect them to the login page
|
||||
if (!isset($_SESSION['account_loggedin'])) {
|
||||
header('Location: ' . url('../index.php?page=myaccount'));
|
||||
@@ -29,7 +39,7 @@ if (!$account || $account['role'] != 'Admin') {
|
||||
exit;
|
||||
}
|
||||
// Page is set to home (home.php) by default, so when the visitor visits that will be the page they see.
|
||||
$page = isset($_GET['page']) && file_exists($_GET['page'] . '.php') ? $_GET['page'] : 'dashboard';
|
||||
$page = isset($_GET['page']) && file_exists($_GET['page'] . '.php') ? $_GET['page'] : 'settings';
|
||||
if (isset($_GET['page']) && $_GET['page'] == 'logout') {
|
||||
session_destroy();
|
||||
header('Location: ' . url('../index.php'));
|
||||
|
||||
@@ -1,66 +1,90 @@
|
||||
<?php
|
||||
defined('admin') or exit;
|
||||
// Capture post data
|
||||
if (isset($_POST['language_US'], $_POST['language_NL'])) {
|
||||
// Save templates
|
||||
file_put_contents(dirname(__FILE__,-1).'/custom/translations/translations_US.php', $_POST['language_US']);
|
||||
file_put_contents(dirname(__FILE__,-1).'/custom/translations/translations_NL.php', $_POST['language_NL']);
|
||||
header('Location: index.php?page=language&success_msg=1');
|
||||
exit;
|
||||
}
|
||||
// Read language_US template PHP file
|
||||
$contents = file_get_contents(dirname(__FILE__,-1).'/custom/translations/translations_US.php');
|
||||
// Read language template PHP file
|
||||
$contents2 = file_get_contents(dirname(__FILE__,-1).'/custom/translations/translations_NL.php');
|
||||
// Handle success messages
|
||||
if (isset($_GET['success_msg'])) {
|
||||
if ($_GET['success_msg'] == 1) {
|
||||
$success_msg = 'Settings updated successfully!';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
//------------------------------------------
|
||||
// Languages supported
|
||||
//------------------------------------------
|
||||
$supportedLanguages = ['US', 'NL', 'DE', 'ES','FR', 'IT'];
|
||||
|
||||
if(isset($_POST['generatefile'])){
|
||||
|
||||
<?=template_admin_header('Language', 'language')?>
|
||||
$language_key = (isset($_POST['language'])) ? $_POST['language'] : '';
|
||||
|
||||
<form action="" method="post">
|
||||
|
||||
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
||||
<h2 class="responsive-width-100">Translations</h2>
|
||||
<input type="submit" name="submit" value="Save" class="btn">
|
||||
</div>
|
||||
|
||||
<?php if (isset($success_msg)): ?>
|
||||
<div class="msg success">
|
||||
<i class="fas fa-check-circle"></i>
|
||||
<p><?=$success_msg?></p>
|
||||
<i class="fas fa-times"></i>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="tabs">
|
||||
<a href="#" class="active">US</a>
|
||||
<a href="#" class="">NL</a>
|
||||
</div>
|
||||
<div class="content-block">
|
||||
<div class="form responsive-width-100">
|
||||
function generateFile($language_key,$token){
|
||||
//GET TRANSLATION RECORDS
|
||||
$api_url = '/v2/translations/generatefile='.$language_key;
|
||||
$responses = ioAPIv2($api_url,'',$token);
|
||||
|
||||
if (!empty($responses)){
|
||||
//define translation variable
|
||||
$translation = '<?php'.PHP_EOL;
|
||||
|
||||
<div class="tab-content active">
|
||||
<label for="language_US">Language_US:</label>
|
||||
<textarea name="language_US" id="language_US" style="min-height: 100vh;"><?=$contents?></textarea>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<label for="language_NL">Language_NL:</label>
|
||||
<textarea name="language_NL" id="language_NL" style="min-height: 100vh;"><?=$contents2?></textarea>
|
||||
</div>
|
||||
//decode the API response
|
||||
$responses = json_decode($responses,true);
|
||||
|
||||
//loop through translation records and create variables
|
||||
foreach ($responses as $response){
|
||||
$text = str_replace(
|
||||
['\\', "'", "\r", "\n", "\0", "\t"],
|
||||
['\\\\', "\\'", '\\r', '\\n', '\\0', '\\t'],
|
||||
$response['translation']
|
||||
);
|
||||
|
||||
//create variable_name = translation per item
|
||||
$translation .= '$'.$response['variable'].' = \''.$text.'\';'.PHP_EOL;
|
||||
}
|
||||
//ADD closure tag for PHP
|
||||
$translation .= '?>';
|
||||
//Target dir
|
||||
$target_dir = '../custom/translations/';
|
||||
//Filename
|
||||
$input_file = $target_dir.'translations_'.strtoupper($language_key).'.php';
|
||||
//store translation to the file
|
||||
file_put_contents($input_file, $translation);
|
||||
}
|
||||
}
|
||||
|
||||
if ($language_key != ''){
|
||||
generateFile($language_key,$clientsecret);
|
||||
} else {
|
||||
|
||||
foreach ($supportedLanguages as $language){
|
||||
generateFile($language,$clientsecret);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
template_admin_header('Language', 'language');
|
||||
|
||||
$view .='
|
||||
<form action="" method="post">
|
||||
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
||||
<h2 class="responsive-width-100">Maintenance</h2>
|
||||
</div>';
|
||||
|
||||
$view .= '<div class="tabs">
|
||||
<a href="#" class="active">'.($general_actions ?? 'Actions' ).'</a>
|
||||
</div>
|
||||
';
|
||||
|
||||
$view .= '<div class="content-block tab-content active">
|
||||
<div class="form responsive-width-100">
|
||||
<label for="">Language</label>
|
||||
<select id="language" name="language">';
|
||||
$view .='<option value=""></option>';
|
||||
foreach ($supportedLanguages as $language){
|
||||
$view .='<option value="'.$language.'">'.$language.'</option>';
|
||||
}
|
||||
$view .=' </select>
|
||||
<input type="submit" name="generatefile" style="width: 15%;" value="Generate language" class="btn">
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
</form>
|
||||
<script>
|
||||
document.querySelectorAll("input[type='checkbox']").forEach(checkbox => {
|
||||
checkbox.onclick = () => checkbox.value = checkbox.checked ? 'true' : 'false';
|
||||
});
|
||||
</script>
|
||||
$view .= '</form>';
|
||||
|
||||
<?=template_admin_footer()?>
|
||||
//Output
|
||||
echo $view;
|
||||
|
||||
template_admin_footer();
|
||||
111
admin/settings.php
Normal file
111
admin/settings.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
defined('admin') or exit;
|
||||
// Configuration file
|
||||
$file = '../custom/settings/config.php';
|
||||
// Open the configuration file for reading
|
||||
$contents = file_get_contents($file);
|
||||
// Format key function
|
||||
function format_key($key) {
|
||||
$key = str_replace(
|
||||
['_', 'url', 'db ', ' pass', ' user', 'ipn', 'paypal'],
|
||||
[' ', 'URL', 'Database ', ' Password', ' Username', 'IPN', 'PayPal'],
|
||||
strtolower($key)
|
||||
);
|
||||
return ucwords($key);
|
||||
}
|
||||
// Format HTML output function
|
||||
function format_var_html($key, $value) {
|
||||
$html = '';
|
||||
$type = 'text';
|
||||
$value = htmlspecialchars(trim($value, '\''), ENT_QUOTES);
|
||||
$type = strpos($key, 'secret') !== false ? 'password' : $type;
|
||||
$type = strpos($key, 'pass') !== false ? 'password' : $type;
|
||||
$type = strpos($key, 'Pw') !== false ? 'password' : $type;
|
||||
$type = in_array(strtolower($value), ['true', 'false']) ? 'checkbox' : $type;
|
||||
$checked = strtolower($value) == 'true' ? ' checked' : '';
|
||||
$html .= '<label for="' . $key . '">' . format_key($key) . '</label>';
|
||||
if ($type == 'checkbox') {
|
||||
$html .= '<input type="hidden" name="' . $key . '" value="false">';
|
||||
}
|
||||
$html .= '<input type="' . $type . '" name="' . $key . '" id="' . $key . '" value="' . $value . '" placeholder="' . format_key($key) . '"' . $checked . '>';
|
||||
return $html;
|
||||
}
|
||||
// Format tabs
|
||||
function format_tabs($contents) {
|
||||
$rows = explode("\n", $contents);
|
||||
echo '<div class="tabs">';
|
||||
echo '<a href="#" class="active">General</a>';
|
||||
for ($i = 0; $i < count($rows); $i++) {
|
||||
preg_match('/\/\*(.*?)\*\//', $rows[$i], $match);
|
||||
if ($match) {
|
||||
echo '<a href="#">' . $match[1] . '</a>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
// Format form
|
||||
function format_form($contents) {
|
||||
$rows = explode("\n", $contents);
|
||||
echo '<div class="tab-content active">';
|
||||
for ($i = 0; $i < count($rows); $i++) {
|
||||
preg_match('/\/\*(.*?)\*\//', $rows[$i], $match);
|
||||
if ($match) {
|
||||
echo '</div><div class="tab-content">';
|
||||
}
|
||||
preg_match('/define\(\'(.*?)\', ?(.*?)\)/', $rows[$i], $match);
|
||||
if ($match) {
|
||||
echo format_var_html($match[1], $match[2]);
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
if (!empty($_POST)) {
|
||||
// Update the configuration file with the new keys and values
|
||||
foreach ($_POST as $k => $v) {
|
||||
$v = in_array(strtolower($v), ['true', 'false']) ? strtolower($v) : '\'' . $v . '\'';
|
||||
$contents = preg_replace('/define\(\'' . $k . '\'\, ?(.*?)\)/s', 'define(\'' . $k . '\',' . $v . ')', $contents);
|
||||
}
|
||||
file_put_contents('../custom/settings/config.php', $contents);
|
||||
header('Location: index.php?page=settings&success_msg=1');
|
||||
exit;
|
||||
}
|
||||
// Handle success messages
|
||||
if (isset($_GET['success_msg'])) {
|
||||
if ($_GET['success_msg'] == 1) {
|
||||
$success_msg = 'Settings updated successfully!';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?=template_admin_header('Settings', 'settings')?>
|
||||
|
||||
<form action="" method="post">
|
||||
|
||||
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
||||
<h2 class="responsive-width-100">Settings</h2>
|
||||
<input type="submit" name="submit" value="Save" class="btn">
|
||||
</div>
|
||||
|
||||
<?php if (isset($success_msg)): ?>
|
||||
<div class="msg success">
|
||||
<i class="fas fa-check-circle"></i>
|
||||
<p><?=$success_msg?></p>
|
||||
<i class="fas fa-times"></i>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?=format_tabs($contents)?>
|
||||
<div class="content-block">
|
||||
<div class="form responsive-width-100">
|
||||
<?=format_form($contents)?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script>
|
||||
document.querySelectorAll("input[type='checkbox']").forEach(checkbox => {
|
||||
checkbox.onclick = () => checkbox.value = checkbox.checked ? 'true' : 'false';
|
||||
});
|
||||
</script>
|
||||
|
||||
<?=template_admin_footer()?>
|
||||
Reference in New Issue
Block a user