function app_input_record($tp_table) { global $SCHEMA; global $ERROR; _db_temporal($tp_table, $table); if (!db_access_table($table, "w")) { return; } // execute user actions on data if (isset($_REQUEST["insert"]) || isset($_REQUEST["new_clone"])) { /* user tries to insert a new record */ $newdata = _app_get_data($table); //echo "db_inserting: "; print_r($newdata); echo "<br>\n"; db_insert($table, $newdata); app_check_error(); } elseif (isset($_REQUEST["change"])) { /* user tries to update a record */ $newdata = _app_get_data($table); db_update($table, $newdata); app_check_error(); } // execute user actions on buttons $primary = _db_primary($table); // TODO: allow combined primary keys (currently goes wrong because no arrays can be submitted as values) if (isset($_REQUEST["delete"])) { /* user has clicked on small delete button */ $olddata = array(app_get_id($table)); db_delete($table, $olddata); app_check_error(); } if (isset($_REQUEST["edit"])) { /* user has clicked on small edit button */ $cond = app_get_id($table); $olddata = db_read($table, null, $cond, null, 0, 1); //echo "edit olddata: "; print_r($olddata); echo "<br>\n"; $mode = "change"; $data = _app_prepare_data($table, $olddata, $mode); } elseif (isset($_REQUEST["clone"])) { /* user has clicked on cloning button */ $cond = app_get_id($table); $olddata = db_read($table, null, $cond, null, 0, 1); //echo "edit olddata: "; print_r($olddata); echo "<br>\n"; $mode = "new_clone"; $data = _app_prepare_data($table, $olddata, $mode); } else { /* no preselection => present empty input fields */ $mode = "insert"; $olddata = db_getemptyrec($table); if (@$ERROR && @$newdata) { // exception: the user does not want to loose bad input $olddata = $newdata; } if (isset($_REQUEST["prepare"])) { /* user has supplied immutable data */ $olddata = array($_REQUEST); } $data = _app_prepare_data($table, $olddata, $mode); } tpl_input_record($data); }
// shutup php warnings require_once $BASEDIR . "/../common/db/db.php"; require_once $BASEDIR . "/../common/app.php"; app_get_templates(); /////////////////////////////////////////////////////////////////////////// // call the "app stuff" for generic table management if (!$download) { $data = array("TITLE" => "inspect_{$table}", "ACTION" => $_SERVER["PHP_SELF"] . "?table={$table}"); tpl_header($data); tpl_body_start($data); app_links(); if (@$debug) { print_r($_REQUEST); echo "<br>\n"; } } if (isset($_REQUEST["primary"])) { $cond = app_get_id($table, $_REQUEST["primary"]); if ($download) { app_display_download($table, $cond, $download, @$_REQUEST["filename"]); } else { app_display_record($table, $cond); } } else { app_input_record($table); app_display_table($tp_table); } if (!$download) { tpl_body_end(null); tpl_footer(null); }