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