@@ -, +, @@ - 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/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 | 11 ++++++++ installer/data/mysql/kohastructure.sql | 8 +++--- installer/data/mysql/sysprefs.sql | 4 ++- .../en/includes/member-alt-address-style-us.inc | 2 +- .../prog/en/includes/members-toolbar.inc | 2 +- .../prog/en/modules/admin/categories.tt | 15 ++++++++++ .../prog/en/modules/admin/preferences/patrons.pref | 6 +++- .../prog/en/modules/common/patron_search.tt | 7 +++-- .../prog/en/modules/members/memberentrygen.tt | 7 ++--- .../prog/en/modules/members/moremember.tt | 28 ++++++++++-------- .../en/modules/members/tables/guarantor_search.tt | 2 +- koha-tmpl/intranet-tmpl/prog/js/members.js | 23 ++++----------- members/memberentry.pl | 18 +++++++++--- members/moremember.pl | 33 ++++++++++++++++++++-- svc/members/search | 2 ++ 19 files changed, 158 insertions(+), 60 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql --- a/C4/Members/Attributes.pm +++ a/C4/Members/Attributes.pm @@ -32,7 +32,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 ); } @@ -383,6 +383,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 @@ -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 --- a/Koha/Schema/Result/Category.pm +++ a/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' @@ -161,6 +167,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", --- a/admin/categories.pl +++ a/admin/categories.pl @@ -93,6 +93,7 @@ elsif ( $op eq 'add_validate' ) { my $checkPrevCheckout = $input->param('checkprevcheckout'); my $default_privacy = $input->param('default_privacy'); my @branches = grep { $_ ne q{} } $input->multi_param('branches'); + my $canbeguarantee = $input->param('canbeguarantee'); my $is_a_modif = $input->param("is_a_modif"); @@ -119,6 +120,7 @@ elsif ( $op eq 'add_validate' ) { $category->hidelostitems($hidelostitems); $category->overduenoticerequired($overduenoticerequired); $category->category_type($category_type); + $category->canbeguarantee($canbeguarantee); $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions); $category->checkprevcheckout($checkPrevCheckout); $category->default_privacy($default_privacy); @@ -145,6 +147,7 @@ elsif ( $op eq 'add_validate' ) { hidelostitems => $hidelostitems, overduenoticerequired => $overduenoticerequired, category_type => $category_type, + canbeguarantee => $canbeguarantee, BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions, checkprevcheckout => $checkPrevCheckout, default_privacy => $default_privacy, --- a/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql +++ a/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql @@ -0,0 +1,11 @@ +-- ******** -- +-- 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'; +UPDATE categories SET canbeguarantee = 1 WHERE category_type = 'P' OR category_type = 'C'; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -318,8 +318,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 - `checkprevcheckout` varchar(7) NOT NULL default 'inherit', -- produce a warning for this patron category if this item has previously been checked out to this patron if 'yes', not if 'no', defer to syspref setting if 'inherit'. + `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; @@ -885,7 +885,7 @@ CREATE TABLE `refund_lost_item_fee_rules` ( -- refund lost item fee rules tbale -- DROP TABLE IF EXISTS `items`; -CREATE TABLE `items` ( -- holdings/item information +CREATE TABLE `items` ( -- holdings/item information `itemnumber` int(11) NOT NULL auto_increment, -- primary key and unique identifier added by Koha `biblionumber` int(11) NOT NULL default 0, -- foreign key from biblio table used to link this item to the right bib record `biblioitemnumber` int(11) NOT NULL default 0, -- foreign key from the biblioitems table to link to item to additional information @@ -2218,7 +2218,7 @@ CREATE TABLE `userflags` ( -- DROP TABLE IF EXISTS `virtualshelves`; -CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) +CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) `shelfnumber` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha `shelfname` varchar(255) default NULL, -- name of the list `owner` int default NULL, -- foreign key linking to the borrowers table (using borrowernumber) for the creator of this list (changed from varchar(80) to int) --- 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'), @@ -542,5 +544,5 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('XSLTListsDisplay','default','','Enable XSLT stylesheet control over lists pages 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/member-alt-address-style-us.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/member-alt-address-style-us.inc @@ -8,7 +8,7 @@ - + [% IF ( mandatoryB_streetnumber ) %]Required[% END %] [% END %] --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -148,7 +148,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/categories.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -151,6 +151,18 @@ Required +
  • + + +
  • [% END %]
  • - [% END %] - [% UNLESS nocontactfirstname %] -
  • + [% UNLESS nocontactfirstname %] +
  • [% IF ( guarantorid ) %] [% contactfirstname %] @@ -1021,6 +1019,7 @@ $(document).ready(function() {
  • + [% IF ( patron_attribute.use_dropdown ) %] " + "Select" }[% UNLESS loop.last %],[% END %] [% END %] ] --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ a/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -182,7 +182,7 @@ function update_category_code(category_code) { $(mytables).find(" li[data-category_code='']").show(); } -function select_user(borrowernumber, borrower) { +function select_user(borrowernumber, borrower, attributes) { var form = $('#entryform').get(0); if (form.guarantorid.value) { $("#contact-details").find('a').remove(); @@ -203,16 +203,11 @@ function select_user(borrowernumber, borrower) { .val(borrower.firstname) .before('' + borrower.firstname + '').get(0).type = 'hidden'; - form.streetnumber.value = borrower.streetnumber; - form.address.value = borrower.address; - form.address2.value = borrower.address2; - form.city.value = borrower.city; - form.state.value = borrower.state; - form.zipcode.value = borrower.zipcode; - form.country.value = borrower.country; - form.branchcode.value = borrower.branchcode; - form.guarantorsearch.value = LABEL_CHANGE; + for (var i = 0; i < attributes.length; i++) { + var attribute = attributes[i]; + document.forms.entryform[attribute].value = borrower[attribute]; + } return 0; } @@ -351,12 +346,4 @@ $(document).ready(function(){ e.preventDefault(); }); $('#floating-save').css( { bottom: parseInt( $('#floating-save').css('bottom') ) + $('#changelanguage').height() + 'px' } ); - $('#qa-save').css( { - bottom: parseInt( $('#qa-save').css('bottom') ) + $('#changelanguage').height() + 'px' , - "background-color": "rgba(185, 216, 217, 0.6)", - "bottom": "3%", - "position": "fixed", - "right": "1%", - "width": "150px", - } ); }); --- a/members/memberentry.pl +++ a/members/memberentry.pl @@ -39,6 +39,7 @@ use C4::Log; use C4::Letters; use C4::Branch; # GetBranches use C4::Form::MessagingPreferences; +use Koha::Patron::Categories; use Koha::Patron::Debarments; use Koha::Cities; use Koha::DateUtils; @@ -235,8 +236,9 @@ if ( ( $op eq 'insert' ) and !$nodouble ) { } } - #recover all data from guarantor address phone ,fax... -if ( $guarantorid ) { +#recover all data from guarantor address phone ,fax... +if ( $guarantorid and ( $category_type eq 'C' || $category_type eq 'P')) { + if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) { $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C'; $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'}; @@ -248,8 +250,14 @@ if ( $guarantorid ) { zipcode country city state phone phonepro mobile fax email emailpro branchcode B_streetnumber B_streettype B_address B_address2 B_city B_state B_zipcode B_country B_email B_phone)) { - $newdata{$_} = $guarantordata->{$_}; + $newdata{$_} = $guarantordata->{$_}; } + my $additionalGuarantorField=C4::Context->preference("AdditionalGuarantorField"); + my @field_add=split(/\|/,$additionalGuarantorField); + my $guarantordata=GetMember(borrowernumber => $guarantorid); + foreach (@field_add) { + $newdata{$_} = $guarantordata->{$_}; + } } } } @@ -660,7 +668,9 @@ if (C4::Context->preference('EnhancedMessagingPreferences')) { $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification")); } -$template->param( "showguarantor" => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are +$template->param( "showguarantor" => $categorycode ? Koha::Patron::Categories->find($categorycode)->canbeguarantee : 1); # associate with step to know where you are + +$template->param( "guarantor_attributes" => C4::Members::Attributes::get_guarantor_shared_attributes() ); $debug and warn "memberentry step: $step"; $template->param(%data); $template->param( "step_$step" => 1) if $step; # associate with step to know where u are --- a/members/moremember.pl +++ a/members/moremember.pl @@ -166,7 +166,6 @@ if ( $category_type eq 'C') { my $patron = Koha::Patrons->find($data->{borrowernumber}); my @relatives; if ( my $guarantor = $patron->guarantor ) { - $template->param( guarantor => $guarantor ); push @relatives, $guarantor->borrowernumber; push @relatives, $_->borrowernumber for $patron->siblings; } elsif ( $patron->contactname || $patron->contactfirstname ) { @@ -178,15 +177,43 @@ if ( my $guarantor = $patron->guarantor ) { ); } else { my @guarantees = $patron->guarantees; - $template->param( guarantees => \@guarantees ); push @relatives, $_->borrowernumber for @guarantees; } my $relatives_issues_count = Koha::Database->new()->schema()->resultset('Issue') ->count( { borrowernumber => \@relatives } ); +my @guarantees = $patron->guarantees; +my $count = scalar @guarantees; +if ( $count ) { + $template->param( isguarantee => 1 ); + + my @guaranteedata; + my $amount; + my $totalmount = 0; + + foreach my $guarantee (@guarantees){ + my ($amount,$accts,undef) = GetMemberAccountRecords($guarantee->borrowernumber); + push(@guaranteedata, + { + borrowernumber => $guarantee->borrowernumber, + cardnumber => $guarantee->cardnumber, + finesguarantee => sprintf("%.2f",$amount), + name => $guarantee->firstname . " " + . $guarantee->surname + } + ); + $totalmount += $amount; + } + $template->param( guaranteeloop => \@guaranteedata ); + $template->param( amounttot => sprintf("%.2f",$totalmount)); +} +( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' || $category_type eq 'I' ); -$template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' ); +if (my $guarantor = $patron->guarantor){ + $template->param(isguarantor => 1); + $template->param(guarantor => $guarantor); +} my %bor; $bor{'borrowernumber'} = $borrowernumber; --- a/svc/members/search +++ a/svc/members/search @@ -112,12 +112,14 @@ if ($has_permission) { $results->{iTotalDisplayRecords} = scalar( @patrons_with_permission ); } +my @attributes = C4::Members::Attributes::get_guarantor_shared_attributes(); $template->param( sEcho => $sEcho, iTotalRecords => $results->{iTotalRecords}, iTotalDisplayRecords => $results->{iTotalDisplayRecords}, aaData => $results->{patrons}, selection_type => $selection_type, + attributes => @attributes ); output_with_http_headers $input, $cookie, $template->output, 'json'; --