Bugzilla – Attachment 88988 Details for
Bug 9099
'Export today's checked in barcodes' always shows and might export an empty file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9099: WIP - Hide the export of today's checkins if none
Bug-9099-WIP---Hide-the-export-of-todays-checkins-.patch (text/plain), 5.07 KB, created by
Jonathan Druart
on 2019-04-28 21:01:30 UTC
(
hide
)
Description:
Bug 9099: WIP - Hide the export of today's checkins if none
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-04-28 21:01:30 UTC
Size:
5.07 KB
patch
obsolete
>From b6e7581086e25a4cbb736f066f3fe6f1ff7237a2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sun, 28 Apr 2019 16:59:41 -0400 >Subject: [PATCH] Bug 9099: WIP - Hide the export of today's checkins if none > >FIXME: >- Add POD >- Add tests > >This patch is for discussion as I do not think it is ready for inclusion: >as the page is not reloaded/updated when a checkin is done, the link will stay hidden. >--- > Koha/Patron.pm | 30 +++++++++++++++++++++- > .../prog/en/includes/members-toolbar.inc | 4 ++- > members/readingrec.pl | 15 ++++++----- > 3 files changed, 41 insertions(+), 8 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 6a25d717c1..1317ac2477 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -30,7 +30,7 @@ use C4::Log; > use Koha::AuthUtils; > use Koha::Checkouts; > use Koha::Database; >-use Koha::DateUtils; >+use Koha::DateUtils qw( dt_from_string ); > use Koha::Exceptions::Password; > use Koha::Holds; > use Koha::Old::Checkouts; >@@ -875,6 +875,34 @@ sub checkouts { > return Koha::Checkouts->_new_from_dbic( $checkouts ); > } > >+sub todays_checkouts { # FIXME Must be moved to Koha::Old::Checkouts->filter_by_returned_today? >+ my ( $self ) = @_; >+ my $dt_today = dt_from_string; >+ my $dtf = Koha::Database->new->schema->storage->datetime_parser; >+ return $self->old_checkouts->search( >+ { >+ returndate => { >+ -between => [ >+ $dtf->format_datetime( >+ $dt_today->set( hour => 0, minute => 0, second => 0 ) >+ ), >+ $dtf->format_datetime( >+ $dt_today->set( >+ hour => 23, >+ minute => 59, >+ second => 59 >+ ) >+ ) >+ ] >+ } >+ }, >+ { >+ order_by => { -desc => 'date_due' }, >+ prefetch => 'item' >+ } >+ ); >+} >+ > =head3 pending_checkouts > > my $pending_checkouts = $patron->pending_checkouts >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >index a86c976846..6c1c34f8cd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc >@@ -85,8 +85,10 @@ > [% IF Koha.Preference('intranetreadinghistory') %] > [%IF ( privacy == 2 ) %] > <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="Not allowed by patron's privacy settings" id="exportbarcodes" href="#">Export today's checked in barcodes</a></li> >- [% ELSE %] >+ [% ELSIF patron.todays_checkouts.size > 0 %] > <li><a id="exportcheckins" href="#">Export today's checked in barcodes</a></li> >+ [% ELSE %] >+ <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="No checkins today" id="exportbarcodes" href="#">Export today's checked in barcodes</a></li> > [% END %] > [% END %] > </ul> >diff --git a/members/readingrec.pl b/members/readingrec.pl >index 7dd71f8fce..c1b648542b 100755 >--- a/members/readingrec.pl >+++ b/members/readingrec.pl >@@ -58,7 +58,7 @@ my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in" > output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); > > my $order = 'date_due desc'; >-my $limit = 0; >+my $limit = 0; # FIXME This variable is useless > my $issues = (); > # Do not request the old issues of anonymous patron > if ( $patron->borrowernumber eq C4::Context->preference('AnonymousPatron') ){ >@@ -73,16 +73,19 @@ if ( $patron->borrowernumber eq C4::Context->preference('AnonymousPatron') ){ > if ( $op eq 'export_barcodes' ) { > # FIXME This should be moved out of this script > if ( $patron->privacy < 2) { >- my $today = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); >- my @barcodes = >- map { $_->{barcode} } grep { $_->{returndate} =~ m/^$today/o } @{$issues}; >- my $borrowercardnumber = $patron->cardnumber; >+ my $dt_today = dt_from_string; >+ my $todays_checkouts = $patron->todays_checkouts; >+ my @barcodes = $todays_checkouts->get_column('item.barcode'); > my $delimiter = "\n"; > binmode( STDOUT, ":encoding(UTF-8)" ); > print $input->header( > -type => 'application/octet-stream', > -charset => 'utf-8', >- -attachment => "$today-$borrowercardnumber-checkinexport.txt" >+ -attachment => sprintf( >+ "%s-%s-checkinexport.txt", >+ output_pref({ dt => $dt_today, dateformat => 'iso', dateonly => 1 }), >+ $patron->cardnumber >+ ), > ); > > my $content = join $delimiter, uniq(@barcodes); >-- >2.11.0
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 9099
: 88988