From 1d8f322bae82a81bc6ed2c762d4008ac5ad562b8 Mon Sep 17 00:00:00 2001
From: Agustin Moyano
Date: Thu, 5 Sep 2019 14:13:27 -0300
Subject: [PATCH] Bug 19618: Add ability to place holds for members of a club
in intranet
This patch adds the ability to place a hold for each member of a club in random order.
To test:
1) apply this patch
2) create 2 clubs, (club names should have some part in common, and some part different for each other)
3) in one of them add at least 6 members
4) enter patron clubs management and click on "Actions" button
SUCCESS.1 => club with members has a new action called "search to hold"
5) click on search to hold
SUCCESS.2 => in the list of bilios there appears an action called "Place hold for "
6) click on "Place hold for "
SUCCESS.3 => a new window appears where you can select pickup location (defaults to club's library, if any), and the list of members.
7) go back to the list of bilios in the catalog and click on "Forget "
8) click on "Holds" action of any biblio
SUCCESS.4 => a search box appears with two tabs: Patrons and Clubs
9) click on Clubs tab and search by the common part of clubs names
SUCCESS.5 => a list of clubs that matches the search appears. If you click on any of them, the same page as SUCCESS.3 appears.
10) go back to the search box in SUCCESS.4 and search by the different part of the name.
SUCCESS.6 => because there is only one club that matches search criteria, the same page as SUCCESS.3 appears;
11) Sign off
---
Koha/Club/Enrollment.pm | 16 ++
catalogue/search.pl | 8 +
.../prog/en/includes/clubs-table.inc | 111 ++++++++
.../prog/en/modules/catalogue/results.tt | 37 ++-
.../prog/en/modules/clubs/clubs.tt | 95 +------
.../prog/en/modules/members/moremember.tt | 2 +-
.../prog/en/modules/reserve/request.tt | 268 ++++++++++++++++--
reserve/request.pl | 73 ++++-
8 files changed, 492 insertions(+), 118 deletions(-)
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/clubs-table.inc
diff --git a/Koha/Club/Enrollment.pm b/Koha/Club/Enrollment.pm
index 168f55bca6..2b4e627a77 100644
--- a/Koha/Club/Enrollment.pm
+++ b/Koha/Club/Enrollment.pm
@@ -24,6 +24,8 @@ use Carp;
use Koha::Database;
use Koha::Clubs;
use Koha::Patrons;
+use Koha::DateUtils qw(dt_from_string);
+use DateTime;
use base qw(Koha::Object);
@@ -71,6 +73,20 @@ sub patron {
return scalar Koha::Patrons->find( $self->borrowernumber() );
}
+=head3 is_canceled
+Determines if enrollment is canceled
+=cut
+
+sub is_canceled {
+ my ( $self ) = @_;
+
+ return 0 unless $self->date_canceled;
+ my $today = dt_from_string;
+ my $date_canceled = dt_from_string( $self->date_canceled );
+
+ return DateTime->compare($date_canceled, $today) < 1;
+}
+
=head3 type
=cut
diff --git a/catalogue/search.pl b/catalogue/search.pl
index a3a7015efc..8f460de8e3 100755
--- a/catalogue/search.pl
+++ b/catalogue/search.pl
@@ -203,6 +203,14 @@ if($cgi->cookie("holdfor")){
);
}
+if($cgi->cookie("holdforclub")){
+ my $holdfor_club = Koha::Clubs->find( $cgi->cookie("holdforclub") );
+ $template->param(
+ holdforclub => $cgi->cookie("holdforclub"),
+ holdforclub_name => $holdfor_club->name,
+ );
+}
+
# get biblionumbers stored in the cart
my @cart_list;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/clubs-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/clubs-table.inc
new file mode 100644
index 0000000000..62027b1a38
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/clubs-table.inc
@@ -0,0 +1,111 @@
+
+
+
+
Name
+
Template
+
Description
+ [% UNLESS destination == 'holds' %]
+
Public enrollment
+
Email required
+ [% END %]
+
Library
+
Start date
+
End date
+
Enrolled patrons
+ [% UNLESS destination == 'holds' %]
+
+ [% END %]
+
+
+
+ [% FOREACH c IN clubs %]
+ [% IF destination == 'holds' %]
+ [% IF multi_hold %]
+ [% SET data_url = "/cgi-bin/koha/reserve/request.pl?club=" _ c.id _ "&multi_hold=1&biblionumbers=" _ biblionumbers %]
+ [% ELSE %]
+ [% SET data_url = "/cgi-bin/koha/reserve/request.pl?club=" _ c.id _ "&biblionumber=" _ biblionumber %]
+ [% END %]
+
+ [% ELSE %]
+
+ [% END %]
+
[% c.name | html %]
+
[% c.club_template.name | html %]
+
[% c.description | html %]
+ [% UNLESS destination == 'holds' %]
+
+ [% IF c.club_template.is_enrollable_from_opac %]
+ Yes
+ [% ELSE %]
+ No
+ [% END %]
+
+
+ [% IF c.club_template.is_email_required %]
+ Yes
+ [% ELSE %]
+ No
+ [% END %]
+
+ [% END %]
+
[% Branches.GetName( c.branchcode ) | html %]
+
+ [% IF c.date_start %]
+ [% c.date_start | $KohaDates %]
+ [% END %]
+
+
+ [% IF c.date_end %]
+ [% c.date_end | $KohaDates %]
+ [% END %]
+
+ [% INCLUDE 'clubs-table.inc' %]
[% ELSE %]
[% IF club_templates %]
No clubs defined.
@@ -282,6 +196,13 @@
});
}
}
+
+ function SearchToHold(club_id) {
+ var date = new Date();
+ date.setTime(date.getTime() + (10 * 60 * 1000));
+ $.cookie("holdforclub", club_id, { path: "/", expires: date });
+ location.href="/cgi-bin/koha/catalogue/search.pl";
+ }
[% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
index 95ad755bca..597de84b19 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
@@ -861,7 +861,7 @@
if ( $('#clubs-tab').length ) {
$('#clubs-tab-link').on('click', function() {
$('#clubs-tab').text(_("Loading..."));
- $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber | html %]');
+ $('#clubs-tab').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% patron.borrowernumber | html %]');
});
}
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
index 91e4ebb6b5..5b0c482c20 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
@@ -73,7 +73,7 @@
Confirm holds
[% END %]
- [% UNLESS patron OR patron.borrowernumber OR noitems %]
+ [% UNLESS club OR patron OR patron.borrowernumber OR noitems %]
[% IF ( messageborrower ) %]