|
Lines 92-97
Link Here
|
| 92 |
[% IF nochanges %] |
92 |
[% IF nochanges %] |
| 93 |
<div class="alert alert-error">No changes were made.</div> |
93 |
<div class="alert alert-error">No changes were made.</div> |
| 94 |
[% END %] |
94 |
[% END %] |
|
|
95 |
[% IF self_renewal %] |
| 96 |
<div class="alert alert-info">Please verify your details to proceed with your self-renewal.</div> |
| 97 |
[% END %] |
| 95 |
[% END %] |
98 |
[% END %] |
| 96 |
|
99 |
|
| 97 |
[% IF empty_mandatory_fields %] |
100 |
[% IF empty_mandatory_fields %] |
|
Lines 241-247
Link Here
|
| 241 |
> |
244 |
> |
| 242 |
[% END %] |
245 |
[% END %] |
| 243 |
|
246 |
|
| 244 |
<form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off"> |
247 |
<form method="post" [% IF (self_renewal) %]action="/api/v1/public/patrons/self_renewal" id="self-renewal-form"[% ELSE %]action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form"[% END %] autocomplete="off"> |
| 245 |
[% INCLUDE 'csrf-token.inc' %] |
248 |
[% INCLUDE 'csrf-token.inc' %] |
| 246 |
|
249 |
|
| 247 |
[% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferred_name' 'middle_name' 'dateofbirth' 'initials' 'pronouns' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_streetnumber' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' 'lang' ] %] |
250 |
[% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferred_name' 'middle_name' 'dateofbirth' 'initials' 'pronouns' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_streetnumber' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' 'lang' ] %] |
|
Lines 1362-1368
Link Here
|
| 1362 |
[% IF OPACPatronDetails %] |
1365 |
[% IF OPACPatronDetails %] |
| 1363 |
<fieldset class="action"> |
1366 |
<fieldset class="action"> |
| 1364 |
<input type="hidden" name="op" value="cud-update" /> |
1367 |
<input type="hidden" name="op" value="cud-update" /> |
| 1365 |
<input type="submit" class="btn btn-primary" value="Submit update request" /> |
1368 |
[% IF (self_renewal) %] |
|
|
1369 |
<input type="submit" class="btn btn-primary" value="Submit renewal request" /> |
| 1370 |
[% ELSE %] |
| 1371 |
<input type="submit" class="btn btn-primary" value="Submit update request" /> |
| 1372 |
[% END %] |
| 1366 |
</fieldset> |
1373 |
</fieldset> |
| 1367 |
[% END %] |
1374 |
[% END %] |
| 1368 |
[% ELSE %] |
1375 |
[% ELSE %] |
|
Lines 1391-1406
Link Here
|
| 1391 |
[% INCLUDE 'calendar.inc' %] |
1398 |
[% INCLUDE 'calendar.inc' %] |
| 1392 |
<script> |
1399 |
<script> |
| 1393 |
$(document).ready(function() { |
1400 |
$(document).ready(function() { |
|
|
1401 |
let formName |
| 1402 |
[% IF (self_renewal) %] |
| 1403 |
formName = 'self-renewal-form' |
| 1404 |
[% ELSE %] |
| 1405 |
formName = 'memberentry-form' |
| 1406 |
[% END %] |
| 1407 |
|
| 1394 |
[% IF op == 'edit' && !OPACPatronDetails %] |
1408 |
[% IF op == 'edit' && !OPACPatronDetails %] |
| 1395 |
$("#memberentry-form :input").attr('readonly', true); |
1409 |
$("#" + formName + " :input").attr('readonly', true); |
| 1396 |
$("#borrower_branchcode").attr('disabled',true); |
1410 |
$("#borrower_branchcode").attr('disabled',true); |
| 1397 |
$("#borrower_title").attr('disabled',true); |
1411 |
$("#borrower_title").attr('disabled',true); |
| 1398 |
$('#memberentry-form :radio').attr('disabled',true); |
1412 |
$('#' + formName + ' :radio').attr('disabled',true); |
| 1399 |
$('span.required').remove(); |
1413 |
$('span.required').remove(); |
| 1400 |
$('label.required').removeClass('required'); |
1414 |
$('label.required').removeClass('required'); |
| 1401 |
[% END %] |
1415 |
[% END %] |
| 1402 |
|
1416 |
|
| 1403 |
$("#memberentry-form").validate({ |
1417 |
$("#" + formName).validate({ |
| 1404 |
rules: { |
1418 |
rules: { |
| 1405 |
borrower_email: { |
1419 |
borrower_email: { |
| 1406 |
email: true |
1420 |
email: true |
|
Lines 1430-1437
Link Here
|
| 1430 |
return false; |
1444 |
return false; |
| 1431 |
} |
1445 |
} |
| 1432 |
else { |
1446 |
else { |
| 1433 |
form.beenSubmitted = true; |
1447 |
if(formName === 'self-renewal-form') { |
| 1434 |
form.submit(); |
1448 |
const formValues = $(form).serializeArray() |
|
|
1449 |
const renewalBody = formValues.reduce((body, curr, i) => { |
| 1450 |
if(curr.name.includes("borrower")) { |
| 1451 |
const fieldName = curr.name.replace("borrower_", "") |
| 1452 |
body[fieldName] = curr.value |
| 1453 |
} |
| 1454 |
if(curr.name === "patron_attribute_code") { |
| 1455 |
const matchingValue = formValues[i + 1].value |
| 1456 |
body.extended_attributes.push({code: curr.value, attribute: matchingValue}) |
| 1457 |
} |
| 1458 |
return body |
| 1459 |
}, {extended_attributes: []}) |
| 1460 |
const options = { |
| 1461 |
url: $(form).attr('action'), |
| 1462 |
method: $(form).attr('method').toUpperCase(), |
| 1463 |
contentType: 'application/json', |
| 1464 |
data: JSON.stringify(renewalBody) |
| 1465 |
}; |
| 1466 |
$.ajax(options) |
| 1467 |
.then(function(result) { |
| 1468 |
let newLocation = "/cgi-bin/koha/opac-user.pl?self_renewal_success=" + result.expiry_date |
| 1469 |
if(result.confirmation_sent) { |
| 1470 |
newLocation += "&confirmation_sent=1" |
| 1471 |
} |
| 1472 |
document.location = newLocation |
| 1473 |
}) |
| 1474 |
.fail(function(err) { |
| 1475 |
document.location = "/cgi-bin/koha/opac-user.pl?self_renewal_success=0"; |
| 1476 |
}); |
| 1477 |
} else { |
| 1478 |
form.beenSubmitted = true; |
| 1479 |
form.submit(); |
| 1480 |
} |
| 1435 |
} |
1481 |
} |
| 1436 |
} |
1482 |
} |
| 1437 |
}); |
1483 |
}); |