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

(-)a/C4/Members/Attributes.pm (-1 / +18 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
392
=cut
393
394
sub get_guarantor_shared_attributes{
395
    my @attributes    = qw( streetnumber address address2 city state zipcode country branchcode phone phonepro mobile email emailpro fax );
396
    if( my @additional = split(/\|/, C4::Context->preference("AdditionalGuarantorField")) ){
397
        $_ =~ s/(?:^\s+)|(?:\s+$)//g for (@additional); # Trim whitespaces
398
        @attributes = ( @attributes, @additional);
399
    }
400
    return \@attributes;
401
}
402
386
=head1 AUTHOR
403
=head1 AUTHOR
387
404
388
Koha Development Team <http://koha-community.org/>
405
Koha Development Team <http://koha-community.org/>
(-)a/C4/Utils/DataTables/Members.pm (-7 / +17 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;
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-59 sub search { Link Here
47
49
48
    }
50
    }
49
51
50
    my $select = "SELECT
52
    $dbh = C4::Context->dbh;
51
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname,
53
    my @columns = qw( borrowernumber surname firstname streetnumber streettype address address2 city state zipcode country cardnumber dateexpiry borrowernotes branchcode email userid dateofbirth categorycode );
52
        borrowers.streetnumber, borrowers.streettype, borrowers.address,
54
    if( my @guarantor_attributes = @{ get_guarantor_shared_attributes() }){
53
        borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
55
        foreach my $item (@guarantor_attributes) {
54
        borrowers.country, cardnumber, borrowers.dateexpiry,
56
             if (! grep {$_ eq $item} @columns) {
55
        borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
57
                 push @columns, $item;
56
        borrowers.userid, borrowers.dateofbirth, borrowers.categorycode,
58
            }
59
        }
60
    };
61
    my $borrowers_columns = "";
62
    foreach my $item (@columns) {
63
        $borrowers_columns .= "borrowers." . $item . ", ";
64
    }
65
66
    my $select = "SELECT " . $borrowers_columns . "
57
        categories.description AS category_description, categories.category_type,
67
        categories.description AS category_description, categories.category_type,
58
        branches.branchname";
68
        branches.branchname";
59
    my $from = "FROM borrowers
69
    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 (-1 / +2 lines)
Lines 331-338 CREATE TABLE `categories` ( -- this table shows information related to Koha patr Link Here
331
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
331
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
332
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
332
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
333
  `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
333
  `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
334
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
334
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category,
335
  `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'.
335
  `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'.
336
  `canbeguarantee` tinyint(1) NOT NULL default '0'
336
  PRIMARY KEY  (`categorycode`),
337
  PRIMARY KEY  (`categorycode`),
337
  UNIQUE KEY `categorycode` (`categorycode`)
338
  UNIQUE KEY `categorycode` (`categorycode`)
338
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
339
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
(-)a/installer/data/mysql/sysprefs.sql (-1 / +3 lines)
Lines 6-12 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
('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'),
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'),
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'),
12
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
14
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (-2 / +2 lines)
Lines 142-149 function searchToHold(){ Link Here
142
    [% END %]
142
    [% END %]
143
143
144
    [% IF ( CAN_user_borrowers ) %]
144
    [% IF ( CAN_user_borrowers ) %]
145
        [% IF adultborrower AND Koha.Preference("borrowerRelationship") %]
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 462-467 Link Here
462
                              [% END %]
476
                              [% END %]
463
                          </td>
477
                          </td>
464
                        [% END %]
478
                        [% END %]
479
                        <td>[% IF category.canbeguarantee %] Yes [% ELSE %] no [% END %]</td>
465
                        <td>
480
                        <td>
466
                            [% SWITCH category.default_privacy %]
481
                            [% SWITCH category.default_privacy %]
467
                            [% CASE 'default' %]
482
                            [% 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 407-413 $(document).ready(function() { Link Here
407
	            [% END %]
407
	            [% END %]
408
	        </li>
408
	        </li>
409
[% ELSE %]
409
[% ELSE %]
410
 [% IF ( C ) %]
411
 [% IF ( guarantorid ) %]
410
 [% IF ( guarantorid ) %]
412
 <li id="contact-details">
411
 <li id="contact-details">
413
 [% ELSE %]
412
 [% ELSE %]
Lines 425-433 $(document).ready(function() { Link Here
425
        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
424
        <input name="contactname" id="contactname" type="text" size="20" value="[% contactname | html %]" />
426
     [% END %]
425
     [% END %]
427
 </li>
426
 </li>
428
        [% END %]
427
     [% UNLESS nocontactfirstname %]
429
        [% UNLESS nocontactfirstname %]
428
<li>
430
 <li>
431
     <label for="contactfirstname">First name: </label>
429
     <label for="contactfirstname">First name: </label>
432
     [% IF ( guarantorid ) %]
430
     [% IF ( guarantorid ) %]
433
     <span>[% contactfirstname %]</span>
431
     <span>[% contactfirstname %]</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-12 / +18 lines)
Lines 222-229 function validate1(date) { Link Here
222
   [% title | html %] [% firstname | html %] [% END %] [% surname | html %] ([% cardnumber | html %])</h3>
222
   [% title | html %] [% firstname | html %] [% END %] [% surname | html %] ([% cardnumber | html %])</h3>
223
 <div class="yui-u first">
223
 <div class="yui-u first">
224
<div id="patron-information" style="padding : .5em;">
224
<div id="patron-information" style="padding : .5em;">
225
225
     [% UNLESS ( I ) %][% IF ( othernames ) %]&ldquo;[% othernames %]&rdquo;[% END %]
226
     [% UNLESS ( I ) %][% IF ( othernames ) %]&ldquo;[% othernames | html %]&rdquo;[% END %]
227
226
228
    <div class = "address">
227
    <div class = "address">
229
        [% IF Koha.Preference( 'AddressFormat' ) %]
228
        [% IF Koha.Preference( 'AddressFormat' ) %]
Lines 254-269 function validate1(date) { Link Here
254
    [% IF ( sex ) %]<li><span class="label">Gender:</span>
253
    [% IF ( sex ) %]<li><span class="label">Gender:</span>
255
    [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
254
    [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
256
    </li>[% END %][% END %]
255
    </li>[% END %][% END %]
257
    [% IF guarantees %]
256
    [% IF ( isguarantee ) %]
258
        <li>
257
        [% IF ( guaranteeloop ) %]
259
            <span class="label">Guarantees:</span>
258
            <li><span class="label">Guarantees:</span>
260
            <ul>
259
                <table>[% FOREACH guaranteeloo IN guaranteeloop %]
261
                [% FOREACH guarantee IN guarantees %]
260
                <tr>
262
                    <li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guarantee.borrowernumber %]">[% guarantee.firstname | html %] [% guarantee.surname | html %]</a></li>
261
                    <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]</a></td>
263
                [% END %]
262
                    <td style='text-align:right'>[% guaranteeloo.finesguarantee %]</td>
264
            </ul>
263
                </tr>[% END %]
265
        </li>
264
                <tr>
266
    [% ELSIF guarantor %]
265
                    <td>Total</td>
266
                    <td style='text-align:right'>[% amounttot %]</td>
267
                </tr>
268
                </table>
269
            </li>
270
        [% END %]
271
    [% END %]
272
    [% IF ( isguarantor ) %]
267
        <li>
273
        <li>
268
            <span class="label">Guarantor:</span>
274
            <span class="label">Guarantor:</span>
269
            [% IF guarantor.borrowernumber %]
275
            [% 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=\"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 %]\" />"
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 (-12 / +6 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 206-219 function select_user(borrowernumber, borrower) { Link Here
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 240-260 if ( ( $op eq 'insert' ) and !$nodouble ) { Link Here
240
    }
240
    }
241
}
241
}
242
242
243
  #recover all data from guarantor address phone ,fax... 
243
#recover all data from guarantor address phone ,fax...
244
if ( $guarantorid ) {
244
if ( $guarantorid) {
245
245
    if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
246
    if (my $guarantordata=GetMember(borrowernumber => $guarantorid)) {
246
        $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
247
        $category_type = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C';
247
        $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
248
        $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
248
        $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
249
        $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
249
        $newdata{'contactname'}     = $guarantordata->{'surname'};
250
        $newdata{'contactname'}     = $guarantordata->{'surname'};
250
        $newdata{'contacttitle'}    = $guarantordata->{'title'};
251
        $newdata{'contacttitle'}    = $guarantordata->{'title'};
252
251
        if ( $op eq 'add' ) {
253
        if ( $op eq 'add' ) {
252
	        foreach (qw(streetnumber address streettype address2
254
            my @attributes = @{C4::Members::Attributes::get_guarantor_shared_attributes()};
253
                        zipcode country city state phone phonepro mobile fax email emailpro branchcode
255
            foreach my $attribute (@attributes) {
254
                        B_streetnumber B_streettype B_address B_address2
256
                $newdata{$attribute} = $guarantordata->{$attribute};
255
                        B_city B_state B_zipcode B_country B_email B_phone)) {
257
            }
256
		        $newdata{$_} = $guarantordata->{$_};
257
	        }
258
        }
258
        }
259
    }
259
    }
260
}
260
}
Lines 720-726 if (C4::Context->preference('EnhancedMessagingPreferences')) { Link Here
720
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
720
    $template->param(TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"));
721
}
721
}
722
722
723
$template->param( "showguarantor"  => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are
723
$template->param( "showguarantor"  => $categorycode ? Koha::Patron::Categories->find($categorycode)->canbeguarantee : 1); # associate with step to know where you are
724
725
$template->param( "guarantor_attributes" => C4::Members::Attributes::get_guarantor_shared_attributes() );
724
$debug and warn "memberentry step: $step";
726
$debug and warn "memberentry step: $step";
725
$template->param(%data);
727
$template->param(%data);
726
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
728
$template->param( "step_$step"  => 1) if $step;	# associate with step to know where u are
(-)a/members/moremember.pl (-3 / +30 lines)
Lines 177-183 if ( $category_type eq 'C') { Link Here
177
177
178
my @relatives;
178
my @relatives;
179
if ( my $guarantor = $patron->guarantor ) {
179
if ( my $guarantor = $patron->guarantor ) {
180
    $template->param( guarantor => $guarantor );
181
    push @relatives, $guarantor->borrowernumber;
180
    push @relatives, $guarantor->borrowernumber;
182
    push @relatives, $_->borrowernumber for $patron->siblings;
181
    push @relatives, $_->borrowernumber for $patron->siblings;
183
} elsif ( $patron->contactname || $patron->contactfirstname ) {
182
} elsif ( $patron->contactname || $patron->contactfirstname ) {
Lines 189-203 if ( my $guarantor = $patron->guarantor ) { Link Here
189
    );
188
    );
190
} else {
189
} else {
191
    my @guarantees = $patron->guarantees;
190
    my @guarantees = $patron->guarantees;
192
    $template->param( guarantees => \@guarantees );
193
    push @relatives, $_->borrowernumber for @guarantees;
191
    push @relatives, $_->borrowernumber for @guarantees;
194
}
192
}
195
193
196
my $relatives_issues_count =
194
my $relatives_issues_count =
197
  Koha::Database->new()->schema()->resultset('Issue')
195
  Koha::Database->new()->schema()->resultset('Issue')
198
  ->count( { borrowernumber => \@relatives } );
196
  ->count( { borrowernumber => \@relatives } );
197
my @guarantees = $patron->guarantees;
198
my $count = scalar @guarantees;
199
if ( $count ) {
200
    $template->param( isguarantee => 1 );
201
202
    my @guaranteedata;
203
    my $amount;
204
    my $totalmount = 0;
205
206
    foreach my $guarantee (@guarantees){
207
        my ($amount,$accts,undef) = GetMemberAccountRecords($guarantee->borrowernumber);
208
        push(@guaranteedata,
209
            {
210
                borrowernumber => $guarantee->borrowernumber,
211
                cardnumber     => $guarantee->cardnumber,
212
                finesguarantee => sprintf("%.2f",$amount),
213
                name           => $guarantee->firstname . " "
214
                                . $guarantee->surname
215
            }
216
        );
217
        $totalmount += $amount;
218
    }
219
    $template->param( guaranteeloop => \@guaranteedata );
220
    $template->param( amounttot => sprintf("%.2f",$totalmount));
221
}
222
( $template->param( adultborrower => 1 ) ) if ( $category_type eq 'A' || $category_type eq 'I' );
199
223
200
$template->param( adultborrower => 1 ) if ( $category_type eq 'A' || $category_type eq 'I' );
224
if (my $guarantor = $patron->guarantor){
225
    $template->param(isguarantor => 1);
226
    $template->param(guarantor => $guarantor);
227
}
201
228
202
my %bor;
229
my %bor;
203
$bor{'borrowernumber'} = $borrowernumber;
230
$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