First version, for githup; UNSTABLE, DO NOT USE!
This commit is contained in:
46
www/intern/scripts/trainer/ajax-fetch_temp_order.php
Normal file
46
www/intern/scripts/trainer/ajax-fetch_temp_order.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) session_start();
|
||||
|
||||
if (empty($_SESSION['access_granted_trainer']) || $_SESSION['access_granted_trainer'] !== true || empty($_SESSION['passcodetrainer_id']) || intval($_SESSION['passcodetrainer_id']) < 1 ) {
|
||||
http_response_code(403);
|
||||
exit;
|
||||
}
|
||||
|
||||
$userId = $_SESSION['passcodetrainer_id'];
|
||||
|
||||
if (!isset($baseDir)) $baseDir = $_SERVER['DOCUMENT_ROOT'];
|
||||
|
||||
$type = 'tr';
|
||||
|
||||
$data = include $baseDir . '/../scripts/db/db-verbindung-script.php';
|
||||
|
||||
if ($data['success'] === false){
|
||||
echo json_encode(['success' => false, 'message' => $data['message']]);
|
||||
exit;
|
||||
}
|
||||
|
||||
require $baseDir . '/../scripts/db/db-tables.php';
|
||||
|
||||
// --- Check for existing open order ---
|
||||
$sql = "SELECT * FROM `$tableOrders` WHERE user_id = ? AND order_status = 0 LIMIT 1";
|
||||
$stmt = $mysqli->prepare($sql);
|
||||
$stmt->bind_param("i", $userId);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
$result = $result->fetch_assoc();
|
||||
$stmt->close();
|
||||
|
||||
if ($result) {
|
||||
$_SESSION['order_id'] = $result['order_id'];
|
||||
$_SESSION['order_preis'] = $result['preis'];
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true, 'result' => $result]);
|
||||
exit;
|
||||
?>
|
||||
Reference in New Issue
Block a user