Webgui: filters and pagination
This commit is contained in:
+9
-4
@@ -146,6 +146,7 @@ CREATE TABLE inventory (
|
|||||||
price decimal(12,2) DEFAULT NULL,
|
price decimal(12,2) DEFAULT NULL,
|
||||||
purchdate date DEFAULT NULL,
|
purchdate date DEFAULT NULL,
|
||||||
invcond enum('unknown','good','normal','bad','repairable','defect') NOT NULL default 'unknown',
|
invcond enum('unknown','good','normal','bad','repairable','defect') NOT NULL default 'unknown',
|
||||||
|
remarks varchar(150) DEFAULT NULL,
|
||||||
PRIMARY KEY (invid),
|
PRIMARY KEY (invid),
|
||||||
INDEX ix_invname (invname)
|
INDEX ix_invname (invname)
|
||||||
);
|
);
|
||||||
@@ -189,16 +190,20 @@ CREATE TABLE document (
|
|||||||
pages smallint(6) unsigned NOT NULL DEFAULT 1,
|
pages smallint(6) unsigned NOT NULL DEFAULT 1,
|
||||||
remarks varchar(150) DEFAULT NULL,
|
remarks varchar(150) DEFAULT NULL,
|
||||||
PRIMARY KEY (docid)
|
PRIMARY KEY (docid)
|
||||||
);
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE docref (
|
CREATE TABLE docref (
|
||||||
drid int(10) NOT NULL AUTO_INCREMENT,
|
drid int(10) NOT NULL AUTO_INCREMENT,
|
||||||
reftype enum('vessel', 'box', 'equipment', 'project', 'task') NOT NULL DEFAULT 'vessel',
|
reftype enum('vessel', 'box', 'equipment', 'project', 'task', 'user') NOT NULL DEFAULT 'vessel',
|
||||||
docid smallint(6) NOT NULL,
|
docid smallint(6) NOT NULL,
|
||||||
refid smallint(6) NOT NULL,
|
refid smallint(6) NOT NULL,
|
||||||
PRIMARY KEY (drid),
|
PRIMARY KEY (drid),
|
||||||
UNIQUE INDEX ix_docref (docid, refid)
|
UNIQUE INDEX ix_docref (docid, refid),
|
||||||
);
|
FOREIGN KEY fx_docref_doc (docid)
|
||||||
|
REFERENCES document (docid)
|
||||||
|
ON DELETE RESTRICT
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE company (
|
CREATE TABLE company (
|
||||||
compid smallint(6) NOT NULL AUTO_INCREMENT,
|
compid smallint(6) NOT NULL AUTO_INCREMENT,
|
||||||
|
|||||||
+3
-18
@@ -36,33 +36,18 @@ switch ($submit = form_get_action()) {
|
|||||||
$p[':sid'] = gpc_get_int($_POST, 'sid');
|
$p[':sid'] = gpc_get_int($_POST, 'sid');
|
||||||
$p[':content'] = gpc_get_string($_POST, 'content');
|
$p[':content'] = gpc_get_string($_POST, 'content');
|
||||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks');
|
$p[':remarks'] = gpc_get_string($_POST, 'remarks');
|
||||||
$keys = array_keys($p);
|
$id = db_exec_insert('box', $p);
|
||||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
|
|
||||||
$pnames = join(',', $keys);
|
|
||||||
$sth = $pdo->prepare("INSERT INTO box ($fields) VALUES ($pnames)");
|
|
||||||
try {
|
|
||||||
$sth->execute($p);
|
|
||||||
} catch (PDOexception $e) {
|
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
|
||||||
}
|
|
||||||
$id = $pdo->LastInsertId();
|
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'update':
|
case 'update':
|
||||||
|
$p[':boxid'] = $id;
|
||||||
$p[':label'] = gpc_get_string($_POST, 'label');
|
$p[':label'] = gpc_get_string($_POST, 'label');
|
||||||
$p[':content'] = gpc_get_string($_POST, 'content');
|
$p[':content'] = gpc_get_string($_POST, 'content');
|
||||||
$p[':color'] = gpc_get_color($_POST, 'color');
|
$p[':color'] = gpc_get_color($_POST, 'color');
|
||||||
$p[':weight'] = min(gpc_get_float($_POST, 'weight'), 99.99);
|
$p[':weight'] = min(gpc_get_float($_POST, 'weight'), 99.99);
|
||||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
|
db_exec_update('box', $p, 'boxid');
|
||||||
$sth = $pdo->prepare("UPDATE box SET $fields WHERE boxid=:boxid");
|
|
||||||
$p[':boxid'] = $id;
|
|
||||||
try {
|
|
||||||
$sth->execute($p);
|
|
||||||
} catch (PDOexception $e) {
|
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
|
||||||
}
|
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -38,3 +38,6 @@ $g_doc_maxsize = 1024*1024*16; // 16 MB
|
|||||||
$g_storage_limit = 1024; // MB
|
$g_storage_limit = 1024; // MB
|
||||||
|
|
||||||
$g_thumb_size = 120;
|
$g_thumb_size = 120;
|
||||||
|
|
||||||
|
$g_rows_pp = 10; // pagination limit
|
||||||
|
|
||||||
|
|||||||
+7
-32
@@ -24,9 +24,7 @@ switch ($submit = form_get_action()) {
|
|||||||
|
|
||||||
case 'insert':
|
case 'insert':
|
||||||
// WIP New standalone document
|
// WIP New standalone document
|
||||||
$p[':title'] = gpc_get_string($_POST, 'title');
|
// debug $g_message->Add(print_r($_FILES, true));
|
||||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks');
|
|
||||||
$g_message->Add(print_r($_FILES, true));
|
|
||||||
if (empty($_FILES['files']['tmp_name']) ) {
|
if (empty($_FILES['files']['tmp_name']) ) {
|
||||||
$g_warning->Add(_('No file for upload submitted. Try again by selecting a file first.'));
|
$g_warning->Add(_('No file for upload submitted. Try again by selecting a file first.'));
|
||||||
$action = ACT_ADD;
|
$action = ACT_ADD;
|
||||||
@@ -66,6 +64,7 @@ switch ($submit = form_get_action()) {
|
|||||||
case 'application/pdf':
|
case 'application/pdf':
|
||||||
$file_techname = $g_doc_basepath . '/doc-'.$file_hash.'.'.$file_ext;
|
$file_techname = $g_doc_basepath . '/doc-'.$file_hash.'.'.$file_ext;
|
||||||
$doctype = 'generic';
|
$doctype = 'generic';
|
||||||
|
// $p['pages'] = pdf_get_pagecount($file_tmp);
|
||||||
break;
|
break;
|
||||||
case 'image/svg+xml':
|
case 'image/svg+xml':
|
||||||
$file_techname = $g_doc_basepath . '/drw-'.$file_hash.'.'.$file_ext;
|
$file_techname = $g_doc_basepath . '/drw-'.$file_hash.'.'.$file_ext;
|
||||||
@@ -86,41 +85,17 @@ switch ($submit = form_get_action()) {
|
|||||||
$p[':docsize'] = $file_size;
|
$p[':docsize'] = $file_size;
|
||||||
$p[':title'] = gpc_get_string($_POST, 'title');
|
$p[':title'] = gpc_get_string($_POST, 'title');
|
||||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks');
|
$p[':remarks'] = gpc_get_string($_POST, 'remarks');
|
||||||
/* $sql = "INSERT INTO document"
|
|
||||||
. " (doctype, filename, extension, hash, doctime, docsize, mimetype) "
|
|
||||||
. "VALUES"
|
|
||||||
. " (?, ?, ?, ?, ?, ?, ?)";
|
|
||||||
$sth = $pdo->prepare($sql);
|
|
||||||
try {
|
|
||||||
$sth->execute([$doctype, $file_name, $file_ext, $file_hash, $file_timestamp, $file_size, $file_mimetype]);
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
|
||||||
}
|
|
||||||
$id = $pdo->lastInsertId(); */
|
|
||||||
$id = db_exec_insert('document', $p);
|
$id = db_exec_insert('document', $p);
|
||||||
move_uploaded_file($file_tmp, $file_techname);
|
move_uploaded_file($file_tmp, $file_techname);
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'update':
|
case 'update':
|
||||||
$filename = gpc_get_string($_POST, 'filename');
|
$p[':docid'] = $id;
|
||||||
$title = gpc_get_string($_POST, 'title', 40);
|
$p['filename'] = gpc_get_string($_POST, 'filename');
|
||||||
$remarks = gpc_get_string($_POST, 'remarks', 150);
|
$p['title'] = gpc_get_string($_POST, 'title', 40);
|
||||||
$sql = "UPDATE document "
|
$p['remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||||
. "SET filename=:filename,"
|
db_exec_update('document', $p, 'docid');
|
||||||
. " title=:title,"
|
|
||||||
. " remarks=:remarks "
|
|
||||||
. "WHERE docid=:docid";
|
|
||||||
$sth = $pdo->prepare($sql);
|
|
||||||
$sth->bindValue(':docid', $id, PDO::PARAM_INT);
|
|
||||||
$sth->bindValue(':filename', $filename, PDO::PARAM_STR);
|
|
||||||
$sth->bindValue(':title', $title, PDO::PARAM_STR);
|
|
||||||
$sth->bindValue(':remarks', $remarks, PDO::PARAM_STR);
|
|
||||||
try {
|
|
||||||
$sth->execute();
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
|
||||||
}
|
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -236,7 +236,7 @@ foreach ($sth->fetchAll() as $row) {
|
|||||||
echo '<td>', $row['ddval'],'</td>';
|
echo '<td>', $row['ddval'],'</td>';
|
||||||
echo '<td>', $row['ddtext'], '</td>';
|
echo '<td>', $row['ddtext'], '</td>';
|
||||||
echo '<td>', $row['ddshort'], '</td>';
|
echo '<td>', $row['ddshort'], '</td>';
|
||||||
echo '<td>', $row['color'], '</td>';
|
echo '<td>', format_color($row['color']), '</td>';
|
||||||
echo '<td>', $row['sort'], '</td>';
|
echo '<td>', $row['sort'], '</td>';
|
||||||
// Action links
|
// Action links
|
||||||
echo '<td>';
|
echo '<td>';
|
||||||
|
|||||||
+154
-92
@@ -11,8 +11,8 @@ $pagetitle = _('Equipment');
|
|||||||
|
|
||||||
$id = gpc_get_int($_REQUEST, 'id', 0);
|
$id = gpc_get_int($_REQUEST, 'id', 0);
|
||||||
|
|
||||||
$opt_supplier = db_get_opt_supp(array(-1 => _('unknown')));
|
$opt_supplier = db_get_opt_supp(array(-1 => _('--- unknown ---')));
|
||||||
$opt_manufacturer = db_get_opt_manuf(array(-1 => _('unknown')));
|
$opt_manufacturer = db_get_opt_manuf(array(-1 => _('--- unknown ---')));
|
||||||
$opt_ecat = db_get_options(4); // Equipment categories
|
$opt_ecat = db_get_options(4); // Equipment categories
|
||||||
|
|
||||||
// ========== ACTIONS START ===================================================
|
// ========== ACTIONS START ===================================================
|
||||||
@@ -26,72 +26,47 @@ switch ($submit = form_get_action()) {
|
|||||||
case 'edit': $action = ACT_EDIT; break;
|
case 'edit': $action = ACT_EDIT; break;
|
||||||
case 'del': $action = ACT_DELETE; break;
|
case 'del': $action = ACT_DELETE; break;
|
||||||
|
|
||||||
case 'insert':
|
case 'filter':
|
||||||
$ename = gpc_get_string($_POST, 'ename');
|
// TODO save new filter settings
|
||||||
$ecat = gpc_get_int($_POST, 'category');
|
$flt = array();
|
||||||
$manufacturer = gpc_get_int($_POST, 'manufacturer');
|
$flt['cat'] = gpc_get_int($_POST, 'flt_category');
|
||||||
$model = gpc_get_string($_POST, 'model');
|
$flt['manuf'] = gpc_get_int($_POST, 'flt_manuf');
|
||||||
$remarks = gpc_get_string($_POST, 'remarks', 150);
|
$flt['supp'] = gpc_get_int($_POST, 'flt_supp');
|
||||||
$sql = "INSERT INTO equipment "
|
$flt['txt'] = gpc_get_string($_POST, 'flt_txt');
|
||||||
. " (vid, ename, manufacturer, model, ecat, remarks) "
|
$sql = "UPDATE settings SET valstr=? WHERE userid=? AND sno=200";
|
||||||
. "VALUES "
|
|
||||||
. " (:vid, :ename, :manufacturer, :model, :ecat, :remarks)";
|
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
$sth->bindValue(':vid', $user->vid, PDO::PARAM_INT);
|
$sth->execute([json_encode($flt), $user->id]);
|
||||||
$sth->bindValue(':ename', $ename, PDO::PARAM_STR);
|
// Only warning in case of failure
|
||||||
$sth->bindValue(':model', $model, PDO::PARAM_STR);
|
$action = ACT_DEFAULT;
|
||||||
$sth->bindValue(':ecat', $ecat, PDO::PARAM_INT);
|
break;
|
||||||
$sth->bindValue(':manufacturer', $manufacturer, PDO::PARAM_INT);
|
|
||||||
$sth->bindValue(':remarks', $remarks, PDO::PARAM_STR);
|
case 'insert':
|
||||||
try {
|
$p[':vid'] = $user->vid;
|
||||||
$sth->execute();
|
$p[':ename'] = gpc_get_string($_POST, 'ename');
|
||||||
} catch (PDOException $e) {
|
$p[':ecat'] = gpc_get_int($_POST, 'category');
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
$p[':manufacturer'] = gpc_get_int($_POST, 'manufacturer');
|
||||||
}
|
$p[':model'] = gpc_get_string($_POST, 'model');
|
||||||
$id = $pdo->lastInsertId();
|
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||||
|
$id = db_exec_insert('equipment', $p);
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'update':
|
case 'update':
|
||||||
$ename = gpc_get_string($_POST, 'ename');
|
$p[':eid'] = $id;
|
||||||
$model = gpc_get_string($_POST, 'model');
|
$p[':ename'] = gpc_get_string($_POST, 'ename');
|
||||||
$serial = gpc_get_string($_POST, 'serial');
|
$p[':model'] = gpc_get_string($_POST, 'model');
|
||||||
$weight = min(gpc_get_float($_POST, 'weight'), 999.99); // limit max value
|
$p[':serial'] = gpc_get_string($_POST, 'serial');
|
||||||
$price = gpc_get_currency($_POST, 'price');
|
$p[':weight'] = min(gpc_get_float($_POST, 'weight'), 999.99); // limit max value
|
||||||
$purchdate = gpc_get_date($_POST, 'purchdate');
|
$p[':price'] = gpc_get_currency($_POST, 'price');
|
||||||
$supplier = gpc_get_int($_POST, 'supplier');
|
$p[':purchdate'] = gpc_get_date($_POST, 'purchdate');
|
||||||
$manufacturer = gpc_get_int($_POST, 'manufacturer');
|
$p[':supplier'] = gpc_get_int($_POST, 'supplier');
|
||||||
$ecat = gpc_get_int($_POST, 'category');
|
if ($p[':supplier'] <= 0) $p[':supplier'] = NULL;
|
||||||
$remarks = gpc_get_string($_POST, 'remarks', 150);
|
$p[':manufacturer'] = gpc_get_int($_POST, 'manufacturer');
|
||||||
$sql = "UPDATE equipment "
|
if ($p[':manufacturer'] <= 0) $p[':manufacturer'] = NULL;
|
||||||
. "SET ename=:ename,"
|
$p[':ecat'] = gpc_get_int($_POST, 'category');
|
||||||
. " model=:model,"
|
if ($p[':ecat'] <= 0) $p[':ecat'] = NULL;
|
||||||
. " serial=:serial,"
|
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||||
. " weight=:weight,"
|
db_exec_update('equipment', $p, 'eid');
|
||||||
. " price=:price,"
|
|
||||||
. " purchdate=:purchdate,"
|
|
||||||
. " supplier=:supplier,"
|
|
||||||
. " manufacturer=:manufacturer,"
|
|
||||||
. " ecat=:ecat,"
|
|
||||||
. " remarks=:remarks "
|
|
||||||
. "WHERE eid=:eid";
|
|
||||||
$sth = $pdo->prepare($sql);
|
|
||||||
$sth->bindValue(':eid', $id, PDO::PARAM_INT);
|
|
||||||
$sth->bindValue(':ename', $ename, PDO::PARAM_STR);
|
|
||||||
$sth->bindValue(':model', $model, PDO::PARAM_STR);
|
|
||||||
$sth->bindValue(':serial', $serial, PDO::PARAM_STR);
|
|
||||||
$sth->bindValue(':weight', $weight);
|
|
||||||
$sth->bindValue(':price', $price);
|
|
||||||
$sth->bindValue(':purchdate', $purchdate, PDO::PARAM_STR);
|
|
||||||
$sth->bindValue(':supplier', $supplier, PDO::PARAM_INT);
|
|
||||||
$sth->bindValue(':manufacturer', $manufacturer, PDO::PARAM_INT);
|
|
||||||
$sth->bindValue(':ecat', $ecat, PDO::PARAM_INT);
|
|
||||||
$sth->bindValue(':remarks', $remarks, PDO::PARAM_STR);
|
|
||||||
try {
|
|
||||||
$sth->execute();
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
|
||||||
}
|
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -208,24 +183,80 @@ require 'header.php';
|
|||||||
if ($action == ACT_DEFAULT):
|
if ($action == ACT_DEFAULT):
|
||||||
// ========== VARIANT: default behavior =======================================
|
// ========== VARIANT: default behavior =======================================
|
||||||
|
|
||||||
|
// load filter from db
|
||||||
|
$flt = db_get_filter($user->id, 200);
|
||||||
|
/*$flt = new stdClass();
|
||||||
|
$sth = $pdo->prepare("SELECT valstr FROM settings WHERE userid=? AND sno=200");
|
||||||
|
try {
|
||||||
|
$sth->execute([$user->id]);
|
||||||
|
$json = $sth->fetchColumn();
|
||||||
|
if (!$json) {
|
||||||
|
// no settings record. create empty one for later updates
|
||||||
|
$sth = $pdo->prepare("INSERT INTO settings (userid, sno, valstr) VALUES (?, 200, '[]')");
|
||||||
|
$sth->execute([$user->id]);
|
||||||
|
} else {
|
||||||
|
$flt = json_decode($json);
|
||||||
|
}
|
||||||
|
} catch (PDOexception $e) {
|
||||||
|
$g_warning->Add('SQL-Error: '. $e->getMessage());
|
||||||
|
} */
|
||||||
|
|
||||||
$sort = array(
|
$sort = array(
|
||||||
1 => 'ename',
|
1 => 'ename',
|
||||||
2 => 'ename DESC'
|
2 => 'ename DESC'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$w = array('vid=:vid');
|
||||||
|
$p = array(':vid' => $user->vid);
|
||||||
|
if ($flt->cat == -1) {
|
||||||
|
$w[] = 'ecat IS NULL';
|
||||||
|
} elseif ($flt->cat > 0) {
|
||||||
|
$w[] = 'ecat=:ecat';
|
||||||
|
$p[':ecat'] = $flt->cat;
|
||||||
|
}
|
||||||
|
if ($flt->manuf > 0) {
|
||||||
|
$w[] = 'manufacturer=:manuf';
|
||||||
|
$p[':manuf'] = $flt->manuf;
|
||||||
|
}
|
||||||
|
if ($flt->supp > 0) {
|
||||||
|
$w[] = 'supplier=:supp';
|
||||||
|
$p[':supp'] = $flt->supp;
|
||||||
|
}
|
||||||
|
if (strlen($flt->txt) > 1) {
|
||||||
|
$w[] = '(ename LIKE :txt OR model LIKE :txt OR remarks LIK :txt';
|
||||||
|
$p[':txt'] = '%'.$flt->txt.'%';
|
||||||
|
}
|
||||||
|
$where = join(' AND ', $w);
|
||||||
|
$order = ' ORDER BY ename';
|
||||||
|
|
||||||
|
// get total recond count for pagination and limit
|
||||||
|
$sth = $pdo->prepare("SELECT COUNT(*) FROM equipment WHERE " . $where);
|
||||||
|
$sth->execute($p);
|
||||||
|
$numrows = $sth->fetchColumn();
|
||||||
|
$lastpage = ceil($numrows/$g_rows_pp);
|
||||||
|
$page = gpc_get_int($_REQUEST, 'p', 1);
|
||||||
|
|
||||||
$sql = "SELECT eid, ename, manufacturer, model, serial, remarks,"
|
$sql = "SELECT eid, ename, manufacturer, model, serial, remarks,"
|
||||||
. " TIMESTAMPDIFF(MONTH, purchdate, NOW()) AS age_mon "
|
. " TIMESTAMPDIFF(MONTH, purchdate, NOW()) AS age_mon "
|
||||||
. "FROM equipment WHERE vid=? "
|
. "FROM equipment";
|
||||||
. "ORDER BY eid";
|
$sql .= ' WHERE ' . $where;
|
||||||
|
$sql .= $order;
|
||||||
|
|
||||||
|
// if pagination:
|
||||||
|
$sql .= ' LIMIT ' . ($page - 1) * $g_rows_pp . ',' . $g_rows_pp;
|
||||||
|
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
$sth->execute([$user->vid]);
|
$sth->execute($p);
|
||||||
$res = $sth->fetchAll();
|
$res = $sth->fetchAll();
|
||||||
|
|
||||||
echo "<h1>$pagetitle</h1>\n";
|
echo "<h1>$pagetitle</h1>\n";
|
||||||
|
|
||||||
// Filter
|
// Filter
|
||||||
|
$opt_special = array(
|
||||||
|
-2 => _('― all ―'),
|
||||||
|
-1 => _('― none ―')
|
||||||
|
);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<form method="post" action="<?=$g_scriptname?>">
|
<form method="post" action="<?=$g_scriptname?>">
|
||||||
<div id="filter" class="card">
|
<div id="filter" class="card">
|
||||||
<div class="card-header">Filter</div>
|
<div class="card-header">Filter</div>
|
||||||
@@ -233,35 +264,61 @@ echo "<h1>$pagetitle</h1>\n";
|
|||||||
<label for="flt_category">Category</label>
|
<label for="flt_category">Category</label>
|
||||||
<select id="flt_category" name="flt_category">
|
<select id="flt_category" name="flt_category">
|
||||||
<?php
|
<?php
|
||||||
foreach ($opt_ecat as $k => $v) {
|
foreach ($opt_special + $opt_ecat as $k => $v) {
|
||||||
echo '<option value="', $k,'">', $v, '</option>';
|
echo '<option value="', $k, '"';
|
||||||
|
if ($k == $flt->cat) {
|
||||||
|
echo ' selected';
|
||||||
|
}
|
||||||
|
echo '>', $v, '</option>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
<label for="flt_manuf">Manufacturer</label>
|
<label for="flt_manuf">Manufacturer</label>
|
||||||
<select id="flt_category" name="flt_category">
|
<select id="flt_manuf" name="flt_manuf">
|
||||||
<?php
|
<?php
|
||||||
foreach ($opt_manufacturer as $k => $v) {
|
foreach ($opt_special + $opt_manufacturer as $k => $v) {
|
||||||
echo '<option value="', $k,'">', $v, '</option>';
|
echo '<option value="', $k,'"';
|
||||||
|
if ($k == $flt->manuf) {
|
||||||
|
echo ' selected';
|
||||||
|
}
|
||||||
|
echo '>', $v, '</option>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
<button class="btn btn-sm btn-primary" title="<?=_('Apply')?>">Go</button>
|
<label for="flt_supp">Supplier</label>
|
||||||
|
<select id="flt_supp" name="flt_supp">
|
||||||
|
<?php
|
||||||
|
foreach ($opt_special + $opt_supplier as $k => $v) {
|
||||||
|
echo '<option value="', $k,'"';
|
||||||
|
if ($k == $flt->supp) {
|
||||||
|
echo ' selected';
|
||||||
|
}
|
||||||
|
echo '>', $v, '</option>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
<label for="flt_txt">Text</label>
|
||||||
|
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt?>">
|
||||||
|
<button name="submit[filter]" class="btn btn-sm btn-primary" title="<?=_('Apply')?>">Go</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
// Pagination on top
|
||||||
|
$pagination = get_pagination($g_scriptname, $page, $lastpage);
|
||||||
|
echo $pagination;
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
echo '<table class="table table-striped">', "\n";
|
echo '<table class="table table-striped">', "\n";
|
||||||
echo "<thead>\n";
|
echo "<thead>\n";
|
||||||
echo "<tr>";
|
echo '<tr>';
|
||||||
echo "<th>" . _('Description') . "</th>";
|
echo '<th>', _('Description'), "</th>";
|
||||||
echo "<th>" . _('Manufacturer') . "</th>";
|
echo '<th>', _('Manufacturer'), "</th>";
|
||||||
echo "<th>" . _('Model') . "</th>";
|
echo '<th>', _('Model'), "</th>";
|
||||||
echo "<th>" . _('Serial') . "</th>";
|
echo '<th>', _('Serial'), "</th>";
|
||||||
echo "<th>" . _('Age') . "</th>";
|
echo '<th>', _('Age'), "</th>";
|
||||||
echo "<th>" . _('Remarks') . "</th>";
|
echo '<th>', _('Remarks'), "</th>";
|
||||||
echo "<th> </th>";
|
echo "<th> </th>";
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
echo "</thead>\n";
|
echo "</thead>\n";
|
||||||
@@ -275,20 +332,22 @@ foreach ($res as $row) {
|
|||||||
$age = sprintf(_('%dy'), intdiv($row['age_mon'], 12));
|
$age = sprintf(_('%dy'), intdiv($row['age_mon'], 12));
|
||||||
}
|
}
|
||||||
echo "<tr>\n";
|
echo "<tr>\n";
|
||||||
echo "<td>". $row['ename'] ."</td>\n";
|
echo "<td>", $row['ename'], "</td>\n";
|
||||||
echo "<td>". $opt_manufacturer[$row['manufacturer']] ."</td>\n";
|
echo "<td>", ($opt_manufacturer[$row['manufacturer']] ?? ''), "</td>\n";
|
||||||
echo "<td>". $row['model'] ."</td>\n";
|
echo "<td>", $row['model'], "</td>\n";
|
||||||
echo "<td>". $row['serial'] ."</td>\n";
|
echo "<td>", $row['serial'], "</td>\n";
|
||||||
echo "<td>". $age ."</td>\n";
|
echo "<td>", $age, "</td>\n";
|
||||||
echo "<td>". $row['remarks'] ."</td>\n";
|
echo "<td>", $row['remarks'], "</td>\n";
|
||||||
// Action buttons
|
// Action buttons
|
||||||
form_action_buttons($g_scriptname, $row['eid']);
|
form_action_buttons($g_scriptname, $row['eid']);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr><td colspan="6"><?php printf(_('%d records'), count($res)); ?></td></tr>
|
<tr><td colspan="6"><?php printf(_('%d records of %d'), count($res), $numrows); ?></td></tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="pagination justify-content-center">
|
<ul class="pagination justify-content-center">
|
||||||
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
|
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
|
||||||
@@ -296,13 +355,16 @@ foreach ($res as $row) {
|
|||||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||||
<li class="page-item"><a class="page-link" href="#">Next</a></li>
|
<li class="page-item"><a class="page-link" href="#">Next</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav> */
|
||||||
<?php
|
echo $pagination;
|
||||||
|
|
||||||
form_add_button($g_scriptname);
|
form_add_button($g_scriptname);
|
||||||
|
|
||||||
elseif ($action == ACT_ADD):
|
elseif ($action == ACT_ADD):
|
||||||
// ========== VARIANT: add record =============================================
|
// ========== VARIANT: add record =============================================
|
||||||
|
|
||||||
|
// filter used to preselect fields
|
||||||
|
$flt = db_get_filter($user->id, 200);
|
||||||
?>
|
?>
|
||||||
<h2><?=_('Add Equipment')?></h2>
|
<h2><?=_('Add Equipment')?></h2>
|
||||||
<form method="post" action="<?=$g_scriptname?>">
|
<form method="post" action="<?=$g_scriptname?>">
|
||||||
@@ -311,8 +373,8 @@ elseif ($action == ACT_ADD):
|
|||||||
<input type="text" class="form-control" id="ename" name="ename">
|
<input type="text" class="form-control" id="ename" name="ename">
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
form_create_select('category', _('Category'), $opt_ecat);
|
form_create_select('category', _('Category'), [-1 => '--- none ---'] + $opt_ecat, $flt->cat);
|
||||||
form_create_select('manufacturer', _('Manufacturer'), $opt_manufacturer);
|
form_create_select('manufacturer', _('Manufacturer'), $opt_manufacturer, $flt->manuf);
|
||||||
?>
|
?>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="model" class="form-label"><?=_('Model')?></label>
|
<label for="model" class="form-label"><?=_('Model')?></label>
|
||||||
@@ -446,7 +508,7 @@ $equipment = $sth->fetch(PDO::FETCH_OBJ);
|
|||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
form_create_select('supplier', _('Supplier'), $opt_supplier, $equipment->supplier);
|
form_create_select('supplier', _('Supplier'), $opt_supplier, $equipment->supplier);
|
||||||
form_create_select('category', _('Category'), $opt_ecat, $equipment->ecat);
|
form_create_select('category', _('Category'), [-1 => _('--- unknown ---')] + $opt_ecat, $equipment->ecat);
|
||||||
?>
|
?>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
||||||
|
|||||||
+32
-56
@@ -41,16 +41,7 @@ switch ($submit = form_get_action()) {
|
|||||||
$p[':vesselname'] = gpc_get_string($_POST, 'vesselname');
|
$p[':vesselname'] = gpc_get_string($_POST, 'vesselname');
|
||||||
$p[':model'] = gpc_get_string($_POST, 'model');
|
$p[':model'] = gpc_get_string($_POST, 'model');
|
||||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||||
$keys = array_keys($p);
|
$id = db_exec_insert('vessel', $p);
|
||||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
|
|
||||||
$pnames = join(',', $keys);
|
|
||||||
$sth = $pdo->prepare("INSERT INTO vessel ($fields) VALUES ($pnames)");
|
|
||||||
try {
|
|
||||||
$sth->execute($p);
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
|
||||||
}
|
|
||||||
$id = $pdo->LastInsertId();
|
|
||||||
// autoselect newly created vessel
|
// autoselect newly created vessel
|
||||||
$sql = "UPDATE settings SET valint=? WHERE userid=? AND sno=1";
|
$sql = "UPDATE settings SET valint=? WHERE userid=? AND sno=1";
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
@@ -59,7 +50,7 @@ switch ($submit = form_get_action()) {
|
|||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
$g_error->Add('SQL-Error: '. $e->getMessage());
|
||||||
}
|
}
|
||||||
$g_message->Add(sprintf(_('Selected new vessel %d'), $vid));
|
$g_message->Add(sprintf(_('Selected new vessel %d'), $id));
|
||||||
$user->load_vessel();
|
$user->load_vessel();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -68,6 +59,7 @@ switch ($submit = form_get_action()) {
|
|||||||
$g_error->Add(_('Access denied. You are not the captain.'));
|
$g_error->Add(_('Access denied. You are not the captain.'));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$p[':vid'] = gpc_get_int($_POST, 'id');
|
||||||
// $p[':vtype'] = gpc_get_string($_POST, 'vtype');
|
// $p[':vtype'] = gpc_get_string($_POST, 'vtype');
|
||||||
$p[':vesselname'] = gpc_get_string($_POST, 'vesselname');
|
$p[':vesselname'] = gpc_get_string($_POST, 'vesselname');
|
||||||
$p[':model'] = gpc_get_string($_POST, 'model');
|
$p[':model'] = gpc_get_string($_POST, 'model');
|
||||||
@@ -82,14 +74,7 @@ switch ($submit = form_get_action()) {
|
|||||||
$p[':beltpos_bow'] = gpc_get_float($_POST, 'beltpos_bow');
|
$p[':beltpos_bow'] = gpc_get_float($_POST, 'beltpos_bow');
|
||||||
$p[':shapefile'] = gpc_get_string($_POST, 'shapefile');
|
$p[':shapefile'] = gpc_get_string($_POST, 'shapefile');
|
||||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
|
db_exec_update('vessel', $p, 'vid');
|
||||||
$sth = $pdo->prepare("UPDATE vessel SET $fields WHERE vid=:vid");
|
|
||||||
$p[':vid'] = gpc_get_int($_POST, 'id');
|
|
||||||
try {
|
|
||||||
$sth->execute($p);
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
|
||||||
}
|
|
||||||
$action = ACT_DEFAULT;
|
$action = ACT_DEFAULT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -153,38 +138,19 @@ $sth->execute([$vid]);
|
|||||||
$vessel = $sth->fetch();
|
$vessel = $sth->fetch();
|
||||||
|
|
||||||
// get vessel shape
|
// get vessel shape
|
||||||
// TODO predefine base shapes for different vessels
|
// test for predefined base shape
|
||||||
$shapefilepath = dirname(__FILE__).'/'.$g_shapedir.'/'.$vessel['shapefile'];
|
$shapefilepath = dirname(__FILE__).'/'.$g_shapedir.'/'.$vessel['shapefile'];
|
||||||
if (isset($vessel['shapefile']) and file_exists($shapefilepath)) {
|
if (isset($vessel['shapefile']) and file_exists($shapefilepath)) {
|
||||||
$baseshape = file_get_contents($shapefilepath);
|
$baseshape = file_get_contents($shapefilepath);
|
||||||
} else {
|
} else {
|
||||||
// use internal default shape
|
// use internal default shape
|
||||||
$baseshape = <<<EOT
|
$baseshape = <<<EOT
|
||||||
<svg
|
<svg version="1.1" width="1024" height="350" viewBox="0 0 1024 350" id="svg1">
|
||||||
width="680.8349"
|
<g id="g1">
|
||||||
height="205.42085"
|
<path id="path1" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:8, 4, 2, 4;stroke-dashoffset:0;stroke-opacity:1" d="M 3.3e-6,174.91172 1023.9982,174.90837" />
|
||||||
viewBox="0 0 180.13756 54.350934"
|
<path id="path2" style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1" d="m 1.1002728,174.9708 c 0,0 0.150828,-90.157538 0.02448,-103.853791 C 66.951611,46.573152 247.6267,3.4573666 430.56326,3.8276086 670.30694,4.3128215 758.66035,44.913257 838.18466,74.965511 917.70898,105.01776 1022.8821,175.00227 1022.8821,175.00227" />
|
||||||
version="1.1"
|
<use id="use1" x="0" y="0" xlink:href="#path2" transform="matrix(1,0,0,-1,0.0781866,350.05682)" />
|
||||||
id="svg5"
|
</g>
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg">
|
|
||||||
<defs
|
|
||||||
id="defs2" />
|
|
||||||
<g
|
|
||||||
id="layer1"
|
|
||||||
transform="translate(-18.454117,-34.670903)">
|
|
||||||
<path
|
|
||||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
||||||
d="M 18.719809,61.846371 18.587517,51.734929 c 0,0 14.698452,-6.829606 22.491781,-8.894215 18.280597,-4.842895 36.646466,-7.606499 56.167649,-7.993756 29.649633,-0.588182 48.780143,4.813228 71.891193,12.372959 10.39946,3.401709 29.38622,14.626454 29.38622,14.626454"
|
|
||||||
id="path245" />
|
|
||||||
<use
|
|
||||||
x="0"
|
|
||||||
y="0"
|
|
||||||
xlink:href="#path245"
|
|
||||||
id="use461"
|
|
||||||
transform="matrix(1,0,0,-1,-4.9118388e-8,123.69274)" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
</svg>
|
||||||
EOT;
|
EOT;
|
||||||
}
|
}
|
||||||
@@ -198,17 +164,17 @@ $line = $g->addChild('line');
|
|||||||
$line->addAttribute('x1', '100');
|
$line->addAttribute('x1', '100');
|
||||||
$line->addAttribute('y1', '0');
|
$line->addAttribute('y1', '0');
|
||||||
$line->addAttribute('x2', '100');
|
$line->addAttribute('x2', '100');
|
||||||
$line->addAttribute('y2', '100');
|
$line->addAttribute('y2', '350');
|
||||||
$line->addAttribute('style', 'stroke:#ff0000;stroke-width:0.25px');
|
$line->addAttribute('style', 'stroke:#ff0000;stroke-width:1px');
|
||||||
|
|
||||||
// rectangle for storage
|
// rectangle for storage
|
||||||
$rect = $g->addChild('rect');
|
$rect = $g->addChild('rect');
|
||||||
$rect->addAttribute('x', '2');
|
$rect->addAttribute('x', '10');
|
||||||
$rect->addAttribute('y', '14');
|
$rect->addAttribute('y', '80');
|
||||||
$rect->addAttribute('width', '20');
|
$rect->addAttribute('width', '40');
|
||||||
$rect->addAttribute('height', '26');
|
$rect->addAttribute('height', '60');
|
||||||
$rect->addAttribute('stroke', '#000');
|
$rect->addAttribute('stroke', '#000');
|
||||||
$rect->addAttribute('stroke-width', '0.25px');
|
$rect->addAttribute('stroke-width', '1px');
|
||||||
$rect->addAttribute('fill', '#57E389');
|
$rect->addAttribute('fill', '#57E389');
|
||||||
$rect->addAttribute('fill-opacity', '0.4');
|
$rect->addAttribute('fill-opacity', '0.4');
|
||||||
|
|
||||||
@@ -216,9 +182,9 @@ $rect->addAttribute('fill-opacity', '0.4');
|
|||||||
$link = $g->addChild('a');
|
$link = $g->addChild('a');
|
||||||
$link->addAttribute('xlink:href', 'storage.php?f=view&id=1');
|
$link->addAttribute('xlink:href', 'storage.php?f=view&id=1');
|
||||||
$text = $link->addChild('text', 'Box1');
|
$text = $link->addChild('text', 'Box1');
|
||||||
$text->addAttribute('font-size', '3.5');
|
$text->addAttribute('font-size', '10');
|
||||||
$text->addAttribute('x', '4');
|
$text->addAttribute('x', '14');
|
||||||
$text->addAttribute('y', '18');
|
$text->addAttribute('y', '95');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="container-fluid my-4">
|
<div class="container-fluid my-4">
|
||||||
@@ -369,6 +335,13 @@ echo '<h2>', _('Add additional yacht'), "</h2>\n";
|
|||||||
elseif ($action == ACT_EDIT):
|
elseif ($action == ACT_EDIT):
|
||||||
// ========== VARIANT: edit single record =====================================
|
// ========== VARIANT: edit single record =====================================
|
||||||
|
|
||||||
|
// get list of shapefiles
|
||||||
|
$opt_shapefiles = array('' => _('--- none ---'));
|
||||||
|
foreach (glob($g_shapedir.'/*.svg') as $f) {
|
||||||
|
$f = basename($f);
|
||||||
|
$opt_shapefiles[$f] = $f;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT vesselname, vtype, model, loa, lwl, beam, draught, draught_min,"
|
$sql = "SELECT vesselname, vtype, model, loa, lwl, beam, draught, draught_min,"
|
||||||
. " displacement, ballast, beltpos_aft, beltpos_bow, shapefile,"
|
. " displacement, ballast, beltpos_aft, beltpos_bow, shapefile,"
|
||||||
. " remarks "
|
. " remarks "
|
||||||
@@ -425,10 +398,13 @@ $vessel = $sth->fetch(PDO::FETCH_OBJ);
|
|||||||
<label for="beltpos_bow" class="form-label"><?=_('Belt position bow')?></label>
|
<label for="beltpos_bow" class="form-label"><?=_('Belt position bow')?></label>
|
||||||
<input type="text" class="form-control" id="beltpos_bow" name="beltpos_bow" value="<?=format_float($vessel->beltpos_bow, 2) ?>">
|
<input type="text" class="form-control" id="beltpos_bow" name="beltpos_bow" value="<?=format_float($vessel->beltpos_bow, 2) ?>">
|
||||||
</div>
|
</div>
|
||||||
|
<?php /*
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="shapefile" class="form-label"><?=_('Shapefile')?></label>
|
<label for="shapefile" class="form-label"><?=_('Shapefile')?></label>
|
||||||
<input type="text" class="form-control" id="shapefile" name="shapefile" value="<?=$vessel->shapefile ?>">
|
<input type="text" class="form-control" id="shapefile" name="shapefile" value="<?=$vessel->shapefile ?>">
|
||||||
</div>
|
</div> */
|
||||||
|
form_create_select('shapefile', _('Shape file'), $opt_shapefiles, $vessel->shapefile);
|
||||||
|
?>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
||||||
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=$vessel->remarks ?></textarea>
|
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=$vessel->remarks ?></textarea>
|
||||||
|
|||||||
+16
-2
@@ -25,6 +25,10 @@ switch ($submit = form_get_action()) {
|
|||||||
case 'edit': $action = ACT_EDIT; break;
|
case 'edit': $action = ACT_EDIT; break;
|
||||||
case 'del': $action = ACT_DELETE; break;
|
case 'del': $action = ACT_DELETE; break;
|
||||||
|
|
||||||
|
case 'filter':
|
||||||
|
$action = ACT_DEFAULT;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'insert':
|
case 'insert':
|
||||||
$p[':invname'] = gpc_get_string($_POST, 'invname');
|
$p[':invname'] = gpc_get_string($_POST, 'invname');
|
||||||
$p[':number'] = gpc_get_int($_POST, 'number');
|
$p[':number'] = gpc_get_int($_POST, 'number');
|
||||||
@@ -47,6 +51,7 @@ switch ($submit = form_get_action()) {
|
|||||||
$p[':price'] = gpc_get_currency($_POST, 'price');
|
$p[':price'] = gpc_get_currency($_POST, 'price');
|
||||||
$p[':purchdate'] = gpc_get_date($_POST, 'purchdate');
|
$p[':purchdate'] = gpc_get_date($_POST, 'purchdate');
|
||||||
$p[':invcond'] = gpc_get_string($_POST, 'invcond');
|
$p[':invcond'] = gpc_get_string($_POST, 'invcond');
|
||||||
|
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||||
db_exec_update('inventory', $p, 'invid');
|
db_exec_update('inventory', $p, 'invid');
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
@@ -80,6 +85,8 @@ require 'header.php';
|
|||||||
if ($action == ACT_DEFAULT):
|
if ($action == ACT_DEFAULT):
|
||||||
// ========== VARIANT: default behavior =======================================
|
// ========== VARIANT: default behavior =======================================
|
||||||
|
|
||||||
|
$flt = db_get_filter($user->id, 201);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The only way to find out whether the inventory is on the current boat is to use
|
The only way to find out whether the inventory is on the current boat is to use
|
||||||
the box assignment. But this is also intentional to allow easy rearrangement.
|
the box assignment. But this is also intentional to allow easy rearrangement.
|
||||||
@@ -161,7 +168,8 @@ form_create_select('boxid', _('Box'), $opt_box);
|
|||||||
elseif ($action == ACT_VIEW):
|
elseif ($action == ACT_VIEW):
|
||||||
// ========== VARIANT: view single record =====================================
|
// ========== VARIANT: view single record =====================================
|
||||||
|
|
||||||
$sql = "SELECT invname, boxtype, sid, boxid, number, weight, price, purchdate, invcond "
|
$sql = "SELECT invname, boxtype, sid, boxid, number, weight, price, purchdate,"
|
||||||
|
. " invcond,remarks "
|
||||||
. "FROM inventory "
|
. "FROM inventory "
|
||||||
. "WHERE invid=?";
|
. "WHERE invid=?";
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
@@ -210,6 +218,7 @@ echo "<tr><th>", _('Weight'), "</th><td>", format_float($inventory->weight, 2, '
|
|||||||
echo "<tr><th>", _('Price'), "</th><td>", format_currency($inventory->price), "</td></tr>\n";
|
echo "<tr><th>", _('Price'), "</th><td>", format_currency($inventory->price), "</td></tr>\n";
|
||||||
echo "<tr><th>", _('Purchase date'), "</th><td>", $inventory->purchdate, "</td></tr>\n";
|
echo "<tr><th>", _('Purchase date'), "</th><td>", $inventory->purchdate, "</td></tr>\n";
|
||||||
echo "<tr><th>", _('Condition'), "</th><td>", $inventory->invcond, "</td></tr>\n";
|
echo "<tr><th>", _('Condition'), "</th><td>", $inventory->invcond, "</td></tr>\n";
|
||||||
|
echo "<tr><th>", _('Remarks'), "</th><td>", $inventory->remarks, "</td></tr>\n";
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
|
|
||||||
form_view_buttons($g_scriptname, $id);
|
form_view_buttons($g_scriptname, $id);
|
||||||
@@ -217,7 +226,8 @@ form_view_buttons($g_scriptname, $id);
|
|||||||
elseif ($action == ACT_EDIT):
|
elseif ($action == ACT_EDIT):
|
||||||
// ========== VARIANT: edit single record =====================================
|
// ========== VARIANT: edit single record =====================================
|
||||||
|
|
||||||
$sql = "SELECT invname, boxtype, sid, boxid, number, weight, price, purchdate, invcond "
|
$sql = "SELECT invname, boxtype, sid, boxid, number, weight, price, purchdate, "
|
||||||
|
. " invcond, remarks "
|
||||||
. "FROM inventory "
|
. "FROM inventory "
|
||||||
. "WHERE invid=?";
|
. "WHERE invid=?";
|
||||||
$sth = $pdo->prepare($sql);
|
$sth = $pdo->prepare($sql);
|
||||||
@@ -281,6 +291,10 @@ foreach ($cond as $k => $v) {
|
|||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
||||||
|
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=$inventory->remarks ?></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -20,6 +20,10 @@ Die Umschaltung erfolgt über eine Auswahlliste auf der Übersichtsseite.</p>
|
|||||||
<p>Die Yachtdaten können nur mit de Berechtigungsebene <em>captain</em>
|
<p>Die Yachtdaten können nur mit de Berechtigungsebene <em>captain</em>
|
||||||
verändert werden.</p>
|
verändert werden.</p>
|
||||||
|
|
||||||
|
<p>Es kann eine Aufsicht für die betreffende Yacht eingerichtet werden.
|
||||||
|
Diese ist als SVG-Zeichnung zu hinterlegen, der Stauraum kann dann
|
||||||
|
an der passenden Position angezeigt werden.</p>
|
||||||
|
|
||||||
<p>Bei Neuanlage eines Datensatzes werden nur die wichtigsten Felder
|
<p>Bei Neuanlage eines Datensatzes werden nur die wichtigsten Felder
|
||||||
angezeigt. Weitere Felder können im Anschluß über die Bearbeiten-Funktion
|
angezeigt. Weitere Felder können im Anschluß über die Bearbeiten-Funktion
|
||||||
ausgefüllt werden.</p>
|
ausgefüllt werden.</p>
|
||||||
@@ -66,7 +70,9 @@ z.B. <em>neu</em>, <em>laufend</em> oder <em>erledigt</em>.</p>
|
|||||||
|
|
||||||
<h3>Firmen</h3>
|
<h3>Firmen</h3>
|
||||||
<p>Es können verschiedene Arten von Firmen hinterlegt werden, wie
|
<p>Es können verschiedene Arten von Firmen hinterlegt werden, wie
|
||||||
beispielsweise Hersteller, Lieferanten oder Dienstleister.</p>
|
beispielsweise Hersteller, Lieferanten, Werften oder Dienstleister.</p>
|
||||||
|
<p>Hersteller und Lieferanten sind immer vorhanden, sie werden als
|
||||||
|
Auswahl an anderen Stellen im Programm benötigt.</p>
|
||||||
|
|
||||||
<h3>Dokumente</h3>
|
<h3>Dokumente</h3>
|
||||||
<p>Ein Dokument kann mehrfach zugeordnet werden. Z.B. einem
|
<p>Ein Dokument kann mehrfach zugeordnet werden. Z.B. einem
|
||||||
|
|||||||
+2
-1
@@ -213,9 +213,10 @@ $sth->execute([$id]);
|
|||||||
<th><?=_('Task')?></th>
|
<th><?=_('Task')?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<?php foreach ($sth->fetchAll() as $row):?>
|
<?php foreach ($sth->fetchAll() as $row): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?=$row['taskname']?></td>
|
<td><?=$row['taskname']?></td>
|
||||||
|
<?php form_action_buttons('task.php', $row['taskid']); ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
+3
-18
@@ -32,34 +32,19 @@ switch ($submit = form_get_action()) {
|
|||||||
$p[':unit'] = gpc_get_int($_POST, 'unit');
|
$p[':unit'] = gpc_get_int($_POST, 'unit');
|
||||||
$p[':storedate'] = gpc_get_string($_POST, 'storedate');
|
$p[':storedate'] = gpc_get_string($_POST, 'storedate');
|
||||||
$p[':shelflife'] = gpc_get_string($_POST, 'shelflife');
|
$p[':shelflife'] = gpc_get_string($_POST, 'shelflife');
|
||||||
$keys = array_keys($p);
|
$id = db_exec_insert('provisions', $p);
|
||||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
|
|
||||||
$pnames = join(',', $keys);
|
|
||||||
$sth = $pdo->prepare("INSERT INTO provisions ($fields) VALUES ($pnames)");
|
|
||||||
try {
|
|
||||||
$sth->execute($p);
|
|
||||||
} catch (PDOexception $e) {
|
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
|
||||||
}
|
|
||||||
$id = $pdo->LastInsertId();
|
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'update':
|
case 'update':
|
||||||
|
$p[':provid'] = $id;
|
||||||
$p[':provname'] = gpc_get_string($_POST, 'provname');
|
$p[':provname'] = gpc_get_string($_POST, 'provname');
|
||||||
$p[':number'] = gpc_get_int($_POST, 'number');
|
$p[':number'] = gpc_get_int($_POST, 'number');
|
||||||
$p[':unit'] = gpc_get_int($_POST, 'unit');
|
$p[':unit'] = gpc_get_int($_POST, 'unit');
|
||||||
$p[':storedate'] = gpc_get_string($_POST, 'storedate');
|
$p[':storedate'] = gpc_get_string($_POST, 'storedate');
|
||||||
$p[':shelflife'] = gpc_get_string($_POST, 'shelflife');
|
$p[':shelflife'] = gpc_get_string($_POST, 'shelflife');
|
||||||
$p[':sid'] = gpc_get_int($_POST, 'sid');
|
$p[':sid'] = gpc_get_int($_POST, 'sid');
|
||||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
|
db_exec_update('provisions', $p, 'provid');
|
||||||
$sth = $pdo->prepare("UPDATE provisions SET $fields WHERE provid=:provid");
|
|
||||||
$p[':provid'] = $id;
|
|
||||||
try {
|
|
||||||
$sth->execute($p);
|
|
||||||
} catch (PDOexception $e) {
|
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
|
||||||
}
|
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -158,7 +158,7 @@ echo "</tr>\n";
|
|||||||
foreach ($res as $row) {
|
foreach ($res as $row) {
|
||||||
echo "<tr>\n";
|
echo "<tr>\n";
|
||||||
echo "<td>". $row['label'] ."</td>\n";
|
echo "<td>". $row['label'] ."</td>\n";
|
||||||
echo '<td><span style="background-color:#', $row['color'],'">'. $row['color'] ."</span></td>\n";
|
echo '<td>', format_color($row['color']), "</td>\n";
|
||||||
echo "<td>". $row['content'] ."</td>\n";
|
echo "<td>". $row['content'] ."</td>\n";
|
||||||
form_action_buttons('box.php', $row['boxid']);
|
form_action_buttons('box.php', $row['boxid']);
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
|
|||||||
+10
-20
@@ -30,34 +30,24 @@ switch ($submit = form_get_action()) {
|
|||||||
$p[':projid'] = NULL;
|
$p[':projid'] = NULL;
|
||||||
}
|
}
|
||||||
$p[':taskname'] = gpc_get_string($_POST, 'taskname');
|
$p[':taskname'] = gpc_get_string($_POST, 'taskname');
|
||||||
$keys = array_keys($p);
|
$id = db_exec_insert('task', $p);
|
||||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
|
$action = ACT_VIEW;
|
||||||
$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());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'update':
|
case 'update':
|
||||||
$p[':taskname'] = gpc_get_string($_POST, 'taskname');
|
$p[':taskid'] = $id;
|
||||||
$p[':projid'] = gpc_get_int($_POST, 'projid');
|
$p[':projid'] = gpc_get_int($_POST, 'projid');
|
||||||
if ($p[':projid'] == -1) {
|
if ($p[':projid'] == -1) {
|
||||||
$p[':projid'] = NULL;
|
$p[':projid'] = NULL;
|
||||||
}
|
}
|
||||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
|
$p[':taskname'] = gpc_get_string($_POST, 'taskname');
|
||||||
$sth = $pdo->prepare("UPDATE task SET $fields WHERE taskid=:taskid");
|
db_exec_update('task', $p, 'taskid');
|
||||||
$p[':taskid'] = $id;
|
|
||||||
try {
|
|
||||||
$sth->execute($p);
|
|
||||||
} catch (PDOexception $e) {
|
|
||||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
|
||||||
}
|
|
||||||
$action = ACT_VIEW;
|
$action = ACT_VIEW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'delete':
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$g_error->Add(sprintf(_("Unknown function '%s'!"), $submit));
|
$g_error->Add(sprintf(_("Unknown function '%s'!"), $submit));
|
||||||
$valid = FALSE;
|
$valid = FALSE;
|
||||||
@@ -155,7 +145,7 @@ form_view_buttons($g_scriptname, $id);
|
|||||||
elseif ($action == ACT_EDIT):
|
elseif ($action == ACT_EDIT):
|
||||||
// ========== VARIANT: edit single record =====================================
|
// ========== VARIANT: edit single record =====================================
|
||||||
|
|
||||||
$sql = "SELECT taskname "
|
$sql = "SELECT taskname, projid "
|
||||||
. "FROM task "
|
. "FROM task "
|
||||||
. "WHERE taskid=?";
|
. "WHERE taskid=?";
|
||||||
$sth = $pdo->prepare($sql);
|
$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 ?>">
|
<input type="text" class="form-control" id="taskname" name="taskname" value="<?=$task->taskname ?>">
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
form_create_select('projid', _('Project'), $opt_projects);
|
form_create_select('projid', _('Project'), $opt_projects, $task->projid);
|
||||||
form_edit_buttons($g_scriptname, $id);
|
form_edit_buttons($g_scriptname, $id);
|
||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user