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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-96 / +258 lines)
Lines 117-174 Link Here
117
            <table id="default-circulation-rules">
117
            <table id="default-circulation-rules">
118
                <thead>
118
                <thead>
119
                    <tr>
119
                    <tr>
120
                        <th>&nbsp;</th>
120
                        <th data-colname="sort-patron">&nbsp;</th>
121
                        <th class="fixed_sort">Patron category</th>
121
                        <th data-colname="patron-category" class="fixed_sort">Patron category</th>
122
                        <th>&nbsp;</th>
122
                        <th data-colname="sort-item">&nbsp;</th>
123
                        <th class="fixed_sort">Item type</th>
123
                        <th data-colname="item-type" class="fixed_sort">Item type</th>
124
                        <th class="no-export">Actions</th>
124
                        <th data-colname="actions-left" class="no-export">Actions</th>
125
                        <th>Note</th>
125
                        <th data-colname="note">Note</th>
126
                        <th>Current checkouts allowed</th>
126
                        <th data-colname="maxissueqty">Current checkouts allowed</th>
127
                        <th>Current on-site checkouts allowed</th>
127
                        <th data-colname="maxonsiteissueqty">Current on-site checkouts allowed</th>
128
                        <th>Loan period</th>
128
                        <th data-colname="issuelength">Loan period</th>
129
                        <th>Days mode</th>
129
                        <th data-colname="daysmode">Days mode</th>
130
                        <th>Unit</th>
130
                        <th data-colname="lengthunit">Unit</th>
131
                        <th>Hard due date</th>
131
                        <th data-colname="hardduedate">Hard due date</th>
132
                        <th>Decreased loan period for high holds (day)</th>
132
                        <th data-colname="decreaseloanholds">Decreased loan period for high holds (day)</th>
133
                        <th>Fine amount</th>
133
                        <th data-colname="fine">Fine amount</th>
134
                        <th>Fine charging interval</th>
134
                        <th data-colname="chargeperiod">Fine charging interval</th>
135
                        <th>When to charge</th>
135
                        <th data-colname="chargeperiod_charge_at">When to charge</th>
136
                        <th>Fine/suspension grace period</th>
136
                        <th data-colname="firstremind">Fine/suspension grace period</th>
137
                        <th>Overdue fines cap (amount)</th>
137
                        <th data-colname="overduefinescap">Overdue fines cap (amount)</th>
138
                        <th>Cap fine at replacement price</th>
138
                        <th data-colname="cap_fine_to_replacement_price">Cap fine at replacement price</th>
139
                        <th>Expired hold charge</th>
139
                        <th data-colname="expire_reserves_charge">Expired hold charge</th>
140
                        <th>Suspension in days (day)</th>
140
                        <th data-colname="finedays">Suspension in days (day)</th>
141
                        <th>Max. suspension duration (day)</th>
141
                        <th data-colname="maxsuspensiondays">Max. suspension duration (day)</th>
142
                        <th>Suspension charging interval</th>
142
                        <th data-colname="suspension_chargeperiod">Suspension charging interval</th>
143
                        <th>Renewals allowed (count)</th>
143
                        <th data-colname="renewalsallowed">Renewals allowed (count)</th>
144
                        [% IF Koha.Preference('UnseenRenewals') %]
144
                        [% IF Koha.Preference('UnseenRenewals') %]
145
                            <th>Unseen renewals allowed (count)</th>
145
                            <th data-colname="unseen_renewals_allowed">Unseen renewals allowed (count)</th>
146
                        [% END %]
146
                        [% END %]
147
                        <th>Renewal period</th>
147
                        <th data-colname="renewalperiod">Renewal period</th>
148
                        <th>No renewal before</th>
148
                        <th data-colname="norenewalbefore">No renewal before</th>
149
                        <th>No automatic renewal before</th>
149
                        <th data-colname="noautorenewalbefore">No automatic renewal before</th>
150
                        <th>Automatic renewal</th>
150
                        <th data-colname="auto_renew">Automatic renewal</th>
151
                        <th>No automatic renewal after</th>
151
                        <th data-colname="no_auto_renewal_after">No automatic renewal after</th>
152
                        <th>No automatic renewal after (hard limit)</th>
152
                        <th data-colname="no_auto_renewal_after_hard_limit">No automatic renewal after (hard limit)</th>
153
                        <th>Holds allowed (total)</th>
153
                        <th data-colname="reservesallowed">Holds allowed (total)</th>
154
                        <th>Holds allowed (daily)</th>
