Subversion Repositories public

Rev

Blame | Last modification | View Log | RSS feed

<?
require_once('version.inc');
require_once('dbaccess.inc');
require_once('language.inc');
require_once('header.inc');
require_once('crypt.inc');
require_once('settings.inc');
require_once('menu.inc');

function SaveNewStatus() {
        $ks_num = $_REQUEST['ks_num'];
        $ks_status = $_REQUEST['ks_status'];

        $db = OpenDB();
        $query = "select ks_status from key_status where ks_status = $ks_num";
        $result = QueryDB($db, $query);
        $numrows = numrowsDB($result);

        if ($numrows == 1) {
           Error("Schl&uuml;ssel $ks_num ist bereits vorhanden!\n");
           closeDB($db);
           return false;
        }

        $query = "insert into key_status (ks_num, ks_status) values ($ks_num, '$ks_status')";

        if (!TQueryDB($db, $query)) {
           Error("SQL-Error: $query");
           closeDB($db);
           return false;
        }

        closeDB($db);
        return true;
}

function SaveEditStatus() {
        $ks_num = $_REQUEST['ks_num'];
        $ks_status = $_REQUEST['ks_status'];

        $db = OpenDB();
        $query = "select ks_status from key_status where ks_num = $ks_num";
        $result = QueryDB($db, $query);
        $numrows = numrowsDB($result);

        if ($numrows != 1) {
           Error("Schl&uuml;ssel $ks_num ist nicht vorhanden!\n");
           closeDB($db);
           return false;
        }

        $query = "update key_status set ks_status = '$ks_status' where ks_num = $ks_num";

        if (!TQueryDB($db, $query)) {
           Error("SQL-Error: $query");
           closeDB($db);
           return false;
        }

        closeDB($db);
        return true;
}

$newstatus = $_REQUEST['newstatus'];
$editstatus = $_REQUEST['editstatus'];

if (!isset($editstatus)) {
   $editstatus = 0;
}

$savenewstatus = $_REQUEST['savenewstatus'];
$saveeditstatus = $_REQUEST['saveeditstatus'];

if (isset($savenewstatus)) {
   SaveNewStatus();
}

if (isset($saveeditstatus)) {
   SaveEditStatus();
}

?>
<form action="status.php" method="post">
<input type="hidden" name="headline" value="17">
<input type="hidden" name="rstufe" value="<? echo "$rstufe"; ?>">
<input type="hidden" name="menu" value="<? echo "$menu"; ?>">
<input type="hidden" name="unum" value="<? echo "$unum"; ?>">
<button type="submit" name="newstatus" value="newstatus"><img src="image/button_newstatus.png" border=0 alt="Neuer Status"></button>
<?php
$db = OpenDB();
$query = "select ks_num, ks_status from key_status order by ks_num";
$result = QueryDB($db, $query);

if (!$result) {
   echo "</table></form><br>\n";
   Error("SQL-Error: $query");
   require('footer.inc');
   exit;
}

$numrows = numrowsDB($result);

if ($numrows > 0 || isset($newstatus)) {
?>
<table border=1>
   <tr>
      <td class="tbhead">&nbsp;</td>
      <td class="tbhead">Key</td>
      <td class="tbhead">Text</td>
   </tr>
<?php
   $row = 0;

   while ($row < $numrows) {
      $data = fetchDB($result, $row);
      $ks_num = $data[0];
      $ks_status = $data[1];

      if ($ks_num == $editstatus) {
         echo "<input type=\"hidden\" name=\"ks_num\" value=\"$ks_num\">\n";
         echo "<tr><td><button type=\"submit\" name=\"saveeditstatus\" value=\"$ks_num\"><img src=\"image/new.png\" border=0 alt=\"Edit\"></button></td>";
         echo "<td>$ks_num</td>";
         echo "<td><input type=\"text\" name=\"ks_status\" value=\"$ks_status\" size=40 maxlength=50></td></tr>\n";
      } else {
         echo "<tr><td><button type=\"submit\" name=\"editstatus\" value=\"$ks_num\"><img src=\"image/edit.png\" border=0 alt=\"Edit\"></button></td>";
         echo "<td>$ks_num</td><td>$ks_status</td></tr>";
      }

      $row++;
   }

   if (isset($newstatus)) {
      echo "<tr><td><button type=\"submit\" name=\"savenewstatus\" value=\"savenewstatus\"><img src=\"image/new.png\" border=0 alt=\"Neu\"></button></td>";
      echo "<td><input type=\"text\" name=\"ks_num\" size=7 maxlength=7></td>";
      echo "<td><input type=\"text\" name=\"ks_status\" size=40 maxlength=50></td></tr>\n";
   }
?>
</table>
<button type="submit" name="newstatus" value="new"><img src="image/button_newstatus.png" border=0 alt="Neuer Status"></button>
</form>
<?php
}

require('footer.inc');
?>