Subversion Repositories public

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 andreas 1
<?
2
require_once('version.inc');
3
require_once('dbaccess.inc');
4
require_once('language.inc');
5
require_once('header.inc');
6
require_once('crypt.inc');
7
require_once('settings.inc');
8
require_once('menu.inc');
9
 
10
function SaveNewAbt() {
11
	$ka_num = $_REQUEST['ka_num'];
12
	$ka_abt = $_REQUEST['ka_abt'];
13
 
14
	$db = OpenDB();
15
	$query = "select ka_abt from key_abt where ka_num = $ka_num";
16
	$result = QueryDB($db, $query);
17
	$numrows = numrowsDB($result);
18
 
19
	if ($numrows == 1) {
20
	   Error("Schl&uuml;ssel $ka_num ist bereits vorhanden!\n");
21
	   closeDB($db);
22
	   return false;
23
	}
24
 
25
	$query = "insert into key_abt (ka_num, ka_abt) values ($ka_num, '$ka_abt')";
26
 
27
	if (!TQueryDB($db, $query)) {
28
	   Error("SQL-Error: $query");
29
	   closeDB($db);
30
	   return false;
31
	}
32
 
33
	closeDB($db);
34
	return true;
35
}
36
 
37
function SaveEditAbt() {
38
	$ka_num = $_REQUEST['ka_num'];
39
	$ka_abt = $_REQUEST['ka_abt'];
40
 
41
	$db = OpenDB();
42
	$query = "select ka_abt from key_abt where ka_num = $ka_num";
43
	$result = QueryDB($db, $query);
44
	$numrows = numrowsDB($result);
45
 
46
	if ($numrows != 1) {
47
	   Error("Schl&uuml;ssel $ka_num ist nicht vorhanden!\n");
48
	   closeDB($db);
49
	   return false;
50
	}
51
 
52
	$query = "update key_abt set ka_abt = '$ka_abt' where ka_num = $ka_num";
53
 
54
	if (!TQueryDB($db, $query)) {
55
	   Error("SQL-Error: $query");
56
	   closeDB($db);
57
	   return false;
58
	}
59
 
60
	closeDB($db);
61
	return true;
62
}
63
 
64
$newabt = $_REQUEST['newabt'];
65
$editabt = $_REQUEST['editabt'];
66
 
67
if (!isset($editabt)) {
68
   $editabt = 0;
69
}
70
 
71
$savenewabt = $_REQUEST['savenewabt'];
72
$saveeditabt = $_REQUEST['saveeditabt'];
73
 
74
if (isset($savenewabt)) {
75
   SaveNewAbt();
76
}
77
 
78
if (isset($saveeditabt)) {
79
   SaveEditAbt();
80
}
81
 
82
?>
83
<form name="abt" action="abt.php" method="post">
84
<input type="hidden" name="headline" value="16">
85
<input type="hidden" name="rstufe" value="<? echo "$rstufe"; ?>">
86
<input type="hidden" name="menu" value="<? echo "$menu"; ?>">
87
<input type="hidden" name="unum" value="<? echo "$unum"; ?>">
88
<table class="indent"><tr><td>
89
<?
90
Button("Neue Abteilung", "abt");
91
//<button type="submit" name="newabt" value="newabt"><img src="image/button_newabt.png" border=0 alt="Neue Abteilung"></button>
92
?>
93
</td></tr></table>
94
<?php
95
$db = OpenDB();
96
$query = "select ka_num, ka_abt from key_abt order by ka_num";
97
$result = QueryDB($db, $query);
98
 
99
if (!$result) {
100
   echo "</table></form><br>\n";
101
   Error("SQL-Error: $query");
102
   require('footer.inc');
103
   exit;
104
}
105
 
106
$numrows = numrowsDB($result);
107
 
108
if ($numrows > 0 || isset($newabt)) {
109
?>
110
<table class="sel">
111
   <tr>
112
      <th class="sel">Aktion</th>
113
      <th class="sel">Key</th>
114
      <th class="sel">Text</th>
115
   </tr>
116
<?php
117
   $row = 0;
118
 
119
   while ($row < $numrows) {
120
      $data = fetchDB($result, $row);
121
      $ka_num = $data[0];
122
      $ka_abt = $data[1];
123
 
124
      if ($ka_num == $editabt) {
125
         echo "<input type=\"hidden\" name=\"ka_num\" value=\"$ka_num\">\n";
126
         echo "<tr><td class=\"selakt\"><button type=\"submit\" name=\"saveeditabt\" value=\"$ka_num\"><img src=\"image/new.png\" border=0 alt=\"Edit\"></button></td>";
127
         echo "<td class=\"selnum\">$ka_num</td>";
128
         echo "<td class=\"sel\"><input type=\"text\" class=\"inputmust\" name=\"ka_abt\" value=\"$ka_abt\" size=40 maxlength=50></td></tr>\n";
129
      } else {
130
         echo "<tr><td class=\"sel\"><button type=\"submit\" name=\"editabt\" value=\"$ka_num\"><img src=\"image/edit.png\" border=0 alt=\"Edit\"></button></td>";
131
         echo "<td class=\"selnum\">$ka_num</td><td class=\"sel\">$ka_abt</td></tr>";
132
      }
133
 
134
      $row++;
135
   }
136
 
137
   if (isset($newabt)) {
138
      echo "<tr><td class=\"sel\"><button type=\"submit\" name=\"savenewabt\" value=\"savenewabt\"><img src=\"image/new.png\" border=0 alt=\"Neu\"></button></td>";
139
      echo "<td class=\"sel\"><input type=\"text\" class=\"inputmust\" name=\"ka_num\" size=7 maxlength=7></td>";
140
      echo "<td class=\"sel\"><input type=\"text\" class=\"inputmust\" name=\"ka_abt\" size=40 maxlength=50></td></tr>\n";
141
   }
142
?>
143
</table>
144
<table class="indent"><tr><td>
145
<?
146
   Button("Neue Abteilung", "abt");
147
//<button type="submit" name="newabt" value="new"><img src="image/button_newabt.png" border=0 alt="Neue Abteilung"></button>
148
?>
149
</td></tr></table>
150
</form>
151
<?php
152
}
153
 
154
require('footer.inc');
155
?>