Bug 30603: Fix other occurrences
[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 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'circ-search.inc' %]
17
18 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
19     <ol>
20         <li>
21             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
22         </li>
23         <li>
24             <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
25         </li>
26         <li>
27             <a href="#" aria-current="page">Holds awaiting pickup</a>
28         </li>
29     </ol>
30 </nav>
31
32 <div class="main container-fluid">
33     <div class="row">
34         <div class="col-sm-12">
35             <main>
36                 <div class="row">
37
38                 [% IF Koha.Preference('CircSidebar') %]
39                     <div class="col-sm-10 col-sm-push-2">
40                 [% ELSE %]
41                     <div class="col-sm-12">
42                 [% END %]
43
44             <h1>Holds awaiting pickup for your library on: [% show_date | $KohaDates %]</h1>
45             <h2>
46             [% IF ( all_branches_link ) %]
47             <span><a href="[% all_branches_link | url %]">
48             View all libraries</a></span>
49             [% END %]
50         </h2>
51     [% IF ( cancel_result ) %]
52         [% FOREACH cancel_result %]
53             [% IF ( messagetransfert ) %]
54                 <div class="dialog message">
55                     <h2>This item is on hold for pick-up at [% Branches.GetName( branchname ) | html %]</h2>
56                     <p><strong>[% nextreservtitle | html %]</strong> is on hold for <strong> [% nextreservsurname | html %], [% nextreservfirstname | html %]</strong>.
57                     Please retain this item and check it in to process the hold.
58                     </p>
59                     <form name="cancelReservewithtransfert" action="waitingreserves.pl#[% tab | html %]" method="post">
60                         <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
61                     </form>
62                 </div>
63             [% END %]
64             [% IF ( waiting ) %]
65                 <div class="dialog message">
66                     <h2>This item is on hold for pick-up at your library</h2>
67                     <p><strong>[% nextreservtitle | html %]</strong> is on hold for <strong>[% nextreservsurname | html %], [% nextreservfirstname | html %]</strong>.
68                     Please retain this item and check it in to process the hold.
69                     </p>
70                     <form name="cancelReservewithwaiting" action="waitingreserves.pl#[% tab | html %]" method="post">
71                         <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> OK</button>
72                     </form>
73                 </div>
74             [% END %]
75         [% END %]
76     [% ELSE %]
77         [% IF enqueued %]
78             <div class="dialog message">
79                 <p>The job has been enqueued! It will be processed as soon as possible.</p>
80                 <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>
81             </div>
82         [% END %]
83         <div id="resultlist" class="toptabs">
84             <ul class="nav nav-tabs" role="tablist">
85                 <li role="presentation" class="active"><a href="#holdswaiting" aria-controls="holdswaiting" role="tab" data-toggle="tab">Holds waiting: [% reservecount | html %]</a></li>
86                 <li role="presentation">
87                     <a href="#holdsover" aria-controls="holdsover" role="tab" data-toggle="tab">
88                         Holds waiting over [% Koha.Preference('ReservesMaxPickUpDelay') | html %] days: [% overcount | html %]
89                     </a>
90                 </li>
91             </ul>
92             <div class="tab-content">
93             <div role="tabpanel" class="tab-pane active" id="holdswaiting">
94         [% IF ( reserveloop ) %]
95             <div id="toolbar" class="btn-toolbar">
96                 <button class="cancel_selected_holds" data-bulk="true"></button>
97             </div>
98             [% INCLUDE waiting_holds.inc select_column='1' table_name='holdst' reserveloop=reserveloop tab='holdwaiting' %]
99         [% ELSE %]
100             <div class="dialog message">No holds found.</div>
101         [% END %]
102         </div>
103         <div role="tabpanel" class="tab-pane" id="holdsover">
104             [% IF ( ReservesMaxPickUpDelay ) %]<p>Holds listed here have been awaiting pickup for more than [% ReservesMaxPickUpDelay | html %] days.</p>[% END %]
105             [% IF ( overloop ) %]
106                 <span id="holdsover-cancel-all">
107                    <button class="cancel_selected_holds" data-bulk="true"></button>
108                    <form name="cancelAllReserve" action="waitingreserves.pl" method="post">
109                        <input type="hidden" name="cancelall" value="1" />
110                        <input type="hidden" name="allbranches" value="[% allbranches | html %]" />
111                        <input type="hidden" name="tab" value="holdsover">
112                        [% IF TransferWhenCancelAllWaitingHolds %]
113                            <input type="submit" value="Cancel and Transfer all" />
114                        [% ELSE %]
115                            <input type="submit" value="Cancel all" />
116                        [% END %]
117                    </form>
118                    [% UNLESS TransferWhenCancelAllWaitingHolds %]
119                         Only items that need not be transferred will be cancelled (TransferWhenCancelAllWaitingHolds syspref)
120                    [% END %]
121
122                 </span>
123                [% INCLUDE waiting_holds.inc select_column='1' table_name='holdso' reserveloop=overloop tab='holdsover' %]
124             [% ELSE %]
125                 <div class="dialog message">No holds found.</div>
126             [% END %]
127         </div>
128         </div>
129     [% END %]
130
131                     [% IF Koha.Preference('CircSidebar') %]
132                             </div> <!-- /.col-sm-10.col-sm-push-2 -->
133                             <div class="col-sm-2 col-sm-pull-10">
134                                 <aside>
135                                     [% INCLUDE 'circ-nav.inc' %]
136                                 </aside>
137                             </div> <!-- /.col-sm-2.col-sm-pull-10 -->
138                         </div> <!-- /.row -->
139                     [% END %]
140
141             </main>
142         </div> <!-- /.col-sm-12 -->
143     </div> <!-- /.row -->
144
145     <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
146         <div class="modal-dialog" role="document">
147             <div class="modal-content">
148                 <div class="modal-header">
149                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
150                     <h3>Confirm deletion</h3>
151                 </div>
152
153                 <div class="modal-body">
154                     <p>Are you sure you want to cancel this hold?</p>
155
156                     <fieldset class="action">
157                         [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
158                         [% IF hold_cancellation.count %]
159                             <label for="cancellation-reason">Cancellation reason: </label>
160                             <select class="cancellation-reason" name="modal-cancellation-reason" id="modal-cancellation-reason">
161                                 <option value="">No reason given</option>
162                                 [% FOREACH reason IN hold_cancellation %]
163                                     <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
164                                 [% END %]
165                             </select>
166                         [% END %]
167                     </fieldset>
168                 </div>
169
170                 <div class="modal-footer">
171                     <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger">Confirm cancellation</button>
172                     <a href="#" data-dismiss="modal">Cancel</a>
173                 </div>
174             </div>
175         </div>
176     </div>
177
178 [% MACRO jsinclude BLOCK %]
179     [% INCLUDE 'datatables.inc' %]
180     [% INCLUDE 'columns_settings.inc' %]
181     <script>
182         var MSG_CANCEL_SELECTED = _("Cancel selected (%s)");
183         var holdst_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdst', 'json' ) | $raw %];
184         var holdso_table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds_awaiting_pickup', 'holdso', 'json' ) | $raw %];
185
186         $(document).ready(function() {
187
188             KohaTable("holdst", {
189                 "sPaginationType": "full",
190                 "order": [[1, 'asc']]
191             }, holdst_table_settings);
192
193             KohaTable("holdso", {
194                 "sPaginationType": "full",
195                 "order": [[1, 'asc']]
196             }, holdso_table_settings);
197
198             let cancel_link;
199
200             $("#cancelModalConfirmBtn").on("click",function(e) {
201                 var ids = cancel_link.data('ids');
202                 localStorage.selectedWaitingHolds = JSON.stringify(JSON.parse(localStorage.selectedWaitingHolds).filter(id => !ids.includes(id)));
203                 let link = `waitingreserves.pl?cancelBulk=1&amp;ids=${ids.join(',')}`;
204                 let reason = $("#modal-cancellation-reason").val();
205                 if ( reason ) {
206                     link += "&amp;cancellation-reason=" + reason
207                 }
208                 window.location.href = link;
209                 return false;
210             });
211
212             if(!localStorage.selectedWaitingHolds || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) {
213                 localStorage.selectedWaitingHolds = '[]';
214             }
215
216             try {
217                 JSON.parse(localStorage.selectedWaitingHolds);
218             } catch(e) {
219                 localStorage.selectedWaitingHolds = '[]';
220             }
221
222             $('.holds_table .select_hold').each(function() {
223                 if(JSON.parse(localStorage.selectedWaitingHolds).includes($(this).data('id'))) {
224                     $(this).prop('checked', true);
225                 }
226             });
227
228             $('.holds_table').each(function() {
229               var table = $(this);
230               var parent = table.parents('.tab-pane');
231
232               $('.holds_table .select_hold_all', parent).each(function() {
233                   var count = $('.select_hold:not(:checked)', table).length;
234                   $('.select_hold_all', table).prop('checked', !count);
235               });
236
237               $('.cancel_selected_holds', parent).html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked', parent).length));
238
239               $('.holds_table .select_hold_all', parent).click(function() {
240                   var count = $('.select_hold:checked', table).length;
241                   $('.select_hold', table).prop('checked', !count);
242                   $(this).prop('checked', !count);
243                   $('.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));
244                   localStorage.selectedWaitingHolds = JSON.stringify($('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')));
245               });
246
247               $('.holds_table .select_hold', parent).click(function() {
248                   var count = $('.select_hold:not(:checked)', table).length;
249                   $('.select_hold_all', table).prop('checked', !count);
250                   $('.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));
251                   localStorage.selectedWaitingHolds = JSON.stringify($('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')));
252               });
253
254               $('.cancel_selected_holds', parent).click(function(e) {
255                   e.preventDefault();
256                   if($('.select_hold:checked', table).length) {
257                       cancel_link = $(this);
258                       $('#cancelModal').modal();
259                   }
260                   return false;
261               });
262             });
263
264
265         });
266     </script>
267 [% END %]
268
269 [% INCLUDE 'intranet-bottom.inc' %]