0,0 → 1,176 |
<? |
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 SaveNewCostloc() { |
$kc_num = $_REQUEST['kc_num']; |
$kc_costloc = $_REQUEST['kc_costloc']; |
|
if (!isset($kc_num) || $kc_num <= 0) { |
Error("SaveEditCostloc: Interner Fehler: Keine ID-Nummer!"); |
return false; |
} |
|
if (!isset($kc_costloc) || strlen($kc_costloc) == 0) { |
Error("Es muss ein Text eingegeben werden! Leere Eingabezeile wurde nicht gespeichert."); |
return false; |
} |
|
$db = OpenDB(); |
$query = "select kc_costloc from key_costloc where kc_num = $kc_num"; |
$result = QueryDB($db, $query); |
$numrows = numrowsDB($result); |
|
if ($numrows == 1) { |
Error("Schlüssel $kc_num ist bereits vorhanden!\n"); |
closeDB($db); |
return false; |
} |
|
$query = "insert into key_costloc (kc_num, kc_costloc) values ($kc_num, '$kc_costloc')"; |
|
if (!TQueryDB($db, $query)) { |
Error("SQL-Error: $query"); |
closeDB($db); |
return false; |
} |
|
closeDB($db); |
return true; |
} |
|
function SaveEditCostloc() { |
$kc_num = $_REQUEST['kc_num']; |
$kc_costloc = $_REQUEST['kc_costloc']; |
|
if (!isset($kc_num) || $kc_num <= 0) { |
Error("SaveEditCostloc: Interner Fehler: Keine ID-Nummer!"); |
return false; |
} |
|
if (!isset($kc_costloc) || strlen($kc_costloc) == 0) { |
Error("Es muss ein Text eingegeben werden! Leere Eingabezeile wurde nicht gespeichert."); |
return false; |
} |
|
$db = OpenDB(); |
$query = "select kc_costloc from key_costloc where kc_num = $kc_num"; |
$result = QueryDB($db, $query); |
$numrows = numrowsDB($result); |
|
if ($numrows != 1) { |
Error("Schlüssel $kc_num ist nicht vorhanden!\n"); |
closeDB($db); |
return false; |
} |
|
$query = "update key_costloc set kc_costloc = '$kc_costloc' where kc_num = $kc_num"; |
|
if (!TQueryDB($db, $query)) { |
Error("SQL-Error: $query"); |
closeDB($db); |
return false; |
} |
|
closeDB($db); |
return true; |
} |
|
$newcostloc = $_REQUEST['newcostloc']; |
$editcostloc = $_REQUEST['editcostloc']; |
|
if (!isset($editcostloc)) { |
$editcostloc = 0; |
} |
|
$savenewcostloc = $_REQUEST['savenewcostloc']; |
$saveeditcostloc = $_REQUEST['saveeditcostloc']; |
|
if (isset($savenewcostloc)) { |
SaveNewCostloc(); |
} |
|
if (isset($saveeditcostloc)) { |
SaveEditCostloc(); |
} |
|
?> |
<form name="costloc" action="costloc.php" method="post"> |
<input type="hidden" name="headline" value="36"> |
<input type="hidden" name="rstufe" value="<? echo "$rstufe"; ?>"> |
<input type="hidden" name="menu" value="<? echo "$menu"; ?>"> |
<input type="hidden" name="unum" value="<? echo "$unum"; ?>"> |
<input type="hidden" name="newcostloc" value=""> |
<table class="indent"><tr><td> |
<?php |
Button("Neue Kostenstelle", "costloc", "newcostloc", "1"); |
echo "</td></tr></table>\n"; |
$db = OpenDB(); |
$query = "select kc_num, kc_costloc from key_costloc order by kc_num"; |
$result = QueryDB($db, $query); |
|
if (!$result) { |
echo "</table></form><br>\n"; |
require('footer.inc'); |
exit; |
} |
|
$numrows = numrowsDB($result); |
|
if ($numrows > 0 || isset($newcostloc)) { |
?> |
<table class="sel"> |
<tr> |
<th class="sel"> </th> |
<th class="sel">Key</th> |
<th class="sel">Text</th> |
</tr> |
<?php |
$row = 0; |
|
while ($row < $numrows) { |
$data = fetchDB($result, $row); |
$kc_num = $data[0]; |
$kc_costloc = $data[1]; |
|
if ($kc_num == $editcostloc) { |
echo "<input type=\"hidden\" name=\"kc_num\" value=\"$kc_num\">\n"; |
echo "<input type=\"hidden\" name=\"saveeditcostloc\" value=\"$kc_num\">\n"; |
echo "<tr><td class=\"selakt\">"; |
ButtonImage("new.png", "costloc", "Neu"); |
echo "</td><td class=\"sel\">$kc_num</td>"; |
echo "<td class=\"sel\"><input type=\"text\" name=\"kc_costloc\" value=\"$kc_costloc\" size=40 maxlength=50></td></tr>\n"; |
} else { |
echo "<tr><td class=\"selakt\">"; |
ButtonImageMove("edit.png", "costloc", "costloc.php", "editcostloc=$kc_num&menu=$menu&headline=36"); |
echo "</td><td class=\"sel\">$kc_num</td><td class=\"sel\">$kc_costloc</td></tr>"; |
} |
|
$row++; |
} |
|
if (isset($newcostloc)) { |
echo "<input type=\"hidden\" name=\"savenewcostloc\" value=\"savenewcostloc\">\n"; |
echo "<tr><td class=\"selakt\">"; |
ButtonImage("new.png", "costloc", "Speichern"); |
echo "</td><td class=\"inputmust\"><input type=\"text\" name=\"kc_num\" size=7 maxlength=7></td>"; |
echo "<td class=\"sel\"><input type=\"text\" name=\"kc_costloc\" size=40 maxlength=50></td></tr>\n"; |
} |
|
echo "<table class=\"indent\"><tr><td>"; |
Button("Neue Kostenstelle", "costloc", "newcostloc", "1"); |
echo "</td></tr></table>\n"; |
?> |
</table> |
</form> |
<?php |
} |
|
require('footer.inc'); |
?> |
|