More webgui work. Filters e.g.

This commit is contained in:
2024-04-19 13:25:56 +02:00
parent 851f7e13a2
commit c3b5ef95a9
20 changed files with 853 additions and 585 deletions
+26 -31
View File
@@ -29,46 +29,41 @@ switch ($submit = form_get_action()) {
case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break;
case 'filter':
$flt = array();
$flt['txt'] = gpc_get_string($_POST, 'flt_txt');
db_save_filter($flt, 205);
$action = ACT_DEFAULT;
break;
case 'insert':
$projname = gpc_get_string($_POST, 'projname');
$responsible = gpc_get_int($_POST, 'responsible');
$remarks = gpc_get_string($_POST, 'remarks', 150);
$sql = "INSERT INTO project "
. " (vid, projname, responsible, remarks) "
. "VALUES "
. " (:vid, :projname, :responsible, :remarks)";
$sth = $pdo->prepare($sql);
$sth->bindValue(':vid', $user->vid, PDO::PARAM_INT);
$sth->bindValue(':projname', $projname, PDO::PARAM_STR);
$sth->bindValue(':responsible', $responsible, PDO::PARAM_INT);
$sth->bindValue(':remarks', $remarks, PDO::PARAM_STR);
$sth->execute();
$id = $pdo->lastInsertId();
$p['vid'] = $user->id;
$p[':projname'] = gpc_get_string($_POST, 'projname');
$p[':responsible'] = gpc_get_int($_POST, 'responsible');
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
$id = db_exec_insert('company', $p);
$action = ACT_VIEW;
break;
case 'update':
$projname = gpc_get_string($_POST, 'projname');
$startdate = gpc_get_date($_POST, 'startdate');
$duration = gpc_get_int($_POST, 'duration');
$remarks = gpc_get_string($_POST, 'remarks', 150);
$sql = "UPDATE project "
. "SET projname=:projname,"
. " startdate=:startdate,"
. " duration=:duration,"
. " remarks=:remarks "
. "WHERE projid=:projid";
$sth = $pdo->prepare($sql);
$sth->bindValue(':projid', $id, PDO::PARAM_INT);
$sth->bindValue(':projname', $projname, PDO::PARAM_STR);
$sth->bindValue(':startdate', $startdate, PDO::PARAM_STR);
$sth->bindValue(':duration', $duration, PDO::PARAM_INT);
$sth->bindValue(':remarks', $remarks, PDO::PARAM_STR);
$sth->execute();
$p[':projid'] = $id;
$p[':projname'] = gpc_get_string($_POST, 'projname');
$p[':startdate'] = gpc_get_date($_POST, 'startdate');
$p[':duration'] = gpc_get_int($_POST, 'duration');
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
db_exec_update('project', $p, 'projid');
$action = ACT_VIEW;
break;
case 'delete':
// Security token needed!
if (gpc_get_string($_POST, 'token', 16) != $_SESSION['token']) {
$g_error->Add(_('Delete prohibited, invalid security token!'));
$action = ACT_VIEW;
break;
}
unset($_SESSION['token']);
// TBD
$action = ACT_DEFAULT;
break;