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) {
67 $date = explode (" ", $row['datum']);
68 $date = explode ("-", $date[0]);
69 $date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);
71 $out .= sprintf ("<tr class=\"t%d\">", $color);
72 $out .= sprintf ("<td width=\"10%%\" align=\"right\">%s</td>", $date);
73 $out .= sprintf ("<td width=\"10%%\" align=\"center\">%s</td>", $row['category']);
74 $out .= sprintf ("<td width=\"70%%\"><a href=\"edit.php?id=%d%s\">%s</a></td>",
75 $row['id'], $add, $descr[0]);
76 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\">%5.2f</td>",
77 $row[$value]>0?"in":"out", $row[$value]);
79 if ($row[$value] > 0) {
80 $sum_in += $row[$value];
82 $sum_out += $row[$value];
87 if (strlen($statement)) {
88 $out .= sprintf ("<tr class=\"t%d\">", $color);
89 $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Einnahmen</strong></td>";
90 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"in\">%5.2f</td>",$sum_in);
92 $out .= sprintf ("<tr class=\"t%d\">", $color);
93 $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Ausgaben</strong></td>";
94 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"out\">%5.2f</td>", $sum_out*-1);
97 $out .= sprintf ("<tr class=\"t%d\">", $color);
98 $out .= "<td width=\"90%\" colspan=\"3\" align=\"left\"><strong>Summe</strong></td>";
99 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\"><strong>%5.2f</strong></td>",
100 $sum>0?"in":"out", $sum);
106 if (!empty($_POST['ajax']) && $_POST['ajax'] == 1) {
107 echo utf8_encode(filter_account());
113 <page func=InfoCon title="Kontoführung">
119 <style type="text/css">
122 border: 1px solid #CCC;
135 <table class="border smallfont" width=100% border=0 cellpadding=0 cellspacing=1>
138 <th width=10%>Datum</th>
139 <th width=10%>Kategorie</th>
140 <th width=70%>Verwendungszweck</th>
141 <th width=10%>Betrag</th>
145 <?=(count($_GET)?'':filter_account())?>
149 <protect><script type="text/javascript">
151 $('table.border tr').not('.head').click(function(){
152 $(this).toggleClass('highlight');
153 if ($(this).hasClass('highlight'))
154 $(this).css('backgroundColor','#add8e6');
156 $(this).css('backgroundColor','');
158 $('body').append('<script type="text/javascript" src="../../jquery.udraggable.js"><\/script>');
159 $('body').append('<script type="text/javascript" src="../../jquery.event.ue.js"><\/script>');
162 function filter_popup()
164 if (!$('#filter_popup form input').length) {
166 window.location.search.substr(1)+'&ajax=1',
168 var text = '<style type="text/css">';
169 text += '#fc { z-index: 10; }';
170 $(data).find('style').each(function(i,e){
171 text += $(this).html();
174 text += $(data).find('form').html();
175 $('#filter_popup form').html(text);
177 $('#filter_popup').udraggable({
178 'handle': 'div#filter_title'
179 }).css('top', '70px').css('left', '103px');
181 $('#filter_popup form input.button[type="submit"]').click(function(e){
183 'ajax=1&'+$('#filter_popup form').serialize(),
185 $('table.border tbody').html(data);
186 $('#filter_popup').hide();
193 if ($('#filter_popup:visible').length)
194 $('#filter_popup').hide();
196 $('#filter_popup').show();
202 <div id="filter_popup" style="display:none;">
203 <div id="filter_title">Filter setzen</div>
204 <div style="padding:5px;">
205 <form id="filter_form"></form>