From b3eabbc8dc9db8dd7744705a83f75e02ddff965c Mon Sep 17 00:00:00 2001 From: radiuscz Date: Mon, 24 Oct 2016 03:41:02 +0200 Subject: [PATCH] Added warning about age being of-of-limits 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 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 https://bugs.koha-community.org/show_bug.cgi?id=17492 --- circ/circulation.pl | 13 +++++++++++++ .../prog/en/includes/category-out-of-age-limit.inc | 6 ++++++ koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt | 13 +++++++++---- .../intranet-tmpl/prog/en/modules/members/moremember.tt | 11 +++++++++-- members/moremember.pl | 11 +++++++++++ 5 files changed, 48 insertions(+), 6 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 fcd967d..6399d42 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -310,6 +310,19 @@ 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( flagged => 1 ); + $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..2aac474 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/category-out-of-age-limit.inc @@ -0,0 +1,6 @@ +[% IF age_limitations %] +
  • + Patron's age is incorrect for their category. + Ages allowed are [% age_low %]-[% age_high %]. + Change category
  • +[% END %] 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 e0284b2..938a37e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -790,10 +790,15 @@ No patron matched [% message | html %] [% IF ( odues ) %]
  • [% IF ( nonreturns ) %]Overdues: Patron has ITEMS OVERDUE. See highlighted items below[% END %]
  • [% END %] - [% IF ( charges ) %] - [% INCLUDE 'blocked-fines.inc' - fines = chargesamount - %] + [% IF ( charges || age_limitations ) %] + [% IF charges %] + [% INCLUDE 'blocked-fines.inc' + fines = chargesamount + %] + [% END %] + [% IF age_limitations %] + [% INCLUDE 'category-out-of-age-limit.inc' %] + [% END %] [% END %] [% IF ( charges_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 c5325e1..193822c 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 %] + [% END %] [% IF ( flagged ) %] diff --git a/members/moremember.pl b/members/moremember.pl index 00e2600..2001a27 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -239,6 +239,17 @@ 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( flagged => 1 ); + $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