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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-6 / +6 lines)
Lines 327-334 Link Here
327
            [% FOREACH r IN relationships %]
327
            [% FOREACH r IN relationships %]
328
                <fieldset class="rows">
328
                <fieldset class="rows">
329
                    <ol>
329
                    <ol>
330
                        [% IF category_type == 'P' %]
330
                        [% IF category_type == 'I' %]
331
                            <li id="contact-details">
331
                            <li class="guarantor-details" data-borrowernumber="[% r.guarantor_id | $raw %]">
332
                                <span class="label">Organization #:</span> [% IF ( r.guarantor_id ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id | uri %]" target="blank">[% r.guarantor_id | html %]</a>[% END %]
332
                                <span class="label">Organization #:</span> [% IF ( r.guarantor_id ) %] <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id | uri %]" target="blank">[% r.guarantor_id | html %]</a>[% END %]
333
                            </li>
333
                            </li>
334
334
Lines 337-343 Link Here
337
                                <span>[% r.guarantor.surname | html %]</span>
337
                                <span>[% r.guarantor.surname | html %]</span>
338
                            </li>
338
                            </li>
339
                        [% ELSE %]
339
                        [% ELSE %]
340
                            <li id="contact-details">
340
                            <li class="guarantor-details" data-borrowernumber="[% r.guarantor_id | $raw %]">
341
                                <span class="label">Patron #:</span>
341
                                <span class="label">Patron #:</span>
342
                                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id | uri %]" target="blank">[% r.guarantor_id | html %]</a>
342
                                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id | uri %]" target="blank">[% r.guarantor_id | html %]</a>
343
                            </li>
343
                            </li>
Lines 362-368 Link Here
362
                            </li>
362
                            </li>
363
363
364
                            <li>
364
                            <li>
365
                                <label for="delete_guarantor-[% r.id | uri %]">Delete: </label>
365
                                <label for="delete_guarantor-[% r.id | uri %]">Remove: </label>
366
                                <input type="checkbox" id="delete_guarantor-[% r.id | uri %]" name="delete_guarantor" value="[% r.id | html %]" />
366
                                <input type="checkbox" id="delete_guarantor-[% r.id | uri %]" name="delete_guarantor" value="[% r.id | html %]" />
367
                            </li>
367
                            </li>
368
                        [% END %]
368
                        [% END %]
Lines 373-379 Link Here
373
373
374
        <fieldset class="rows guarantor" id="guarantor_template">
374
        <fieldset class="rows guarantor" id="guarantor_template">
375
            <ol>
375
            <ol>
376
                <li class="guarantor_id">
376
                <li class="guarantor-details" data-borrowernumber="0">
377
                    <span class="label">Patron #:</span>
377
                    <span class="label">Patron #:</span>
378
                    <span class="new_guarantor_id_text"></span>
378
                    <span class="new_guarantor_id_text"></span>
379
                    <input type="hidden" class="new_guarantor_id" name="new_guarantor_id" value=""/>
379
                    <input type="hidden" class="new_guarantor_id" name="new_guarantor_id" value=""/>
Lines 411-417 Link Here
411
                <input name="guarantor_firstname" id="guarantor_firstname" type="hidden" />
411
                <input name="guarantor_firstname" id="guarantor_firstname" type="hidden" />
412
412
413
                <li>
413
                <li>
414
                    <a href="#" id="guarantor_search" class="btn btn-sm"><i class="fa fa-search"></i> Search</a>
414
                    <a href="#" id="guarantor_search" class="btn btn-sm"><i class="fa fa-plus"></i> Search to add</a>
415
                </li>
415
                </li>
416
416
417
                [% IF relationships && Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %]
