From e0123586a5058fc1d6372dd885a51d08bb81c234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20=C5=A0iman?= Date: Mon, 24 Oct 2016 03:41:02 +0200 Subject: [PATCH] Bug 17492: Add a warning about age being of-limits and a button to update it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds a warning if a patron's age is out of limits if an assigned category. It also adds a button allowing to change the category. Test plan: 1) Apply patch 2) Create a patron and assign him a category having age limits set 3) Change patron's age to be older/younger than category's limits 4) At "Check out" and "Details" tabs you should see a warning with a button allowing to change the category, eg.: - http://prntscr.com/cz7ch3 - http://prntscr.com/cz7em4 - http://prntscr.com/cz7dj1 5) Set a valid category according to patron's age 6) Warning should disappear 7) Perform similar test again, but instead of changing the age change the limits of a category 8) During tests verify "Change category" button everytime opens "Modify patron" page: http://prntscr.com/cz7g5q Tested all 4 patches together, works as expected Signed-off-by: Marc Véron Bug 17492: Removed a line setting 'flagged' template parameter by mistake Signed-off-by: Marc Véron Bug 17492: Fixed URL generation of "Change category" button Signed-off-by: Marc Véron Bug 17492: Fixed forbidden patterns Signed-off-by: Marc Véron Bug 17492: Removed extra IFs Signed-off-by: Jonathan Druart Signed-off-by: Katrin Fischer --- circ/circulation.pl | 12 ++++++++++++ .../prog/en/includes/category-out-of-age-limit.inc | 4 ++++ koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt | 6 +++++- .../intranet-tmpl/prog/en/modules/members/moremember.tt | 12 ++++++++---- members/moremember.pl | 10 ++++++++++ 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/category-out-of-age-limit.inc diff --git a/circ/circulation.pl b/circ/circulation.pl index 130d350..c921fd4 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -303,6 +303,18 @@ if ($patron) { } } + # Calculate and display patron's age + my $dateofbirth = $borrower->{ 'dateofbirth' }; + my $age = GetAge($dateofbirth); + + my $borrowercategory = Koha::Patron::Categories->find($borrower->{ 'categorycode' }); + my ($low,$high) = ($borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit); + if (($high && ($age > $high)) or ($age < $low)) { + $template->param( age_limitations => 1 ); + $template->param( age_low => $low ); + $template->param( age_high => $high ); + } + } # diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/category-out-of-age-limit.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/category-out-of-age-limit.inc new file mode 100644 index 0000000..982df7b --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/category-out-of-age-limit.inc @@ -0,0 +1,4 @@ +
  • + Patron's age is incorrect for their category. + Ages allowed are [% age_low %]-[% age_high %]. + Change category
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index d5507c0..43cb8b0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -836,10 +836,14 @@ No patron matched [% message | html %] [% IF ( odues ) %]
  • [% IF ( nonreturns ) %]Overdues: Patron has ITEMS OVERDUE. See highlighted items below[% END %]
  • [% END %] - [% IF ( charges ) %] + [% IF charges %] [% INCLUDE 'blocked-fines.inc' fines = chargesamount %] [% END %] + [% IF age_limitations %] + [% INCLUDE 'category-out-of-age-limit.inc' %] + [% END %] + [% IF ( charges_guarantees ) %]
  • Fees & Charges: Patron's guarantees collectively owe [% chargesamount_guarantees | $Price %]. 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 b40c29a..6ec9234 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -183,12 +183,16 @@ function validate1(date) { [% ELSE %] [% IF ( was_renewed ) %]
    Patron's account has been renewed until [% dateexpiry | $KohaDates %]
    [% END %] - [% IF fines %] + [% IF fines || age_limitations %]
      - [% INCLUDE 'blocked-fines.inc' %] -
    -
    + [% IF fines %] + [% INCLUDE 'blocked-fines.inc' %] + [% END %] + [% IF age_limitations %] + [% INCLUDE 'category-out-of-age-limit.inc' %] + [% END %] + [% END %] [% IF ( flagged ) %] diff --git a/members/moremember.pl b/members/moremember.pl index 30e8ce0..64c994b 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -250,6 +250,16 @@ if ( $data->{dateofbirth} ) { $template->param( age => Koha::Patron->new({ dateofbirth => $data->{dateofbirth} })->get_age ); } +# Check patron's category against age +my $borrowercategory = Koha::Patron::Categories->find($data->{ 'categorycode' }); +my ($low,$high) = ($borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit); +if (($high && ($age > $high)) or ($age < $low)) { + $template->param( age_limitations => 1 ); + $template->param( age_low => $low ); + $template->param( age_high => $high ); +} + + ### ############################################################################### # BUILD HTML # show all reserves of this borrower, and the position of the reservation .... -- 2.1.4