Commit f72c1bcc by mhasan

added functionality to view page

parent 062b200e
......@@ -2557,7 +2557,7 @@ textarea.form-control {
}
}
.btn {
/* .btn {
display: inline-block;
ont-weight: 400;
color: #EBEBEB;
......@@ -2577,6 +2577,29 @@ textarea.form-control {
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
} */
.btn {
display: inline-block;
font-weight: 400;
color: #495057;
text-align: center;
vertical-align: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: transparent;
border: 1px solid transparent;
padding: 0.375rem 0.75rem;
font-size: 1rem;
line-height: 1.5;
border-radius: 0.25rem;
-webkit-transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
}
@media (prefers-reduced-motion: reduce) {
......
......@@ -23,9 +23,15 @@ class Task
}
function all($pdo, &$taskArr) {
function all($pdo, &$taskArr, $comp) {
// $date = date('Y-m-d');
$querry;
if(is_null($comp)) {
$querry = sprintf("SELECT * FROM %s ORDER BY t_date ASC;", $_SESSION['userName']);
}
else{
$querry = sprintf("SELECT * FROM %s WHERE task_completion = '%s' ORDER BY t_date ASC;", $_SESSION['userName'],$comp);
}
$pdo_st = $pdo->query($querry);
$pdo_st->setFetchMode(PDO::FETCH_ASSOC);
while ($row = $pdo_st->fetch()) // Takes 1 row of the data table, stores into an assoc array called row, elements of each row can be called by column name.
......@@ -35,9 +41,14 @@ function all($pdo, &$taskArr) {
}
}
function today($pdo, &$taskArr) {
function today($pdo, &$taskArr, $comp) {
$date = date('Y-m-d');
if(is_null($comp)) {
$querry = sprintf("SELECT * FROM %s WHERE t_date >= '%s' ORDER BY t_date ASC;", $_SESSION['userName'],$date);
}
else {
$querry = sprintf("SELECT * FROM %s WHERE t_date >= '%s' AND task_completion = '%s' ORDER BY t_date ASC;", $_SESSION['userName'],$date,$comp);
}
$pdo_st = $pdo->query($querry);
$pdo_st->setFetchMode(PDO::FETCH_ASSOC);
while ($row = $pdo_st->fetch()) // Takes 1 row of the data table, stores into an assoc array called row, elements of each row can be called by column name.
......@@ -47,8 +58,12 @@ function today($pdo, &$taskArr) {
}
}
function custom($pdo, &$taskArr, $inputDate) {
function custom($pdo, &$taskArr, $inputDate, $comp) {
if( is_null($comp)) {
$querry = sprintf("SELECT * FROM %s WHERE t_date >= '%s' ORDER BY t_date ASC;", $_SESSION['userName'],$inputDate);
} else {
$querry = sprintf("SELECT * FROM %s WHERE t_date >= '%s' AND task_completion = '%s' ORDER BY t_date ASC;", $_SESSION['userName'],$inputDate,$comp);
}
$pdo_st = $pdo->query($querry);
$pdo_st->setFetchMode(PDO::FETCH_ASSOC);
while ($row = $pdo_st->fetch()) // Takes 1 row of the data table, stores into an assoc array called row, elements of each row can be called by column name.
......@@ -61,19 +76,19 @@ function custom($pdo, &$taskArr, $inputDate) {
if ($amount == 'all') {
try {
all($pdo,$taskArray);
all($pdo,$taskArray, $completion);
} catch (PDOException $p) {
echo ($p->getMessage() . " " . $p->getLine());
}
} elseif ($amount == 'today'){
try {
today($pdo,$taskArray);
today($pdo,$taskArray, $completion);
} catch (PDOException $p) {
echo ($p->getMessage() . " " . $p->getLine());
}
} elseif( $amount == 'custom') {
try {
custom($pdo,$taskArray,$custom);
custom($pdo,$taskArray,$custom, $completion);
} catch (PDOException $p) {
echo ($p->getMessage() . " " . $p->getLine());
}
......
......@@ -14,6 +14,14 @@ $twig = new \Twig\Environment($loader, [
]);
$twig->addExtension(new \Twig\Extension\DebugExtension());
$completion;
if($_POST['completion'] == 'done') {
$completion = 1;
} elseif ($_POST['completion'] == 'todo') {
$completion = 0;
} else {
$completion = null;
}
if(isset($_SESSION['userName'])) {
$amount = $_POST['amount'];
$custom = $_POST['custom'];
......
......@@ -32,7 +32,7 @@
</nav>
{% if tasks is not null %}
<h2 style="text-align: center; margin-top:80px"> View Tasks for today</h2>
<h2 style="text-align: center; margin-top:80px"> View Tasks</h2>
<form method='POST' action="view.php" id = "select">
<select name = "amount" id = "selectElement" form = "select" onchange="enableInput(this.options[this.selectedIndex].value);">
<option value = "today"> Today</option>
......@@ -42,11 +42,18 @@
<br> <br>
<input type="text" name = "custom" id="dateInput" onkeyup="dateValid();" disabled>
<br> <br>
<select name = "completion" id='selectComp' form='select'>
<option value="todo"> To do </option>
<option value="done"> Done</option>
<option value="all">All</option>
</select>
<input type="submit" name = "submit" id = "submit" value = "submit">
</form>
<table class="table table-success table-hover" style="margin-left:auto; margin-right:auto;margin-top: 35px">
<table class="table table-dark table-hover" style="margin-left:auto; margin-right:auto;margin-top: 35px">
<tr>
<th class="table-info"> STATUS </th>
......@@ -67,15 +74,14 @@
{% for task in tasks %}
{% if 1 in task.task_completion %}
<tr class="table-danger">
<tr class="table-success">
<td> DONE </td>
<td>{{ task.taskID }}</td>
<td>{{ task.t_date }}</td>
<td>{{ task.t_time }}</td>
<td>{{ task.task }}</td>
<td> <input class="btn btn-warning" type='submit' form='done' value='done?' name={{task.taskID}}> </input>
</td>
<td> <input class="btn btn-secondary" type='submit' form='edit' value='edit' name={{task.taskID}}> </td>
<td> <input class="btn btn-warning" type='submit' form='done' value='done?' name={{task.taskID}}> </input></td>
<td> <input class="btn btn-primary" type='submit' form='edit' value='edit' name={{task.taskID}}> </td>
<td> <input class="btn btn-danger" type='submit' form='delete' value='delete' name={{task.taskID}}> </td>
</tr>
{% else %}
......@@ -85,9 +91,8 @@
<td>{{ task.t_date }}</td>
<td>{{ task.t_time }}</td>
<td>{{ task.task }}</td>
<td> <input class="btn btn-warning" type='submit' form='done' value='done?' name={{task.taskID}}> </input>
</td>
<td> <input class="btn btn-secondary" type='submit' form='edit' value='edit' name={{task.taskID}}> </td>
<td> <input class="btn btn-warning" type='submit' form='done' value='done?' name={{task.taskID}}> </input></td>
<td> <input class="btn btn-primary" type='submit' form='edit' value='edit' name={{task.taskID}}> </td>
<td> <input class="btn btn-danger" type='submit' form='delete' value='delete' name={{task.taskID}}> </td>
</tr>
{% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment