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