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 $where[] = sprintf("category = '%s'", $_POST['category']);
39 if (strlen($_POST['keyword']) && strlen(trim($_POST['keyword']))) {
40 $where[] = sprintf("descr ~* '%s'", $_POST['keyword']);
43 if (strlen($_POST['from_to']) && strlen(trim($_POST['from_to']))) {
44 $where[] = sprintf("from_to = '%s'", $_POST['from_to']);
47 if ($_POST['input'] && !$_POST['output']) {
48 $where[] = "$value > 0.0";
49 } elseif ($_POST['output'] && !$_POST['input']) {
50 $where[] = "$value < 0.0";
53 $query = "SELECT datum,id,category,descr,$value FROM $table WHERE "
54 . implode ($where, " AND ")
55 . " ORDER BY datum,id";
61 foreach ($db->fetchAssocList($query) as $row) {
64 $date = explode (" ", $row['datum']);
65 $date = explode ("-", $date[0]);
66 $date = sprintf ("%d.%d.%d", $date[2], $date[1], $date[0]);
68 $out .= sprintf ("<tr class=\"t%d\">", $color);
69 $out .= sprintf ("<td width=\"10%%\" align=\"right\">%s</td>", $date);
70 $out .= sprintf ("<td width=\"10%%\" align=\"center\">%s</td>", $row['category']);
71 $out .= sprintf ("<td width=\"70%%\"><a href=\"edit.php?id=%d%s\">%s</a></td>",
72 $row['id'], $add, $descr[0]);
73 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\">%5.2f</td>",
74 $row[$value]>0?"in":"out", $row[$value]);
76 if ($row[$value] > 0) {
77 $sum_in += $row[$value];
79 $sum_out += $row[$value];
84 if (strlen($statement)) {
85 $out .= sprintf ("<tr class=\"t%d\">", $color);
86 $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Einnahmen</strong></td>";
87 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"in\">%5.2f</td>",$sum_in);
89 $out .= sprintf ("<tr class=\"t%d\">", $color);
90 $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Ausgaben</strong></td>";
91 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"out\">%5.2f</td>", $sum_out*-1);
94 $out .= sprintf ("<tr class=\"t%d\">", $color);
95 $out .= "<td width=\"90%\" colspan=\"3\" align=\"left\"><strong>Summe</strong></td>";
96 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\"><strong>%5.2f</strong></td>",
97 $sum>0?"in":"out", $sum);
103 if (!empty($_POST['ajax']) && $_POST['ajax'] == 1) {
104 echo utf8_encode(filter_account());
110 <page func=InfoCon title="Kontoführung">
116 <style type="text/css">
119 border: 1px solid #CCC;
132 <table class="border smallfont" width=100% border=0 cellpadding=0 cellspacing=1>
135 <th width=10%>Datum</th>
136 <th width=10%>Kategorie</th>
137 <th width=70%>Verwendungszweck</th>
138 <th width=10%>Betrag</th>
142 <?=(count($_GET)?'':filter_account())?>
146 <protect><script type="text/javascript">
148 $('table.border tr').not('.head').click(function(){
149 $(this).toggleClass('highlight');
150 if ($(this).hasClass('highlight'))
151 $(this).css('backgroundColor','#add8e6');
153 $(this).css('backgroundColor','');
155 $('body').append('<script type="text/javascript" src="../../jquery.udraggable.js"><\/script>');
156 $('body').append('<script type="text/javascript" src="../../jquery.event.ue.js"><\/script>');
159 function filter_popup()
161 if (!$('#filter_popup form input').length) {
163 window.location.search.substr(1)+'&ajax=1',
165 var text = '<style type="text/css">';
166 text += '#fc { z-index: 10; }';
167 $(data).find('style').each(function(i,e){
168 text += $(this).html();
171 text += $(data).find('form').html();
172 $('#filter_popup form').html(text);
174 $('#filter_popup').udraggable({
175 'handle': 'div#filter_title'
176 }).css('top', '70px').css('left', '103px');
178 $('#filter_popup form input.button[type="submit"]').click(function(e){
180 'ajax=1&'+$('#filter_popup form').serialize(),
182 $('table.border tbody').html(data);
183 $('#filter_popup').hide();
190 if ($('#filter_popup:visible').length)
191 $('#filter_popup').hide();
193 $('#filter_popup').show();
199 <div id="filter_popup" style="display:none;">
200 <div id="filter_title">Filter setzen</div>
201 <div style="padding:5px;">
202 <form id="filter_form"></form>