[Koha-bugs] [Bug 12446] Enable an adult to have a guarantor
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Wed Jul 5 13:55:24 CEST 2017
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12446
--- Comment #55 from Philippe Audet-Fortin <philippe.audet-fortin at inlibro.com> ---
Comment on attachment 64793
--> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=64793
Cam 722: Permet a n'importe quelle categorie d'avoir un garant (bz12446)
>From 0ca1ba90904daea5fac5285799b38f8dfb0b6265 Mon Sep 17 00:00:00 2001
>From: Paudet <philippe.audet-fortin at inlibro.com>
>Date: Tue, 4 Jul 2017 16:41:04 -0400
>Subject: [PATCH] Cam 722: Permet a n'importe quelle categorie d'avoir un
> garant (bz12446)
>
>Il s'agit du code du bz 12446 collapse en un commit.
>---
> C4/Members/Attributes.pm | 19 ++++++++++++-
> C4/Utils/DataTables/Members.pm | 24 +++++++++++-----
> Koha/Schema/Result/Category.pm | 8 ++++++
> admin/categories.pl | 3 ++
> .../atomicupdate/bug_12446-EnableAdultGarantee.sql | 11 ++++++++
> installer/data/mysql/kohastructure.sql | 3 +-
> installer/data/mysql/sysprefs.sql | 4 ++-
> .../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 | 6 ++--
> .../prog/en/modules/members/moremember.tt | 30 ++++++++++++--------
> .../en/modules/members/tables/guarantor_search.tt | 2 +-
> koha-tmpl/intranet-tmpl/prog/js/members.js | 18 ++++--------
> members/memberentry.pl | 20 +++++++------
> members/moremember.pl | 33 ++++++++++++++++++++--
> svc/members/search | 2 ++
> 17 files changed, 156 insertions(+), 54 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 ab43a7c..2f3bd49 100644
>--- a/C4/Members/Attributes.pm
>+++ b/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,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 <http://koha-community.org/>
>diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm
>index 302eaff..846bcb3 100644
>--- a/C4/Utils/DataTables/Members.pm
>+++ b/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;
>
>@@ -47,13 +49,21 @@ 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,
>+ $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 );
>+ 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 fc26a7d..f655fd9 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'
>@@ -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",
>diff --git a/admin/categories.pl b/admin/categories.pl
>index 358ef7d..dbaaf48 100755
>--- a/admin/categories.pl
>+++ b/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,
>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..56462a7
>--- /dev/null
>+++ b/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';
>diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
>index e9c60aa..7e3bc48 100644
>--- a/installer/data/mysql/kohastructure.sql
>+++ b/installer/data/mysql/kohastructure.sql
>@@ -331,8 +331,9 @@ 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,
> `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'.
>+ `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 0bd8cac..27173df 100644
>--- a/installer/data/mysql/sysprefs.sql
>+++ b/installer/data/mysql/sysprefs.sql
>@@ -6,7 +6,9 @@ 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'),
>-('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
>+('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'),
> ('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
>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 e33b36f..b115aa4 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt
>+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt
>@@ -151,6 +151,18 @@
> </select>
> <span class="required">Required</span>
> </li>
>+ <li>
>+ <label for="canbeguarantee">Can be guarantee</label>
>+ <select name="canbeguarantee" id="canbeguarantee">
>+ [% IF category.canbeguarantee %]
>+ <option value="1" selected>Yes</option>
>+ <option value="0">No</option>
>+ [% ELSE %]
>+ <option value="1">Yes</option>
>+ <option value="0" selected>No</option>
>+ [% END %]
>+ <select>
>+ </li>
> <li><label for="branches">Branches limitation: </label>
> <select id="branches" name="branches" multiple size="10">
> <option value="">All branches</option>
>@@ -299,6 +311,7 @@
> </td>
> </tr>
> [% END %]
>+ <tr><th scope="row">Can be guarantee</th><td>[% IF category.canbeguarantee %]Yes[% ELSE %]No[% END %]</td></tr>
> <tr>
> <th scope="row">Default privacy: </th>
> <td>
>@@ -358,6 +371,7 @@
> [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
> <th scope="col">Check previous checkout?</th>
> [% END %]
>+ <th scope="col">Can be guarantee</th>
> <th scope="col">Default privacy</th>
> <th scope="col">Actions</th>
> </tr>
>@@ -462,6 +476,7 @@
> [% END %]
> </td>
> [% END %]
>+ <td>[% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %]</td>
> <td>
> [% SWITCH category.default_privacy %]
> [% CASE 'default' %]
>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 ac4946d..fe0c78a 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
>@@ -190,7 +190,12 @@ Patrons:
> yes: Do
> no: "Don't"
> - track last patron activity.
>+ -
> - Everytime a patron will connect, the borrowers.lastseen will be updated with the current time.
>+ - "These additional following <a href='http://schema.koha-community.org/tables/borrowers.html' target='blank'>database columns</a> will be transferred from guarantor to guarantee:"
>+ - pref: AdditionalGuarantorField
>+ class: multi
>+ - (separate columns with |)
> "Norwegian patron database":
> -
> - pref: NorwegianPatronDBEnable
>diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
>index 9fe6473..ab0d15e 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
>+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt
>@@ -113,7 +113,8 @@ $(document).ready(function(){
> 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) );
> });
>
> });
>@@ -160,9 +161,9 @@ function filterByFirstLetterSurname(letter) {
> 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, attributes);
> window.close();
> }
> [% END %]
>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 7f6f734..710d9ba 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
>+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
>@@ -407,7 +407,6 @@ $(document).ready(function() {
> [% END %]
> </li>
> [% ELSE %]
>- [% IF ( C ) %]
> [% IF ( guarantorid ) %]
> <li id="contact-details">
> [% ELSE %]
>@@ -425,9 +424,8 @@ $(document).ready(function() {
> <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
> [% END %]
> </li>
>- [% END %]
>- [% UNLESS nocontactfirstname %]
>- <li>
>+ [% UNLESS nocontactfirstname %]
>+<li>
> <label for="contactfirstname">First name: </label>
> [% IF ( guarantorid ) %]
> <span>[% contactfirstname %]</span>
>diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
>index 6e5308f..c106093 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
>+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
>@@ -222,8 +222,7 @@ function validate1(date) {
> [% title | html %] [% firstname | html %] [% END %] [% surname | html %] ([% cardnumber | html %])</h3>
> <div class="yui-u first">
> <div id="patron-information" style="padding : .5em;">
>-
>- [% UNLESS ( I ) %][% IF ( othernames ) %]“[% othernames | html %]”[% END %]
>+ [% UNLESS ( I ) %][% IF ( othernames ) %]“[% othernames %]”[% END %]
>
> <div class = "address">
> [% IF Koha.Preference( 'AddressFormat' ) %]
>@@ -254,16 +253,23 @@ function validate1(date) {
> [% IF ( sex ) %]<li><span class="label">Gender:</span>
> [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
> </li>[% END %][% END %]
>- [% IF guarantees %]
>- <li>
>- <span class="label">Guarantees:</span>
>- <ul>
>- [% FOREACH guarantee IN guarantees %]
>- <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
>- [% END %]
>- </ul>
>- </li>
>- [% ELSIF guarantor %]
>+ [% IF ( isguarantee ) %]
>+ [% IF ( guaranteeloop ) %]
>+ <li><span class="label">Guarantees:</span>
>+ <table>[% FOREACH guaranteeloo IN guaranteeloop %]
>+ <tr>
>+ <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]</a></td>
>+ <td style='text-align:right'>[% guaranteeloo.finesguarantee %]</td>
>+ </tr>[% END %]
>+ <tr>
>+ <td>Total</td>
>+ <td style='text-align:right'>[% amounttot %]</td>
>+ </tr>
>+ </table>
>+ </li>
>+ [% END %]
>+ [% END %]
>+ [% IF ( isguarantor ) %]
> <li>
> <span class="label">Guarantor:</span>
> [% IF guarantor.borrowernumber %]
>diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt
>index f1bb9a1..5817391 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt
>+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt
>@@ -17,7 +17,7 @@
> "dt_address":
> "[% INCLUDE escape_address data=data %]",
> "dt_action":
>- "<a href=\"#\" class=\"btn btn-default btn-xs select_user\" data-borrowernumber=\"[% data.borrowernumber %]\">Select</a><input type=\"hidden\" id=\"borrower_data[% data.borrowernumber %]\" name=\"borrower_data[% data.borrowernumber %]\" value=\"[% To.json(data) | html %]\" />"
>+ "<a href=\"#\" class=\"btn btn-mini select_user\" data-borrowernumber=\"[% data.borrowernumber %]\">Select</a><input type=\"hidden\" id=\"borrower_data[% data.borrowernumber %]\" name=\"guarantor_data\" value=\"[% To.json(data) | html %]\" /><input type=\"hidden\" id=\"guarantor_attributes\" name=\"guarantor_attributes\" value=\"[% To.json(attributes) | html %]\" />"
> }[% UNLESS loop.last %],[% END %]
> [% END %]
> ]
>diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js
>index 28853b2..c476469 100644
>--- a/koha-tmpl/intranet-tmpl/prog/js/members.js
>+++ b/koha-tmpl/intranet-tmpl/prog/js/members.js
>@@ -183,7 +183,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, #quick_add_form #contact-details").find('a').remove();
>@@ -206,14 +206,11 @@ function select_user(borrowernumber, borrower) {
> .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
> $("#quick_add_form #contactfirstname").val(borrower.firstname).before('<span>'+borrower.firstname+'</span.').attr({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];
>+ }
>
> $("#quick_add_form #streetnumber").val(borrower.streetnumber);
> $("#quick_add_form #address").val(borrower.address);
>@@ -224,9 +221,6 @@ function select_user(borrowernumber, borrower) {
> $("#quick_add_form #country").val(borrower.country);
> $("#quick_add_form select[name='branchcode']").val(borrower.branchcode);
>
>- form.guarantorsearch.value = LABEL_CHANGE;
>- $("#quick_add_form #guarantorsearch").val(LABEL_CHANGE);
>-
> return 0;
> }
>
>diff --git a/members/memberentry.pl b/members/memberentry.pl
>index 2ffea5d..eef8554 100755
>--- a/members/memberentry.pl
>+++ b/members/memberentry.pl
>@@ -240,21 +240,21 @@ 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) {
>+
> if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
> $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
> $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
> $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
> $newdata{'contactname'} = $guarantordata->{'surname'};
> $newdata{'contacttitle'} = $guarantordata->{'title'};
>+
> if ( $op eq 'add' ) {
>- foreach (qw(streetnumber address streettype address2
>- 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->{$_};
>- }
>+ my @attributes = @{C4::Members::Attributes::get_guarantor_shared_attributes()};
>+ foreach my $attribute (@attributes) {
>+ $newdata{$attribute} = $guarantordata->{$attribute};
>+ }
> }
> }
> }
>@@ -720,7 +720,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
>diff --git a/members/moremember.pl b/members/moremember.pl
>index 0649dcf..1767a5c 100755
>--- a/members/moremember.pl
>+++ b/members/moremember.pl
>@@ -177,7 +177,6 @@ if ( $category_type eq 'C') {
>
> 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 ) {
>@@ -189,15 +188,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;
>diff --git a/svc/members/search b/svc/members/search
>index 4f798ab..cdebc80 100755
>--- a/svc/members/search
>+++ b/svc/members/search
>@@ -108,12 +108,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';
>--
>1.9.1
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list