<?php
# $Id: search.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>
<b><?php echo "$search $entries:";?></b><p>
<table border=0 cellpadding=4 cellspacing=1>
<tr valign=bottom><td>
<table bgcolor="#EEEEEE">
<?php echo "$entrytext:";?>
<tr>
<td valign=top> </td></tr>
<tr>
<form method="post" action=<?php $PHP_SELF;?>>
<td valign=bottom><input type=text name=suchtext></td>
<td valign=bottom><input type=submit class=button_click name=textsearch value="<?php echo $search;?>"></td>
</form>
</tr></table>
</td><td>
<table bgcolor=#EEEEEE>
<?php echo "$date:";?>
<tr>
<form method="post" action=<?php $PHP_SELF;?>>
<td valign=top>Start:
<?php if ($_POST[starttag])
echo "<input type=text name=\"starttag\" size=\"2\" maxlenght=\"2\" value=$_POST[starttag]>";
else
echo "<input type=text name=\"starttag\" size=\"2\" maxlenght=\"2\">";?>
</td><td valign=top>
<select size=1 name="startmonat" required=yes>
<?php foreach (range(1,12) as $month)
{
if ($_POST[startmonat] == $month)
echo "<option selected value=$month>$month</option>";
elseif ($month == $activemonth)
echo "<option selected value=$month>$month</option>";
else
echo "<option value=$month>$month</option>";
}?>
</select>
</td><td valign=top>
</td></tr><tr>
<td valign=top>End:
<?php if ($_POST[endtag])
echo "<input type=text name=\"endtag\" size=\"2\" maxlenght=\"2\" value=$_POST[endtag]>";
else
echo "<input type=text name=\"endtag\" size=\"2\" maxlenght=\"2\">"; ?>
</td><td valign=top>
<select size=1 name="endmonat" required=yes>
<?php foreach (range(1,12) as $month)
{
if ($_POST[endmonat] == $month)
echo "<option selected value=$month>$month</option>";
elseif ($month == $activemonth)
echo "<option selected value=$month>$month</option>";
else
echo "<option value=$month>$month</option>";
}?>
</select>
</td><td valign=top>
<select size=1 name="jahr">
<?php if ($_POST[jahr])
echo "<option selected value=$_POST[jahr]>$_POST[jahr]</option>";
else {
echo "<option value=$activeyear>$activeyear</option>";
echo "<option value=" . ($activeyear-1) . ">" . ($activeyear-1) . "</option>";
}?>
</select>
<input type=submit class=button_click name=datesearch value="<?php echo $search;?>"></td>
</form>
</tr></table>
</td><td>
<table bgcolor="#EEEEEE">
<?php echo "$amount:";?>
<tr>
<td valign=top> </td></tr>
<tr>
<form method="post" action=<?php $PHP_SELF;?>>
<td valign=top><?php echo $currency;?> <input type=text size=6 name=betrag></td>
<td valign=top><input type=submit class=button_click name=amountsearch value="<?php echo $search;?>"></td>
</form>
</tr></table>
</td><td>
</td></tr></table>
<?php if (isset($_POST[textsearch])) {
if ($_POST['suchtext'] == '') {
echo "<font color=red>$searchfield $may_not_empty";
} else {
echo "$search <i>" . $_POST['suchtext'] . "</i>";
$result = mysql_query("SELECT $queryentriesjoin WHERE text LIKE '%" . $_POST['suchtext'] . "%' AND username='$activeuser' ORDER BY jahr,monat,tag ASC");
echo "<table><tr><td>";
tabelleVerbuchungen($result);
echo "</td></tr>";
# echo "<tr><td valign=top align=right>";
# eintragEditieren();
}
} elseif (isset($_POST[datesearch])) {
if ($_POST['starttag'] == '' || $_POST['endtag'] == '') {
echo "<font color=red>$day $may_not_empty";
} else {
echo "$search $date $from <i>" . $_POST['starttag'] . "." . $_POST['startmonat'] . "." . $_POST['jahr'] . " $to " . $_POST['endtag'] . "." . $_POST['endmonat'] . "." . $_POST['jahr'] . "</i>";
$result = mysql_query("SELECT $queryentriesjoin WHERE tag >= $_POST[starttag] AND tag <= $_POST[endtag] AND monat >= $_POST[startmonat] AND monat <= $_POST[endmonat] AND jahr = $_POST[jahr] AND username='$activeuser' ORDER BY jahr,monat,tag ASC");
echo "<table><tr><td>";
tabelleVerbuchungen($result);
echo "</td></tr>";
# echo "<tr><td valign=top align=right>";
# eintragEditieren();
}
} elseif (isset($_POST[amountsearch])) {
if ($_POST['betrag'] == '') {
echo "<font color=red>$amount $may_not_empty";
} else {
echo "$search $amount $currency <i>" . $_POST['betrag'] . "</i>";
$result = mysql_query("SELECT $queryentriesjoin WHERE betrag='$_POST[betrag]' AND username='$activeuser' ORDER BY jahr,monat,tag ASC");
tabelleVerbuchungen($result);
echo "</td></tr>";
# echo "<tr><td valign=top align=right>";
# eintragEditieren();
}
}?>
</td></tr>
</table>
</td>
</table>
</div>
</body>
</html>