Bug 12904: Force browser to load new javascript files after upgrade
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / circ / request-article.tt
1 [% USE KohaDates %]
2 [% USE Branches %]
3 [% USE ItemTypes %]
4 [% SET footerjs = 1 %]
5 [% SET article_requests_view = 1 %]
6 [% SET biblionumber = biblio.biblionumber %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Circulation &rsaquo; Request article</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables_[% KOHA_VERSION %].css" />
11 </head>
12
13 <body id="circ_request-article" class="circ">
14     [% INCLUDE 'header.inc' %]
15     [% INCLUDE 'circ-search.inc' %]
16
17     <div id="breadcrumbs">
18         <a href="/cgi-bin/koha/mainpage.pl">Home</a>
19         &rsaquo;
20         <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
21         &rsaquo;
22         <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]">[% biblio.title | html %]</a>
23         &rsaquo;
24         Request article
25     </div>
26
27     <div id="doc3" class="yui-t2">
28         <div id="bd">
29             <div id="yui-main">
30                 <div class="yui-b">
31
32                     <h1>Request article from <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.id %]">[% biblio.title | html %]</a></h1>
33                     [% IF no_patrons_found %]
34                         <div class="dialog alert">
35                             <h3>Patron not found</h3>
36                             <p>No patron with this name, please, try another</p>
37                         </div>
38                     [% ELSIF patrons %]
39                         <form id="article_request_patron_results" method="post">
40                             <fieldset>
41                                 <table id="table_borrowers">
42                                     <thead>
43                                         <tr>
44                                             <th></th>
45                                             <th>Name</th>
46                                             <th>Cardnumber</th>
47                                             <th>Category</th>
48                                             <th>Library</th>
49                                             <th>Address</th>
50                                         </tr>
51                                     </thead>
52                                     <tbody>
53                                         [% FOREACH patron IN patrons %]
54                                             <tr>
55                                                 <td><input type="radio" name="patron_id" value="[% patron.borrowernumber %]"/></td>
56                                                 <td>[% patron.surname %], [% patron.firstname %]</td>
57                                                 <td>[% patron.cardnumber %]</td>
58                                                 <td>[% patron.categorycode %]</td>
59                                                 <td>[% patron.branchcode %]</td>
60                                                 <td>[% patron.address %]</td>
61                                             </tr>
62                                         [% END %]
63                                     </tbody>
64                                 </table>
65                                 <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
66                                 <fieldset class="action"><input type="submit" value="Select" /></fieldset>
67                             </fieldset>
68                         </form>
69                     [% ELSIF !patron %]
70                         <form id="article_requests_patronsearch" action="request-article.pl" method="post">
71                             <fieldset class="brief">
72                                 <label for="patron">Patron: </label>
73                                 <div class="hint">Enter patron card number or partial name:</div>
74                                 <input type="text" size="40" id="patron" class="focus" name="patron_cardnumber" />
75                                 <input type="submit" value="Search" />
76                                 <input type="hidden" name="biblionumber" value="[% biblio.id %]" />
77                             </fieldset>
78                         </form>
79                     [% ELSE %]
80                         [% IF biblio.can_article_request( patron ) %]
81
82                             <form id="place-article-request" method="post" action="/cgi-bin/koha/circ/request-article.pl">
83                                 <input type="hidden" name="action" value="create" />
84                                 <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber %]" />
85                                 <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.id %]" />
86
87                                 <fieldset class="rows">
88                                     <legend>Place article request from [% biblio.title %] for [% patron.firstname %] [% patron.surname %] ( [% patron.cardnumber %] )</legend>
89                                     <p/>
90                                     <ul>
91                                         <li>
92                                             <label for="title">Title:</label>
93                                             <input type="text" name="title" id="title" size="50"/>
94                                         </li>
95
96                                         <li>
97                                             <label for="author">Author:</label>
98                                             <input type="text" name="author" id="author" size="50"/>
99                                         </li>
100
101                                         <li>
102                                             <label for="volume">Volume:</label>
103                                             <input type="text" name="volume" id="volume" size="50"/>
104                                         </li>
105
106                                         <li>
107                                             <label for="issue">Issue:</label>
108                                             <input type="text" name="issue" id="issue" size="50"/>
109                                         </li>
110
111                                         <li>
112                                             <label for="date">Date:</label>
113                                             <input type="text" name="date" id="date" size="50"/>
114                                         </li>
115
116                                         <li>
117                                             <label for="pages">Pages:</label>
118                                             <input type="text" name="pages" id="pages" size="50"/>
119                                         </li>
120
121                                         <li>
122                                             <label for="chapters">Chapters:</label>
123                                             <input type="text" name="chapters" id="chapters" size="50"/>
124                                         </li>
125
126                                         <li>
127                                             <label for="patron_notes">Patron notes:</label>
128                                             <input type="text" name="patron_notes" id="patron_notes" size="50"/>
129                                         </li>
130
131                                         <li>
132                                             <label for="branchcode">Pickup library:</label>
133                                             <select name="branchcode" id="branchcode">
134                                                 [% FOREACH b IN Branches.all %]
135                                                     [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
136                                                         <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
137                                                     [% ELSE %]
138                                                         <option value="[% b.branchcode %]">[% b.branchname %]</option>
139                                                     [% END %]
140                                                 [% END %]
141                                             </select>
142                                         </li>
143                                     </ul>
144                                 </fieldset>
145
146                                 [% SET article_request_type = biblio.article_request_type( patron ) %]
147                                 [% IF article_request_type != 'bib_only' %]
148                                     <table id="current-requests-table" class="ar-table table table-bordered table-striped">
149                                         <caption>Select item:</caption>
150                                         <thead>
151                                             <tr>
152                                                 <th>&nbsp;</th>
153                                                 <th>Item type</th>
154                                                 <th>Barcode</th>
155                                                 <th>Home library</th>
156                                                 <th>Call number</th>
157                                                 <th>Enumeration</th>
158                                             </tr>
159                                         </thead>
160
161                                         <tbody>
162                                             [% FOREACH item IN biblio.items %]
163                                                 [% IF item.can_article_request( patron ) %]
164                                                     <tr>
165                                                         <td>
166                                                             [% IF article_request_type == 'item_only' && !checked %]
167                                                                 [% SET checked = 1 %]
168                                                                 <input type="radio" name="itemnumber" value="[% item.itemnumber %]" checked="checked" />
169                                                             [% ELSE %]
170                                                                 <input type="radio" name="itemnumber" value="[% item.itemnumber %]" />
171                                                             [% END %]
172                                                         </td>
173                                                         <td>
174                                                             [% ItemTypes.GetDescription( item.itype ) %]
175                                                         </td>
176                                                         <td>
177                                                             [% item.barcode %]
178                                                         </td>
179                                                         <td>
180                                                             [% Branches.GetName( item.homebranch ) %]
181                                                         </td>
182                                                         <td>
183                                                             [% item.itemcallnumber %]
184                                                         </td>
185                                                         <td>
186                                                             [% item.enumchron %]
187                                                         </td>
188                                                     </tr>
189                                                 [% END %]
190                                             [% END %]
191
192                                             [% IF article_request_type != 'item_only' %]
193                                                 <tr>
194                                                     <td>
195                                                         <input type="radio" name="itemnumber" value="" checked="checked"/>
196                                                     </td>
197                                                     <td colspan="5">
198                                                         Any item
199                                                     </td>
200                                                 </tr>
201                                             [% END %]
202                                         </tbody>
203                                     </table>
204                                 [% END %]
205
206                                 <p>
207                                     <input type="submit" class="btn btn-default" value="Place request" />
208                                 </p>
209                             </form>
210                         [% ELSE %]
211                             No article requests can be made for this record.
212                         [% END %]
213
214                     [% END %]
215
216                     [% IF biblio.article_requests_current && !patron %]
217                         <fieldset class="rows left" id="current-article-requests-fieldset">
218                             <legend>Current article requests</legend>
219
220                             <table id="current-article-requests-table">
221                                 <tr>
222                                     <th>Placed on</th>
223                                     <th>Patron</th>
224                                     <th>Title</th>
225                                     <th>Author</th>
226                                     <th>Volume</th>
227                                     <th>Issue</th>
228                                     <th>Date</th>
229                                     <th>Pages</th>
230                                     <th>Chapters</th>
231                                     <th>Patron notes</th>
232                                     <th>Item</th>
233                                     <th>Status</th>
234                                     <th>Pickup library</th>
235                                     <th>&nbsp;</th>
236                                 </tr>
237
238                                 [% FOREACH ar IN biblio.article_requests_current %]
239                                     <tr>
240                                         <td>[% ar.created_on | $KohaDates %]</td>
241                                         <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% ar.borrowernumber %]">[% ar.borrower.firstname %] [% ar.borrower.surname %]</a></td>
242                                         <td>[% ar.title %]</td>
243                                         <td>[% ar.author %]</td>
244                                         <td>[% ar.volume %]</td>
245                                         <td>[% ar.issue %]</td>
246                                         <td>[% ar.date %]</td>
247                                         <td>[% ar.pages %]</td>
248                                         <td>[% ar.chapters %]</td>
249                                         <td>[% ar.patron_notes %]</td>
250                                         <td>
251                                             [% IF ar.item %]
252                                                 <a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% ar.itemnumber %]&biblionumber=[% ar.biblionumber %]">[% ar.item.barcode %]</a>
253                                             [% END %]
254                                         </td>
255                                         <td>
256                                             [% IF ar.status == 'PENDING' %]
257                                                 Pending
258                                             [% ELSIF ar.status == 'PROCESSING' %]
259                                                 Processing
260                                             [% ELSIF ar.status == 'COMPLETED' %]
261                                                 Completed
262                                             [% ELSIF ar.status == 'CANCELED' %]
263                                                 Canceled
264                                             [% END %]
265                                         </td>
266                                         <td>
267                                             <i id="update-processing-[% ar.id %]" class="fa fa-cog fa-spin hidden"></i>
268                                             <select name="branchcode" id="branchcode-[% ar.id %]" class="ar-update-branchcode">
269                                                 [% FOREACH b IN Branches.all %]
270                                                     [% IF b.branchcode == ar.branchcode %]
271                                                         <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
272                                                     [% ELSE %]
273                                                         <option value="[% b.branchcode %]">[% b.branchname %]</option>
274                                                     [% END %]
275                                                 [% END %]
276                                             </select>
277                                         </td>
278                                         <td>
279                                             <a title="Cancel article request" href="#" id="cancel-[% ar.id %]" class="ar-cancel-request">
280                                                 <i id="cancel-processing-spinner-[% ar.id %]" class="fa fa-cog fa-spin hide"></i>
281                                                 <i id="cancel-processing-[% ar.id %]" class="fa fa-times fa-lg" style="color:red"></i>
282                                             </a>
283                                         </td>
284                                     </tr>
285                                 [% END %]
286                             </table>
287                         </fieldset>
288                     [% END %]
289                 </div>
290             </div>
291
292             <div class="yui-b">
293                 [% INCLUDE 'biblio-view-menu.inc' %]
294             </div>
295         </div>
296     </div>
297
298 [% MACRO jsinclude BLOCK %]
299     [% INCLUDE 'datatables.inc' %]
300
301     <script type="text/javascript">
302         $('#current-article-requests').ready(function() {
303             $(".hide").hide();
304         });
305
306         $(document).ready(function() {
307             $( "#patron" ).autocomplete({
308                 source: "/cgi-bin/koha/circ/ysearch.pl",
309                 minLength: 3,
310                 select: function( event, ui ) {
311                     $( "#patron" ).val( ui.item.cardnumber );
312                     $( "#holds_patronsearch" ).submit();
313                     return false;
314                 }
315             })
316             .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
317                 return $( "<li></li>" )
318                 .data( "ui-autocomplete-item", item )
319                 .append( "<a>" + item.surname + ", " + item.firstname +
320                          " (" + item.cardnumber + ") <small>" + item.address +
321                          " " + item.city + " " + item.zipcode + " " +
322                          item.country + "</small></a>" )
323                 .appendTo( ul );
324             };
325
326             $( ".ar-update-branchcode" ).on('focus', function(){
327                 previous_branchcode = this.value;
328             }).on('change', function(){
329                 var branchcode = this.value;
330                 var c = confirm(_("Are you sure you want to change the pickup library from %s to %s for this request?").format( previous_branchcode, branchcode ));
331
332                 if ( c ) {
333                     var id = this.id.split("branchcode-")[1];
334                     $("#update-processing-" + id ).css({opacity: 0, visibility: "visible"}).animate({opacity: 1.0}, 200);
335
336                     $.ajax({
337                         type: "POST",
338                         url: '/cgi-bin/koha/svc/article_request',
339                         data: {
340                             action: 'update_branchcode',
341                             id: id,
342                             branchcode: branchcode,
343                         },
344                         success: function( data ) {
345                             $("#update-processing-" + id ).css({opacity: 1.0, visibility: "visible"}).animate({opacity: 0}, 200);
346                         },
347                         dataType: 'json'
348                     });
349
350                 } else {
351                     this.value = previous_branchcode;
352                 }
353             });
354
355             $(".ar-cancel-request").on("click", function(){
356                 var a = $(this);
357                 var notes = prompt(_("Reason for cancellation:"));
358
359                 if ( notes != null ) {
360                     var id = this.id.split("cancel-")[1];
361                     $("#cancel-processing-" + id ).hide('slow');
362                     $("#cancel-processing-spinner-" + id ).show('slow');
363
364                     $.ajax({
365                         type: "POST",
366                         url: '/cgi-bin/koha/svc/article_request',
367                         data: {
368                             action: 'cancel',
369                             id: id,
370                             notes: notes
371                         },
372                         success: function( data ) {
373                             a.parents('tr').hide('slow');
374                         },
375                         dataType: 'json'
376                     });
377                 }
378             });
379         });
380     </script>
381 [% END %]
382
383 [% INCLUDE 'intranet-bottom.inc' %]