Bug 14570: (QA follow-up) Fix issues in Guarantee context

Signed-off-by: Agustin Moyano <agustinmoyano@theke.io>
Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Kyle Hall 2019-08-12 14:14:39 -04:00 committed by Martin Renvoize
parent 2003521838
commit f827064bad
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F
2 changed files with 45 additions and 35 deletions

View file

@ -327,8 +327,8 @@
[% FOREACH r IN relationships %]
<fieldset class="rows">
<ol>
[% IF category_type == 'P' %]
<li id="contact-details">
[% IF category_type == 'I' %]
<li class="guarantor-details" data-borrowernumber="[% r.guarantor_id | $raw %]">
<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 %]
</li>
@ -337,7 +337,7 @@
<span>[% r.guarantor.surname | html %]</span>
</li>
[% ELSE %]
<li id="contact-details">
<li class="guarantor-details" data-borrowernumber="[% r.guarantor_id | $raw %]">
<span class="label">Patron #:</span>
<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% r.guarantor_id | uri %]" target="blank">[% r.guarantor_id | html %]</a>
</li>
@ -362,7 +362,7 @@
</li>
<li>
<label for="delete_guarantor-[% r.id | uri %]">Delete: </label>
<label for="delete_guarantor-[% r.id | uri %]">Remove: </label>
<input type="checkbox" id="delete_guarantor-[% r.id | uri %]" name="delete_guarantor" value="[% r.id | html %]" />
</li>
[% END %]
@ -373,7 +373,7 @@
<fieldset class="rows guarantor" id="guarantor_template">
<ol>
<li class="guarantor_id">
<li class="guarantor-details" data-borrowernumber="0">
<span class="label">Patron #:</span>
<span class="new_guarantor_id_text"></span>
<input type="hidden" class="new_guarantor_id" name="new_guarantor_id" value=""/>
@ -411,7 +411,7 @@
<input name="guarantor_firstname" id="guarantor_firstname" type="hidden" />
<li>
<a href="#" id="guarantor_search" class="btn btn-sm"><i class="fa fa-search"></i> Search</a>
<a href="#" id="guarantor_search" class="btn btn-sm"><i class="fa fa-plus"></i> Search to add</a>
</li>
[% IF relationships && Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %]

View file

@ -166,38 +166,48 @@ function update_category_code(category_code) {
}
function select_user(borrowernumber, borrower) {
$('#guarantor_id').val(borrower.borrowernumber);
$('#guarantor_surname').val(borrower.surname);
$('#guarantor_firstname').val(borrower.firstname);
let is_guarantor = $(`.guarantor-details[data-borrowernumber=${borrower.borrowernumber}]`).length;
console.log("LEN: " + is_guarantor );
var fieldset = $('#guarantor_template').clone();
fieldset.removeAttr('id');
var guarantor_id = $('#guarantor_id').val();
if ( guarantor_id ) {
fieldset.find('.new_guarantor_id').first().val( guarantor_id );
fieldset.find('.new_guarantor_id_text').first().text( guarantor_id );
if ( is_guarantor ) {
alert("Patron is already a guarantor for this patron");
} else {
fieldset.find('.guarantor_id').first().hide();
$('#guarantor_id').val(borrower.borrowernumber);
$('#guarantor_surname').val(borrower.surname);
$('#guarantor_firstname').val(borrower.firstname);
var fieldset = $('#guarantor_template').clone();
fieldset.removeAttr('id');
var guarantor_id = $('#guarantor_id').val();
if ( guarantor_id ) {
fieldset.find('.new_guarantor_id').first().val( guarantor_id );
fieldset.find('.new_guarantor_id_text').first().text( guarantor_id );
} else {
fieldset.find('.guarantor_id').first().hide();
}
$('#guarantor_id').val("");
var guarantor_surname = $('#guarantor_surname').val();
fieldset.find('.new_guarantor_surname').first().val( guarantor_surname );
fieldset.find('.new_guarantor_surname_text').first().text( guarantor_surname );
$('#guarantor_surname').val("");
var guarantor_firstname = $('#guarantor_firstname').val();
fieldset.find('.new_guarantor_firstname').first().val( guarantor_firstname );
fieldset.find('.new_guarantor_firstname_text').first().text( guarantor_firstname );
$('#guarantor_firstname').val("");
var guarantor_relationship = $('#relationship').val();
fieldset.find('.new_guarantor_relationship').first().val( guarantor_relationship );
$('#relationship').find('option:eq(0)').prop('selected', true);
fieldset.find('.guarantor-details').first().attr( 'data-borrowernumber', borrower.borrowernumber );
console.log( fieldset.find('.guarantor-details').first().data() );
$('#guarantor_relationships').append( fieldset );
fieldset.show();
}
$('#guarantor_id').val("");
var guarantor_surname = $('#guarantor_surname').val();
fieldset.find('.new_guarantor_surname').first().val( guarantor_surname );
fieldset.find('.new_guarantor_surname_text').first().text( guarantor_surname );
$('#guarantor_surname').val("");
var guarantor_firstname = $('#guarantor_firstname').val();
fieldset.find('.new_guarantor_firstname').first().val( guarantor_firstname );
fieldset.find('.new_guarantor_firstname_text').first().text( guarantor_firstname );
$('#guarantor_firstname').val("");
var guarantor_relationship = $('#relationship').val();
fieldset.find('.new_guarantor_relationship').first().val( guarantor_relationship );
$('#relationship').find('option:eq(0)').prop('selected', true);;
$('#guarantor_relationships').append( fieldset );
fieldset.show();
return 0;
}