From be2ac2001f23ee94058276d7fe6a53908fd829f2 Mon Sep 17 00:00:00 2001 From: remi Date: Wed, 6 Jan 2016 08:46:27 -0500 Subject: [PATCH] bug 12446 - Enable adult patrons to have a guarantor I have rebased every patch. This includes all the features from the previous patches. Removed the dollar signs and stopped using C4::Category On the patron category page, there is a new field to specify whether patrons can be guarantee or not. The atomic update SQL script adds this new field and sets it to true for categories of type "C" and "P". 1) Apply the patch 2) Run updatedatabase.pl to add AdditionalGuarantorField to preferences and canbeguarantee to categories. 3) Go to patron category administration, edit a category and change the value of Can Be Guarantee to yes (for Child and Professional mostly to set it by default) 4) See below to test various scenarios - Enable an adult to have a guarantor: 0.0) Create or edit a patron category of type 'A'. 0.1) Set the "Can be guarantee" field to "Yes" and save. 1) Select an adult patron -> details tab; 2) Click edit button; 3) validate "guarantor information" fieldset; - Shows guarantees' fines in the guarantor's page: 4) Click Set to patron button and select a guarantor; 5) Generate a fine; 6) Select guarantor patron -> details tab; 7) Validate guarantee's fine information. - Transfer some guarantor's information to the guarantee while adding a guarantiee: 0) Select an adult patron; 1) Insert all information; 2) Click Add guarantiee bouton; 3) Validade Garantor information/Main address/Contact fieldsets filled; - Transfer some guarantor's information to the guarantee while creating a new patron 0) Select an adult patron; 1) Insert all information; 2) Add a new adult patron; 3) Click "Set to patron" button; 4) Select the adult patron from 0); 5) Validade Garantor information/Main address/Contact fieldsets filled; - Transfer some guarantor's information to the guarantee while adding a guarantiee: 0) Select an adult patron; 1) Insert all information; 2) Click Add guarantiee bouton; 3) Validade Garantor information/Main address/Contact fieldsets filled; - Transfer guarantor's alternate address/contact to the guarantee while creating a new patron: 0) Search AdditionalGuarantorField preference; 1) Insert some additional database columns from alternate address/contact to be transferred from guarantor; 2) Select an adult patron; 3) Insert all information; 4) Add a new adult patron; 5) Click "Set to patron" button; 6) Select the adult patron from 0); 7) Validade Garantor information/Main address/Contact fieldsets filled; 8) Validade Garantor additional alternate address/contact filled; - Transfer guarantor's alternate address/contact to the guarantee while adding a guarantiee: 0) Search AdditionalGuarantorField preference; 1) Insert some additional database columns from alternate address/contact to be transferred from guarantor; 3) Select an adult patron; 4) Insert all information; 5) Click Add guarantiee bouton; 6) Validade Garantor information/Main address/Contact fieldsets filled; 7) Validade Garantor additional alternate address/contact filled; --- C4/Members/Attributes.pm | 17 +++++++++++++- C4/Utils/DataTables/Members.pm | 22 ++++++++++++------ Koha/Schema/Result/Category.pm | 8 +++++++ admin/categories.pl | 3 +++ .../atomicupdate/bug_12446-EnableAdultGarantee.sql | 10 ++++++++ installer/data/mysql/kohastructure.sql | 3 ++- installer/data/mysql/sysprefs.sql | 4 +++- .../prog/en/includes/members-toolbar.inc | 2 +- .../prog/en/modules/admin/categories.tt | 15 ++++++++++++ .../prog/en/modules/admin/preferences/patrons.pref | 5 ++++ .../prog/en/modules/members/memberentrygen.tt | 18 +++++---------- .../prog/en/modules/members/moremember.tt | 18 +++++++++++---- members/memberentry.pl | 18 +++++++++++---- members/moremember.pl | 27 +++++++++++----------- 14 files changed, 126 insertions(+), 44 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql diff --git a/C4/Members/Attributes.pm b/C4/Members/Attributes.pm index b25a813..b2b0762 100644 --- a/C4/Members/Attributes.pm +++ b/C4/Members/Attributes.pm @@ -34,7 +34,7 @@ BEGIN { @EXPORT_OK = qw(GetBorrowerAttributes GetBorrowerAttributeValue CheckUniqueness SetBorrowerAttributes DeleteBorrowerAttribute UpdateBorrowerAttribute extended_attributes_code_value_arrayref extended_attributes_merge - SearchIdMatchingAttribute); + SearchIdMatchingAttribute get_guarantor_shared_attributes); %EXPORT_TAGS = ( all => \@EXPORT_OK ); } @@ -357,6 +357,21 @@ sub _sort_by_code { return $x->{code} cmp $y->{code} || $x->{value} cmp $y->{value}; } +=head2 get_guarantor_shared_attributes + + $guarantor_attributes = get_guarantor_attributes(); + + returns an array reference containing attributes to be shared between guarantor and guarantee. +=cut +sub get_guarantor_shared_attributes{ + my @attributes = qw( streetnumber address address2 city state zipcode country branchcode phone phonepro mobile email emailpro fax ); + if( my @additional = split(/\|/, C4::Context->preference("AdditionalGuarantorField")) ){ + $_ =~ s/(?:^\s+)|(?:\s+$)//g for (@additional); # Trim whitespaces + @attributes = ( @attributes, @additional); + } + return \@attributes; +} + =head1 AUTHOR Koha Development Team diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm index 1ebecd7..49fd1fc 100644 --- a/C4/Utils/DataTables/Members.pm +++ b/C4/Utils/DataTables/Members.pm @@ -4,6 +4,7 @@ use Modern::Perl; use C4::Branch qw/onlymine/; use C4::Context; use C4::Members qw/GetMemberIssuesAndFines/; +use C4::Members::Attributes qw/get_guarantor_shared_attributes/; use C4::Utils::DataTables; use Koha::DateUtils; @@ -32,13 +33,20 @@ sub search { } my $dbh = C4::Context->dbh; - my $select = "SELECT - borrowers.borrowernumber, borrowers.surname, borrowers.firstname, - borrowers.streetnumber, borrowers.streettype, borrowers.address, - borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode, - borrowers.country, cardnumber, borrowers.dateexpiry, - borrowers.borrowernotes, borrowers.branchcode, borrowers.email, - borrowers.userid, borrowers.dateofbirth, borrowers.categorycode, + my @columns = qw( borrowernumber surname firstname streetnumber streettype address address2 city state zipcode country cardnumber dateexpiry borrowernotes branchcode email userid dateofbirth categorycode ); + if( my @guarantor_attributes = @{ get_guarantor_shared_attributes() }){ + foreach my $item (@guarantor_attributes) { + if (! grep {$_ eq $item} @columns) { + push @columns, $item; + } + } + }; + my $borrowers_columns = ""; + foreach my $item (@columns) { + $borrowers_columns .= "borrowers." . $item . ", "; + } + + my $select = "SELECT " . $borrowers_columns . " categories.description AS category_description, categories.category_type, branches.branchname"; my $from = "FROM borrowers diff --git a/Koha/Schema/Result/Category.pm b/Koha/Schema/Result/Category.pm index 4926587..e5a40a9 100644 --- a/Koha/Schema/Result/Category.pm +++ b/Koha/Schema/Result/Category.pm @@ -109,6 +109,12 @@ __PACKAGE__->table("categories"); default_value: -1 is_nullable: 0 +=head2 canbeguarantee + + data_type: 'tinyint' + default_value: 0 + is_nullable: 0 + =head2 default_privacy data_type: 'enum' @@ -154,6 +160,8 @@ __PACKAGE__->add_columns( default_value => -1, is_nullable => 0, }, + "canbeguarantee", + { data_type => "tinyint", default_value => 0, is_nullable => 0}, "default_privacy", { data_type => "enum", diff --git a/admin/categories.pl b/admin/categories.pl index 1370b58..593886c 100755 --- a/admin/categories.pl +++ b/admin/categories.pl @@ -91,6 +91,7 @@ elsif ( $op eq 'add_validate' ) { my $category_type = $input->param('category_type'); my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions'); my $default_privacy = $input->param('default_privacy'); + my $canbeguarantee = $input->param('canbeguarantee'); my @branches = grep { $_ ne q{} } $input->param('branches'); my $is_a_modif = $input->param("is_a_modif"); @@ -112,6 +113,7 @@ elsif ( $op eq 'add_validate' ) { $category->hidelostitems($hidelostitems); $category->overduenoticerequired($overduenoticerequired); $category->category_type($category_type); + $category->canbeguarantee($canbeguarantee); $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions); $category->default_privacy($default_privacy); eval { @@ -137,6 +139,7 @@ elsif ( $op eq 'add_validate' ) { hidelostitems => $hidelostitems, overduenoticerequired => $overduenoticerequired, category_type => $category_type, + canbeguarantee => $canbeguarantee, BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions, default_privacy => $default_privacy, }); diff --git a/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql b/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql new file mode 100644 index 0000000..55c2b78 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql @@ -0,0 +1,10 @@ +-- ******** -- +-- SYSPREFS -- +-- ******** -- +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) +VALUES ('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free'); + +-- ********* -- +-- STRUCTURE -- +-- ********* -- +ALTER TABLE categories ADD COLUMN `canbeguarantee` tinyint(1) NOT NULL default '0'; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 02725fd..1302be2 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -488,7 +488,8 @@ CREATE TABLE `categories` ( -- this table shows information related to Koha patr `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no) `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff) `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions - `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category + `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category, + `canbeguarantee` tinyint(1) NOT NULL default '0' PRIMARY KEY (`categorycode`), UNIQUE KEY `categorycode` (`categorycode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index aa53139..fdfe94c 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -6,6 +6,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'), ('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'), ('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'), +('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free'), +('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'), ('AddressFormat','us','','Choose format to display postal addresses', 'Choice'), ('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'), ('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option. Example: eng|fre|ita','Textarea'), @@ -517,5 +519,5 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('XSLTDetailsDisplay','default','','Enable XSL stylesheet control over details page display on intranet','Free'), ('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'), ('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'), -('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo') +('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'), ; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index 641bbad..7cc0c0e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -146,7 +146,7 @@ function searchToHold(){ [% IF ( CAN_user_borrowers ) %] [% IF ( adultborrower AND activeBorrowerRelationship ) %] - Add child + Add guarantee [% END %] [% IF ( CAN_user_borrowers ) %] Change password diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index d4d0130..4112d44 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -238,6 +238,18 @@ Required +
  • + + +
  • [% END %]
  • - [% END %] - [% UNLESS nocontactfirstname %] -
  • + [% UNLESS nocontactfirstname %] +
  • [% IF ( guarantorid ) %] [% contactfirstname %] @@ -1025,6 +1018,7 @@
  • + [% IF ( patron_attribute.use_dropdown ) %]