Bug 24488: Show correct first patron details on Holds to pull
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / circ / pendingreserves.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE TablesSettings %]
6 [% USE AuthorisedValues %]
7 [%- USE Branches -%]
8 [%- USE ItemTypes -%]
9 [% SET footerjs = 1 %]
10 [% INCLUDE 'doc-head-open.inc' %]
11 <title>Koha &rsaquo; Circulation &rsaquo; Holds to pull</title>
12 [% INCLUDE 'doc-head-close.inc' %]
13 </head>
14
15 <body id="circ_pendingreserves" class="circ">
16 [% INCLUDE 'header.inc' %]
17 [% INCLUDE 'circ-search.inc' %]
18
19
20 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo; Holds to pull</div>
21
22 <div class="main container-fluid">
23     <div class="row">
24         <div class="col-sm-10 col-sm-push-2">
25             <main>
26
27         [% FOR m IN messages %]
28             <div class="dialog [% m.type | html %]">
29                 [% SWITCH m.code %]
30                 [% CASE 'letter_enqueued' %]
31                     <span>The notice has been correctly enqueued.</span>
32                 [% CASE 'no_email_address' %]
33                     <span>The patron does not have an email address defined.</span>
34                 [% CASE 'no_template_notice' %]
35                     <span>There is no notice template with a code 'CANCEL_HOLD_ON_LOST' defined in your system.</span>
36                 [% CASE 'hold_cancelled' %]
37                     <span>The hold has been correctly cancelled.</span>
38                 [% CASE 'hold_placed_at_biblio_level' %]
39                     <span>The hold has been placed on biblio level. It is not possible to determine the item to mark as lost.</span>
40                 [% CASE %]
41                     [% m.code | html %]
42                 [% END %]
43             </div>
44         [% END %]
45
46 <h2>Holds to pull placed between [% from | $KohaDates %] and [% to | $KohaDates %]</h2>
47 <h3>Reported on [% todaysdate | $KohaDates %]</h3>
48 <p>The following holds have not been filled. Please retrieve them and check them in.</p>
49 <div id="searchresults">
50     [% IF ( reserves ) %]
51     <table id="holdst">
52     <thead>
53         <tr>
54         <th>Pull this many items</th>
55         <th>Items available</th>
56         <th>Patrons with holds</th>
57         <th>First patron</th>
58         <th class="anti-the">Title</th>
59         <th class="string-sort">Libraries</th>
60         <th>Available barcodes</th>
61         <th>Available call numbers</th>
62         <th>Available copy numbers</th>
63         <th>Available enumeration</th>
64         <th class="string-sort">Available item types</th>
65         <th class="string-sort">Available locations</th>
66         <th class="title-string">Earliest hold date</th>
67         <th>Action</th>
68         </tr>
69     </thead>
70     <tbody>
71         [% FOREACH reserve IN reserves %]
72         <tr>
73         [% IF ( reserve.value.borrower ) %]
74             <td><p><strong>[% reserve.value.pull_count | html %]</strong></p></td>
75             <td>[% reserve.value.items_count | html %]</td>
76             <td>[% reserve.value.patrons_count | html %]</td>
77             <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% reserve.value.borrower.borrowernumber | uri %]">[% reserve.value.borrower.firstname | html %] [% reserve.value.borrower.surname | html %]</a></td>
78             <td>
79                 <p>
80                     [% INCLUDE 'biblio-title.inc' biblio=reserve.value.biblio link = 1 %]
81                 </p>
82                 [% IF ( reserve.value.biblio.author ) %]<p> by [% reserve.value.biblio.author | html %]</p>[% END %]
83                 [% IF ( reserve.value.biblio.biblioitem.editionstatement ) %]<p>[% reserve.value.biblio.biblioitem.editionstatement | html %]</p>[% END %]
84                 [% IF ( reserve.value.biblio.biblioitem.publicationyear ) %]<p>[% reserve.value.biblio.biblioitem.publicationyear | html %]</p>[% END %]
85             </td>
86         [% ELSE %]
87             <td>"</td>
88             <td>"</td>
89             <td>"</td>
90             <td>"</td>
91             <td>"</td>
92         [% END %]
93         <td>
94             [% IF ( reserve.value.holdingbranches ) %]
95             <ul>
96                 [% FOREACH holdingbranch IN reserve.value.holdingbranches %]
97                     <li>[% Branches.GetName ( holdingbranch.holdingbranch ) | html %]</li>
98                 [% END %]
99             </ul>
100             [% END %]
101         </td>
102         <td>
103             [% IF ( reserve.value.barcodes.count ) %]
104                 [% SET barcode = reserve.value.barcodes.next.barcode %]
105                 [% IF ( reserve.value.itemnumber ) %]Only [% barcode | html %][% ELSE %][% barcode | html %] or any available.[% END %]
106             [% END %]
107         </td>
108         <td>
109             [% IF ( reserve.value.callnumbers ) %]
110                 <ul>
111                     [% FOREACH callnumber IN reserve.value.callnumbers %]
112                         <li>
113                             [% callnumber.itemcallnumber | html %]
114                         </li>
115                     [% END %]
116                 </ul>
117             [% END %]
118         </td>
119         <td>
120             [% IF ( reserve.value.copynumbers ) %]
121                 <ul>
122                     [% FOREACH copyno IN reserve.value.copynumbers %]
123                         <li>
124                             [% copyno.copynumber | html %]
125                         </li>
126                     [% END %]
127                 </ul>
128             [% END %]
129         </td>
130         <td>
131             [% IF ( reserve.value.enumchrons ) %]
132                 <ul>
133                     [% FOREACH enumchron IN reserve.value.enumchrons %]
134                         <li>
135                             [% enumchron.enumchron | html %]
136                         </li>
137                     [% END %]
138                 </ul>
139             [% END %]
140         </td>
141         <td>
142             <ul>
143             [% FOREACH type IN reserve.value.itemtypes %]
144                 [% IF Koha.Preference('item-level_itypes') %]
145                     <li>[% ItemTypes.GetDescription( type.itype ) | html %]</li>
146                 [% ELSE %]
147                     <li>[% ItemTypes.GetDescription( type.itemtype ) | html %]</li>
148                 [% END %]
149             [% END %]
150             </ul>
151         </td>
152         <td>
153             <ul>
154             [% FOREACH loc IN reserve.value.locations %]
155                 <li>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => loc.location) | html %]</li>
156             [% END %]
157             </ul>
158         </td>
159         <td>
160             <span title="[% reserve.value.reserve.reservedate | html %]">[% reserve.value.reserve.reservedate | $KohaDates %] in [% Branches.GetName ( reserve.value.reserve.branchcode ) | html %]</span>
161         </td>
162         <td>
163             <form name="cancelReserve" action="/cgi-bin/koha/circ/pendingreserves.pl" method="post">
164                 <input type="hidden" name="op" value="cancel_reserve" />
165                 <input type="hidden" name="reserve_id" value="[% reserve.value.reserve.reserve_id | html %]" />
166
167                 [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %]
168                 [% IF hold_cancellation %]
169                     <div class="form-group">
170                         <label for="cancellation-reason">Cancellation reason:</label>
171                         <select class="cancellation-reason" name="cancellation-reason" id="cancellation-reason">
172                             <option value="">No reason given</option>
173                             [% FOREACH reason IN hold_cancellation %]
174                                 <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
175                             [% END %]
176                         </select>
177                     </div>
178                 [% END %]
179
180                 [% IF reserve.value.item.holdingbranch != reserve.value.item.homebranch %]
181                     <input class="btn btn-default" type="submit" value="Cancel hold and return to : [% Branches.GetName( reserve.value.item.homebranch ) | html %]" />
182                 [% ELSE %]
183                     <input class="btn btn-default" type="submit" value="Cancel hold" />
184                 [% END %]
185             </form>
186
187         [% IF Koha.Preference('CanMarkHoldsToPullAsLost') != 'do_not_allow' %]
188             [% IF reserve.value.reserve.itemnumber %]
189                 <form name="cancelReserve" action="/cgi-bin/koha/circ/pendingreserves.pl" method="post">
190                     <input type="hidden" name="reserve_id" value="[% reserve.value.reserve.reserve_id | html %]" />
191                     [% IF Koha.Preference('CanMarkHoldsToPullAsLost') == 'allow' %]
192                         <input type="hidden" name="op" value="mark_as_lost" />
193                         <input type="submit" value="Mark item as lost" />
194                     [% ELSIF Koha.Preference('CanMarkHoldsToPullAsLost') == 'allow_and_notify' %]
195                         <input type="hidden" name="op" value="mark_as_lost_and_notify" />
196                         <input type="submit" value="Mark lost and notify patron" />
197                     [% END %]
198                 </form>
199             [% ELSE %]
200                 <span>Biblio level hold.</span>
201             [% END %]
202         [% END %]
203             </td>
204         </tr>
205         [% END %]
206     </tbody>
207     <tfoot>
208         <tr>
209         <td><input type="text" class="filter" data-column_num="0" placeholder="Pull this many items" style="width:95%"/></td>
210         <td><input type="text" class="filter" data-column_num="1" placeholder="Items available" style="width:95%"/></td>
211         <td><input type="text" class="filter" data-column_num="2" placeholder="Patron holds" style="width:95%"/></td>
212         <td><input type="text" class="filter" data-column_num="3" placeholder="Patron name" style="width:95%"/></td>
213         <td><input type="text" class="filter" data-column_num="4" placeholder="Title" style="width:95%"/></td>
214         <td id="homebranchfilter"></td>
215         <td></td>
216         <td><input type="text" class="filter" data-column_num="7" placeholder="Call number" style="width:95%"/></td>
217         <td><input type="text" class="filter" data-column_num="8" placeholder="Available copy" style="width:95%"/></td>
218         <td><input type="text" class="filter" data-column_num="9" placeholder="Available enumeration" style="width:95%"/></td>
219         <td id="itemtype-filter"></td>
220         <td id="locationfilter"></td>
221         <td></td>
222         <td></td>
223         </tr>
224     </tfoot>
225     </table>
226     [% ELSE %]
227         <strong>No items found.</strong>
228     [% END %]
229 </div>
230
231
232             </main>
233         </div> <!-- /.col-sm-10.col-sm-push-2 -->
234
235         <div class="col-sm-2 col-sm-pull-10">
236             <aside>
237
238 <div id="filters">
239
240 <form action="/cgi-bin/koha/circ/pendingreserves.pl" method="post" >
241 <fieldset class="brief">
242 <h4>Refine results</h4>
243 <ol>
244 <li>
245 <label for="from">
246     Start date:
247 </label>
248 <input type="text" size="10" id="from" name="from" value="[% from | $KohaDates %]" class="datepickerfrom" />
249 </li>
250 <li><label for="to">
251     End date:
252 </label>
253 <input type="text" size="10" id="to" name="to" value="[% to | $KohaDates %]" class="datepickerto" />
254 </li>
255 </ol>
256
257 [% IF ( HoldsToPullEndDate ) %]
258     <p><em>(Inclusive, default is [% HoldsToPullStartDate | html %] days ago to [% HoldsToPullEndDate | html %] days ahead. Set other date ranges as needed.)</em></p>
259 [% ELSE %]
260     <p><em>(Inclusive, default is [% HoldsToPullStartDate | html %] days ago to today. Set other date ranges as needed.)</em></p>
261 [% END %]
262
263 <fieldset class="action"><input type="submit" name="run_report" value="Submit" class="submit"/></fieldset>
264 </fieldset>
265 </form>
266
267 </div>
268             </aside>
269         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
270      </div> <!-- /.row -->
271
272 [% MACRO jsinclude BLOCK %]
273     [% INCLUDE 'calendar.inc' %]
274     [% INCLUDE 'datatables.inc' %]
275     [% INCLUDE 'columns_settings.inc' %]
276     <script>
277         $(document).ready(function() {
278           var columns_settings = [% TablesSettings.GetColumns('circ', 'holds', 'holds-to-pull', 'json') | $raw %];
279           var holdst = KohaTable("holdst", {
280             "sPaginationType": "full_numbers"
281           }, columns_settings);
282           holdst.fnAddFilters("filter");
283           [%# add separateData function to cleanse jQuery select lists by breaking apart strings glued with BR tags and then de-duplicating any repeated library codes %]
284           function separateData ( ColumnData ){
285             var cD = ColumnData;
286             var new_array = new Array();
287             for ( j=0 ; j<cD.length ; j++ ) {
288                 var split_array = cD[j].split(/\n/gi);
289                 for ( k=0 ; k<split_array.length ; k++ ){
290                     var str = $.trim(split_array[k].replace(/[\n\r]/g, ''));
291                     if ($.inArray(str, new_array) == -1 && str.length > 0 ) {
292                         new_array.push(str);
293                     }
294                 }
295             }
296             new_array.sort();
297             return new_array;
298           }
299           [%# add SeparateData function into createSelect function, so that it does the createSelect on clean data %]
300           function createSelect( data ) {
301               data = separateData(data);
302               var r='<select style="width:99%"><option value="">' + _("None") + '</option>', i, len=data.length;
303               var regex = /(<([^>]+)>)/ig; // Remove html tags
304               for ( i=0 ; i<len ; i++ ) {
305                   var cell_val = data[i].replace(regex, '');
306                   if ( cell_val.length < 1 ) continue;
307                   r += '<option value="'+cell_val+'">'+cell_val+'</option>';
308               }
309               return r+'</select>';
310           }
311           $("#homebranchfilter").each( function () {
312               $(this).html( createSelect( holdst.fnGetColumnData(5) ) );
313               $('select', this).change( function () {
314                   holdst.fnFilter( $(this).child().val(), 5 );
315               });
316           });
317           $("#itemtype-filter").each( function () {
318               $(this).html( createSelect( holdst.fnGetColumnData(10) ) );
319               $('select', this).change( function () {
320                   holdst.fnFilter( $(this).val(), 10 );
321               });
322           });
323           $("#locationfilter").each( function () {
324               $(this).html( createSelect( holdst.fnGetColumnData(11) ) );
325               $('select', this).change( function () {
326                   holdst.fnFilter( $(this).val(), 11 );
327               });
328           });
329         });
330     </script>
331 [% END %]
332
333 [% INCLUDE 'intranet-bottom.inc' %]