Webgui: filters and pagination
This commit is contained in:
+32
-56
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user