partially implemented todo tracker
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
function todo_actions()
|
||||
{
|
||||
$actions = '
|
||||
<div class="todo_actions">
|
||||
<form method="post">
|
||||
<button name="action" value="new">New</button>
|
||||
<button name="action" value="new">New</button>
|
||||
<button name="action" value="new">New</button>
|
||||
<button name="action" value="new">New</button>
|
||||
<button name="action" value="new">New</button>
|
||||
<button name="action" value="new">New</button>
|
||||
<button name="action" value="new">New</button>
|
||||
</form>
|
||||
</div>
|
||||
';
|
||||
|
||||
return $actions;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
function todo_category($category, $todos)
|
||||
{
|
||||
$category = '
|
||||
<div class="todo_category med_border padding">
|
||||
<h4 class="padding">' . ucwords($category) . '</h4>
|
||||
<div class="line bottom_margin"></div>
|
||||
' . todo_list($todos) . '
|
||||
</div>
|
||||
';
|
||||
|
||||
return $category;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
function sort_by_completion($a, $b)
|
||||
{
|
||||
// Ensure $a and $b are arrays before proceeding
|
||||
if (!is_array($a) || !is_array($b)) {
|
||||
// Handle the case where one or both are not arrays.
|
||||
// This shouldn't ideally happen with uasort on your $categories array,
|
||||
// but adding a safeguard is good practice.
|
||||
return 0; // Maintain original order if not arrays
|
||||
}
|
||||
|
||||
$a_completed = true;
|
||||
foreach ($a as $todo) {
|
||||
if (isset($todo['status']) && $todo['status'] !== 'completed') {
|
||||
$a_completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$b_completed = true;
|
||||
foreach ($b as $todo) {
|
||||
if (isset($todo['status']) && $todo['status'] !== 'completed') {
|
||||
$b_completed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($a_completed && $b_completed) {
|
||||
return 0;
|
||||
} elseif ($a_completed && !$b_completed) {
|
||||
return 1;
|
||||
} elseif (!$a_completed && $b_completed) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function todo_display($todos)
|
||||
{
|
||||
$categories = [];
|
||||
while ($row = $todos->fetch_assoc())
|
||||
$categories[$row['category']][] = $row;
|
||||
|
||||
foreach ($categories as $c)
|
||||
uasort($c, 'sort_by_completion');
|
||||
|
||||
$display = '
|
||||
<div class="todo_display">
|
||||
' . todo_actions() . '
|
||||
<div class="todo_category_window">
|
||||
';
|
||||
|
||||
foreach ($categories as $c)
|
||||
$c = array_reverse($c);
|
||||
|
||||
foreach (array_keys($categories) as $key)
|
||||
$display .= todo_category($key, $categories[$key]);
|
||||
|
||||
$display .= '
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
return $display;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
function todo_item($todo)
|
||||
{
|
||||
$item = '
|
||||
<div class="todo_item bottom_margin top_padding bottom_padding sm_border">
|
||||
<div class="row left_margin">
|
||||
<div class="column center">
|
||||
<label class="form_checkbox_container no_margin">
|
||||
<input type="hidden" name="todo_id" value="' . $todo['todo_id'] . '">
|
||||
|
||||
<input type="checkbox"' . ($todo['status'] == 'completed' ? ' checked' : '') . '>
|
||||
<span class="checkmark no_margin"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="column center">
|
||||
<small>' . $todo['task'] . '</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="todo_item_details" style="display: none;">
|
||||
|
||||
</div>
|
||||
';
|
||||
|
||||
return $item;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
function todo_list($todos)
|
||||
{
|
||||
$list = '
|
||||
<div class="todo_list">
|
||||
';
|
||||
|
||||
foreach ($todos as $todo)
|
||||
$list .= todo_item($todo);
|
||||
|
||||
$list .= '
|
||||
</div>
|
||||
';
|
||||
|
||||
return $list;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
function modal() {}
|
||||
Reference in New Issue
Block a user