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

(-)a/C4/Utils/DataTables/Members.pm (-9 / +18 lines)
Lines 77-91 sub search { Link Here
77
        }
77
        }
78
    }
78
    }
79
79
80
    my $select = "SELECT
80
    my @columns = qw( borrowernumber surname firstname othernames flags streetnumber streettype address address2 city state zipcode country cardnumber dateexpiry borrowernotes branchcode email userid dateofbirth categorycode phone phonepro mobile fax email emailpro);
81
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname,
81
82
        borrowers.othernames,
82
    my $prefillguarantorfields = C4::Context->preference("PrefillGuaranteeField");
83
        borrowers.flags,
83
    my @prefill_fields = split(/\,/,$prefillguarantorfields);
84
        borrowers.streetnumber, borrowers.streettype, borrowers.address,
84
    if ( @prefill_fields ) {
85
        borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
85
        foreach my $field (@prefill_fields) {
86
        borrowers.country, cardnumber, borrowers.dateexpiry,
86
            if (! grep {$_ eq $field} @columns) {
87
        borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
87
                push @columns, $field;
88
        borrowers.userid, borrowers.dateofbirth, borrowers.categorycode,
88
            }
89
        }
90
    };
91
92
    my $borrowers_columns = "";
93
    foreach my $item (@columns) {
94
        $borrowers_columns .= "borrowers." . $item . ", ";
95
    }
96
97
    my $select = "SELECT " . $borrowers_columns . "
89
        categories.description AS category_description, categories.category_type,
98
        categories.description AS category_description, categories.category_type,
90
        branches.branchname, borrowers.phone";
99
        branches.branchname, borrowers.phone";
91
    my $from = "FROM borrowers
100
    my $from = "FROM borrowers
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +1 lines)
Lines 249-255 Patrons: Link Here
249
           class: multi
249
           class: multi
250
         - (input multiple choices separated by |). Leave empty to deactivate.
250
         - (input multiple choices separated by |). Leave empty to deactivate.
251
     -
251
     -
252
         - "When adding a guarantee to a guarantor patron fill the following fields in the guarantee's member entry form from the guarantors record:"
252
         - "When adding a guarantor relationship to a patron fill the following unfilled fields in the guarantee's member entry form from the guarantors record:"
253
         - pref: PrefillGuaranteeField
253
         - pref: PrefillGuaranteeField
254
           multiple:
254
           multiple:
255
               B_address: "Alternate address - Address"
255
               B_address: "Alternate address - Address"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt (-3 / +7 lines)
Lines 225-231 Link Here
225
                e.preventDefault();
225
                e.preventDefault();
226
                var borrowernumber = $(this).data("borrowernumber");
226
                var borrowernumber = $(this).data("borrowernumber");
227
                var borrower_data = $("#borrower_data"+borrowernumber).val();
227
                var borrower_data = $("#borrower_data"+borrowernumber).val();
228
                select_user( borrowernumber, JSON.parse(borrower_data) );
228
                var guarantor_attributes = $("#guarantor_attributes"+borrowernumber).val();
229
                if ( !guarantor_attributes ) {
230
                    guarantor_attributes = "{}";
231
                }
232
                select_user( borrowernumber, JSON.parse(borrower_data), JSON.parse(guarantor_attributes) );
229
            });
233
            });
