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