Bug 32482: Reindent holds awaiting pickup template
[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 [% SET footerjs = 1 %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Holds awaiting pickup &rsaquo; Circulation &rsaquo; Koha</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 </head>
13
14 <body id="circ_waitingreserves" class="circ">
15 [% WRAPPER 'header.inc' %]
16     [% INCLUDE 'circ-search.inc' %]
17 [% END %]
18
19 [% WRAPPER 'sub-header.inc' %]
20 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
21     <ol>
22         <li>
23             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
24         </li>
25         <li>
26             <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
27         </li>
28         <li>
29             <a href="#" aria-current="page">Holds awaiting pickup</a>
30         </li>
31     </ol>
32 </nav>
33 [% END %]
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 %]
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 %]
87                             [% END %]
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                             <div id="resultlist" class="toptabs">
96                                 <ul class="nav nav-tabs" role="tablist">
97                                     <li role="presentation" class="active"><a href="#holdswaiting" aria-controls="holdswaiting" role="tab" data-toggle="tab">Holds waiting: [% reservecount | html %]</a></li>
98                                     <li role="presentation">
99                                         <a href="#holdsover" aria-controls="holdsover" role="tab" data-toggle="tab">
100                                             Holds waiting over [% Koha.Preference('ReservesMaxPickUpDelay') | html %] days: [% overcount | html %]
101                                         </a>
102                                     </li>
103                                     <li role="presentation">
104                                         <a href="#holdscancelled" aria-controls="holdscancelled" role="tab" data-toggle="tab">
105                                             Holds with cancellation requests: [% cancel_reqs_count | html %]
106                                         </a>
107                                     </li>
108                                 </ul>
109                                 <div class="tab-content">
110                                     <div role="tabpanel" class="tab-pane active" id="holdswaiting">
111                                         [% IF ( reserveloop ) %]
112                                             <div id="toolbar" class="btn-toolbar">
113                                                 <button class="btn btn-default 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                                     </div>
120                                     <div role="tabpanel" class="tab-pane" id="holdsover">
121                                         [% IF ( ReservesMaxPickUpDelay ) %]
122                                             <p>Holds listed here have been awaiting pickup for more than [% ReservesMaxPickUpDelay | html %] days.</p>
123                                         [% END %]
124                                         [% IF ( overloop ) %]
125                                             <span id="holdsover-cancel-all">
126                                                 <button class="cancel_selected_holds" data-bulk="true"></button>
127                                                 <form name="cancelAllReserve" action="waitingreserves.pl" method="post">
128                                                     <input type="hidden" name="cancelall" value="1" />
129                                                     <input type="hidden" name="allbranches" value="[% allbranches | html %]" />
130                                                     <input type="hidden" name="tab" value="holdsover">
131                                                     [% IF TransferWhenCancelAllWaitingHolds %]
132                                                         <input type="submit" class="btn btn-primary" value="Cancel and transfer all" />
133                                                     [% ELSE %]
134                                                         <input type="submit" class="btn btn-primary" value="Cancel all" />
135                                                     [% END %]
136                                                 </form>
137                                                 [% UNLESS TransferWhenCancelAllWaitingHolds %]
138                                                     Only items that need not be transferred will be cancelled (TransferWhenCancelAllWaitingHolds syspref)
139                                                 [% END %]
140                                             </span>
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 %]
145                                     </div>
146                                     <div role="tabpanel" class="tab-pane" id="holdscancelled">
147                                         [% IF cancel_reqs_count %]
148                                             [% INCLUDE waiting_holds.inc select_column='1' table_name='holdscr' reserveloop=cancel_reqs tab='holdscr' %]
149                                         [% ELSE %]
150                                             <div class="dialog message">No holds found.</div>
151                                         [% END %]
152                                     </div>
153                                 </div>
154                             </div>
155                         [% END %]
156                     </div> <!-- /.col-sm-10.col-sm-push-2 -->
157
158                     [% IF Koha.Preference('CircSidebar') %]
159                         <div class="col-sm-2 col-sm-pull-10">
160                             <aside>
161                                 [% INCLUDE 'circ-nav.inc' %]
162                             </aside>
163                         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
164                     [% END %]
165                 </div> <!-- /.row -->
166
167             </main>
168         </div> <!-- /.col-sm-12 -->
169     </div> <!-- /.row -->
170
171     <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
172         <div class="modal-dialog" role="document">
173             <div class="modal-content">
174                 <div class="modal-header">
175                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
176                     <h3>Confirm deletion</h3>
177                 </div>
178
179                 <div class="modal-body">
180                     <p>Are you sure you want to cancel this hold?</p>
181
182                     <fieldset class="action">
183                         [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
184                         [% IF hold_cancellation.count %]
185                             <label for="cancellation-reason">Cancellation reason: </label>
186                             <select class="cancellation-reason" name="modal-cancellation-reason" id="modal-cancellation-reason">
187                                 <option value="">No reason given</option>
188                                 [% FOREACH reason IN hold_cancellation %]
189                                     <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
190                                 [% END %]
191                             </select>
192                         [% END %]
193                     </fieldset>
194                 </div>
195
196                 <div class="modal-footer">
197                     <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger">Confirm cancellation</button>
198                     <a href="#" data-dismiss="modal">Cancel</a>
199                 </div>
200             </div>
201         </div>
202     </div>
203
204 [% MACRO jsinclude BLOCK %]
205     [% INCLUDE 'datatables.inc' %]
206     [% INCLUDE 'columns_settings.inc' %]
207     <script>
208         var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
209         var holdst_table_settings  = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdst',  'json' ) | $raw %];
210         var holdso_table_settings  = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdso',  'json' ) | $raw %];
211         var holdscr_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdscr', 'json' ) | $raw %];
212
213         $(document).ready(function() {
214
215             KohaTable("holdst", {
216                 "sPaginationType": "full",
217                 "order": [[1, 'asc']]
218             }, holdst_table_settings);
219
220             KohaTable("holdso", {
221                 "sPaginationType": "full",
222                 "order": [[1, 'asc']]
223             }, holdso_table_settings);
224
225             KohaTable("holdscr", {
226                 "sPaginationType": "full",
227                 "order": [[1, 'asc']]
228             }, holdscr_table_settings);
229
230             let cancel_link;
231
232             $("#cancelModalConfirmBtn").on("click",function(e) {
233                 var ids = cancel_link.data('ids');
234                 localStorage.selectedWaitingHolds = JSON.stringify(JSON.parse(localStorage.selectedWaitingHolds).filter(id => !ids.includes(id)));
235                 let link = `waitingreserves.pl?cancelBulk=1&amp;ids=${ids.join(',')}`;
236                 let reason = $("#modal-cancellation-reason").val();
237                 if ( reason ) {
238                     link += "&amp;cancellation-reason=" + reason
239                 }
240                 window.location.href = link;
241                 return false;
242             });
243
244             if(!localStorage.selectedWaitingHolds || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) {
245                 localStorage.selectedWaitingHolds = '[]';
246             }
247
248             try {
249                 JSON.parse(localStorage.selectedWaitingHolds);
250             } catch(e) {
251                 localStorage.selectedWaitingHolds = '[]';
252             }
253
254             $('.holds_table .select_hold').each(function() {
255                 if(JSON.parse(localStorage.selectedWaitingHolds).includes($(this).data('id'))) {
256                     $(this).prop('checked', true);
257                 }
258             });
259
260             $('.holds_table').each(function() {
261               var table = $(this);
262               var parent = table.parents('.tab-pane');
263
264               $('.holds_table .select_hold_all', parent).each(function() {
265                   var count = $('.select_hold:not(:checked)', table).length;
266                   $('.select_hold_all', table).prop('checked', !count);
267               });
268
269               $('.cancel_selected_holds', parent).html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked', parent).length));
270
271               $('.holds_table .select_hold_all', parent).click(function() {
272                   var count = $('.select_hold:checked', table).length;
273                   $('.select_hold', table).prop('checked', !count);
274                   $(this).prop('checked', !count);
275                   $('.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));
276                   localStorage.selectedWaitingHolds = JSON.stringify($('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')));
277               });
278
279               $('.holds_table .select_hold', parent).click(function() {
280                   var count = $('.select_hold:not(:checked)', table).length;
281                   $('.select_hold_all', table).prop('checked', !count);
282                   $('.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));
283                   localStorage.selectedWaitingHolds = JSON.stringify($('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')));
284               });
285
286               $('.cancel_selected_holds', parent).click(function(e) {
287                   e.preventDefault();
288                   if($('.select_hold:checked', table).length) {
289                       cancel_link = $(this);
290                       $('#cancelModal').modal();
291                   }
292                   return false;
293               });
294             });
295
296             var activeTab = localStorage.getItem("waitingreserves_activetab");
297             if( activeTab ){
298                 $("div#resultlist li:eq(" + activeTab + ") a").tab("show");
299             }
300             $("div#resultlist a[data-toggle='tab']").on("shown.bs.tab", function (e) {
301                 var thisTab = $(e.target).parent();
302                 var activeTab = thisTab.index();
303                 localStorage.setItem("waitingreserves_activetab", activeTab );
304             });
305
306         });
307     </script>
308 [% END %]
309
310 [% INCLUDE 'intranet-bottom.inc' %]