Improved cable functions

master
Thomas Hooge 2 years ago
parent 6e4c4236aa
commit 6a5c483c42
  1. 9
      cable.php
  2. 2
      lang/de.php
  3. 14
      tpl/cable.tpl
  4. 10
      tpl/cableedit.tpl
  5. 12
      tpl/cableview.tpl
  6. 2
      tpl/vlan.tpl

@ -34,14 +34,16 @@ switch ($submit = form_get_action()) {
case 'insert': case 'insert':
$description = sanitize($_POST['description']); $description = sanitize($_POST['description']);
$color = sanitize($_POST['color']); $color = sanitize($_POST['color']);
$type = sanitize($_POST['cable_type']);
$info = sanitize($_POST['info']); $info = sanitize($_POST['info']);
$sql = "INSERT INTO cable $sql = "INSERT INTO cable
(cable_description, cable_color, cable_info) (cable_description, cable_color, cable_type, cable_info)
VALUES VALUES
(:description, :color, :info)"; (:description, :color, :type, :info)";
$sth = $dbh->prepare($sql); $sth = $dbh->prepare($sql);
$sth->bindValue(':description', $description, PDO::PARAM_STR); $sth->bindValue(':description', $description, PDO::PARAM_STR);
$sth->bindValue(':color', $color, PDO::PARAM_STR); $sth->bindValue(':color', $color, PDO::PARAM_STR);
$sth->bindValue(':type', $type, PDO::PARAM_STR);
$sth->bindValue(':info', $info, PDO::PARAM_STR); $sth->bindValue(':info', $info, PDO::PARAM_STR);
$sth->execute(); $sth->execute();
$id = $dbh->lastInsertId(); $id = $dbh->lastInsertId();
@ -53,12 +55,14 @@ switch ($submit = form_get_action()) {
$color = sanitize($_POST['color']); $color = sanitize($_POST['color']);
$length = sanitize($_POST['length']); $length = sanitize($_POST['length']);
$type = sanitize($_POST['cable_type']); $type = sanitize($_POST['cable_type']);
$links = sanitize($_POST['links']);
$info = sanitize($_POST['info']); $info = sanitize($_POST['info']);
$sql = "UPDATE cable $sql = "UPDATE cable
SET cable_description=:desc, SET cable_description=:desc,
cable_color=:color, cable_color=:color,
cable_length=:length, cable_length=:length,
cable_type=:type, cable_type=:type,
cable_links=:links,
cable_info=:info cable_info=:info
WHERE cable_id=:id"; WHERE cable_id=:id";
$sth = $dbh->prepare($sql); $sth = $dbh->prepare($sql);
@ -67,6 +71,7 @@ switch ($submit = form_get_action()) {
$sth->bindValue(':length', $length, PDO::PARAM_INT); $sth->bindValue(':length', $length, PDO::PARAM_INT);
$sth->bindValue(':color', $color, PDO::PARAM_STR); $sth->bindValue(':color', $color, PDO::PARAM_STR);
$sth->bindValue(':type', $type, PDO::PARAM_STR); $sth->bindValue(':type', $type, PDO::PARAM_STR);
$sth->bindValue(':links', $links, PDO::PARAM_INT);
$sth->bindValue(':info', $info, PDO::PARAM_STR); $sth->bindValue(':info', $info, PDO::PARAM_STR);
$sth->execute(); $sth->execute();
$action = ACT_VIEW; $action = ACT_VIEW;

@ -46,7 +46,7 @@ $lang = array(
'lang_submit' => 'Absenden', 'lang_submit' => 'Absenden',
'lang_unassigned' => 'Nicht zugeordnet', 'lang_unassigned' => 'Nicht zugeordnet',
'lang_warning' => 'Warnung', 'lang_warning' => 'Warnung',
'lang_description' => 'Beschreibung', 'lang_description' => 'Bezeichnung',
'lang_empty' => 'leer', 'lang_empty' => 'leer',
'lang_source' => 'Quelle', 'lang_source' => 'Quelle',
'lang_target' => 'Ziel', 'lang_target' => 'Ziel',

@ -23,29 +23,35 @@
<td class="header"> <td class="header">
{$lang_cable_type} {$lang_cable_type}
</td> </td>
<td class="header">
# Links
</td>
<td class="header"> <td class="header">
{$lang_cable_info} {$lang_cable_info}
</td> </td>
</tr> </tr>
{foreach item=cable from=$cables} {foreach item=cable from=$cables}
<tr> <tr>
<td class="label"> <td class="label" style="width:20%">
<img src="image.php?color={$cable.cable_color}" alt="#{$cable.cable_color}"> <img src="image.php?color={$cable.cable_color}" alt="#{$cable.cable_color}">
<a href="cable.php?f=view&id={$cable.id}">{$cable.description}</a> <a href="cable.php?f=view&id={$cable.id}">{$cable.description}</a>
</td> </td>
<td class="label"> <td class="label" style="width:10%">
{$cable.cable_length} m {$cable.cable_length} m
</td> </td>
<td class="label"> <td class="label" style="width:10%">
{$cable.cable_type} {$cable.cable_type}
</td> </td>
<td class="label" style="width:10%">
{$cable.cable_links}
</td>
<td class="label"> <td class="label">
{$cable.info} {$cable.info}
</td> </td>
</tr> </tr>
{foreachelse} {foreachelse}
<tr> <tr>
<td> <td colspan="4">
{$lang_cable_none} {$lang_cable_none}
</td> </td>
</tr> </tr>

@ -55,6 +55,14 @@
{html_options name=cable_type options=$type_options selected=$cable->cable_type} {html_options name=cable_type options=$type_options selected=$cable->cable_type}
</td> </td>
</tr> </tr>
<tr>
<td class="label">
# Links
</td>
<td class="value">
<input type="text" size="4" name="links" maxlength="4" value="{$cable->cable_links}">
</td>
</tr>
<tr> <tr>
<td class="label"> <td class="label">
{$lang_color} {$lang_color}
@ -65,7 +73,7 @@
</tr> </tr>
<tr> <tr>
<td class="label"> <td class="label">
{$lang_info} {$lang_cable_info}
</td> </td>
<td class="value"> <td class="value">
<textarea name="info" cols="30" rows="10">{$cable->info}</textarea> <textarea name="info" cols="30" rows="10">{$cable->info}</textarea>

@ -28,6 +28,14 @@
{$cable->description} {$cable->description}
</td> </td>
</tr> </tr>
<tr>
<td class="label">
{$lang_length}
</td>
<td class="value">
{$cable->cable_length} m
</td>
</tr>
<tr> <tr>
<td class="label"> <td class="label">
{$lang_cable_type} {$lang_cable_type}
@ -38,10 +46,10 @@
</tr> </tr>
<tr> <tr>
<td class="label"> <td class="label">
{$lang_length} # Links
</td> </td>
<td class="value"> <td class="value">
{$cable->cable_length} m {$cable->cable_links}
</td> </td>
</tr> </tr>
<tr> <tr>

@ -26,7 +26,7 @@
</tr> </tr>
{foreach item=vlan from=$vlans} {foreach item=vlan from=$vlans}
<tr> <tr>
<td class="label"> <td class="label" style="width:10%">
{$vlan.number} {$vlan.number}
</td> </td>
<td class="value"> <td class="value">