@@ -, +, @@ - Enable an adult to have a guarantor: - Shows guarantees' fines in the guarantor's page: - Transfer some guarantor's information to the guarantee while adding a guarantiee: - Transfer some guarantor's information to the guarantee while creating a new patron - Transfer some guarantor's information to the guarantee while adding a guarantiee: - Transfer guarantor's alternate address/contact to the guarantee while creating a new patron: - Transfer guarantor's alternate address/contact to the guarantee while adding a guarantiee: --- C4/Category.pm | 34 ++++++++++++++++++++ C4/Members/Attributes.pm | 17 +++++++++- C4/Utils/DataTables/Members.pm | 16 +++++---- admin/categorie.pl | 14 ++++---- .../atomicupdate/bug_12446-EnableAdultGarantee.sql | 14 ++++++++ installer/data/mysql/kohastructure.sql | 3 +- installer/data/mysql/sysprefs.sql | 4 ++- .../prog/en/includes/members-toolbar.inc | 2 +- .../prog/en/modules/admin/categorie.tt | 20 ++++++++++++ .../prog/en/modules/admin/preferences/patrons.pref | 5 +++ .../prog/en/modules/members/memberentrygen.tt | 18 ++++------- .../prog/en/modules/members/moremember.tt | 17 ++++++++-- members/memberentry.pl | 19 ++++++++--- members/moremember.pl | 30 ++++++++++------- 14 files changed, 164 insertions(+), 49 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql --- a/C4/Category.pm +++ a/C4/Category.pm @@ -94,6 +94,36 @@ sub all { }; } +=head3 C4::Category->get + + $cat = get( $category_code ); + This returns the category as an object. + +=cut + +sub get { + my ( $class, $code ) = @_; + my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : ""; + my $dbh = C4::Context->dbh; + + my ( $query , @params ); + if( $branch_limit ){ + $query = qq| SELECT categories.* FROM categories + LEFT JOIN categories_branches ON categories_branches.categorycode = categories.categorycode + WHERE categories.categorycode = ? AND (categories_branches.branchcode = ? OR categories_branches.branchcode IS NULL) + |; + @params = ( $code, $branch_limit ); + } + else{ + $query = "SELECT categories.* FROM categories WHERE categorycode = ?"; + @params = ( $code ); + } + + my $data = $dbh->selectrow_hashref( $query, undef, @params ); + + return $class->new($data); +} + @@ -149,6 +179,10 @@ These are read-only accessors for attributes of a C4::Category object. =cut +=head3 $category->canbeguarantee + +=cut + sub AUTOLOAD { my $self = shift; my $attr = $AUTOLOAD; --- a/C4/Members/Attributes.pm +++ a/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 --- a/C4/Utils/DataTables/Members.pm +++ a/C4/Utils/DataTables/Members.pm @@ -3,6 +3,7 @@ package C4::Utils::DataTables::Members; 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 Modern::Perl; @@ -31,13 +32,14 @@ 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() }){ + my %seen = (); + @columns = grep { ! $seen{ $_ }++ } ( @columns, @guarantor_attributes ); + }; + $_ = "borrowers.".$dbh->quote_identifier($_) for (@columns); + + my $select = "SELECT ${ \join(',', @columns) }, categories.description AS category_description, categories.category_type, branches.branchname"; my $from = "FROM borrowers --- a/admin/categorie.pl +++ a/admin/categorie.pl @@ -154,6 +154,7 @@ if ( $op eq 'add_form' ) { $data->{'BlockExpiredPatronOpacActions'}, TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"), + canbeguarantee => $data->{'canbeguarantee'}, ); if ( C4::Context->preference('EnhancedMessagingPreferences') ) { @@ -178,7 +179,6 @@ elsif ( $op eq 'add_validate' ) { ) ); } - if ($is_a_modif) { my $sth = $dbh->prepare( " UPDATE categories @@ -193,7 +193,8 @@ elsif ( $op eq 'add_validate' ) { overduenoticerequired=?, category_type=?, BlockExpiredPatronOpacActions=?, - default_privacy=? + default_privacy=?, + canbeguarantee=? WHERE categorycode=?" ); $sth->execute( @@ -204,7 +205,7 @@ elsif ( $op eq 'add_validate' ) { 'reservefee', 'hidelostitems', 'overduenoticerequired', 'category_type', 'block_expired', 'default_privacy', - 'categorycode' + 'canbeguarantee', 'categorycode' ) ); $sth->finish; @@ -224,7 +225,8 @@ elsif ( $op eq 'add_validate' ) { overduenoticerequired, category_type, BlockExpiredPatronOpacActions, - default_privacy + default_privacy, + canbeguarantee ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)" ); my $inserted = $sth->execute( @@ -235,7 +237,7 @@ elsif ( $op eq 'add_validate' ) { 'enrolmentfee', 'reservefee', 'hidelostitems', 'overduenoticerequired', 'category_type', 'block_expired', - 'default_privacy', + 'default_privacy', 'canbeguarantee' ) ); if ( $inserted ) { @@ -340,7 +342,6 @@ if ( $op eq 'list' ) { } $results->[$i]{'category_type'} //= ''; - my %row = ( branches => \@selected_branches, categorycode => $results->[$i]{'categorycode'}, @@ -354,6 +355,7 @@ if ( $op eq 'list' ) { hidelostitems => $results->[$i]{'hidelostitems'}, category_type => $results->[$i]{'category_type'}, default_privacy => $results->[$i]{'default_privacy'}, + canbeguarantee => $results->[$i]{'canbeguarantee'}, reservefee => sprintf( "%.2f", $results->[$i]{'reservefee'} || 0 ), enrolmentfee => sprintf( "%.2f", $results->[$i]{'enrolmentfee'} || 0 ), --- a/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql +++ a/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql @@ -0,0 +1,14 @@ +-- ******** -- +-- 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'; + +-- Set defaults for new column +UPDATE categories set canbeguarantee = 1 WHERE category_type IN ('C', 'P'); + --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -489,7 +489,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; --- a/installer/data/mysql/sysprefs.sql +++ a/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'), @@ -490,5 +492,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'), ; --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -140,7 +140,7 @@ function searchToHold(){ [% IF ( CAN_user_borrowers ) %] [% IF ( adultborrower AND activeBorrowerRelationship ) %] - Add child + Add guarantee [% END %] [% IF ( CAN_user_borrowers ) %] Change password --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt @@ -24,6 +24,11 @@ if ( $("#branches option:selected").length < 1 ) { $("#branches option:first").attr("selected", "selected"); } + $("#category_type").change(function(){ + var canbeguarantee_bydefault = ['C','P']; + var selected = $(this).val(); + $("#canbeguarantee").val( ( $.inArray(selected, canbeguarantee_bydefault) != -1 ) ? "1" : "0" ); + }); }); function isNotNull(f,noalert) { if (f.value.length ==0) { @@ -197,6 +202,18 @@ Required +
  • + + +
  • [% END %]
  • - [% END %] - [% UNLESS nocontactfirstname %] -
  • + [% UNLESS nocontactfirstname %] +
  • [% IF ( guarantorid ) %] [% contactfirstname %] @@ -1006,6 +999,7 @@
  • + [% IF ( patron_attribute.use_dropdown ) %]