From a6d054dd517248d1597ebc658fe3c40e75b41bbb Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Thu, 24 Apr 2014 09:02:51 +0300 Subject: [PATCH] [SIGNED-OFF] Bug 12133: Guarantor requirements when registering a patron Add two requirements when registering a new patron: - A child patron must have a guarantor. This is controlled by a new syspref ChildNeedsGuarantor. - A guarantor cannot be a guarantee. Signed-off-by: ppp --- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 11 +++++++++++ .../prog/en/modules/admin/preferences/patrons.pref | 7 +++++++ .../prog/en/modules/members/memberentrygen.tt | 7 +++++++ members/memberentry.pl | 7 +++++++ 5 files changed, 33 insertions(+) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index ff27608..2394650 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -83,6 +83,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'), ('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'), ('checkdigit','none','none|katipo','If ON, enable checks on patron cardnumber: none or \"Katipo\" style checks','Choice'), +('ChildNeedsGuarantor', '0', NULL, 'If ON, a child patron must have a guarantor when adding the patron.', 'YesNo'), ('CircAutocompl','1',NULL,'If ON, autocompletion is enabled for the Circulation input','YesNo'), ('CircAutoPrintQuickSlip','qslip',NULL,'Choose what should happen when an empty barcode field is submitted in circulation: Display a print quick slip window, Display a print slip window or Clear the screen.','Choice'), ('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 5ada385..1cd39ce 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -9438,6 +9438,17 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.15.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) + VALUES('ChildNeedsGuarantor', 0, 'If ON, a child patron must have a guarantor when adding the patron.', '', 'YesNo') + }); + + print "Upgrade to $DBversion done (Bug 12133 - Guarantor requirements when registering a patron)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 2469431..513b172 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -56,6 +56,13 @@ Patrons: katipo: Do - check and construct borrower card numbers in the Katipo style. This overrides autoMemberNum if on. - + - "A child patron" + - pref: "ChildNeedsGuarantor" + choices: + yes: "must have" + no: "doesn't need" + - a guarantor when adding the patron. + - - pref: EnhancedMessagingPreferences choices: yes: Allow diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 56cc570..4f0f30f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -175,6 +175,12 @@

The following fields are wrong. Please fix them.

    + [% IF ( ERROR_child_no_guarantor ) %] +
  • A child patron needs a guarantor.
  • + [% END %] + [% IF ( ERROR_guarantor_is_guarantee ) %] +
  • A guarantor cannot be a guarantee.
  • + [% END %] [% IF ( ERROR_login_exist ) %]
  • Username/password already exists.
  • [% END %] @@ -383,6 +389,7 @@ [% ELSE %] [% IF ( C ) %] + [% IF ( Koha.Preference('ChildNeedsGuarantor') ) %]
  • Required
  • [% END %] [% IF ( guarantorid ) %]
  • [% ELSE %] diff --git a/members/memberentry.pl b/members/memberentry.pl index 3c7f648..373ae6d 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -262,9 +262,16 @@ if ( $guarantorid and ( $category_type eq 'C' || $category_type eq 'P' )) { $newdata{$_} = $guarantordata->{$_}; } } + + push @errors, 'ERROR_guarantor_is_guarantee' if ( $guarantordata->{'guarantorid'} && + ($op eq 'save' || $op eq 'insert') ); } } +push @errors, 'ERROR_child_no_guarantor' if ( $category_type eq 'C' && !$guarantorid && + ($op eq 'save' || $op eq 'insert') && + C4::Context->preference('ChildNeedsGuarantor') ); + ###############test to take the right zipcode, country and city name ############## # set only if parameter was passed from the form $newdata{'city'} = $input->param('city') if defined($input->param('city')); -- 1.7.9.5