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