View | Details | Raw Unified | Return to bug 12446
Collapse All | Expand All

(-)a/C4/Members/Attributes.pm (-1 / +16 lines)
Lines 32-38 BEGIN { Link Here
32
    @EXPORT_OK = qw(GetBorrowerAttributes GetBorrowerAttributeValue CheckUniqueness SetBorrowerAttributes
32
    @EXPORT_OK = qw(GetBorrowerAttributes GetBorrowerAttributeValue CheckUniqueness SetBorrowerAttributes
33
                    DeleteBorrowerAttribute UpdateBorrowerAttribute
33
                    DeleteBorrowerAttribute UpdateBorrowerAttribute
34
                    extended_attributes_code_value_arrayref extended_attributes_merge
34
                    extended_attributes_code_value_arrayref extended_attributes_merge
35
                    SearchIdMatchingAttribute);
35
                    SearchIdMatchingAttribute get_guarantor_shared_attributes);
36
    %EXPORT_TAGS = ( all => \@EXPORT_OK );
36
    %EXPORT_TAGS = ( all => \@EXPORT_OK );
37
}
37
}
38
38
Lines 383-388 sub _sort_by_code { Link Here
383
    return $x->{code} cmp $y->{code} || $x->{value} cmp $y->{value};
383
    return $x->{code} cmp $y->{code} || $x->{value} cmp $y->{value};
384
}
384
}
385
385
386
=head2 get_guarantor_shared_attributes
387
388
    $guarantor_attributes = get_guarantor_attributes();
389
390
    returns an array reference containing attributes to be shared between guarantor and guarantee.
391
=cut
392
sub get_guarantor_shared_attributes{
393
    my @attributes    = qw( streetnumber address address2 city state zipcode country branchcode phone phonepro mobile email emailpro fax );
394
    if( my @additional = split(/\|/, C4::Context->preference("AdditionalGuarantorField")) ){
395
        $_ =~ s/(?:^\s+)|(?:\s+$)//g for (@additional); # Trim whitespaces
396
        @attributes = ( @attributes, @additional);
397
    }
398
    return \@attributes;
399
}
400
386
=head1 AUTHOR
401
=head1 AUTHOR
387
402
388
Koha Development Team <http://koha-community.org/>
403
Koha Development Team <http://koha-community.org/>
(-)a/C4/Utils/DataTables/Members.pm (+20 lines)
Lines 2-7 package C4::Utils::DataTables::Members; Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use C4::Context;
4
use C4::Context;
5
use C4::Members qw/GetMemberIssuesAndFines/;
6
use C4::Members::Attributes qw/get_guarantor_shared_attributes/;
5
use C4::Utils::DataTables;
7
use C4::Utils::DataTables;
6
use Koha::DateUtils;
8
use Koha::DateUtils;
7
9
Lines 47-52 sub search { Link Here
47
49
48
    }
50
    }
49
51
52
<<<<<<< HEAD
50
    my $select = "SELECT
53
    my $select = "SELECT
51
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname,
54
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname,
52
        borrowers.streetnumber, borrowers.streettype, borrowers.address,
55
        borrowers.streetnumber, borrowers.streettype, borrowers.address,
Lines 54-59 sub search { Link Here
54
        borrowers.country, cardnumber, borrowers.dateexpiry,
57
        borrowers.country, cardnumber, borrowers.dateexpiry,
55
        borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
58
        borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
56
        borrowers.userid, borrowers.dateofbirth, borrowers.categorycode,
59
        borrowers.userid, borrowers.dateofbirth, borrowers.categorycode,
60
=======
61
    my $dbh = C4::Context->dbh;
62
    my @columns = qw( borrowernumber surname firstname streetnumber streettype address address2 city state zipcode country cardnumber dateexpiry borrowernotes branchcode email userid dateofbirth categorycode );
63
    if( my @guarantor_attributes = @{ get_guarantor_shared_attributes() }){
64
        foreach my $item (@guarantor_attributes) {
65
             if (! grep {$_ eq $item} @columns) {
66
                 push @columns, $item;
67
	     }
68
	}
69
    };
70
    my $borrowers_columns = "";
71
    foreach my $item (@columns) {
72
        $borrowers_columns .= "borrowers." . $item . ", ";
73
    }
74
75
    my $select = "SELECT " . $borrowers_columns . "
76
>>>>>>> Bug 12446 - Enable an adult to have a guarantor
57
        categories.description AS category_description, categories.category_type,
77
        categories.description AS category_description, categories.category_type,
58
        branches.branchname";
78
        branches.branchname";
59
    my $from = "FROM borrowers
79
    my $from = "FROM borrowers
(-)a/Koha/Schema/Result/Category.pm (+8 lines)
Lines 109-114 __PACKAGE__->table("categories"); Link Here
109
  default_value: -1
109
  default_value: -1
110
  is_nullable: 0
110
  is_nullable: 0
111
111
112
=head2 canbeguarantee
113
114
  data_type: 'tinyint'
115
  default_value: 0
116
  is_nullable: 0
117
112
=head2 default_privacy
118
=head2 default_privacy
113
119
114
  data_type: 'enum'
120
  data_type: 'enum'
Lines 161-166 __PACKAGE__->add_columns( Link Here
161
    default_value => -1,
167
    default_value => -1,
162
    is_nullable   => 0,
168
    is_nullable   => 0,
163
  },
169
  },
