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