From a5a7e90536f6b641ba536601ca6128882c21d0ab Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 10 May 2022 09:50:55 +0200 Subject: [PATCH] Bug 30650: Add link from the circ patron page Sponsored-by: Association KohaLa - https://koha-fr.org/ Signed-off-by: Koha Team University Lyon 3 --- Koha/Patron.pm | 15 +++++++++ .../prog/en/includes/patron_messages.inc | 31 +++++++++++++++++++ t/db_dependent/Koha/CurbsidePickups.t | 3 +- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index c4788eaa68e..6cb025fb3a4 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -39,6 +39,7 @@ use Koha::DateUtils qw( dt_from_string ); use Koha::Encryption; use Koha::Exceptions::Password; use Koha::Holds; +use Koha::CurbsidePickups; use Koha::Old::Checkouts; use Koha::Patron::Attributes; use Koha::Patron::Categories; @@ -1325,6 +1326,20 @@ sub old_holds { return Koha::Old::Holds->_new_from_dbic($old_holds_rs); } +=head3 curbside_pickups + +my $curbside_pickups = $patron->curbside_pickups; + +Return all the curbside pickups for this patron + +=cut + +sub curbside_pickups { + my ($self) = @_; + my $curbside_pickups_rs = $self->_result->curbside_pickups_borrowernumbers->search; + return Koha::CurbsidePickups->_new_from_dbic($curbside_pickups_rs); +} + =head3 return_claims my $return_claims = $patron->return_claims diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc index 97219917e74..0575cc2933e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc @@ -1,3 +1,4 @@ +[% USE raw %] [% SET ClaimReturnedWarningThreshold = Koha.Preference('ClaimReturnedWarningThreshold') %] [% SET return_claims = patron.return_claims %] @@ -188,6 +189,36 @@ [% END # /IF WaitingHolds.count %] +[% IF Koha.Preference("CurbsidePickup") %] + [% SET curbside_pickups = patron.curbside_pickups.search( branchcode => logged_in_user.branchcode ) %] + [% IF curbside_pickups.count %] +
+

Curbside pickups scheduled here

+
    + [% FOR cp IN curbside_pickups %] +
  • On [% cp.scheduled_pickup_datetime | $KohaDates %]: + [% SWITCH cp.status %] + [% CASE 'to-be-staged' %] + + To be staged + [% CASE 'staged-and-ready' %] + + Staged and ready + [% CASE 'patron-is-outside' %] + + Patron is outside! + [% CASE 'delivered' %] + + Delivered + [% CASE %]Unknown status "[% cp.status | html %]" + [% END %] +
  • + [% END %] +
+
+ [% END %] +[% END %] + [% IF ( patron.borrowernotes ) %]

Notes

diff --git a/t/db_dependent/Koha/CurbsidePickups.t b/t/db_dependent/Koha/CurbsidePickups.t index 0d027312d46..a85945b4210 100755 --- a/t/db_dependent/Koha/CurbsidePickups.t +++ b/t/db_dependent/Koha/CurbsidePickups.t @@ -77,7 +77,7 @@ $policy->add_opening_slot('1-12:00-18:00'); my $today = dt_from_string; subtest 'Create a pickup' => sub { - plan tests => 7; + plan tests => 8; # Day and datetime are ok my $next_monday = @@ -108,6 +108,7 @@ subtest 'Create a pickup' => sub { $policy->enable_waiting_holds_only(0)->store; my $cp = Koha::CurbsidePickup->new($params)->store; is( $cp->status, 'to-be-staged' ); + is( $patron->curbside_pickups->count, 1, 'Koha::Patron->curbside_pickups' ); throws_ok { Koha::CurbsidePickup->new($params)->store -- 2.25.1