implemented additional todo functionality

This commit is contained in:
2025-04-20 20:38:41 -06:00
parent 0753e1867c
commit ab8f1b9ec8
18 changed files with 279 additions and 145 deletions
+20 -7
View File
@@ -7,21 +7,34 @@ if (isset($_POST['ajax_id'])) {
handle_todo();
break;
}
} else
echo 'Received malformed request.';
} else {
$response = [
'error' => 'Malformed URI request.',
];
echo json_encode($response);
}
function handle_todo()
{
$response = [];
include 'functions/todo_functions.php';
if (isset($_POST['todo_id']) && isset($_POST['action_id']) && isset($_POST['status'])) {
$response = ['log' => []];
if (isset($_POST['todo_id']) && isset($_POST['action_id'])) {
$response['log'][] = 'Required parameters met.';
switch ($_POST['action_id']) {
case 'status':
$response['todo_status'] = $_POST['status'];
$response['log'][] = 'Changing status on ' . $_POST['todo_id'] . ' to ' . $_POST['status'] . '.';
change_status($_POST['todo_id'], $_POST['status']);
break;
case 'create_update_todo':
if ($_POST['todo_id'] != -1) {
$response['log'][] = 'Updating todo information on ' . $_POST['todo_id'] . '.';
update_todo($_POST['todo_id'], urldecode($_POST['todo']));
} else {
$response['log'][] = 'Creating todo information on ' . $_POST['todo_id'] . '.';
create_todo(urldecode($_POST['todo']));
}
break;
}
}