Move list table to class / new AJAX framework
[infodrom.org/service.infodrom.org] / src / InfoCon / account / list.wml
1 #include <infocon.style>
2 #include <phptools.inc>
3 #include "account.inc"
4
5 <?php
6 function filter_account()
7 {
8     if ((strlen($_POST['currency']) > 0) && ($_POST['currency'] == "dm")) {
9         $account = new AccountingDM();
10     } else {
11         $account = new Accounting();
12     }
13
14     return $account->filterTable($_POST);
15 }
16
17 if (!empty($_POST['ajax']) && $_POST['ajax'] == 1) {
18     echo utf8_encode(filter_account());
19     exit;
20 }
21
22 ?>
23
24 <page func=InfoCon title="Kontof├╝hrung">
25
26 <calendar_init -5>
27 <account_heading>
28 <form_to_yyyymmdd>
29
30 <style type="text/css">
31 div#filter_popup {
32     background: white;
33     border: 1px solid #CCC;
34     height:auto;
35     width:340px;
36     position:absolute;
37 }
38 div#filter_title {
39     width: 100%;
40     cursor: move;
41     background: #EEE;
42     margin-bottom: 5px;
43     font-weight: bold;
44 }
45 </style>
46 <table class="border smallfont yellow-hover" width=100% border=0 cellpadding=0 cellspacing=1>
47 <thead>
48 <tr class=head>
49   <th width=10%>Datum</th>
50   <th width=10%>Kategorie</th>
51   <th width=70%>Verwendungszweck</th>
52   <th width=10%>Betrag</th>
53 </tr>
54 </thead>
55 <tbody>
56 <?=(count($_GET)?'':filter_account())?>
57 </tbody>
58 </table><p>
59
60 <protect><script type="text/javascript">
61 $(function(){
62     $('table.border tr').not('.head').click(function(){
63         $(this).toggleClass('highlight');
64         if ($(this).hasClass('highlight'))
65             $(this).css('backgroundColor','#add8e6');
66         else
67             $(this).css('backgroundColor','');
68     });
69     $('body').append('<script type="text/javascript" src="../../jquery.udraggable.js"><\/script>');
70     $('body').append('<script type="text/javascript" src="../../jquery.event.ue.js"><\/script>');
71     $('body').append('<script type="text/javascript" src="../../jquery.editable.js"><\/script>');
72 });
73
74 //+ Jonas Raoni Soares Silva
75 //@ http://jsfromhell.com/geral/utf-8 [rev. #1]
76
77 UTF8 = {
78         encode: function(s){
79                 for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
80                         s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
81                 );
82                 return s.join("");
83         },
84         decode: function(s){
85                 for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
86                         ((a = s[i][c](0)) & 0x80) &&
87                         (s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
88                         o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
89                 );
90                 return s.join("");
91         }
92 };
93
94 function filter_popup()
95 {
96     if (!$('#filter_popup form input').length) {
97         $.get('query.php',
98               window.location.search.substr(1)+'&ajax=1',
99               function(data) {
100                   var text = '<style type="text/css">';
101                   text += '#fc { z-index: 10; }';
102                   $(data).find('style').each(function(i,e){
103                       text += $(this).html();
104                   });
105                   text += '</style>';
106                   text += $(data).find('form').html();
107                   $('#filter_popup form').html(text);
108
109                   $('#filter_popup').udraggable({
110                       'handle': 'div#filter_title'
111                   }).css('top', '70px').css('left', '103px');
112
113                   $('#filter_popup form input,#filter_popup form select').not('input.button').change(function(e){
114                       $.invoke('Accounting/Filter',
115                                $('#filter_popup form').serialize(),
116                              function(data){
117                                  $('table.border tbody').html(data.table);
118                                  make_editable('table.smallfont tr span');
119                              });
120                       return false;
121                   });
122
123                   $('#filter_popup form input.button[type="submit"]').click(function(e){
124                       $.invoke('Accounting/Filter',
125                                $('#filter_popup form').serialize(),
126                              function(data){
127                                  $('table.border tbody').html(data.table);
128                                  $('#filter_popup').hide();
129                                  make_editable('table.smallfont tr span');
130                              });
131                       return false;
132                   });
133           });
134     }
135
136     if ($('#filter_popup:visible').length)
137         $('#filter_popup').hide();
138     else
139         $('#filter_popup').show();
140
141     return false;
142 }
143
144 </script></protect>
145 <div id="filter_popup" style="display:none;">
146 <div id="filter_title">Filter setzen</div>
147 <div style="padding:5px;">
148 <form id="filter_form"></form>
149 </div>
150 </div>
151 </page>
152
153 # Local variables:
154 # mode: text
155 # mode: auto-fill
156 # end: