Bug 30952: Staff interface redesign (header)
[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"><i class="fa fa-home"></i></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="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 ) %]<p>Holds listed here have been awaiting pickup for more than [% ReservesMaxPickUpDelay | html %] days.</p>[% END %]
122             [% IF ( overloop ) %]
123                 <span id="holdsover-cancel-all">
124                    <button class="cancel_selected_holds" data-bulk="true"></button>
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" value="Cancel and Transfer all" />
131                        [% ELSE %]
132                            <input type="submit" value="Cancel all" />
133                        [% END %]
134                    </form>
135                    [% UNLESS TransferWhenCancelAllWaitingHolds %]
136                         Only items that need not be transferred will be cancelled (TransferWhenCancelAllWaitingHolds syspref)
137                    [% END %]
138
139                 </span>
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 %]
144         </div>
145         <div role="tabpanel" class="tab-pane" id="holdscancelled">
146             [% IF cancel_reqs_count %]
147                 [% INCLUDE waiting_holds.inc select_column='1' table_name='holdscr' reserveloop=cancel_reqs tab='holdscr' %]
148             [% ELSE %]
149                 <div class="dialog message">No holds found.</div>
150             [% END %]
151         </div>
152         </div>
153     [% END %]
154
155                     [% IF Koha.Preference('CircSidebar') %]
156                             </div> <!-- /.col-sm-10.col-sm-push-2 -->
157                             <div class="col-sm-2 col-sm-pull-10">
158                                 <aside>
159                                     [% INCLUDE 'circ-nav.inc' %]
160                                 </aside>
161                             </div> <!-- /.col-sm-2.col-sm-pull-10 -->
162                         </div> <!-- /.row -->
163                     [% END %]
164
165             </main>
166         </div> <!-- /.col-sm-12 -->
167     </div> <!-- /.row -->
168
169     <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
170         <div class="modal-dialog" role="document">
171             <div class="modal-content">
172                 <div class="modal-header">
173                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
174                     <h3>Confirm deletion</h3>
175                 </div>
176
177                 <div class="modal-body">
178                     <p>Are you sure you want to cancel this hold?</p>
179
180                     <fieldset class="action">
181                         [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
182                         [% IF hold_cancellation.count %]
183                             <label for="cancellation-reason">Cancellation reason: </label>
184                             <select class="cancellation-reason" name="modal-cancellation-reason" id="modal-cancellation-reason">
185                                 <option value="">No reason given</option>
186                                 [% FOREACH reason IN hold_cancellation %]
187                                     <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
188                                 [% END %]
189                             </select>
190                         [% END %]
191                     </fieldset>
192                 </div>
193
194                 <div class="modal-footer">
195                     <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger">Confirm cancellation</button>
196                     <a href="#" data-dismiss="modal">Cancel</a>
197                 </div>
198             </div>
199         </div>
200     </div>
201
202 [% MACRO jsinclude BLOCK %]
203     [% INCLUDE 'datatables.inc' %]
204     [% INCLUDE 'columns_settings.inc' %]
205     <script>
206         var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
207         var holdst_table_settings  = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdst',  'json' ) | $raw %];
208         var holdso_table_settings  = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdso',  'json' ) | $raw %];
209         var holdscr_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdscr', 'json' ) | $raw %];
210
211         $(document).ready(function() {
212
213             KohaTable("holdst", {
214                 "sPaginationType": "full",
215                 "order": [[1, 'asc']]
216             }, holdst_table_settings);
217
218             KohaTable("holdso", {
219                 "sPaginationType": "full",
220                 "order": [[1, 'asc']]
221             }, holdso_table_settings);
222
223             KohaTable("holdscr", {
224                 "sPaginationType": "full",
225                 "order": [[1, 'asc']]
226             }, holdscr_table_settings);
227
228             let cancel_link;
229
230             $("#cancelModalConfirmBtn").on("click",function(e) {
231                 var ids = cancel_link.data('ids');
232                 localStorage.selectedWaitingHolds = JSON.stringify(JSON.parse(localStorage.selectedWaitingHolds).filter(id => !ids.includes(id)));
233                 let link = `waitingreserves.pl?cancelBulk=1&amp;ids=${ids.join(',')}`;
234                 let reason = $("#modal-cancellation-reason").val();
235                 if ( reason ) {
236                     link += "&amp;cancellation-reason=" + reason
237                 }
238                 window.location.href = link;
239                 return false;
240             });
241
242             if(!localStorage.selectedWaitingHolds || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) {
243                 localStorage.selectedWaitingHolds = '[]';
244             }
245
246             try {
247                 JSON.parse(localStorage.selectedWaitingHolds);
248             } catch(e) {
249                 localStorage.selectedWaitingHolds = '[]';
250             }
251
252             $('.holds_table .select_hold').each(function() {
253                 if(JSON.parse(localStorage.selectedWaitingHolds).includes($(this).data('id'))) {
254                     $(this).prop('checked', true);
255                 }
256             });
257
258             $('.holds_table').each(function() {
259               var table = $(this);
260               var parent = table.parents('.tab-pane');
261
262               $('.holds_table .select_hold_all', parent).each(function() {
263                   var count = $('.select_hold:not(:checked)', table).length;
264                   $('.select_hold_all', table).prop('checked', !count);
265               });
266
267               $('.cancel_selected_holds', parent).html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked', parent).length));
268
269               $('.holds_table .select_hold_all', parent).click(function() {
270                   var count = $('.select_hold:checked', table).length;
271                   $('.select_hold', table).prop('checked', !count);
272                   $(this).prop('checked', !count);
273                   $('.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));
274                   localStorage.selectedWaitingHolds = JSON.stringify($('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')));
275               });
276
277               $('.holds_table .select_hold', parent).click(function() {
278                   var count = $('.select_hold:not(:checked)', table).length;
279                   $('.select_hold_all', table).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               $('.cancel_selected_holds', parent).click(function(e) {
285                   e.preventDefault();
286                   if($('.select_hold:checked', table).length) {
287                       cancel_link = $(this);
288                       $('#cancelModal').modal();
289                   }
290                   return false;
291               });
292             });
293
294             var activeTab = localStorage.getItem("waitingreserves_activetab");
295             if( activeTab ){
296                 $("div#resultlist li:eq(" + activeTab + ") a").tab("show");
297             }
298             $("div#resultlist a[data-toggle='tab']").on("shown.bs.tab", function (e) {
299                 var thisTab = $(e.target).parent();
300                 var activeTab = thisTab.index();
301                 localStorage.setItem("waitingreserves_activetab", activeTab );
302             });
303
304         });
305     </script>
306 [% END %]
307
308 [% INCLUDE 'intranet-bottom.inc' %]