417
                [% IF relationships && Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/members.js (-27 / +36 lines)
Lines 166-203 function update_category_code(category_code) { Link Here
166
}
166
}
167
167
168
function select_user(borrowernumber, borrower) {
168
function select_user(borrowernumber, borrower) {
169
    $('#guarantor_id').val(borrower.borrowernumber);
169
    let is_guarantor = $(`.guarantor-details[data-borrowernumber=${borrower.borrowernumber}]`).length;
170
    $('#guarantor_surname').val(borrower.surname);
170
    console.log("LEN: "  + is_guarantor );
171
    $('#guarantor_firstname').val(borrower.firstname);
172
171
173
    var fieldset = $('#guarantor_template').clone();
172
    if ( is_guarantor ) {
174
    fieldset.removeAttr('id');
173
        alert("Patron is already a guarantor for this patron");
175
176
    var guarantor_id = $('#guarantor_id').val();
177
    if ( guarantor_id ) {
178
        fieldset.find('.new_guarantor_id').first().val( guarantor_id );
179
        fieldset.find('.new_guarantor_id_text').first().text( guarantor_id );
180
    } else {
174
    } else {
181
        fieldset.find('.guarantor_id').first().hide();
175
        $('#guarantor_id').val(borrower.borrowernumber);
182
    }
176
        $('#guarantor_surname').val(borrower.surname);
183
    $('#guarantor_id').val("");
177
        $('#guarantor_firstname').val(borrower.firstname);
178
179
        var fieldset = $('#guarantor_template').clone();
180
        fieldset.removeAttr('id');
181
182
        var guarantor_id = $('#guarantor_id').val();
183
        if ( guarantor_id ) {
184
            fieldset.find('.new_guarantor_id').first().val( guarantor_id );
185
            fieldset.find('.new_guarantor_id_text').first().text( guarantor_id );
186
        } else {
187
            fieldset.find('.guarantor_id').first().hide();
188
        }
189
        $('#guarantor_id').val("");
184
190
185
    var guarantor_surname = $('#guarantor_surname').val();
191
        var guarantor_surname = $('#guarantor_surname').val();
186
    fieldset.find('.new_guarantor_surname').first().val( guarantor_surname );
192
        fieldset.find('.new_guarantor_surname').first().val( guarantor_surname );
187
    fieldset.find('.new_guarantor_surname_text').first().text( guarantor_surname );
193
        fieldset.find('.new_guarantor_surname_text').first().text( guarantor_surname );
188
    $('#guarantor_surname').val("");
194
        $('#guarantor_surname').val("");
189
195
190
    var guarantor_firstname = $('#guarantor_firstname').val();
196
        var guarantor_firstname = $('#guarantor_firstname').val();
191
    fieldset.find('.new_guarantor_firstname').first().val( guarantor_firstname );
197
        fieldset.find('.new_guarantor_firstname').first().val( guarantor_firstname );
192
    fieldset.find('.new_guarantor_firstname_text').first().text( guarantor_firstname );
198
        fieldset.find('.new_guarantor_firstname_text').first().text( guarantor_firstname );
193
    $('#guarantor_firstname').val("");
199
        $('#guarantor_firstname').val("");
194
200
195
    var guarantor_relationship = $('#relationship').val();
201
        var guarantor_relationship = $('#relationship').val();
196
    fieldset.find('.new_guarantor_relationship').first().val( guarantor_relationship );
202
        fieldset.find('.new_guarantor_relationship').first().val( guarantor_relationship );
197
    $('#relationship').find('option:eq(0)').prop('selected', true);;
203
        $('#relationship').find('option:eq(0)').prop('selected', true);
198
204
199
    $('#guarantor_relationships').append( fieldset );
205
        fieldset.find('.guarantor-details').first().attr( 'data-borrowernumber', borrower.borrowernumber );
200
    fieldset.show();
206
        console.log( fieldset.find('.guarantor-details').first().data() );
207
208
        $('#guarantor_relationships').append( fieldset );
209
        fieldset.show();
210
    }
201
211
202
    return 0;
212
    return 0;
203
}
213
}
204
- 

Return to bug 14570