More webgui development
This commit is contained in:
+74
-9
@@ -12,6 +12,7 @@ $pagetitle = _('Task');
|
||||
$id = gpc_get_int($_REQUEST, 'id', 0);
|
||||
|
||||
$opt_projects = db_get_opt_proj($user->vid, array(-1 => _('unassigned')));
|
||||
$opt_priority = db_load_enum('task', 'priority', true, true);
|
||||
|
||||
// ========== ACTIONS START ===================================================
|
||||
|
||||
@@ -25,6 +26,7 @@ switch ($submit = form_get_action()) {
|
||||
case 'del': $action = ACT_DELETE; break;
|
||||
|
||||
case 'insert':
|
||||
$p[':vid'] = $user->vid;
|
||||
$p[':projid'] = gpc_get_int($_POST, 'projid');
|
||||
if ($p[':projid'] == -1) {
|
||||
$p[':projid'] = NULL;
|
||||
@@ -37,10 +39,16 @@ switch ($submit = form_get_action()) {
|
||||
case 'update':
|
||||
$p[':taskid'] = $id;
|
||||
$p[':projid'] = gpc_get_int($_POST, 'projid');
|
||||
$p[':plandate'] = gpc_get_string($_POST, 'plandate');
|
||||
$p[':duedate'] = gpc_get_string($_POST, 'duedate');
|
||||
if ($p[':projid'] == -1) {
|
||||
$p[':projid'] = NULL;
|
||||
}
|
||||
$p[':taskname'] = gpc_get_string($_POST, 'taskname');
|
||||
$p[':priority'] = gpc_get_string($_POST, 'priority', 10);
|
||||
if ($p[':priority'] == 'X') {
|
||||
$p[':projid'] = NULL;
|
||||
}
|
||||
db_exec_update('task', $p, 'taskid');
|
||||
$action = ACT_VIEW;
|
||||
break;
|
||||
@@ -65,7 +73,7 @@ if ($action == ACT_DEFAULT):
|
||||
|
||||
echo "<h1>$pagetitle</h1>\n";
|
||||
|
||||
$sql = "SELECT t.taskid, t.projid, t.taskname, p.projname "
|
||||
$sql = "SELECT t.taskid, t.projid, t.taskname, t.priority, p.projname "
|
||||
. "FROM task AS t LEFT JOIN project AS p USING (projid) "
|
||||
. "WHERE p.projid IS NULL OR p.vid=? "
|
||||
. "ORDER BY t.taskid";
|
||||
@@ -83,15 +91,17 @@ echo "<tr>\n";
|
||||
echo '<th>#</th>';
|
||||
echo '<th>', _('Task'), "</th>";
|
||||
echo '<th>', _('Project'), "</th>";
|
||||
echo '<th>', _('Priority'), "</th>";
|
||||
echo "<th></th>";
|
||||
echo "<th></th>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</thead>\n";
|
||||
foreach ($res as $row) {
|
||||
echo "<tr>\n";
|
||||
echo "<td>" . $row['taskid'] . "</td>\n";
|
||||
echo "<td>" . $row['taskname'] . "</td>\n";
|
||||
echo "<td>" . $row['projname'] . "</td>\n";
|
||||
echo "<td>", $row['taskid'], "</td>\n";
|
||||
echo "<td>", $row['taskname'], "</td>\n";
|
||||
echo "<td>", $row['projname'], "</td>\n";
|
||||
echo "<td>", ($opt_priority[$row['priority']] ?? ''), "</td>\n";
|
||||
// Action buttons
|
||||
form_action_buttons($g_scriptname, $row['taskid']);
|
||||
echo "</tr>\n";
|
||||
@@ -102,6 +112,8 @@ echo '<tr><td colspan="6">', sprintf(_('%d records'), count($res)), '</td></tr>'
|
||||
echo "</tfoot>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
form_add_button($g_scriptname);
|
||||
|
||||
elseif ($action == ACT_ADD):
|
||||
// ========== VARIANT: add record =============================================
|
||||
|
||||
@@ -111,7 +123,8 @@ echo '<h2>', _('Add Task'), "</h2>\n";
|
||||
<?php
|
||||
// preselect project if parameter is set
|
||||
$projid = gpc_get_int($_REQUEST, 'projid');
|
||||
form_create_select('projid', _('Project'), $opt_projects, $projid);
|
||||
$opt_none = [-1 => '― none ―'];
|
||||
form_create_select('projid', _('Project'), $opt_none + $opt_projects, $projid);
|
||||
?>
|
||||
<div class="mb-3">
|
||||
<label for="taskname" class="form-label"><?=_('Task')?></label>
|
||||
@@ -127,7 +140,8 @@ form_create_select('projid', _('Project'), $opt_projects, $projid);
|
||||
elseif ($action == ACT_VIEW):
|
||||
// ========== VARIANT: view single record =====================================
|
||||
|
||||
$sql = "SELECT t.taskname, p.projname "
|
||||
$sql = "SELECT t.taskname, t.priority, t.plandate, t.duedate,"
|
||||
. " t.started, t.finished, p.projname "
|
||||
. "FROM task AS t LEFT JOIN project AS p USING (projid) "
|
||||
. "WHERE taskid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -137,15 +151,46 @@ $task = $sth->fetch(PDO::FETCH_OBJ);
|
||||
echo '<h2>', _('View Task'), "</h2>\n";
|
||||
echo '<table class="table">', "\n";
|
||||
echo '<tr><th>', _('Task'),"</th><td>", $task->taskname, "</td></tr>\n";
|
||||
echo '<tr><th>', _('Project'),"</th><td>", $task->projname ?? _('unassigned'), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Project'),"</th><td>", ($task->projname ?? _('unassigned')), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Priority'),"</th><td>", ($task->priority ?? _('none')), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Plan date'),"</th><td>", $task->plandate, "</td></tr>\n";
|
||||
echo '<tr><th>', _('Due date'),"</th><td>", $task->duedate, "</td></tr>\n";
|
||||
echo '<tr><th>', _('Started at'),"</th><td>", $task->started, "</td></tr>\n";
|
||||
echo '<tr><th>', _('Finished at'),"</th><td>", $task->finished, "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
form_view_buttons($g_scriptname, $id);
|
||||
|
||||
echo "<h3>Annotations</h3>";
|
||||
|
||||
$sql = "SELECT noteid, annotation "
|
||||
. "FROM note "
|
||||
. "WHERE notetype='task' AND refid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$id]);
|
||||
if ($sth->rowCount() > 0) {
|
||||
$n = 0;
|
||||
foreach ($sth->fetchAll() as $row) {
|
||||
$n += 1;
|
||||
echo "<p>($n) {$row['annotation']}";
|
||||
echo ' <a title="', _('Edit'), '" href="note.php?f=edit&id=', $row['noteid'], '"><i class="bi-pencil"></i></a>';
|
||||
echo "</p>\n";
|
||||
}
|
||||
} else {
|
||||
echo '<p>', _('No annotations for this task'), "</p>\n";
|
||||
}
|
||||
echo '<div class="container-fluid px-0 my-3">', "\n";
|
||||
echo '<a href="note.php?f=add&t=task&id=', $id, '" class="btn btn-primary" role="button">';
|
||||
echo _('Add note'), "</a>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
echo "<h3>Documents</h3>";
|
||||
echo "<p>Not yet implemented</p>";
|
||||
|
||||
elseif ($action == ACT_EDIT):
|
||||
// ========== VARIANT: edit single record =====================================
|
||||
|
||||
$sql = "SELECT taskname, projid "
|
||||
$sql = "SELECT taskname, projid, priority, plandate, duedate, started, finished "
|
||||
. "FROM task "
|
||||
. "WHERE taskid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -162,7 +207,27 @@ echo '<h2>', _('Edit Task'), "</h2>\n";
|
||||
<input type="text" class="form-control" id="taskname" name="taskname" value="<?=$task->taskname ?>">
|
||||
</div>
|
||||
<?php
|
||||
form_create_select('projid', _('Project'), $opt_projects, $task->projid);
|
||||
$opt_none = [-1 => '― none ―'];
|
||||
form_create_select('projid', _('Project'), $opt_none + $opt_projects, $task->projid);
|
||||
form_create_select('priority', _('Priority'), $opt_none + $opt_priority, $task->priority ?? 'X');
|
||||
?>
|
||||
<div class="mb-3">
|
||||
<label for="plandate" class="form-label"><?=_('Plan date')?></label>
|
||||
<input type="date" class="form-control" id="plandate" name="plandate" value="<?=$task->plandate ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="duedate" class="form-label"><?=_('Due date')?></label>
|
||||
<input type="date" class="form-control" id="duedate" name="duedate" value="<?=$task->duedate ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="started" class="form-label"><?=_('Started at')?></label>
|
||||
<input type="datetime-local" class="form-control" id="started" name="started" value="<?=$task->started ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="finished" class="form-label"><?=_('Finished at')?></label>
|
||||
<input type="datetime-local" class="form-control" id="finished" name="finished" value="<?=$task->finished ?>">
|
||||
</div>
|
||||
<?php
|
||||
form_edit_buttons($g_scriptname, $id);
|
||||
echo "</form>\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user