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