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 if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/') === false)
74 $out .= sprintf ("<td width=\"70%%\"><a href=\"edit.php?id=%d%s\" target=\"_new\">%s</a></td>",
75 $row['id'], $add, $descr[0]);
77 $out .= sprintf ("<td width=\"70%%\"><span route=\"Accounting/EditDescr\" item_id=\"%d\" text=\"%s\">%s</span></td>",
78 $row['id'], $add, $descr[0]);
79 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\">%5.2f</td>",
80 $row[$value]>0?"in":"out", $row[$value]);
82 if ($row[$value] > 0) {
83 $sum_in += $row[$value];
85 $sum_out += $row[$value];
90 if (strlen($_POST['statement'])) {
91 $out .= sprintf ("<tr class=\"t%d\">", $color);
92 $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Einnahmen</strong></td>";
93 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"in\">%5.2f</td>",$sum_in);
95 $out .= sprintf ("<tr class=\"t%d\">", $color);
96 $out .= "<td width=\"90%\" colspan=\"3\"><strong>Summe Ausgaben</strong></td>";
97 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"out\">%5.2f</td>", $sum_out*-1);
100 $out .= sprintf ("<tr class=\"t%d\">", $color);
101 $out .= "<td width=\"90%\" colspan=\"3\" align=\"left\"><strong>Summe</strong></td>";
102 $out .= sprintf ("<td width=\"10%%\" align=\"right\" class=\"%s\"><strong>%5.2f</strong></td>",
103 $sum>0?"in":"out", $sum);
109 if (!empty($_POST['ajax']) && $_POST['ajax'] == 1) {
110 echo utf8_encode(filter_account());
116 <page func=InfoCon title="Kontoführung">
122 <style type="text/css">
125 border: 1px solid #CCC;
138 <table class="border smallfont yellow-hover" width=100% border=0 cellpadding=0 cellspacing=1>
141 <th width=10%>Datum</th>
142 <th width=10%>Kategorie</th>
143 <th width=70%>Verwendungszweck</th>
144 <th width=10%>Betrag</th>
148 <?=(count($_GET)?'':filter_account())?>
152 <protect><script type="text/javascript">
154 $('table.border tr').not('.head').click(function(){
155 $(this).toggleClass('highlight');
156 if ($(this).hasClass('highlight'))
157 $(this).css('backgroundColor','#add8e6');
159 $(this).css('backgroundColor','');
161 $('body').append('<script type="text/javascript" src="../../jquery.udraggable.js"><\/script>');
162 $('body').append('<script type="text/javascript" src="../../jquery.event.ue.js"><\/script>');
163 $('body').append('<script type="text/javascript" src="../../jquery.editable.js"><\/script>');
166 //+ Jonas Raoni Soares Silva
167 //@ http://jsfromhell.com/geral/utf-8 [rev. #1]
171 for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
172 s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
177 for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
178 ((a = s[i][c](0)) & 0x80) &&
179 (s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
180 o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
186 function filter_popup()
188 if (!$('#filter_popup form input').length) {
190 window.location.search.substr(1)+'&ajax=1',
192 var text = '<style type="text/css">';
193 text += '#fc { z-index: 10; }';
194 $(data).find('style').each(function(i,e){
195 text += $(this).html();
198 text += $(data).find('form').html();
199 $('#filter_popup form').html(text);
201 $('#filter_popup').udraggable({
202 'handle': 'div#filter_title'
203 }).css('top', '70px').css('left', '103px');
205 $('#filter_popup form input,#filter_popup form select').not('input.button').change(function(e){
207 'ajax=1&'+$('#filter_popup form').serialize(),
209 $('table.border tbody').html(UTF8.decode(data));
210 make_editable('table.smallfont tr span');
215 $('#filter_popup form input.button[type="submit"]').click(function(e){
217 'ajax=1&'+$('#filter_popup form').serialize(),
219 $('table.border tbody').html(UTF8.decode(data));
220 $('#filter_popup').hide();
221 make_editable('table.smallfont tr span');
228 if ($('#filter_popup:visible').length)
229 $('#filter_popup').hide();
231 $('#filter_popup').show();
237 <div id="filter_popup" style="display:none;">
238 <div id="filter_title">Filter setzen</div>
239 <div style="padding:5px;">
240 <form id="filter_form"></form>