Bug 27947: Add cancellation reason to article request
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / circ / article-requests.tt
1 [% USE KohaDates %]
2 [% USE ItemTypes %]
3 [% USE Branches %]
4 [% USE AuthorisedValues %]
5 [% USE Asset %]
6 [% USE raw %]
7 [% SET footerjs = 1 %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Article requests &rsaquo; Circulation &rsaquo; Koha</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 <style>p { margin-top: 0; } [id^="article-menu-"] { display: none; } [id^="article-menu-"]:before { content: "|"; } .starthidden { display:none; }</style>
12 </head>
13
14 [% BLOCK actions %]
15     <div id="[% menuid | html %]" class="btn-group dropup">
16     <span>
17         <a class="btn btn-default btn-xs dropdown-toggle ar-actions" role="button" data-toggle="dropdown" href="#">
18             Actions <b class="caret"></b>
19         </a>
20
21         <ul class="dropdown-menu [% pull_right | html %]" role="menu" aria-labelledby="[% aria_menu | html %]">
22             <li>
23                 <a class="ar-set-pending-request" href="#" onclick="HandleMulti( SetPending, [% id_arg | html %], $(this) ); return false;">
24                     <i class="fa fa-bars"></i>
25                     Set request as pending
26                 </a>
27
28                 <a class="ar-process-request" href="#" onclick="HandleMulti( Process, [% id_arg | html %], $(this) ); return false;">
29                     <i class="fa fa-cog"></i>
30                     Process request
31                 </a>
32
33                 [% IF id_arg && format=='SCAN' %]
34                 <a class="ar-edit-urls" href="#" onclick="HandleMulti( EditURLs, [% id_arg | html %], $(this) ); return false;">
35                     <i class="fa fa-edit"></i>
36                     Edit URLs
37                 </a>
38                 [% END %]
39
40                 <a class="ar-complete-request" href="#" onclick="HandleMulti( Complete, [% id_arg | html %], $(this) ); return false;">
41                     <i class="fa fa-check-circle"></i>
42                     Complete request
43                 </a>
44
45                 <a class="ar-cancel-request" href="#" onclick="Cancel( [% id_arg | html %], $(this) ); return false;">
46                     <i class="fa fa-minus-circle"></i>
47                     Cancel request
48                 </a>
49
50                 [% IF id_arg %][%# TODO: Does not work with multi-select %]
51                 <a class="ar-print-request" href="#" onclick="HandleMulti( PrintSlip, [% id_arg | html %], $(this) ); return false;">
52                     <i class="fa fa-print"></i>
53                     Print slip
54                 </a>
55                 [% END %]
56             </li>
57         </ul>
58         </span>
59     </div>
60 [% END %]
61 [% BLOCK item_status %]
62     [% IF myitem.onloan %]<span>Checked out</span>
63     [% ELSIF myitem.holds({ found => ['W', 'T'] }).count > 0 %]<span>On hold</span>
64     [% ELSIF myitem.notforloan > 0 OR myitem.itemtype.notforloan %]<span>Not for loan</span>
65     [% ELSIF myitem.notforloan < 0 %]<span>On order</span>
66     [% END %]
67 [% END %]
68 [% BLOCK urls_modal %]
69     <div id="myModal" class="modal fade modal-lg" role="dialog">
70       <div class="modal-dialog">
71         <div class="modal-content">
72           <div class="modal-header">
73              <h4 class="modal-title">Edit URL(s)</h4>
74           </div>
75           <div class="modal-body">
76             <textarea id="urls" style="width:100%;"></textarea>
77           </div>
78           <div class="modal-footer">
79             <button type="button" class="btn btn-default" data-dismiss="modal">Save</button>
80           </div>
81         </div>
82       </div>
83     </div>
84 [% END %]
85 [% BLOCK cancel_modal %]
86     <div id="cancelModal" class="modal" tabindex="-1" role="dialog" aria-hidden="true">
87         <div class="modal-dialog" role="document">
88             <div class="modal-content">
89                 <div class="modal-header">
90                     <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
91                     <h3>Confirm deletion</h3>
92                 </div>
93
94                 <div class="modal-body">
95                     <p>Are you sure you want to cancel this article request?</p>
96
97                     <fieldset class="action">
98                         [% SET ar_cancellation = AuthorisedValues.GetAuthValueDropbox('AR_CANCELLATION') %]
99                         [% IF ar_cancellation %]
100                             <label for="cancellation-reason" class="col-sm-4">Cancellation reason: </label>
101                             <select class="cancellation-reason col-sm-8" name="cancellation-reason" id="modal-cancellation-reason">
102                                 <option value="" selected>Other reasons</option>
103                                 [% FOREACH reason IN ar_cancellation %]
104                                     <option value="[% reason.authorised_value | html %]">[% reason.lib | html %]</option>
105                                 [% END %]
106                             </select>
107                         [% END %]
108                     </fieldset>
109                     <fieldset class="action">
110                         <div class="hint col-sm-offset-4">Enter reason</div>
111                         <input type="text" class="notes col-sm-offset-4 col-sm-8" name="notes" id="modal-notes"/>
112                     </fieldset>
113                 </div>
114
115                 <div class="modal-footer">
116                     <button id="cancelModalConfirmBtn" type="button" class="btn btn-danger" data-dismiss="modal">Confirm cancellation</button>
117                     <a href="#" data-dismiss="modal">Cancel</a>
118                 </div>
119             </div>
120         </div>
121     </div>
122 [% END %]
123
124 <body id="circ_article-requests" class="circ">
125     [% INCLUDE 'header.inc' %]
126     [% INCLUDE 'cat-search.inc' %]
127
128
129     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
130         <ol>
131             <li>
132                 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
133             </li>
134             <li>
135                 <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
136             </li>
137             <li>
138                 <a href="#" aria-current="page">Article requests</a>
139             </li>
140         </ol>
141     </nav>
142
143     <div class="main container-fluid starthidden">
144         <div class="row">
145             <div class="col-md-10 col-md-offset-1 col-lg-10 col-lg-offset-1">
146
147                 <h1>Article requests</h1>
148                 [% PROCESS urls_modal %]
149
150                 <form id="ar-branchcode-form" method="post">
151                     <select name="branchcode" id="branchcode">
152                         <option value="">All libraries</option>
153                         [% FOREACH b IN Branches.all( only_from_group => 1 ) %]
154                             [% IF b.branchcode == branchcode %]
155                                 <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
156                             [% ELSE %]
157                                 <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
158                             [% END %]
159                         [% END %]
160                     </select>
161                     <button type="submit" class="btn btn-default btn-xs">
162                         <i class="fa fa-refresh"></i> Update
163                     </button>
164                 </form>
165
166                 <div id="article-request-tabs" class="toptabs">
167                     <ul>
168                         <li>
169                             <a href="#article-requests-requested">
170                                 New (<span id="ar_requested_count">[% article_requests_requested.count | html %]</span>)
171                             </a>
172                         </li>
173
174                         <li>
175                             <a href="#article-requests-pending">
176                                 Pending (<span id="ar_pending_count">[% article_requests_pending.count | html %]</span>)
177                             </a>
178                         </li>
179
180                         <li>
181                             <a href="#article-requests-processing">
182                                 Processing (<span id="ar_processing_count">[% article_requests_processing.count | html %]</span>)
183                             </a>
184                         </li>
185                     </ul>
186
187                     <div id="article-requests-requested">
188                         <div class="article-requests-requested_table_controls">
189                             <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
190                             [% PROCESS actions menuid='article-menu-requested' id_arg=0 pull_right='' aria_menu='table_controls' %]
191                         </div>
192
193                         <table id="article-requests-requested-table">
194                             <thead>
195                                 <tr>
196                                     <th/>
197                                     <th class="ar-title">Title</th>
198                                     <th class="ar-request">Requested article</th>
199                                     <th class="ar-collection">Collection</th>
200                                     <th class="ar-itemtype">Item type</th>
201                                     <th class="ar-callnumber">Call number</th>
202                                     <th class="ar-status">Status</th>
203                                     <th class="ar-copynumber">Copy number</th>
204                                     <th class="ar-enumchron">Enumeration</th>
205                                     <th class="ar-barcode">Barcode</th>
206                                     <th class="ar-format">Format</th>
207                                     <th class="ar-urls">URLs</th>
208                                     <th class="ar-patron">Patron</th>
209                                     <th class="ar-date">Date</th>
210                                     <th class="ar-actions noExport">Actions</th>
211                                 </tr>
212                             </thead>
213
214                              <tbody>
215                                 [% FOREACH ar IN article_requests_requested %]
216                                     <tr class="ar-row ar-requested">
217                                         <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
218                                         <td class="ar-title">
219                                             <p>
220                                                 <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
221                                                     [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
222                                                 </a>
223                                             </p>
224
225                                             <p>
226                                                 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
227                                                 <div class="ar-author">[% ar.biblio.author | html %]</div>
228                                                 <div class="ar-pubdata">
229                                                     [% ar.biblio.biblioitem.publishercode | html %]
230
231                                                     [% IF ar.biblio.biblioitem.publicationyear %]
232                                                         [% ar.biblio.biblioitem.publicationyear | html %]
233                                                     [% ELSIF ar.biblio.copyrightdate %]
234                                                         [% ar.biblio.copyrightdate | html %]
235                                                     [% END %]
236
237                                                     [% IF ar.biblio.biblioitem.pages %]
238                                                         : [% ar.biblio.biblioitem.pages | html %]
239                                                     [% END %]
240
241                                                     [% r.biblio.biblioitem.size | html %]
242
243                                                     [% IF ar.biblio.biblioitem.isbn %]
244                                                         ISBN: [% ar.biblio.biblioitem.isbn | html %]
245                                                     [% END %]
246                                                 </div>
247                                             </p>
248                                         </td>
249                                         <td class="ar-request">
250                                             [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title | html %]        </p> [% END %]
251                                             [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author | html %]       </p> [% END %]
252                                             [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume | html %]       </p> [% END %]
253                                             [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue | html %]        </p> [% END %]
254                                             [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date | html %]         </p> [% END %]
255                                             [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages | html %]        </p> [% END %]
256                                             [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters | html %]     </p> [% END %]
257                                             [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
258                                         </td>
259                                         <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
260                                         <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
261                                         <td class="ar-callnumber">
262                                             [% IF ar.item.location %]
263                                                 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
264                                             [% END %]
265
266                                             [% ar.item.itemcallnumber | html %]
267                                         </td>
268                                         <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
269                                         <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
270                                         <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
271                                         <td class="ar-barcode">[% ar.item.barcode | html %]</td>
272                                         <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
273                                         <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id | html %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id | html %]" style="display:none;">[% ar.urls | url %]</span>[% END %]</td>
274                                         <td class="ar-patron">
275                                             <p>
276                                                 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
277                                                     [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
278                                                 </a>
279                                             </p>
280
281                                             <p>[% ar.borrower.phone | html %]</p>
282                                         </td>
283                                         <td class="ar-date"><span title="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</span></td>
284                                         <td class="ar-actions">
285                                             [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id pull_right='pull-right' aria_menu='ar-actions' %]
286                                         </td>
287                                     </tr>
288                                 [% END %]
289                             </tbody>
290                         </table>
291                     </div>
292
293                     <div id="article-requests-pending">
294                         <div class="article-requests-pending_table_controls">
295                             <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
296                             [% PROCESS actions menuid='article-menu-pending' id_arg=0 pull_right='' aria_menu='table_controls' %]
297                         </div>
298
299                         <table id="article-requests-pending-table">
300                             <thead>
301                                 <tr>
302                                     <th/>
303                                     <th class="ar-title">Title</th>
304                                     <th class="ar-request">Requested article</th>
305                                     <th class="ar-collection">Collection</th>
306                                     <th class="ar-itemtype">Item type</th>
307                                     <th class="ar-callnumber">Call number</th>
308                                     <th class="ar-status">Status</th>
309                                     <th class="ar-copynumber">Copy number</th>
310                                     <th class="ar-enumchron">Enumeration</th>
311                                     <th class="ar-barcode">Barcode</th>
312                                     <th class="ar-format">Format</th>
313                                     <th class="ar-urls">URLs</th>
314                                     <th class="ar-patron">Patron</th>
315                                     <th class="ar-date">Date</th>
316                                     <th class="ar-actions noExport">Actions</th>
317                                 </tr>
318                             </thead>
319
320                              <tbody>
321                                 [% FOREACH ar IN article_requests_pending %]
322                                     <tr class="ar-row ar-pending">
323                                         <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
324                                         <td class="ar-title">
325                                             <p>
326                                                 <a class="title" href="/cgi-bin/koha/circ/request-article.pl?biblionumber=[% ar.biblionumber | uri %]">
327                                                     [% INCLUDE 'biblio-title.inc' biblio=ar.biblio %]
328                                                 </a>
329                                             </p>
330
331                                             <p>
332                                                 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
333                                                 <div class="ar-author">[% ar.biblio.author | html %]</div>
334                                                 <div class="ar-pubdata">
335                                                     [% ar.biblio.biblioitem.publishercode | html %]
336
337                                                     [% IF ar.biblio.biblioitem.publicationyear %]
338                                                         [% ar.biblio.biblioitem.publicationyear | html %]
339                                                     [% ELSIF ar.biblio.copyrightdate %]
340                                                         [% ar.biblio.copyrightdate | html %]
341                                                     [% END %]
342
343                                                     [% IF ar.biblio.biblioitem.pages %]
344                                                         : [% ar.biblio.biblioitem.pages | html %]
345                                                     [% END %]
346
347                                                     [% r.biblio.biblioitem.size | html %]
348
349                                                     [% IF ar.biblio.biblioitem.isbn %]
350                                                         ISBN: [% ar.biblio.biblioitem.isbn | html %]
351                                                     [% END %]
352                                                 </div>
353                                             </p>
354                                         </td>
355                                         <td class="ar-request">
356                                             [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title | html %]        </p> [% END %]
357                                             [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author | html %]       </p> [% END %]
358                                             [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume | html %]       </p> [% END %]
359                                             [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue | html %]        </p> [% END %]
360                                             [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date | html %]         </p> [% END %]
361                                             [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages | html %]        </p> [% END %]
362                                             [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters | html %]     </p> [% END %]
363                                             [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
364                                         </td>
365                                         <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
366                                         <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
367                                         <td class="ar-callnumber">
368                                             [% IF ar.item.location %]
369                                                 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
370                                             [% END %]
371
372                                             [% ar.item.itemcallnumber | html %]
373                                         </td>
374                                         <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
375                                         <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
376                                         <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
377                                         <td class="ar-barcode">[% ar.item.barcode | html %]</td>
378                                         <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
379                                         <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id | html %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id | html %]" style="display:none;">[% ar.urls | url %]</span>[% END %]</td>
380                                         <td class="ar-patron">
381                                             <p>
382                                                 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
383                                                     [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
384                                                 </a>
385                                             </p>
386
387                                             <p>[% ar.borrower.phone | html %]</p>
388                                         </td>
389                                         <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
390                                         <td class="ar-actions">
391                                             [% PROCESS actions menuid = "row" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
392                                         </td>
393                                     </tr>
394                                 [% END %]
395                             </tbody>
396                         </table>
397                     </div>
398
399                     <div id="article-requests-processing">
400                         <div class="article-requests-processing_table_controls">
401                             <a href="#" class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
402                             [% PROCESS actions menuid='article-menu-processing' id_arg=0 pull_right='' aria_menu='table_controls' %]
403                         </div>
404                         <table id="article-requests-processing-table">
405                             <thead>
406                                 <tr>
407                                     <th/>
408                                     <th class="ar-title">Title</th>
409                                     <th class="ar-request">Requested article</th>
410                                     <th class="ar-collection">Collection</th>
411                                     <th class="ar-itemtype">Item type</th>
412                                     <th class="ar-callnumber">Call number</th>
413                                     <th class="ar-status">Status</th>
414                                     <th class="ar-copynumber">Copy number</th>
415                                     <th class="ar-enumchron">Enumeration</th>
416                                     <th class="ar-barcode">Barcode</th>
417                                     <th class="ar-format">Format</th>
418                                     <th class="ar-urls">URLs</th>
419                                     <th class="ar-patron">Patron</th>
420                                     <th class="ar-date">Date</th>
421                                     <th class="ar-actions noExport">Actions</th>
422                                 </tr>
423                             </thead>
424
425                              <tbody>
426                                 [% FOREACH ar IN article_requests_processing %]
427                                     <tr class="ar-row ar-processing">
428                                         <td><input type="checkbox" reqid="[% ar.id | html %]"/></td>
429                                         <td class="ar-title">
430                                             <p>
431                                                 [% INCLUDE 'biblio-title.inc' biblio=ar.biblio link = 1%]
432                                             </p>
433
434                                             <p>
435                                                 <div class="ar-biblionumber content_hidden">[% ar.biblionumber | html %]</div>
436                                                 <div class="ar-author">[% ar.biblio.author | html %]</div>
437                                                 <div class="ar-pubdata">
438                                                     [% ar.biblio.biblioitem.publishercode | html %]
439
440                                                     [% IF ar.biblio.biblioitem.publicationyear %]
441                                                         [% ar.biblio.biblioitem.publicationyear | html %]
442                                                     [% ELSIF ar.biblio.copyrightdate %]
443                                                         [% ar.biblio.copyrightdate | html %]
444                                                     [% END %]
445
446                                                     [% IF ar.biblio.biblioitem.pages %]
447                                                         : [% ar.biblio.biblioitem.pages | html %]
448                                                     [% END %]
449
450                                                     [% r.biblio.biblioitem.size | html %]
451
452                                                     [% IF ar.biblio.biblioitem.isbn %]
453                                                         ISBN: [% ar.biblio.biblioitem.isbn | html %]
454                                                     [% END %]
455                                                 </div>
456                                             </p>
457                                         </td>
458                                         <td class="ar-request">
459                                             [% IF ar.title %]        <p><strong>Title:</strong>        [% ar.title | html %]        </p> [% END %]
460                                             [% IF ar.author %]       <p><strong>Author:</strong>       [% ar.author | html %]       </p> [% END %]
461                                             [% IF ar.volume %]       <p><strong>Volume:</strong>       [% ar.volume | html %]       </p> [% END %]
462                                             [% IF ar.issue %]        <p><strong>Issue:</strong>        [% ar.issue | html %]        </p> [% END %]
463                                             [% IF ar.date %]         <p><strong>Date:</strong>         [% ar.date | html %]         </p> [% END %]
464                                             [% IF ar.pages %]        <p><strong>Pages:</strong>        [% ar.pages | html %]        </p> [% END %]
465                                             [% IF ar.chapters %]     <p><strong>Chapters:</strong>     [% ar.chapters | html %]     </p> [% END %]
466                                             [% IF ar.patron_notes %] <p><strong>Patron notes:</strong> [% ar.patron_notes | html %] </p> [% END %]
467                                         </td>
468                                         <td class="ar-collection">[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => ar.item.ccode ) | html %]</td>
469                                         <td class="ar-itemtype">[% ItemTypes.GetDescription( ar.item.effective_itemtype ) | html %]</td>
470                                         <td class="ar-callnumber">
471                                             [% IF ar.item.location %]
472                                                 <em>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ar.item.location ) | html %]</em>
473                                             [% END %]
474
475                                             [% ar.item.itemcallnumber | html %]
476                                         </td>
477                                         <td class="ar-status">[% PROCESS 'item_status' myitem = ar.item IF ar.item %]</td>
478                                         <td class="ar-copynumber">[% ar.item.copynumber | html %]</td>
479                                         <td class="ar-enumchron">[% ar.item.enumchron | html %]</td>
480                                         <td class="ar-barcode">[% ar.item.barcode | html %]</td>
481                                         <td class="ar-format">[% IF ar.format == 'PHOTOCOPY' %]Copy[% ELSIF ar.format == 'SCAN' %]Scan[% END %]</td>
482                                         <td class="ar-urls">[% IF ar.format == 'SCAN' %]<span id="url_yesno_[% ar.id | html %]">[% IF ar.urls %]Yes[% ELSE %]No[% END%]</span><span id="url_[% ar.id | html %]" style="display:none;">[% ar.urls | url %]</span>[% END %]</td>
483                                         <td class="ar-patron">
484                                             <p>
485                                                 <a href="/cgi-bin/koha/circ/circulation.pl?findborrower=[% ar.borrower.cardnumber | uri %]">
486                                                     [% ar.borrower.surname | html %][% IF ar.borrower.firstname %], [% ar.borrower.firstname | html %][% END %] ([% ar.borrower.cardnumber | html %])
487                                                 </a>
488                                             </p>
489
490                                             <p>[% ar.borrower.phone | html %]</p>
491                                         </td>
492                                         <td class="ar-date" data-order="[% ar.created_on | html %]">[% ar.created_on | $KohaDates %]</td>
493                                         <td class="ar-actions">
494                                             [% PROCESS actions menuid="table_" _ ar.id id_arg=ar.id format=ar.format pull_right='pull-right' aria_menu='ar-actions' %]
495                                         </td>
496                                     </tr>
497                                 [% END %]
498                             </tbody>
499                         </table>
500                     </div>
501                     <br/>
502                 </div>
503             </div>
504         </div>
505     </div>
506     [% PROCESS cancel_modal %]
507
508 [% MACRO jsinclude BLOCK %]
509     [% INCLUDE 'datatables.inc' %]
510     <script>
511         var active_tab = "#article-requests-requested";
512         var last_cancel_reason, requested_datatable, pending_datatable, processing_datatable, active_datatable;
513         $(document).ready(function() {
514             $('#article-request-tabs').tabs({
515                 activate: function( activate_event, activate_ui ) {
516                     active_tab = activate_ui.newPanel.selector;
517                     if( active_tab == '#article-requests-requested' )
518                         active_datatable = requested_datatable;
519                     else if( active_tab == '#article-requests-pending' )
520                         active_datatable = pending_datatable;
521                     else active_datatable = processing_datatable;
522                     activateBatchActions( active_tab );
523                 },
524             });
525
526
527             $( "input:checkbox, #article-request-tabs" ).on("change", function(){
528                 activateBatchActions( active_tab );
529             });
530
531             $(".SelectAll").on("click", function(e) {
532                 e.preventDefault();
533                 $( active_tab + " input[type='checkbox']").prop('checked', true);
534                 activateBatchActions( active_tab );
535             });
536             $(".ClearAll").on("click", function(e) {
537                 e.preventDefault();
538                 $( active_tab + " input[type='checkbox']").prop('checked', false);
539                 activateBatchActions( active_tab );
540             });
541             $("a.ar-actions").on('click', function(e) {
542                 // Hide menu option ?
543                 if( $('#article-requests-requested-table:visible,#article-requests-pending-table:visible').length )
544                     $('a.ar-process-request').show();
545                 else $('a.ar-process-request').hide();
546
547                 if( $('#article-requests-requested-table').is(":visible") )
548                     $('a.ar-set-pending-request').show();
549                 else $('a.ar-set-pending-request').hide();
550             });
551
552             $('#myModal').on("shown.bs.modal", function () {
553                 $('#myModal textarea').focus();
554             });
555             $('#myModal').on("hidden.bs.modal", function () {
556                 // Set focus back to dropdown
557                 var id = $('#myModal textarea').attr('ar_id');
558                 var link = $('span#url_'+ id).parent().parent().find('td.ar-actions').find('div.dropdown a');
559                 if( link.length > 0 ) link[0].focus();
560             });
561             $( '#myModal button' ).on("click", function () {
562                 SaveURLs( $('#myModal textarea').val() );
563             });
564
565             requested_datatable = $("#article-requests-requested-table").DataTable($.extend(true, {}, dataTablesDefaults, {
566                 "aoColumnDefs": [
567                     { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
568                 ],
569             }));
570
571             pending_datatable = $("#article-requests-pending-table").DataTable($.extend(true, {}, dataTablesDefaults, {
572                 "aoColumnDefs": [
573                     { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
574                 ],
575             }));
576             processing_datatable = $("#article-requests-processing-table").DataTable($.extend(true, {}, dataTablesDefaults, {
577                 "aoColumnDefs": [
578                     { "aTargets": [0, -1], "bSortable": false, "bSearchable": false },
579                 ],
580             }));
581             active_datatable = requested_datatable;
582             activateBatchActions( active_tab );
583             $(".starthidden").show();
584         });
585
586         function activateBatchActions( active_tab ){
587             // Check to see whether batch menu should be shown based on state of checkboxes
588             if ( $( "input:checkbox", active_tab ).length > 0 ) {
589                 // There are rows with checkboxes
590                 $( "[class$='_table_controls']", active_tab ).show();
591                 if ( $( "input:checkbox:checked", active_tab ).length > 0 ) {
592                     $( "[id^='article-menu-']", active_tab ).css("display","inline-block");
593                 } else {
594                     $( "[id^='article-menu-']", active_tab ).hide();
595                 }
596             } else {
597                 // All rows have been removed
598                 $("[class$='_table_controls']", active_tab ).hide();
599             }
600         }
601
602         function HandleMulti( fnHandler, id, a ) {
603             last_cancel_reason = undefined;
604             if( id !== 0 ) { fnHandler( id, a ); return; }
605             $( active_tab + " input[type='checkbox']:checked").each(function() {
606                 fnHandler( $(this).attr('reqid'), $(this).closest('tr').find('td.ar-actions div a') );
607             });
608         }
609
610         function PrintSlip(id, a) {
611             var link = 'article-request-slip.pl?id='+id;
612             window.open(link, 'popup', 'width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top');
613         }
614
615         $('#modal-cancellation-reason').on('change', function(e) {
616             let reason = $(this).val();
617             $('#modal-notes').attr('disabled', !!reason);
618         })
619
620         // Confirm cancellation of article requests
621         let cancel_id;
622         let cancel_a;
623         $("#cancelModalConfirmBtn").on("click",function(e) {
624             let reason = $("#modal-cancellation-reason").val();
625             let notes = $("#modal-notes").val();
626             let query = '?'+(reason?'cancellation_reason='+reason:'notes='+notes)
627
628             HandleMulti(function(id, a) {
629                 var table_row = a.closest('tr');
630                 table_row.find('.ar-process-request').remove();
631                 table_row.find('input[type="checkbox"]').prop('checked', false);
632
633
634                 a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
635
636                 $.ajax({
637                     type: "DELETE",
638                     url: '/api/v1/article_requests/'+id+query,
639                     success: function( data ) {
640                         active_datatable.row( a.closest('tr') ).remove().draw();
641                         UpdateTabCounts();
642                         activateBatchActions( active_tab );
643                     }
644                 });
645             }, cancel_id, cancel_a)
646         });
647
648         function Cancel( id, a ) {
649             cancel_id = id;
650             cancel_a = a;
651
652             $('#cancelModal').modal();
653         }
654
655         function SetPending( id, a ) {
656             var table_row = a.closest('tr');
657             table_row.find('.ar-set-pending-request').remove();
658             table_row.find('input[type="checkbox"]').prop('checked', false);
659             a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
660             $.ajax({
661                 type: "POST",
662                 url: '/cgi-bin/koha/svc/article_request',
663                 data: {
664                     action: 'pending',
665                     id: id,
666                 },
667                 success: function( data ) {
668                     $("img.spinner").remove();
669                     requested_datatable.row( table_row ).remove().draw();
670                     pending_datatable.row.add( table_row ).draw();
671                     UpdateTabCounts();
672                     activateBatchActions( active_tab );
673                 },
674                 dataType: 'json'
675             });
676         }
677
678         function Process( id, a ) {
679             var table_row = a.closest('tr');
680             var table = a.closest('table');
681             var orig_datatable = table.attr('id')==='article-requests-pending-table'?pending_datatable:requested_datatable;
682             table_row.find('.ar-process-request').remove();
683             table_row.find('input[type="checkbox"]').prop('checked', false);
684
685             a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif" class="spinner"/>').find('div.dropdown').hide();
686             $.ajax({
687                 type: "POST",
688                 url: '/cgi-bin/koha/svc/article_request',
689                 data: {
690                     action: 'process',
691                     id: id,
692                 },
693                 success: function( data ) {
694                     $("img.spinner").remove();
695                     orig_datatable.row( table_row ).remove().draw();
696                     processing_datatable.row.add( table_row ).draw();
697                     UpdateTabCounts();
698                     activateBatchActions( active_tab );
699                 },
700                 dataType: 'json'
701             });
702         }
703
704         function Complete( id, a ) {
705             // if it is a scan, check if urls field is filled
706             var urlspan = $('span#url_'+id);
707             if( urlspan.length>0 && urlspan.text() === '' ) {
708                 alert( _("Please fill URL before completing request.") );
709                 return;
710             }
711             a.closest('td').prepend('<img src="[% interface | html %]/[% theme | html %]/img/spinner-small.gif"/>').find('div.dropdown').hide();
712             $.ajax({
713                 type: "POST",
714                 url: '/cgi-bin/koha/svc/article_request',
715                 data: {
716                     action: 'complete',
717                     id: id,
718                 },
719                 success: function( data ) {
720                     active_datatable.row( a.closest('tr') ).remove().draw();
721                     UpdateTabCounts();
722                     activateBatchActions( active_tab );
723                 },
724                 dataType: 'json'
725             });
726         }
727
728         function UpdateTabCounts() {
729             $("#ar_requested_count").html( requested_datatable.rows().count() );
730             $("#ar_pending_count").html( pending_datatable.rows().count() );
731             $("#ar_processing_count").html( processing_datatable.rows().count() );
732         }
733
734         function EditURLs(id) {
735             var urls = $('span#url_'+ id).text();
736             $('#myModal textarea').val(urls);
737             $('#myModal textarea').attr('ar_id', id);
738             $('#myModal').modal('show');
739         }
740
741         function SaveURLs(newurl) {
742             var id = $('#myModal textarea').attr('ar_id');
743             $('span#url_'+ id).text(newurl);
744             if(newurl)
745                 $('span#url_yesno_'+id).text(_("Yes"));
746             else
747                 $('span#url_yesno_'+id).text(_("No"));
748
749             $.ajax({
750                 type: "POST",
751                 url: '/cgi-bin/koha/svc/article_request',
752                 data: { action: 'update_urls', id: id, urls: newurl },
753                 dataType: 'json',
754                 error: function() { alert('Error: Saving URL failed!'); },
755                 success: function(data) { if(!data.success) alert('Saving URL failed!'); },
756             });
757         }
758     </script>
759 [% END %]
760
761 [% INCLUDE 'intranet-bottom.inc' %]