aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateja <mail@matejamaric.com>2020-10-04 04:45:20 +0200
committerMateja <mail@matejamaric.com>2020-10-04 04:45:20 +0200
commit49a53b71175f14d988ee79ef202743700eab0661 (patch)
treebd1c4e0edf45a38c7e2c63983f5c49ececcd9e56
parent825e8f41908b9a81d4bc64103ba34d441aecb9d5 (diff)
downloadold-php-yota-49a53b71175f14d988ee79ef202743700eab0661.tar.gz
old-php-yota-49a53b71175f14d988ee79ef202743700eab0661.zip
lol i need to debug...
-rw-r--r--edit.php80
-rw-r--r--request-edit.js5
2 files changed, 45 insertions, 40 deletions
diff --git a/edit.php b/edit.php
index 713a7a5..c3cd0db 100644
--- a/edit.php
+++ b/edit.php
@@ -21,19 +21,19 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_SESSION['admin']) && $_SESSI
try {
$recvData = json_decode(file_get_contents("php://input"));
- $recvData.id = clear_input($recvData.id);
- $recvData.approved = clear_input($recvData.approved);
- $recvData.specialCall = clear_input($recvData.specialCall);
- $recvData.fromTime = clear_input($recvData.fromTime);
- $recvData.toTime = clear_input($recvData.toTime);
- $recvData.frequencies = clear_input($recvData.frequencies);
- $recvData.modes = clear_input($recvData.modes);
- $recvData.operatorCall = clear_input($recvData.operatorCall);
- $recvData.operatorName = clear_input($recvData.operatorName);
- $recvData.operatorEmail = clear_input($recvData.operatorEmail);
- $recvData.operatorPhone = clear_input($recvData.operatorPhone);
- $recvData.qso = clear_input($recvData.qso);
- } catch {
+ $recvData->id = clear_input($recvData->id);
+ $recvData->approved = clear_input($recvData->approved);
+ $recvData->specialCall = clear_input($recvData->specialCall);
+ $recvData->fromTime = clear_input($recvData->fromTime);
+ $recvData->toTime = clear_input($recvData->toTime);
+ $recvData->frequencies = clear_input($recvData->frequencies);
+ $recvData->modes = clear_input($recvData->modes);
+ $recvData->operatorCall = clear_input($recvData->operatorCall);
+ $recvData->operatorName = clear_input($recvData->operatorName);
+ $recvData->operatorEmail = clear_input($recvData->operatorEmail);
+ $recvData->operatorPhone = clear_input($recvData->operatorPhone);
+ $recvData->qso = clear_input($recvData->qso);
+ } catch (Exception $e) {
die("Can't decode JSON!");
}
@@ -54,51 +54,51 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_SESSION['admin']) && $_SESSI
WHERE id=:id";
$stmt = $conn->prepare($sql);
- $stmt->bindParam(':approved', $recvData.approved);
- $stmt->bindParam(':specialCall', $recvData.specialCall);
- $stmt->bindParam(':fromTime', $recvData.fromTime);
- $stmt->bindParam(':toTime', $recvData.toTime);
- $stmt->bindParam(':frequencies', $recvData.frequencies);
- $stmt->bindParam(':modes', $recvData.modes);
- $stmt->bindParam(':operatorCall', $recvData.operatorCall);
- $stmt->bindParam(':operatorName', $recvData.operatorName);
- $stmt->bindParam(':operatorEmail', $recvData.operatorEmail);
- $stmt->bindParam(':operatorPhone', $recvData.operatorPhone);
- $stmt->bindParam(':qso', $recvData.qso);
+ $stmt->bindParam(':approved', $recvData->approved);
+ $stmt->bindParam(':specialCall', $recvData->specialCall);
+ $stmt->bindParam(':fromTime', $recvData->fromTime);
+ $stmt->bindParam(':toTime', $recvData->toTime);
+ $stmt->bindParam(':frequencies', $recvData->frequencies);
+ $stmt->bindParam(':modes', $recvData->modes);
+ $stmt->bindParam(':operatorCall', $recvData->operatorCall);
+ $stmt->bindParam(':operatorName', $recvData->operatorName);
+ $stmt->bindParam(':operatorEmail', $recvData->operatorEmail);
+ $stmt->bindParam(':operatorPhone', $recvData->operatorPhone);
+ $stmt->bindParam(':qso', $recvData->qso);
$stmt->execute();
- $sendData->action=$recvData.action;
+ $sendData->action=$recvData->action;
echo json_encode($sendData);
} else if ($recvData->action == "restore") {
$stmt = $conn->prepare("SELECT * FROM activities WHERE id=:id");
- $stmt->bindParam(':id', $recvData.id);
+ $stmt->bindParam(':id', $recvData->id);
$stmt->execute();
$row = $stmt->fetch();
$sendData->action=$recvData->action;
- $sendData->id=$row.id;
- $sendData->approved=$row.approved;
- $sendData->specialCall=$row.specialCall;
- $sendData->fromTime=$row.fromTime;
- $sendData->toTime=$row.toTime;
- $sendData->frequencies=$row.frequencies;
- $sendData->modes=$row.modes;
- $sendData->operatorCall=$row.operatorCall;
- $sendData->operatorName=$row.operatorName;
- $sendData->operatorEmail=$row.operatorEmail;
- $sendData->operatorPhone=$row.operatorPhone;
- $sendData->qso=$row.qso;
+ $sendData->id=$row->id;
+ $sendData->approved=$row->approved;
+ $sendData->specialCall=$row->specialCall;
+ $sendData->fromTime=$row->fromTime;
+ $sendData->toTime=$row->toTime;
+ $sendData->frequencies=$row->frequencies;
+ $sendData->modes=$row->modes;
+ $sendData->operatorCall=$row->operatorCall;
+ $sendData->operatorName=$row->operatorName;
+ $sendData->operatorEmail=$row->operatorEmail;
+ $sendData->operatorPhone=$row->operatorPhone;
+ $sendData->qso=$row->qso;
echo json_encode($sendData);
} else if ($recvData->action == "delete") {
$stmt = $conn->prepare("DELETE FROM activities WHERE id=:id");
- $stmt->bindParam(':id', $recvData.id);
+ $stmt->bindParam(':id', $recvData->id);
$stmt->execute();
- $sendData->action=$recvData.action;
+ $sendData->action=$recvData->action;
echo json_encode($sendData);
}
} catch ( Exception $e ) {
diff --git a/request-edit.js b/request-edit.js
index 467a7d0..60c0d55 100644
--- a/request-edit.js
+++ b/request-edit.js
@@ -18,6 +18,8 @@ function btnAction(action, btn) {
operatorPhone: trData[11].firstElementChild.innerHTML
}
+ console.log(actionData);
+
if (actionData.action == 'delete')
if (confirm("Are you sure you want to delete reservation #" + actionData.id + " made by " + actionData.operatorSign + "?"))
trDom.remove();
@@ -46,6 +48,9 @@ function btnAction(action, btn) {
document.getElementById("notice").innerHTML = "Record's #" + actionData.id + " data restored.";
} else if (response.action == "delete") {
document.getElementById("notice").innerHTML = "Record #" + actionData.id + " deleted.";
+ } else {
+ console.log("Nothing?");
+ console.log(this.responseText);
}
} catch {
console.log(this.responseText);