Webgui: filters and pagination

This commit is contained in:
2024-04-15 07:34:31 +02:00
parent 806cc407eb
commit 851f7e13a2
13 changed files with 248 additions and 246 deletions
+3 -18
View File
@@ -36,33 +36,18 @@ switch ($submit = form_get_action()) {
$p[':sid'] = gpc_get_int($_POST, 'sid');
$p[':content'] = gpc_get_string($_POST, 'content');
$p[':remarks'] = gpc_get_string($_POST, 'remarks');
$keys = array_keys($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();
$id = db_exec_insert('box', $p);
$action = ACT_VIEW;
break;
case 'update':
$p[':boxid'] = $id;
$p[':label'] = gpc_get_string($_POST, 'label');
$p[':content'] = gpc_get_string($_POST, 'content');
$p[':color'] = gpc_get_color($_POST, 'color');
$p[':weight'] = min(gpc_get_float($_POST, 'weight'), 99.99);
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
$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());
}
db_exec_update('box', $p, 'boxid');
$action = ACT_VIEW;
break;
+3
View File
@@ -38,3 +38,6 @@ $g_doc_maxsize = 1024*1024*16; // 16 MB
$g_storage_limit = 1024; // MB
$g_thumb_size = 120;
$g_rows_pp = 10; // pagination limit
+7 -32
View File
@@ -24,9 +24,7 @@ switch ($submit = form_get_action()) {
case 'insert':
// WIP New standalone document
$p[':title'] = gpc_get_string($_POST, 'title');
$p[':remarks'] = gpc_get_string($_POST, 'remarks');
$g_message->Add(print_r($_FILES, true));
// debug $g_message->Add(print_r($_FILES, true));
if (empty($_FILES['files']['tmp_name']) ) {
$g_warning->Add(_('No file for upload submitted. Try again by selecting a file first.'));
$action = ACT_ADD;
@@ -66,6 +64,7 @@ switch ($submit = form_get_action()) {
case 'application/pdf':
$file_techname = $g_doc_basepath . '/doc-'.$file_hash.'.'.$file_ext;
$doctype = 'generic';
// $p['pages'] = pdf_get_pagecount($file_tmp);
break;
case 'image/svg+xml':
$file_techname = $g_doc_basepath . '/drw-'.$file_hash.'.'.$file_ext;
@@ -86,41 +85,17 @@ switch ($submit = form_get_action()) {
$p[':docsize'] = $file_size;
$p[':title'] = gpc_get_string($_POST, 'title');
$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);
move_uploaded_file($file_tmp, $file_techname);
$action = ACT_VIEW;
break;
case 'update':
$filename = gpc_get_string($_POST, 'filename');
$title = gpc_get_string($_POST, 'title', 40);
$remarks = gpc_get_string($_POST, 'remarks', 150);
$sql = "UPDATE document "
. "SET filename=:filename,"
. " 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());
}
$p[':docid'] = $id;
$p['filename'] = gpc_get_string($_POST, 'filename');
$p['title'] = gpc_get_string($_POST, 'title', 40);
$p['remarks'] = gpc_get_string($_POST, 'remarks', 150);
db_exec_update('document', $p, 'docid');
$action = ACT_VIEW;
break;
+1 -1
View File
@@ -236,7 +236,7 @@ foreach ($sth->fetchAll() as $row) {
echo '<td>', $row['ddval'],'</td>';
echo '<td>', $row['ddtext'], '</td>';
echo '<td>', $row['ddshort'], '</td>';
echo '<td>', $row['color'], '</td>';
echo '<td>', format_color($row['color']), '</td>';
echo '<td>', $row['sort'], '</td>';
// Action links
echo '<td>';
+154 -92
View File
@@ -11,8 +11,8 @@ $pagetitle = _('Equipment');
$id = gpc_get_int($_REQUEST, 'id', 0);
$opt_supplier = db_get_opt_supp(array(-1 => _('unknown')));
$opt_manufacturer = db_get_opt_manuf(array(-1 => _('unknown')));
$opt_supplier = db_get_opt_supp(array(-1 => _('--- unknown ---')));
$opt_manufacturer = db_get_opt_manuf(array(-1 => _('--- unknown ---')));
$opt_ecat = db_get_options(4); // Equipment categories
// ========== ACTIONS START ===================================================
@@ -26,72 +26,47 @@ switch ($submit = form_get_action()) {
case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break;
case 'insert':
$ename = gpc_get_string($_POST, 'ename');
$ecat = gpc_get_int($_POST, 'category');
$manufacturer = gpc_get_int($_POST, 'manufacturer');
$model = gpc_get_string($_POST, 'model');
$remarks = gpc_get_string($_POST, 'remarks', 150);
$sql = "INSERT INTO equipment "
. " (vid, ename, manufacturer, model, ecat, remarks) "
. "VALUES "
. " (:vid, :ename, :manufacturer, :model, :ecat, :remarks)";
case 'filter':
// TODO save new filter settings
$flt = array();
$flt['cat'] = gpc_get_int($_POST, 'flt_category');
$flt['manuf'] = gpc_get_int($_POST, 'flt_manuf');
$flt['supp'] = gpc_get_int($_POST, 'flt_supp');
$flt['txt'] = gpc_get_string($_POST, 'flt_txt');
$sql = "UPDATE settings SET valstr=? WHERE userid=? AND sno=200";
$sth = $pdo->prepare($sql);
$sth->bindValue(':vid', $user->vid, PDO::PARAM_INT);
$sth->bindValue(':ename', $ename, PDO::PARAM_STR);
$sth->bindValue(':model', $model, PDO::PARAM_STR);
$sth->bindValue(':ecat', $ecat, PDO::PARAM_INT);
$sth->bindValue(':manufacturer', $manufacturer, PDO::PARAM_INT);
$sth->bindValue(':remarks', $remarks, PDO::PARAM_STR);
try {
$sth->execute();
} catch (PDOException $e) {
$g_error->Add('SQL-Error: '. $e->getMessage());
}
$id = $pdo->lastInsertId();
$sth->execute([json_encode($flt), $user->id]);
// Only warning in case of failure
$action = ACT_DEFAULT;
break;
case 'insert':
$p[':vid'] = $user->vid;
$p[':ename'] = gpc_get_string($_POST, 'ename');
$p[':ecat'] = gpc_get_int($_POST, 'category');
$p[':manufacturer'] = gpc_get_int($_POST, 'manufacturer');
$p[':model'] = gpc_get_string($_POST, 'model');
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
$id = db_exec_insert('equipment', $p);
$action = ACT_VIEW;
break;
case 'update':
$ename = gpc_get_string($_POST, 'ename');
$model = gpc_get_string($_POST, 'model');
$serial = gpc_get_string($_POST, 'serial');
$weight = min(gpc_get_float($_POST, 'weight'), 999.99); // limit max value
$price = gpc_get_currency($_POST, 'price');
$purchdate = gpc_get_date($_POST, 'purchdate');
$supplier = gpc_get_int($_POST, 'supplier');
$manufacturer = gpc_get_int($_POST, 'manufacturer');
$ecat = gpc_get_int($_POST, 'category');
$remarks = gpc_get_string($_POST, 'remarks', 150);
$sql = "UPDATE equipment "
. "SET ename=:ename,"
. " model=:model,"
. " serial=:serial,"
. " weight=:weight,"
. " 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());
}
$p[':eid'] = $id;
$p[':ename'] = gpc_get_string($_POST, 'ename');
$p[':model'] = gpc_get_string($_POST, 'model');
$p[':serial'] = gpc_get_string($_POST, 'serial');
$p[':weight'] = min(gpc_get_float($_POST, 'weight'), 999.99); // limit max value
$p[':price'] = gpc_get_currency($_POST, 'price');
$p[':purchdate'] = gpc_get_date($_POST, 'purchdate');
$p[':supplier'] = gpc_get_int($_POST, 'supplier');
if ($p[':supplier'] <= 0) $p[':supplier'] = NULL;
$p[':manufacturer'] = gpc_get_int($_POST, 'manufacturer');
if ($p[':manufacturer'] <= 0) $p[':manufacturer'] = NULL;
$p[':ecat'] = gpc_get_int($_POST, 'category');
if ($p[':ecat'] <= 0) $p[':ecat'] = NULL;
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
db_exec_update('equipment', $p, 'eid');
$action = ACT_VIEW;
break;
@@ -208,24 +183,80 @@ require 'header.php';
if ($action == ACT_DEFAULT):
// ========== 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(
1 => 'ename',
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,"
. " TIMESTAMPDIFF(MONTH, purchdate, NOW()) AS age_mon "
. "FROM equipment WHERE vid=? "
. "ORDER BY eid";
. "FROM equipment";
$sql .= ' WHERE ' . $where;
$sql .= $order;
// if pagination:
$sql .= ' LIMIT ' . ($page - 1) * $g_rows_pp . ',' . $g_rows_pp;
$sth = $pdo->prepare($sql);
$sth->execute([$user->vid]);
$sth->execute($p);
$res = $sth->fetchAll();
echo "<h1>$pagetitle</h1>\n";
// Filter
$opt_special = array(
-2 => _('&horbar; all &horbar;'),
-1 => _('&horbar; none &horbar;')
);
?>
<form method="post" action="<?=$g_scriptname?>">
<div id="filter" class="card">
<div class="card-header">Filter</div>
@@ -233,35 +264,61 @@ echo "<h1>$pagetitle</h1>\n";
<label for="flt_category">Category</label>
<select id="flt_category" name="flt_category">
<?php
foreach ($opt_ecat as $k => $v) {
echo '<option value="', $k,'">', $v, '</option>';
foreach ($opt_special + $opt_ecat as $k => $v) {
echo '<option value="', $k, '"';
if ($k == $flt->cat) {
echo ' selected';
}
echo '>', $v, '</option>';
}
?>
</select>
<label for="flt_manuf">Manufacturer</label>
<select id="flt_category" name="flt_category">
<select id="flt_manuf" name="flt_manuf">
<?php
foreach ($opt_manufacturer as $k => $v) {
echo '<option value="', $k,'">', $v, '</option>';
foreach ($opt_special + $opt_manufacturer as $k => $v) {
echo '<option value="', $k,'"';
if ($k == $flt->manuf) {
echo ' selected';
}
echo '>', $v, '</option>';
}
?>
</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>
</form>
<?php
// Pagination on top
$pagination = get_pagination($g_scriptname, $page, $lastpage);
echo $pagination;
// Data
echo '<table class="table table-striped">', "\n";
echo "<thead>\n";
echo "<tr>";
echo "<th>" . _('Description') . "</th>";
echo "<th>" . _('Manufacturer') . "</th>";
echo "<th>" . _('Model') . "</th>";
echo "<th>" . _('Serial') . "</th>";
echo "<th>" . _('Age') . "</th>";
echo "<th>" . _('Remarks') . "</th>";
echo '<tr>';
echo '<th>', _('Description'), "</th>";
echo '<th>', _('Manufacturer'), "</th>";
echo '<th>', _('Model'), "</th>";
echo '<th>', _('Serial'), "</th>";
echo '<th>', _('Age'), "</th>";
echo '<th>', _('Remarks'), "</th>";
echo "<th>&nbsp;</th>";
echo "</tr>\n";
echo "</thead>\n";
@@ -275,20 +332,22 @@ foreach ($res as $row) {
$age = sprintf(_('%dy'), intdiv($row['age_mon'], 12));
}
echo "<tr>\n";
echo "<td>". $row['ename'] ."</td>\n";
echo "<td>". $opt_manufacturer[$row['manufacturer']] ."</td>\n";
echo "<td>". $row['model'] ."</td>\n";
echo "<td>". $row['serial'] ."</td>\n";
echo "<td>". $age ."</td>\n";
echo "<td>". $row['remarks'] ."</td>\n";
echo "<td>", $row['ename'], "</td>\n";
echo "<td>", ($opt_manufacturer[$row['manufacturer']] ?? ''), "</td>\n";
echo "<td>", $row['model'], "</td>\n";
echo "<td>", $row['serial'], "</td>\n";
echo "<td>", $age, "</td>\n";
echo "<td>", $row['remarks'], "</td>\n";
// Action buttons
form_action_buttons($g_scriptname, $row['eid']);
}
?>
<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>
</table>
<?php
/*
<nav>
<ul class="pagination justify-content-center">
<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="#">Next</a></li>
</ul>
</nav>
<?php
</nav> */
echo $pagination;
form_add_button($g_scriptname);
elseif ($action == ACT_ADD):
// ========== VARIANT: add record =============================================
// filter used to preselect fields
$flt = db_get_filter($user->id, 200);
?>
<h2><?=_('Add Equipment')?></h2>
<form method="post" action="<?=$g_scriptname?>">
@@ -311,8 +373,8 @@ elseif ($action == ACT_ADD):
<input type="text" class="form-control" id="ename" name="ename">
</div>
<?php
form_create_select('category', _('Category'), $opt_ecat);
form_create_select('manufacturer', _('Manufacturer'), $opt_manufacturer);
form_create_select('category', _('Category'), [-1 => '--- none ---'] + $opt_ecat, $flt->cat);
form_create_select('manufacturer', _('Manufacturer'), $opt_manufacturer, $flt->manuf);
?>
<div class="mb-3">
<label for="model" class="form-label"><?=_('Model')?></label>
@@ -446,7 +508,7 @@ $equipment = $sth->fetch(PDO::FETCH_OBJ);
</div>
<?php
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">
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
+32 -56
View File
@@ -41,16 +41,7 @@ switch ($submit = form_get_action()) {
$p[':vesselname'] = gpc_get_string($_POST, 'vesselname');
$p[':model'] = gpc_get_string($_POST, 'model');
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
$keys = array_keys($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();
$id = db_exec_insert('vessel', $p);
// autoselect newly created vessel
$sql = "UPDATE settings SET valint=? WHERE userid=? AND sno=1";
$sth = $pdo->prepare($sql);
@@ -59,7 +50,7 @@ switch ($submit = form_get_action()) {
} catch (PDOException $e) {
$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();
break;
@@ -68,6 +59,7 @@ switch ($submit = form_get_action()) {
$g_error->Add(_('Access denied. You are not the captain.'));
break;
}
$p[':vid'] = gpc_get_int($_POST, 'id');
// $p[':vtype'] = gpc_get_string($_POST, 'vtype');
$p[':vesselname'] = gpc_get_string($_POST, 'vesselname');
$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[':shapefile'] = gpc_get_string($_POST, 'shapefile');
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
$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());
}
db_exec_update('vessel', $p, 'vid');
$action = ACT_DEFAULT;
break;
@@ -153,38 +138,19 @@ $sth->execute([$vid]);
$vessel = $sth->fetch();
// get vessel shape
// TODO predefine base shapes for different vessels
// test for predefined base shape
$shapefilepath = dirname(__FILE__).'/'.$g_shapedir.'/'.$vessel['shapefile'];
if (isset($vessel['shapefile']) and file_exists($shapefilepath)) {
$baseshape = file_get_contents($shapefilepath);
} else {
// use internal default shape
$baseshape = <<<EOT
<svg
width="680.8349"
height="205.42085"
viewBox="0 0 180.13756 54.350934"
version="1.1"
id="svg5"
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 version="1.1" width="1024" height="350" viewBox="0 0 1024 350" id="svg1">
<g id="g1">
<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" />
<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" />
<use id="use1" x="0" y="0" xlink:href="#path2" transform="matrix(1,0,0,-1,0.0781866,350.05682)" />
</g>
</svg>
EOT;
}
@@ -198,17 +164,17 @@ $line = $g->addChild('line');
$line->addAttribute('x1', '100');
$line->addAttribute('y1', '0');
$line->addAttribute('x2', '100');
$line->addAttribute('y2', '100');
$line->addAttribute('style', 'stroke:#ff0000;stroke-width:0.25px');
$line->addAttribute('y2', '350');
$line->addAttribute('style', 'stroke:#ff0000;stroke-width:1px');
// rectangle for storage
$rect = $g->addChild('rect');
$rect->addAttribute('x', '2');
$rect->addAttribute('y', '14');
$rect->addAttribute('width', '20');
$rect->addAttribute('height', '26');
$rect->addAttribute('x', '10');
$rect->addAttribute('y', '80');
$rect->addAttribute('width', '40');
$rect->addAttribute('height', '60');
$rect->addAttribute('stroke', '#000');
$rect->addAttribute('stroke-width', '0.25px');
$rect->addAttribute('stroke-width', '1px');
$rect->addAttribute('fill', '#57E389');
$rect->addAttribute('fill-opacity', '0.4');
@@ -216,9 +182,9 @@ $rect->addAttribute('fill-opacity', '0.4');
$link = $g->addChild('a');
$link->addAttribute('xlink:href', 'storage.php?f=view&id=1');
$text = $link->addChild('text', 'Box1');
$text->addAttribute('font-size', '3.5');
$text->addAttribute('x', '4');
$text->addAttribute('y', '18');
$text->addAttribute('font-size', '10');
$text->addAttribute('x', '14');
$text->addAttribute('y', '95');
?>
<div class="container-fluid my-4">
@@ -369,6 +335,13 @@ echo '<h2>', _('Add additional yacht'), "</h2>\n";
elseif ($action == ACT_EDIT):
// ========== 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,"
. " displacement, ballast, beltpos_aft, beltpos_bow, shapefile,"
. " remarks "
@@ -425,10 +398,13 @@ $vessel = $sth->fetch(PDO::FETCH_OBJ);
<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) ?>">
</div>
<?php /*
<div class="mb-3">
<label for="shapefile" class="form-label"><?=_('Shapefile')?></label>
<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">
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=$vessel->remarks ?></textarea>
+16 -2
View File
@@ -25,6 +25,10 @@ switch ($submit = form_get_action()) {
case 'edit': $action = ACT_EDIT; break;
case 'del': $action = ACT_DELETE; break;
case 'filter':
$action = ACT_DEFAULT;
break;
case 'insert':
$p[':invname'] = gpc_get_string($_POST, 'invname');
$p[':number'] = gpc_get_int($_POST, 'number');
@@ -47,6 +51,7 @@ switch ($submit = form_get_action()) {
$p[':price'] = gpc_get_currency($_POST, 'price');
$p[':purchdate'] = gpc_get_date($_POST, 'purchdate');
$p[':invcond'] = gpc_get_string($_POST, 'invcond');
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
db_exec_update('inventory', $p, 'invid');
$action = ACT_VIEW;
break;
@@ -80,6 +85,8 @@ require 'header.php';
if ($action == ACT_DEFAULT):
// ========== 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 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):
// ========== 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 "
. "WHERE invid=?";
$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>", _('Purchase date'), "</th><td>", $inventory->purchdate, "</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";
form_view_buttons($g_scriptname, $id);
@@ -217,7 +226,8 @@ form_view_buttons($g_scriptname, $id);
elseif ($action == ACT_EDIT):
// ========== 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 "
. "WHERE invid=?";
$sth = $pdo->prepare($sql);
@@ -281,6 +291,10 @@ foreach ($cond as $k => $v) {
?>
</select>
</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
+7 -1
View File
@@ -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>
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
angezeigt. Weitere Felder können im Anschluß über die Bearbeiten-Funktion
ausgefüllt werden.</p>
@@ -66,7 +70,9 @@ z.B. <em>neu</em>, <em>laufend</em> oder <em>erledigt</em>.</p>
<h3>Firmen</h3>
<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>
<p>Ein Dokument kann mehrfach zugeordnet werden. Z.B. einem
+2 -1
View File
@@ -213,9 +213,10 @@ $sth->execute([$id]);
<th><?=_('Task')?></th>
</tr>
</thead>
<?php foreach ($sth->fetchAll() as $row):?>
<?php foreach ($sth->fetchAll() as $row): ?>
<tr>
<td><?=$row['taskname']?></td>
<?php form_action_buttons('task.php', $row['taskid']); ?>
</tr>
<?php endforeach; ?>
</table>
+3 -18
View File
@@ -32,34 +32,19 @@ switch ($submit = form_get_action()) {
$p[':unit'] = gpc_get_int($_POST, 'unit');
$p[':storedate'] = gpc_get_string($_POST, 'storedate');
$p[':shelflife'] = gpc_get_string($_POST, 'shelflife');
$keys = array_keys($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();
$id = db_exec_insert('provisions', $p);
$action = ACT_VIEW;
break;
case 'update':
$p[':provid'] = $id;
$p[':provname'] = gpc_get_string($_POST, 'provname');
$p[':number'] = gpc_get_int($_POST, 'number');
$p[':unit'] = gpc_get_int($_POST, 'unit');
$p[':storedate'] = gpc_get_string($_POST, 'storedate');
$p[':shelflife'] = gpc_get_string($_POST, 'shelflife');
$p[':sid'] = gpc_get_int($_POST, 'sid');
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
$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());
}
db_exec_update('provisions', $p, 'provid');
$action = ACT_VIEW;
break;
+1 -1
View File
@@ -158,7 +158,7 @@ echo "</tr>\n";
foreach ($res as $row) {
echo "<tr>\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";
form_action_buttons('box.php', $row['boxid']);
echo "</tr>\n";
+10 -20
View File
@@ -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";