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