Bug 19754: Move template JavaScript to the footer: Acquisitions, part 2
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / orderreceive.tt
1 [% USE KohaDates %]
2 [% USE Branches %]
3 [% USE Price %]
4 [% SET footerjs = 1 %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha &rsaquo; Acquisitions &rsaquo; Receipt summary for : [% name %] [% IF ( invoice ) %]invoice, [% invoice %][% END %]</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 </head>
9
10 <body id="acq_orderreceive" class="acq">
11 [% INCLUDE 'header.inc' %]
12 [% INCLUDE 'acquisitions-search.inc' %]
13
14 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% name %]</a> &rsaquo; Receive items from : [% name %] [% IF ( invoice ) %][[% invoice |html %]][% END %] (order #[% ordernumber %])</div>
15
16 <div id="doc3" class="yui-t2">
17    
18    <div id="bd">
19         <div id="yui-main">
20         <div class="yui-b">
21
22 <h1>Receive items from : [% name %] [% IF ( invoice ) %][[% invoice |html %]] [% END %] (order #[% ordernumber %])</h1>
23
24 [% IF ( count ) %]
25     <form action="/cgi-bin/koha/acqui/finishreceive.pl" method="post" onsubmit="return Check(this);">
26 <div class="yui-g">
27 <div class="yui-u first">
28     <div class="error" style="display:none"></div>
29
30     <fieldset class="rows">
31     <legend>Catalog details</legend>
32     <ol><li><span class="label">Title: </span><span class="title">[% title |html %]</span></li>
33     <li> <span class="label">Author: </span>
34         [% author %]</li>
35     <li><span class="label">Copyright: </span>
36         [% copyrightdate %]</li>
37     <li> <span class="label">ISBN: </span>
38         [% isbn %]</li>
39     <li> <span class="label">Series: </span>
40         [% seriestitle %]</li>
41     </ol>
42         </fieldset>
43
44     [% IF ( suggestionid ) %]
45         <fieldset class="rows">
46         <legend>Suggestion</legend>
47         <ol>
48           <li>
49             <span class="label">Suggested by: </span>
50             [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]&amp;op=show">suggestion #[% suggestionid %]</a>)
51           </li>
52         </ol>
53         </fieldset>
54     [% END %]
55
56     [% IF (AcqCreateItemReceiving) %]
57         <div id="items_list" style="display:none">
58             <p><b>Items list</b></p>
59             <div style="width:100%;overflow:auto;">
60                 <table>
61                     <thead>
62                         <tr>
63                             <th>&nbsp;</th>
64                             <th>&nbsp;</th>
65                             <th>Barcode</th>
66                             <th>Home library</th>
67                             <th>Holding library</th>
68                             <th>Not for loan</th>
69                             <th>Restricted</th>
70                             <th>Location</th>
71                             <th>Call number</th>
72                             <th>Copy number</th>
73                             <th>Inventory number</th>
74                             <th>Collection code</th>
75                             <th>Item type</th>
76                             <th>Materials</th>
77                             <th>Notes</th>
78                         </tr>
79                     </thead>
80                     <tbody>
81                     </tbody>
82                 </table>
83             </div>
84         </div>
85
86         [% UNLESS subscriptionid %]
87           <fieldset class="rows" id="itemfieldset">
88               <legend>Item</legend>
89               [% IF ( NoACQframework ) %]
90                   <p class="required">
91                       No ACQ framework, using default. You should create a
92                       framework with code ACQ, the items framework would be
93                       used
94                   </p>
95               [% END %]
96               <div id="outeritemblock"></div>
97           </fieldset>
98         [% END %]
99     [% ELSIF (AcqCreateItem == 'ordering') %]
100         [% IF (items.size) %]
101             <h5>Items</h5>
102             <div style="width:100%;overflow:auto">
103                 <table>
104                     <thead>
105                         <tr>
106                             <th>Receive?</th>
107                             <th>&nbsp;</th>
108                             <th>Barcode</th>
109                             <th>Home branch</th>
110                             <th>Holding branch</th>
111                             <th>Not for loan</th>
112                             <th>Restricted</th>
113                             <th>Location</th>
114                             <th>Call number</th>
115                             <th>Copy number</th>
116                             <th>Inventory number</th>
117                             <th>Collection code</th>
118                             <th>Item type</th>
119                             <th>Materials</th>
120                             <th>Notes</th>
121                         </tr>
122                     </thead>
123                     <tbody>
124                         [% FOREACH item IN items %]
125                             <tr id="item_[% item.itemnumber %]">
126                                 <td style="text-align:center"><input type="checkbox" name="items_to_receive" value="[% item.itemnumber %]" /></td>
127                                 <td><a style="cursor:pointer" onclick="PopupEditPage([% item.biblionumber %],[% item.itemnumber %]);">Edit</a></td>
128                                 <td>[% item.barcode %]</td>
129                                 <td>[% Branches.GetName( item.homebranch )%]</td>
130                                 <td>[% Branches.GetName( item.holdingbranch ) %]</td>
131                                 <td>[% item.notforloan %]</td>
132                                 <td>[% item.restricted %]</td>
133                                 <td>[% item.location %]</td>
134                                 <td>[% item.itemcallnumber %]</td>
135                                 <td>[% item.copynumber %]</td>
136                                 <td>[% item.stocknumber %]</td>
137                                 <td>[% item.collection %]</td>
138                                 <td>[% item.itemtype %]</td>
139                                 <td>[% item.materials %]</td>
140                                 <td>[% item.itemnotes %]</td>
141                             </tr>
142                         [% END %]
143                     </tbody>
144                 </table>
145             </div>
146         [% END %]
147     [% END %]
148     <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
149     <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
150     <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
151     <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
152         </div>
153         <div class="yui-u">
154     <fieldset class="rows">
155     <legend>Accounting details</legend>
156         <ol>
157             <li>
158                 <label for="datereceived">Date received: </label>
159                 <input type="text" size="10" id="datereceived" name="datereceived" value="[% datereceived | $KohaDates %]" class="datepicker" />
160             </li>
161        <li><label for="bookfund">Fund: </label><select id="bookfund" name="bookfund">
162             <option value="">Keep current ([% budget_period_description %] - [% bookfund %])</option>
163             [% FOREACH period IN budget_loop %]
164                 <optgroup label="[% period.description %]">
165                 [% FOREACH fund IN period.funds %]
166                     [% IF ( fund.b_sel ) %]
167                         <option value="[% fund.b_id %]" selected="selected">[% fund.b_txt %]</option>
168                     [% ELSE %]
169                         <option value="[% fund.b_id %]">[% fund.b_txt %]</option>
170                     [% END %]
171                 [% END %]
172             [% END %]
173        </select></li>
174        <li><label>&nbsp;</label><span>(Current: [% budget_period_description %] - [% bookfund %])</span></li>
175        <li><label for="creator">Created by: </label><span> [% IF ( memberfirstname and membersurname ) %][% IF ( memberfirstname ) %][% memberfirstname %][% END %] [% membersurname %][% ELSE %]No name[% END %]</span></li>
176        <li><label for="quantity_to_receive">Quantity to receive: </label><span class="label">
177            [% IF ( edit and not subscriptionid) %]
178                <input type="text" id="quantity_to_receive" name="quantity" value="[% quantity %]" />
179            [% ELSE%]
180                <input type="text" readonly="readonly" id="quantity_to_receive" name="quantity" value="[% quantity %]" />
181            [% END %]
182            </span></li>
183         <li><label for="quantity">Quantity received: </label>
184           [% IF (AcqCreateItemReceiving) %]
185             [% IF ( subscriptionid ) %]
186               <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="1" />
187             [% ELSE %]
188               <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="0" />
189             [% END %]
190           [% ELSE %]
191             [% IF ( quantityreceived ) %]
192                 [% IF ( edit ) %]
193                     <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceived %]" />
194                     <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% quantityreceived %]" />
195                 [% ELSE %]
196                     [% IF ( items ) %]
197                         <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceivedplus1 %]" />
198                     [% ELSE %]
199                         <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceivedplus1 %]" />
200                     [% END %]
201                     <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% quantityreceived %]" />
202                 [% END %]
203             [% ELSE %]
204                 [% IF ( subscriptionid ) %]
205                     <input type="text" readonly="readonly" id="quantity" size="20" name="quantityrec" value="1" />
206                 [% ELSE %]
207                     <input type="text" id="quantity" size="20" name="quantityrec" value="1" />
208                 [% END %]
209                 <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="0" />
210             [% END %]
211             <div id="qtyrecerror" style="display:none">
212                 <p class="error">Warning, you have entered more items than expected.
213                 Items will not be created.</p>
214             </div>
215           [% END %][%# IF (AcqCreateItemReceiving) %]
216                 </li>
217
218         [% IF ( gst_values ) %]
219             <li>
220                 <label for="tax_rate">Tax rate: </label>
221                 <select name="tax_rate" id="tax_rate">
222                 [% FOREACH gst IN gst_values %]
223                     [% IF gst.option == tax_rate %]
224                         <option value="[% gst.option %]" selected="selected">[% gst.option * 100 %]%</option>
225                     [% ELSE %]
226                         <option value="[% gst.option %]">[% gst.option * 100 %]%</option>
227                     [% END %]
228                 [% END %]
229                 </select>
230             </li>
231         [% ELSE %]
232             <input type="hidden" name="tax_rate" value="0" />
233         [% END %]
234
235         <li><label for="rrp">Replacement cost: </label>[% rrp | $Price %]</li>
236         <li><label for="ecost">Budgeted cost: </label>[% ecost | $Price %]</li>
237         <li>
238             <label for="unitprice">Actual cost:</label>
239             <input type="text" size="20" name="unitprice" id="unitprice" value="[% unitprice | $Price %]" />
240         </li>
241         <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote %]</textarea></li>
242         [% IF order_vendornote %]
243             <li><label for="order_vendornote">Vendor note: </label><span>[% order_vendornote %]</span></li>
244         [% END %]
245         </ol>
246     </fieldset>
247
248 </div>
249 </div><div class="yui-g"><fieldset class="action">
250         <input type="submit"  value="Save" class="button" accesskey="w" />
251         <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]&sticky_filters=1">Cancel</a>
252 </fieldset></div>    </form>
253 [% ELSE %]
254     This ordernumber does not exist.
255 [% END %]
256
257 </div>
258 </div>
259 <div class="yui-b">
260 [% INCLUDE 'acquisitions-menu.inc' %]
261 </div>
262 </div>
263
264 [% MACRO jsinclude BLOCK %]
265     <script type="text/javascript" src="[% interface %]/[% theme %]/js/acquisitions-menu_[% KOHA_VERSION %].js"></script>
266 [% INCLUDE 'calendar.inc' %]
267     [% INCLUDE 'additem.js.inc' %]
268     <script type="text/javascript" src="[% interface %]/[% theme %]/js/additem_[% KOHA_VERSION %].js"></script>
269     <script type="text/javascript" src="[% interface %]/[% theme %]/js/cataloging_[% KOHA_VERSION %].js"></script>
270     <script type="text/javascript" src="[% interface %]/[% theme %]/js/prevent_submit_[% KOHA_VERSION %].js"></script>
271     <script type="text/javascript">
272         function Check(form) {
273             [% IF (AcqCreateItemReceiving) %]
274                 var total_errors = CheckMandatorySubfields(form);
275                 if (total_errors != 0) {
276                     var alertString = _("Form not submitted because of the following problem(s)");
277                     alertString += "\n------------------------------------------------------------------------------------\n";
278                     alertString += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_errors);
279                     alert(alertString);
280                     return false;
281                 }
282
283                 if(check_additem('[% UniqueItemFields %]') == false){
284                     alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
285                     return false;
286                 };
287
288                 // Remove last itemblock if it is not in items_list
289                 var lastitemblock = $("#outeritemblock > div:last");
290                 var tobedeleted = true;
291                 var listitems = $("#items_list tr");
292                 $(listitems).each(function(){
293                     if($(this).attr('idblock') == $(lastitemblock).attr('id')){
294                         tobedeleted = false;
295                     }
296                 });
297                 if(tobedeleted){
298                     $(lastitemblock).remove();
299                 }
300
301                 if(check_additem('[% UniqueItemFields %]') == false){
302                     alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
303                     if(tobedeleted) {
304                         $(lastitemblock).appendTo("#outeritemblock");
305                     }
306                     return false;
307                 };
308             [% END %]
309
310             return true;
311         }
312
313         [% IF (AcqCreateItem == 'ordering') %]
314             var items_columns = [null, null, 'barcode', 'homebranchname',
315                 'holdingbranchname', 'notforloan', 'restricted', 'location',
316                 'itemcallnumber', 'copynumber', 'stocknumber', 'collection',
317                 'itemtype', 'materials', 'itemnotes'];
318
319             function PopupEditPage(biblionumber, itemnumber) {
320                 var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber="
321                     + biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem";
322                 var w = window.open(url);
323                 var watchClose = setInterval(function() {
324                     if (w.closed) {
325                         clearTimeout(watchClose);
326                         $.getJSON('/cgi-bin/koha/catalogue/getitem-ajax.pl',
327                             {
328                                 'itemnumber': itemnumber
329                             },
330                             function(item) {
331                                 var tds = $("#item_"+itemnumber+" td");
332                                 for(var i=2; i<tds.length; i++) {
333                                     var column = items_columns[i];
334                                     var text = item[column];
335                                     if ( text == null ) text = '';
336                                     $(tds[i]).text(text);
337                                 }
338                             }
339                         );
340                     }
341                 }, 500);
342             }
343
344             function CalcQtyToReceive() {
345                 var qty = $("input[name='items_to_receive']:checked").length;
346                 $("#quantity").val(qty);
347             }
348
349             function CheckNItems(n) {
350                 $("input[name='items_to_receive']").each(function() {
351                     $(this).prop('checked', false);
352                 });
353                 $("input[name='items_to_receive']:lt("+n+")").each(function () {
354                     $(this).prop('checked', true);
355                 });
356             }
357         [% END %]
358
359         $(document).ready(function() {
360             [% IF (AcqCreateItemReceiving) %]
361                 cloneItemBlock(0, '[% UniqueItemFields %]');
362             [% ELSIF (AcqCreateItem == 'ordering') && not subscriptionid %]
363                 $("input[name='items_to_receive']").change(function() {
364                     CalcQtyToReceive();
365                 });
366                 CalcQtyToReceive();
367                 $("#quantity").keyup(function() {
368                     var qty = parseInt($("#quantity").val());
369                     var qtyto = parseInt($("#quantity_to_receive").val());
370                     if(qty > qtyto) {
371                         $("#qtyrecerror").show();
372                     } else {
373                         $("#qtyrecerror").hide();
374                     }
375                     CheckNItems($(this).val());
376                 });
377             [% END %]
378         });
379     </script>
380 [% END %]
381
382 [% INCLUDE 'intranet-bottom.inc' %]