@@ -, +, @@
- 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 guarantee:
- Transfer some guarantor's information to the guarantee while creating a new patron
- 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 guarantee:
---
C4/Members/Attributes.pm | 19 ++++++++++++-
C4/Utils/DataTables/Members.pm | 32 +++++++++++++++++-----
admin/categories.pl | 3 ++
.../atomicupdate/bug_12446-EnableAdultGarantee.sql | 11 ++++++++
installer/data/mysql/kohastructure.sql | 1 +
installer/data/mysql/sysprefs.sql | 1 +
.../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/common/patron_search.tt | 7 +++--
.../prog/en/modules/members/memberentrygen.tt | 2 +-
.../prog/en/modules/members/moremember.tt | 15 +++++++---
.../en/modules/members/tables/guarantor_search.tt | 2 +-
koha-tmpl/intranet-tmpl/prog/js/members.js | 9 +++++-
members/memberentry.pl | 4 ++-
members/moremember.pl | 16 +++++++++++
svc/members/search | 2 ++
17 files changed, 126 insertions(+), 20 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 );
}
@@ -365,6 +365,23 @@ 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
@@ -2,6 +2,8 @@ package C4::Utils::DataTables::Members;
use Modern::Perl;
use C4::Context;
+use C4::Members;
+use C4::Members::Attributes qw/get_guarantor_shared_attributes/;
use C4::Utils::DataTables;
use Koha::DateUtils;
use C4::Members::Attributes qw(SearchIdMatchingAttribute );
@@ -56,13 +58,29 @@ sub search {
}
}
- 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,
+ # If branches are independent and user is not superlibrarian
+ # The search has to be only on the user branch
+ if ( C4::Context::only_my_library ) {
+ my $userenv = C4::Context->userenv;
+ $branchcode = $userenv->{'branch'};
+
+ }
+
+ $dbh = C4::Context->dbh;
+ my @columns = qw( borrowernumber surname firstname streetnumber streettype address address2 city state zipcode country cardnumber dateexpiry borrowernotes branchcode email userid dateofbirth categorycode phone phonepro mobile fax email emailpro);
+ 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, borrowers.phone";
my $from = "FROM borrowers
--- a/admin/categories.pl
+++ a/admin/categories.pl
@@ -95,6 +95,7 @@ elsif ( $op eq 'add_validate' ) {
my $reset_password = $input->param('reset_password');
my $change_password = $input->param('change_password');
my @branches = grep { $_ ne q{} } $input->multi_param('branches');
+ my $canbeguarantee = $input->param('canbeguarantee');
$reset_password = undef if $reset_password eq -1;
$change_password = undef if $change_password eq -1;
@@ -124,6 +125,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);
@@ -152,6 +154,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
@@ -324,6 +324,7 @@ CREATE TABLE `categories` ( -- this table shows information related to Koha patr
`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'.
`reset_password` TINYINT(1) NULL DEFAULT NULL, -- if patrons of this category can do the password reset flow,
`change_password` TINYINT(1) NULL DEFAULT NULL, -- if patrons of this category can change their passwords in the OAPC
+ `canbeguarantee` tinyint(1) NOT NULL default '0'
PRIMARY KEY (`categorycode`),
UNIQUE KEY `categorycode` (`categorycode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--- a/installer/data/mysql/sysprefs.sql
+++ a/installer/data/mysql/sysprefs.sql
@@ -8,6 +8,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('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'),
('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'),
+('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free'),
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
('AdlibrisCoversEnabled','0',NULL,'Display cover images in OPAC results and detail listing from Swedish retailer Adlibris.','YesNo'),
('AdlibrisCoversURL','http://www.adlibris.com/se/organisationer/showimagesafe.aspx',NULL,'Base URL for Adlibris cover image web service.','Free'),
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
@@ -12,7 +12,7 @@
[% IF CAN_user_borrowers_edit_borrowers %]
[% IF patron.is_adult AND Koha.Preference("borrowerRelationship") %]
- Add guarantee
+ Add guarantee
[% END %]
Change password
Duplicate
--- 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
+
+
+
@@ -363,6 +375,7 @@
[% END %]
+ Can be guarantee | [% IF category.canbeguarantee %]Yes[% ELSE %]No[% END %] |
Default privacy: |
@@ -422,6 +435,7 @@
[% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
| Check previous checkout? |
[% END %]
+ Can be guarantee |
Default privacy |
Actions |
@@ -526,6 +540,7 @@
[% END %]
[% END %]
+ [% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %] |
[% SWITCH category.default_privacy %]
[% CASE 'default' %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
@@ -233,6 +233,11 @@ Patrons:
no: Allow all permitted users
- "to access/change superlibrarian privileges."
- " NOTE: A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
+ -
+ - "These additional following database columns will be transferred from guarantor to guarantee:"
+ - pref: AdditionalGuarantorField
+ class: multi
+ - (separate columns with |)
Privacy:
-
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
@@ -220,7 +220,8 @@
e.preventDefault();
var borrowernumber = $(this).data("borrowernumber");
var borrower_data = $("#borrower_data"+borrowernumber).val();
- select_user( borrowernumber, JSON.parse(borrower_data) );
+ var guarantor_attributes = $("#guarantor_attributes").val();
+ select_user( borrowernumber, JSON.parse(borrower_data), JSON.parse(guarantor_attributes) );
});
$("body").on("click",".patron_preview", function( e ){
@@ -278,9 +279,9 @@
wait_for_opener();
}
[% ELSIF selection_type == 'select' %]
- function select_user(borrowernumber, data) {
+ function select_user(borrowernumber, data, attributes) {
var p = window.opener;
- p.select_user(borrowernumber, data);
+ p.select_user(borrowernumber, data, null, attributes);
window.close();
}
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
@@ -1249,7 +1249,7 @@
[% IF new_guarantors %]
[% FOREACH g IN new_guarantors %]
- select_user( '[% g.patron.borrowernumber | html %]', [% To.json( g.patron.unblessed ) | $raw %], '[% g.relationship | html %]' );
+ select_user( '[% g.patron.borrowernumber | html %]', [% To.json( g.patron.unblessed ) | $raw %], '[% g.relationship | html %]' [% IF guarantor_attributes %], [% To.json( guarantor_attributes ) | $raw %][% END %] );
[% END %]
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
@@ -252,15 +252,22 @@
[% IF guarantees %]
Guarantees:
-
[% ELSIF guarantor_relationships.count > 0 %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt
@@ -18,7 +18,7 @@
"dt_address":
"[% INCLUDE escape_address data=data %]",
"dt_action":
- "Select"
+ "Select"
}[% UNLESS loop.last %],[% END %]
[% END %]
]
--- a/koha-tmpl/intranet-tmpl/prog/js/members.js
+++ a/koha-tmpl/intranet-tmpl/prog/js/members.js
@@ -165,7 +165,7 @@ function update_category_code(category_code) {
$(mytables).find(" li[data-category_code='']").show();
}
-function select_user(borrowernumber, borrower, relationship) {
+function select_user(borrowernumber, borrower, relationship, attributes) {
let is_guarantor = $(`.guarantor-details[data-borrowernumber=${borrower.borrowernumber}]`).length;
if ( is_guarantor ) {
@@ -209,6 +209,13 @@ function select_user(borrowernumber, borrower, relationship) {
if ( relationship ) {
fieldset.find('.new_guarantor_relationship').val(relationship);
}
+
+ for (var i = 0; i < parseInt(attributes.length, 10); i++) {
+ var attribute = attributes[i];
+ if (borrower[attribute] != null){
+ document.forms.entryform[attribute].value = borrower[attribute];
+ }
+ }
}
return 0;
--- a/members/memberentry.pl
+++ a/members/memberentry.pl
@@ -770,7 +770,9 @@ if (C4::Context->preference('EnhancedMessagingPreferences')) {
$template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
}
-$template->param( "show_guarantor" => ( $category_type =~ /A|I|S|X/ ) ? 0 : 1 ); # associate with step to know where you are
+$template->param( "show_guarantor" => $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
@@ -116,6 +116,22 @@ $template->param(
my $relatives_issues_count =
Koha::Checkouts->count({ borrowernumber => \@relatives });
+my $count = scalar @guarantees;
+if ( $count ) {
+ $template->param( isguarantee => 1 );
+
+ my @guaranteedata;
+ my $amount;
+ my $totalmount = 0;
+
+ foreach my $guarantee (@guarantees){
+
+ $totalmount += $guarantee->account->balance;
+
+ }
+ $template->param( guarantees => @guarantees);
+ $template->param( amounttot => sprintf("%.2f",$totalmount));
+}
# Calculate and display patron's age
if ( !$patron->is_valid_age ) {
--- a/svc/members/search
+++ a/svc/members/search
@@ -109,12 +109,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';
--
|