diff --git a/webgui/equipment_js.php b/webgui/equipment_js.php
deleted file mode 100644
index 59b3674..0000000
--- a/webgui/equipment_js.php
+++ /dev/null
@@ -1,294 +0,0 @@
-Add("Unbekannte Funktion!");
- $valid = FALSE;
-
-}
-
-// ========== ACTIONS END =====================================================
-
-require 'header.php';
-
-// ========== PAGE CONTENT ====================================================
-
-if ($action == ACT_DEFAULT):
-// ========== VARIANT: default behavior =======================================
-
-echo "
\n";
-
-$sql = "SELECT eid, ename, make, model, serial, remarks "
- . "FROM equipment "
- . "ORDER BY eid";
-$sth = $pdo->query($sql);
-$res = $sth->fetchAll();
-echo '
\n";
-
-elseif ($action == ACT_ADD):
-// ========== VARIANT: add record =============================================
-?>
-
-prepare($sql);
-$sth->execute([$id]);
-$equipment = $sth->fetch(PDO::FETCH_OBJ);
-echo "
';
-echo '
';
-echo '
';
-
-echo "
\n";
-echo "| ", _('Make')," | ", $equipment->make, " |
\n";
-echo "| ", _('Model')," | ", $equipment->model, " |
\n";
-echo "| ", _('Serial')," | ", $equipment->serial, " |
\n";
-echo "
\n";
-
-
-echo '
'; // Column break
-echo '
';
-?>
-
Images and documents go here
-
-
-
-'; // col
-echo '
'; // row
-echo '
'; // container
-
-// Buttons at bottom of data area
-echo '
\n";
-
-
-elseif ($action == ACT_EDIT):
-// ========== VARIANT: edit single record =====================================
-
-$sql = "SELECT eid, ename, make, model, serial, remarks "
- . "FROM equipment "
- . "WHERE eid=?";
-$sth = $pdo->prepare($sql);
-$sth->execute([$id]);
-$equipment = $sth->fetch(PDO::FETCH_OBJ);
-?>
-
=_('Edit Equipment')?>
-
-", _('Unknown function call: Please report to system development!'), "\n";
-
-endif; // $action == ...
-// ========== END OF VARIANTS =================================================
-
-include 'footer.php';
diff --git a/webgui/globals.inc b/webgui/globals.inc
index 4dffd21..1305443 100644
--- a/webgui/globals.inc
+++ b/webgui/globals.inc
@@ -288,24 +288,50 @@ function db_exec_insert($table, $params) {
$keys = array_keys($params);
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
$pnames = join(',', $keys);
- $sth = $pdo->prepare("INSERT INTO $table ($fields) VALUES ($pnames)");
+ $sql = "INSERT INTO $table ($fields) VALUES ($pnames)";
+// $sth = $pdo->prepare("INSERT INTO $table ($fields) VALUES ($pnames)");
+ $sth = $pdo->prepare($sql);
try {
$sth->execute($params);
} catch (PDOexception $e) {
$g_error->Add('SQL-Error: '. $e->getMessage());
+ $g_error->Add($sql);
+ $g_error->Add(print_r($params, true));
}
return $pdo->LastInsertId();
}
function db_exec_update($table, $params, $pk) {
+ // TODO primary key with multiple fields: $pk is an array
global $pdo;
global $g_error;
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($params)));
- $sth = $pdo->prepare("UPDATE $table SET $fields WHERE $pk=:$pk");
+ $sql = "UPDATE $table SET $fields WHERE $pk=:$pk";
+ $sth = $pdo->prepare($sql);
try {
$sth->execute($params);
} catch (PDOexception $e) {
$g_error->Add('SQL-Error: '. $e->getMessage());
+ $g_error->Add($sql);
+ $g_error->Add(print_r($params, true));
+ return false;
+ }
+ return true;
+}
+
+function db_save_filter($flt, $sno) {
+ global $user;
+ global $pdo;
+ global $g_warning;
+ $sql = "UPDATE settings SET valstr=? WHERE userid=? AND sno=?";
+ $sth = $pdo->prepare($sql);
+ try {
+ $sth->execute([json_encode($flt), $user->id, $sno]);
+ } catch (PDOexception $e) {
+ $g_warning->Add('SQL-Error: '. $e->getMessage());
+ $g_warning->Add($sql);
+ $g_warning->Add(print_r($flt, true));
+ $g_warning->Add('Setting: ', $sno);
return false;
}
return true;
@@ -320,7 +346,7 @@ function get_enum($enum) {
'closed' => _('Closed'),
'defect' => _('Defect'),
'done' => _('Done'),
- 'drawing' => _('Drawng'),
+ 'drawing' => _('Drawing'),
'equipment' => _('Equipment'),
'estimated' => _('Estimated'),
'finished' => _('Finished'),
@@ -330,7 +356,7 @@ function get_enum($enum) {
'invoice' => _('Invoice'),
'locked' => _('Locked'),
'manual' => _('Manual'),
- 'mono' => _('Monoholl'),
+ 'mono' => _('Monohull'),
'new' => _('New'),
'normal' => _('Normal'),
'ongoing' => _('Ongoing'),
@@ -338,6 +364,7 @@ function get_enum($enum) {
'picture' => _('Picture'),
'planned' => _('Planned'),
'precise' => _('Precise'),
+ 'repairable' => _('Repairable'),
'rough' => _('Rough'),
'storage' => _('Storage'),
'task' => _('Task'),
@@ -536,6 +563,27 @@ function db_get_opt_proj($vid, $default=NULL) {
return $list;
}
+function db_get_filter($user, $sno) {
+ global $pdo;
+ global $g_warning;
+ $flt = new stdClass();
+ $sth = $pdo->prepare("SELECT valstr FROM settings WHERE userid=? AND sno=?");
+ try {
+ $sth->execute([$user, $sno]);
+ $json = $sth->fetchColumn();
+ if (!$json) {
+ // no settings record. create empty one for later updates
+ $sth = $pdo->prepare("INSERT INTO settings (userid, sno, valstr) VALUES (?, ?, '{}')");
+ $sth->execute([$user, $sno]);
+ } else {
+ $flt = json_decode($json);
+ }
+ } catch (PDOexception $e) {
+ $g_warning->Add('SQL-Error: '. $e->getMessage());
+ }
+ return $flt;
+}
+
function date_to_sql($var) {
if (!isset($var) || $var == '') {
return NULL;
@@ -563,7 +611,6 @@ function float_to_sql($var) {
// ========== FORM FUNCTIONS ==================================================
function form_create_select($fieldname, $label, $optlist, $selval=NULL) {
- //if (
echo '
', "\n";
echo '
\n";
echo '