Improved reports menu display.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 26 Nov 2010 14:24:09 +0000 (14:24 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Fri, 26 Nov 2010 14:24:09 +0000 (14:24 +0000)
CHANGELOG.txt
js/inserts.js
js/reports.js [new file with mode: 0644]
js/utils.js
reporting/includes/reports_classes.inc
reporting/reports_main.php

index 6267f8a787c60825929639b6209b3475efa230e0..ffb7eef51c97e3d520dac087bd4e11f64f700bd3 100644 (file)
@@ -20,6 +20,12 @@ Legend:
 $ -> Affected files
 
 26-Nov-2010 Janusz Dobrowolski
+! [0000282] Improved reports menu display.
+$ /js/inserts.js
+  /js/utils.js
+  /js/reports.js (new)
+  /reporting/reports_main.php
+  /reporting/includes/reports_classes.inc
 # [0000283] Fixed potential vulnerability (Mithy)
 $ /admin/db/security_db.inc
 # Fixed hotkeys support.
index e486c6c4a1c53241114ecfbb6578b17a91430f85..a17519ef36a2298134f7b305c72a042dab62e0f0 100644 (file)
@@ -303,6 +303,16 @@ var inserts = {
                        return false;
                }
        },
+       'a.repopts_link':       function(l) {
+               l.onclick = function() {
+                   save_focus(this);
+                   var replinks = document.getElementsBySelector('a.repopts_link');
+                               for(var i in replinks)
+                                       replinks[i].style.fontWeight = replinks[i]==this ? 'bold' : 'normal';
+                       JsHttpRequest.request(this, null);
+                       return false;
+               }
+       },
        'a': function(e) { // traverse menu
                e.onkeydown = function(ev) { 
                        ev = ev||window.event;
diff --git a/js/reports.js b/js/reports.js
new file mode 100644 (file)
index 0000000..1c24875
--- /dev/null
@@ -0,0 +1,63 @@
+/**********************************************************************
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
+***********************************************************************/
+var replinks = {
+       'a, button': function(e) { // traverse menu
+               e.onkeydown = function(ev) { 
+                       ev = ev||window.event;
+                       key = ev.keyCode||ev.which;
+                       if(key==37 || key==38 || key==39 || key==40) {
+                               move_focus(key, e, document.links);
+                               ev.returnValue = false;
+                               return false;
+                       }
+               }
+       },
+       'a.repopts_link':       function(e) {
+               e.onclick = function() {
+                   save_focus(this);
+                   set_options(this);
+                       JsHttpRequest.request(this, null);
+                       return false;
+               }
+       },
+       'a.repclass_link': function(e) {
+               e.onclick = function() {
+                   save_focus(this);
+                       showClass(this.id.substring(5)); // id=classX
+                       return false;
+               }
+       }
+}
+
+function set_options(e)
+{
+    var replinks = document.getElementsBySelector('a.repopts_link');
+       for(var i in replinks)
+               replinks[i].style.fontWeight = replinks[i]==e ? 'bold' : 'normal';
+}
+
+function showClass(pClass) {
+       var classes = document.getElementsBySelector('.repclass');
+       for(var i in  classes) {
+               cl = classes[i];
+               cl.style.display = (cl.id==('TAB_'+pClass)) ? "block" : "none";
+       }
+       var classlinks = document.getElementsBySelector('a.repclass_link');
+       for(var i in classlinks)
+               classlinks[i].style.fontWeight = classlinks[i].id == ('class'+pClass) ?
+                       'bold' : 'normal';
+
+    set_options(); // clear optionset links
+       document.getElementById('rep_form').innerHTML = '';
+       return false;
+}
+
+Behaviour.register(replinks);
\ No newline at end of file
index 0474ae2361b21f8c28cc71d3dd75883e6ec2ac87..51a7a491bfeedd96f7d9da8a12c4a560ba7358b5 100644 (file)
@@ -295,7 +295,8 @@ function move_focus(dir, e0, neighbours)
        for(var i=0; i<neighbours.length; i++) {
                var e = neighbours[i];
                var p = element_pos(e);
-               if (p!=null && (e.className=='menu_option' || e.className=='printlink')) {
+               if (p!=null && (e.className=='menu_option' || e.className=='printlink'
+                                || e.className == 'repclass_link' || e.className == 'repopts_link')) {
                        if (((dir==40) && (p.y>p0.y)) || (dir==38 && (p.y<p0.y)) 
                                || ((dir==37) && (p.x<p0.x)) || ((dir==39 && (p.x>p0.x)))) {
                                        var l1 = (p.y-p0.y)*(p.y-p0.y)+(p.x-p0.x)*(p.x-p0.x);
index 9aad89c586be0292fc8910109b1ae9abf65d51ce..72be5bbf67c7fbf87140c386adce8f3fb00c7431 100644 (file)
@@ -55,26 +55,37 @@ class BoxReports
                $st_reports = "";
                $st_params = "";
                $st_classes = "<b>" . _("Report Classes:") . "</b><br>";
+
+               if (isset($_GET['Class']))
+                       set_focus('class'.$_GET['Class']);
+
                foreach($this->ar_classes as $class_id => $name)
                {
                        if (!isset($this->ar_reports[$class_id]))
                                continue; // e.g. no dimensions
-                       $style = $class_id==$_REQUEST['Class'] ? '' : "style='display:none'";
-//                     $cname = access_string($key, true);
-//                     $style = $_REQUEST['Class']==$cname ? '' : "style='display:none'";
+
                        $acc = access_string($name);
                        $st_classes .= "<a href='"
                                .$_SERVER['PHP_SELF']."?Class=$class_id'"
-                               ." class='menu_option' id='".default_focus()."'"
-                               ." onclick='return showClass(\"$class_id\");'$acc[1]>$acc[0]</a> <br>";
+                               ." style='font-weight:". ($_REQUEST['Class'] == $class_id ? 'bold' : 'normal')."'"
+                               ." class='repclass_link' id='".'class'.$class_id."'"
+                               ."$acc[1]>$acc[0]</a> <br>";
+
+                       $style = $class_id==$_REQUEST['Class'] ? '' : "style='display:none'";
                        $st_reports .= "<table class='repclass' id='TAB_" . $class_id ."' $style cellpadding=0 cellspacing=0 border=0 width='100%'><tr><td><b>" . _("Reports For Class: ") . "&nbsp;$name</b></td></tr>\n";
                        foreach($this->ar_reports[$class_id] as $rep_id => $report)
                        {
                                $acc = access_string($report->name);
-                               $st_reports .= "<tr><td><a class='printlink' href='"
-                                       .$_SERVER['PHP_SELF']."?Class=$class_id&rep_id=$report->id'"
-                                       ." id='".default_focus()."'"
+                               $st_reports .= "<tr><td><a class='repopts_link'"
+                                       ." href='".$_SERVER['PHP_SELF']."?Class=$class_id&rep_id=$report->id'"
+                                       ." style='font-weight:". (@$_GET['rep_id'] == $report->id ? 'bold' : 'normal')."'"
+                                       ." id='".$id = default_focus()."'"
                                        ."$acc[1]>$acc[0]</a><tr><td>\n";
+
+                               if (@$_REQUEST['rep_id'] == $report->id) {
+                                       $Ajax->activate($id);
+                               }
+
                                if (isset($_REQUEST['rep_id']) && $_REQUEST['rep_id']==$report->id) {
 
                                        $action = $path_to_root.'/reporting/prn_redirect.php';
@@ -96,28 +107,7 @@ class BoxReports
                $st_params = "<div id='rep_form'>".
                        "$st_params</div>";
                
-
-               $st =   "<script language='javascript'>
-                                       function showClass(pClass) {
-                                               var classes = document.getElementsBySelector('.repclass');
-                                               for(var i in  classes) {
-                                                       cl = classes[i];
-                                                       cl.style.display=
-                                                       (cl.id==('TAB_'+pClass)) ? \"block\" : \"none\";
-                                               }
-                                               document.getElementById('rep_form').innerHTML = '';
-//                                             document.getElementById('rep_form').style.display = 'none';
-                                               return false;
-                                       }
-                                       function checkDate(pObj) {
-                                               var re = /^(3[01]|0[1-9]|[12]\d)\/(0[1-9]|1[012])\/\d{4}/;
-                                               if (re.test(pObj.value)==false) {
-                                                       alert('" . _("Invalid date format") . "')
-                                               }
-                                       }
-                               </script>
-                               ";
-               $st .= "<table align='center' width='80%' style='border:1px solid #cccccc;'><tr valign='top'>";
+               $st = "<table align='center' width='80%' style='border:1px solid #cccccc;'><tr valign='top'>";
                $st .= "<td width='30%'>$st_classes</td>";
                $st .= "<td width='35%' style='border-left:1px solid #cccccc;border-right:1px solid #cccccc;padding-left:3px;'>$st_reports</td>";
                $st .= "<td width='35%'>$st_params</td>";
index 635505c3467b3db880a8297af94fb7b66f202c75..718484a03b34e911c451d346e065485d78e80bb3 100644 (file)
@@ -20,6 +20,9 @@ include_once($path_to_root . "/reporting/includes/reports_classes.inc");
 $js = "";
 if ($use_date_picker)
        $js .= get_js_date_picker();
+
+add_js_file('reports.js');
+
 page(_($help_context = "Reports and Analysis"), false, false, "", $js);
 
 $reports = new BoxReports;
@@ -390,13 +393,6 @@ $reports->addReport(RC_GL, 710, _('Audit Trail'),
 
 add_custom_reports($reports);
 
-echo "<script language='javascript'>
-               function onWindowLoad() {
-                       showClass(" . $_GET['Class'] . ")
-               }
-       Behaviour.addLoadEvent(onWindowLoad);
-       </script>
-";
 echo $reports->getDisplay();
 
 end_page();