From 718002ba2116d474a0ab3dac5ab1fe1fcff51f7b 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested all 4 patches together, works as expected Signed-off-by: Marc VĂ©ron --- 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 45322b2..857a2cb 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -312,6 +312,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 7111ef9..7ec8bb7 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 a5008ca..683066b 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 01d16b6..4a4bb9b 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -240,6 +240,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