|
Lines 252-311
Link Here
|
| 252 |
var holds_to_modify_table_settings = [% TablesSettings.GetTableSettings( 'tools', 'batch_hold_modification', 'holds_to_modify', 'json' ) | $raw %]; |
252 |
var holds_to_modify_table_settings = [% TablesSettings.GetTableSettings( 'tools', 'batch_hold_modification', 'holds_to_modify', 'json' ) | $raw %]; |
| 253 |
var modified_holds_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %]; |
253 |
var modified_holds_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %]; |
| 254 |
</script> |
254 |
</script> |
| 255 |
|
|
|
| 256 |
<script> |
255 |
<script> |
| 257 |
$(document).ready(function() { |
256 |
$(document).ready(function () { |
| 258 |
|
|
|
| 259 |
// Apply select2 to all select fields having a "multiple" attribute |
257 |
// Apply select2 to all select fields having a "multiple" attribute |
| 260 |
let selectFields = document.querySelectorAll('select[multiple]'); |
258 |
let selectFields = document.querySelectorAll("select[multiple]"); |
| 261 |
selectFields.forEach((selectField) => { |
259 |
selectFields.forEach(selectField => { |
| 262 |
selectField.style.minWidth = '200px'; |
260 |
selectField.style.minWidth = "200px"; |
| 263 |
$(selectField).select2(); |
261 |
$(selectField).select2(); |
| 264 |
}); |
262 |
}); |
| 265 |
|
263 |
|
| 266 |
//Empty local storage from previous selections |
264 |
//Empty local storage from previous selections |
| 267 |
localStorage.removeItem("holds_modify_selections"); |
265 |
localStorage.removeItem("holds_modify_selections"); |
| 268 |
|
266 |
|
| 269 |
$("#holds_to_modify").on("change", "input[type='checkbox']", function(){ |
267 |
$("#holds_to_modify").on("change", "input[type='checkbox']", function () { |
| 270 |
var holds_modify_selections = JSON.parse(localStorage.getItem("holds_modify_selections")) || []; |
268 |
var holds_modify_selections = JSON.parse(localStorage.getItem("holds_modify_selections")) || []; |
| 271 |
var hold_id = $(this).val(); |
269 |
var hold_id = $(this).val(); |
| 272 |
if ($(this).prop("checked")) { |
270 |
if ($(this).prop("checked")) { |
| 273 |
|
|
|
| 274 |
hold_data = { |
271 |
hold_data = { |
| 275 |
hold_id: hold_id, |
272 |
hold_id: hold_id, |
| 276 |
found_status: $(this).closest('tr').find('.found_status').children('span').data('found-status'), |
273 |
found_status: $(this).closest("tr").find(".found_status").children("span").data("found-status"), |
| 277 |
suspended: $(this).closest('tr').find('.suspended').children('span').data('suspended'), |
274 |
suspended: $(this).closest("tr").find(".suspended").children("span").data("suspended"), |
| 278 |
} |
275 |
}; |
| 279 |
|
276 |
|
| 280 |
holds_modify_selections.push(hold_data); |
277 |
holds_modify_selections.push(hold_data); |
| 281 |
localStorage.setItem("holds_modify_selections", JSON.stringify(holds_modify_selections)); |
278 |
localStorage.setItem("holds_modify_selections", JSON.stringify(holds_modify_selections)); |
| 282 |
showHoldSelections(holds_modify_selections.length); |
279 |
showHoldSelections(holds_modify_selections.length); |
| 283 |
} else { |
280 |
} else { |
| 284 |
var filtered = holds_modify_selections.filter(function( hold_obj ){ |
281 |
var filtered = holds_modify_selections.filter(function (hold_obj) { |
| 285 |
return hold_obj.hold_id !== hold_id; |
282 |
return hold_obj.hold_id !== hold_id; |
| 286 |
}); |
283 |
}); |
| 287 |
if( filtered.length > 0 ){ |
284 |
if (filtered.length > 0) { |
| 288 |
localStorage.setItem("holds_modify_selections", JSON.stringify( filtered )); |
285 |
localStorage.setItem("holds_modify_selections", JSON.stringify(filtered)); |
| 289 |
holds_modify_selections = filtered; |
286 |
holds_modify_selections = filtered; |
| 290 |
showHoldSelections( filtered.length ); |
287 |
showHoldSelections(filtered.length); |
| 291 |
} else { |
288 |
} else { |
| 292 |
holds_modify_selections = []; |
289 |
holds_modify_selections = []; |
| 293 |
localStorage.removeItem("holds_modify_selections"); |
290 |
localStorage.removeItem("holds_modify_selections"); |
| 294 |
showHoldSelections( 0 ); |
291 |
showHoldSelections(0); |
| 295 |
} |
292 |
} |
| 296 |
} |
293 |
} |
| 297 |
}); |
294 |
}); |
| 298 |
|
295 |
|
| 299 |
$("#select_all").on("click", function(e){ |
296 |
$("#select_all").on("click", function (e) { |
| 300 |
e.preventDefault(); |
297 |
e.preventDefault(); |
| 301 |
$("#holds_to_modify input[type='checkbox']").each(function(){ |
298 |
$("#holds_to_modify input[type='checkbox']").each(function () { |
| 302 |
$(this).prop("checked", true).change(); |
299 |
$(this).prop("checked", true).change(); |
| 303 |
}); |
300 |
}); |
| 304 |
}); |
301 |
}); |
| 305 |
|
302 |
|
| 306 |
$("#clear_all").on("click", function(e){ |
303 |
$("#clear_all").on("click", function (e) { |
| 307 |
e.preventDefault(); |
304 |
e.preventDefault(); |
| 308 |
$("#holds_to_modify input[type='checkbox']").each(function(){ |
305 |
$("#holds_to_modify input[type='checkbox']").each(function () { |
| 309 |
$(this).prop("checked", false).change(); |
306 |
$(this).prop("checked", false).change(); |
| 310 |
}); |
307 |
}); |
| 311 |
}); |
308 |
}); |
|
Lines 317-396
Link Here
|
| 317 |
$("#table_search_selections").hide(); |
314 |
$("#table_search_selections").hide(); |
| 318 |
}); |
315 |
}); |
| 319 |
|
316 |
|
| 320 |
$('#modify_holds_form').submit(function() { |
317 |
$("#modify_holds_form").submit(function () { |
| 321 |
var modify_holds_form = $(this); |
318 |
var modify_holds_form = $(this); |
| 322 |
search_holds(modify_holds_form); |
319 |
search_holds(modify_holds_form); |
| 323 |
$("#modify_holds_search").hide(); |
320 |
$("#modify_holds_search").hide(); |
| 324 |
$('#edit_search').show(); |
321 |
$("#edit_search").show(); |
| 325 |
return false; |
322 |
return false; |
| 326 |
}); |
323 |
}); |
| 327 |
|
324 |
|
| 328 |
if(hold_ids_from_sql.length > 0){ |
325 |
if (hold_ids_from_sql.length > 0) { |
| 329 |
$('#modify_holds_form').trigger('submit'); |
326 |
$("#modify_holds_form").trigger("submit"); |
| 330 |
} |
327 |
} |
| 331 |
|
328 |
|
| 332 |
$("#edit_search").on("click", function(e){ |
329 |
$("#edit_search").on("click", function (e) { |
| 333 |
e.preventDefault(); |
330 |
e.preventDefault(); |
| 334 |
$('#modify_holds_search').show(); |
331 |
$("#modify_holds_search").show(); |
| 335 |
$('#edit_search').hide(); |
332 |
$("#edit_search").hide(); |
| 336 |
}); |
333 |
}); |
| 337 |
|
334 |
|
| 338 |
function showHoldSelections( number ){ |
335 |
function showHoldSelections(number) { |
| 339 |
if (number === 0) { |
336 |
if (number === 0) { |
| 340 |
$("#table_search_selections").hide(); |
337 |
$("#table_search_selections").hide(); |
| 341 |
} else { |
338 |
} else { |
| 342 |
$("#table_search_selections") |
339 |
$("#table_search_selections").show().find("span").text(_("Holds selected: %s").format(number)); |
| 343 |
.show() |
|
|
| 344 |
.find("span") |
| 345 |
.text(_("Holds selected: %s").format(number)); |
| 346 |
} |
340 |
} |
| 347 |
} |
341 |
} |
| 348 |
|
342 |
|
| 349 |
function search_holds(modify_holds_form){ |
343 |
function search_holds(modify_holds_form) { |
| 350 |
var searchpattern = ""; |
344 |
var searchpattern = ""; |
| 351 |
var filters = { |
345 |
var filters = { |
| 352 |
"me.expirationdate": function(){ |
346 |
"me.expirationdate": function () { |
| 353 |
var expirationdate_from = modify_holds_form.find("#expirationdate_from").val(); |
347 |
var expirationdate_from = modify_holds_form.find("#expirationdate_from").val(); |
| 354 |
var expirationdate_to = modify_holds_form.find("#expirationdate_to").val(); |
348 |
var expirationdate_to = modify_holds_form.find("#expirationdate_to").val(); |
| 355 |
|
349 |
|
| 356 |
if (expirationdate_from && expirationdate_to){ |
350 |
if (expirationdate_from && expirationdate_to) { |
| 357 |
searchpattern += _("expiration date between ") + expirationdate_from + " and " + expirationdate_to + " "; |
351 |
searchpattern += _("expiration date between ") + expirationdate_from + " and " + expirationdate_to + " "; |
| 358 |
return {"-between": [expirationdate_from, expirationdate_to]}; |
352 |
return { "-between": [expirationdate_from, expirationdate_to] }; |
| 359 |
} |
353 |
} else if (expirationdate_from && !expirationdate_to) { |
| 360 |
else if (expirationdate_from && !expirationdate_to){ |
|
|
| 361 |
searchpattern += _("expiration date from ") + expirationdate_from + " "; |
354 |
searchpattern += _("expiration date from ") + expirationdate_from + " "; |
| 362 |
return {">=": expirationdate_from }; |
355 |
return { ">=": expirationdate_from }; |
| 363 |
} else if (!expirationdate_from && expirationdate_to){ |
356 |
} else if (!expirationdate_from && expirationdate_to) { |
| 364 |
searchpattern += _("expiration date to ") + expirationdate_to + " "; |
357 |
searchpattern += _("expiration date to ") + expirationdate_to + " "; |
| 365 |
return {"<=": expirationdate_to }; |
358 |
return { "<=": expirationdate_to }; |
| 366 |
} |
359 |
} |
| 367 |
}, |
360 |
}, |
| 368 |
"me.branchcode": function(){ |
361 |
"me.branchcode": function () { |
| 369 |
var branchcodes = modify_holds_form.find("#branchcodes").val(); |
362 |
var branchcodes = modify_holds_form.find("#branchcodes").val(); |
| 370 |
if( branchcodes.length > 0 ){ |
363 |
if (branchcodes.length > 0) { |
| 371 |
searchpattern += _("from libraries "); |
364 |
searchpattern += _("from libraries "); |
| 372 |
var selected_libraries = modify_holds_form.find("#branchcodes option:selected"); |
365 |
var selected_libraries = modify_holds_form.find("#branchcodes option:selected"); |
| 373 |
$.each(selected_libraries, function(key, value) { |
366 |
$.each(selected_libraries, function (key, value) { |
| 374 |
searchpattern += value.text + " "; |
367 |
searchpattern += value.text + " "; |
| 375 |
}); |
368 |
}); |
| 376 |
return {"-in": branchcodes }; |
369 |
return { "-in": branchcodes }; |
| 377 |
} |
370 |
} |
| 378 |
}, |
371 |
}, |
| 379 |
"me.status": function(){ |
372 |
"me.status": function () { |
| 380 |
var found_status = modify_holds_form.find("#found_status").val(); |
373 |
var found_status = modify_holds_form.find("#found_status").val(); |
| 381 |
if( found_status.length > 0 ){ |
374 |
if (found_status.length > 0) { |
| 382 |
var filters = [{"-in": found_status}]; |
375 |
var filters = [{ "-in": found_status }]; |
| 383 |
if(jQuery.inArray("NULL", found_status) !== -1){ |
376 |
if (jQuery.inArray("NULL", found_status) !== -1) { |
| 384 |
filters.push({"=": null}); |
377 |
filters.push({ "=": null }); |
| 385 |
} |
378 |
} |
| 386 |
searchpattern += _("found status in "); |
379 |
searchpattern += _("found status in "); |
| 387 |
$.each(found_status, function(key, value) { |
380 |
$.each(found_status, function (key, value) { |
| 388 |
let status = _("No status "); |
381 |
let status = _("No status "); |
| 389 |
if ( value == "T" ) { |
382 |
if (value == "T") { |
| 390 |
status = _("In transit "); |
383 |
status = _("In transit "); |
| 391 |
} else if( value == "P" ) { |
384 |
} else if (value == "P") { |
| 392 |
status = _("In processing "); |
385 |
status = _("In processing "); |
| 393 |
} else if( value == "W" ) { |
386 |
} else if (value == "W") { |
| 394 |
status = _("Waiting "); |
387 |
status = _("Waiting "); |
| 395 |
} |
388 |
} |
| 396 |
searchpattern += status; |
389 |
searchpattern += status; |
|
Lines 398-656
Link Here
|
| 398 |
return filters; |
391 |
return filters; |
| 399 |
} |
392 |
} |
| 400 |
}, |
393 |
}, |
| 401 |
"me.suspended": function(){ |
394 |
"me.suspended": function () { |
| 402 |
var suspend_status = modify_holds_form.find("#suspend_status").val(); |
395 |
var suspend_status = modify_holds_form.find("#suspend_status").val(); |
| 403 |
|
396 |
|
| 404 |
if(suspend_status != "none"){ |
397 |
if (suspend_status != "none") { |
| 405 |
var suspended_text = suspend_status == 0 ? _("Not suspended") : _("Suspended"); |
398 |
var suspended_text = suspend_status == 0 ? _("Not suspended") : _("Suspended"); |
| 406 |
searchpattern += _("with suspend status ") + suspended_text; |
399 |
searchpattern += _("with suspend status ") + suspended_text; |
| 407 |
|
400 |
|
| 408 |
return {"=": suspend_status}; |
401 |
return { "=": suspend_status }; |
| 409 |
} |
402 |
} |
| 410 |
}, |
403 |
}, |
| 411 |
"me.suspend_until": function(){ |
404 |
"me.suspend_until": function () { |
| 412 |
var suspend_until_from = modify_holds_form.find("#suspend_until_from").val(); |
405 |
var suspend_until_from = modify_holds_form.find("#suspend_until_from").val(); |
| 413 |
var suspend_until_to = modify_holds_form.find("#suspend_until_to").val(); |
406 |
var suspend_until_to = modify_holds_form.find("#suspend_until_to").val(); |
| 414 |
|
407 |
|
| 415 |
if (suspend_until_from && suspend_until_to){ |
408 |
if (suspend_until_from && suspend_until_to) { |
| 416 |
searchpattern += _("suspend date between ") + suspend_until_from + " and " + suspend_until_to + " "; |
409 |
searchpattern += _("suspend date between ") + suspend_until_from + " and " + suspend_until_to + " "; |
| 417 |
return {"-between": [suspend_until_from, suspend_until_to]}; |
410 |
return { "-between": [suspend_until_from, suspend_until_to] }; |
| 418 |
} |
411 |
} else if (suspend_until_from && !suspend_until_to) { |
| 419 |
else if (suspend_until_from && !suspend_until_to){ |
|
|
| 420 |
searchpattern += _("suspend date from ") + suspend_until_from + " "; |
412 |
searchpattern += _("suspend date from ") + suspend_until_from + " "; |
| 421 |
return {">=": suspend_until_from }; |
413 |
return { ">=": suspend_until_from }; |
| 422 |
} else if (!suspend_until_from && suspend_until_to){ |
414 |
} else if (!suspend_until_from && suspend_until_to) { |
| 423 |
searchpattern += _("suspend date to ") + suspend_until_to + " "; |
415 |
searchpattern += _("suspend date to ") + suspend_until_to + " "; |
| 424 |
return {"<=": suspend_until_to }; |
416 |
return { "<=": suspend_until_to }; |
| 425 |
} |
417 |
} |
| 426 |
}, |
418 |
}, |
| 427 |
"me.notes": function(){ |
419 |
"me.notes": function () { |
| 428 |
var holdnotes = modify_holds_form.find("#holdnotes").val(); |
420 |
var holdnotes = modify_holds_form.find("#holdnotes").val(); |
| 429 |
|
421 |
|
| 430 |
searchpattern += holdnotes ? _("hold notes like ") + holdnotes : ""; |
422 |
searchpattern += holdnotes ? _("hold notes like ") + holdnotes : ""; |
| 431 |
|
423 |
|
| 432 |
return holdnotes ? {"-like": "%"+holdnotes+"%"} : ""; |
424 |
return holdnotes ? { "-like": "%" + holdnotes + "%" } : ""; |
| 433 |
}, |
425 |
}, |
| 434 |
"me.hold_id": function(){ |
426 |
"me.hold_id": function () { |
| 435 |
return hold_ids_from_sql.length > 0 ? { "-in": hold_ids_from_sql } : ""; |
427 |
return hold_ids_from_sql.length > 0 ? { "-in": hold_ids_from_sql } : ""; |
| 436 |
} |
|
|
| 437 |
} |
| 438 |
|
| 439 |
var holds_modify_table = $("#holds_to_modify").kohaTable({ |
| 440 |
ajax: { |
| 441 |
"url": "/api/v1/holds" |
| 442 |
}, |
428 |
}, |
| 443 |
embed: [ |
429 |
}; |
| 444 |
"biblio", |
430 |
|
| 445 |
"item", |
431 |
var holds_modify_table = $("#holds_to_modify").kohaTable( |
| 446 |
"pickup_library", |
432 |
{ |
| 447 |
"patron" |
433 |
ajax: { |
| 448 |
], |
434 |
url: "/api/v1/holds", |
| 449 |
destroy: true, |
|
|
| 450 |
autoWidth: false, |
| 451 |
processing: true, |
| 452 |
order: [ |
| 453 |
[1, 'asc'] |
| 454 |
], |
| 455 |
columns: [ |
| 456 |
{ |
| 457 |
"data": "hold_id", |
| 458 |
"name": "checkbox", |
| 459 |
"orderable": false, |
| 460 |
"render": function(data, type, row, meta) { |
| 461 |
return '<input class="selection" type="checkbox" value="'+ encodeURIComponent(data) +'"/>' |
| 462 |
} |
| 463 |
}, |
| 464 |
{ |
| 465 |
"data": "hold_date", |
| 466 |
"name": "hold_date", |
| 467 |
"type": "date", |
| 468 |
"title": _("Hold date"), |
| 469 |
"orderable": true, |
| 470 |
"render": function( data, type, row, meta ) { |
| 471 |
return $date(data); |
| 472 |
} |
| 473 |
}, |
| 474 |
{ |
| 475 |
"data": "expiration_date", |
| 476 |
"name": "expiration_date", |
| 477 |
"type": "date", |
| 478 |
"title": _("Expiration date"), |
| 479 |
"orderable": true, |
| 480 |
"render": function( data, type, row, meta ) { |
| 481 |
return $date(data); |
| 482 |
} |
| 483 |
}, |
| 484 |
{ |
| 485 |
"data": "biblio.title:biblio.subtitle:biblio.medium", |
| 486 |
"title": _("Title"), |
| 487 |
"searchable": true, |
| 488 |
"orderable": true, |
| 489 |
"render": function(data, type, row, meta) { |
| 490 |
return $biblio_to_html(row.biblio, { link: 1 }); |
| 491 |
} |
| 492 |
}, |
| 493 |
{ |
| 494 |
"data": "item.external_id", |
| 495 |
"name": "barcode", |
| 496 |
"title": _("Barcode"), |
| 497 |
"defaultContent": _(""), |
| 498 |
"orderable": true, |
| 499 |
"render": function( data, type, row, meta ) { |
| 500 |
if( row.item ){ |
| 501 |
let item_id = encodeURIComponent( row.item_id ); |
| 502 |
let biblio_id = encodeURIComponent( row.biblio_id ); |
| 503 |
return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?' + |
| 504 |
'itemnumber='+ item_id +'&biblionumber='+ biblio_id +'&' + |
| 505 |
'bi='+ biblio_id +'#item'+ item_id +'">' + escape_str( data ) + '</a>' |
| 506 |
} |
| 507 |
} |
| 508 |
}, |
| 509 |
{ |
| 510 |
"data": "patron_id", |
| 511 |
"name": "patron", |
| 512 |
"title": _("Patron"), |
| 513 |
"orderable": true, |
| 514 |
"render": function( data, type, row, meta ) { |
| 515 |
let patron_to_html = $patron_to_html(row.patron, { url: true, display_cardnumber: true, hide_patron_name }); |
| 516 |
return patron_to_html; |
| 517 |
} |
| 518 |
}, |
| 519 |
{ |
| 520 |
"data": "status", |
| 521 |
"name": "status", |
| 522 |
"title": _("Status"), |
| 523 |
"className": "found_status", |
| 524 |
"orderable": true, |
| 525 |
"render": function( data, type, row, meta ) { |
| 526 |
let status = _("No status"); |
| 527 |
if ( data == "T" ) { |
| 528 |
status = _("In transit"); |
| 529 |
} else if( data == "P" ) { |
| 530 |
status = _("In processing"); |
| 531 |
} else if( data == "W" ) { |
| 532 |
status = _("Waiting"); |
| 533 |
} |
| 534 |
return "<span data-found-status='" + escape_str( data ) + "'>" + status + "</span>"; |
| 535 |
} |
| 536 |
}, |
| 537 |
{ |
| 538 |
"data": "pickup_library_id", |
| 539 |
"name": "pickup_library", |
| 540 |
"title": _("Hold pickup library"), |
| 541 |
"orderable": true, |
| 542 |
"render": function( data, type, row, meta ) { |
| 543 |
return escape_str( row.pickup_library.name ); |
| 544 |
} |
| 545 |
}, |
| 546 |
{ |
| 547 |
"data": "suspended", |
| 548 |
"name": "suspended", |
| 549 |
"className": "suspended", |
| 550 |
"title": _("Suspended"), |
| 551 |
"orderable": true, |
| 552 |
"render": function( data, type, row, meta ) { |
| 553 |
var suspended_string = data == 0 ? _("No") : _("Yes"); |
| 554 |
return "<span data-suspended='" + data + "'>" + suspended_string + "</span>"; |
| 555 |
} |
| 556 |
}, |
| 557 |
{ |
| 558 |
"data": "suspended_until", |
| 559 |
"name": "suspended_until", |
| 560 |
"title": _("Suspended until"), |
| 561 |
"orderable": true, |
| 562 |
"render": function( data, type, row, meta ) { |
| 563 |
return $date( data ); |
| 564 |
} |
| 565 |
}, |
435 |
}, |
| 566 |
{ |
436 |
embed: ["biblio", "item", "pickup_library", "patron"], |
| 567 |
"data": "notes", |
437 |
destroy: true, |
| 568 |
"name": "notes", |
438 |
autoWidth: false, |
| 569 |
"title": _("Notes"), |
439 |
processing: true, |
| 570 |
"orderable": true, |
440 |
order: [[1, "asc"]], |
| 571 |
"render": function( data, type, row, meta ) { |
441 |
columns: [ |
| 572 |
return escape_str( data ); |
442 |
{ |
| 573 |
} |
443 |
data: "hold_id", |
| 574 |
} |
444 |
name: "checkbox", |
| 575 |
], |
445 |
orderable: false, |
| 576 |
}, holds_to_modify_table_settings, 0, filters); |
446 |
render: function (data, type, row, meta) { |
|
|
447 |
return '<input class="selection" type="checkbox" value="' + encodeURIComponent(data) + '"/>'; |
| 448 |
}, |
| 449 |
}, |
| 450 |
{ |
| 451 |
data: "hold_date", |
| 452 |
name: "hold_date", |
| 453 |
type: "date", |
| 454 |
title: _("Hold date"), |
| 455 |
orderable: true, |
| 456 |
render: function (data, type, row, meta) { |
| 457 |
return $date(data); |
| 458 |
}, |
| 459 |
}, |
| 460 |
{ |
| 461 |
data: "expiration_date", |
| 462 |
name: "expiration_date", |
| 463 |
type: "date", |
| 464 |
title: _("Expiration date"), |
| 465 |
orderable: true, |
| 466 |
render: function (data, type, row, meta) { |
| 467 |
return $date(data); |
| 468 |
}, |
| 469 |
}, |
| 470 |
{ |
| 471 |
data: "biblio.title:biblio.subtitle:biblio.medium", |
| 472 |
title: _("Title"), |
| 473 |
searchable: true, |
| 474 |
orderable: true, |
| 475 |
render: function (data, type, row, meta) { |
| 476 |
return $biblio_to_html(row.biblio, { link: 1 }); |
| 477 |
}, |
| 478 |
}, |
| 479 |
{ |
| 480 |
data: "item.external_id", |
| 481 |
name: "barcode", |
| 482 |
title: _("Barcode"), |
| 483 |
defaultContent: _(""), |
| 484 |
orderable: true, |
| 485 |
render: function (data, type, row, meta) { |
| 486 |
if (row.item) { |
| 487 |
let item_id = encodeURIComponent(row.item_id); |
| 488 |
let biblio_id = encodeURIComponent(row.biblio_id); |
| 489 |
return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?' + "itemnumber=" + item_id + "&biblionumber=" + biblio_id + "&" + "bi=" + biblio_id + "#item" + item_id + '">' + escape_str(data) + "</a>"; |
| 490 |
} |
| 491 |
}, |
| 492 |
}, |
| 493 |
{ |
| 494 |
data: "patron_id", |
| 495 |
name: "patron", |
| 496 |
title: _("Patron"), |
| 497 |
orderable: true, |
| 498 |
render: function (data, type, row, meta) { |
| 499 |
let patron_to_html = $patron_to_html(row.patron, { url: true, display_cardnumber: true, hide_patron_name }); |
| 500 |
return patron_to_html; |
| 501 |
}, |
| 502 |
}, |
| 503 |
{ |
| 504 |
data: "status", |
| 505 |
name: "status", |
| 506 |
title: _("Status"), |
| 507 |
className: "found_status", |
| 508 |
orderable: true, |
| 509 |
render: function (data, type, row, meta) { |
| 510 |
let status = _("No status"); |
| 511 |
if (data == "T") { |
| 512 |
status = _("In transit"); |
| 513 |
} else if (data == "P") { |
| 514 |
status = _("In processing"); |
| 515 |
} else if (data == "W") { |
| 516 |
status = _("Waiting"); |
| 517 |
} |
| 518 |
return "<span data-found-status='" + escape_str(data) + "'>" + status + "</span>"; |
| 519 |
}, |
| 520 |
}, |
| 521 |
{ |
| 522 |
data: "pickup_library_id", |
| 523 |
name: "pickup_library", |
| 524 |
title: _("Hold pickup library"), |
| 525 |
orderable: true, |
| 526 |
render: function (data, type, row, meta) { |
| 527 |
return escape_str(row.pickup_library.name); |
| 528 |
}, |
| 529 |
}, |
| 530 |
{ |
| 531 |
data: "suspended", |
| 532 |
name: "suspended", |
| 533 |
className: "suspended", |
| 534 |
title: _("Suspended"), |
| 535 |
orderable: true, |
| 536 |
render: function (data, type, row, meta) { |
| 537 |
var suspended_string = data == 0 ? _("No") : _("Yes"); |
| 538 |
return "<span data-suspended='" + data + "'>" + suspended_string + "</span>"; |
| 539 |
}, |
| 540 |
}, |
| 541 |
{ |
| 542 |
data: "suspended_until", |
| 543 |
name: "suspended_until", |
| 544 |
title: _("Suspended until"), |
| 545 |
orderable: true, |
| 546 |
render: function (data, type, row, meta) { |
| 547 |
return $date(data); |
| 548 |
}, |
| 549 |
}, |
| 550 |
{ |
| 551 |
data: "notes", |
| 552 |
name: "notes", |
| 553 |
title: _("Notes"), |
| 554 |
orderable: true, |
| 555 |
render: function (data, type, row, meta) { |
| 556 |
return escape_str(data); |
| 557 |
}, |
| 558 |
}, |
| 559 |
], |
| 560 |
}, |
| 561 |
holds_to_modify_table_settings, |
| 562 |
0, |
| 563 |
filters |
| 564 |
); |
| 577 |
|
565 |
|
| 578 |
$(".searchpattern").text(searchpattern); |
566 |
$(".searchpattern").text(searchpattern); |
| 579 |
|
567 |
|
| 580 |
$("#modify_holds_results-wrapper").show(); |
568 |
$("#modify_holds_results-wrapper").show(); |
| 581 |
} |
569 |
} |
| 582 |
|
570 |
|
| 583 |
$("#process_mods").on('submit', function(e) { |
571 |
$("#process_mods").on("submit", function (e) { |
| 584 |
|
572 |
var hold_ids = JSON.parse(localStorage.getItem("holds_modify_selections")) || []; |
| 585 |
var hold_ids = JSON.parse( localStorage.getItem("holds_modify_selections") ) || []; |
|
|
| 586 |
|
573 |
|
| 587 |
$("#process_mods input[name='hold_id']").remove(); |
574 |
$("#process_mods input[name='hold_id']").remove(); |
| 588 |
|
575 |
|
| 589 |
hold_ids.forEach(function(hold) { |
576 |
hold_ids.forEach(function (hold) { |
| 590 |
$('<input>').attr({ |
577 |
$("<input>") |
| 591 |
type: 'hidden', |
578 |
.attr({ |
| 592 |
name: 'hold_id', |
579 |
type: "hidden", |
| 593 |
value: hold.hold_id |
580 |
name: "hold_id", |
| 594 |
}).appendTo('#process_mods'); |
581 |
value: hold.hold_id, |
|
|
582 |
}) |
| 583 |
.appendTo("#process_mods"); |
| 595 |
}); |
584 |
}); |
| 596 |
|
585 |
|
| 597 |
var errors = []; |
586 |
var errors = []; |
| 598 |
|
587 |
|
| 599 |
var new_expiration_date = $("#new_expiration_date").val(); |
588 |
var new_expiration_date = $("#new_expiration_date").val(); |
| 600 |
var new_pickup_loc = $("#new_pickup_loc").val(); |
589 |
var new_pickup_loc = $("#new_pickup_loc").val(); |
| 601 |
var new_suspend_status = $("#new_suspend_status").val(); |
590 |
var new_suspend_status = $("#new_suspend_status").val(); |
| 602 |
var new_suspend_date = $("#new_suspend_date").val(); |
591 |
var new_suspend_date = $("#new_suspend_date").val(); |
| 603 |
var new_hold_note = $("#new_hold_note").val(); |
592 |
var new_hold_note = $("#new_hold_note").val(); |
| 604 |
var clear_hold_notes = $("#clear_hold_notes").val(); |
593 |
var clear_hold_notes = $("#clear_hold_notes").val(); |
| 605 |
|
594 |
|
| 606 |
if ( hold_ids.length == 0 ) { |
595 |
if (hold_ids.length == 0) { |
| 607 |
e.preventDefault(); |
596 |
e.preventDefault(); |
| 608 |
errors.push(_("Please select at least one hold to process.")); |
597 |
errors.push(_("Please select at least one hold to process.")); |
| 609 |
} |
598 |
} |
| 610 |
|
599 |
|
| 611 |
if( new_pickup_loc || new_suspend_status || new_suspend_date ){ |
600 |
if (new_pickup_loc || new_suspend_status || new_suspend_date) { |
| 612 |
var found = false; |
601 |
var found = false; |
| 613 |
hold_ids.forEach(function(hold){ |
602 |
hold_ids.forEach(function (hold) { |
| 614 |
if( hold.found_status ){ |
603 |
if (hold.found_status) { |
| 615 |
e.preventDefault(); |
604 |
e.preventDefault(); |
| 616 |
found = true; |
605 |
found = true; |
| 617 |
} |
606 |
} |
| 618 |
}); |
607 |
}); |
| 619 |
if( ( new_suspend_status || new_suspend_date ) && found ){ |
608 |
if ((new_suspend_status || new_suspend_date) && found) { |
| 620 |
errors.push(_("One or more holds have found status and can't be suspended.")); |
609 |
errors.push(_("One or more holds have found status and can't be suspended.")); |
| 621 |
} |
610 |
} |
| 622 |
if( new_pickup_loc && found ){ |
611 |
if (new_pickup_loc && found) { |
| 623 |
errors.push(_("One or more holds have found status and their pick up location can't be changed.")); |
612 |
errors.push(_("One or more holds have found status and their pick up location can't be changed.")); |
| 624 |
} |
613 |
} |
| 625 |
} |
614 |
} |
| 626 |
|
615 |
|
| 627 |
var suspended = false; |
616 |
var suspended = false; |
| 628 |
|
617 |
|
| 629 |
hold_ids.forEach(function(hold){ |
618 |
hold_ids.forEach(function (hold) { |
| 630 |
if( hold.suspened ){ |
619 |
if (hold.suspened) { |
| 631 |
suspended = true; |
620 |
suspended = true; |
| 632 |
} |
621 |
} |
| 633 |
}); |
622 |
}); |
| 634 |
|
623 |
|
| 635 |
if( ( !new_suspend_status || new_suspend_status == "0" || !suspended ) && new_suspend_date ){ |
624 |
if ((!new_suspend_status || new_suspend_status == "0" || !suspended) && new_suspend_date) { |
| 636 |
new_suspend_status = 1; |
625 |
new_suspend_status = 1; |
| 637 |
} |
626 |
} |
| 638 |
|
627 |
|
| 639 |
if (errors.length > 0) { |
628 |
if (errors.length > 0) { |
| 640 |
e.preventDefault(); |
629 |
e.preventDefault(); |
| 641 |
$("#errorList").html(errors.map(error => `<li>${error}</li>`).join("")); |
630 |
$("#errorList").html(errors.map(error => `<li>${error}</li>`).join("")); |
| 642 |
$("#errorModal").modal('show'); |
631 |
$("#errorModal").modal("show"); |
| 643 |
return false; |
632 |
return false; |
| 644 |
} |
633 |
} |
| 645 |
return true; |
634 |
return true; |
| 646 |
}); |
635 |
}); |
| 647 |
|
636 |
|
| 648 |
//Modified holds table |
637 |
//Modified holds table |
| 649 |
$("#modified_holds").kohaTable({ |
638 |
$("#modified_holds").kohaTable( |
| 650 |
pagingType: "full", |
639 |
{ |
| 651 |
autoWidth: false |
640 |
pagingType: "full", |
| 652 |
}, modified_holds_table_settings); |
641 |
autoWidth: false, |
| 653 |
|
642 |
}, |
|
|
643 |
modified_holds_table_settings |
| 644 |
); |
| 654 |
}); |
645 |
}); |
| 655 |
</script> |
646 |
</script> |
| 656 |
[% END %] |
647 |
[% END %] |