#include <infocon.style>
+#include <phptools.inc>
#include "account.inc"
-<page func=InfoCon title="Kontoführung">
-
-<h3 class=bar align=center><font face="Helvetica,Arial"> - <?
- $both = explode (":", $blzkto);
- printf ("BLZ %s, Konto %s", $both[0], $both[1]);
-?> - </font></h3>
-
-<table class=font width=100% border=0 cellpadding=2 cellspacing=0>
-<tr bgcolor=#<colh>>
- <th width=10%><font face="Helvetica,Arial">Datum</font></th>
- <th width=10%><font face="Helvetica,Arial">Kategorie</font></th>
- <th width=70%><font face="Helvetica,Arial">Verwendungszweck</font></th>
- <th width=10%><font face="Helvetica,Arial">Betrag</font></th>
-</tr>
-<?
- pg_exec ($dbh, "SET DateStyle = 'ISO'") or die("Datenbank-Abfrage!");
-
+<?php
+function filter_account()
+{
+ global $db;
+ $out = '';
$table = "account";
$value = "value_eur";
$add = '';
- if ((strlen ($currency) > 0) && ($currency == "dm")) {
+ if ((strlen($_POST['currency']) > 0) && ($_POST['currency'] == "dm")) {
$table = "account_dm";
$value = "value_dm";
$add = "&cur=dm";
}
- $where[] = "blz_kto = '$blzkto'";
- if (strlen($year)) {
- $where[] = sprintf ("datum >= '%04d-01-01'", $year);
+ $where[] = sprintf("blz_kto = '%s'", $_POST['blzkto']);
+ if (strlen($_POST['year'])) {
+ $where[] = sprintf ("datum >= '%04d-01-01'", $_POST['year']);
$year++;
- $where[] = sprintf ("datum < '%04d-01-01'", $year);
+ $where[] = sprintf ("datum < '%04d-01-01'", $_POST['year']+1);
}
- if (strlen($statement)) {
- $where[] = "statement = '$statement'";
+
+ if (strlen($_POST['deadline']) && strlen(trim($_POST['deadline']))) {
+ $date = form_to_yyyymmdd ($_POST['deadline']);
+ $where[] = sprintf ("datum < '%s'", $date);
}
- if (strlen($category)) {
- $where[] = "category = '$category'";
+
+ if (strlen($_POST['statement']) && strlen(trim($_POST['statement']))) {
+ $where[] = sprintf("statement = '%s'", $_POST['statement']);
}
- if (strlen($keyword)) {
- $where[] = "descr ~* '$keyword'";
+
+ if (strlen($_POST['category']) && strlen(trim($_POST['category']))) {
+ if (!empty($_POST['ajax'])) $_POST['category'] = utf8_decode($_POST['category']);
+ $where[] = sprintf("category = '%s'", $_POST['category']);
}
- if (strlen($from_to)) {
- $where[] = "from_to = '$from_to'";
+
+ if (strlen($_POST['keyword']) && strlen(trim($_POST['keyword']))) {
+ if (!empty($_POST['ajax'])) $_POST['keyword'] = utf8_decode($_POST['keyword']);
+ $where[] = sprintf("descr ~* '%s'", $_POST['keyword']);
}
- if ($input && !$output) {
+
+ if (strlen($_POST['from_to']) && strlen(trim($_POST['from_to']))) {
+ if (!empty($_POST['ajax'])) $_POST['from_to'] = utf8_decode($_POST['from_to']);
+ $where[] = sprintf("from_to = '%s'", $_POST['from_to']);
+ }
+
+ if ($_POST['input'] && !$_POST['output']) {
$where[] = "$value > 0.0";
- } elseif ($output && !$input) {
+ } elseif ($_POST['output'] && !$_POST['input']) {
$where[] = "$value < 0.0";
}
- $query = "SELECT datum,oid,category,descr,$value FROM $table WHERE "
+ $query = "SELECT datum,id,category,descr,$value FROM $table WHERE "
. implode ($where, " AND ")
- . " ORDER BY datum,oid";
- $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
+ . " ORDER BY datum,id";
$sum = 0.0;
$sum_in = 0.0;
$sum_out = 0.0;
- $color = "<cold>";
- for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
- $row = pg_fetch_array ($sth, $nr);
- $color = $color=="<cold>"?"<coln>":"<cold>";
-
- $descr = explode ("
-", $row['descr']);
+ $color = 0;
+ foreach ($db->fetchAssocList($query) as $row) {
+ $descr = explode ("\n", $row['descr']);
$date = explode (" ", $row['datum']);
$date = explode ("-", $date[0]);
$date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);
- printf ("<tr bgcolor=\"#%s\">", $color);
- printf ("<td width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%s</font></td>", $date);
- printf ("<td width=\"10%%\" align=\"center\"><font face=\"Helvetica,Arial\">%s</font></td>", $row['category']);
- printf ("<td width=\"70%%\"><font face=\"Helvetica,Arial\"><a href=\"edit.php3?oid=%d%s\">%s</a></font></td>",
- $row['oid'], $add, $descr[0]);
- printf ("<td width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%5.2f</font></td>", $row[$value]);
+ $out .= sprintf ("<tr class=\"t%d\">", $color);
+ $out .= sprintf ("<td width=\"10%%\" align=\"right\">%s</td>", $date);
+ $out .= sprintf ("<td width=\"10%%\" align=\"center\">%s</td>", $row['category']);
+ $out .= sprintf ("<td width=\"70%%\"><a href=\"edit.php?id=%d%s\" target=\"_new\">%s</a></td>",
+ $row['id'], $add, $descr[0]);
+ $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\">%5.2f</td>",
+ $row[$value]>0?"in":"out", $row[$value]);
$sum += $row[$value];
if ($row[$value] > 0) {
$sum_in += $row[$value];
} else {
$sum_out += $row[$value];
}
- echo ("</tr>");
+ $out .= "</tr>";
+ $color = !$color;
}
- $color = $color=="<cold>"?"<coln>":"<cold>";
- printf ("<tr bgcolor=\"#%s\">", $color);
- echo ("<th width=\"90%\" colspan=\"3\"><font face=\"Helvetica,Arial\">Summe</font></th>");
- printf ("<th width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%5.2f</font></th>", $sum);
- echo ("</tr>");
- if (strlen($statement)) {
- $color = $color=="<cold>"?"<coln>":"<cold>";
- printf ("<tr bgcolor=\"#%s\">", $color);
- echo ("<th width=\"90%\" colspan=\"3\"><font face=\"Helvetica,Arial\">Summe Einnahmen</font></th>");
- printf ("<th width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%5.2f</font></th>", $sum_in);
- echo ("</tr>");
- $color = $color=="<cold>"?"<coln>":"<cold>";
- printf ("<tr bgcolor=\"#%s\">", $color);
- echo ("<th width=\"90%\" colspan=\"3\"><font face=\"Helvetica,Arial\">Summe Ausgaben</font></th>");
- printf ("<th width=\"10%%\" align=\"right\"><font face=\"Helvetica,Arial\">%5.2f</font></th>", $sum_out*-1);
- echo ("</tr>");
- }
+ if (strlen($_POST['statement'])) {
+ $out .= sprintf ("<tr class=\"t%d\">", $color);
+ $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Einnahmen</strong></td>";
+ $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"in\">%5.2f</td>",$sum_in);
+ $out .= "</tr>";
+ $out .= sprintf ("<tr class=\"t%d\">", $color);
+ $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Ausgaben</strong></td>";
+ $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"out\">%5.2f</td>", $sum_out*-1);
+ $out .= "</tr>";
+ }
+ $out .= sprintf ("<tr class=\"t%d\">", $color);
+ $out .= "<td width=\"90%\" colspan=\"3\" align=\"left\"><strong>Summe</strong></td>";
+ $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\"><strong>%5.2f</strong></td>",
+ $sum>0?"in":"out", $sum);
+ $out .= "</tr>";
+
+ return $out;
+}
+
+if (!empty($_POST['ajax']) && $_POST['ajax'] == 1) {
+ echo utf8_encode(filter_account());
+ exit;
+}
?>
+
+<page func=InfoCon title="Kontoführung">
+
+<calendar_init -5>
+<account_heading>
+<form_to_yyyymmdd>
+
+<style type="text/css">
+div#filter_popup {
+ background: white;
+ border: 1px solid #CCC;
+ height:auto;
+ width:340px;
+ position:absolute;
+}
+div#filter_title {
+ width: 100%;
+ cursor: move;
+ background: #EEE;
+ margin-bottom: 5px;
+ font-weight: bold;
+}
+</style>
+<table class="border smallfont" width=100% border=0 cellpadding=0 cellspacing=1>
+<thead>
+<tr class=head>
+ <th width=10%>Datum</th>
+ <th width=10%>Kategorie</th>
+ <th width=70%>Verwendungszweck</th>
+ <th width=10%>Betrag</th>
+</tr>
+</thead>
+<tbody>
+<?=(count($_GET)?'':filter_account())?>
+</tbody>
</table><p>
-<? printf ("<a href=\"edit.php3?blzkto=%s\">Neuer Eintrag</a>", $blzkto); ?>
+<protect><script type="text/javascript">
+$(function(){
+ $('table.border tr').not('.head').click(function(){
+ $(this).toggleClass('highlight');
+ if ($(this).hasClass('highlight'))
+ $(this).css('backgroundColor','#add8e6');
+ else
+ $(this).css('backgroundColor','');
+ });
+ $('body').append('<script type="text/javascript" src="../../jquery.udraggable.js"><\/script>');
+ $('body').append('<script type="text/javascript" src="../../jquery.event.ue.js"><\/script>');
+});
+
+//+ Jonas Raoni Soares Silva
+//@ http://jsfromhell.com/geral/utf-8 [rev. #1]
+
+UTF8 = {
+ encode: function(s){
+ for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
+ s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
+ );
+ return s.join("");
+ },
+ decode: function(s){
+ for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
+ ((a = s[i][c](0)) & 0x80) &&
+ (s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
+ o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
+ );
+ return s.join("");
+ }
+};
+
+function filter_popup()
+{
+ if (!$('#filter_popup form input').length) {
+ $.get('query.php',
+ window.location.search.substr(1)+'&ajax=1',
+ function(data) {
+ var text = '<style type="text/css">';
+ text += '#fc { z-index: 10; }';
+ $(data).find('style').each(function(i,e){
+ text += $(this).html();
+ });
+ text += '</style>';
+ text += $(data).find('form').html();
+ $('#filter_popup form').html(text);
+
+ $('#filter_popup').udraggable({
+ 'handle': 'div#filter_title'
+ }).css('top', '70px').css('left', '103px');
+
+ $('#filter_popup form input,#filter_popup form select').not('input.button').change(function(e){
+ $.post('list.php',
+ 'ajax=1&'+$('#filter_popup form').serialize(),
+ function(data){
+ $('table.border tbody').html(UTF8.decode(data));
+ });
+ return false;
+ });
+
+ $('#filter_popup form input.button[type="submit"]').click(function(e){
+ $.post('list.php',
+ 'ajax=1&'+$('#filter_popup form').serialize(),
+ function(data){
+ $('table.border tbody').html(UTF8.decode(data));
+ $('#filter_popup').hide();
+ });
+ return false;
+ });
+ });
+ }
+
+ if ($('#filter_popup:visible').length)
+ $('#filter_popup').hide();
+ else
+ $('#filter_popup').show();
+
+ return false;
+}
+</script></protect>
+<div id="filter_popup" style="display:none;">
+<div id="filter_title">Filter setzen</div>
+<div style="padding:5px;">
+<form id="filter_form"></form>
+</div>
+</div>
</page>
# Local variables: