View | Details | Raw Unified | Return to bug 38122
Collapse All | Expand All

(-)a/Koha/REST/V1/Biblios.pm (-20 / +80 lines)
Lines 271-297 sub get_items { Link Here
271
271
272
        if ($group_by_status) {
272
        if ($group_by_status) {
273
            $c->req->params->remove('_order_by');
273
            $c->req->params->remove('_order_by');
274
            $items_rs = $items_rs->search(
274
275
                {},
275
            my $q_param = $c->param('q');
276
                {
276
            if ($q_param) {
277
                    order_by => [
277
                if ( $q_param =~ /"_status"\s*:\s*"(\w+)"/ ) {
278
                        \[ "CASE
278
                    my $requested_status = $1;
279
                                WHEN (withdrawn != 0) THEN '10_Withdrawn'
279
280
                                WHEN (itemlost != 0) THEN '09_Lost'
280
                    if ( $requested_status eq 'recalled' ) {
281
                                WHEN (damaged != 0) THEN '08_Damaged'
281
                        $items_rs = $items_rs->search(
282
                                WHEN (notforloan = 3) THEN '07_In bundle'
282
                            \[
283
                                WHEN (notforloan != 0) THEN '06_Not for loan'
283
                                "EXISTS (SELECT 1 FROM recalls WHERE item_id = me.itemnumber AND status IN ('requested','overdue','waiting','in_transit'))"
284
                                WHEN EXISTS (SELECT 1 FROM issues WHERE itemnumber = me.itemnumber AND onsite_checkout = 1) THEN '05_Local use'
284
                            ]
285
                                WHEN (onloan IS NOT NULL) THEN '04_Checked out'
285
                        );
286
                                WHEN (SELECT COUNT(*) FROM branchtransfers WHERE itemnumber = me.itemnumber AND datearrived IS NULL) > 0 THEN '03_In transit'
286
                        $c->req->params->remove('q');
287
                                WHEN (SELECT COUNT(*) FROM reserves WHERE itemnumber = me.itemnumber AND (found IS NULL OR found = 'W')) > 0 THEN '02_On hold'
287
                    } elsif ( $requested_status eq 'available' ) {
288
                                ELSE '01_Available'
288
                        $items_rs = $items_rs->search(
289
                            END ASC" ],
289
                            {
290
                        { -asc => 'me.itemlost' },
290
                                'me.itemlost'   => 0,
291
                        { -asc => 'me.notforloan' },
291
                                'me.withdrawn'  => 0,
292
                    ]
292
                                'me.onloan'     => undef,
293
                                'me.notforloan' => 0,
294
                                'me.damaged'    => 0,
295
                                'me.restricted' => [ undef, 0 ],
296
                            }
297
                        );
298
                        $items_rs = $items_rs->search(
299
                            \[
300
                                "NOT EXISTS (SELECT 1 FROM branchtransfers WHERE itemnumber = me.itemnumber AND datearrived IS NULL)"
301
                            ]
302
                        );
303
                        $items_rs = $items_rs->search(
304
                            \[
305
                                "NOT EXISTS (SELECT 1 FROM reserves WHERE itemnumber = me.itemnumber AND (found IS NULL OR found = 'W'))"
306
                            ]
307
                        );
308
                        $c->req->params->remove('q');
309
                    } else {
310
                        $items_rs = $items_rs->search(
311
                            {},
312
                            {
313
                                order_by => [
314
                                    { -asc => 'me.onloan' },
315
                                    { -asc => 'me.itemlost' },
316
                                    { -asc => 'me.withdrawn' },
317
                                    { -asc => 'me.notforloan' },
318
                                    { -asc => 'me.restricted' },
319
                                ]
320
                            }
321
                        );
322
                    }
293
                }
323
                }
294
            );
324
            } else {
325
326
                $items_rs = $items_rs->search(
327
                    {},
328
                    {
329
                        order_by => [
330
                            \[
331
                                "CASE
332
                                    WHEN (withdrawn != 0) THEN '11_Withdrawn'
333
                                    WHEN (itemlost != 0) THEN '10_Lost'
334
                                    WHEN (restricted IS NOT NULL AND restricted != 0) THEN '09_Restricted'
335
                                    WHEN (damaged != 0) THEN '08_Damaged'
336
                                    WHEN (notforloan = 3) THEN '07_In bundle'
337
                                    WHEN (notforloan != 0) THEN '06_Not for loan'
338
                                    WHEN EXISTS (SELECT 1 FROM issues WHERE itemnumber = me.itemnumber AND onsite_checkout = 1) THEN '05_Local use'
339
                                    WHEN EXISTS (SELECT 1 FROM recalls WHERE item_id = me.itemnumber AND status IN ('requested','overdue','waiting','in_transit','cancelled','expired','fulfilled')) THEN '04_Recalled'
340
                                    WHEN (onloan IS NOT NULL) THEN '03_Checked out'
341
                                    WHEN (SELECT COUNT(*) FROM branchtransfers WHERE itemnumber = me.itemnumber AND datearrived IS NULL) > 0 THEN '02_In transit'
342
                                    WHEN (SELECT COUNT(*) FROM reserves WHERE itemnumber = me.itemnumber AND (found IS NULL OR found = 'W')) > 0 THEN '01_On hold'
343
                                    ELSE '00_Available'
344
                                END ASC"
345
                            ],
346
                            { -asc => 'me.onloan' },
347
                            { -asc => 'me.itemlost' },
348
                            { -asc => 'me.withdrawn' },
349
                            { -asc => 'me.notforloan' },
350
                            { -asc => 'me.restricted' },
351
                        ]
352
                    }
353
                );
354
            }
295
        }
355
        }
296
356
297
        # FIXME We need to order_by serial.publisheddate if we have _order_by=+me.serial_issue_number
357
        # FIXME We need to order_by serial.publisheddate if we have _order_by=+me.serial_issue_number
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-26 / +36 lines)
Lines 306-357 Link Here
306
            let status = "";
306
            let status = "";
307
            let priority = "";
307
            let priority = "";
308
308
309
            if (!row._status) row._status = [];
309
            if (!row._status) return;
310
310
311
            if (row.withdrawn != 0) {
311
            if (row.withdrawn != 0) {
312
                status = _("Withdrawn");
312
                status = av_withdrawn.get(row.withdrawn.toString()) || _("Withdrawn");
313
                priority = "10";
313
                priority = "11";
314
            } else if (row.lost_status != 0) {
314
            }
315
            else if (row.lost_status != 0) {
315
                let lost_text = av_lost.get(row.lost_status.toString()) || _("Lost");
316
                let lost_text = av_lost.get(row.lost_status.toString()) || _("Lost");
316
                status = lost_text;
317
                status = lost_text;
317
                if (forSort) {
318
                if (forSort) {
318
                    if (lost_text.toLowerCase().includes("paid")) priority = "09c";
319
                    if (lost_text.toLowerCase().includes("paid")) priority = "10c";
319
                    else if (lost_text.toLowerCase().includes("overdue")) priority = "09b";
320
                    else if (lost_text.toLowerCase().includes("overdue")) priority = "10b";
320
                    else priority = "09a";
321
                    else priority = "10a";
321
                } else {
322
                } else {
322
                    priority = "09";
323
                    priority = "10";
323
                }
324
                }
324
            }
325
            }
325
             else if (row.damaged_status != 0) {
326
            else if (row.restricted_status != null && row.restricted_status != 0) {
326
                status = _("Damaged");
327
                status = av_restricted.get(row.restricted_status.toString()) || _("Restricted access");
328
                priority = "09";
329
            }
330
            else if (row.damaged_status != 0) {
331
                status = av_damaged.get(row.damaged_status.toString()) || _("Damaged");
327
                priority = "08";
332
                priority = "08";
328
            }
333
            }
329
            else if (row.not_for_loan_status == 3) {
334
            else if (row.not_for_loan_status == 3) {
330
                status = _("In bundle");
335
                status = _("In bundle");
331
                priority = "07";
336
                priority = "07";
332
            } else if (row.not_for_loan_status != 0) {
337
            }
333
                status = _("Not for loan");
338
            else if (row.not_for_loan_status != 0) {
339
                status = av_not_for_loan.get(row.not_for_loan_status.toString()) || _("Not for loan");
334
                priority = "06";
340
                priority = "06";
335
            }
341
            }
336
            else if (row._status.includes('local_use')) {
342
            else if (row._status.includes('local_use')) {
337
                status = _("Local use");
343
                status = _("Local use");
338
                priority = "05";
344
                priority = "05";
339
            }
345
            }
346
            else if (row._status.includes('recalled')) {
347
                status = _("Recalled");
348
                priority = "04";
349
            }
340
            else if (row._status.includes('checked_out')) {
350
            else if (row._status.includes('checked_out')) {
341
                status = _("Checked out");
351
                status = _("Checked out");
342
                priority = "04";
352
                priority = "03";
343
            }
353
            }
344
            else if (row._status.includes('in_transit')) {
354
            else if (row._status.includes('in_transit')) {
345
                status = _("In transit");
355
                status = _("In transit");
346
                priority = "03";
356
                priority = "02";
347
            }
357
            }
348
             else if (row._status.includes('on_hold') || row._status.includes('waiting')) {
358
            else if (row._status.includes('on_hold') || row._status.includes('waiting')) {
349
                status = _("On hold");
359
                status = _("On hold");
350
                priority = "02";
360
                priority = "01";
351
            }
361
            }
352
            else if (row._status.includes('available') || (row.lost_status == 0 && row.withdrawn == 0)) {
362
            else if (row._status.includes('available')
363
                || (row.lost_status == 0 && row.withdrawn == 0)
364
                && (row.restricted_status == null || row.restricted_status == 0)) {
353
                status = _("Available");
365
                status = _("Available");
354
                priority = "01";
366
                priority = "00";
355
            }
367
            }
356
            else {
368
            else {
357
                status = _("Undefined");
369
                status = _("Undefined");
Lines 361-368 Link Here
361
            status = status.trim();
373
            status = status.trim();
362
374
363
            if (forSort) {
375
            if (forSort) {
364
                if (priority.startsWith("09")) {
376
                if (priority.startsWith("10")) {
365
                    return "09_" + _("Lost");
377
                    return "10_" + _("Lost");
366
                }
378
                }
367
                return priority + "_" + status;
379
                return priority + "_" + status;
368
            }
380
            }
Lines 391-399 Link Here
391
403
392
                        let groupColor = "#007bff";
404
                        let groupColor = "#007bff";
393
405
394
                        if (group.startsWith("01")) {
406
                        if (group.startsWith("00")) {
395
                            groupColor = "#28a745";
407
                            groupColor = "#28a745";
396
                        } else if (group.startsWith("08") || group.startsWith("09") || group.startsWith("10")) {
408
                        }else if (group.startsWith("08") || group.startsWith("09")){
409
                            groupColor = "#FFEB3B";
410
                        }else if (group.startsWith("10") || group.startsWith("11")) {
397
                            groupColor = "#dc3545";
411
                            groupColor = "#dc3545";
398
                        }
412
                        }
399
413
Lines 634-642 Link Here
634
                    searchable: false,
648
                    searchable: false,
635
                    orderable: false,
649
                    orderable: false,
636
                    render: function (data, type, row, meta) {
650
                    render: function (data, type, row, meta) {
637
                        if (type === 'sort' || type === 'filter' || type === 'type') {
638
                            return get_display_status(row, true);
639
                        }
640
                        let nodes = "";
651
                        let nodes = "";
641
                        row._status.forEach( status => {
652
                        row._status.forEach( status => {
642
                            if ( status == 'checked_out' || status == 'local_use') {
653
                            if ( status == 'checked_out' || status == 'local_use') {
643
- 

Return to bug 38122