154
                        <th data-colname="holds_per_day">Holds allowed (daily)</th>
155
                        <th>Holds per record (count)</th>
155
                        <th data-colname="holds_per_record">Holds per record (count)</th>
156
                        <th>On shelf holds allowed</th>
156
                        <th data-colname="onshelfholds">On shelf holds allowed</th>
157
                        <th>OPAC item level holds</th>
157
                        <th data-colname="opacitemholds">OPAC item level holds</th>
158
                        <th>Holds pickup period (day)</th>
158
                        <th data-colname="holds_pickup_period">Holds pickup period (day)</th>
159
                        [% IF Koha.Preference('ArticleRequests') %]
159
                        [% IF Koha.Preference('ArticleRequests') %]
160
                            <th>Article requests</th>
160
                            <th data-colname="article_requests">Article requests</th>
161
                        [% END %]
161
                        [% END %]
162
                        <th>Rental discount (%)</th>
162
                        <th data-colname="rentaldiscount">Rental discount (%)</th>
163
                        [% IF Koha.Preference('UseRecalls') %]
163
                        [% IF Koha.Preference('UseRecalls') %]
164
                            <th>Recalls allowed (total)</th>
164
                            <th data-colname="recalls_allowed">Recalls allowed (total)</th>
165
                            <th>Recalls per record (count)</th>
165
                            <th data-colname="recalls_per_record">Recalls per record (count)</th>
166
                            <th>On shelf recalls allowed</th>
166
                            <th data-colname="on_shelf_recalls">On shelf recalls allowed</th>
167
                            <th>Recall due date interval (day)</th>
167
                            <th data-colname="recall_due_date_interval">Recall due date interval (day)</th>
168
                            <th>Recall overdue fine amount</th>
168
                            <th data-colname="recall_overdue_fine">Recall overdue fine amount</th>
169
                            <th>Recall pickup period (day)</th>
169
                            <th data-colname="recall_shelf_time">Recall pickup period (day)</th>
170
                        [% END %]
170
                        [% END %]
171
                        <th class="no-export">Actions</th>
171
                        <th data-colname="actions-right" class="no-export">Actions</th>
172
                    </tr>
172
                    </tr>
173
                </thead>
173
                </thead>
174
                <tbody>
174
                <tbody>
Lines 598-655 Link Here
598
                </tbody>
598
                </tbody>
599
                <tfoot>
599
                <tfoot>
600
                    <tr>
600
                    <tr>
601
                        <th>&nbsp;</th>
601
                        <th data-colname="sort-patron">&nbsp;</th>
602
                        <th>Patron category</th>
602
                        <th data-colname="patron-category">Patron category</th>
603
                        <th>&nbsp;</th>
603
                        <th data-colname="sort-item">&nbsp;</th>
604
                        <th>Item type</th>
604
                        <th data-colname="item-type">Item type</th>
605
                        <th>&nbsp;</th>
605
                        <th data-colname="actions-left">&nbsp;</th>
606
                        <th>Note</th>
606
                        <th data-colname="note">Note</th>
607
                        <th>Current checkouts allowed</th>
607
                        <th data-colname="maxissueqty">Current checkouts allowed</th>
608
                        <th>Current on-site checkouts allowed</th>
608
                        <th data-colname="maxonsiteissueqty">Current on-site checkouts allowed</th>
609
                        <th>Loan period</th>
609
                        <th data-colname="issuelength">Loan period</th>
610
                        <th>Days mode</th>
610
                        <th data-colname="daysmode">Days mode</th>
611
                        <th>Unit</th>
611
                        <th data-colname="lengthunit">Unit</th>
612
                        <th>Hard due date</th>
612
                        <th data-colname="hardduedate">Hard due date</th>
613
                        <th>Decreased loan period for high holds (day)</th>
613
                        <th data-colname="decreaseloanholds">Decreased loan period for high holds (day)</th>
614
                        <th>Fine amount</th>
614
                        <th data-colname="fine">Fine amount</th>
615
                        <th>Fine charging interval</th>
615
                        <th data-colname="chargeperiod">Fine charging interval</th>
616
                        <th>Charge when?</th>
616
                        <th data-colname="chargeperiod_charge_at">Charge when?</th>
617
                        <th>Fine/suspension grace period</th>
617
                        <th data-colname="firstremind">Fine/suspension grace period</th>
618
                        <th>Overdue fines cap (amount)</th>
618
                        <th data-colname="overduefinescap">Overdue fines cap (amount)</th>
