More webgui work. Filters e.g.
This commit is contained in:
+89
-37
@@ -135,12 +135,11 @@ $sql = "SELECT vesselname, model, loa, lwl, beam, draught, draught_min,"
|
||||
. "WHERE vid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$vid]);
|
||||
$vessel = $sth->fetch();
|
||||
|
||||
$vessel = $sth->fetch(PDO::FETCH_OBJ);
|
||||
// get vessel shape
|
||||
// test for predefined base shape
|
||||
$shapefilepath = dirname(__FILE__).'/'.$g_shapedir.'/'.$vessel['shapefile'];
|
||||
if (isset($vessel['shapefile']) and file_exists($shapefilepath)) {
|
||||
$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
|
||||
@@ -156,35 +155,88 @@ EOT;
|
||||
}
|
||||
|
||||
$shape = new SimpleXMLElement($baseshape);
|
||||
// $shape['width'], $shape['height']
|
||||
|
||||
$g = $shape->addChild('g');
|
||||
$g->addAttribute('id', 'boxlayout');
|
||||
|
||||
// line for belt
|
||||
$line = $g->addChild('line');
|
||||
$line->addAttribute('x1', '100');
|
||||
$line->addAttribute('y1', '0');
|
||||
$line->addAttribute('x2', '100');
|
||||
$line->addAttribute('y2', '350');
|
||||
$line->addAttribute('style', 'stroke:#ff0000;stroke-width:1px');
|
||||
if (isset($vessel->beltpos_aft) and isset($vessel->loa) and ($vessel->beltpos_aft < $vessel->loa)) {
|
||||
$x = round($vessel->beltpos_aft / $vessel->loa * 1024);
|
||||
$line = $g->addChild('line');
|
||||
$line->addAttribute('x1', $x);
|
||||
$line->addAttribute('y1', '0');
|
||||
$line->addAttribute('x2', $x);
|
||||
$line->addAttribute('y2', $shape['height']);
|
||||
$line->addAttribute('style', 'stroke:#ff0000;stroke-width:1px');
|
||||
}
|
||||
|
||||
if (isset($vessel->beltpos_bow) and isset($vessel->loa) and ($vessel->beltpos_bow < $vessel->loa)) {
|
||||
$x = round($vessel->beltpos_bow / $vessel->loa * 1024);
|
||||
$line = $g->addChild('line');
|
||||
$line->addAttribute('x1', $x);
|
||||
$line->addAttribute('y1', '0');
|
||||
$line->addAttribute('x2', $x);
|
||||
$line->addAttribute('y2', $shape['height']);
|
||||
$line->addAttribute('style', 'stroke:#ff0000;stroke-width:1px');
|
||||
}
|
||||
|
||||
// select all visible storages
|
||||
// - x,y,z is center of storage
|
||||
// - todo: shape offset x and y for non centered shapes?
|
||||
// read center line y-coordinate from shape?
|
||||
if (isset($vessel->loa)) {
|
||||
$f = $shape['width'] / ($vessel->loa * 1000);
|
||||
$sql = "SELECT sid, sname, x, y, wx, wy FROM storage WHERE x>0 AND wx>0 AND wy>0 AND vid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$user->vid]);
|
||||
foreach ($sth->fetchAll() as $row) {
|
||||
$w = round($row['wx'] * $f);
|
||||
$h = round($row['wy'] * $f);
|
||||
$x = round($row['x'] * $f - $w / 2.0);
|
||||
$y = round($row['y'] * $f + $shape['height'] / 2.0 - $h / 2.0);
|
||||
$rect = $g->addChild('rect');
|
||||
$rect->addChild('title', $row['sname']);
|
||||
$rect->addAttribute('x', $x);
|
||||
$rect->addAttribute('y', $y);
|
||||
$rect->addAttribute('width', $w);
|
||||
$rect->addAttribute('height', $h);
|
||||
$rect->addAttribute('stroke', '#000');
|
||||
$rect->addAttribute('stroke-width', '1px');
|
||||
$rect->addAttribute('fill', '#57E389');
|
||||
$rect->addAttribute('fill-opacity', '0.4');
|
||||
}
|
||||
|
||||
// grid
|
||||
// not yet production ready
|
||||
/* $step = round($shape['width'] / ($vessel->loa * 10)); // 10cm steps
|
||||
$x = $step;
|
||||
$n = 0;
|
||||
while ($x < ($vessel->loa * 1000)) {
|
||||
$n += 1;
|
||||
$line = $g->addChild('line');
|
||||
$line->addAttribute('x1', $x);
|
||||
$line->addAttribute('y1', '0');
|
||||
$line->addAttribute('x2', $x);
|
||||
$line->addAttribute('y2', $shape['height']);
|
||||
if ($n % 10 == 0) {
|
||||
$line->addAttribute('style', 'stroke:#0000dd;stroke-width:1px');
|
||||
} else {
|
||||
$line->addAttribute('style', 'stroke:#0000aa;stroke-width:0.3px');
|
||||
}
|
||||
$x += $step;
|
||||
} */
|
||||
|
||||
}
|
||||
|
||||
// rectangle for storage
|
||||
$rect = $g->addChild('rect');
|
||||
$rect->addAttribute('x', '10');
|
||||
$rect->addAttribute('y', '80');
|
||||
$rect->addAttribute('width', '40');
|
||||
$rect->addAttribute('height', '60');
|
||||
$rect->addAttribute('stroke', '#000');
|
||||
$rect->addAttribute('stroke-width', '1px');
|
||||
$rect->addAttribute('fill', '#57E389');
|
||||
$rect->addAttribute('fill-opacity', '0.4');
|
||||
|
||||
// text with link
|
||||
$link = $g->addChild('a');
|
||||
/*$link = $g->addChild('a');
|
||||
$link->addAttribute('xlink:href', 'storage.php?f=view&id=1');
|
||||
$text = $link->addChild('text', 'Box1');
|
||||
$text->addAttribute('font-size', '10');
|
||||
$text->addAttribute('x', '14');
|
||||
$text->addAttribute('y', '95');
|
||||
$text->addAttribute('y', '95'); */
|
||||
|
||||
?>
|
||||
<div class="container-fluid my-4">
|
||||
@@ -199,15 +251,15 @@ $text->addAttribute('y', '95');
|
||||
<div class="card-body">
|
||||
<h5 class="card-title"><?=_('Boat data') ?></h5>
|
||||
<table class="table table-sm">
|
||||
<tr><td><?=_('Loa')?></td><td><?=format_float($vessel['loa'], 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Lwl')?></td><td><?=format_float($vessel['lwl'], 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Beam')?></td><td><?=format_float($vessel['beam'], 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Draught')?></td><td><?=format_float($vessel['draught'], 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Draught, min.')?></td><td><?=format_float($vessel['draught_min'], 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Displacement')?></td><td><?=$vessel['displacement']?> kg</td></tr>
|
||||
<tr><td><?=_('Ballast')?></td><td><?=$vessel['ballast']?> kg</td></tr>
|
||||
<tr><td><?=_('Belt position aft')?></td><td><?=format_float($vessel['beltpos_aft'], 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Belt position bow')?></td><td><?=format_float($vessel['beltpos_bow'], 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Loa')?></td><td><?=format_float($vessel->loa, 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Lwl')?></td><td><?=format_float($vessel->lwl, 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Beam')?></td><td><?=format_float($vessel->beam, 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Draught')?></td><td><?=format_float($vessel->draught, 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Draught, min.')?></td><td><?=format_float($vessel->draught_min, 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Displacement')?></td><td><?=$vessel->displacement?> kg</td></tr>
|
||||
<tr><td><?=_('Ballast')?></td><td><?=$vessel->ballast?> kg</td></tr>
|
||||
<tr><td><?=_('Belt position aft')?></td><td><?=format_float($vessel->beltpos_aft, 2, 'm')?></td></tr>
|
||||
<tr><td><?=_('Belt position bow')?></td><td><?=format_float($vessel->beltpos_bow, 2, 'm')?></td></tr>
|
||||
</table>
|
||||
<?php
|
||||
// Edit vessel only for captain
|
||||
@@ -363,19 +415,19 @@ $vessel = $sth->fetch(PDO::FETCH_OBJ);
|
||||
<input type="text" class="form-control" id="model" name="model" value="<?=$vessel->model ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="loa" class="form-label"><?=_('LoA')?></label>
|
||||
<label for="loa" class="form-label"><?=_('LoA')?>, m</label>
|
||||
<input type="text" class="form-control" id="loa" name="loa" value="<?=format_float($vessel->loa, 2) ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="lwl" class="form-label"><?=_('LwL')?></label>
|
||||
<label for="lwl" class="form-label"><?=_('LwL')?>, m</label>
|
||||
<input type="text" class="form-control" id="lwl" name="lwl" value="<?=format_float($vessel->lwl, 2) ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="beam" class="form-label"><?=_('Beam')?></label>
|
||||
<label for="beam" class="form-label"><?=_('Beam')?>, m</label>
|
||||
<input type="text" class="form-control" id="beam" name="beam" value="<?=format_float($vessel->beam, 2) ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="draught" class="form-label"><?=_('Draught')?></label>
|
||||
<label for="draught" class="form-label"><?=_('Draught')?>, m</label>
|
||||
<input type="text" class="form-control" id="draught" name="draught" value="<?=format_float($vessel->draught, 2) ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
@@ -391,11 +443,11 @@ $vessel = $sth->fetch(PDO::FETCH_OBJ);
|
||||
<input type="number" input-mode="decimal" min="0" max="100000" step="1" class="form-control" id="ballast" name="ballast" value="<?=$vessel->ballast ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="beltpos_aft" class="form-label"><?=_('Belt position aft')?></label>
|
||||
<label for="beltpos_aft" class="form-label"><?=_('Belt position aft')?>, m</label>
|
||||
<input type="text" class="form-control" id="beltpos_aft" name="beltpos_aft" value="<?=format_float($vessel->beltpos_aft, 2) ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="beltpos_bow" class="form-label"><?=_('Belt position bow')?></label>
|
||||
<label for="beltpos_bow" class="form-label"><?=_('Belt position bow')?>, m</label>
|
||||
<input type="text" class="form-control" id="beltpos_bow" name="beltpos_bow" value="<?=format_float($vessel->beltpos_bow, 2) ?>">
|
||||
</div>
|
||||
<?php /*
|
||||
|
||||
Reference in New Issue
Block a user