vid, array(-1 => _('unassigned'))); $opt_priority = db_load_enum('task', 'priority', true, true); // ========== ACTIONS START =================================================== switch ($submit = form_get_action()) { case NULL: break; case 'add': $action = ACT_ADD; break; case 'view': $action = ACT_VIEW; break; case 'edit': $action = ACT_EDIT; break; 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; } $p[':taskname'] = gpc_get_string($_POST, 'taskname'); $id = db_exec_insert('task', $p); $action = ACT_VIEW; break; 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; case 'delete': break; default: $g_error->Add(sprintf(_("Unknown function '%s'!"), $submit)); $valid = FALSE; } // ========== ACTIONS END ===================================================== require 'header.php'; // ========== PAGE CONTENT ==================================================== if ($action == ACT_DEFAULT): // ========== VARIANT: default behavior ======================================= echo "
| # | '; echo '', _('Task'), " | "; echo '', _('Project'), " | "; echo '', _('Priority'), " | "; echo ""; echo " | \n"; echo " |
|---|---|---|---|---|---|
| ", $row['taskid'], " | \n"; echo "", $row['taskname'], " | \n"; echo "", $row['projname'], " | \n"; echo "", ($opt_priority[$row['priority']] ?? ''), " | \n"; // Action buttons form_action_buttons($g_scriptname, $row['taskid']); echo "||
| ', sprintf(_('%d records'), count($res)), ' | |||||
| ', _('Task')," | ", $task->taskname, " |
|---|---|
| ', _('Project')," | ", ($task->projname ?? _('unassigned')), " |
| ', _('Priority')," | ", ($task->priority ?? _('none')), " |
| ', _('Plan date')," | ", $task->plandate, " |
| ', _('Due date')," | ", $task->duedate, " |
| ', _('Started at')," | ", $task->started, " |
| ', _('Finished at')," | ", $task->finished, " |
($n) {$row['annotation']}"; echo ' '; echo "
\n"; } } else { echo '', _('No annotations for this task'), "
\n"; } echo 'Not yet implemented
"; elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== $sql = "SELECT taskname, projid, priority, plandate, duedate, started, finished " . "FROM task " . "WHERE taskid=?"; $sth = $pdo->prepare($sql); $sth->execute([$id]); $task = $sth->fetch(PDO::FETCH_OBJ); echo '