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 SaveNewCostloc() {
11
	$kc_num = $_REQUEST['kc_num'];
12
	$kc_costloc = $_REQUEST['kc_costloc'];
13
 
14
	if (!isset($kc_num) || $kc_num <= 0) {
15
	   Error("SaveEditCostloc: Interner Fehler: Keine ID-Nummer!");
16
	   return false;
17
	}
18
 
19
	if (!isset($kc_costloc) || strlen($kc_costloc) == 0) {
20
	   Error("Es muss ein Text eingegeben werden! Leere Eingabezeile wurde nicht gespeichert.");
21
	   return false;
22
	}
23
 
24
	$db = OpenDB();
25
	$query = "select kc_costloc from key_costloc where kc_num = $kc_num";
26
	$result = QueryDB($db, $query);
27
	$numrows = numrowsDB($result);
28
 
29
	if ($numrows == 1) {
30
	   Error("Schl&uuml;ssel $kc_num ist bereits vorhanden!\n");
31
	   closeDB($db);
32
	   return false;
33
	}
34
 
35
	$query = "insert into key_costloc (kc_num, kc_costloc) values ($kc_num, '$kc_costloc')";
36
 
37
	if (!TQueryDB($db, $query)) {
38
	   Error("SQL-Error: $query");
39
	   closeDB($db);
40
	   return false;
41
	}
42
 
43
	closeDB($db);
44
	return true;
45
}
46
 
47
function SaveEditCostloc() {
48
	$kc_num = $_REQUEST['kc_num'];
49
	$kc_costloc = $_REQUEST['kc_costloc'];
50
 
51
	if (!isset($kc_num) || $kc_num <= 0) {
52
	   Error("SaveEditCostloc: Interner Fehler: Keine ID-Nummer!");
53
	   return false;
54
	}
55
 
56
	if (!isset($kc_costloc) || strlen($kc_costloc) == 0) {
57
	   Error("Es muss ein Text eingegeben werden! Leere Eingabezeile wurde nicht gespeichert.");
58
	   return false;
59
	}
60
 
61
	$db = OpenDB();
62
	$query = "select kc_costloc from key_costloc where kc_num = $kc_num";
63
	$result = QueryDB($db, $query);
64
	$numrows = numrowsDB($result);
65
 
66
	if ($numrows != 1) {
67
	   Error("Schl&uuml;ssel $kc_num ist nicht vorhanden!\n");
68
	   closeDB($db);
69
	   return false;
70
	}
71
 
72
	$query = "update key_costloc set kc_costloc = '$kc_costloc' where kc_num = $kc_num";
73
 
74
	if (!TQueryDB($db, $query)) {
75
	   Error("SQL-Error: $query");
76
	   closeDB($db);
77
	   return false;
78
	}
79
 
80
	closeDB($db);
81
	return true;
82
}
83
 
84
$newcostloc = $_REQUEST['newcostloc'];
85
$editcostloc = $_REQUEST['editcostloc'];
86
 
87
if (!isset($editcostloc)) {
88
   $editcostloc = 0;
89
}
90
 
91
$savenewcostloc = $_REQUEST['savenewcostloc'];
92
$saveeditcostloc = $_REQUEST['saveeditcostloc'];
93
 
94
if (isset($savenewcostloc)) {
95
   SaveNewCostloc();
96
}
97
 
98
if (isset($saveeditcostloc)) {
99
   SaveEditCostloc();
100
}
101
 
102
?>
103
<form name="costloc" action="costloc.php" method="post">
104
<input type="hidden" name="headline" value="36">
105
<input type="hidden" name="rstufe" value="<? echo "$rstufe"; ?>">
106
<input type="hidden" name="menu" value="<? echo "$menu"; ?>">
107
<input type="hidden" name="unum" value="<? echo "$unum"; ?>">
108
<input type="hidden" name="newcostloc" value="">
109
<table class="indent"><tr><td>
110
<?php
111
Button("Neue Kostenstelle", "costloc", "newcostloc", "1");
112
echo "</td></tr></table>\n";
113
$db = OpenDB();
114
$query = "select kc_num, kc_costloc from key_costloc order by kc_num";
115
$result = QueryDB($db, $query);
116
 
117
if (!$result) {
118
   echo "</table></form><br>\n";
119
   require('footer.inc');
120
   exit;
121
}
122
 
123
$numrows = numrowsDB($result);
124
 
125
if ($numrows > 0 || isset($newcostloc)) {
126
?>
127
<table class="sel">
128
   <tr>
129
      <th class="sel">&nbsp;</th>
130
      <th class="sel">Key</th>
131
      <th class="sel">Text</th>
132
   </tr>
133
<?php
134
   $row = 0;
135
 
136
   while ($row < $numrows) {
137
      $data = fetchDB($result, $row);
138
      $kc_num = $data[0];
139
      $kc_costloc = $data[1];
140
 
141
      if ($kc_num == $editcostloc) {
142
         echo "<input type=\"hidden\" name=\"kc_num\" value=\"$kc_num\">\n";
143
	 echo "<input type=\"hidden\" name=\"saveeditcostloc\" value=\"$kc_num\">\n";
144
	 echo "<tr><td class=\"selakt\">";
145
         ButtonImage("new.png", "costloc", "Neu");
146
         echo "</td><td class=\"sel\">$kc_num</td>";
147
         echo "<td class=\"sel\"><input type=\"text\" name=\"kc_costloc\" value=\"$kc_costloc\" size=40 maxlength=50></td></tr>\n";
148
      } else {
149
	 echo "<tr><td class=\"selakt\">";
150
         ButtonImageMove("edit.png", "costloc", "costloc.php", "editcostloc=$kc_num&menu=$menu&headline=36");
151
         echo "</td><td class=\"sel\">$kc_num</td><td class=\"sel\">$kc_costloc</td></tr>";
152
      }
153
 
154
      $row++;
155
   }
156
 
157
   if (isset($newcostloc)) {
158
      echo "<input type=\"hidden\" name=\"savenewcostloc\" value=\"savenewcostloc\">\n";
159
      echo "<tr><td class=\"selakt\">";
160
      ButtonImage("new.png", "costloc", "Speichern");
161
      echo "</td><td class=\"inputmust\"><input type=\"text\" name=\"kc_num\" size=7 maxlength=7></td>";
162
      echo "<td class=\"sel\"><input type=\"text\" name=\"kc_costloc\" size=40 maxlength=50></td></tr>\n";
163
   }
164
 
165
   echo "<table class=\"indent\"><tr><td>";
166
   Button("Neue Kostenstelle", "costloc", "newcostloc", "1");
167
   echo "</td></tr></table>\n";
168
?>
169
</table>
170
</form>
171
<?php
172
}
173
 
174
require('footer.inc');
175
?>
176