Webgui: filter and pagination working
This commit is contained in:
+64
-29
@@ -78,6 +78,7 @@ switch ($submit = form_get_action()) {
|
||||
if ($p[':shapefile'] == '-1') {
|
||||
$p[':shapefile'] = NULL;
|
||||
}
|
||||
$p[':shipyard'] = gpc_get_int($_POST, 'shipyard');
|
||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||
db_exec_update('vessel', $p, 'vid');
|
||||
$action = ACT_DEFAULT;
|
||||
@@ -109,44 +110,68 @@ $sth->execute([$user->id]);
|
||||
$res = $sth->fetch(PDO::FETCH_NUM);
|
||||
$vid = ($res[0]);
|
||||
|
||||
// Switch between vessels
|
||||
$sth = $pdo->query("SELECT vid, vesselname, model FROM vessel ORDER BY vid");
|
||||
$res = $sth->fetchAll();
|
||||
echo '<form class="row align-items-center" method="post">', "\n";
|
||||
echo '<div class="col-1">', "\n";
|
||||
echo '<label class="form-label" for="vid">Yacht:</label>';
|
||||
echo "</div>\n";
|
||||
echo '<div class="col-4">', "\n";
|
||||
echo '<select class="form-select" name="vid" id="vid">', "\n";
|
||||
foreach ($res as $row) {
|
||||
echo '<option value="', $row['vid'], '"', ($row['vid'] == $vid ? ' selected>' : '>');
|
||||
echo $row['vesselname'], ' - ', $row['model'];
|
||||
echo "</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</div>\n";
|
||||
echo '<div class="col">', "\n";
|
||||
echo '<button type="submit" class="btn btn-secondary" name="submit[select]">', _('Select'), '</button>', "\n";
|
||||
echo '<button type="submit" class="btn btn-secondary" name="submit[add]">', _('Add yacht'), '</button>', "\n";
|
||||
echo "</div>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
// Get current vessel data
|
||||
$sql = "SELECT vesselname, model, loa, lwl, beam, draught, draught_min,"
|
||||
. " displacement, ballast, beltpos_aft, beltpos_bow, shapefile,"
|
||||
. " remarks "
|
||||
. " shipyard, remarks "
|
||||
. "FROM vessel "
|
||||
. "WHERE vid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$vid]);
|
||||
$vessel = $sth->fetch(PDO::FETCH_OBJ);
|
||||
|
||||
// Show remarks first
|
||||
if (strlen($vessel->remarks) > 0) {
|
||||
echo "<p>";
|
||||
echo nl2br($vessel->remarks);
|
||||
echo "</p>\n";
|
||||
echo '<div class="container-fluid">', "\n"; // head block
|
||||
|
||||
// Switch between vessels
|
||||
?>
|
||||
<form class="row align-items-center" method="post" action="<?=$g_scriptname?>">
|
||||
<div class="col-1">
|
||||
<label class="form-label" for="vid">Yacht:</label>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<select class="form-select" name="vid" id="vid">', "\n";
|
||||
<?php
|
||||
$sth = $pdo->query("SELECT vid, vesselname, model FROM vessel ORDER BY vid");
|
||||
$res = $sth->fetchAll();
|
||||
foreach ($res as $row) {
|
||||
echo ' <option value="', $row['vid'], '"', ($row['vid'] == $vid ? ' selected>' : '>');
|
||||
echo $row['vesselname'], ' - ', $row['model'];
|
||||
echo "</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col">
|
||||
<?php
|
||||
echo ' <button type="submit" class="btn btn-secondary" name="submit[select]">', _('Select'), '</button>', "\n";
|
||||
echo ' <button type="submit" class="btn btn-secondary" name="submit[add]">', _('Add yacht'), '</button>', "\n";
|
||||
?>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
// Show additional yacht info
|
||||
echo '<div class="row my-2">', "\n";
|
||||
echo '<div class="col-1"></div>', "\n";
|
||||
echo '<div class="col">';
|
||||
if ($vessel->shipyard) {
|
||||
if ($vessel->shipyard == -3) {
|
||||
echo _('Custom-build');
|
||||
} else {
|
||||
$sql = "SELECT compname FROM company WHERE compid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$vessel->shipyard]);
|
||||
echo sprintf(_('Built by %s'), $sth->fetchColumn());
|
||||
// TODO year of build?
|
||||
}
|
||||
}
|
||||
if (strlen($vessel->remarks) > 0) {
|
||||
echo nl2br($vessel->remarks);
|
||||
}
|
||||
echo "</div>\n";
|
||||
echo "</div>\n"; // row 2
|
||||
|
||||
echo "</div>\n"; // end of yacht head block
|
||||
|
||||
// get vessel shape
|
||||
// test for predefined base shape
|
||||
@@ -377,6 +402,8 @@ echo "</table>\n";
|
||||
<li class="list-group-item"><a href="settings.php"><?=_('Settings')?></a></li>
|
||||
<li class="list-group-item"><a href="task.php"><?=_('Tasks')?></a></li>
|
||||
<li class="list-group-item"><a href="measurement.php"><?=_('Measurements')?></a></li>
|
||||
<li class="list-group-item"><a href="cable.php"><?=_('Cables')?></a></li>
|
||||
<li class="list-group-item"><a href="fuse.php"><?=_('Fuses')?></a></li>
|
||||
<li class="list-group-item"><a href="checklist.php"><?=_('Checklists')?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -426,9 +453,16 @@ foreach (glob($g_shapedir.'/*.svg') as $f) {
|
||||
$opt_shapefiles[$f] = $f;
|
||||
}
|
||||
|
||||
$opt_shipyard = $g_opt_none + [-3 => _('― Custom-built ―')];
|
||||
$sql = "SELECT compid, compname FROM company WHERE comptype=3 ORDER BY compname";
|
||||
$sth = $pdo->query($sql);
|
||||
foreach ($sth->fetchAll(PDO::FETCH_NUM) as $row) {
|
||||
$opt_shipyard[$row[0]] = $row[1];
|
||||
}
|
||||
|
||||
$sql = "SELECT vesselname, vtype, model, loa, lwl, beam, draught, draught_min,"
|
||||
. " displacement, ballast, beltpos_aft, beltpos_bow, shapefile,"
|
||||
. " remarks "
|
||||
. " shipyard, remarks "
|
||||
. "FROM vessel "
|
||||
. "WHERE vid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -488,6 +522,7 @@ $vessel = $sth->fetch(PDO::FETCH_OBJ);
|
||||
<input type="text" class="form-control" id="shapefile" name="shapefile" value="<?=$vessel->shapefile ?>">
|
||||
</div> */
|
||||
form_create_select('shapefile', _('Shape file'), $opt_shapefiles, $vessel->shapefile);
|
||||
form_create_select('shipyard', _('Shipyard'), $opt_shipyard, $vessel->shipyard);
|
||||
?>
|
||||
<div class="mb-3">
|
||||
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
|
||||
|
||||
Reference in New Issue
Block a user