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 SaveNewPhase() {
11
	$kp_num = $_REQUEST['kp_num'];
12
	$kp_phase = $_REQUEST['kp_phase'];
13
 
14
	$db = OpenDB();
15
	$query = "select kp_phase from key_phase where kp_num = $kp_num";
16
	$result = QueryDB($db, $query);
17
	$numrows = numrowsDB($result);
18
 
19
	if ($numrows == 1) {
20
	   Error("Schl&uuml;ssel $kp_num ist bereits vorhanden!\n");
21
	   closeDB($db);
22
	   return false;
23
	}
24
 
25
	$query = "insert into key_phase (kp_num, kp_phase) values ($kp_num, '$kp_phase')";
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 SaveEditPhase() {
38
	$kp_num = $_REQUEST['kp_num'];
39
	$kp_phase = $_REQUEST['kp_phase'];
40
 
41
	$db = OpenDB();
42
	$query = "select kp_phase from key_phase where kp_num = $kp_num";
43
	$result = QueryDB($db, $query);
44
	$numrows = numrowsDB($result);
45
 
46
	if ($numrows != 1) {
47
	   Error("Schl&uuml;ssel $kp_num ist nicht vorhanden!\n");
48
	   closeDB($db);
49
	   return false;
50
	}
51
 
52
	$query = "update key_phase set kp_phase = '$kp_phase' where kp_num = $kp_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
$newphase = $_REQUEST['newphase'];
65
$editphase = $_REQUEST['editphase'];
66
 
67
if (!isset($editphase)) {
68
   $editphase = 0;
69
}
70
 
71
$savenewphase = $_REQUEST['savenewphase'];
72
$saveeditphase = $_REQUEST['saveeditphase'];
73
 
74
if (isset($savenewphase)) {
75
   SaveNewPhase();
76
}
77
 
78
if (isset($saveeditphase)) {
79
   SaveEditPhase();
80
}
81
 
82
?>
83
<form action="phase.php" method="post">
84
<input type="hidden" name="headline" value="15">
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
<button type="submit" name="newphase" value="newphase"><img src="image/button_newphase.png" border=0 alt="Neue Phase"></button>
89
<?php
90
$db = OpenDB();
91
$query = "select kp_num, kp_phase from key_phase order by kp_num";
92
$result = QueryDB($db, $query);
93
 
94
if (!$result) {
95
   echo "</table></form><br>\n";
96
   Error("SQL-Error: $query");
97
   require('footer.inc');
98
   exit;
99
}
100
 
101
$numrows = numrowsDB($result);
102
 
103
if ($numrows > 0 || isset($newphase)) {
104
?>
105
<table border=1>
106
   <tr>
107
      <td class="tbhead">&nbsp;</td>
108
      <td class="tbhead">Key</td>
109
      <td class="tbhead">Text</td>
110
   </tr>
111
<?php
112
   $row = 0;
113
 
114
   while ($row < $numrows) {
115
      $data = fetchDB($result, $row);
116
      $kp_num = $data[0];
117
      $kp_phase = $data[1];
118
 
119
      if ($kp_num == $editphase) {
120
         echo "<input type=\"hidden\" name=\"kp_num\" value=\"$kp_num\">\n";
121
         echo "<tr><td><button type=\"submit\" name=\"saveeditphase\" value=\"$kp_num\"><img src=\"image/new.png\" border=0 alt=\"Edit\"></button></td>";
122
         echo "<td>$kp_num</td>";
123
         echo "<td><input type=\"text\" name=\"kp_phase\" value=\"$kp_phase\" size=40 maxlength=60></td></tr>\n";
124
      } else {
125
         echo "<tr><td><button type=\"submit\" name=\"editphase\" value=\"$kp_num\"><img src=\"image/edit.png\" border=0 alt=\"Edit\"></button></td>";
126
         echo "<td>$kp_num</td><td>$kp_phase</td></tr>";
127
      }
128
 
129
      $row++;
130
   }
131
 
132
   if (isset($newphase)) {
133
      echo "<tr><td><button type=\"submit\" name=\"savenewphase\" value=\"savenewphase\"><img src=\"image/new.png\" border=0 alt=\"Neu\"></button></td>";
134
      echo "<td><input type=\"text\" name=\"kp_num\" size=7 maxlength=7></td>";
135
      echo "<td><input type=\"text\" name=\"kp_phase\" size=40 maxlength=60></td></tr>\n";
136
   }
137
?>
138
</table>
139
<button type="submit" name="newphase" value="new"><img src="image/button_newphase.png" border=0 alt="Neue Phase"></button>
140
</form>
141
<?php
142
}
143
 
144
require('footer.inc');
145
?>