230
234
231
            $("body").on("click",".patron_preview", function( e ){
235
            $("body").on("click",".patron_preview", function( e ){
Lines 283-291 Link Here
283
                wait_for_opener();
287
                wait_for_opener();
284
            }
288
            }
285
        [% ELSIF selection_type == 'select' %]
289
        [% ELSIF selection_type == 'select' %]
286
            function select_user(borrowernumber, data) {
290
            function select_user(borrowernumber, data, attributes) {
287
                var p = window.opener;
291
                var p = window.opener;
288
                p.select_user(borrowernumber, data);
292
                p.select_user(borrowernumber, data, null, attributes);
289
                window.close();
293
                window.close();
290
            }
294
            }
291
        [% END %]
295
        [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-1 / +1 lines)
Lines 1581-1587 legend:hover { Link Here
1581
1581
1582
            [% IF new_guarantors %]
1582
            [% IF new_guarantors %]
1583
                [% FOREACH g IN new_guarantors %]
1583
                [% FOREACH g IN new_guarantors %]
1584
                    select_user( '[% g.patron.borrowernumber | html %]', [% To.json( g.patron.unblessed ) | $raw %], '[% g.relationship | html %]' );
1584
                    select_user( '[% g.patron.borrowernumber | html %]', [% To.json( g.patron.unblessed ) | $raw %], '[% g.relationship | html %]' [% IF guarantor_attributes %], [% To.json( guarantor_attributes ) | $raw %][% END %] );
1585
                [% END %]
1585
                [% END %]
1586
            [% END %]
1586
            [% END %]
1587
1587
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/guarantor_search.tt (-1 / +1 lines)
Lines 18-24 Link Here
18
                "dt_address":
18
                "dt_address":
19
                    "[% INCLUDE escape_address data=data %]",
19
                    "[% INCLUDE escape_address data=data %]",
20
                "dt_action":
20
                "dt_action":
21
                    "<a href=\"#\" class=\"btn btn-default btn-xs select_user\" data-borrowernumber=\"[% data.borrowernumber | html %]\">Select</a><input type=\"hidden\" id=\"borrower_data[% data.borrowernumber | html %]\" name=\"borrower_data[% data.borrowernumber | html %]\" value=\"[% To.json(data) | html %]\" />"
21
                    "<a href=\"#\" class=\"btn btn-default btn-xs select_user\" data-borrowernumber=\"[% data.borrowernumber | html %]\">Select</a><input type=\"hidden\" id=\"borrower_data[% data.borrowernumber | html %]\" name=\"borrower_data[% data.borrowernumber | html %]\" value=\"[% To.json(data) | html %]\" /><input type=\"hidden\" id=\"guarantor_attributes[% data.borrowernumber | html %]\" name=\"guarantor_attributes[% data.borrowernumber | html %]\" value=\"[% To.json(guarantor_attributes) | html %]\" />"
22
            }[% UNLESS loop.last %],[% END %]
22
            }[% UNLESS loop.last %],[% END %]
23
        [% END %]
23
        [% END %]
24
    ]
24
    ]
(-)a/koha-tmpl/intranet-tmpl/prog/js/members.js (-1 / +10 lines)
Lines 75-81 function update_category_code(category_code) { Link Here
75
    $(mytables).find(" li[data-category_code='']").show();
75
    $(mytables).find(" li[data-category_code='']").show();
76
}
76
}
77
77
78
function select_user(borrowernumber, borrower, relationship) {
78
function select_user(borrowernumber, borrower, relationship, attributes) {
79
    let is_guarantor = $(`.guarantor-details[data-borrowernumber=${borrower.borrowernumber}]`).length;
79
    let is_guarantor = $(`.guarantor-details[data-borrowernumber=${borrower.borrowernumber}]`).length;
80
80
81
    if ( is_guarantor ) {
81
    if ( is_guarantor ) {
Lines 120-125 function select_user(borrowernumber, borrower, relationship) { Link Here
120
        if ( relationship ) {
120
        if ( relationship ) {
121
            fieldset.find('.new_guarantor_relationship').val(relationship);
121
            fieldset.find('.new_guarantor_relationship').val(relationship);
122
        }
122
        }
123
124
        if ( attributes ) {
125
            for (var i = 0; i < parseInt(attributes.length, 10); i++) {
126
                var attribute = attributes[i];
127
                if ( borrower[attribute] != null && document.forms.entryform[attribute].value == "" ) {
128
                    document.forms.entryform[attribute].value = borrower[attribute];
129
                }
130
            }
131
        }
123
    }
132
    }
124
133
125
    return 0;
134
    return 0;
(-)a/svc/members/search (-1 / +4 lines)
Lines 90-101 $results = C4::Utils::DataTables::Members::search( Link Here
90
    }
90
    }
91
) unless $results;
91
) unless $results;
92
92
93
my $prefillguarantorfields = C4::Context->preference("PrefillGuaranteeField");
94
my @prefill_fields = split(/\,/,$prefillguarantorfields);
95
93
$template->param(
96
$template->param(
94
    sEcho => $sEcho,
97
    sEcho => $sEcho,
95
    iTotalRecords => $results->{iTotalRecords},
98
    iTotalRecords => $results->{iTotalRecords},
96
    iTotalDisplayRecords => $results->{iTotalDisplayRecords},
99
    iTotalDisplayRecords => $results->{iTotalDisplayRecords},
97
    aaData => $results->{patrons},
100
    aaData => $results->{patrons},
98
    selection_type => $selection_type,
101
    selection_type => $selection_type,
102
    guarantor_attributes => \@prefill_fields,
99
);
103
);
100
104
101
output_with_http_headers $input, $cookie, $template->output, 'json';
105
output_with_http_headers $input, $cookie, $template->output, 'json';
102
- 

Return to bug 26597