619
                        <th>Cap fine at replacement price</th>
619
                        <th data-colname="cap_fine_to_replacement_price">Cap fine at replacement price</th>
620
                        <th>Expired hold charge</th>
620
                        <th data-colname="expire_reserves_charge">Expired hold charge</th>
621
                        <th>Suspension in days (day)</th>
621
                        <th data-colname="finedays">Suspension in days (day)</th>
622
                        <th>Max. suspension duration (day)</th>
622
                        <th data-colname="maxsuspensiondays">Max. suspension duration (day)</th>
623
                        <th>Suspension charging interval</th>
623
                        <th data-colname="suspension_chargeperiod">Suspension charging interval</th>
624
                        <th>Renewals allowed (count)</th>
624
                        <th data-colname="renewalsallowed">Renewals allowed (count)</th>
625
                        [% IF Koha.Preference('UnseenRenewals') %]
625
                        [% IF Koha.Preference('UnseenRenewals') %]
626
                            <th>Unseen renewals allowed (count)</th>
626
                            <th data-colname="unseen_renewals_allowed">Unseen renewals allowed (count)</th>
627
                        [% END %]
627
                        [% END %]
628
                        <th>Renewal period</th>
628
                        <th data-colname="renewalperiod">Renewal period</th>
629
                        <th>No renewal before</th>
629
                        <th data-colname="norenewalbefore">No renewal before</th>
630
                        <th>No automatic renewal before</th>
630
                        <th data-colname="noautorenewalbefore">No automatic renewal before</th>
631
                        <th>Automatic renewal</th>
631
                        <th data-colname="auto_renew">Automatic renewal</th>
632
                        <th>No automatic renewal after</th>
632
                        <th data-colname="no_auto_renewal_after">No automatic renewal after</th>
633
                        <th>No automatic renewal after (hard limit)</th>
633
                        <th data-colname="no_auto_renewal_after_hard_limit">No automatic renewal after (hard limit)</th>
634
                        <th>Holds allowed (total)</th>
634
                        <th data-colname="reservesallowed">Holds allowed (total)</th>
635
                        <th>Holds allowed (daily)</th>
635
                        <th data-colname="holds_per_day">Holds allowed (daily)</th>
636
                        <th>Holds per record (count)</th>
636
                        <th data-colname="holds_per_record">Holds per record (count)</th>
637
                        <th>On shelf holds allowed</th>
637
                        <th data-colname="onshelfholds">On shelf holds allowed</th>
638
                        <th>OPAC item level holds</th>
638
                        <th data-colname="opacitemholds">OPAC item level holds</th>
639
                        <th>Holds pickup period (day)</th>
639
                        <th data-colname="holds_pickup_period">Holds pickup period (day)</th>
640
                        [% IF Koha.Preference('ArticleRequests') %]
640
                        [% IF Koha.Preference('ArticleRequests') %]
641
                            <th>Article requests</th>
641
                            <th data-colname="article_requests">Article requests</th>
642
                        [% END %]
642
                        [% END %]
643
                        <th>Rental discount (%)</th>
643
                        <th data-colname="rentaldiscount">Rental discount (%)</th>
644
                        [% IF Koha.Preference('UseRecalls') %]
644
                        [% IF Koha.Preference('UseRecalls') %]
645
                            <th>Recalls allowed (total)</th>
645
                            <th data-colname="recalls_allowed">Recalls allowed (total)</th>
646
                            <th>Recalls per record (count)</th>
646
                            <th data-colname="recalls_per_record">Recalls per record (count)</th>
647
                            <th>On shelf recalls allowed</th>
647
                            <th data-colname="on_shelf_recalls">On shelf recalls allowed</th>
648
                            <th>Recall due date interval (day)</th>
648
                            <th data-colname="recall_due_date_interval">Recall due date interval (day)</th>
649
                            <th>Recall overdue fine amount</th>
649
                            <th data-colname="recall_overdue_fine">Recall overdue fine amount</th>
650
                            <th>Recall pickup period (day)</th>
650
                            <th data-colname="recall_shelf_time">Recall pickup period (day)</th>
651
                        [% END %]
651
                        [% END %]
652
                        <th>&nbsp;</th>
652
                        <th data-colname="actions-right">&nbsp;</th>
653
                    </tr>
653
                    </tr>
654
                </tfoot>
654
                </tfoot>
655
            </table>
655
            </table>
Lines 1441-1451 Link Here
1441
    [% INCLUDE 'datatables.inc' %]
