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