Martin Renvoize
ef880e349f
This patch cleans out the print media css rules that were originally added for modalprinting. The window.open method is simpler to maintain and will more reliably print modal content as expected. We factor out the printer code into it's own JS asset that we can apply to other printable modals and then use it in the two existing places where such modals have been defined already (cashup summary and bundle confirmation). Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
44 lines
2.2 KiB
JavaScript
44 lines
2.2 KiB
JavaScript
$(document).ready(function() {
|
|
$('#cashupSummaryModal').on('show.bs.modal', function(e) {
|
|
var button = $(e.relatedTarget);
|
|
var cashup = button.data('cashup');
|
|
var description = button.data('register');
|
|
var summary_modal = $(this);
|
|
summary_modal.find('#register_description').text(description);
|
|
$.ajax({
|
|
url: '/api/v1/cashups/' + cashup,
|
|
headers: {
|
|
'x-koha-embed': 'summary'
|
|
},
|
|
async: false,
|
|
success: function(data) {
|
|
let from_date = $datetime(data.summary.from_date);
|
|
summary_modal.find('#from_date').text(from_date);
|
|
let to_date = $datetime(data.summary.to_date);
|
|
summary_modal.find('#to_date').text(to_date);
|
|
var tbody = summary_modal.find('tbody')
|
|
tbody.empty();
|
|
for (out of data.summary.payout_grouped) {
|
|
if (out.credit_type_code == 'REFUND') {
|
|
tbody.append('<tr><td>' + __x('{credit_type_description} against {debit_type_description}', { 'credit_type_description': escape_str(out.credit_type.description), 'debit_type_description': escape_str(out.related_debit.debit_type.description) }) + '</td><td>- ' + out.total.format_price() + '</td></tr>');
|
|
} else {
|
|
tbody.append('<tr><td>' + escape_str(out.credit_type.description) + '</td><td>- ' + out.total.format_price() + '</td></tr>');
|
|
}
|
|
}
|
|
|
|
for (income of data.summary.income_grouped) {
|
|
tbody.append('<tr><td>' + escape_str(income.debit_type.description) + '</td><td>' + income.total.format_price() + '</td></tr>');
|
|
}
|
|
|
|
var tfoot = summary_modal.find('tfoot');
|
|
tfoot.empty();
|
|
tfoot.append('<tr><td>Total</td><td>' + data.summary.total.format_price() + '</td></tr>');
|
|
for (type of data.summary.total_grouped) {
|
|
if (type.total !== 0) {
|
|
tfoot.append('<tr><td>' + escape_str(type.payment_type) + '</td><td>' + type.total.format_price() + '</td></tr>');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|