Bugzilla – Attachment 13560 Details for
Bug 9117
Reports hierarchies management improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9117: Reports hierarchies management improvements
Bug-9117-Reports-hierarchies-management-improvemen.patch (text/plain), 27.79 KB, created by
Julian Maurice
on 2012-11-20 15:34:01 UTC
(
hide
)
Description:
Bug 9117: Reports hierarchies management improvements
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2012-11-20 15:34:01 UTC
Size:
27.79 KB
patch
obsolete
>From fe7eb3c35a3886ec230c19b25fa7f8878bd699ba Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >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) >--- > C4/Koha.pm | 21 + > .../en/modules/reports/guided_reports_start.tt | 459 +++++++++++--------- > reports/guided_reports.pl | 42 ++- > 3 files changed, 315 insertions(+), 207 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index d38729a..b90502b 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -63,6 +63,7 @@ BEGIN { > &GetAuthorisedValueByCode > &GetKohaImageurlFromAuthorisedValues > &GetAuthValCode >+ &AddAuthorisedValue > &GetNormalizedUPC > &GetNormalizedISBN > &GetNormalizedEAN >@@ -1202,6 +1203,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 fa0ae38..60927ed 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 >@@ -14,36 +14,107 @@ > [% END %] > [% END %] > </title> >+<link rel="stylesheet" href="[% themelang %]/css/datatables.css" /> > [% INCLUDE 'doc-head-close.inc' %] > [% INCLUDE 'calendar.inc' %] > <style type="text/css"> > #sql { width: 90%; height: 9em;} > </style> >-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.pager.js"></script> >- >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> >+[% INCLUDE 'datatables-strings.inc' %] >+<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> > <script type="text/javascript"> > //<![CDATA[ > 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('<option value="">' + no_subgroup_label + '</option>'); >+ $(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; >- $('<option value="' + value[0] + '">' + value[1] + '</option>').appendTo(sg); >+ $('<option value="' + value[0] + '">' + value[1] + '</option>').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', >+ '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( >+ '<option value="' + group_subgroups[g_id][i][0] + '">' >+ + group_subgroups[g_id][i][1] + '</option>' >+ ); >+ } >+ $("#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(); >@@ -60,25 +131,56 @@ $(document).ready(function(){ > } > }); > [% END %] >- // call the tablesorter plugin >- $("#table_reports").tablesorter({ >- widgets : ['zebra'], >- sortList: [[1,0]], >- headers: { >- 6: { sorter: false}, >- 7: { sorter: false}, >- 8: { sorter: false}, >- 9: { sorter: false}, >- 10: { sorter: false} >- } >- }).tablesorterPager({ >- container: $("#pagertable_reports"), >- positionFixed: false, >- size: 20 >- }); > // 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 %] > }); > //]]> > </script> >@@ -148,65 +250,78 @@ canned reports and writing custom SQL reports.</p> > [% IF ( saved1 ) %] > [% IF ( savedreports ) %]<h1>Saved reports</h1> > >-<div id="pagertable_reports"> >-[% INCLUDE 'table-pager.inc' perpage='20' %] >-</div> >- >-<table id="table_reports" class="tablesorter"> >-<thead> >- <tr> >- <th>ID</th> >- <th>Report name</th> >- <th>Type</th> >- <th>Area</th> >- <th>Group</th> >- <th>Subgroup</th> >- <th>Notes</th> >- <th>Author</th> >- <th>Creation date</th> >- <th>Public</th> >- [% IF (usecache) %] <th>Cache expiry (seconds)</th> [% END %] >- <th>Saved results</th> >- <th>Saved SQL</th> >- <th> </th> >- <th> </th> >- </tr> >-</thead> >-<tbody> >-[% FOREACH savedreport IN savedreports %] >-[% UNLESS ( loop.odd ) %]<tr class="odd">[% ELSE %]<tr>[% END %] >-<td>[% savedreport.id %]</td> >-<td>[% savedreport.report_name %]</td> >-<td>[% savedreport.type %]</td> >-<td>[% savedreport.areaname %]</td> >-<td>[% savedreport.groupname %]</td> >-<td>[% savedreport.subgroupname %]</td> >-<td>[% savedreport.notes %]</td> >-<td>[% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %])</td> >-<td>[% savedreport.date_created %]</td> >-[% IF (savedreport.public) %] >-<td>Yes</td> >-[% ELSE %] >-<td>No</td> >-[% END %] >-[% IF (usecache) %] <td>[% savedreport.cache_expiry %]</td> [% END %] >-<td>[% IF ( savedreport.date_run ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&id=[% savedreport.id %]">[% savedreport.date_run %]</a>[% END %] >-</td> >- <td> >- <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&phase=Show%20SQL">Show</a> >- [% IF ( CAN_user_reports_create_reports ) %] >- <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&phase=Edit%20SQL">Edit</a> >+<div id="tabs" class="toptabs"> >+ <ul> >+ <li><a href="#reports">All</a></li> >+ [% FOREACH group IN groups_with_subgroups %] >+ <li><a id="[% group.id %]" href="#reports">[% group.name %]</a></li> > [% END %] >- </td> >-<td><a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&phase=Run%20this%20report">Run</a> >-<a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id %]">Schedule</a></td> >- [% IF ( CAN_user_reports_create_reports ) %] >- <td><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&phase=Delete%20Saved">Delete</a></td> >- [% END %] >-</tr> >-[% END %] >-</tbody> >-</table> >+ </ul> >+ <div id="reports"> >+ <div id="subgroup_filter_block"> >+ <label for="subgroup_filter">Subgroup:</label> >+ <select id="subgroup_filter"> >+ <option value="">All</option> >+ </select> >+ </div> >+ <table id="table_reports"> >+ <thead> >+ <tr> >+ <th>ID</th> >+ <th>Report name</th> >+ <th>Type</th> >+ <th>Group</th> >+ <th>Subgroup</th> >+ <th>Notes</th> >+ <th>Author</th> >+ <th>Creation date</th> >+ <th>Public</th> >+ [% IF (usecache) %] <th>Cache expiry (seconds)</th> [% END %] >+ <th>Saved results</th> >+ <th>Saved SQL</th> >+ <th> </th> >+ <th> </th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH savedreport IN savedreports %] >+ <tr> >+ <td>[% savedreport.id %]</td> >+ <td>[% savedreport.report_name %]</td> >+ <td>[% savedreport.type %]</td> >+ <td>[% savedreport.groupname %]</td> >+ <td>[% savedreport.subgroupname %]</td> >+ <td>[% savedreport.notes %]</td> >+ <td>[% savedreport.borrowersurname %][% IF ( savedreport.borrowerfirstname ) %], [% savedreport.borrowerfirstname %][% END %] ([% savedreport.borrowernumber %])</td> >+ <td>[% savedreport.date_created %]</td> >+ [% IF (savedreport.public) %] >+ <td>Yes</td> >+ [% ELSE %] >+ <td>No</td> >+ [% END %] >+ [% IF (usecache) %] <td>[% savedreport.cache_expiry %]</td> [% END %] >+ <td>[% IF ( savedreport.date_run ) %]<a href="/cgi-bin/koha/reports/guided_reports.pl?phase=retrieve%20results&id=[% savedreport.id %]">[% savedreport.date_run %]</a>[% END %] >+ </td> >+ <td> >+ <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&phase=Show%20SQL">Show</a> >+ [% IF ( CAN_user_reports_create_reports ) %] >+ <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&phase=Edit%20SQL">Edit</a> >+ <a title="Duplicate this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Create report from SQL&sql=[% savedreport.savedsql |uri %]&reportname=[% savedreport.report_name |uri %]¬es=[% savedreport.notes |uri %]">Duplicate</a> >+ [% END %] >+ </td> >+ <td> >+ <a href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&phase=Run%20this%20report">Run</a> >+ <a href="/cgi-bin/koha/tools/scheduler.pl?id=[% savedreport.id %]">Schedule</a> >+ </td> >+ [% IF ( CAN_user_reports_create_reports ) %] >+ <td><a class="confirmdelete" title="Delete this saved report" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% savedreport.id %]&phase=Delete%20Saved">Delete</a></td> >+ [% END %] >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ </div> >+</div> > [% ELSE %]<div class="dialog message"> > [% IF (filter_set) %] > <h4>No saved reports match your criteria. </h4> >@@ -518,31 +633,7 @@ canned reports and writing custom SQL reports.</p> > <legend>Save your custom report</legend> > <ol> > <li><label for="reportname">Report name: </label><input type="text" id="reportname" name="reportname" /></li> >- [% IF groups_with_subgroups %] >- <li><label for="group">Report group: </label><select name="group" id="group" onChange="load_group_subgroups();"> >- [% FOR g IN groups_with_subgroups %] >- [% IF g.selected %] >- <option value="[% g.id %]" selected>[% g.name %]</option> >- [% ELSE %] >- <option value="[% g.id %]">[% g.name %]</option> >- [% END %] >- <script type="text/javascript"> >- var g_sg = new Array(); >- [% FOR sg IN g.subgroups %] >- g_sg.push(["[% sg.id %]", "[% sg.name %]"]); >- [% IF sg.selected %] >- $(document).ready(function() { >- $("#subgroup").val("[% sg.id %]"); >- }); >- [% END %] >- [% END %] >- group_subgroups["[% g.id %]"] = g_sg; >- </script> >- [% END %] >- </select></li> >- <li><label for="subgroup">Report subgroup: </label><select name="subgroup" id="subgroup"> >- </select></li> >- [% END %] >+ [% PROCESS group_and_subgroup_selection %] > <li><label for="notes">Notes:</label> <textarea name="notes" id="notes"></textarea></li> > </ol></fieldset> > <fieldset class="action"><input type="hidden" name="phase" value="Save Report" /> >@@ -618,31 +709,8 @@ $(document).ready(function() { > [% IF ( reportname ) %]<input type="text" id="reportname" name="reportname" value="[% reportname %]" /> > [% ELSE %]<input type="text" id="reportname" name="reportname" />[% END %] > </li> >- [% IF groups_with_subgroups %] >- <li><label for="group">Report group: </label><select name="group" id="group" onChange="load_group_subgroups();"> >- [% FOR g IN groups_with_subgroups %] >- [% IF g.selected %] >- <option value="[% g.id %]" selected>[% g.name %]</option> >- [% ELSE %] >- <option value="[% g.id %]">[% g.name %]</option> >- [% END %] >- <script type="text/javascript"> >- var g_sg = new Array(); >- [% FOR sg IN g.subgroups %] >- g_sg.push(["[% sg.id %]", "[% sg.name %]"]); >- [% IF sg.selected %] >- $(document).ready(function() { >- $("#subgroup").val("[% sg.id %]"); >- }); >- [% END %] >- [% END %] >- group_subgroups["[% g.id %]"] = g_sg; >- </script> >- [% END %] >- </select></li> >- <li><label for="subgroup">Report subgroup: </label><select name="subgroup" id="subgroup"> >- </select></li> >- [% END %] >+ [% PROCESS group_and_subgroup_selection %] >+ > [% IF (public) %] > <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0">No (default)</option> <option value="1" selected="selected">Yes</public> </select></li> > [% ELSE %] >@@ -727,11 +795,6 @@ Sub report:<select name="subreport"> > [% END %] > > [% IF ( editsql ) %] >-<script type="text/javascript"> >-$(document).ready(function() { >- load_group_subgroups(); >-}); >-</script> > <form action="/cgi-bin/koha/reports/guided_reports.pl" method="post"> > <input type="hidden" name="phase" value="Update SQL" /> > <input type="hidden" name="id" value="[% id %]"/> >@@ -739,31 +802,7 @@ $(document).ready(function() { > <legend>Edit SQL report</legend> > <ol> > <li><label for="reportname">Report name:</label><input type="text" id="reportname" name="reportname" value="[% reportname %]" size="50" /></li> >- [% IF groups_with_subgroups %] >- <li><label for="group">Report group: </label><select name="group" id="group" onChange="load_group_subgroups();"> >- [% FOR g IN groups_with_subgroups %] >- [% IF g.selected %] >- <option value="[% g.id %]" selected>[% g.name %]</option> >- [% ELSE %] >- <option value="[% g.id %]">[% g.name %]</option> >- [% END %] >- <script type="text/javascript"> >- var g_sg = new Array(); >- [% FOR sg IN g.subgroups %] >- g_sg.push(["[% sg.id %]", "[% sg.name %]"]); >- [% IF sg.selected %] >- $(document).ready(function() { >- $("#subgroup").val("[% sg.id %]"); >- }); >- [% END %] >- [% END %] >- group_subgroups["[% g.id %]"] = g_sg; >- </script> >- [% END %] >- </select></li> >- <li><label for="subgroup">Report subgroup: </label><select name="subgroup" id="subgroup"> >- </select></li> >- [% END %] >+[% PROCESS group_and_subgroup_selection %] > [% IF (public) %] > <li><label for="public">Report is public:</label><select id="public" name="public"> <option value="0">No (default)</option> <option value="1" selected="selected">Yes</public> </select></li> > [% ELSE %] >@@ -831,43 +870,12 @@ $(document).ready(function() { > > [% IF ( saved1 ) %] > <div id="saved-reports-filter"> >-<script type="text/javascript"> >-$(document).ready(function() { >- no_subgroup_label = _( "-- All --" ); >- load_group_subgroups(); >-}); >-</script> > <form action="/cgi-bin/koha/reports/guided_reports.pl" method="get"> > <input type="hidden" name="phase" value="Use saved" /> > <input type="hidden" name="filter_set" value="1" /> > <fieldset class="brief"> > <h3>Filter</h3> > <ol> >- <li><label for="group">Choose Group and Subgroup: </label> >- <select name="group" id="group" onChange="load_group_subgroups();"> >- <option value="">-- All --</option> >- [% FOR g IN groups_with_subgroups %] >- [% IF g.selected %] >- <option value="[% g.id %]" selected>[% g.name %]</option> >- [% ELSE %] >- <option value="[% g.id %]">[% g.name %]</option> >- [% END %] >- <script type="text/javascript"> >- var g_sg = new Array(); >- [% FOR sg IN g.subgroups %] >- g_sg.push(["[% sg.id %]", "[% sg.name %]"]); >- [% IF sg.selected %] >- $(document).ready(function() { >- $("#subgroup").val("[% sg.id %]"); >- }); >- [% END %] >- [% END %] >- group_subgroups["[% g.id %]"] = g_sg; >- </script> >- [% END %] >- </select> >- <select name="subgroup" id="subgroup"></select> >- </li> > <li><label for="filter_date">Date:</label> <input type="text" id="filter_date" name="filter_date" size="10" value="[% filter_date %]" class="datepicker" /> > <div class="hint">[% INCLUDE 'date-format.inc' %]</div> > >@@ -903,3 +911,56 @@ $("#column_submit").submit(function() { > //]]> > </script> > [% INCLUDE 'intranet-bottom.inc' %] >+ >+ >+[% BLOCK group_and_subgroup_selection %] >+ <li id="group"> >+ <label>Report group:</label> >+ <input type="radio" name="select_or_create_group" >+ id="select_group" checked="checked" /> >+ <label for="select_group" style="float:none">Select</label> >+ <select name="group" onChange="load_group_subgroups();" id="group_select"> >+ <option value="">(None)</option> >+ [% FOREACH group IN groups_with_subgroups %] >+ [% IF (group.selected) %] >+ <option value="[% group.id %]" selected="selected"> >+ [% ELSE %] >+ <option value="[% group.id %]"> >+ [% END %] >+ [% group.name %] >+ </option> >+ [% END %] >+ </select> >+ <input type="radio" name="select_or_create_group" id="create_group" /> >+ <label for="create_group" style="float:none">or create</label> >+ <input type="text" name="group" id="group_input" title="Group code" placeholder="Code" /> >+ <input type="text" name="groupdesc" id="groupdesc_input" title="Group name" placeholder="Name" /> >+ </li> >+ <li id="subgroup"> >+ <label>Report subgroup:</label> >+ <input type="radio" name="select_or_create_subgroup" >+ id="select_subgroup" checked="checked" /> >+ <label for="select_subgroup" style="float:none">Select</label> >+ <select name="subgroup" id="subgroup_select"> >+ <option value="">(None)</option> >+ [% FOREACH group IN groups_with_subgroups %] >+ [% IF (group.selected) %] >+ [% FOREACH subgroup IN group.subgroups %] >+ [% IF (subgroup.selected) %] >+ <option value="[% subgroup.id %]" selected="selected"> >+ [% ELSE %] >+ <option value="[% subgroup.id %]"> >+ [% END %] >+ [% subgroup.name %] >+ </option> >+ [% END %] >+ [% END %] >+ [% END %] >+ </select> >+ <input type="radio" name="select_or_create_subgroup" >+ id="create_subgroup" /> >+ <label for="create_subgroup" style="float:none">or create</label> >+ <input type="text" name="subgroup" id="subgroup_input" title="Subgroup code" placeholder="Code" /> >+ <input type="text" name="subgroupdesc" id="subgroupdesc_input" title="Subgroup name" placeholder="Name" /> >+ </li> >+[% END %] >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index de18072..ed9aa6e 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -17,8 +17,6 @@ > # with Koha; if not, write to the Free Software Foundation, Inc., > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > >-use strict; >-use warnings; > > use CGI; > use Text::CSV; >@@ -106,6 +104,7 @@ elsif ( $phase eq 'Build new' ) { > 'savedreports' => get_saved_reports($filter), > 'usecache' => $usecache, > 'groups_with_subgroups'=> groups_with_subgroups($group, $subgroup), >+ dateformat => C4::Context->preference('dateformat'), > ); > } > >@@ -178,6 +177,8 @@ elsif ( $phase eq 'Update SQL'){ > push @errors, {cache_expiry => $cache_expiry}; > } > >+ create_non_existing_group_and_subgroup($input, $group, $subgroup); >+ > if ($sql =~ /;?\W?(UPDATE|DELETE|DROP|INSERT|SHOW|CREATE)\W/i) { > push @errors, {sqlerr => $1}; > } >@@ -482,6 +483,9 @@ elsif ( $phase eq 'Save Report' ) { > if( $cache_expiry && $cache_expiry >= 2592000 ){ > push @errors, {cache_expiry => $cache_expiry}; > } >+ >+ create_non_existing_group_and_subgroup($input, $group, $subgroup); >+ > ## FIXME this is AFTER entering a name to save the report under > if ($sql =~ /;?\W?(UPDATE|DELETE|DROP|INSERT|SHOW|CREATE)\W/i) { > push @errors, {sqlerr => $1}; >@@ -730,9 +734,9 @@ elsif ( $phase eq 'Create report from SQL' ) { > $group = $input->param('report_group'); > $subgroup = $input->param('report_subgroup'); > $template->param( >- 'sql' => $input->param('sql'), >- 'reportname' => $input->param('reportname'), >- 'notes' => $input->param('notes'), >+ 'sql' => $input->param('sql') // '', >+ 'reportname' => $input->param('reportname') // '', >+ 'notes' => $input->param('notes') // '', > ); > } > $template->param( >@@ -786,13 +790,17 @@ sub groups_with_subgroups { > > my $groups_with_subgroups = get_report_groups(); > my @g_sg; >- while (my ($g_id, $v) = each %$groups_with_subgroups) { >+ my @sorted_keys = sort { >+ $groups_with_subgroups->{$a}->{name} cmp $groups_with_subgroups->{$b}->{name} >+ } keys %$groups_with_subgroups; >+ foreach my $g_id (@sorted_keys) { >+ my $v = $groups_with_subgroups->{$g_id}; > my @subgroups; > if (my $sg = $v->{subgroups}) { >- while (my ($sg_id, $n) = each %$sg) { >+ foreach my $sg_id (sort { $sg->{$a} cmp $sg->{$b} } keys %$sg) { > push @subgroups, { > id => $sg_id, >- name => $n, >+ name => $sg->{$sg_id}, > selected => ($group && $g_id eq $group && $subgroup && $sg_id eq $subgroup ), > }; > } >@@ -806,3 +814,21 @@ sub groups_with_subgroups { > } > return \@g_sg; > } >+ >+sub create_non_existing_group_and_subgroup { >+ my ($input, $group, $subgroup) = @_; >+ >+ if (defined $group and $group ne '') { >+ my $report_groups = C4::Reports::Guided::get_report_groups; >+ if (not exists $report_groups->{$group}) { >+ my $groupdesc = $input->param('groupdesc') // $group; >+ C4::Koha::AddAuthorisedValue('REPORT_GROUP', $group, $groupdesc); >+ } >+ if (defined $subgroup and $subgroup ne '') { >+ if (not exists $report_groups->{$group}->{subgroups}->{$subgroup}) { >+ my $subgroupdesc = $input->param('subgroupdesc') // $subgroup; >+ C4::Koha::AddAuthorisedValue('REPORT_SUBGROUP', $subgroup, $subgroupdesc, $group); >+ } >+ } >+ } >+} >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9117
:
13560
|
13578
|
13597
|
13627
|
13628
|
13931
|
14668
|
14669
|
14670
|
16241
|
16244
|
16246
|
16270
|
16271
|
16282
|
16283
|
16284
|
16285
|
16286
|
16287
|
16288
|
16290
|
16292
|
16293
|
16294
|
16295
|
16296
|
16653