Bug 27948: (QA follow-up) Correct empty branchcode
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-request-article.tt
1 [% USE Koha %]
2 [% USE Branches %]
3 [% USE ItemTypes %]
4 [% USE KohaNews %]
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 = KohaNews.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 biblio.can_article_request( patron ) %]
37                     <h1>Place article request for [% biblio.title | html %]</h1>
38                     [% IF ( disclaimer && !action) %]
39                         <div class="alert alert-warning">
40                             [% PROCESS koha_news_block news => disclaimer %]
41                             <a href="/cgi-bin/koha/opac-request-article.pl?biblionumber=[% biblio.biblionumber | uri %]&amp;action=accept"
42                             class="btn btn-sm btn-primary"><i class="fa fa-check" aria-hidden="true"></i> Accept</a>
43                         </div>
44                     [% ELSE %]
45                         [% SET article_request_type = biblio.article_request_type( patron ) %]
46
47                         [% IF article_request_type == 'yes' %]       [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFields') %]           [% END %]
48                         [% IF article_request_type == 'bib_only' %]  [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsRecordOnly') %] [% END %]
49                         [% IF article_request_type == 'item_only' %] [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsItemOnly') %]   [% END %]
50
51
52                         <form id="place-article-request" method="post" action="/cgi-bin/koha/opac-request-article.pl">
53                             <legend class="sr-only">Place article request</legend>
54                             <input type="hidden" name="action" value="create" />
55                             <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber | html %]" />
56
57                             <fieldset class="rows">
58                                 <ul>
59                                     <li>
60                                         [% IF mandatory_fields.search('title') %]
61                                             <label for="title" class="required">Title:</label>
62                                             <input type="text" required="required" name="title" id="title" size="50"/>
63                                         [% ELSE %]
64                                             <label for="title">Title:</label>
65                                             <input type="text" name="title" id="title" size="50"/>
66                                         [% END %]
67                                     </li>
68
69                                     <li>
70                                         [% IF mandatory_fields.search('author') %]
71                                             <label for="author" class="required">Author:</label>
72                                             <input type="text" required="required" name="author" id="author" size="50"/>
73                                         [% ELSE %]
74                                             <label for="author">Author:</label>
75                                             <input type="text" name="author" id="author" size="50"/>
76                                         [% END %]
77                                     </li>
78
79                                     <li>
80                                         [% IF mandatory_fields.search('volume') %]
81                                             <label for="volume" class="required">Volume:</label>
82                                             <input type="text" required="required" name="volume" id="volume" size="50"/>
83                                         [% ELSE %]
84                                             <label for="volume">Volume:</label>
85                                             <input type="text" name="volume" id="volume" size="50"/>
86                                         [% END %]
87                                     </li>
88
89                                     <li>
90                                         [% IF mandatory_fields.search('issue') %]
91                                             <label for="issue" class="required">Issue:</label>
92                                             <input type="text" required="required" name="issue" id="issue" size="50"/>
93                                         [% ELSE %]
94                                             <label for="issue">Issue:</label>
95                                             <input type="text" name="issue" id="issue" size="50"/>
96                                         [% END %]
97                                     </li>
98
99                                     <li>
100                                         [% IF mandatory_fields.search('date') %]
101                                             <label for="date" class="required">Date:</label>
102                                             <input type="text" required="required" name="date" id="date" size="50"/>
103                                         [% ELSE %]
104                                             <label for="date">Date:</label>
105                                             <input type="text" name="date" id="date" size="50"/>
106                                         [% END %]
107                                     </li>
108
109                                     <li>
110                                         [% IF mandatory_fields.search('pages') %]
111                                             <label for="pages" class="required">Pages:</label>
112                                             <input type="text" required="required" name="pages" id="pages" size="50"/>
113                                         [% ELSE %]
114                                             <label for="pages">Pages:</label>
115                                             <input type="text" name="pages" id="pages" size="50"/>
116                                         [% END %]
117                                     </li>
118
119                                     <li>
120                                         [% IF mandatory_fields.search('chapters') %]
121                                             <label for="chapters" class="required">Chapters:</label>
122                                             <input type="text" required="required" name="chapters" id="chapters" size="50"/>
123                                         [% ELSE %]
124                                             <label for="chapters">Chapters:</label>
125                                             <input type="text" name="chapters" id="chapters" size="50"/>
126                                         [% END %]
127                                     </li>
128
129                                     <li>
130                                         <label for="patron_notes">Notes:</label>
131                                         <input type="text" name="patron_notes" id="patron_notes" size="50"/>
132                                     </li>
133
134                                     <li>
135                                         <label for="branchcode">Pickup library:</label>
136                                         <select name="branchcode" id="branchcode" required="required">
137                                             [% FOREACH b IN Branches.all %]
138                                                 [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
139                                                     <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
140                                                 [% ELSE %]
141                                                     <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
142                                                 [% END %]
143                                             [% END %]
144                                         </select>
145                                     </li>
146                                 </ul>
147                             </fieldset>
148
149                             [% IF article_request_type != 'bib_only' %]
150                                 <table class="copiesrow table table-bordered table-striped">
151                                     <caption>Select a specific item:</caption>
152                                     <thead>
153                                         <tr>
154                                             <th>&nbsp;</th>
155                                             <th>Item type</th>
156                                             <th>Barcode</th>
157                                             <th>Home library</th>
158                                             <th>Call number</th>
159                                             <th>Enumeration</th>
160                                         </tr>
161                                     </thead>
162
163                                     <tbody>
164                                         [% FOREACH item IN biblio.items %]
165                                             [% IF item.can_article_request( patron ) %]
166                                                 <tr>
167                                                     <td>
168                                                         [% IF article_request_type == 'item_only' && !checked %]
169                                                             [% SET checked = 1 %]
170                                                             <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" checked="checked" />
171                                                         [% ELSE %]
172                                                             <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" />
173                                                         [% END %]
174                                                     </td>
175                                                     <td>
176                                                         [% ItemTypes.GetDescription( item.itype ) | html %]
177                                                     </td>
178                                                     <td>
179                                                         [% item.barcode | html %]
180                                                     </td>
181                                                     <td>
182                                                         [% Branches.GetName( item.homebranch ) | html %]
183                                                     </td>
184                                                     <td>
185                                                         [% item.itemcallnumber | html %]
186                                                     </td>
187                                                     <td>
188                                                         [% item.enumchron | html %]
189                                                     </td>
190                                                 </tr>
191                                             [% END %]
192                                         [% END %]
193
194                                         [% IF article_request_type != 'item_only' %]
195                                             <tr>
196                                                 <td>
197                                                     <input type="radio" name="itemnumber" value="" checked="checked"/>
198                                                 </td>
199                                                 <td colspan="6">
200                                                     Any item
201                                                 </td>
202                                             </tr>
203                                         [% END %]
204                                     </tbody>
205                                 </table>
206                             [% END %]
207
208                             <input type="submit" class="btn btn-primary" value="Place request" />
209                         </form>
210                     [% END %]
211                 [% ELSE %]
212                     <h1 class="title">[% biblio.title | html %]</h1>
213                     <div class="alert alert-info">
214                         No article requests can be made for this record.
215                     </div>
216                 [% END %]
217             </div> <!-- /.col -->
218         </div> <!-- /.row -->
219     </div> <!-- / .container-fluid -->
220 </div> <!-- / .main -->
221
222 [% INCLUDE 'opac-bottom.inc' %]
223
224 [% BLOCK jsinclude %]
225 <script>
226     allow_submit = false;
227     $('#place-article-request').on('submit', function( event ){
228         if ( ! allow_submit ) {
229             event.preventDefault();
230
231             [% IF article_request_type == 'item_only' %]
232                 if ( ! $("input:radio[name='itemnumber']").is(":checked") ) {
233                     alert( _("Please select a specific item for this article request.") );
234                     return 0;
235                 }
236             [% END %]
237
238             var mandatory_fields = "[% mandatory_fields | html %]";
239             var m = new Array();
240             if ( mandatory_fields ) m = mandatory_fields.split(",");
241             var f = new Array();
242
243             for (i = 0; i < m.length; i++) {
244                 if ( ! $("#" + m[i]).val() ) {
245                     f.push( m[i] );
246                 }
247             }
248
249             if ( f.length ) {
250                 alert( _("The following fields are required and not filled in: ") + f.join(", ") );
251                 return 0;
252             }
253
254             allow_submit = true;
255             $('#place-article-request').submit();
256         }
257     });
258 </script>
259 [% END %]