From 1e92b9c15e525442bd147c0f44586640c8f38c85 Mon Sep 17 00:00:00 2001
From: Julian Maurice
Date: Thu, 2 Aug 2012 16:03:32 +0200
Subject: [PATCH] Bug 9117: Reports hierarchies management improvements
- Filter by groups using tabs
- Filter by subgroups using a dropdown list under each tab
- Allow to create new group and subgroups when building a new report or
editing an existing report (no need to go through admin AV interface)
+ Possibility to duplicate a report (new link in the table)
Signed-off-by: Kyle M Hall
Signed-off-by: Katrin Fischer
Signed-off-by: Jared Camins-Esakov
---
C4/Koha.pm | 21 +
.../modules/reports/guided_reports_start.tt | 445 ++++++++++--------
reports/guided_reports.pl | 42 +-
3 files changed, 314 insertions(+), 194 deletions(-)
diff --git a/C4/Koha.pm b/C4/Koha.pm
index 4c01309263..13ab94a978 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -63,6 +63,7 @@ BEGIN {
&GetAuthorisedValueByCode
&GetKohaImageurlFromAuthorisedValues
&GetAuthValCode
+ &AddAuthorisedValue
&GetNormalizedUPC
&GetNormalizedISBN
&GetNormalizedEAN
@@ -1226,6 +1227,26 @@ sub GetKohaAuthorisedValueLib {
return $value;
}
+=head2 AddAuthorisedValue
+
+ AddAuthorisedValue($category, $authorised_value, $lib, $lib_opac);
+
+Create a new authorised value.
+
+=cut
+
+sub AddAuthorisedValue {
+ my ($category, $authorised_value, $lib, $lib_opac) = @_;
+
+ my $dbh = C4::Context->dbh;
+ my $query = qq{
+ INSERT INTO authorised_values (category, authorised_value, lib, lib_opac)
+ VALUES (?,?,?,?)
+ };
+ my $sth = $dbh->prepare($query);
+ $sth->execute($category, $authorised_value, $lib, $lib_opac);
+}
+
=head2 display_marc_indicators
my $display_form = C4::Koha::display_marc_indicators($field);
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 e1f4593e7d..e2a5a19177 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
@@ -32,25 +32,98 @@
dt_add_type_uk_date();
[% END %]
var group_subgroups = {};
-var no_subgroup_label = _( "(None)" );
+[% FOREACH group IN groups_with_subgroups %]
+ var gid = "[% group.id %]"
+ group_subgroups[gid] = new Array();
+ [% FOREACH subgroup IN group.subgroups %]
+ var sgid = "[% subgroup.id %]";
+ var sgname = "[% subgroup.name %]";
+ group_subgroups[gid].push([sgid, sgname]);
+ [% END %]
+[% END %]
+
function load_group_subgroups () {
- var group = $("#group").val();
+ var group = $("#group_select").val();
var sg = $("#subgroup");
- var has_subgroups = false;
- $(sg).empty().append('');
+ $(sg).find('option[value!=""]').each(function() {
+ $(this).remove();
+ });
+ $(sg).hide();
if (group) {
+ var select = $(sg).find('select')[0];
$.each( group_subgroups[group], function(index, value) {
- has_subgroups = true;
- $('').appendTo(sg);
+ $('').appendTo(select);
} );
- }
- if (has_subgroups) {
- $(sg).show();
- } else {
- $(sg).hide();
+ $("#subgroup, #subgroup *").show();
}
}
+
$(document).ready(function(){
+
+[% IF (saved1) %]
+ [% IF (dateformat == "metric") %]
+ dt_add_type_uk_date();
+ [% END %]
+ var rtable = $("#table_reports").dataTable($.extend(true, {}, dataTablesDefaults, {
+ 'bAutoWidth': false,
+ 'sDom': 't<"bottom pager"ilpf>',
+ 'sPaginationType': 'four_button',
+ 'aLengthMenu': [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
+ 'iDisplayLength': 20,
+ 'aaSorting': [[ 1, "asc" ]],
+ 'aoColumnDefs': [
+ { 'bSortable': false, 'bSearchable':false, 'aTargets': [-1, -2, -3, -4] },
+ { 'bSearchable': false, 'aTargets': [3, 4] }
+ ],
+ 'oLanguage': {
+ 'sZeroRecords': _('No matching reports found')
+ }
+ }));
+
+ var rtabs = $("#tabs").tabs();
+ rtabs.bind("tabsshow", function(e, ui) {
+ $("#subgroup_filter option").each(function() {
+ if($(this).val().length > 0) {
+ $(this).remove();
+ }
+ });
+ rtable.fnFilter('', 3);
+ rtable.fnFilter('', 4);
+ rtable.fnSetColumnVis(3, true);
+ rtable.fnSetColumnVis(4, true);
+
+ var g_id = $(ui.tab).attr('id')
+ var g_name = $(ui.tab).text();
+ if (g_id && g_id.length > 0) {
+ rtable.fnFilter(g_name, 3);
+ rtable.fnSetColumnVis(3, false);
+ for(var i in group_subgroups[g_id]) {
+ $("#subgroup_filter").append(
+ ''
+ );
+ }
+ $("#subgroup_filter_block").show();
+ } else {
+ $("#subgroup_filter_block").hide();
+ }
+ });
+ $("#subgroup_filter_block").hide();
+
+ $("#subgroup_filter").change(function() {
+ var selected = $(this).find('option:selected');
+ var sg_id = $(selected).val();
+ var sg_name = $(selected).text();
+ if (sg_id.length > 0) {
+ rtable.fnFilter(sg_name, 4);
+ rtable.fnSetColumnVis(4, false);
+ } else {
+ rtable.fnFilter('', 4);
+ rtable.fnSetColumnVis(4, true);
+ }
+ });
+[% END %]
+
[% IF ( showsql ) %]
$("#sql").focus(function() {
$(this).select();
@@ -66,20 +139,57 @@ $(document).ready(function(){
return false;
}
});
- // call the datatables plugin
- $("#table_reports").dataTable($.extend(true, {}, dataTablesDefaults, {
- "aoColumnDefs": [
- { "aTargets": [ -1, -2, -3, -4 ], "bSortable": false, "bSearchable": false },
- ],
- "aaSorting": [[ 1, "asc" ]],
- "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
- "iDisplayLength": 20,
- "sPaginationType": "four_button"
- }));
[% END %]
// redefine the datepicker's default because reports require ISO
// http://jqueryui.com/demos/datepicker/#option-dateFormat
$( ".datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd" );
+
+[% IF (create || editsql || save) %]
+ $("#select_group").change(function() {
+ if($(this).attr('checked')) {
+ $("#group_input").attr('disabled', 'disabled');
+ $("#groupdesc_input").attr('disabled', 'disabled');
+ $("#group_select").attr('disabled', false);
+ if ($("#group_select").val().length > 0) {
+ $("#select_subgroup").attr('checked', 'checked');
+ $("#select_subgroup").change();
+ $("#subgroup, #subgroup *").show();
+ } else {
+ $("#subgroup").hide();
+ }
+ }
+ });
+ $("#create_group").change(function() {
+ if($(this).attr('checked')) {
+ $("#group_input").attr('disabled', false);
+ $("#groupdesc_input").attr('disabled', false);
+ $("#group_select").attr('disabled', 'disabled');
+ $("#create_subgroup").attr('checked', 'checked').change();
+ $("#subgroup_select").hide();
+ $("#subgroup input[type='radio']").hide();
+ $("#subgroup label[for]").hide();
+ $("#subgroup_input").show();
+ $("#subgroupdesc_input").show();
+ $("#subgroup").show();
+ }
+ });
+ $("#select_subgroup").change(function() {
+ if($(this).attr('checked')) {
+ $("#subgroup_select").attr('disabled', false);
+ $("#subgroup_input").attr('disabled', 'disabled');
+ $("#subgroupdesc_input").attr('disabled', 'disabled');
+ }
+ });
+ $("#create_subgroup").change(function() {
+ if($(this).attr('checked')) {
+ $("#subgroup_input").attr('disabled', false);
+ $("#subgroupdesc_input").attr('disabled', false);
+ $("#subgroup_select").attr('disabled', 'disabled');
+ }
+ });
+ $("#select_group").change();
+ $("#select_subgroup").change();
+[% END %]
});
//]]>
@@ -149,61 +259,78 @@ canned reports and writing custom SQL reports.
[% IF ( saved1 ) %]
[% IF ( savedreports ) %]Saved reports
-
-
-
- ID |
- Report name |
- Type |
- Area |
- Group |
- Subgroup |
- Notes |
- Author |
- Creation date |
- Public |
- [% IF (usecache) %] Cache expiry (seconds) | [% END %]
- Saved results |
- Saved SQL |
- |
- |
-
-
-
-[% FOREACH savedreport IN savedreports %]
-[% UNLESS ( loop.odd ) %][% ELSE %]
[% END %]
-[% savedreport.id %] |
-[% savedreport.report_name %] |
-[% savedreport.type %] |
-[% savedreport.areaname %] |
-[% savedreport.groupname %] |
-[% savedreport.subgroupname %] |
-[% savedreport.notes %] |
-[% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %]) |
-[% savedreport.date_created %] |
-[% IF (savedreport.public) %]
-Yes |
-[% ELSE %]
-No |
-[% END %]
-[% IF (usecache) %] [% savedreport.cache_expiry %] | [% END %]
-[% IF ( savedreport.date_run ) %][% savedreport.date_run %][% END %]
- |
-
- Show
- [% IF ( CAN_user_reports_create_reports ) %]
- Edit
+ |
-Run
-Schedule |
- [% IF ( CAN_user_reports_create_reports ) %]
- Delete |
- [% END %]
-
-[% END %]
-
-
+
+
+
+
+
+
+
+
+
+ ID |
+ Report name |
+ Type |
+ Group |
+ Subgroup |
+ Notes |
+ Author |
+ Creation date |
+ Public |
+ [% IF (usecache) %] Cache expiry (seconds) | [% END %]
+ Saved results |
+ Saved SQL |
+ |
+ |
+
+
+
+ [% FOREACH savedreport IN savedreports %]
+ [% UNLESS ( loop.odd ) %][% ELSE %]
[% END %]
+ [% savedreport.id %] |
+ [% savedreport.report_name %] |
+ [% savedreport.type %] |
+ [% savedreport.groupname %] |
+ [% savedreport.subgroupname %] |
+ [% savedreport.notes %] |
+ [% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %]) |
+ [% savedreport.date_created %] |
+ [% IF (savedreport.public) %]
+ Yes |
+ [% ELSE %]
+ No |
+ [% END %]
+ [% IF (usecache) %] [% savedreport.cache_expiry %] | [% END %]
+ [% IF ( savedreport.date_run ) %][% savedreport.date_run %][% END %]
+ |
+
+ Show
+ [% IF ( CAN_user_reports_create_reports ) %]
+ Edit
+ Duplicate
+ [% END %]
+ |
+
+ Run
+ Schedule
+ |
+ [% IF ( CAN_user_reports_create_reports ) %]
+ Delete |
+ [% END %]
+
+ [% END %]
+
+
+
+
[% ELSE %]