New column has now been changed to an enum in line with comments and the strings have been amended to be picked up for translation. The file koha-tmpl/intranet-tmpl/prog/en/includes/str/checkout_renewals.inc has been removed as the variables can be included within the javascript file. Test plan: 1) In the database shell run "show columns from checkout_renewals;" and observe that there is currently no column for recording the type of renewal 2) Apply patch 3) In the shell run "dbic" and "perl installer/data/mysql/updatedatabase.pl" to update the database schema with the new column. 4) Create some checkouts 5) Renew some checkouts manually and observe in the database that there is now a column called "renewal_type" that will have recorded these as "Manual" 6) Create some checkouts that can be automatically renewed 7) Run the cron script in automatic_renewals.pl and observe that there are now also entries with a renewal_type of "Automatic" 8) Send a GET request to http://localhost:8081/api/v1/checkouts/1/renewals and observe that the renewal_type is now returned in the response 9) In the Item Details tab for a record, there is the "Current renewals" option which has a button to view renewals. Click on this and observe that the modal now displays the new information. Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
29 lines
1.6 KiB
JavaScript
29 lines
1.6 KiB
JavaScript
$(document).ready(function(){
|
|
// Display the modal containing checkout renewals details
|
|
$('.checkout_renewals_view').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#checkoutRenewals #incomplete').html('').hide();
|
|
$('#checkoutRenewals #results').html('').hide();
|
|
$('#checkoutRenewals').modal({show:true});
|
|
var renewals = $(this).data('renewals');
|
|
var checkoutID = $(this).data('issueid');
|
|
$('#checkoutRenewals #retrieving').show();
|
|
$.get({ 'url': '/api/v1/checkouts/'+checkoutID+'/renewals', 'headers': { 'x-koha-embed': 'renewer' } }, function(data) {
|
|
if (data.length < renewals) {
|
|
$('#checkoutRenewals #incomplete').append(__("Note: %s out of %s renewals have been logged").format(data.length, renewals)).show();
|
|
}
|
|
var items = data.map(function(item) {
|
|
return createLi(item);
|
|
});
|
|
$('#checkoutRenewals #retrieving').hide();
|
|
$('#checkoutRenewals #results').append(items).show();
|
|
});
|
|
});
|
|
function createLi(renewal) {
|
|
if(renewal.renewal_type === "Manual"){
|
|
return '<li><span style="font-weight:bold">' + $datetime(renewal.timestamp) + '</span> ' + __("Renewed by") + ' <span style="font-weight:bold">' + $patron_to_html(renewal.renewer) + " " + __("manually") + '</span></li>';
|
|
} else {
|
|
return '<li><span style="font-weight:bold">' + $datetime(renewal.timestamp) + '</span> ' + __("Renewal type:") + ' <span style="font-weight:bold">' + __("Automatic") + '</span></li>';
|
|
}
|
|
}
|
|
});
|