170
  "canbeguarantee",
171
  { data_type => "tinyint", default_value => 0, is_nullable => 0},
164
  "default_privacy",
172
  "default_privacy",
165
  {
173
  {
166
    data_type => "enum",
174
    data_type => "enum",
(-)a/admin/categories.pl (+3 lines)
Lines 93-98 elsif ( $op eq 'add_validate' ) { Link Here
93
    my $checkPrevCheckout = $input->param('checkprevcheckout');
93
    my $checkPrevCheckout = $input->param('checkprevcheckout');
94
    my $default_privacy = $input->param('default_privacy');
94
    my $default_privacy = $input->param('default_privacy');
95
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
95
    my @branches = grep { $_ ne q{} } $input->multi_param('branches');
96
    my $canbeguarantee = $input->param('canbeguarantee');
96
97
97
    my $is_a_modif = $input->param("is_a_modif");
98
    my $is_a_modif = $input->param("is_a_modif");
98
99
Lines 119-124 elsif ( $op eq 'add_validate' ) { Link Here
119
        $category->hidelostitems($hidelostitems);
120
        $category->hidelostitems($hidelostitems);
120
        $category->overduenoticerequired($overduenoticerequired);
121
        $category->overduenoticerequired($overduenoticerequired);
121
        $category->category_type($category_type);
122
        $category->category_type($category_type);
123
        $category->canbeguarantee($canbeguarantee);
122
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
124
        $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions);
123
        $category->checkprevcheckout($checkPrevCheckout);
125
        $category->checkprevcheckout($checkPrevCheckout);
124
        $category->default_privacy($default_privacy);
126
        $category->default_privacy($default_privacy);
Lines 145-150 elsif ( $op eq 'add_validate' ) { Link Here
145
            hidelostitems => $hidelostitems,
147
            hidelostitems => $hidelostitems,
146
            overduenoticerequired => $overduenoticerequired,
148
            overduenoticerequired => $overduenoticerequired,
147
            category_type => $category_type,
149
            category_type => $category_type,
150
            canbeguarantee => $canbeguarantee,
148
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
151
            BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions,
149
            checkprevcheckout => $checkPrevCheckout,
152
            checkprevcheckout => $checkPrevCheckout,
150
            default_privacy => $default_privacy,
153
            default_privacy => $default_privacy,
(-)a/installer/data/mysql/atomicupdate/bug_12446-EnableAdultGarantee.sql (+11 lines)
Line 0 Link Here
1
-- ******** --
2
-- SYSPREFS --
3
-- ******** --
4
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` )
5
VALUES ('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free');
6
7
-- ********* --
8
-- STRUCTURE --
9
-- ********* --
10
ALTER TABLE categories ADD COLUMN `canbeguarantee` tinyint(1) NOT NULL default '0';
11
UPDATE categories SET canbeguarantee = 1 WHERE category_type = 'P' OR category_type = 'C';
(-)a/installer/data/mysql/kohastructure.sql (-3 / +4 lines)
Lines 328-335 CREATE TABLE `categories` ( -- this table shows information related to Koha patr Link Here
328
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
328
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
329
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
329
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
330
  `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
330
  `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
331
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
331
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category,
332
  `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'.
332
  `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'.
333
  `canbeguarantee` tinyint(1) NOT NULL default '0'
333
  PRIMARY KEY  (`categorycode`),
334
  PRIMARY KEY  (`categorycode`),
334
  UNIQUE KEY `categorycode` (`categorycode`)
335
  UNIQUE KEY `categorycode` (`categorycode`)
335
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
336
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Lines 898-904 CREATE TABLE `refund_lost_item_fee_rules` ( -- refund lost item fee rules tbale Link Here
898
--
899
--
899
900
900
DROP TABLE IF EXISTS `items`;
901
DROP TABLE IF EXISTS `items`;
901
CREATE TABLE `items` ( -- holdings/item information 
902
CREATE TABLE `items` ( -- holdings/item information
902
  `itemnumber` int(11) NOT NULL auto_increment, -- primary key and unique identifier added by Koha
903
  `itemnumber` int(11) NOT NULL auto_increment, -- primary key and unique identifier added by Koha
903
  `biblionumber` int(11) NOT NULL default 0, -- foreign key from biblio table used to link this item to the right bib record
904
  `biblionumber` int(11) NOT NULL default 0, -- foreign key from biblio table used to link this item to the right bib record
904
  `biblioitemnumber` int(11) NOT NULL default 0, -- foreign key from the biblioitems table to link to item to additional information
905
  `biblioitemnumber` int(11) NOT NULL default 0, -- foreign key from the biblioitems table to link to item to additional information
Lines 2239-2245 CREATE TABLE `userflags` ( Link Here
2239
--
2240
--
2240
2241
2241
DROP TABLE IF EXISTS `virtualshelves`;
2242
DROP TABLE IF EXISTS `virtualshelves`;
2242
CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves) 
2243
CREATE TABLE `virtualshelves` ( -- information about lists (or virtual shelves)
2243
  `shelfnumber` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2244
  `shelfnumber` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
2244
  `shelfname` varchar(255) default NULL, -- name of the list
2245
  `shelfname` varchar(255) default NULL, -- name of the list
2245
  `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)
2246
  `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 (+2 lines)
Lines 6-11 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
6
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
7
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
9
('AdditionalGuarantorField','',NULL,'Additional fields name to be transfer from guarantor to guarantee.','free'),
10
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
9
('AddressFormat','us','','Choose format to display postal addresses', 'Choice'),
11
('AddressFormat','us','','Choose format to display postal addresses', 'Choice'),
10
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
12
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
11
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
13
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (-1 / +1 lines)
Lines 143-149 function searchToHold(){ Link Here
143
143
144
    [% IF ( CAN_user_borrowers ) %]
144
    [% IF ( CAN_user_borrowers ) %]
145
        [% IF ( adultborrower AND activeBorrowerRelationship ) %]
145
        [% IF ( adultborrower AND activeBorrowerRelationship ) %]
146
            <a id="addchild" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantorid=[% borrowernumber %]"><i class="fa fa-plus"></i> Add child</a>
146
            <a id="addchild" class="btn btn-small" href="/cgi-bin/koha/members/memberentry.pl?op=add&amp;guarantorid=[% borrowernumber %]&amp;category_type=C"><i class="fa fa-plus"></i> Add guarantee</a>
147
        [% END %]
147
        [% END %]
148
        [% IF ( CAN_user_borrowers ) %]
148
        [% IF ( CAN_user_borrowers ) %]
149
            <a id="changepassword" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/member-password.pl?member=[% borrowernumber %]"><i class="fa fa-lock"></i> Change password</a>
149
            <a id="changepassword" class="btn btn-default btn-sm" href="/cgi-bin/koha/members/member-password.pl?member=[% borrowernumber %]"><i class="fa fa-lock"></i> Change password</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt (+15 lines)
Lines 151-156 Link Here
151
                    </select>
151
                    </select>
152
                    <span class="required">Required</span>
152
                    <span class="required">Required</span>
153
                </li>
153
                </li>
154
                <li>
155
                    <label for="canbeguarantee">Can be guarantee</label>
156
                    <select name="canbeguarantee" id="canbeguarantee">
157
                        [% IF category.canbeguarantee %]
158
                            <option value="1" selected>Yes</option>
159
                            <option value="0">No</option>
160
                        [% ELSE %]
161
                            <option value="1">Yes</option>
162
                            <option value="0" selected>No</option>
163
                        [% END %]
164
                    <select>
165
                </li>
154
                <li><label for="branches">Branches limitation: </label>
166
                <li><label for="branches">Branches limitation: </label>
155
                    <select id="branches" name="branches" multiple size="10">
167
                    <select id="branches" name="branches" multiple size="10">
156
                        <option value="">All branches</option>
168
                        <option value="">All branches</option>
Lines 299-304 Link Here
299
                      </td>
311
                      </td>
300
                  </tr>
312
                  </tr>
301
                [% END %]
313
                [% END %]
314
                <tr><th scope="row">Can be guarantee</th><td>[% IF category.canbeguarantee %]Yes[% ELSE %]No[% END %]</td></tr>
302
                <tr>
315
                <tr>
303
                    <th scope="row">Default privacy: </th>
316
                    <th scope="row">Default privacy: </th>
304
                    <td>
317
                    <td>
Lines 358-363 Link Here
358
                    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
371
                    [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %]
359
                    <th scope="col">Check previous checkout?</th>
372
                    <th scope="col">Check previous checkout?</th>
360
                    [% END %]
373
                    [% END %]
374
                    <th scope="col">Can be guarantee</th>
361
                    <th scope="col">Default privacy</th>
375
                    <th scope="col">Default privacy</th>
362
                    <th scope="col">Actions</th>
376
                    <th scope="col">Actions</th>
363
                </tr>
377
                </tr>
Lines 446-451 Link Here
446
                              [% END %]
460
                              [% END %]
447
                          </td>
461
                          </td>
448
                        [% END %]
462
                        [% END %]
463
                        <td>[% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %]</td>
449
                        <td>
464
                        <td>
450
                            [% SWITCH category.default_privacy %]
465
                            [% SWITCH category.default_privacy %]
451
                            [% CASE 'default' %]
466
                            [% CASE 'default' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+5 lines)
Lines 190-196 Patrons: Link Here
190
               yes: Do
190
               yes: Do
191
               no: "Don't"
191
               no: "Don't"
192
         - track last patron activity.
192
         - track last patron activity.
193
    -
193
         - Everytime a patron will connect, the borrowers.lastseen will be updated with the current time.
194
         - Everytime a patron will connect, the borrowers.lastseen will be updated with the current time.
195
         - "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:"
196
         - pref: AdditionalGuarantorField
197
           class: multi
198
         - (separate columns with |)
194
    "Norwegian patron database":
199
    "Norwegian patron database":
195
     -
200
     -
196
         - pref: NorwegianPatronDBEnable
201
         - pref: NorwegianPatronDBEnable
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt (-3 / +4 lines)
Lines 113-119 $(document).ready(function(){ Link Here
113
        e.preventDefault();
113
        e.preventDefault();
114
        var borrowernumber = $(this).data("borrowernumber");
114
        var borrowernumber = $(this).data("borrowernumber");
115
        var borrower_data = $("#borrower_data"+borrowernumber).val();
115
        var borrower_data = $("#borrower_data"+borrowernumber).val();
116
        select_user( borrowernumber, JSON.parse(borrower_data) );
116
        var guarantor_attributes = $("#guarantor_attributes").val();
117
        select_user( borrowernumber, JSON.parse(borrower_data), JSON.parse(guarantor_attributes) );
117
    });
118
    });
118
119
119
});
120
});
Lines 160-168 function filterByFirstLetterSurname(letter) { Link Here
160
            wait_for_opener();
161
            wait_for_opener();
161
        }
162
        }
162
    [% ELSIF selection_type == 'select' %]
163
    [% ELSIF selection_type == 'select' %]
163
        function select_user(borrowernumber, data) {
164
        function select_user(borrowernumber, data, attributes) {
164
            var p = window.opener;
165
            var p = window.opener;
165
            p.select_user(borrowernumber, data);
166
            p.select_user(borrowernumber, data, attributes);
166
            window.close();
167
            window.close();
167
        }
168
        }
168
    [% END %]
169
    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-4 / +2 lines)
Lines 409-415 $(document).ready(function() { Link Here
409
	            [% END %]
409
	            [% END %]
410
	        </li>
410
	        </li>
411
[% ELSE %]
411
[% ELSE %]
412
 [% IF ( C ) %]
413
 [% IF ( guarantorid ) %]
412
 [% IF ( guarantorid ) %]
414
 <li id="contact-details">
413
 <li id="contact-details">
415
 [% ELSE %]
414
 [% ELSE %]
Lines 427-435 $(document).ready(function() { Link Here
427
        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
426
        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
428
     [% END %]
427
     [% END %]
429
 </li>
428
 </li>
430
        [% END %]
429
     [% UNLESS nocontactfirstname %]
431
        [% UNLESS nocontactfirstname %]
430
<li>
432
 <li>
433
     <label for="contactfirstname">First name: </label>
431
     <label for="contactfirstname">First name: </label>
434
     [% IF ( guarantorid ) %]
432
     [% IF ( guarantorid ) %]
435
     <span>[% contactfirstname %]</span>
433
     <span>[% contactfirstname %]</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-12 / +18 lines)
Lines 218-225 function validate1(date) { Link Here
218
   [% title | html %] [% firstname | html %] [% END %] [% surname | html %] ([% cardnumber | html %])</h3>
218
   [% title | html %] [% firstname | html %] [% END %] [% surname | html %] ([% cardnumber | html %])</h3>
219
 <div class="yui-u first">
219
 <div class="yui-u first">
220
<div id="patron-information" style="padding : .5em;">
220
<div id="patron-information" style="padding : .5em;">
221
221
     [% UNLESS ( I ) %][% IF ( othernames ) %]&ldquo;[% othernames %]&rdquo;[% END %]
222
     [% UNLESS ( I ) %][% IF ( othernames ) %]&ldquo;[% othernames | html %]&rdquo;[% END %]
223
222
224
    <div class = "address">
223
    <div class = "address">
225
        [% IF Koha.Preference( 'AddressFormat' ) %]
224
        [% IF Koha.Preference( 'AddressFormat' ) %]
Lines 250-265 function validate1(date) { Link Here
250
    [% IF ( sex ) %]<li><span class="label">Gender:</span>
249
    [% IF ( sex ) %]<li><span class="label">Gender:</span>
251
    [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
250
    [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
252
    </li>[% END %][% END %]
251
    </li>[% END %][% END %]
253
    [% IF guarantees %]
252
    [% IF ( isguarantee ) %]
254
        <li>
253
        [% IF ( guaranteeloop ) %]
255
            <span class="label">Guarantees:</span>
254
            <li><span class="label">Guarantees:</span>
256
            <ul>
255
                <table>[% FOREACH guaranteeloo IN guaranteeloop %]
257
                [% FOREACH guarantee IN guarantees %]
256
                <tr>
258
                    <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
257
                    <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]</a></td>
259
                [% END %]
258
                    <td style='text-align:right'>[% guaranteeloo.finesguarantee %]</td>
260
            </ul>
259
                </tr>[% END %]
261
        </li>
260
                <tr>
262
    [% ELSIF guarantor %]
261
                    <td>Total</td>
262
                    <td style='text-align:right'>[% amounttot %]</td>
263
                </tr>
264
                </table>
265
            </li>
266
        [% END %]
267
    [% END %]
268
    [% IF ( isguarantor ) %]
263
        <li>
269
        <li>
264
            <span class="label">Guarantor:</span>
270
            <span class="label">Guarantor:</span>
265
            [% IF guarantor.borrowernumber %]
271
            [% IF guarantor.borrowernumber %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt (-1 / +1 lines)
Lines 17-23 Link Here
17
                "dt_address":
17
                "dt_address":
18
                    "[% INCLUDE escape_address data=data %]",
18
                    "[% INCLUDE escape_address data=data %]",
19
                "dt_action":
19
                "dt_action":
20
                    "<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 %]\" />"
20
                    "<a href=\"#\" class=\"btn btn-mini select_user\" data-borrowernumber=\"[% data.borrowernumber %]\">Select</a><input type=\"hidden\" id=\"guarantor_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 %]\" />"
21
            }[% UNLESS loop.last %],[% END %]
21
            }[% UNLESS loop.last %],[% END %]
22
        [% END %]
22
        [% END %]
23
    ]
23
    ]
(-)a/koha-tmpl/intranet-tmpl/prog/js/members.js (-13 / +7 lines)
Lines 183-189 function update_category_code(category_code) { Link Here
183
    $(mytables).find(" li[data-category_code='']").show();
183
    $(mytables).find(" li[data-category_code='']").show();
184
}
184
}
185
185
186
function select_user(borrowernumber, borrower) {
186
function select_user(borrowernumber, borrower, attributes) {
187
    var form = $('#entryform').get(0);
187
    var form = $('#entryform').get(0);
188
    if (form.guarantorid.value) {
188
    if (form.guarantorid.value) {
189
        $("#contact-details, #quick_add_form #contact-details").find('a').remove();
189
        $("#contact-details, #quick_add_form #contact-details").find('a').remove();
Lines 205-219 function select_user(borrowernumber, borrower) { Link Here
205
        .val(borrower.firstname)
205
        .val(borrower.firstname)
206
        .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
206
        .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden';
207
    $("#quick_add_form #contactfirstname").val(borrower.firstname).before('<span>'+borrower.firstname+'</span.').attr({type:"hidden"});
207
    $("#quick_add_form #contactfirstname").val(borrower.firstname).before('<span>'+borrower.firstname+'</span.').attr({type:"hidden"});
208
208
    
209
    form.streetnumber.value = borrower.streetnumber;
209
    form.guarantorsearch.value = LABEL_CHANGE;
210
    form.address.value = borrower.address;
210
     for (var i = 0; i < attributes.length; i++) {
211
    form.address2.value = borrower.address2;
211
       var attribute = attributes[i];
212
    form.city.value = borrower.city;
212
       document.forms.entryform[attribute].value = borrower[attribute];
213
    form.state.value = borrower.state;
213
     }   
214
    form.zipcode.value = borrower.zipcode;
215
    form.country.value = borrower.country;
216
    form.branchcode.value = borrower.branchcode;
217
214
218
    $("#quick_add_form #streetnumber").val(borrower.streetnumber);
215
    $("#quick_add_form #streetnumber").val(borrower.streetnumber);
219
    $("#quick_add_form #address").val(borrower.address);
216
    $("#quick_add_form #address").val(borrower.address);
Lines 224-232 function select_user(borrowernumber, borrower) { Link Here
224
    $("#quick_add_form #country").val(borrower.country);
221
    $("#quick_add_form #country").val(borrower.country);
225
    $("#quick_add_form select[name='branchcode']").val(borrower.branchcode);
222
    $("#quick_add_form select[name='branchcode']").val(borrower.branchcode);
226
223
227
    form.guarantorsearch.value = LABEL_CHANGE;
228
    $("#quick_add_form #guarantorsearch").val(LABEL_CHANGE);
229
230
    return 0;
224
    return 0;
231
}
225
}
232
226
(-)a/members/memberentry.pl (-9 / +11 lines)
Lines 242-262 if ( ( $op eq 'insert' ) and !$nodouble ) { Link Here
242
    }
242
    }
243
}
243
}
244
244
245
  #recover all data from guarantor address phone ,fax... 
245
#recover all data from guarantor address phone ,fax...
246
if ( $guarantorid ) {
246
if ( $guarantorid) {
247
247
    if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
248
    if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
248
        $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
249
        $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
249
        $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
250
        $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
250
        $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
251
        $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
251
        $newdata{'contactname'}     = $guarantordata->{'surname'};
252
        $newdata{'contactname'}     = $guarantordata->{'surname'};
252
        $newdata{'contacttitle'}    = $guarantordata->{'title'};
253
        $newdata{'contacttitle'}    = $guarantordata->{'title'};
254
253
        if ( $op eq 'add' ) {
255
        if ( $op eq 'add' ) {
254
	        foreach (qw(streetnumber address streettype address2
256
            my @attributes = @{C4::Members::Attributes::get_guarantor_shared_attributes()};
255
                        zipcode country city state phone phonepro mobile fax email emailpro branchcode
257
            foreach my $attribute (@attributes) {
256
                        B_streetnumber B_streettype B_address B_address2
258
                $newdata{$attribute} = $guarantordata->{$attribute};
257
                        B_city B_state B_zipcode B_country B_email B_phone)) {
259
            }
258
		        $newdata{$_} = $guarantordata->{$_};
259
	        }
260
        }
260
        }
261
    }
261
    }
262
}
262
}
Lines 721-727 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
721
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
721
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
722
}
722
}
723
723
724
$template->param( "showguarantor"  => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are
724
$template->param( "showguarantor"  => $categorycode ? Koha::Patron::Categories->find($categorycode)->canbeguarantee : 1); # associate with step to know where you are
725
726
$template->param( "guarantor_attributes" => C4::Members::Attributes::get_guarantor_shared_attributes() );
725
$debug and warn "memberentry step: $step";
727
$debug and warn "memberentry step: $step";
726
$template->param(%data);
728
$template->param(%data);
727
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
729
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
(-)a/members/moremember.pl (-3 / +30 lines)
Lines 173-179 if ( $category_type eq 'C') { Link Here
173
173
174
my @relatives;
174
my @relatives;
175
if ( my $guarantor = $patron->guarantor ) {
175
if ( my $guarantor = $patron->guarantor ) {
176
    $template->param( guarantor => $guarantor );
177
    push @relatives, $guarantor->borrowernumber;
176
    push @relatives, $guarantor->borrowernumber;
178
    push @relatives, $_->borrowernumber for $patron->siblings;
177
    push @relatives, $_->borrowernumber for $patron->siblings;
179
} elsif ( $patron->contactname || $patron->contactfirstname ) {
178
} elsif ( $patron->contactname || $patron->contactfirstname ) {
Lines 185-199 if ( my $guarantor = $patron->guarantor ) { Link Here
185
    );
184
    );
186
} else {
185
} else {
187
    my @guarantees = $patron->guarantees;
186
    my @guarantees = $patron->guarantees;
188
    $template->param( guarantees => \@guarantees );
189
    push @relatives, $_->borrowernumber for @guarantees;
187
    push @relatives, $_->borrowernumber for @guarantees;
190
}
188
}
191
189
192
my $relatives_issues_count =
190
my $relatives_issues_count =
193
  Koha::Database->new()->schema()->resultset('Issue')
191
  Koha::Database->new()->schema()->resultset('Issue')
194
  ->count( { borrowernumber => \@relatives } );
192
  ->count( { borrowernumber => \@relatives } );
193
my @guarantees = $patron->guarantees;
194
my $count = scalar @guarantees;
195
if ( $count ) {
196
    $template->param( isguarantee => 1 );
197
198
    my @guaranteedata;
199
    my $amount;
200
    my $totalmount = 0;
201
202
    foreach my $guarantee (@guarantees){
203
        my ($amount,$accts,undef) = GetMemberAccountRecords($guarantee->borrowernumber);
204
        push(@guaranteedata,
205
            {
206
                borrowernumber => $guarantee->borrowernumber,
207
                cardnumber     => $guarantee->cardnumber,
208
                finesguarantee => sprintf("%.2f",$amount),
209
                name           => $guarantee->firstname . " "
210
                                . $guarantee->surname
211
            }
212
        );
213
        $totalmount += $amount;
214
    }
215
    $template->param( guaranteeloop => \@guaranteedata );
216
    $template->param( amounttot => sprintf("%.2f",$totalmount));
217
}
218
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' || $category_type eq 'I' );
195
219
196
$template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
220
if (my $guarantor = $patron->guarantor){
221
	$template->param(isguarantor => 1);
222
    $template->param(guarantor => $guarantor);
223
}
197
224
198
my %bor;
225
my %bor;
199
$bor{'borrowernumber'} = $borrowernumber;
226
$bor{'borrowernumber'} = $borrowernumber;
(-)a/svc/members/search (-1 / +2 lines)
Lines 108-119 if ($has_permission) { Link Here
108
    $results->{iTotalDisplayRecords} = scalar( @patrons_with_permission );
108
    $results->{iTotalDisplayRecords} = scalar( @patrons_with_permission );
109
}
109
}
110
110
111
my @attributes = C4::Members::Attributes::get_guarantor_shared_attributes();
111
$template->param(
112
$template->param(
112
    sEcho => $sEcho,
113
    sEcho => $sEcho,
113
    iTotalRecords => $results->{iTotalRecords},
114
    iTotalRecords => $results->{iTotalRecords},
114
    iTotalDisplayRecords => $results->{iTotalDisplayRecords},
115
    iTotalDisplayRecords => $results->{iTotalDisplayRecords},
115
    aaData => $results->{patrons},
116
    aaData => $results->{patrons},
116
    selection_type => $selection_type,
117
    selection_type => $selection_type,
118
    attributes => @attributes
117
);
119
);
118
120
119
output_with_http_headers $input, $cookie, $template->output, 'json';
121
output_with_http_headers $input, $cookie, $template->output, 'json';
120
- 

Return to bug 12446