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