1441
    [% INCLUDE 'datatables.inc' %]
1442
    [% INCLUDE 'calendar.inc' %]
1442
    [% INCLUDE 'calendar.inc' %]
1443
    [% INCLUDE 'format_price.inc' %]
1443
    [% INCLUDE 'format_price.inc' %]
1444
    <style>
1445
        #default-circulation-rules_wrapper .top {
1446
            margin-bottom: 1em;
1447
            display: flex;
1448
            gap: 1em;
1449
            align-items: center;
1450
            flex-wrap: wrap;
1451
        }
1452
        #default-circulation-rules_wrapper .dt-buttons {
1453
            display: flex;
1454
            flex-wrap: wrap;
1455
            gap: 0.5em;
1456
            align-items: center;
1457
            padding: 0.5em;
1458
            background-color: #f8f9fa;
1459
            border: 1px solid #dee2e6;
1460
            border-radius: 4px;
1461
            order: -1; /* Place on the left */
1462
        }
1463
        #default-circulation-rules_wrapper .dt-buttons button {
1464
            margin: 0 !important;
1465
            white-space: nowrap;
1466
        }
1467
        /* Hide the clear filter button since we disabled search */
1468
        #default-circulation-rules_wrapper .dt_button_clear_filter {
1469
            display: none !important;
1470
        }
1471
    </style>
1444
    <script>
1472
    <script>
