[0005209] Reports: fixed broken reports after session timeout.
[fa-stable.git] / js / reports.js
1 /**********************************************************************
2     Copyright (C) FrontAccounting, LLC.
3         Released under the terms of the GNU General Public License, GPL, 
4         as published by the Free Software Foundation, either version 3 
5         of the License, or (at your option) any later version.
6     This program is distributed in the hope that it will be useful,
7     but WITHOUT ANY WARRANTY; without even the implied warranty of
8     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
9     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ***********************************************************************/
11 var replinks = {
12         'a, button': function(e) { // traverse menu
13                 e.onkeydown = function(ev) { 
14                         ev = ev||window.event;
15                         key = ev.keyCode||ev.which;
16                         if(key==37 || key==38 || key==39 || key==40) {
17                                 move_focus(key, e, document.links);
18                                 ev.returnValue = false;
19                                 return false;
20                         }
21                 }
22         },
23         'a.repopts_link':       function(e) {
24                 e.onclick = function() {
25                     save_focus(this);
26                     set_options(this);
27                         JsHttpRequest.request(this, null);
28                         return false;
29                 }
30         },
31         'a.repclass_link': function(e) {
32                 e.onclick = function() {
33                     save_focus(this);
34                         showClass(this.id.substring(5)); // id=classX
35                         return false;
36                 }
37         },
38         'button': function(e) {
39                 e.onclick = function() {
40                         window.open('', 'formpopup', 'toolbar=no,scrollbars=yes,resizable=yes,menubar=no');
41                         e.form.target='formpopup';
42                 }
43         },
44 }
45
46 function set_options(e)
47 {
48     var replinks = document.getElementsBySelector('a.repopts_link');
49         for(var i in replinks)
50                 replinks[i].style.fontWeight = replinks[i]==e ? 'bold' : 'normal';
51 }
52
53 function showClass(pClass) {
54         var classes = document.getElementsBySelector('.repclass');
55         for(var i in  classes) {
56                 cl = classes[i];
57                 cl.style.display = (cl.id==('TAB_'+pClass)) ? "block" : "none";
58         }
59         var classlinks = document.getElementsBySelector('a.repclass_link');
60         for(var i in classlinks)
61                 classlinks[i].style.fontWeight = classlinks[i].id == ('class'+pClass) ?
62                         'bold' : 'normal';
63
64     set_options(); // clear optionset links
65         document.getElementById('rep_form').innerHTML = '';
66         return false;
67 }
68
69 Behaviour.register(replinks);