Bug 7668 - Improve navigation and toolbar options in guided reports
authorOwen Leonard <oleonard@myacpl.org>
Wed, 7 Mar 2012 19:06:45 +0000 (14:06 -0500)
committerPaul Poulain <paul.poulain@biblibre.com>
Mon, 19 Mar 2012 17:00:15 +0000 (18:00 +0100)
Creating new include, reports-toolbar.inc for presenting "action"
options to the user, in contrast with "view" options in the left-
hand navigation menu.

In the toolbar: New (guided report, SQL report), Edit, Run.

The presence of the toolbar allows the user to access functions
more flexibly: Getting directly to 'edit' or 'run' from the 'view'
page for instance.

Modifications to guided_reports.pl pass report id and name to
the template for clarity and for the purpose of enabling the
edit/run buttons.

To test: Apply the patch and go through the process of creating
a new saved SQL report. Note that the toolbar is present and
the buttons are functional at appropriate times.

New and Edit options should only be displayed if the user has
permission to create reports. Test with a user who does not
have create permission to confirm.

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
koha-tmpl/intranet-tmpl/prog/en/includes/guided-reports-view.inc
koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
reports/guided_reports.pl

index e8821f5..78dd4f9 100644 (file)
@@ -886,7 +886,16 @@ fieldset.rows .inputnote {
        background-repeat : no-repeat;
 }
 
-#editpatron a, #editmenuc .first-child, #editshelf a, #edit a, #editsupplier a, #managelabel a, #managetemplate a, #managelabelbatch a, #manageprofile a {
+#editpatron a,
+#editreport a,
+#editmenuc .first-child,
+#editshelf a,
+#edit a,
+#editsupplier a,
+#managelabel a,
+#managetemplate a,
+#managelabelbatch a,
+#manageprofile a {
        padding-left : 34px;
        background-image: url("../../img/toolbar-edit.gif");
        background-position : center left;
index d354170..aa03be8 100644 (file)
@@ -1,8 +1,6 @@
-<h5>Build and Run Reports</h5>
+<h5>Run Reports</h5>
 <ul>
