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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +104 lines)
Lines 986-991 Link Here
986
        </div>
986
        </div>
987
    </div>
987
    </div>
988
[% END %]
988
[% END %]
989
[% INCLUDE modals/cancel_booking.inc %]
989
990
990
[% MACRO jsinclude BLOCK %]
991
[% MACRO jsinclude BLOCK %]
991
    [% INCLUDE 'datatables.inc' %]
992
    [% INCLUDE 'datatables.inc' %]
Lines 1026-1035 Link Here
1026
    [% END %]
1027
    [% END %]
1027
    [% Asset.js("js/holds.js") | $raw %]
1028
    [% Asset.js("js/holds.js") | $raw %]
1028
    [% INCLUDE 'calendar.inc' %]
1029
    [% INCLUDE 'calendar.inc' %]
1030
    [% Asset.js("js/cancel_booking_modal.js") | $raw %]
1031
    [% INCLUDE 'js-biblio-format.inc' %]
1029
    <script>
1032
    <script>
1030
        table_settings_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'issues-table', 'json' ) | $raw %]
1033
        table_settings_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'issues-table', 'json' ) | $raw %]
1031
        table_settings_relatives_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'relatives-issues-table', 'json' ) | $raw %]
1034
        table_settings_relatives_issues_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'relatives-issues-table', 'json' ) | $raw %]
1032
        table_settings_holds_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'holds-table', 'json' ) | $raw %]
1035
        table_settings_holds_table = [% TablesSettings.GetTableSettings( 'circ', 'circulation', 'holds-table', 'json' ) | $raw %]
1036
        table_settings_bookings_table = [% TablesSettings.GetTableSettings( 'members', 'moremember', 'bookings-table', 'json' ) | $raw %]
1037
1038
        var bookings_table;
1039
        $(document).ready(function() {
1040
            $("#info_digests").tooltip();
1041
1042
            $("#finesholdsissues a[data-toggle='tab']").on("shown.bs.tab", function(e){
1043
                var oTable = $('div.dataTables_wrapper > table', $(e.target.hash) ).dataTable();
1044
                if ( oTable.length > 0 ) {
1045
                    oTable.fnAdjustColumnSizing();
1046
                }
1047
            });
1048
1049
            $("#view_restrictions").on("click",function(){
1050
                $('#reldebarments-tab').click();
1051
            });
1052
1053
            $("#view_guarantees_finesandcharges").on("click",function(){
1054
                $('#guarantees_finesandcharges-tab').click();
1055
            });
1056
1057
            // Bookings
1058
            // Load bookings table on tab selection
1059
            $("#bookings-tab").on( "click", function(){
1060
                if ( !bookings_table ) {
1061
                    var today = new Date();
1062
                    var bookings_table_url = "/api/v1/bookings";
1063
                    bookings_table = $('#bookings_table').kohaTable({
1064
                        "ajax": {
1065
                            "url": bookings_table_url
1066
                        },
1067
                        "embed": [
1068
                            "biblio",
1069
                            "item",
1070
                            "patron"
1071
                        ],
1072
                        "columns": [{
1073
                            "data": "booking_id",
1074
                            "title": _("Booking ID"),
1075
                        },
1076
                        {
1077
                            "data": "biblio.title",
1078
                            "title": _("Title"),
1079
                            "searchable": true,
1080
                            "orderable": true,
1081
                            "render": function(data,type,row,meta) {
1082
                                return $biblio_to_html(row.biblio, {
1083
                                    link: 'bookings'
1084
                                });
1085
                            }
1086
                        },
1087
                        {
1088
                            "data": "item.external_id",
1089
                            "title": _("Item"),
1090
                            "searchable": true,
1091
                            "orderable": true,
1092
                            "defaultContent": _("Any item"),
1093
                            "render": function(data,type,row,meta) {
1094
                                if ( row.item ) {
1095
                                    return row.item.external_id + " (" + row.booking_id + ")";
1096
                                } else {
1097
                                    return null;
1098
                                }
1099
                            }
1100
                        },
1101
                        {
1102
                            "data": "start_date",
1103
                            "title": _("Start date"),
1104
                            "searchable": true,
1105
                            "orderable": true,
1106
                            "render": function(data, type, row, meta) {
1107
                                return $date(row.start_date);
1108
                            }
1109
                        },
1110
                        {
1111
                            "data": "end_date",
1112
                            "title": _("End date"),
1113
                            "searchable": true,
1114
                            "orderable": true,
1115
                            "render": function(data, type, row, meta) {
1116
                                return $date(row.end_date);
1117
                            }
1118
                        },
1119
                        {
1120
                            "data": "",
1121
                            "title": _("Actions"),
1122
                            "class": "actions",
1123
                            "searchable": false,
1124
                            "orderable": false,
1125
                            "render": function(data, type, row, meta) {
1126
                                let result = "";
1127
                                [% IF CAN_user_circulate_manage_bookings %]
1128
                                result += '<button type="button" class="btn btn-default btn-xs cancel-action" data-toggle="modal" data-target="#cancelBookingModal" data-booking="'+row.booking_id+'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Cancel")+'</button>';
1129
                                [% END %]
1130
                                return result;
1131
                            }
1132
                        }]
1133
                    }, table_settings_bookings_table, 0, { patron_id: "[% patron.borrowernumber | html %]", end_date: { ">=": today.toISOString() } });
1134
                };
1135
            });
1136
         });
1033
1137
1034
        [% IF borrowernumber and patron %]
1138
        [% IF borrowernumber and patron %]
1035
            if( Cookies.get("holdfor") != [% patron.borrowernumber | html %]){
1139
            if( Cookies.get("holdfor") != [% patron.borrowernumber | html %]){
1036
- 

Return to bug 37047