Bug 11529: Add templates for biblio title display. Unify display.
[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>Koha &rsaquo; Circulation &rsaquo; Request article</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     <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 | uri %]">[% INCLUDE 'biblio-title.inc' %]</a>
25         &rsaquo;
26         Request article
27         [% END %]
28     </div>
29
30 [% INCLUDE 'blocking_errors.inc' %]
31 <div class="main container-fluid">
32     <div class="row">
33         <div class="col-sm-10 col-sm-push-2">
34             <main>
35
36                     <h1>Request article from <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.id | uri %]">[% INCLUDE 'biblio-title.inc' %]</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 | html %]"/></td>
60                                                 <td>[% patron.surname | html %], [% patron.firstname | html %]</td>
61                                                 <td>[% patron.cardnumber | html %]</td>
62                                                 <td>[% patron.categorycode | html %]</td>
63                                                 <td>[% patron.branchcode | html %]</td>
64                                                 <td>[% patron.address | html %]</td>
65                                             </tr>
66                                         [% END %]
67                                     </tbody>
68                                 </table>
69                                 <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
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 | html %]" />
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 | html %]" />
89                                 <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.id | html %]" />
90
91                                 <fieldset class="rows">
92                                     <legend>Place article request from [% biblio.title | html %] for [% patron.firstname | html %] [% patron.surname | html %] ( [% patron.cardnumber | html %] )</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 | html %]" selected="selected">[% b.branchname | html %]</option>
141                                                     [% ELSE %]
142                                                         <option value="[% b.branchcode | html %]">[% b.branchname | html %]</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 | html %]" checked="checked" />
173                                                             [% ELSE %]
174                                                                 <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" />
175                                                             [% END %]
176                                                         </td>
177                                                         <td>
178                                                             [% ItemTypes.GetDescription( item.itype ) | html %]
179                                                         </td>
180                                                         <td>
181                                                             [% item.barcode | html %]
182                                                         </td>
183                                                         <td>
184                                                             [% Branches.GetName( item.homebranch ) | html %]
185                                                         </td>
186                                                         <td>
187                                                             [% item.itemcallnumber | html %]
188                                                         </td>
189                                                         <td>
190                                                             [% item.enumchron | html %]
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 | uri %]">[% ar.borrower.firstname | html %] [% ar.borrower.surname | html %]</a></td>
246                                         <td>[% ar.title | html %]</td>
247                                         <td>[% ar.author | html %]</td>
248                                         <td>[% ar.volume | html %]</td>
249                                         <td>[% ar.issue | html %]</td>
250                                         <td>[% ar.date | html %]</td>
251                                         <td>[% ar.pages | html %]</td>
252                                         <td>[% ar.chapters | html %]</td>
253                                         <td>[% ar.patron_notes | html %]</td>
254                                         <td>
255                                             [% IF ar.item %]
256                                                 <a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% ar.itemnumber | uri %]&biblionumber=[% ar.biblionumber | uri %]">[% ar.item.barcode | html %]</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 | html %]" class="fa fa-cog fa-spin hidden"></i>
272                                             <select name="branchcode" id="branchcode-[% ar.id | html %]" class="ar-update-branchcode">
273                                                 [% FOREACH b IN Branches.all %]
274                                                     [% IF b.branchcode == ar.branchcode %]
275                                                         <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
276                                                     [% ELSE %]
277                                                         <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
278                                                     [% END %]
279                                                 [% END %]
280                                             </select>
281                                         </td>
282                                         <td>
283                                             <a title="Cancel article request" href="#" id="cancel-[% ar.id | html %]" class="ar-cancel-request">
284                                                 <i id="cancel-processing-spinner-[% ar.id | html %]" class="fa fa-cog fa-spin hide"></i>
285                                                 <i id="cancel-processing-[% ar.id | html %]" 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
294             </main>
295         </div> <!-- /.col-sm-10.col-sm-push-2 -->
296
297         <div class="col-sm-2 col-sm-pull-10">
298             <aside>
299                 [% INCLUDE 'biblio-view-menu.inc' %]
300             </aside>
301         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
302      </div> <!-- /.row -->
303
304 [% MACRO jsinclude BLOCK %]
305     [% INCLUDE 'datatables.inc' %]
306
307     <script>
308         $('#current-article-requests').ready(function() {
309             $(".hide").hide();
310         });
311
312         $(document).ready(function() {
313             if ( $( "#patron" ).size() ){
314                 $( "#patron" ).autocomplete({
315                     source: "/cgi-bin/koha/circ/ysearch.pl",
316                     minLength: 3,
317                     select: function( event, ui ) {
318                         $( "#patron" ).val( ui.item.cardnumber );
319                         $( "#holds_patronsearch" ).submit();
320                         return false;
321                     }
322                 })
323                 .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
324                     return $( "<li></li>" )
325                     .data( "ui-autocomplete-item", item )
326                     .append( "<a>" + item.surname + ", " + item.firstname +
327                              " (" + item.cardnumber + ") <small>" + item.address +
328                              " " + item.city + " " + item.zipcode + " " +
329                              item.country + "</small></a>" )
330                     .appendTo( ul );
331                 };
332             }
333
334             $( ".ar-update-branchcode" ).on('focus', function(){
335                 previous_branchcode = this.value;
336             }).on('change', function(){
337                 var branchcode = this.value;
338                 var c = confirm(_("Are you sure you want to change the pickup library from %s to %s for this request?").format( previous_branchcode, branchcode ));
339
340                 if ( c ) {
341                     var id = this.id.split("branchcode-")[1];
342                     $("#update-processing-" + id ).css({opacity: 0, visibility: "visible"}).animate({opacity: 1.0}, 200);
343
344                     $.ajax({
345                         type: "POST",
346                         url: '/cgi-bin/koha/svc/article_request',
347                         data: {
348                             action: 'update_branchcode',
349                             id: id,
350                             branchcode: branchcode,
351                         },
352                         success: function( data ) {
353                             $("#update-processing-" + id ).css({opacity: 1.0, visibility: "visible"}).animate({opacity: 0}, 200);
354                         },
355                         dataType: 'json'
356                     });
357
358                 } else {
359                     this.value = previous_branchcode;
360                 }
361             });
362
363             $(".ar-cancel-request").on("click", function(){
364                 var a = $(this);
365                 var notes = prompt(_("Reason for cancellation:"));
366
367                 if ( notes != null ) {
368                     var id = this.id.split("cancel-")[1];
369                     $("#cancel-processing-" + id ).hide('slow');
370                     $("#cancel-processing-spinner-" + id ).show('slow');
371
372                     $.ajax({
373                         type: "POST",
374                         url: '/cgi-bin/koha/svc/article_request',
375                         data: {
376                             action: 'cancel',
377                             id: id,
378                             notes: notes
379                         },
380                         success: function( data ) {
381                             a.parents('tr').hide('slow');
382                         },
383                         dataType: 'json'
384                     });
385                 }
386             });
387         });
388     </script>
389 [% END %]
390
391 [% INCLUDE 'intranet-bottom.inc' %]