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