Add(_('Delete prohibited, invalid security token!')); $action = ACT_VIEW; break; } // TODO $action = ACT_DEFAULT; break; default: $g_error->Add(sprintf(_('Unknown function!'), $submit)); $valid = FALSE; } // ========== ACTIONS END ===================================================== require 'header.php'; // ========== PAGE CONTENT ==================================================== if ($action == ACT_DEFAULT): // ========== VARIANT: default behavior ======================================= // load filter from db $flt = db_get_filter($user->id, 211); echo "

$pagetitle

\n"; // Filter ?>
Filter
query($sql); $res = $sth->fetchAll(); echo '', "\n"; echo "\n"; echo "\n"; echo ''; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo ""; echo "\n"; echo "\n"; $i = 0; foreach ($res as $row) { $i++; // record number echo "\n"; echo '\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } // Table summary table_rec_summary($i0, $i, $numrows, 6); echo "
#', _('Cable'), "', _('Name'), "', _('Conductors'), "', _('Length'), "', _('Cross section'), "', _('Color'), "', _('Condition'), "
', $i; echo '', "\n"; echo "", $row['cableid'], "", $row['cablename'], "", $row['conductors'], "", $row['length'], "m", $row['xsection'], "mm²", format_color($row['color']), "", $row['condition'], ""; echo '', "\n"; echo "
\n"; form_add_button($g_scriptname); elseif ($action == ACT_ADD): // ========== VARIANT: add record ============================================= echo '

', _('Add Cable'), "

\n"; ?>
\n"; elseif ($action == ACT_VIEW): // ========== VARIANT: view single record ===================================== $sql = "SELECT cablename, cabletype, length, conductors, diameter, xsection," . " weight, color, supplier, manufacturer, cablecond, remarks " . "FROM cable " . "WHERE cableid=?"; $sth = $pdo->prepare($sql); $sth->execute([$id]); $cable = $sth->fetch(PDO::FETCH_OBJ); echo '

', _('View cable'), "

\n"; echo '', "\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo '\n"; echo "\n"; echo "
', _('Cable'),"", $cable->cablename, "
', _('Type'),"", $opt_cabletype[$cable->cabletype], "
', _('Length'),"", format_float($cable->length, 1, 'm'), "
', _('Conductors'),"", $cable->conductors, "
', _('Diameter'),"", format_float($cable->diameter, 1, 'mm'), "
', _('Cross section'),"", format_float($cable->xsection, 1, 'mm²'), "
', _('Weight'),"", format_float($cable->weight, 2, 'kg/m'), "
', _('Color'),"", format_color($cable->color), "
', _('Condition'),"", $opt_cablecond[$cable->cablecond], "
", _('Remarks'), "", nl2br($cable->remarks), "
\n"; form_view_buttons($g_scriptname, $id); elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== $sql = "SELECT cablename, cabletype, length, conductors, diameter, xsection," . " weight, color, supplier, manufacturer, cablecond, remarks " . "FROM cable " . "WHERE cableid=?"; $sth = $pdo->prepare($sql); $sth->execute([$id]); $cable = $sth->fetch(PDO::FETCH_OBJ); echo '

', _('Edit cable'), "

\n"; ?>
cabletype); ?>
cablecond); ?>
\n"; elseif ($action == ACT_DELETE): // ========== VARIANT: delete record ========================================== echo '

', _('Delete cable'), "

\n"; $sql = "SELECT objid, objtype FROM tagref WHERE tagid=?"; $sth = $pdo->prepare($sql); $sth->execute([$id]); if ($sth->rowCount() > 0) { foreach ($sth->fetchAll() as $row) { echo '', $row['objid'], '/', $row['objtype'], "\n"; } } else { echo _('Tag is not used anywhere'); $_SESSION['token'] = bin2hex(random_bytes(8)); form_delete_buttons($g_scriptname, $id, $_SESSION['token']); } else: // ========== ERROR UNKNOWN VARIANT =========================================== echo '

', _('Unknown function call: Please report to system development!'), "

\n"; endif; // $action == ... // ========== END OF VARIANTS ================================================= include 'footer.php';