Compare commits
24 Commits
baefedd775
...
6f6c605cc9
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f6c605cc9 | |||
| c09ab3c48e | |||
| 34af4254a2 | |||
| e3b7d9351f | |||
| 445dae586e | |||
| 7cf29a7607 | |||
| 6b16ddfc31 | |||
| a9a4667231 | |||
| 54baa5c305 | |||
| 13e1607d40 | |||
| fdea1600f3 | |||
| dc52cc86f6 | |||
| 39678d34c1 | |||
| 5b4118f20d | |||
| db2e8ede95 | |||
| 176fc0736b | |||
| 8f47e90251 | |||
| 6222ca71a4 | |||
| d4a53f0844 | |||
| 18b9a73cc7 | |||
| f3e32d4d92 | |||
| c59df02d6f | |||
| 5514113103 | |||
| cd3b1dbe7a |
|
|
@ -10,7 +10,7 @@ $data["error"] = false;
|
|||
if ( !isset($_REQUEST['id']) ) pushData("Invalid completion request");
|
||||
$task = new Task(intval($_REQUEST['id']));
|
||||
if ( $task->getID() == 0 ) pushData("Task not found");
|
||||
if ( isset($_REQUEST['incomplete']) && ($_REQUEST['incomplete'] == "1") ) {
|
||||
if ( isset($_REQUEST['complete']) && ($_REQUEST['complete'] == "0") ) {
|
||||
$task->setCompleteTime(Task::INCOMPLETE);
|
||||
} else {
|
||||
$task->setCompleteTime(Task::NOW);
|
||||
|
|
|
|||
|
|
@ -58,12 +58,13 @@ class Task implements JsonSerializable {
|
|||
}
|
||||
|
||||
public function getCompleted($flag = 0) {
|
||||
$completed = (is_null($this->getCompleteTime())) ? false : true;
|
||||
switch ($flag) {
|
||||
case AppDB::BOOLEANDB:
|
||||
return ($this->completed) ? "true" : "false";
|
||||
return ($completed) ? "true" : "false";
|
||||
break;
|
||||
default:
|
||||
return $this->completed;
|
||||
return $completed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -220,6 +221,7 @@ class Task implements JsonSerializable {
|
|||
'createdate' => $this->getCreateTime(SHORTDATE),
|
||||
'duetime' => $this->getDueTime(),
|
||||
'duedate' => $this->getDueTime(SHORTDATE),
|
||||
'completed' => $this->getCompleted(),
|
||||
'completetime' => $this->getCompleteTime(),
|
||||
'completedate' => $this->getCompleteTime(SHORTDATE)
|
||||
];
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ div.mainbody {
|
|||
flex-basis: 100%;
|
||||
flex: 2;
|
||||
text-align: left;
|
||||
padding-left: 0.75em;
|
||||
}
|
||||
.inline {
|
||||
display: inline;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ $deg = html_entity_decode("°");
|
|||
$image = imagecreate(480, 800);
|
||||
$white = imagecolorallocate($image, 0, 0, 0);
|
||||
$black = imagecolorallocate($image, 255, 255, 255);
|
||||
//$white = imagecolorallocate($image, 255, 255, 255);
|
||||
//$black = imagecolorallocate($image, 0, 0, 0);
|
||||
//$red = imagecolorallocate($image, 255, 0, 0);
|
||||
$red = $black;
|
||||
$transparent = imagecolorallocatealpha($image, 255, 255, 255, 127);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ include "htmlheader.php";
|
|||
<div id='mainbody' class='mainbody'>
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#tasks">Tasks</a></li>
|
||||
<li id="tab-tasks"><a href="#tasks">Tasks</a></li>
|
||||
<li><a href="#newtask">New Task</a></li>
|
||||
<li><a href="#stats">Stats</a></li>
|
||||
<li><a href="#panel">Img</a></li>
|
||||
|
|
@ -44,7 +44,7 @@ include "htmlheader.php";
|
|||
</div>
|
||||
<div id="newtask">
|
||||
<p>Editing/Creating Tasks</p>
|
||||
<div class="noshow"><input id="form_id" type="text"></div>
|
||||
<div class="noshow"><input id="form_id" type="text" value="0"></div>
|
||||
<div class="row">
|
||||
<div class="column-left">
|
||||
Title:
|
||||
|
|
|
|||
105
js/main.js
105
js/main.js
|
|
@ -1,19 +1,22 @@
|
|||
var chart;
|
||||
let chart;
|
||||
const TASKCOMPLETE = true;
|
||||
const TASKINCOMPLETE = false;
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#tabs").tabs({ active: 0 });
|
||||
$("#form_duedate").datepicker();
|
||||
$("#form_submit").click(function() { submitTask(); });
|
||||
$("#form_delete").click(function() { deleteTask(); });
|
||||
$("#form_showall").click(function() { toggleShowAll(); });
|
||||
$("#form_setcomplete").click(function() { setTaskComplete(); });
|
||||
$("#form_setincomplete").click(function() { setTaskComplete(true); });
|
||||
$("#form_cancel").click(function() { resetForm(true); });
|
||||
$("#filter_reset").click(function() { $("#form_filter").val(""); });
|
||||
$("#panelimg").click(function() { updateImage(); });
|
||||
//$("#tabs").on("tabsactivate", function(event, ui) { console.log($("#tabs").tabs('option', 'active')); });
|
||||
$("#form_submit").on("click", function() { submitTask(); });
|
||||
$("#form_delete").on("click", function() { deleteTask(); });
|
||||
$("#form_showall").on("change", function() { toggleShowAll(); });
|
||||
$("#form_setcomplete").on("click", function() { setTaskCompleteState(TASKCOMPLETE); });
|
||||
$("#form_setincomplete").on("click", function() { setTaskCompleteState(TASKINCOMPLETE); });
|
||||
$("#form_cancel").on("click", function() { resetForm(true); });
|
||||
$("#filter_reset").on("click", function() { $("#form_filter").val(""); });
|
||||
$("#panelimg").on("click", function() { updateImage(); });
|
||||
$("#tab-tasks").on("click", function() { getTasks(); });
|
||||
$("#tasklist").on("click", ".task", function() { editTask(this.dataset.id); });
|
||||
getTasks();
|
||||
var chartOptions = {
|
||||
let chartOptions = {
|
||||
chart: {
|
||||
type: 'bar',
|
||||
height: 550
|
||||
|
|
@ -73,10 +76,12 @@ function updateChart() {
|
|||
|
||||
function deleteTask() {
|
||||
if ( $("#form_id").val() == "0" ) return;
|
||||
var doDelete = confirm("Are you certain you wish to delete this task?\n\nIf so then click 'OK'.")
|
||||
const doDelete = confirm("Are you certain you wish to delete this task?\n\nIf so then click 'OK'.")
|
||||
if ( !doDelete ) return;
|
||||
$("#form_delete").prop("disabled", true);
|
||||
$.ajax({
|
||||
url: 'ajax/task-delete.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id: $("#form_id").val(),
|
||||
|
|
@ -93,38 +98,52 @@ function deleteTask() {
|
|||
},
|
||||
error: function(jqo, stat, error) {
|
||||
toastr.error("Could not communicate with server!", "Server Error");
|
||||
},
|
||||
complete: function() {
|
||||
$("#form_delete").prop("disabled", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setTaskComplete(incomplete = false) {
|
||||
function setTaskCompleteState(complete = TASKCOMPLETE) {
|
||||
if ( $("#form_id").val() == "0" ) return;
|
||||
$("#form_setcomplete, #form_setincomplete").prop("disabled", true);
|
||||
$.ajax({
|
||||
url: 'ajax/task-setcomplete.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id: $("#form_id").val(),
|
||||
incomplete: (incomplete) ? 1 : 0
|
||||
complete: (complete) ? 1 : 0
|
||||
},
|
||||
success: function(data, stat, jqo) {
|
||||
if ( data.error ) {
|
||||
toastr.error(data.message, "Submission Error");
|
||||
} else {
|
||||
toastr.success(data.message, "Task Complete");
|
||||
getTasks();
|
||||
updateImage();
|
||||
resetForm(true);
|
||||
return;
|
||||
}
|
||||
if ( !data.task ) {
|
||||
toastr.error("No task returned", "API Error);
|
||||
return;
|
||||
}
|
||||
toastr.success(data.message, (data.task.completed) ? "Task Complete" : "Task Incomplete");
|
||||
getTasks();
|
||||
updateImage();
|
||||
resetForm(true);
|
||||
},
|
||||
error: function(jqo, stat, error) {
|
||||
toastr.error("Could not communicate with server!", "Server Error");
|
||||
},
|
||||
complete: function() {
|
||||
$("#form_setcomplete, #form_setincomplete").prop("disabled", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function toggleShowAll() {
|
||||
const previousValue = ! $("#form_showall").prop('checked');
|
||||
$.ajax({
|
||||
url: 'ajax/toggleshowall.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
showall: ($("#form_showall").prop('checked')) ? 1 : 0,
|
||||
|
|
@ -132,21 +151,25 @@ function toggleShowAll() {
|
|||
success: function(data, stat, jqo) {
|
||||
if ( data.error ) {
|
||||
toastr.error(data.message, "Form Data Error");
|
||||
} else {
|
||||
toastr.success(data.message, "Task List");
|
||||
getTasks();
|
||||
$("#form_showall").prop('checked', previousValue);
|
||||
return;
|
||||
}
|
||||
$("#form_showall").prop('checked', data.showall);
|
||||
toastr.success(data.message, "Task List");
|
||||
getTasks();
|
||||
},
|
||||
error: function(jqo, stat, error) {
|
||||
toastr.error("Could not communicate with server!", "Server Error");
|
||||
$("#form_showall").prop('checked', previousValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function submitTask() {
|
||||
$("#form_submit").prop("disabled", true);
|
||||
$.ajax({
|
||||
url: 'ajax/task-submit.php',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id: $("#form_id").val(),
|
||||
|
|
@ -162,31 +185,24 @@ function submitTask() {
|
|||
toastr.success(data.message, "Success");
|
||||
getTasks();
|
||||
resetForm(true);
|
||||
$("#form_id").val("");
|
||||
$("#form_title").val("");
|
||||
$("#form_description").val("");
|
||||
$("#form_createdate").val("Now");
|
||||
$("#form_duedate").val("");
|
||||
$("#form_completedate").html("");
|
||||
$("#form_completerow").addClass("noshow");
|
||||
$("#column_deletebutton").addClass("noshow");
|
||||
$("#column_incompletebutton").addClass("noshow");
|
||||
$("#column_completebutton").addClass("noshow");
|
||||
updateImage();
|
||||
}
|
||||
},
|
||||
error: function(jqo, stat, error) {
|
||||
toastr.error("Could not communicate with server!", "Server Error");
|
||||
},
|
||||
complete: function() {
|
||||
$("#form_submit").prop("disabled", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function resetForm(backToTasks = false) {
|
||||
if ( backToTasks ) $("#tabs").tabs("option", "active", 0);
|
||||
$("#form_id").val("");
|
||||
$("#form_id").val("0");
|
||||
$("#form_title").val("");
|
||||
$("#form_description").val("");
|
||||
$("#form_createdate").val("Now");
|
||||
$("#form_createdate").text("Now");
|
||||
$("#form_duedate").val("");
|
||||
$("#form_completedate").html("");
|
||||
$("#form_completerow").addClass("noshow");
|
||||
|
|
@ -200,10 +216,14 @@ function getTasks() {
|
|||
url: 'ajax/task-list.php',
|
||||
dataType: 'json',
|
||||
success: function(data, stat, jqo) {
|
||||
if ( data.error ) {
|
||||
toastr.error(data.message, "Error retrieving task list");
|
||||
return;
|
||||
}
|
||||
$("#form_showall").prop('checked', data.showalltasks);
|
||||
var show = "";
|
||||
let show = "";
|
||||
data.tasks.forEach(function(task, index) {
|
||||
show += "<div class='task' id='task_" + task.id + "'>";
|
||||
show += "<div class='task' data-id='" + task.id + "'>";
|
||||
show += "<div><span class='strongtext'>Title: </span>" + task.title_safe + "</div>";
|
||||
show += "<div><span class='strongtext'>Description: </span>" + task.description_safe + "</div>";
|
||||
show += "<div><span class='strongtext'>Priority: </span>" + task.priority + "</div>";
|
||||
|
|
@ -213,11 +233,6 @@ function getTasks() {
|
|||
show += "</div>";
|
||||
});
|
||||
$("#tasklist").html(show);
|
||||
data.tasks.forEach(function(task, index) {
|
||||
$("#task_"+task.id).click(function() {
|
||||
editTask(task.id);
|
||||
});
|
||||
});
|
||||
},
|
||||
error: function(jqo, stat, error) {
|
||||
toastr.error("Could not communicate with server!", "Server Error");
|
||||
|
|
@ -241,17 +256,21 @@ function editTask(taskId) {
|
|||
$("#form_duedate").val(data.task.duedate);
|
||||
$("#form_createdate").text(data.task.createdate);
|
||||
if ( data.task.completed ) {
|
||||
$("#form_createrow").removeClass("noshow");
|
||||
$("#form_completedate").text(data.task.completedate);
|
||||
$("#form_completerow").removeClass("noshow");
|
||||
$("#column_incompletebutton").removeClass("noshow");
|
||||
$("#column_completebutton").addClass("noshow");
|
||||
} else {
|
||||
$("#form_completedate").text("");
|
||||
$("#form_completerow").addClass("noshow");
|
||||
$("#column_incompletebutton").addClass("noshow");
|
||||
$("#column_completebutton").removeClass("noshow");
|
||||
}
|
||||
$("#column_deletebutton").removeClass("noshow");
|
||||
$("#tabs").tabs("option", "active", 1);
|
||||
updateImage();
|
||||
} else {
|
||||
toastr.warn("Task not found!", "Task Error");
|
||||
toastr.warning("Task not found!", "Task Error");
|
||||
}
|
||||
},
|
||||
error: function(jqo, stat, error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user