Bug 23625: ArticleRequestsMandatoryFields* only affects field labels, does not make...
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-request-article.tt
1 [% USE Koha %]
2 [% USE Branches %]
3 [% USE ItemTypes %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Request article</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 [% BLOCK cssinclude %][% END %]
8 </head>
9
10 [% INCLUDE 'bodytag.inc' bodyid='opac-request-article' %]
11 [% INCLUDE 'masthead.inc' %]
12
13 <div class="main">
14     <ul class="breadcrumb">
15         <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
16         <li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblio.biblionumber | uri %]">Details for: [% biblio.title | html %]</a> <span class="divider">&rsaquo;</span></li>
17         <li><a href="#">Request article</a></li>
18     </ul>
19
20     <div class="container">
21         [% IF biblio.can_article_request( patron ) %]
22             [% SET article_request_type = biblio.article_request_type( patron ) %]
23
24             [% IF article_request_type == 'yes' %]       [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFields') %]           [% END %]
25             [% IF article_request_type == 'bib_only' %]  [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsRecordOnly') %] [% END %]
26             [% IF article_request_type == 'item_only' %] [% SET mandatory_fields = Koha.Preference('ArticleRequestsMandatoryFieldsItemOnly') %]   [% END %]
27
28             <h3>Place article request for [% biblio.title | html %]</h3>
29
30             <form id="place-article-request" method="post" action="/cgi-bin/koha/opac-request-article.pl">
31                 <input type="hidden" name="action" value="create" />
32                 <input type="hidden" name="biblionumber" id="biblionumber" value="[% biblio.biblionumber | html %]" />
33
34                 <fieldset class="rows">
35                     <ul>
36                         <li>
37                             [% IF mandatory_fields.search('title') %]
38                                 <label for="title" class="required">Title:</label>
39                                 <input type="text" required name="title" id="title" size="50"/>
40                             [% ELSE %]
41                                 <label for="title">Title:</label>
42                                 <input type="text" name="title" id="title" size="50"/>
43                             [% END %]
44                         </li>
45
46                         <li>
47                             [% IF mandatory_fields.search('author') %]
48                                 <label for="author" class="required">Author:</label>
49                                 <input type="text" required name="author" id="author" size="50"/>
50                             [% ELSE %]
51                                 <label for="author">Author:</label>
52                                 <input type="text" name="author" id="author" size="50"/>
53                             [% END %]
54                         </li>
55
56                         <li>
57                             [% IF mandatory_fields.search('volume') %]
58                                 <label for="volume" class="required">Volume:</label>
59                                 <input type="text" required name="volume" id="volume" size="50"/>
60                             [% ELSE %]
61                                 <label for="volume">Volume:</label>
62                                 <input type="text" name="volume" id="volume" size="50"/>
63                             [% END %]
64                         </li>
65
66                         <li>
67                             [% IF mandatory_fields.search('issue') %]
68                                 <label for="issue" class="required">Issue:</label>
69                                 <input type="text" required name="issue" id="issue" size="50"/>
70                             [% ELSE %]
71                                 <label for="issue">Issue:</label>
72                                 <input type="text" name="issue" id="issue" size="50"/>
73                             [% END %]
74                         </li>
75
76                         <li>
77                             [% IF mandatory_fields.search('date') %]
78                                 <label for="date" class="required">Date:</label>
79                                 <input type="text" required name="date" id="date" size="50"/>
80                             [% ELSE %]
81                                 <label for="date">Date:</label>
82                                 <input type="text" name="date" id="date" size="50"/>
83                             [% END %]
84                         </li>
85
86                         <li>
87                             [% IF mandatory_fields.search('pages') %]
88                                 <label for="pages" class="required">Pages:</label>
89                                 <input type="text" required name="pages" id="pages" size="50"/>
90                             [% ELSE %]
91                                 <label for="pages">Pages:</label>
92                                 <input type="text" name="pages" id="pages" size="50"/>
93                             [% END %]
94                         </li>
95
96                         <li>
97                             [% IF mandatory_fields.search('chapters') %]
98                                 <label for="chapters" class="required">Chapters:</label>
99                                 <input type="text" required name="chapters" id="chapters" size="50"/>
100                             [% ELSE %]
101                                 <label for="chapters">Chapters:</label>
102                                 <input type="text" name="chapters" id="chapters" size="50"/>
103                             [% END %]
104                         </li>
105
106                         <li>
107                             <label for="patron_notes">Notes:</label>
108                             <input type="text" name="patron_notes" id="patron_notes" size="50"/>
109                         </li>
110
111                         <li>
112                             <label for="branchcode">Pickup library:</label>
113                             <select name="branchcode" id="branchcode">
114                                 [% FOREACH b IN Branches.all %]required
115                                     [% IF b.branchcode == Branches.GetLoggedInBranchcode %]
116                                         <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
117                                     [% ELSE %]
118                                         <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
119                                     [% END %]
120                                 [% END %]
121                             </select>
122                         </li>
123                     </ul>
124                 </fieldset>
125
126                 [% IF article_request_type != 'bib_only' %]
127                     <table class="copiesrow table table-bordered table-striped">
128                         <caption>Select a specific item:</caption>
129                         <thead>
130                             <tr>
131                                 <th>&nbsp;</th>
132                                 <th>Item type</th>
133                                 <th>Barcode</th>
134                                 <th>Home library</th>
135                                 <th>Call number</th>
136                                 <th>Enumeration</th>
137                             </tr>
138                         </thead>
139
140                         <tbody>
141                             [% FOREACH item IN biblio.items %]
142                                 [% IF item.can_article_request( patron ) %]
143                                     <tr>
144                                         <td>
145                                             [% IF article_request_type == 'item_only' && !checked %]
146                                                 [% SET checked = 1 %]
147                                                 <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" checked="checked" />
148                                             [% ELSE %]
149                                                 <input type="radio" name="itemnumber" value="[% item.itemnumber | html %]" />
150                                             [% END %]
151                                         </td>
152                                         <td>
153                                             [% ItemTypes.GetDescription( item.itype ) | html %]
154                                         </td>
155                                         <td>
156                                             [% item.barcode | html %]
157                                         </td>
158                                         <td>
159                                             [% Branches.GetName( item.homebranch ) | html %]
160                                         </td>
161                                         <td>
162                                             [% item.itemcallnumber | html %]
163                                         </td>
164                                         <td>
165                                             [% item.enumchron | html %]
166                                         </td>
167                                     </tr>
168                                 [% END %]
169                             [% END %]
170
171                             [% IF article_request_type != 'item_only' %]
172                                 <tr>
173                                     <td>
174                                         <input type="radio" name="itemnumber" value="" checked="checked"/>
175                                     </td>
176                                     <td colspan="6">
177                                         Any item
178                                     </td>
179                                 </tr>
180                             [% END %]
181                         </tbody>
182                     </table>
183                 [% END %]
184
185                 <input type="submit" class="btn" value="Place request" />
186             </form>
187         [% ELSE %]
188             <h1 class="title">[% biblio.title | html %]</h1>
189             <div class="alert alert-info">
190                 No article requests can be made for this record.
191             </div>
192         [% END %]
193
194     </div> <!-- / .container -->
195 </div> <!-- / .main -->
196
197 [% INCLUDE 'opac-bottom.inc' %]
198
199 [% BLOCK jsinclude %]
200 <script>
201     allow_submit = false;
202     $('#place-article-request').on('submit', function( event ){
203         if ( ! allow_submit ) {
204             event.preventDefault();
205
206             [% IF article_request_type == 'item_only' %]
207                 if ( ! $("input:radio[name='itemnumber']").is(":checked") ) {
208                     alert( _("Please select a specific item for this article request.") );
209                     return 0;
210                 }
211             [% END %]
212
213             var mandatory_fields = "[% mandatory_fields | html %]";
214             var m = new Array();
215             if ( mandatory_fields ) m = mandatory_fields.split(",");
216             var f = new Array();
217
218             for (i = 0; i < m.length; i++) {
219                 if ( ! $("#" + m[i]).val() ) {
220                     f.push( m[i] );
221                 }
222             }
223
224             if ( f.length ) {
225                 alert( _("The following fields are required and not filled in: ") + f.join(", ") );
226                 return 0;
227             }
228
229             allow_submit = true;
230             $('#place-article-request').submit();
231         }
232     });
233 </script>
234 [% END %]