Bugzilla – Attachment 176102 Details for
Bug 36585
Report 'Patrons with the most checkouts' doesn't have the total when outputting to CSV
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36585: Improve 'Patrons with the most checkouts' report
Bug-36585-Improve-Patrons-with-the-most-checkouts-.patch (text/plain), 7.61 KB, created by
Lisette Scheer
on 2025-01-02 19:05:18 UTC
(
hide
)
Description:
Bug 36585: Improve 'Patrons with the most checkouts' report
Filename:
MIME Type:
Creator:
Lisette Scheer
Created:
2025-01-02 19:05:18 UTC
Size:
7.61 KB
patch
obsolete
>From f247eeb752868c58baaedd75cde4114a16af37b7 Mon Sep 17 00:00:00 2001 >From: Michael Hafen <michael.hafen@washk12.org> >Date: Thu, 11 Apr 2024 16:33:39 -0600 >Subject: [PATCH] Bug 36585: Improve 'Patrons with the most checkouts' report > >Update the 'Patrons with the most checkouts' report (bor_issues_top.pl) >to: >1. Add the total to the CSV output. >2. Change the screen output to only show the patrons name once, instead > of for each group by column. >3. Add total check out when output to screen. >4. Change item type group by from biblioitems.itemtype to items.itype. > >Note: This does not fix the SQL query so that it can run if the >database is in strict mode. > >Test plan: >1. If using koha-testing-docker (KTD), set strict SQL mode for your > database to 0 (that is, turn it off). > (Edit <strict_sql_modes>0</strict_sql_modes> in > /etc/koha/sites/kohadev/koha-conf.xml > (and then flush_memcached and restart_all)) >2. Add some data so that a useful report can be generated: > . Check out and return some items to different patrons in different > libraries: > ==> Minimum end result: > . two items issued to a patron for one library, 1 item issued > and returned for the same patron at another library > . one item issued to another patron from another patron > category for one of the libraries used previously >3. Generate the report with output to screen with a group by, for > example: 'By' option set to Category code >4. Observe that the patron name is repeated for each column group. >5. Observe that there is no total column. >6. Generate the report with output to CSV. >7. Observe that the total checkouts is not in the CSV. >8. Apply the patch and restart Koha (restart_all). >9. Generate the CSV report again. >10. Observe that the total checkouts is in the CSV. >11. Generate the report to screen again. >12. Observe that there is a total column and the patron name is only > shown in one column. > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com> >--- > .../prog/en/modules/reports/bor_issues_top.tt | 15 +++--- > reports/bor_issues_top.pl | 50 +++++++++++-------- > 2 files changed, 36 insertions(+), 29 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt >index 0c429f02feb..702b93c096f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/bor_issues_top.tt >@@ -87,13 +87,14 @@ > <table> > <tr> > <th rowspan="2">Rank</th> >+ <th rowspan="2">Patron</th> >+ <th rowspan="2">Total</th> > [% FOREACH loopco IN mainloo.loopcol %] >- <th colspan="2">[% loopco.coltitle | html %]</th> >+ <th>[% loopco.coltitle | html %]</th> > [% END %] > </tr> > <tr> > [% FOREACH loopco IN mainloo.loopcol %] >- <th>Patron</th> > <th>Checkout count</th> > [% END %] > </tr> >@@ -101,13 +102,13 @@ > <tr> > [% IF ( loopro.hilighted ) %]<td>[% ELSE %]<td>[% END %] > [% loopro.rowtitle | html %]</td> >+ [% IF ( loopro.hilighted ) %]<td>[% ELSE %]<td>[% END %] >+ [% IF ( loopro.reference ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loopro.reference | uri %]">[% END %] >+ [% IF ( loopro.patron ) %][% loopro.patron | html %][% END %] >+ [% IF ( loopro.reference ) %]</a>[% END %] >+ </td> > [% FOREACH loopcel IN loopro.loopcell %] > [% IF ( loopcel.hilighted ) %]<td>[% ELSE %]<td>[% END %] >- [% IF ( loopcel.reference ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loopcel.reference | uri %]">[% END %] >- [% IF ( loopcel.value ) %][% loopcel.value | html %][% END %] >- [% IF ( loopcel.reference ) %]</a>[% END %] >- </td> >- [% IF ( loopcel.hilighted ) %]<td>[% ELSE %]<td>[% END %] > [% IF ( loopcel.count ) %][% loopcel.count | html %][% END %] > </td> > [% END %] >diff --git a/reports/bor_issues_top.pl b/reports/bor_issues_top.pl >index 439db23810f..617b3c97034 100755 >--- a/reports/bor_issues_top.pl >+++ b/reports/bor_issues_top.pl >@@ -68,23 +68,25 @@ if ($do_it) { > -filename=>"$basename.csv" ); > my $cols = @$results[0]->{loopcol}; > my $lines = @$results[0]->{looprow}; >-# header top-right >+# header top-left > print @$results[0]->{line} ."/". @$results[0]->{column} .$sep; >+ print "Patron".$sep; >+ print "Total".$sep; > # Other header > print join($sep, map {$_->{coltitle}} @$cols); >- print $sep . "Total\n"; >+ print "\n"; > # Table > foreach my $line ( @$lines ) { > my $x = $line->{loopcell}; > print $line->{rowtitle}.$sep; >- print join($sep, map {$_->{value}} @$x); >- print $sep,$line->{totalrow}; >+ print '"'.$line->{patron}.'"'.$sep; >+ print join($sep, map {$_->{count}} @$x); > print "\n"; > } > # footer > print "TOTAL"; > $cols = @$results[0]->{loopfooter}; >- print join($sep, map {$_->{totalcol}} @$cols); >+ print join($sep, map {$_->{total}} @$cols); > print $sep.@$results[0]->{total}; > } > exit; >@@ -148,7 +150,7 @@ sub calculate { > my $colorder; > if ($column){ > $column = "old_issues." .$column if (($column=~/branchcode/) or ($column=~/timestamp/)); >- $column = "biblioitems.".$column if $column=~/itemtype/; >+ $column = "items.itype" if $column=~/itemtype/; > $column = "borrowers." .$column if $column=~/categorycode/; > my @colfilter ; > if ($column =~ /timestamp/) { >@@ -245,7 +247,7 @@ sub calculate { > 'old_issues.returndate >', > 'old_issues.returndate <', > 'old_issues.branchcode like', >- 'biblioitems.itemtype like', >+ 'items.itype like', > 'borrowers.categorycode like', > ); > foreach ((@$filters)[0..9]) { >@@ -309,24 +311,28 @@ sub calculate { > foreach my $id (@ranked_ids) { > my @loopcell; > >- foreach my $key (@cols_in_order) { >- if($column){ >- push @loopcell, { >- value => $patrons{$id}->{name}, >- reference => $id, >- count => $patrons{$id}->{allcols}->{$key}, >- }; >- }else{ >- push @loopcell, { >- value => $patrons{$id}->{name}, >- reference => $id, >- count => $patrons{$id}->{total}, >- }; >- } >+ if($column){ >+ # Total >+ push @loopcell, { >+ count => $patrons{$id}->{total}, >+ }; >+ foreach my $key (@cols_in_order) { >+ push @loopcell, { >+ count => $patrons{$id}->{allcols}->{$key}, >+ }; >+ $grantotal += $patrons{$id}->{allcols}->{$key}; >+ } >+ }else{ >+ push @loopcell, { >+ count => $patrons{$id}->{total}, >+ }; >+ $grantotal += $patrons{$id}->{total}; > } > push @looprow,{ 'rowtitle' => $i++ , > 'loopcell' => \@loopcell, > 'hilighted' => ($i%2), >+ 'patron' => $patrons{$id}->{name}, >+ 'reference' => $id, > }; > # use a limit, if a limit is defined > last if $i > $limit and $limit >@@ -336,7 +342,7 @@ sub calculate { > $globalline{loopfilter}=\@loopfilter; > # the core of the table > $globalline{looprow} = \@looprow; >- $globalline{loopcol} = [ map {{coltitle=>$_}} @cols_in_order ]; >+ $globalline{loopcol} = [ map {{coltitle=>$_}} @cols_in_order ] if ($column); > # the foot (totals by borrower type) > $globalline{loopfooter} = []; > $globalline{total}= $grantotal; # FIXME: useless >-- >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 Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36585
:
164782
|
167248
|
167251
|
176100
|
176102
|
176103
|
176104