Webgui fixed cables and fuses, parts of code reorganized
This commit is contained in:
1 parent
9d09b1e120
commit
5641e1706f
25 files changed
+497
-427
No files matched your search
+18
-7
@@ -9,6 +9,7 @@
|
||||
require 'globals.inc';
|
||||
require 'lib/db.inc';
|
||||
require 'lib/gpc.inc';
|
||||
require 'lib/form.inc';
|
||||
|
||||
$pagetitle = _('Cables');
|
||||
|
||||
@@ -31,6 +32,7 @@ switch ($submit = form_get_action()) {
|
||||
|
||||
case 'filter':
|
||||
$flt = array();
|
||||
$flt['type'] = gpc_get_int($_POST, 'flt_type');
|
||||
$flt['txt'] = gpc_get_string($_POST, 'flt_txt');
|
||||
db_save_filter($flt, 211);
|
||||
$action = ACT_DEFAULT;
|
||||
@@ -95,7 +97,7 @@ if ($action == ACT_DEFAULT):
|
||||
// ========== VARIANT: default behavior =======================================
|
||||
|
||||
// load filter from db
|
||||
$flt = db_get_filter($user->id, 211, ['txt']);
|
||||
$flt = db_get_filter($user->id, 211, ['txt', 'type']);
|
||||
|
||||
$w = array('vid=:vid');
|
||||
$p = array(':vid' => $user->vid);
|
||||
@@ -104,6 +106,13 @@ if (strlen($flt->txt) > 1) {
|
||||
$w[] = 'cablename LIKE :txt OR remarks LIKE :txt';
|
||||
$p[':txt'] = '%'.$flt->txt.'%';
|
||||
}
|
||||
if ($flt->type == -1) {
|
||||
$w[] = 'cabletype IS NULL';
|
||||
} elseif ($flt->type > 0) {
|
||||
$w[] = 'cabletype=:cabletype';
|
||||
$p[':type'] = $flt->type;
|
||||
}
|
||||
|
||||
$where = join(' AND ', $w);
|
||||
$order = ' ORDER BY cablename';
|
||||
|
||||
@@ -115,10 +124,10 @@ echo "<h1>$pagetitle</h1>\n";
|
||||
<div id="filter" class="card">
|
||||
<div class="card-header"><i class="bi bi-funnel me-2"></i>Filter</div>
|
||||
<div class="card-body d-flex flex-wrap gap-3">
|
||||
<div class="d-flex flex-nowrap gap-2">
|
||||
<label for="flt_txt">Text</label>
|
||||
<input type="text" class="form-control" name="flt_txt" maxlength="30" value="<?=$flt->txt ?? ''?>">
|
||||
</div>
|
||||
<?php
|
||||
filter_create_select('flt_type', _('Type'), $g_opt_all + $g_opt_none + $opt_cabletype, $flt->type);
|
||||
filter_create_text('flt_txt', _('Text'), $flt->text, 30, 45);
|
||||
?>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button name="submit[filter]" class="btn btn-sm btn-primary" title="<?=_('Apply')?>"><?=_('Go')?></button>
|
||||
@@ -128,7 +137,7 @@ echo "<h1>$pagetitle</h1>\n";
|
||||
</form>
|
||||
<?php
|
||||
|
||||
$sql = "SELECT cableid, cablename, conductors, length, xsection, color, cablecond "
|
||||
$sql = "SELECT cableid, cablename, cabletype, conductors, length, xsection, color, cablecond "
|
||||
. "FROM cable ";
|
||||
$sql .= ' WHERE ' . $where;
|
||||
$sql .= $order;
|
||||
@@ -143,6 +152,7 @@ echo "<tr>\n";
|
||||
echo '<th>#</th>';
|
||||
echo '<th>', _('Cable'), "</th>";
|
||||
echo '<th>', _('Name'), "</th>";
|
||||
echo '<th>', _('Type'), "</th>";
|
||||
echo '<th>', _('Conductors'), "</th>";
|
||||
echo '<th>', _('Length'), "</th>";
|
||||
echo '<th>', _('Cross section'), "</th>";
|
||||
@@ -160,6 +170,7 @@ foreach ($res as $row) {
|
||||
echo "</td>\n";
|
||||
echo "<td>", $row['cableid'], "</td>\n";
|
||||
echo "<td>", $row['cablename'], "</td>\n";
|
||||
echo "<td>", $row['cabletype'], "</td>\n";
|
||||
echo "<td>", $row['conductors'], "</td>\n";
|
||||
echo "<td>", $row['length'], "m</td>\n";
|
||||
echo "<td>", $row['xsection'], "mm²</td>\n";
|
||||
@@ -171,7 +182,7 @@ foreach ($res as $row) {
|
||||
echo "</tr>\n";
|
||||
}
|
||||
// Table summary
|
||||
table_rec_summary(1, $i, $i, 9);
|
||||
// table_rec_summary(1, $i-1, $i-1, 10);
|
||||
echo "</table>\n";
|
||||
|
||||
form_add_button($g_scriptname);
|
||||
|
||||
Reference in new issue
Block a user