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