From 1e92b9c15e525442bd147c0f44586640c8f38c85 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 2 Aug 2012 16:03:32 +0200 Subject: [PATCH 1/6] 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

- - - - - - - - - - - - - - [% IF (usecache) %] [% END %] - - - - - - - -[% FOREACH savedreport IN savedreports %] -[% UNLESS ( loop.odd ) %][% ELSE %][% END %] - - - - - - - - - -[% IF (savedreport.public) %] - -[% ELSE %] - -[% END %] -[% IF (usecache) %] [% END %] - - - - [% IF ( CAN_user_reports_create_reports ) %] - - [% END %] - -[% END %] - -
IDReport nameTypeAreaGroupSubgroupNotesAuthorCreation datePublicCache expiry (seconds)Saved resultsSaved SQL  
[% 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 %]YesNo[% savedreport.cache_expiry %][% IF ( savedreport.date_run ) %][% savedreport.date_run %][% END %] - - Show - [% IF ( CAN_user_reports_create_reports ) %] -   Edit +
+
Run -ScheduleDelete
+ +
+
+ + +
+ + + + + + + + + + + + + [% IF (usecache) %] [% END %] + + + + + + + + [% FOREACH savedreport IN savedreports %] + [% UNLESS ( loop.odd ) %][% ELSE %][% END %] + + + + + + + + + [% IF (savedreport.public) %] + + [% ELSE %] + + [% END %] + [% IF (usecache) %] [% END %] + + + + [% IF ( CAN_user_reports_create_reports ) %] + + [% END %] + + [% END %] + +
IDReport nameTypeGroupSubgroupNotesAuthorCreation datePublicCache expiry (seconds)Saved resultsSaved SQL  
[% 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 %]YesNo[% savedreport.cache_expiry %][% IF ( savedreport.date_run ) %][% savedreport.date_run %][% END %] + + Show + [% IF ( CAN_user_reports_create_reports ) %] + Edit + Duplicate + [% END %] + + Run + Schedule + Delete
+
+ [% ELSE %]
[% IF (filter_set) %]

No saved reports match your criteria.

@@ -515,31 +642,7 @@ canned reports and writing custom SQL reports.

Save your custom report
  1. - [% IF groups_with_subgroups %] -
  2. -
  3. - [% END %] + [% PROCESS group_and_subgroup_selection %]
