Bug 35360: Make HTML/buttons consistent on waitingreserves.tt
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / circ / waitingreserves.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% USE TablesSettings %]
7 [% USE AuthorisedValues %]
8 [% PROCESS 'i18n.inc' %]
9 [% SET footerjs = 1 %]
10 [% INCLUDE 'doc-head-open.inc' %]
11 <title>Holds awaiting pickup &rsaquo; Circulation &rsaquo; Koha</title>
12 [% INCLUDE 'doc-head-close.inc' %]
13 </head>
14
15 <body id="circ_waitingreserves" class="circ">
16 [% WRAPPER 'header.inc' %]
17     [% INCLUDE 'circ-search.inc' %]
18 [% END %]
19
20 [% WRAPPER 'sub-header.inc' %]
21     [% WRAPPER breadcrumbs %]
22         [% WRAPPER breadcrumb_item %]
23             <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
24         [% END %]
25         [% WRAPPER breadcrumb_item bc_active= 1 %]
26             <span>Holds awaiting pickup</span>
27         [% END %]
28     [% END #/ WRAPPER breadcrumbs %]
29 [% END #/ WRAPPER sub-header.inc %]
30
31 <div class="main container-fluid">
32     <div class="row">
33         <div class="col-sm-12">
34             <main>
35                 <div class="row">
36
37                     [% IF Koha.Preference('CircSidebar') %]
38                         <div class="col-sm-10 col-sm-push-2">
39                     [% ELSE %]
40                         <div class="col-sm-12">
41                     [% END %]
42
43                         <h1>Holds awaiting pickup for your library on: [% show_date | $KohaDates %]</h1>
44                         <h2>
45                             [% IF ( all_branches_link ) %]
46                                 <span><a href="[% all_branches_link | url %]">
47                                 View all libraries</a></span>
48                             [% END %]
49                         </h2>
50                         [% IF reject_result_error %]
51                             <div class="error message">
52                                 [% IF reject_result_error.invalid_status %]
53                                     <p>There was a problem rejecting the cancellation request. Cannot reject an already completed cancellation request.</p>
54                                 [% ELSE %]
55                                     <p>Some error occurred while rejecting the cancellation request. Please check the logs</p>
56                                 [% END %]
57                             </div>
58                         [% END %]
59                         [% IF ( cancel_result ) %]
60                             [% FOREACH cancel_result %]
61                                 [% IF ( messagetransfert ) %]
62                                     <div class="dialog message">
63                                         <h2>This item is on hold for pick-up at [% Branches.GetName( branchname ) | html %]</h2>
64                                         <p><strong>[% nextreservtitle | html %]</strong> is on hold for <strong> [% nextreservsurname | html %], [% nextreservfirstname | html %]</strong>.
65                                         Please retain this item and check it in to process the hold.
66                                         </p>
67                                         <form name="cancelReservewithtransfert" action="waitingreserves.pl#[% tab | html %]" method="post">
68                                             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
69                                         </form>
70                                     </div>
71                                 [% END # /IF messagetransfert%]
72                                 [% IF ( waiting ) %]
73                                     <div class="dialog message">
74                                         <h2>This item is on hold for pick-up at your library</h2>
75                                         <p><strong>[% nextreservtitle | html %]</strong> is on hold for <strong>[% nextreservsurname | html %], [% nextreservfirstname | html %]</strong>.
76                                         Please retain this item and check it in to process the hold.
77                                         </p>
78                                         <form name="cancelReservewithwaiting" action="waitingreserves.pl#[% tab | html %]" method="post">
79                                             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
80                                         </form>
81                                     </div>
82                                 [% END # /IF waiting %]
83                             [% END # /FOREACH cancel_result %]
84                         [% ELSE %]
85                             [% IF enqueued %]
86                                 <div class="dialog message">
87                                     <p>The job has been enqueued! It will be processed as soon as possible.</p>
88                                     <p><a href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job_id | uri %]" title="View detail of the enqueued job">View detail of the enqueued job</a></p>
89                                 </div>
90                             [% END %]
91
92                             [% WRAPPER tabs id= "resultlist" %]
93                                 [% WRAPPER tabs_nav %]
94                                     [% WRAPPER tab_item tabname= "holdswaiting" bt_active= 1 %]
95                                         <span>Holds waiting:</span> [% reservecount | html %]
96                                     [% END %]
97                                     [% WRAPPER tab_item tabname= "holdsover" %]
98                                         [% tx("Holds waiting over {count} days:", { count = Koha.Preference('ReservesMaxPickUpDelay') }) %] [% overcount | html %]
99                                     [% END %]
100                                     [% WRAPPER tab_item tabname= "holdscancelled" %]
101                                         <span>Holds with cancellation requests:</span> [% cancel_reqs_count | html %]
102                                     [% END %]
103                                 [% END # /WRAPPER tabs_nav %]
104
105                                 [% WRAPPER tab_panels %]
106                                     [% WRAPPER tab_panel tabname="holdswaiting" bt_active= 1 %]
107                                         [% IF ( reserveloop ) %]
108                                             <div id="toolbar" class="btn-toolbar">
109                                                 <button class="btn cancel_selected_holds" data-bulk="true"></button>
110                                             </div>
111                                             [% INCLUDE waiting_holds.inc table_name='holdst' reserveloop=reserveloop tab='holdwaiting' %]
112                                         [% ELSE %]
113                                             <div class="dialog message">No holds found.</div>
114                                         [% END %]
115                                     [% END # /tab_panel#holdswaiting %]
116
117                                     [% WRAPPER tab_panel tabname="holdsover" %]
118                                         [% IF ( ReservesMaxPickUpDelay ) %]
119                                             <p>Holds listed here have been awaiting pickup for more than [% ReservesMaxPickUpDelay | html %] days.</p>
120                                         [% END %]
121                                         [% IF ( overloop ) %]
122                                             <div id="toolbar" class="btn-toolbar">
123                                                 <button class="btn cancel_selected_holds" data-bulk="true"></button>
124                                                 <div class="btn-group">
125                                                     <form name="cancelAllReserve" action="waitingreserves.pl" method="post">
126                                                         <input type="hidden" name="cancelall" value="1" />
127                                                         <input type="hidden" name="allbranches" value="[% allbranches | html %]" />
128                                                         <input type="hidden" name="tab" value="holdsover">
129                                                         [% IF TransferWhenCancelAllWaitingHolds %]
130                                                             <input type="submit" class="btn btn-primary" value="Cancel and transfer all" />
131                                                         [% ELSE %]
132                                                             <input type="submit" class="btn btn-primary" value="Cancel all" />
133                                                         [% END %]
134                                                     </form>
135                                                 </div>
136                                             </div>
137                                             [% UNLESS TransferWhenCancelAllWaitingHolds %]
138                                                 <div class="hint">Only items that need not be transferred will be cancelled (TransferWhenCancelAllWaitingHolds syspref)</div>
139                                             [% END %]
140                                             [% INCLUDE waiting_holds.inc table_name='holdso' reserveloop=overloop tab='holdsover' %]
141                                         [% ELSE %]
142                                             <div class="dialog message">No holds found.</div>
143                                         [% END # /IF( overloop ) %]
144                                     [% END # /tab_panel#holdsover %]
145
146                                     [% WRAPPER tab_panel tabname="holdscancelled" %]
147                                         [% IF cancel_reqs_count %]
148                                             <div id="toolbar" class="btn-toolbar">
149                                                 <button class="btn cancel_selected_holds" data-bulk="true"></button>
150                                             </div>
151                                             [% INCLUDE waiting_holds.inc select_column='1' table_name='holdscr' reserveloop=cancel_reqs tab='holdscr' %]
152                                         [% ELSE %]
153                                             <div class="dialog message">No holds found.</div>
154                                         [% END %]
155                                     [% END # /tab_panel#holdscancelled %]
156                                 [% END # /WRAPPER tab_panels %]
157                             [% END # /WRAPPER tabs %]
158
159                         [% END # /IF ( cancel_result ) %]
160                     </div> <!-- /.col-sm-10.col-sm-push-2 -->
161
162                     [% IF Koha.Preference('CircSidebar') %]
163                         <div class="col-sm-2 col-sm-pull-10">
164                             <aside>
165                                 [% INCLUDE 'circ-nav.inc' %]
166                             </aside>
167                         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
168                     [% END %]
169                 </div> <!-- /.row -->
170
171             </main>
172         </div> <!-- /.col-sm-12 -->
173     </div> <!-- /.row -->
174
175     <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
176         <div class="modal-dialog" role="document">
177             <div class="modal-content">
178                 <div class="modal-header">
179                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
180                     <h3>Confirm deletion</h3>
181                 </div>
182
183                 <div class="modal-body">
184                     <p>Are you sure you want to cancel this hold?</p>
185
186                     <fieldset class="action">
187                         [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
188                         [% IF hold_cancellation.count %]
189                             <label for="cancellation-reason">Cancellation reason: </label>
190                             <select class="cancellation-reason" name="modal-cancellation-reason" id="modal-cancellation-reason">
191                                 <option value="">No reason given</option>
192                                 [% FOREACH reason IN hold_cancellation %]
193                                     <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
194                                 [% END %]
195                             </select>
196                         [% END %]
197                     </fieldset> <!-- /.action -->
198                 </div> <!-- /.modal-body -->
199
200                 <div class="modal-footer">
201                     <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger">Confirm cancellation</button>
202                     <a href="#" data-dismiss="modal">Cancel</a>
203                 </div> <!-- /.modal-footer -->
204             </div> <!-- /.modal-content -->
205         </div> <!-- /.modal-dialog -->
206     </div> <!-- /#cancelModal -->
207
208 [% MACRO jsinclude BLOCK %]
209     [% INCLUDE 'datatables.inc' %]
210     [% INCLUDE 'columns_settings.inc' %]
211     <script>
212         var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
213         var holdst_table_settings  = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdst',  'json' ) | $raw %];
214         var holdso_table_settings  = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdso',  'json' ) | $raw %];
215         var holdscr_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdscr', 'json' ) | $raw %];
216
217         $(document).ready(function() {
218
219             KohaTable("holdst", {
220                 "sPaginationType": "full",
221                 "order": [[1, 'asc']]
222             }, holdst_table_settings);
223
224             KohaTable("holdso", {
225                 "sPaginationType": "full",
226                 "order": [[1, 'asc']]
227             }, holdso_table_settings);
228
229             KohaTable("holdscr", {
230                 "sPaginationType": "full",
231                 "order": [[1, 'asc']]
232             }, holdscr_table_settings);
233
234             let cancel_link;
235
236             $("#cancelModalConfirmBtn").on("click",function(e) {
237                 var ids = cancel_link.data('ids');
238                 localStorage.selectedWaitingHolds = JSON.stringify(JSON.parse(localStorage.selectedWaitingHolds).filter(id => !ids.includes(id)));
239                 let link = `waitingreserves.pl?cancelBulk=1&amp;ids=${ids.join(',')}`;
240                 let reason = $("#modal-cancellation-reason").val();
241                 if ( reason ) {
242                     link += "&amp;cancellation-reason=" + reason
243                 }
244                 window.location.href = link;
245                 return false;
246             });
247
248             if(!localStorage.selectedWaitingHolds || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) {
249                 localStorage.selectedWaitingHolds = '[]';
250             }
251
252             try {
253                 JSON.parse(localStorage.selectedWaitingHolds);
254             } catch(e) {
255                 localStorage.selectedWaitingHolds = '[]';
256             }
257
258             $('.holds_table .select_hold').each(function() {
259                 if(JSON.parse(localStorage.selectedWaitingHolds).includes($(this).data('id'))) {
260                     $(this).prop('checked', true);
261                 }
262             });
263
264             $('.holds_table').each(function() {
265               var table = $(this);
266               var parent = table.parents('.tab-pane');
267
268               $('.holds_table .select_hold_all', parent).each(function() {
269                   var count = $('.select_hold:not(:checked)', table).length;
270                   $('.select_hold_all', table).prop('checked', !count);
271               });
272
273               $('.cancel_selected_holds', parent).html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked', parent).length));
274
275               $('.holds_table .select_hold_all', parent).click(function() {
276                   var count = $('.select_hold:checked', table).length;
277                   $('.select_hold', table).prop('checked', !count);
278                   $(this).prop('checked', !count);
279                   $('.cancel_selected_holds', parent).data('ids', $('.holds_table .select_hold:checked', parent).toArray().map(el => $(el).data('id'))).html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked', parent).length));
280                   localStorage.selectedWaitingHolds = JSON.stringify($('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')));
281               });
282
283               $('.holds_table .select_hold', parent).click(function() {
284                   var count = $('.select_hold:not(:checked)', table).length;
285                   $('.select_hold_all', table).prop('checked', !count);
286                   $('.cancel_selected_holds', parent).data('ids', $('.holds_table .select_hold:checked', parent).toArray().map(el => $(el).data('id'))).html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked', parent).length));
287                   localStorage.selectedWaitingHolds = JSON.stringify($('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')));
288               });
289
290               $('.cancel_selected_holds', parent).click(function(e) {
291                   e.preventDefault();
292                   if($('.select_hold:checked', table).length) {
293                       cancel_link = $(this);
294                       $('#cancelModal').modal();
295                   }
296                   return false;
297               });
298             });
299
300             var activeTab = localStorage.getItem("waitingreserves_activetab");
301             if( activeTab ){
302                 $("div#resultlist li:eq(" + activeTab + ") a").tab("show");
303             }
304             $("div#resultlist a[data-toggle='tab']").on("shown.bs.tab", function (e) {
305                 var thisTab = $(e.target).parent();
306                 var activeTab = thisTab.index();
307                 localStorage.setItem("waitingreserves_activetab", activeTab );
308             });
309
310         });
311     </script>
312 [% END %]
313
314 [% INCLUDE 'intranet-bottom.inc' %]