Bug 29002: Add modal based booking cancellation
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / bookings / list.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Bookings for [% INCLUDE 'biblio-title-head.inc' %] &rsaquo; Bookings &rsaquo; Circulation &rsaquo; Koha</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 </head>
9
10 <body id="circ_request" class="catalog">
11
12 [% INCLUDE 'header.inc' %]
13 [% INCLUDE 'circ-search.inc' %]
14
15 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
16     <ol>
17         <li>
18             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
19         </li>
20         <li>
21             <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
22         </li>
23         <li>
24             [% INCLUDE 'biblio-title.inc' link =1 %]
25         </li>
26         <li>
27             <a href="#" aria-current="page">
28                 Bookings
29             </a>
30         </li>
31     </ol>
32 </nav>
33
34 <div class="main container-fluid">
35     <div class="row">
36         <div class="col-sm-10 col-sm-push-2">
37             <main>
38                 <div class="row">
39                     [% INCLUDE 'cat-toolbar.inc' %]
40                     <h1>Bookings for [% INCLUDE 'biblio-title-head.inc' %]</h1>
41                     <div class="page-section">
42                         <table id="bookings_table"></table>
43                     </div>
44                 </div>
45             </main>
46         </div> <!-- /.col-sm-10.col-sm-push-2 -->
47
48         <div class="col-sm-2 col-sm-pull-10">
49             <aside>
50                 [% INCLUDE 'biblio-view-menu.inc' %]
51             </aside>
52         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
53     </div> <!-- /.row -->
54
55     [% INCLUDE modals/cancel_booking.inc %]
56
57     [% MACRO jsinclude BLOCK %]
58     [% Asset.js("lib/dayjs/dayjs.min.js") | $raw %]
59     [% INCLUDE 'datatables.inc' %]
60     [% INCLUDE 'columns_settings.inc' %]
61     [% INCLUDE 'calendar.inc' %]
62     [% INCLUDE 'select2.inc' %]
63     [% INCLUDE 'js-date-format.inc' %]
64     [% Asset.js("js/place_booking_modal.js") | $raw %]
65     [% Asset.js("js/cancel_booking_modal.js") | $raw %]
66 <script>
67     var bookings_table;
68     $(document).ready(function(){
69         var bookings_table_url = "/api/v1/biblios/[% biblionumber | uri %]/bookings";
70         bookings_table = $('#bookings_table').kohaTable({
71             "ajax": {
72                 "url": bookings_table_url
73             },
74             "embed": [
75                 "item",
76                 "patron"
77             ],
78             "columns": [{
79                 "data": "booking_id",
80                 "title": "Booking ID",
81                 "visible": false,
82                 "searchable": false,
83                 "orderable": false
84             },
85             {
86                 "data": "item.external_id",
87                 "title": "Item",
88                 "searchable": true,
89                 "orderable": true,
90                 "defaultContent": "Any item",
91                 "render": function(data,type,row,meta) {
92                     if ( row.item ) {
93                         return row.item.external_id;
94                     } else {
95                         return null;
96                     }
97                 }
98             },
99             {
100                 "data": "patron.firstname:patron.surname",
101                 "title": "Patron",
102                 "searchable": true,
103                 "orderable": true,
104                 "render": function(data, type, row, meta) {
105                     var fullname;
106                     if ( row.patron.firstname == null ) {
107                         fullname = row.patron.surname;
108                     }
109                     else {
110                         fullname = row.patron.firstname + " " + row.patron.surname;
111                     }
112                     return escape_str(fullname);
113                 }
114             },
115             {
116                 "data": "start_date",
117                 "title": "Start date",
118                 "searchable": true,
119                 "orderable": true,
120                 "render": function(data, type, row, meta) {
121                     return $date(row.start_date);
122                 }
123             },
124             {
125                 "data": "end_date",
126                 "title": "End date",
127                 "searchable": true,
128                 "orderable": true,
129                 "render": function(data, type, row, meta) {
130                     return $date(row.end_date);
131                 }
132             },
133             {
134                 "data": "",
135                 "title": "Actions",
136                 "searchable": false,
137                 "orderable": false,
138                 "render": function(data, type, row, meta) {
139                     var 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>';
140                     return result;
141                 }
142             }]
143         }, [], 1);
144     });
145 </script>
146     [% END %]
147
148 [% INCLUDE 'intranet-bottom.inc' %]