@@ -635,31 +738,8 @@ $(document).ready(function() { [% IF ( reportname ) %] [% ELSE %][% END %] - [% IF groups_with_subgroups %] -
  • -
  • - [% END %] + [% PROCESS group_and_subgroup_selection %] + [% IF (public) %]
  • [% ELSE %] @@ -744,11 +824,6 @@ Sub report: @@ -756,31 +831,7 @@ $(document).ready(function() { Edit SQL report
    1. - [% IF groups_with_subgroups %] -
    2. -
    3. - [% END %] +[% PROCESS group_and_subgroup_selection %] [% IF (public) %]
    4. [% ELSE %] @@ -848,43 +899,12 @@ $(document).ready(function() { [% IF ( saved1 ) %]
      -

      Filter

        -
      1. - - -
      2. [% INCLUDE 'date-format.inc' %]
        @@ -920,3 +940,56 @@ $("#column_submit").submit(function() { //]]> [% INCLUDE 'intranet-bottom.inc' %] + + +[% BLOCK group_and_subgroup_selection %] +
      3. + + + + + + + + +
      4. +
      5. + + + + + + + + +
      6. +[% END %] diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl index 23d85a9e2c..0171cb46a0 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}; @@ -735,9 +739,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( @@ -790,13 +794,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 ), }; } @@ -810,3 +818,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); + } + } + } +} From 38082bfd381d2b16118d541d695f1baccea5c2a1 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 21 Nov 2012 10:36:13 -0500 Subject: [PATCH 2/6] Bug 9117 [Follow-up] Reports hierarchies management improvements This patch corrects serveral markup errors in the template introduced by this bug as well as previous patches: unescaped ampersands, missing closing tags, typos. To test, view various stages of the process of viewing or creating guided reports and check the source for validity. Signed-off-by: Julian Maurice Signed-off-by: Katrin Fischer Signed-off-by: Jared Camins-Esakov --- .../modules/reports/guided_reports_start.tt | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) 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 e2a5a19177..99b4871591 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 @@ -315,7 +315,7 @@ canned reports and writing custom SQL reports.

        Show [% IF ( CAN_user_reports_create_reports ) %] Edit - Duplicate + Duplicate [% END %] @@ -375,9 +375,9 @@ canned reports and writing custom SQL reports.

        [% END %] [% IF (public) %] -
      7. +
      8. [% ELSE %] -
      9. +
      10. [% END %] [% IF (usecache) %]
      11. @@ -389,7 +389,7 @@ canned reports and writing custom SQL reports.

      12. [% END %]
      - +
      @@ -537,11 +537,13 @@ canned reports and writing custom SQL reports.

      [% IF ( definitions ) %] -
      Dictionary definitions +
      Dictionary definitions +
      [% FOREACH definition IN definitions %] [% END %]
      [% definition.name %]
      +
      [% END %]
      @@ -741,9 +743,9 @@ $(document).ready(function() { [% PROCESS group_and_subgroup_selection %] [% IF (public) %] -
    5. +
    6. [% ELSE %] -
    7. +
    8. [% END %] [% IF (usecache) %]
    9. @@ -833,9 +835,9 @@ Sub report:
    10. [% PROCESS group_and_subgroup_selection %] [% IF (public) %] -
    11. +
    12. [% ELSE %] -
    13. +
    14. [% END %] [% IF (usecache) %]
    15. @@ -912,6 +914,7 @@ Sub report:
    +
    From fc4cbe6884b456d7877e3116fcc423bd9a919f1e Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 22 Nov 2012 10:48:08 +0100 Subject: [PATCH 3/6] Bug 9117 [Follow-up] Reports hierarchies management improvements This patch avoid javascript bugs when user hasn't 'create_reports' permission (last column is hidden in this case but remains) + fix a typo 'selelcted' > 'selected' Signed-off-by: Katrin Fischer Signed-off-by: Jared Camins-Esakov --- .../prog/en/modules/reports/guided_reports_start.tt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 99b4871591..e542b85bb5 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 @@ -289,7 +289,9 @@ canned reports and writing custom SQL reports.

    Saved results Saved SQL   -   + [% IF ( CAN_user_reports_create_reports ) %] +   + [% END %] @@ -837,7 +839,7 @@ Sub report: [% ELSE %] -
  • +
  • [% END %] [% IF (usecache) %]
  • From 4fad5a7a6ba33d01b3fe2d93a2dbc84c557e564a Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 18 Mar 2013 15:40:02 +0000 Subject: [PATCH 4/6] Bug 9117 [Follow-up] Fix group and subgroup filtering When a group code is contained in another group code (e.g. 'COD' and 'CODE'), filtering on the longest ('CODE') include reports of the smallest ('COD'). Same problem for the subgroups. This patch fixes this. Signed-off-by: Katrin Fischer Signed-off-by: Jared Camins-Esakov --- .../prog/en/modules/reports/guided_reports_start.tt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 e542b85bb5..855fc36970 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 @@ -95,7 +95,7 @@ $(document).ready(function(){ 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.fnFilter('^' + g_name + '$', 3, true, true, true, false); rtable.fnSetColumnVis(3, false); for(var i in group_subgroups[g_id]) { $("#subgroup_filter").append( @@ -115,7 +115,7 @@ $(document).ready(function(){ var sg_id = $(selected).val(); var sg_name = $(selected).text(); if (sg_id.length > 0) { - rtable.fnFilter(sg_name, 4); + rtable.fnFilter('^' + sg_name + '$', 4, true, true, true, false); rtable.fnSetColumnVis(4, false); } else { rtable.fnFilter('', 4); From d00f21833abe9eca649ef4c1e7a5f3b36bbf78e0 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 18 Mar 2013 15:50:30 +0000 Subject: [PATCH 5/6] Bug 9117 [Follow-up] Translatable string should be in double quotes Signed-off-by: Katrin Fischer All tests and QA script pass. Tests done: - Created several reports fresh and using the new duplicate feature. - Verified authorized values were created correctly and can be viewed from Administration > authorized values. - Checked tabs and limiting on subgroups works correctly. Signed-off-by: Jared Camins-Esakov --- .../prog/en/modules/reports/guided_reports_start.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 855fc36970..330a7cda49 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 @@ -76,7 +76,7 @@ $(document).ready(function(){ { 'bSearchable': false, 'aTargets': [3, 4] } ], 'oLanguage': { - 'sZeroRecords': _('No matching reports found') + 'sZeroRecords': _("No matching reports found") } })); From 8eae0c2a67c92fe1459486d1f50ccd3fdc646019 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 21 Mar 2013 14:47:37 +0000 Subject: [PATCH 6/6] Bug 9117: Add imageurl to the list of parameters of AddAuthorisedValue and add unit test in t/db_dependant/Koha.t Signed-off-by: Jared Camins-Esakov --- C4/Koha.pm | 10 +++++----- t/db_dependent/Koha.t | 8 +++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 13ab94a978..6869ab0778 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -1229,22 +1229,22 @@ sub GetKohaAuthorisedValueLib { =head2 AddAuthorisedValue - AddAuthorisedValue($category, $authorised_value, $lib, $lib_opac); + AddAuthorisedValue($category, $authorised_value, $lib, $lib_opac, $imageurl); Create a new authorised value. =cut sub AddAuthorisedValue { - my ($category, $authorised_value, $lib, $lib_opac) = @_; + my ($category, $authorised_value, $lib, $lib_opac, $imageurl) = @_; my $dbh = C4::Context->dbh; my $query = qq{ - INSERT INTO authorised_values (category, authorised_value, lib, lib_opac) - VALUES (?,?,?,?) + INSERT INTO authorised_values (category, authorised_value, lib, lib_opac, imageurl) + VALUES (?,?,?,?,?) }; my $sth = $dbh->prepare($query); - $sth->execute($category, $authorised_value, $lib, $lib_opac); + $sth->execute($category, $authorised_value, $lib, $lib_opac, $imageurl); } =head2 display_marc_indicators diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t index aea5245f50..1a68c7d9dc 100644 --- a/t/db_dependent/Koha.t +++ b/t/db_dependent/Koha.t @@ -32,9 +32,7 @@ subtest 'Authorized Values Tests' => sub { # Insert an entry into authorised_value table - my $query = "INSERT INTO authorised_values (category, authorised_value, lib, lib_opac, imageurl) VALUES (?,?,?,?,?);"; - my $sth = $dbh->prepare($query); - my $insert_success = $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); + my $insert_success = AddAuthorisedValue($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); ok($insert_success, "Insert data in database"); @@ -57,8 +55,8 @@ subtest 'Authorized Values Tests' => sub { # Clean up if($insert_success){ - $query = "DELETE FROM authorised_values WHERE category=? AND authorised_value=? AND lib=? AND lib_opac=? AND imageurl=?;"; - $sth = $dbh->prepare($query); + my $query = "DELETE FROM authorised_values WHERE category=? AND authorised_value=? AND lib=? AND lib_opac=? AND imageurl=?;"; + my $sth = $dbh->prepare($query); $sth->execute($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); } };