From 1c54a9a4c578a504a656ab49755655f9c3a8cfc5 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 --- 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 | 11 +++++++++-- members/moremember.pl | 10 ++++++++++ 5 files changed, 40 insertions(+), 3 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 ded56c4..6ad9c1b 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -313,6 +313,18 @@ if ($borrowernumber) { } } + # 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 a937bf1..8855025 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -790,12 +790,16 @@ 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 %]. 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 209671e..a6e902a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -179,8 +179,15 @@ function validate1(date) { [% ELSE %] [% IF ( was_renewed ) %]
    Patron's account has been renewed until [% dateexpiry | $KohaDates %]
    [% END %] - [% IF fines %] - [% INCLUDE 'blocked-fines.inc' %] + [% IF fines || age_limitations %] +
      + [% 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 01d16b6..d5a25f0 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -240,6 +240,16 @@ my $dateofbirth = $data->{ 'dateofbirth' }; my $age = GetAge($dateofbirth); $template->param( age => $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