Bugzilla – Attachment 184516 Details for
Bug 16631
Show groups/categories of reports to authorized staff
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Bug 16631: 0009-Get-selected-reports-and-save-selected-reports-from-
0009-Get-selected-reports-and-save-selected-reports-from-.patch (text/plain), 9.15 KB, created by
Casey Conlin
on 2025-07-22 22:03:09 UTC
(
hide
)
Description:
Bug 16631: 0009-Get-selected-reports-and-save-selected-reports-from-
Filename:
MIME Type:
Creator:
Casey Conlin
Created:
2025-07-22 22:03:09 UTC
Size:
9.15 KB
patch
obsolete
>From a728ba47cf381fda8100d893a16ad5d704ef5323 Mon Sep 17 00:00:00 2001 >From: Casey Conlin <101153261+CaseyConlin@users.noreply.github.com> >Date: Sat, 12 Jul 2025 12:53:20 -0400 >Subject: [PATCH 09/16] Get selected reports and save selected reports from > edit screen working. > >--- > .../modules/reports/guided_reports_start.tt | 29 +++++------ > reports/guided_reports.pl | 49 ++++++++++++++++--- > 2 files changed, 54 insertions(+), 24 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 56989e0106..07fe927347 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 >@@ -3,6 +3,7 @@ > [% USE AuthorisedValues %] > [% USE KohaDates %] > [% USE Koha %] >+[% USE Branches %] > [% USE TablesSettings %] > [% USE HtmlScrubber %] > [% USE JSON.Escape %] >@@ -850,6 +851,7 @@ > <input type="hidden" name="reportname" value="[% reportname | html %]" /> > <input type="hidden" name="group" value="[% group | html %]" /> > <input type="hidden" name="subgroup" value="[% subgroup | html %]" /> >+ <input type="hidden" name="branches" value="[% branches | html %] /> > <input type="hidden" name="notes" value="[% notes | scrub_html type => 'note' | $raw %]" /> > <input type="hidden" name="cache_expiry" value="[% cache_expiry | html %]" /> > <input type="hidden" name="cache_expiry_units" value="[% cache_expiry_units | html %]" /> >@@ -1553,28 +1555,19 @@ > <legend>Library limitation:</legend> > <div > ><label for="library_limitation">Library limitation: </label> >- [% IF branches_loop.size %] >- <span class="label"> </span> >- <div> >- <select id="library_limitation" name="branches" multiple size="10"> >- <option value="">(no library)</option> >- [% FOREACH branch IN branches_loop %] >- [% IF ( basketbranchcode == branch.branchcode ) %] >- <option selected="selected" value="[% branch.branchcode | html %]"> [% branch.branchname | html %]</option> >- [% ELSE %] >- <option value="[% branch.branchcode | html %]"> [% branch.branchname | html %]</option> >- [% END %] >- [% END %] >- </select> >- </div> >- <!-- #/managing_library_entry --> >- [% END # /IF branches_loop.size %] >- [% PROCESS options_for_libraries libraries => Branches.all( selected => savedreport.savedsql.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %] >+ <select id="library_limitation" name="branches" multiple size="10"> >+ [% FOREACH branch IN branches_loop %] >+ [% IF ( branch.selected ) %] >+ <option selected="selected" value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option> >+ [% ELSE %] >+ <option value="[% branch.branchcode | html %]">[% branch.branchname | html %]</option> >+ [% END %] >+ [% END %] > </select> > <div class="hint">Limits the use of this report to the selected libraries.</div> > </div> > </fieldset> >- [% END %] >+ [% END %] > <fieldset class="action"> > <button class="btn btn-primary" type="submit" name="op" value="cud-update_sql">Update SQL</button> > <button class="btn btn-default" type="submit" name="op" value="cud-update_and_run_sql">Update and run SQL</button> >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index fbd2d105df..d5834bfb76 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -42,6 +42,7 @@ use Koha::Notice::Templates; > use Koha::TemplateUtils qw( process_tt ); > use C4::ClassSource qw( GetClassSources ); > use C4::Scrubber; >+use Data::Dumper; > > =head1 NAME > >@@ -56,8 +57,9 @@ Script to control the guided report creation > my $input = CGI->new; > my $usecache = Koha::Caches->get_instance->memcached_cache; > >-my $op = $input->param('op') // ''; >-my @branches = grep { $_ ne q{} } $input->multi_param('branches'); >+my $op = $input->param('op') // ''; >+ >+# my @branches = grep { $_ ne q{} } $input->multi_param('branches'); > my $flagsrequired; > if ( ( $op eq 'add_form' ) > || ( $op eq 'add_form_sql' ) >@@ -172,6 +174,22 @@ if ( !$op ) { > }; > } > >+ # my $selected_branches = $report ? $report->get_library_limits : undef; >+ # my $branches = Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed; >+ # my @branches_loop; >+ # foreach my $branch (@$branches) { >+ # my $selected = >+ # ( $selected_branches && grep { $_->branchcode eq $branch->{branchcode} } @{ $selected_branches->as_list } ) >+ # ? 1 >+ # : 0; >+ # push @branches_loop, >+ # { >+ # branchcode => $branch->{branchcode}, >+ # branchname => $branch->{branchname}, >+ # selected => $selected, >+ # }; >+ # } >+ > $template->param( > 'sql' => $report->savedsql, > 'reportname' => $report->report_name, >@@ -185,11 +203,14 @@ if ( !$op ) { > 'mana_id' => $report->{mana_id}, > 'mana_comments' => $report->{comments}, > 'tables' => $tables, >- 'branches_loop' => \@branches_loop >+ >+ # 'branches' => $report->get_library_limits ? $report->get_library_limits->as_list : [], >+ 'branches_loop' => \@branches_loop > ); > > } elsif ( $op eq 'cud-update_sql' || $op eq 'cud-update_and_run_sql' ) { > my $id = $input->param('id'); >+ my $report = Koha::Reports->find($id); > my $sql = $input->param('sql'); > my $reportname = $input->param('reportname'); > my $group = $input->param('group'); >@@ -200,9 +221,20 @@ if ( !$op ) { > my $public = $input->param('public'); > my $save_anyway = $input->param('save_anyway'); > my @errors; >- my $tables = get_tables(); >- >+ my $tables = get_tables(); >+ my @branches = grep { $_ ne q{} } $input->multi_param('branches'); >+ >+ # use Data::Dumper; >+ # warn Dumper(\@branches); >+ # warn "hey"; >+ # warn "DEBUG branches: " . Dumper(\@branches); >+ # print STDERR "DEBUG branches: " . join(", ", @branches); >+ # my $libraries = $report->get_library_limits; >+ # my $stuff = $libraries ? $libraries->as_list : []; >+ # print STDERR "DEBUG stuff: " . Dumper(@branches); > # if we have the units, then we came from creating a report from SQL and thus need to handle converting units >+ # $report->store; >+ # $report->replace_library_limits( \@branches ); > if ($cache_expiry_units) { > if ( $cache_expiry_units eq "minutes" ) { > $cache_expiry *= 60; >@@ -248,6 +280,7 @@ if ( !$op ) { > 'problematic_authvals' => $problematic_authvals, > 'warn_authval_problem' => 1, > 'phase_update' => 1, >+ 'branches' => @branches, > ); > > } else { >@@ -266,6 +299,9 @@ if ( !$op ) { > } > ); > >+ $report->store; >+ $report->replace_library_limits( \@branches ); >+ > my $editsql = 1; > if ( $op eq 'cud-update_and_run_sql' ) { > $editsql = 0; >@@ -282,7 +318,8 @@ if ( !$op ) { > 'cache_expiry' => $cache_expiry, > 'public' => $public, > 'usecache' => $usecache, >- 'tables' => $tables >+ 'tables' => $tables, >+ 'branches' => @branches, > ); > logaction( "REPORTS", "MODIFY", $id, "$reportname | $sql" ) if C4::Context->preference("ReportsLog"); > } >-- >2.39.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 Raw
Actions:
View
Attachments on
bug 16631
:
184422
|
184508
|
184509
|
184510
|
184511
|
184512
|
184513
|
184514
|
184515
|
184516
|
184517
|
184518
|
184519
|
184520
|
184521
|
184522
|
184525
|
184526
|
184657
|
184674
|
184686
|
184687
|
184688
|
184689
|
184690
|
184691
|
184692
|
184693
|
184694
|
184695
|
184845
|
184846
|
184847
|
184848
|
184859
|
184861