<?php
# $Id: modifyentry.php 86 2010-10-05 12:19:27Z rediculum $
#
# Includes
####################################################################
include("includes/session.inc.php");
include("includes/layout.inc.php");
include("includes/functions.inc.php");
include("includes/db.inc.php");
include("includes/variables.inc.php");
# Main
#####################################################################?>
<html>
<head>
<?php echo "$headtitle $head";?>
</head>
<body>
<div id=menu>
<?php include("includes/menu.inc.php");?>
</div>
<div id=mainframe>
<table bgcolor="#FFFFFF">
<tr><td valign=top align=left width=500>
<?
if ($_POST[id] == "") {
echo "<font color=red>$ERROR: $number $missing";
exit(1);
}
if (isset($_POST[delete])) {
echo "$entrynumber <i>$_POST[id] </i>$deleted";
mysql_query("DELETE FROM $_POST[table] WHERE id='$_POST[id]'") or die (mysql_error());
exit(0);
}
if (isset($_POST[modifyentry])) {
$textbutton = "$entry $edit";
$targetfile = "modify.php";
}
if (isset($_POST[copy])) {
$textbutton = "$entry $copy";
$targetfile = "copy.php";
}
echo "$entrynumber <i>$_POST[id]</i>:";?>
<table border=0 cellpadding=4 cellspacing=1>
<tr align=center bgcolor="#EEEEEE">
<?
print("<td><b>$day</td>
<td><b>$month</td>
<td><b>$year</td>
<td><b>$entrytext</td>
<td><b>$amount</td>
<td><b>$source</td>
<td><b>$maincategory</td>
<td><b>$subcategory</td>
<td><b>$shared_s</td>
");
?>
</tr><tr>
<td valign=top>
<?
$result = mysql_query("SELECT * FROM $_POST[table] WHERE id='$_POST[id]'");
while ($output=mysql_fetch_array($result)) {
echo "<form method=post action=$targetfile>";
if ($_POST[table] == verbuchungen) {
echo "<select size=1 name=\"tag\">";
foreach (range(1,31) as $day) {
if ($day == $output[1]) {
echo "<option selected value=$output[1]>$day</option>";
} else {
echo "<option value=$day>$day</option>";
}
}
echo "</select>";
} else {
echo "<input type=text name=\"tag\" size=3 maxlenght=2 value=$output[1]>";
}?>
</td><td valign=top>
<?php if ($_POST[table] == verbuchungen) {
echo "<select size=1 name=\"monat\" required=yes>";
foreach (range(1,12) as $month) {
if ($month == $output[2]) {
echo "<option selected value=$output[2]>$month</option>";
} else {
echo "<option value=$month>$month</option>";
}
}
echo "</select>";
} else {
echo "<input type=text name=\"monat\" size=3 maxlenght=2 value=$output[2]>";
}?>
</td><td valign=top>
<?php if ($_POST[table] == verbuchungen) {
echo "<select size=1 name=\"jahr\">";
echo "<option value=" . ($output[3]-1) . ">" . ($output[3]-1) . "</option>";
echo "<option selected value=$output[3]>$output[3]</option>";
echo "<option value=" . ($output[3]+1) . ">" . ($output[3]+1) . "</option>";
echo "</select>";
} else {
echo "<input type=text name=\"jahr\"size=3 maxlenght=2 value=$output[3]>";
}
echo "</td><td valign=top>";
echo "<input type=text name=\"text\" value=\"$output[10]\">";
echo "</td><td valign=top>";
echo "$currency <input type=text name=\"betrag\" size=\"6\" maxlenght=\"6\" value=\"$output[4]\">";
echo "</td><td valign=top>";
echo "<select size=1 name=\"q_id\">";
$result2= mysql_query("SELECT q_id,q_name FROM quelle") or die (mysql_error());
while ($resultarr = mysql_fetch_array($result2)) {
if ($resultarr[0] == $output[5]) {
echo ("<option selected value=$output[5]>$resultarr[1]</option>");
} else {
echo ("<option value=$resultarr[0]>$resultarr[1]</option>");
}
}
echo "</select>";
echo "</td><td valign=top>";
echo "<select size=1 name=\"hk_id\">";
$result2= mysql_fetch_row(mysql_query("SELECT hk_id,hk_name FROM hauptkategorien WHERE hk_id='$output[6]'")) or die (mysql_error());
echo ("<option selected value=$output[6]>$result2[1]</option>");
echo "</select>";
echo "</td><td valign=top>";
echo "<select size=1 name=\"sk_id\">";
$result2 = mysql_query("SELECT sk_id,sk_name FROM subkategorien WHERE hk_id='$output[6]' ORDER BY sk_id") or die (mysql_error());
while ($resultarr = mysql_fetch_array($result2)) {
if ($resultarr[0] == $output[7]) {
echo ("<option selected value=$output[7]>$resultarr[1]</option>");
} else {
echo ("<option value=$resultarr[0]>$resultarr[1]</option>");
}
}
echo "</select>";
echo "</td><td valign=top>";
if ($output[9] == "1") {
echo "<input type=checkbox checked name=\"shared\" value=\"1\">";
} else {
echo "<input type=checkbox name=\"shared\" value=\"1\">";
}?>
</td></tr>
<tr><td>
</td>
<td>
</td>
<td>
</td>
<td align=center>
<input type=hidden name=id value=<?php echo $output[0];?>>
<input type=hidden name=table value=<?php echo $_POST[table];?>>
<input type=submit name=submit class=button_click value="<?php echo $textbutton;?>">
</td></tr>
</table>
<p>
</form>
<?}?>
</td></tr>
</table>
</div>
</body>
</html>