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