1 #include <infocon.style>
2 #include <phptools.inc>
6 function filter_account()
13 if ((strlen($_POST['currency']) > 0) && ($_POST['currency'] == "dm")) {
14 $table = "account_dm";
19 $where[] = sprintf("blz_kto = '%s'", $_POST['blzkto']);
20 if (strlen($_POST['year'])) {
21 $where[] = sprintf ("datum >= '%04d-01-01'", $_POST['year']);
23 $where[] = sprintf ("datum < '%04d-01-01'", $_POST['year']+1);
26 if (strlen($_POST['deadline']) && strlen(trim($_POST['deadline']))) {
27 $date = form_to_yyyymmdd ($_POST['deadline']);
28 $where[] = sprintf ("datum < '%s'", $date);
31 if (strlen($_POST['statement']) && strlen(trim($_POST['statement']))) {
32 $where[] = sprintf("statement = '%s'", $_POST['statement']);
35 if (strlen($_POST['category']) && strlen(trim($_POST['category']))) {
36 if (!empty($_POST['ajax'])) $_POST['category'] = utf8_decode($_POST['category']);
37 $where[] = sprintf("category = '%s'", $_POST['category']);
40 if (strlen($_POST['keyword']) && strlen(trim($_POST['keyword']))) {
41 if (!empty($_POST['ajax'])) $_POST['keyword'] = utf8_decode($_POST['keyword']);
42 $where[] = sprintf("descr ~* '%s'", $_POST['keyword']);
45 if (strlen($_POST['from_to']) && strlen(trim($_POST['from_to']))) {
46 if (!empty($_POST['ajax'])) $_POST['from_to'] = utf8_decode($_POST['from_to']);
47 $where[] = sprintf("from_to = '%s'", $_POST['from_to']);
50 if ($_POST['input'] && !$_POST['output']) {
51 $where[] = "$value > 0.0";
52 } elseif ($_POST['output'] && !$_POST['input']) {
53 $where[] = "$value < 0.0";
56 $query = "SELECT datum,id,category,descr,$value FROM $table WHERE "
57 . implode ($where, " AND ")
58 . " ORDER BY datum,id";
64 foreach ($db->fetchAssocList($query) as $row) {
65 $descr = explode ("\n", $row['descr']);
66 $date = explode (" ", $row['datum']);
67 $date = explode ("-", $date[0]);
68 $date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);
70 $out .= sprintf ("<tr class=\"t%d\">", $color);
71 $out .= sprintf ("<td width=\"10%%\" align=\"right\">%s</td>", $date);
72 $out .= sprintf ("<td width=\"10%%\" align=\"center\">%s</td>", $row['category']);
73 $out .= sprintf ("<td width=\"70%%\"><a href=\"edit.php?id=%d%s\" target=\"_new\">%s</a></td>",
74 $row['id'], $add, $descr[0]);
75 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\">%5.2f</td>",
76 $row[$value]>0?"in":"out", $row[$value]);
78 if ($row[$value] > 0) {
79 $sum_in += $row[$value];
81 $sum_out += $row[$value];
86 if (strlen($_POST['statement'])) {
87 $out .= sprintf ("<tr class=\"t%d\">", $color);
88 $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Einnahmen</strong></td>";
89 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"in\">%5.2f</td>",$sum_in);
91 $out .= sprintf ("<tr class=\"t%d\">", $color);
92 $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Ausgaben</strong></td>";
93 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"out\">%5.2f</td>", $sum_out*-1);
96 $out .= sprintf ("<tr class=\"t%d\">", $color);
97 $out .= "<td width=\"90%\" colspan=\"3\" align=\"left\"><strong>Summe</strong></td>";
98 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\"><strong>%5.2f</strong></td>",
99 $sum>0?"in":"out", $sum);
105 if (!empty($_POST['ajax']) && $_POST['ajax'] == 1) {
106 echo utf8_encode(filter_account());
112 <page func=InfoCon title="Kontoführung">
118 <style type="text/css">
121 border: 1px solid #CCC;
134 <table class="border smallfont" width=100% border=0 cellpadding=0 cellspacing=1>
137 <th width=10%>Datum</th>
138 <th width=10%>Kategorie</th>
139 <th width=70%>Verwendungszweck</th>
140 <th width=10%>Betrag</th>
144 <?=(count($_GET)?'':filter_account())?>
148 <protect><script type="text/javascript">
150 $('table.border tr').not('.head').click(function(){
151 $(this).toggleClass('highlight');
152 if ($(this).hasClass('highlight'))
153 $(this).css('backgroundColor','#add8e6');
155 $(this).css('backgroundColor','');
157 $('body').append('<script type="text/javascript" src="../../jquery.udraggable.js"><\/script>');
158 $('body').append('<script type="text/javascript" src="../../jquery.event.ue.js"><\/script>');
161 //+ Jonas Raoni Soares Silva
162 //@ http://jsfromhell.com/geral/utf-8 [rev. #1]
166 for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
167 s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
172 for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
173 ((a = s[i][c](0)) & 0x80) &&
174 (s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
175 o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
181 function filter_popup()
183 if (!$('#filter_popup form input').length) {
185 window.location.search.substr(1)+'&ajax=1',
187 var text = '<style type="text/css">';
188 text += '#fc { z-index: 10; }';
189 $(data).find('style').each(function(i,e){
190 text += $(this).html();
193 text += $(data).find('form').html();
194 $('#filter_popup form').html(text);
196 $('#filter_popup').udraggable({
197 'handle': 'div#filter_title'
198 }).css('top', '70px').css('left', '103px');
200 $('#filter_popup form input,#filter_popup form select').not('input.button').change(function(e){
202 'ajax=1&'+$('#filter_popup form').serialize(),
204 $('table.border tbody').html(UTF8.decode(data));
209 $('#filter_popup form input.button[type="submit"]').click(function(e){
211 'ajax=1&'+$('#filter_popup form').serialize(),
213 $('table.border tbody').html(UTF8.decode(data));
214 $('#filter_popup').hide();
221 if ($('#filter_popup:visible').length)
222 $('#filter_popup').hide();
224 $('#filter_popup').show();
230 <div id="filter_popup" style="display:none;">
231 <div id="filter_title">Filter setzen</div>
232 <div style="padding:5px;">
233 <form id="filter_form"></form>