[Koha-patches] [PATCH] Bug 7668 - Improve navigation and toolbar options in guided reports

Owen Leonard oleonard at myacpl.org
Wed Mar 7 21:48:20 CET 2012


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.
---
 .../intranet-tmpl/prog/en/css/staff-global.css     |   11 ++++-
 .../prog/en/includes/guided-reports-view.inc       |    6 +--
 .../prog/en/includes/reports-toolbar.inc           |   44 ++++++++++++++++++++
 .../en/modules/reports/guided_reports_start.tt     |   21 +++++++---
 reports/guided_reports.pl                          |   10 ++++-
 5 files changed, 79 insertions(+), 13 deletions(-)
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc

diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
index fec66d6..eb0aae9 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
@@ -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;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/guided-reports-view.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/guided-reports-view.inc
index d354170..aa03be8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/guided-reports-view.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/guided-reports-view.inc
@@ -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
index 0000000..a4e4226
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc
@@ -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
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
index caf27f1..4ccb0ac 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
@@ -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>
@@ -548,7 +549,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 %]
 
@@ -589,7 +591,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 ) %]
@@ -597,16 +605,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>
 
 
@@ -615,7 +624,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>
diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl
index 27377e0..b9d7430 100755
--- a/reports/guided_reports.pl
+++ b/reports/guided_reports.pl
@@ -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,
         );
     }
@@ -528,6 +533,7 @@ elsif ($phase eq 'Run this report'){
         $template->param(
             'results' => \@rows,
             'sql'     => $sql,
+            'id'      => $report,
             'execute' => 1,
             'name'    => $name,
             'notes'   => $notes,
-- 
1.7.3



More information about the Koha-patches mailing list