1445
        $(document).ready(function () {
1473
        $(document).ready(function () {
1446
            $("#default-circulation-rules").kohaTable({
1474
            // Define column groups by their data-colname attributes
1475
            const columnGroups = {
1476
                core: ['patron-category', 'item-type', 'actions-left', 'note', 'actions-right'],
1477
                checkout: ['maxissueqty', 'maxonsiteissueqty', 'issuelength', 'daysmode', 'lengthunit'],
1478
                dueDate: ['hardduedate', 'decreaseloanholds'],
1479
                fines: ['fine', 'chargeperiod', 'chargeperiod_charge_at', 'firstremind', 'overduefinescap',
1480
                        'cap_fine_to_replacement_price', 'expire_reserves_charge', 'finedays',
1481
                        'maxsuspensiondays', 'suspension_chargeperiod'],
1482
                renewals: ['renewalsallowed', [% IF Koha.Preference('UnseenRenewals') %]'unseen_renewals_allowed',[% END %]
1483
                          'renewalperiod', 'norenewalbefore', 'noautorenewalbefore', 'auto_renew',
1484
                          'no_auto_renewal_after', 'no_auto_renewal_after_hard_limit'].filter(Boolean),
1485
                holds: ['reservesallowed', 'holds_per_day', 'holds_per_record', 'onshelfholds',
1486
                        'opacitemholds', 'holds_pickup_period'],
1487
                [% IF Koha.Preference('ArticleRequests') %]
1488
                articleRequests: ['article_requests'],
1489
                [% END %]
1490
                rental: ['rentaldiscount'],
1491
                [% IF Koha.Preference('UseRecalls') %]
1492
                recalls: ['recalls_allowed', 'recalls_per_record', 'on_shelf_recalls',
1493
                         'recall_due_date_interval', 'recall_overdue_fine', 'recall_shelf_time']
1494
                [% END %]
1495
            };
1496
1497
            // Helper function to get column selector for a group
1498
            function getColumnSelector(groupNames) {
1499
                return groupNames.map(name => 'th[data-colname="' + name + '"]').join(',');
1500
            }
1501
1502
            // Initialize the table first with kohaTable
1503
            var table = $("#default-circulation-rules").kohaTable({
1447
                columnDefs: [
1504
                columnDefs: [
1448
                    { visible: false, targets: [0, 2] },
1505
                    { visible: false, targets: getColumnSelector(['sort-patron', 'sort-item']) },
1449
                    { orderable: false, targets: ["_all"] },
1506
                    { orderable: false, targets: ["_all"] },
1450
                ],
1507
                ],
1451
                orderFixed: [
1508
                orderFixed: [
Lines 1455-1462 Link Here
1455
                    [3, "asc"],
1512
                    [3, "asc"],
1456
                ],
1513
                ],
1457
                paging: false,
1514
                paging: false,
1458
                autoWidth: false,
1515
                searching: false,
1516
                autoWidth: false
1517
            });
1518
1519
            // Get the DataTables API instance
1520
            var dtApi = table.DataTable();
1521
1522
            // Add our custom column visibility buttons
1523
            const visibilityButtons = [
1524
                {
1525
                    text: 'Checkouts',
1526
                    className: 'btn btn-sm btn-default',
1527
                    action: function (e, dt, node, config) {
1528
                        dt.columns().visible(false);
1529
                        dt.columns(getColumnSelector(columnGroups.core.concat(columnGroups.checkout))).visible(true);
1530
                    }
1531
                },
1532
                {
1533
                    text: 'Due dates',
1534
                    className: 'btn btn-sm btn-default',
1535
                    action: function (e, dt, node, config) {
1536
                        dt.columns().visible(false);
1537
                        dt.columns(getColumnSelector(columnGroups.core.concat(columnGroups.dueDate))).visible(true);
1538
                    }
1539
                },
1540
                {
1541
                    text: 'Fines',
1542
                    className: 'btn btn-sm btn-default',
1543
                    action: function (e, dt, node, config) {
1544
                        dt.columns().visible(false);
1545
                        dt.columns(getColumnSelector(columnGroups.core.concat(columnGroups.fines))).visible(true);
1546
                    }
1547
                },
1548
                {
1549
                    text: 'Renewals',
1550
                    className: 'btn btn-sm btn-default',
1551
                    action: function (e, dt, node, config) {
1552
                        dt.columns().visible(false);
1553
                        dt.columns(getColumnSelector(columnGroups.core.concat(columnGroups.renewals))).visible(true);
1554
                    }
1555
                },
1556
                {
1557
                    text: 'Holds',
1558
                    className: 'btn btn-sm btn-default',
1559
                    action: function (e, dt, node, config) {
1560
                        dt.columns().visible(false);
1561
                        dt.columns(getColumnSelector(columnGroups.core.concat(columnGroups.holds))).visible(true);
1562
                    }
1563
                }
1564
            ];
1565
1566
            [% IF Koha.Preference('ArticleRequests') %]
1567
            visibilityButtons.push({
1568
                text: 'Article requests',
1569
                className: 'btn btn-sm btn-default',
1570
                action: function (e, dt, node, config) {
1571
                    dt.columns().visible(false);
1572
                    dt.columns(getColumnSelector(columnGroups.core.concat(columnGroups.articleRequests))).visible(true);
1573
                }
1574
            });
1575
            [% END %]
1576
1577
            [% IF Koha.Preference('UseRecalls') %]
1578
            visibilityButtons.push({
1579
                text: 'Recalls',
1580
                className: 'btn btn-sm btn-default',
1581
                action: function (e, dt, node, config) {
1582
                    dt.columns().visible(false);
1583
                    dt.columns(getColumnSelector(columnGroups.core.concat(columnGroups.recalls))).visible(true);
1584
                }
1459
            });
1585
            });
1586
            [% END %]
1587
1588
            // Add 'Show all' button at the end
1589
            visibilityButtons.push({
1590
                text: 'Show all',
1591
                className: 'btn btn-sm btn-default',
1592
                action: function (e, dt, node, config) {
1593
                    dt.columns().visible(true);
1594
                    dt.columns(getColumnSelector(['sort-patron', 'sort-item'])).visible(false); // Keep sorting columns hidden
1595
                }
1596
            });
1597
1598
            // Create a button container
1599
            var buttonContainer = $('<div class="dt-buttons"></div>');
1600
1601
            // Add each button manually
1602
            visibilityButtons.forEach(function(buttonConfig) {
1603
                var button = $('<button type="button"></button>')
1604
                    .addClass(buttonConfig.className)
1605
                    .text(buttonConfig.text)
1606
                    .on('click', function() {
1607
                        // Remove active class from all buttons
1608
                        buttonContainer.find('button').removeClass('btn-primary').addClass('btn-default');
1609
                        // Add active class to clicked button
1610
                        $(this).removeClass('btn-default').addClass('btn-primary');
1611
                        // Execute the button action
1612
                        buttonConfig.action(null, dtApi, $(this), buttonConfig);
1613
                    });
1614
                buttonContainer.append(button);
1615
            });
1616
1617
            // Insert into the top area
1618
            var wrapper = $('#default-circulation-rules_wrapper');
1619
            wrapper.find('.top').append(buttonContainer);
1620
1621
            // Default to Checkouts view on page load
1622
            buttonContainer.find('button:first').trigger('click');
1460
        });
1623
        });
1461
1624
1462
        function clear_edit() {
1625
        function clear_edit() {
1463
- 

Return to bug 41439