Koha/koha-tmpl/intranet-tmpl/prog/js/cart.js
Joonas Kylmälä 52b5a22edf Bug 28782: Use query param list instead of splitting elements using '/'
This removes the need to handle single and multiple cases separately,
thus removing bunch if-else cases and simplifying our code. This
coding style is also in line with our other .pl scripts.

To test:
 1) Make sure placing a hold still works from the following pages:

   /cgi-bin/koha/catalogue/detail.pl?biblionumber=XXX

   /cgi-bin/koha/catalogue/search.pl?q=a

   /cgi-bin/koha/virtualshelves/shelves.pl?op=view&shelfnumber=XXXX

   /cgi-bin/koha/clubs/clubs.pl (create a new club and add a patron
   there and through the clubs.pl create a hold to a bib)

Signed-off-by: Hayley Pelham <hayleypelham@catalyst.net.nz>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-03-03 16:11:50 -10:00

149 lines
3.8 KiB
JavaScript

/* global __ dataTablesDefaults showMore showLess delSelRecords addSelToShelf sendBasket printBasket delBasket openBiblio selRecord */
function placeHold () {
var checkedItems = $("input:checkbox:checked");
if ($(checkedItems).size() === 0) {
alert( __("No item was selected") );
return false;
}
var bib_params = [];
$(checkedItems).each(function() {
var bib = $(this).val();
bib_params.push("biblionumber=" + bib);
});
if (bib_params.length > 1) {
bib_params.push('multi_hold=1');
}
window.opener.location = "/cgi-bin/koha/reserve/request.pl?" + bib_params.join('&');
window.close();
}
function batchDelete(){
var checkedItems = $("input:checkbox:checked");
if ($(checkedItems).size() === 0) {
alert( __("No item was selected") );
return false;
}
var newloc;
var bibs = "";
checkedItems.each(function() {
var bib = $(this).val();
bibs += bib + "/";
});
newloc = "/cgi-bin/koha/tools/batch_delete_records.pl?op=list&type=biblio&bib_list=" + bibs;
window.opener.location = newloc;
window.close();
}
function batchModify(){
var checkedItems = $("input:checkbox:checked");
if ($(checkedItems).size() === 0) {
alert( __("No item was selected") );
return false;
}
var newloc;
var bibs = "";
$(checkedItems).each(function() {
var bib = $(this).val();
bibs += bib + "/";
});
newloc = "/cgi-bin/koha/tools/batch_record_modification.pl?op=list&amp;bib_list=" + bibs + "&type=biblio";
window.opener.location = newloc;
window.close();
}
$(document).ready(function(){
$("#items-popover").popover();
$("#CheckAll").click(function (e) {
e.preventDefault();
$(".select_record").each(function () {
$(this).prop("checked", true).change();
});
});
$("#CheckNone").click(function (e) {
e.preventDefault();
$(".select_record").each(function () {
$(this).prop("checked", false).change();
});
});
$(".holdsep").text("| ");
$(".hold").text( __("Place hold") );
$("#downloadcartc").empty();
$("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, {
"sDom": 't',
"aoColumnDefs": [
{ "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "sType": "callnumbers", "aTargets" : [ "callnumbers"] }
],
"aaSorting": [[ 1, "asc" ]],
"bPaginate": false
}));
$(".showdetails").on("click",function(e){
e.preventDefault();
if( $(this).hasClass("showmore") ){
showMore();
} else {
showLess();
}
});
$("#batch_modify").on("click",function(e){
e.preventDefault();
batchModify();
});
$("#batch_delete").on("click",function(e){
e.preventDefault();
batchDelete();
});
$("#remove_from_cart").on("click",function(e){
e.preventDefault();
delSelRecords();
});
$("#add_to_list").on("click",function(e){
e.preventDefault();
addSelToShelf();
});
$("#place_hold").on("click",function(e){
e.preventDefault();
placeHold();
});
$("#send_cart").on("click",function(e){
e.preventDefault();
sendBasket();
});
$("#print_cart").on("click",function(e){
e.preventDefault();
printBasket();
});
$("#empty_cart").on("click",function(e){
e.preventDefault();
delBasket('popup');
});
$(".title").on("click",function(e){
e.preventDefault();
openBiblio( this.href );
});
$(".select_record").on("change",function(){
selRecord( this.value, this.checked );
});
});