Bug 28955: (follow-up) Set to fall back
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-request-article.tt
1 [% USE Koha %]
2 [% USE Branches %]
3 [% USE ItemTypes %]
4 [% USE AdditionalContents %]
5 [% USE Price %]
6 [% USE raw %]
7 [% INCLUDE 'doc-head-open.inc' %]
8
9 <title>Request article &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 [% BLOCK cssinclude %][% END %]
12 </head>
13
14 [% INCLUDE 'bodytag.inc' bodyid='opac-request-article' %]
15 [% INCLUDE 'masthead.inc' %]
16
17 [% SET disclaimer = AdditionalContents.get( location => "ArticleRequestsDisclaimerText", lang => lang, library => logged_in_user.branchcode || default_branch ) %]
18
19 <div class="main">
20     <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumbs">
21         <ol class="breadcrumb">
22             <li class="breadcrumb-item">
23                 <a href="/cgi-bin/koha/opac-main.pl">Home</a>
24             </li>
25             <li class="breadcrumb-item">
26                 <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | uri %]">Details for: [% biblio.title | html %]</a>
27             </li>
28             <li class="breadcrumb-item active">
29                 <a href="#" aria-current="page">Request article</a>
30             </li>
31         </ol>
32     </nav> <!-- /#breadcrumbs -->
33
34     <div class="container-fluid maincontent">
35         <div class="row">
36             <div class="col">
37                 [% IF error_message %]
38                     <h1 class="title">[% biblio.title | html %]</h1>
39                     <div class="alert alert-info">
40                         [% SWITCH error_message %]
41                             [% CASE 'article_request_limit_reached'       %]You reached your open article requests limit.
42                             [% CASE 'article_request_unhandled_exception' %]An error has occurred.
43                         [% END %]
44                     </div>
45                 [% ELSIF biblio.can_article_request( patron ) %]
46                     <h1>Place article request for [% biblio.title | html %]</h1>
47                     [% IF ( disclaimer && !action) %]
48                         <div class="alert alert-warning">
49                             [% PROCESS koha_news_block news => disclaimer %]
50                             <a href="/cgi-bin/koha/opac-request-article.pl?biblionumber=[% biblio.biblionumber | uri %]&amp;action=accept"
51                             class="btn btn-sm btn-primary"><i class="fa fa-check" aria-hidden="true"></i> Accept</a>
52                         </div>
53                     [% ELSE %]
54                         [% SET article_request_type = biblio.article_request_type( patron ) %]
55
56                         [% IF article_request_type == 'yes' %]       [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFields') %]           [% END %]
57                         [% IF article_request_type == 'bib_only' %]  [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsRecordOnly') %] [% END %]
58                         [% IF article_request_type == 'item_only' %] [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsItemOnly') %]   [% END %]
59
60
61                     [% IF article_request_fee > 0 %]
62                         <div class="alert alert-warning">
63                             You will be charged with <strong>[% article_request_fee | $Price %]</strong> for every request
64                         </div>
65                     [% END %]
66
67                         <form id="place-article-request" method="post" action="/cgi-bin/koha/opac-request-article.pl">
68                             <legend class="sr-only">Place article request</legend>
69                             <input type="hidden" name="action" value="create" />
70                             <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber | html %]" />
71
72                             <fieldset class="rows">
73                                 <ul>
74                                     <li>
75                                         [% IF mandatory_fields.search('title') %]
76                                             <label for="title" class="required">Title:</label>
77                                             <input type="text" required="required" name="title" id="title" size="50" value="[% title | html %]"/>
78                                         [% ELSE %]
79                                             <label for="title">Title:</label>
80                                             <input type="text" name="title" id="title" size="50" value="[% title | html %]"/>
81                                         [% END %]
82                                     </li>
83
84                                     <li>
85                                         [% IF mandatory_fields.search('author') %]
86                                             <label for="author" class="required">Author:</label>
87                                             <input type="text" required="required" name="author" id="author" size="50" value="[% author | html %]"/>
88                                         [% ELSE %]
89                                             <label for="author">Author:</label>
90                                             <input type="text" name="author" id="author" size="50" value="[% author | html %]"/>
91                                         [% END %]
92                                     </li>
93
94                                     <li>
95                                         [% IF mandatory_fields.search('volume') %]
96                                             <label for="volume" class="required">Volume:</label>
97                                             <input type="text" required="required" name="volume" id="volume" size="50"/>
98                                         [% ELSE %]
99                                             <label for="volume">Volume:</label>
100                                             <input type="text" name="volume" id="volume" size="50"/>
101                                         [% END %]
102                                     </li>
103
104                                     <li>
105                                         [% IF mandatory_fields.search('issue') %]
106                                             <label for="issue" class="required">Issue:</label>
107                                             <input type="text" required="required" name="issue" id="issue" size="50"/>
108                                         [% ELSE %]
109                                             <label for="issue">Issue:</label>
110                                             <input type="text" name="issue" id="issue" size="50"/>
111                                         [% END %]
112                                     </li>
113
114                                     <li>
115                                         [% IF mandatory_fields.search('date') %]
116                                             <label for="date" class="required">Date:</label>
117                                             <input type="text" required="required" name="date" id="date" size="50"/>
118                                         [% ELSE %]
119                                             <label for="date">Date:</label>
120                                             <input type="text" name="date" id="date" size="50"/>
121                                         [% END %]
122                                     </li>
123
124                                     <li>
125                                         <label for="toc_request">Table of contents:</label>
126                                         <input type="checkbox" name="toc_request" value="1"/>
127                                     </li>
128
129                                     <li>
130                                         [% IF mandatory_fields.search('pages') %]
131                                             <label for="pages" class="required">Pages:</label>
132                                             <input type="text" required="required" name="pages" id="pages" size="50" value="[% pageinfo | html %]"/>
133                                         [% ELSE %]
134                                             <label for="pages">Pages:</label>
135                                             <input type="text" name="pages" id="pages" size="50" value="[% pageinfo | html %]"/>
136                                         [% END %]
137                                     </li>
138
139                                     <li>
140                                         [% IF mandatory_fields.search('chapters') %]
141                                             <label for="chapters" class="required">Chapters:</label>
142                                             <input type="text" required="required" name="chapters" id="chapters" size="50"/>
143                                         [% ELSE %]
144                                             <label for="chapters">Chapters:</label>
145                                             <input type="text" name="chapters" id="chapters" size="50"/>
146                                         [% END %]
147                                     </li>
148
149                                     <li>
150                                         <label for="patron_notes">Notes:</label>
151                                         <input type="text" name="patron_notes" id="patron_notes" size="50"/>
152                                     </li>
153
154                                     <li>
155                                         <label for="format">Format:</label>
156                                         <select name="format" id="format">
157                                             <option value="PHOTOCOPY">Photocopy</option>
158                                             <option value="SCAN">Digital scan</option>
159                                         </select>
160                                     </li>
161
162                                     <li>
163                                         <label for="branchcode">Pickup library:</label>
164                                         <select name="branchcode" id="branchcode" required="required">
165                                             [% FOREACH b IN Branches.all %]
166                                                 [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
167                                                     <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
168                                                 [% ELSE %]
169                                                     <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
170                                                 [% END %]
171                                             [% END %]
172                                         </select>
173                                     </li>
174                                 </ul>
175                             </fieldset>
176
177                             [% IF article_request_type != 'bib_only' %]
178                                 <table class="copiesrow table table-bordered table-striped">
179                                     <caption>Select a specific item:</caption>
180                                     <thead>
181                                         <tr>
182                                             <th>&nbsp;</th>
183                                             <th>Item type</th>
184                                             <th>Barcode</th>
185                                             <th>Home library</th>
186                                             <th>Call number</th>
187                                             <th>Enumeration</th>
188                                         </tr>
189                                     </thead>
190
191                                     <tbody>
192                                         [% FOREACH item IN biblio.items %]
193                                             [% IF item.can_article_request( patron ) %]
194                                                 <tr>
195                                                     <td>
196                                                         [% IF article_request_type == 'item_only' && !checked %]
197                                                             [% SET checked = 1 %]
198                                                             <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" checked="checked" />
199                                                         [% ELSE %]
200                                                             <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" />
201                                                         [% END %]
202                                                     </td>
203                                                     <td>
204                                                         [% ItemTypes.GetDescription( item.itype ) | html %]
205                                                     </td>
206                                                     <td>
207                                                         [% item.barcode | html %]
208                                                     </td>
209                                                     <td>
210                                                         [% Branches.GetName( item.homebranch ) | html %]
211                                                     </td>
212                                                     <td>
213                                                         [% item.itemcallnumber | html %]
214                                                     </td>
215                                                     <td>
216                                                         [% item.enumchron | html %]
217                                                     </td>
218                                                 </tr>
219                                             [% END %]
220                                         [% END %]
221
222                                         [% IF article_request_type != 'item_only' %]
223                                             <tr>
224                                                 <td>
225                                                     <input type="radio" name="itemnumber" value="" checked="checked"/>
226                                                 </td>
227                                                 <td colspan="6">
228                                                     Any item
229                                                 </td>
230                                             </tr>
231                                         [% END %]
232                                     </tbody>
233                                 </table>
234                             [% END %]
235
236                             <input type="submit" class="btn btn-primary" value="Place request" />
237                         </form>
238                     [% END %]
239                 [% ELSE %]
240                     <h1 class="title">[% biblio.title | html %]</h1>
241                     <div class="alert alert-info">
242                         No article requests can be made for this record.
243                     </div>
244                 [% END %]
245             </div> <!-- /.col -->
246         </div> <!-- /.row -->
247     </div> <!-- / .container-fluid -->
248 </div> <!-- / .main -->
249
250 [% INCLUDE 'opac-bottom.inc' %]
251
252 [% BLOCK jsinclude %]
253 <script>
254 $(document).ready( function() {
255     allow_submit = false;
256     $('#place-article-request').on('submit', function( event ){
257         if ( ! allow_submit ) {
258             event.preventDefault();
259
260             [% IF article_request_type == 'item_only' %]
261                 if ( ! $("input:radio[name='itemnumber']").is(":checked") ) {
262                     alert( _("Please select a specific item for this article request.") );
263                     return 0;
264                 }
265             [% END %]
266
267             var mandatory_fields = "[% mandatory_fields | html %]";
268             var m = new Array();
269             if ( mandatory_fields ) m = mandatory_fields.split(",");
270             var f = new Array();
271
272             for (i = 0; i < m.length; i++) {
273                 if ( ! $("#" + m[i]).val() ) {
274                     f.push( m[i] );
275                 }
276             }
277
278             if ( f.length ) {
279                 alert( _("The following fields are required and not filled in: ") + f.join(", ") );
280                 return 0;
281             }
282
283             // Check if all fields are blank
284             if( m.length == 0 && $('#title').val()=='' && $('#author').val()=='' && $('#volume').val()=='' && $('#issue').val()=='' && $('#date').val()=='' && $('#pages').val()=='' && $('#chapters').val()=='' && $('#patron_notes').val()=='' && !$('input[name="toc_request"]').prop('checked') ) {
285                 alert( _("Please fill in at least one field.") );
286                 return 0;
287             }
288
289             allow_submit = true;
290             $('#place-article-request').submit();
291         }
292     });
293
294     // Initialize format(s)
295     var supported_formats = "[% Koha.Preference('ArticleRequestsSupportedFormats') | $raw %]";
296     if( !supported_formats.match(/PHOTOCOPY/) )
297         $('#format option[value="PHOTOCOPY"]').remove();
298     if( !supported_formats.match(/SCAN/) )
299         $('#format option[value="SCAN"]').remove();
300
301     if( $('#format option').length > 1 ) {
302         // Select first listed format
303         var first_format = supported_formats.split('|')[0].replace(/^\s*|\s*$/g, '');
304         $('#format option[value="'+first_format+'"]').attr('selected', true);
305     }
306 });
307 </script>
308 [% END %]