|
Lines 301-319
Link Here
|
| 301 |
holdings: false, |
301 |
holdings: false, |
| 302 |
otherholdings: false, |
302 |
otherholdings: false, |
| 303 |
}; |
303 |
}; |
| 304 |
$(".GroupByStatus").on("click",function(e){ |
304 |
|
|
|
305 |
function get_display_status(row, forSort = false) { |
| 306 |
let status = ""; |
| 307 |
let priority = ""; |
| 308 |
|
| 309 |
if (!row._status) row._status = []; |
| 310 |
|
| 311 |
if (row.withdrawn != 0) { |
| 312 |
status = _("Withdrawn"); |
| 313 |
priority = "10"; |
| 314 |
} else if (row.lost_status != 0) { |
| 315 |
let lost_text = av_lost.get(row.lost_status.toString()) || _("Lost"); |
| 316 |
status = lost_text; |
| 317 |
if (forSort) { |
| 318 |
if (lost_text.toLowerCase().includes("paid")) priority = "09c"; |
| 319 |
else if (lost_text.toLowerCase().includes("overdue")) priority = "09b"; |
| 320 |
else priority = "09a"; |
| 321 |
} else { |
| 322 |
priority = "09"; |
| 323 |
} |
| 324 |
} |
| 325 |
else if (row.damaged_status != 0) { |
| 326 |
status = _("Damaged"); |
| 327 |
priority = "08"; |
| 328 |
} |
| 329 |
else if (row.not_for_loan_status == 3) { |
| 330 |
status = _("In bundle"); |
| 331 |
priority = "07"; |
| 332 |
} else if (row.not_for_loan_status != 0) { |
| 333 |
status = _("Not for loan"); |
| 334 |
priority = "06"; |
| 335 |
} |
| 336 |
else if (row._status.includes('local_use')) { |
| 337 |
status = _("Local use"); |
| 338 |
priority = "05"; |
| 339 |
} |
| 340 |
else if (row._status.includes('checked_out')) { |
| 341 |
status = _("Checked out"); |
| 342 |
priority = "04"; |
| 343 |
} |
| 344 |
else if (row._status.includes('in_transit')) { |
| 345 |
status = _("In transit"); |
| 346 |
priority = "03"; |
| 347 |
} |
| 348 |
else if (row._status.includes('on_hold') || row._status.includes('waiting')) { |
| 349 |
status = _("On hold"); |
| 350 |
priority = "02"; |
| 351 |
} |
| 352 |
else if (row._status.includes('available') || (row.lost_status == 0 && row.withdrawn == 0)) { |
| 353 |
status = _("Available"); |
| 354 |
priority = "01"; |
| 355 |
} |
| 356 |
else { |
| 357 |
status = _("Undefined"); |
| 358 |
priority = "99"; |
| 359 |
} |
| 360 |
|
| 361 |
status = status.trim(); |
| 362 |
|
| 363 |
if (forSort) { |
| 364 |
if (priority.startsWith("09")) { |
| 365 |
return "09_" + _("Lost"); |
| 366 |
} |
| 367 |
return priority + "_" + status; |
| 368 |
} |
| 369 |
|
| 370 |
return status; |
| 371 |
} |
| 372 |
|
| 373 |
$(".GroupByStatus").on("click", function(e) { |
| 305 |
e.preventDefault(); |
374 |
e.preventDefault(); |
| 306 |
let tab_id = $(this).data("tab"); |
375 |
let tab_id = $(this).data("tab"); |
| 307 |
let was_grouped = group_by_status_values[tab_id]; |
376 |
group_by_status_values[tab_id] = !group_by_status_values[tab_id]; |
| 308 |
group_by_status_values[tab_id] = !was_grouped; |
377 |
let is_grouping = group_by_status_values[tab_id]; |
|
|
378 |
|
| 379 |
var dt_options = { |
| 380 |
"destroy": true, |
| 381 |
}; |
| 309 |
|
382 |
|
| 310 |
build_items_table(tab_id, true, { destroy: true }, build_items_table_drawncallback ); |
383 |
if (is_grouping) { |
|
|
384 |
dt_options["rowGroup"] = { |
| 385 |
"dataSrc": function(row) { |
| 386 |
return get_display_status(row, true); |
| 387 |
}, |
| 388 |
"startRender": function (rows, group) { |
| 389 |
let displayTitle = group.indexOf('_') !== -1 ? group.split('_')[1] : group; |
| 390 |
|
| 391 |
let groupColor = "#007bff"; |
| 392 |
|
| 393 |
if (group.startsWith("01")) { |
| 394 |
groupColor = "#28a745"; |
| 395 |
} else if (group.startsWith("08") || group.startsWith("09") || group.startsWith("10")) { |
| 396 |
groupColor = "#dc3545"; |
| 397 |
} |
| 398 |
|
| 399 |
return $('<tr class="group-header"><td colspan="30" style="background-color:#f8f9fa; font-weight:bold; border-left:5px solid ' + groupColor + '; padding:10px;">' |
| 400 |
+ displayTitle + ' (' + rows.count() + ')</td></tr>'); |
| 401 |
} |
| 402 |
}; |
| 311 |
|
403 |
|
| 312 |
if ( was_grouped ) { |
404 |
$(this).html('<i class="fa fa-object-ungroup"></i> ' + _("Ungroup by status") + '</button>'); |
| 313 |
$(this).html('<i class="fa fa-object-group"></i> ' + _("Group by status") + '</button>'); |
|
|
| 314 |
} else { |
405 |
} else { |
| 315 |
$(this).html('<i class="fa fa-object-ungroup"></i> '+ _("Ungroup by status") + '</button>'); |
406 |
$(this).html('<i class="fa fa-object-group"></i> '+ _("Group by status") + '</button>'); |
| 316 |
} |
407 |
} |
|
|
408 |
build_items_table(tab_id, true, dt_options, build_items_table_drawncallback, { group_by_status: is_grouping ? 1 : 0 }); |
| 317 |
}); |
409 |
}); |
| 318 |
|
410 |
|
| 319 |
function build_items_table (tab_id, add_filters, dt_options, drawcallback) { |
411 |
function build_items_table (tab_id, add_filters, dt_options, drawcallback) { |
|
Lines 570-576
Link Here
|
| 570 |
} |
662 |
} |
| 571 |
|
663 |
|
| 572 |
if ( status == 'lost' ) { |
664 |
if ( status == 'lost' ) { |
| 573 |
let lost_lib = av_lost.get(row.lost_status.toString()) || _("Unavailable (lost or missing"); |
665 |
let lost_lib = av_lost.get(row.lost_status.toString()) || _("Unavailable (lost or missing)"); |
| 574 |
nodes += '<span class="lost">%s</span>'.format(escape_str(lost_lib)); |
666 |
nodes += '<span class="lost">%s</span>'.format(escape_str(lost_lib)); |
| 575 |
|
667 |
|
| 576 |
const hasReturnClaims = row.return_claims && row.return_claims.filter(rc => !rc.resolution).length > 0 ? true : false |
668 |
const hasReturnClaims = row.return_claims && row.return_claims.filter(rc => !rc.resolution).length > 0 ? true : false |
| 577 |
- |
|
|