Webgui: filters and pagination
This commit is contained in:
+10
-20
@@ -30,34 +30,24 @@ switch ($submit = form_get_action()) {
|
||||
$p[':projid'] = NULL;
|
||||
}
|
||||
$p[':taskname'] = gpc_get_string($_POST, 'taskname');
|
||||
$keys = array_keys($p);
|
||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
|
||||
$pnames = join(',', $keys);
|
||||
$sth = $pdo->prepare("INSERT INTO task ($fields) VALUES ($pnames)");
|
||||
try {
|
||||
$sth->execute($p);
|
||||
} catch (PDOexception $e) {
|
||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
||||
}
|
||||
$id = db_exec_insert('task', $p);
|
||||
$action = ACT_VIEW;
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$p[':taskname'] = gpc_get_string($_POST, 'taskname');
|
||||
$p[':taskid'] = $id;
|
||||
$p[':projid'] = gpc_get_int($_POST, 'projid');
|
||||
if ($p[':projid'] == -1) {
|
||||
$p[':projid'] = NULL;
|
||||
}
|
||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
|
||||
$sth = $pdo->prepare("UPDATE task SET $fields WHERE taskid=:taskid");
|
||||
$p[':taskid'] = $id;
|
||||
try {
|
||||
$sth->execute($p);
|
||||
} catch (PDOexception $e) {
|
||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
||||
}
|
||||
$p[':taskname'] = gpc_get_string($_POST, 'taskname');
|
||||
db_exec_update('task', $p, 'taskid');
|
||||
$action = ACT_VIEW;
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
break;
|
||||
|
||||
default:
|
||||
$g_error->Add(sprintf(_("Unknown function '%s'!"), $submit));
|
||||
$valid = FALSE;
|
||||
@@ -155,7 +145,7 @@ form_view_buttons($g_scriptname, $id);
|
||||
elseif ($action == ACT_EDIT):
|
||||
// ========== VARIANT: edit single record =====================================
|
||||
|
||||
$sql = "SELECT taskname "
|
||||
$sql = "SELECT taskname, projid "
|
||||
. "FROM task "
|
||||
. "WHERE taskid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -172,7 +162,7 @@ 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);
|
||||
form_create_select('projid', _('Project'), $opt_projects, $task->projid);
|
||||
form_edit_buttons($g_scriptname, $id);
|
||||
echo "</form>\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user