-       [% IF ( CAN_user_reports_create_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">Build New</a></li>[% END %]
-       [% IF ( CAN_user_reports_execute_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Use Saved</a></li>[% END %]
-       [% IF ( CAN_user_reports_create_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">Create from SQL</a></li>[% END %]
+       [% IF ( CAN_user_reports_execute_reports ) %]<li><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved">Saved reports</a></li>[% END %]
 </ul>
 <h5>Reports Dictionary</h5>
 <ul>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc
new file mode 100644 (file)
index 0000000..a4e4226
--- /dev/null
@@ -0,0 +1,44 @@
+[% UNLESS ( no_add ) %]
+<div id="toolbar">
+       <script type="text/javascript">
+       //<![CDATA[
+        $(document).ready(function() {
+               $("#newmenuc").empty();
+               $("#newsql").remove();
+               yuiToolbar();
+        });
+
+       // YUI Toolbar Functions
+       function yuiToolbar() {
+       [% IF ( CAN_user_reports_create_reports ) %]
+               var newmenu = [
+                       { text: _("Guided report"),  url: "/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new" },
+                       { text: _("SQL report"),  url: "/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL" }
+               ]
+           new YAHOO.widget.Button({
+               type: "menu",
+               label: _("New"),
+               name: "newmenubutton",
+               menu: newmenu,
+               container: "newmenuc"
+           });
+           new YAHOO.widget.Button("editreport");[% END %]
+           new YAHOO.widget.Button("runreport");
+       }
+       //]]>
+       </script>
+
+       <ul class="toolbar">
+               [% IF ( CAN_user_reports_create_reports ) %]<li id="newmenuc"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Build%20new">New guided report</a> </li>[% END %]
+               <li id="newsql"><a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create%20report%20from%20SQL">New SQL report</a> </li>
+               [% IF ( showsql || execute || editsql || save_successful ) %]
+                       [% UNLESS ( errors ) %][%# Unless there are errors saving a report %]
+                               [% UNLESS ( editsql ) %][%# Do not show edit button on edit page %]
+                                       [% IF ( CAN_user_reports_create_reports ) %]<li><a id="editreport" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id %]&amp;phase=Edit%20SQL">Edit</a></li>[% END %]
+                               [% END %]
+                               <li><a id="runreport" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id %]&amp;phase=Run%20this%20report">Run report</a></li>
+                       [% END %]
+               [% END %]
+       </ul>
+</div>
+[% END %]
\ No newline at end of file
index 03b007d..8dbbb03 100644 (file)
@@ -87,6 +87,7 @@ $(document).ready(function(){
 <div id="bd">
 <div id="yui-main">
     <div class="yui-b">
+    [% INCLUDE "reports-toolbar.inc" %]
 
 [% IF ( start ) %]
     <h2>Guided Reports</h2>
@@ -562,7 +563,8 @@ canned reports and writing custom SQL reports.</p>
 </fieldset>
 
 <fieldset class="action"><input type="hidden" name="phase" value="Save Report" />
-<input type="submit" name="submit" value="Save Report" /></fieldset>
+<input type="submit" name="submit" value="Save Report" /> <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
+</fieldset>
 </form>
 [% END %]
 
@@ -603,7 +605,13 @@ Sub report:<select name="subreport">
 [% END %]
 
 [% IF ( showsql ) %]
-<textarea id="sql">[% sql %]</textarea>
+<fieldset class="rows">
+    <legend>[% reportname %]</legend>
+    <ol>
+        [% IF ( notes ) %]<li><span class="label">Notes:</span> [% notes %]</li>[% ELSE %][% END %]
+        <li><textarea id="sql">[% sql %]</textarea></li>
+    </ol>
+</fieldset>
 [% END %]
 
 [% IF ( editsql ) %]
@@ -611,16 +619,17 @@ Sub report:<select name="subreport">
 <input type="hidden" name="phase" value="Update SQL" />
 <input type="hidden" name="id" value="[% id %]"/>
 <fieldset class="rows">
-<legend>Edit SQL</legend>
+<legend>Edit SQL report</legend>
 <ol>
-<li><label for="reportname">Report Name:</label><input type="text" id="reportname" name="reportname" value="[% reportname %]" /></li>
+<li><label for="reportname">Report Name:</label><input type="text" id="reportname" name="reportname" value="[% reportname %]" size="50" /></li>
 <li><label for="notes">Notes:</label><textarea id="notes" name="notes" cols="50" rows="2">[% notes %]</textarea></li>
 <li><textarea id="sql" name="sql" rows="10" cols="60">[% sql %]</textarea></li>
 </ol>
 </fieldset>
 
 <fieldset class="action">
-<input type="submit" name="submit" value="Update SQL" /></fieldset>
+<input type="submit" name="submit" value="Update SQL" /> <a href="/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved" class="cancel">Cancel</a>
+</fieldset>
 </form>
 
 
@@ -629,7 +638,7 @@ Sub report:<select name="subreport">
 [% IF ( save_successful ) %]
 [% UNLESS ( errors ) %]
 <h2>Your report has been saved</h2>
-<p>The report you have created has now been saved. You can now</p>
+<h4>[% reportname %]</h4>
 <ul>
     [% IF ( id ) %]
     <li><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id %]&amp;phase=Run%20this%20report">Run this report</a></li>
index 5d53791..cb85f39 100755 (executable)
@@ -112,9 +112,12 @@ elsif ( $phase eq 'Delete Saved') {
 elsif ( $phase eq 'Show SQL'){
        
        my $id = $input->param('reports');
-       my $sql = get_sql($id);
+    my ($sql,$type,$reportname,$notes) = get_saved_report($id);
        $template->param(
-               'sql' => $sql,
+        'id'      => $id,
+        'reportname' => $reportname,
+        'notes'      => $notes,
+               'sql'     => $sql,
                'showsql' => 1,
     );
 }
@@ -154,6 +157,7 @@ elsif ( $phase eq 'Update SQL'){
         update_sql( $id, $sql, $reportname, $notes );
         $template->param(
             'save_successful'       => 1,
+            'reportname'            => $reportname,
             'id'                    => $id,
         );
     }
@@ -392,6 +396,7 @@ elsif ( $phase eq 'Save Report' ) {
         my $id = save_report( $borrowernumber, $sql, $name, $type, $notes );
         $template->param(
             'save_successful'       => 1,
+            'reportname'            => $name,
             'id'                    => $id,
         );
     }
@@ -531,6 +536,7 @@ elsif ($phase eq 'Run this report'){
         $template->param(
             'results' => \@rows,
             'sql'     => $sql,
+            'id'      => $report,
             'execute' => 1,
             'name'    => $name,
             'notes'   => $notes,