Bug 19754: Move template JavaScript to the footer: Acquisitions, part 2
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / neworderempty.tt
1 [% USE Koha %]
2 [% USE KohaDates %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Koha &rsaquo; Acquisitions &rsaquo; Basket [% basketno %] &rsaquo; [% IF ( ordernumber ) %]Modify order details (line #[% ordernumber %])[% ELSE %]New order[% END %]</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="acq_neworderempty" class="acq">
10
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; <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Basket [% basketno %]</a> &rsaquo; [% IF ( ordernumber ) %]Modify order details (line #[% ordernumber %])[% ELSE %]New order[% END %]</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 <h2>
23     [% IF ( ordernumber ) %]
24         Modify order line
25     [% ELSE %]
26         New order
27     [% END %]
28 </h2>
29
30 <div class="error" style="display:none"></div>
31
32 [% IF ( basketno ) %]
33     <div id="acqui_basket_summary"  class="yui-g">
34     <fieldset class="rows">
35         <legend>Basket details</legend>
36         <ol>
37         [% IF ( basketnote ) %]<li><span class="label">Internal note:</span> [% basketnote %]</li>[% END %]
38         [% IF ( basketbooksellernote ) %]<li><span class="label">Vendor note:</span> [% basketbooksellernote %]</li>[% END %]
39         [% IF ( basketcontractno ) %]
40             <li><span class="label">Contract number: </span>[% basketcontractno %]</li>
41             <li><span class="label">Contract name:</span> <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno %]">[% basketcontractname %]</a></li>
42         [% END %]
43         [% IF ( authorisedbyname ) %]<li><span class="label">Managed by:</span>  [% authorisedbyname %]</li>[% END %]
44         [% IF ( creationdate ) %]<li><span class="label">Open on:</span>  [% creationdate | $KohaDates %]</li>[% END %]
45         [% IF ( closedate ) %]
46         <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="post">
47         <li><span class="label">Closed on:</span>  [% closedate | $KohaDates %]</li>
48         [% IF ( basketgroups ) %]
49             <li>Basketgroup: <select id="basketgroupid" name="basketgroupid">
50                 [% FOREACH basketgroup IN basketgroups %]
51                     [% IF ( basketgroup.default ) %]
52                     <option value="[% basketgroup.id %]" selected="selected">[% basketgroup.name %]</option>
53                     [% ELSE %]
54                     <option value="[% basketgroup.id %]">[% basketgroup.name %]</option>
55                     [% END %]
56                 [% END %]
57                 </select>
58                 <input type="hidden" id="basketno" value="[% basketno %]" name="basketno" />
59                 <input type="hidden" value="mod_basket" name="op" />
60                 <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
61             </li>
62             <fieldset class="action"><input type="submit" value="Change basketgroup" /></fieldset>
63         [% END %]
64         </form>
65         [% END %]
66         </ol>
67     </fieldset>
68     </div>
69 [% END %]
70
71 <form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);">
72
73     <fieldset class="rows">
74         <legend>Patrons</legend>
75         <ol>
76             <li>
77                 <span class="label">To notify on receiving:</span>
78                 <div style="float:left">
79                     <ul id="users_names" style="padding-left:0">
80                       [% FOREACH user IN users %]
81                         <li id="user_[% user.borrowernumber %]">
82                             [% user.firstname %] [% user.surname %]
83                             [<a onclick="del_user([% user.borrowernumber %]);" style="cursor:pointer">Delete user</a>]
84                         </li>
85                       [% END %]
86                     </ul>
87                     <input type="hidden" id="users_ids" name="users_ids" value="[% users_ids %]" />
88                     <input type="hidden" id="op" name="op" value="mod_users" />
89                     <input type="button" id="add_user" onclick="UserSearchPopup();" value="Add user" />
90                 </div>
91             </li>
92         </ol>
93     </fieldset>
94
95 <fieldset class="rows">
96         <legend>
97             Catalog details
98             [% IF ( biblionumber ) %]
99                 <span><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]"> Edit record</a></span>
100             [% END %]
101         </legend>
102         [% UNLESS ( existing ) %]
103         <input type="hidden" name="existing" value="no" />
104         [% END %]
105         <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
106         <input type="hidden" name="basketno" value="[% basketno %]" />
107         <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
108         <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
109         <input type="hidden" name="listinc" id="listinc" value="[% listincgst %]" />
110         <input type="hidden" name="invoiceincgst" id="invoiceincgst" value="[% invoiceincgst %]" />
111         <input type="hidden" name="suggestionid" value="[% suggestionid %]" />
112         <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
113
114         [% FOREACH c IN currencies %]
115             <input type="hidden" id="currency_rate_[% c.currency %]"  name="[% c.currency %]" value="[% c.rate %]" />
116         [% END %]
117
118         <ol><li>
119             [% IF ( biblionumber ) %]
120             <span class="label">Title</span>
121                 <input type="hidden" name="title" value="[% title |html %]" /> <span class="title">[% title |html %]</span>
122             [% ELSE %]
123             <label for="entertitle" class="required">Title: </label>
124                 <input type="text" id="entertitle" size="50" name="title" value="[% title |html %]" class="focus" />
125                 <span class="required">Required</span>
126             [% END %]
127         </li>
128         <li>
129             [% IF ( biblionumber ) %]
130             <span class="label">Author: </span>
131                 <input type="hidden" name="author" id="author" value="[% author %]" />[% author %]
132             [% ELSE %]
133             <label for="author">Author: </label>
134                 <input type="text" size="50" name="author" id="author" value="[% author %]" />
135             [% END %]
136         </li>
137         <li>
138             [% IF ( biblionumber ) %]
139             <span class="label">Publisher: </span>
140                 <input type="hidden" name="publishercode" id="publishercode" value="[% publishercode %]" />[% publishercode %]
141             [% ELSE %]
142             <label for="publishercode"> Publisher: </label>
143                 <input type="text" size="50" name="publishercode" id="publishercode" value="[% publishercode %]" />
144             [% END %]
145         </li>
146         <li>
147             [% IF ( biblionumber ) %]
148             <span class="label">Edition: </span>
149                 <input type="hidden" name="editionstatement" id="editionstatement" value="[% editionstatement %]" />[% editionstatement %]
150
151             [% ELSE %]
152             <label for="editionstatement">Edition: </label>
153                 <input type="text" size="20" name="editionstatement" id="editionstatement" value="[% editionstatement %]" />
154             [% END %]
155         </li>
156         <li>
157             [% IF ( biblionumber ) %]
158             <span class="label">Publication year: </span>
159                 <input type="hidden" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />[% publicationyear %]
160             [% ELSE %]
161             <label for="publicationyear">Publication year: </label>
162                 <input type="text" size="10" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />
163             [% END %]
164         </li>
165         <li>
166             [% IF ( biblionumber ) %]
167             <span class="label">ISBN: </span>
168                 <input type="hidden" name="isbn" id="ISBN" value="[% isbn %]" />[% isbn %]
169             [% ELSE %]
170             <label for="ISBN">ISBN: </label>
171                 <input type="text" size="50" name="isbn" id="ISBN" value="[% isbn %]" />
172             [% END %]
173         </li>
174         [% IF (UNIMARC) %]
175         <li>
176             [% IF ( biblionumber ) %]
177             <span class="label">EAN: </span>
178                 <input type="hidden" name="ean" id="EAN" value="[% ean %]" />[% ean %]
179             [% ELSE %]
180             <label for="EAN">EAN: </label>
181                 <input type="text" size="20" name="ean" id="EAN" value="[% ean %]" />
182             [% END %]
183         </li>
184         [% END %]
185         <li>
186             [% IF ( biblionumber ) %]
187             <span class="label">Series: </span>
188                 <input type="hidden" name="series" id="series" value="[% seriestitle %]" />[% seriestitle %]
189             [% ELSE %]
190             <label for="series">Series: </label>
191                 <input type="text" size="50" name="series" id="series" value="[% seriestitle %]" />
192             [% END %]
193         </li>
194             [% UNLESS ( biblionumber ) %]
195             [% IF ( itemtypeloop ) %]
196             <li>
197                 <span class="label">Item type:</span>
198                 <select name="itemtype" style="width:12em;">
199                 [% FOREACH itemtype IN itemtypeloop %]
200                     <option value="[% itemtype.itemtype %]">[% itemtype.description %]</option>
201                 [% END %]
202                 </select>
203             </li>
204             [% END %]
205             [% END %]
206         </ol>
207     </fieldset>
208
209     [% IF ( suggestionid ) %]
210         <fieldset class="rows">
211         <legend>Suggestion</legend>
212         <ol>
213           <li>
214             <span class="label">Suggested by: </span>
215             [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]&amp;op=show">suggestion #[% suggestionid %]</a>)
216           </li>
217         </ol>
218         </fieldset>
219     [% END %]
220
221     [% UNLESS subscriptionid || basket.is_standing %][% # it is a suggestion, we have not items %]
222       [% IF (AcqCreateItemOrdering) %]
223
224       <div id="items_list" style="display:none">
225           <p><b>Items list</b></p>
226           <div style="width:100%;overflow:auto;">
227               <table>
228                   <thead>
229                       <tr>
230                           <th>&nbsp;</th>
231                           <th>&nbsp;</th>
232                           <th>Barcode</th>
233                           <th>Home library</th>
234                           <th>Holding library</th>
235                           <th>Not for loan</th>
236                           <th>Restricted</th>
237                           <th>Location</th>
238                           <th>Call number</th>
239                           <th>Copy number</th>
240                           <th>Inventory number</th>
241                           <th>Collection code</th>
242                           <th>Item type</th>
243                           <th>Materials</th>
244                           <th>Notes</th>
245                       </tr>
246                   </thead>
247                   <tbody>
248                   </tbody>
249               </table>
250           </div>
251       </div>
252
253       <fieldset class="rows" id="itemfieldset">
254           <legend>Item</legend>
255           [% IF ( NoACQframework ) %]
256               <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
257           [% END %]
258
259           [% UNLESS Koha.Preference('autoBarcode') == 'OFF' %]
260               <div class="dialog message">The autoBarcode system preference is set to [% Koha.Preference('autoBarcode') %] and items with blank barcodes will have barcodes generated upon save to database</div>
261           [% END %]
262
263           <div id="outeritemblock"></div>
264
265       </fieldset>
266       [% END %][%# UNLESS subscriptionid %]
267     [% END %][%# IF (AcqCreateItemOrdering) %]
268     <fieldset class="rows">
269         <legend>Accounting details</legend>
270         <ol>
271             <li>
272                 [% IF ( close ) %]
273                     <span class="label required">Quantity: </span>
274                     <input type="hidden" name="quantity" value="[% quantity %]" />[% quantity %]
275                 [% ELSE %]
276                     <label class="required" for="quantity">Quantity: </label>
277                     [% IF (AcqCreateItemOrdering) %]
278                         [% IF subscriptionid || basket.is_standing %]
279                             <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" />
280                         [% ELSE %]
281                             <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" />
282                         [% END %]
283                     [% ELSE %]
284                         [% IF subscriptionid || basket.is_standing %]
285                             <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" />
286                         [% ELSE %]
287                             <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="updateCosts();" />
288                         [% END %]
289                     [% END %]
290                     <span class="required">Required</span>
291                 [% END %]
292                 <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
293                 <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
294             </li>
295             <li>
296                 [% IF ( close ) %]
297             <span class="label required">Fund: </span>
298                     <input type="hidden" name="budget_id" id="budget_id" value="[% budget_id %]" />[% Budget_name %]
299                 [% ELSE %]
300                 <label class="required" for="budget_id">Fund: </label>
301                 [% active_count = 0 %]
302                 [% IF !ordernumber %]
303                     [% FOREACH budget_loo IN budget_loop %]
304                         [% active_count= active_count + budget_loo.b_active %]
305                     [% END %]
306                 [% END %]
307                 <select id="budget_id" size="1" name="budget_id">
308                     <option value="">Select a fund</option>
309                 [% FOREACH budget_loo IN budget_loop %]
310                     [% IF ( budget_loo.b_sel ) %]
311                         [% active_count = 0 #select no other fund %]
312                         <option value="[% budget_loo.b_id %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]"
313                                 style="padding-left:[% budget_loo.b_level %]em;"
314                         >
315                     [% ELSIF active_count==1 && budget_loo.b_active %]
316                         <option value="[% budget_loo.b_id %]" selected="selected" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]"
317                                 style="padding-left:[% budget_loo.b_level %]em;"
318                         >
319                     [% ELSE %]
320                         [% bdgclass=budget_loo.b_active? "": "b_inactive" %]
321                         <option value="[% budget_loo.b_id %]" class="[% bdgclass %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]"
322                                 style="padding-left:[% budget_loo.b_level %]em;"
323                         >
324                     [% END %]
325                     [% budget_loo.b_txt %][% IF !budget_loo.b_active %] (inactive)[% END %]
326                     </option>
327                 [% END %]
328                 </select>
329                 <span class="required">Required</span>
330                 <label for="showallbudgets" style="float:none;">&nbsp;Show inactive:</label>
331                 <input type="checkbox" id="showallbudgets" />
332                 [% END %]
333             </li>
334                 <li>
335                 [% IF ( close ) %]
336                         <span class="label">Currency: </span>
337             <input type="hidden" name="currency" id="currency" value="[% currency %]" />[% currency %]
338                 [% ELSE %]
339                         <label for="currency">Currency:</label>
340             <select name="currency" id="currency" onchange="updateCosts();">
341                 [% FOREACH c IN currencies %]
342                     [% IF ordernumber and c.currency == currency or not ordernumber and c.currency == vendor_currency %]
343                         <option value="[% c.currency %]" selected="selected">[% c.currency %]</option>
344                     [% ELSIF not c.archived %]
345                         <option value="[% c.currency %]">[% c.currency %]</option>
346                     [% END %]
347                 [% END %]
348             </select>
349                 [% END %]
350                 </li>
351             <li>
352                 [% IF ( close ) %]
353                     <span class="label">Vendor price: </span>
354                     <input type="hidden" name="listprice" id="listprice" value="[% listprice %]" />[% listprice %] [% IF (listincgst == 1) %](tax inc.)[% ELSE %](tax exc.)[% END %]
355                 [% ELSE %]
356                 <label for="listprice">Vendor price: </label>
357                     <input type="text" size="20" name="listprice" id="listprice" value="[% listprice %]" onchange="updateCosts()" /> [% IF (listincgst == 1) %](tax inc.)[% ELSE %](tax exc.)[% END %]
358                 [% END %]
359             </li>
360             [% UNLESS ( close ) %]
361             <li>
362                     <label for="uncertainprice">Uncertain price: </label>
363                     [% IF ( uncertainprice ) %]
364                     <input type="checkbox" name="uncertainprice"  id="uncertainprice" value="1" checked="checked" />
365                     [% ELSE %]
366                     <input type="checkbox" name="uncertainprice" id="uncertainprice" value="1" />
367                 [% END %]
368             </li>
369             [% END %]
370             [% IF ( gst_values ) %]
371                 <li>
372                     [% IF ( close ) %]
373                         <span class="label">Tax rate: </span>
374                         <input type="hidden" name="tax_rate" id="tax_rate" value="[% tax_rate %]" />[% tax_rate %]%
375                     [% ELSE %]
376                         <label for="tax_rate">Tax rate: </label>
377                         <select name="tax_rate" id="tax_rate" onchange="updateCosts();">
378                         [% FOREACH gst IN gst_values %]
379                           [% IF ( gst.option == tax_rate ) %]
380                             <option value="[% gst.option %]" selected="selected">[% gst.option * 100 %]%</option>
381                           [% ELSE %]
382                             <option value="[% gst.option %]">[% gst.option * 100 %]%</option>
383                           [% END %]
384                         [% END %]
385                         </select>
386                     [% END %]
387                 [% ELSE %]
388                     <input type="hidden" name="tax_rate" value="0" />
389                 </li>
390             [% END %]
391             <li>
392                 <label for="discount">Discount: </label>
393                 [% IF ( close ) %]
394                     [% IF ( orderdiscount ) %]
395                         <input type="hidden" name="discount" id="discount" value="[% orderdiscount %]" />[% orderdiscount_2dp %]%
396                     [% ELSE %]
397                         <input type="hidden" name="discount" id="discount" value="[% discount %]" />[% discount_2dp %]%
398                     [% END %]
399                 [% ELSE %]
400                     [% IF ( orderdiscount ) %]
401                         <input type="text" size="6" name="discount" id="discount" value="[% orderdiscount %]" onchange="updateCosts();" />%
402                     [% ELSE %]
403                         <input type="text" size="6" name="discount" id="discount" value="[% discount %]" onchange="updateCosts();" />%
404                     [% END %]
405                 [% END %]
406             </li>
407             <li>
408                 [% IF ( close ) %]
409                     <span class="label">Replacement cost: </span>
410                     <input type="hidden" name="rrp" id="rrp" value="[% rrp %]" />[% rrp %]  (adjusted for [% cur_active %], [% IF (listincgst == 1) %]tax inc.[% ELSE %]tax exc.[% END %])
411                 [% ELSE %]
412                     <label for="rrp">Replacement cost: </label>
413                     <input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /> (adjusted for [% cur_active %], [% IF (listincgst == 1) %]tax inc.[% ELSE %]tax exc.[% END %])
414                 [% END %]
415             </li>
416             <li>
417                 <label for="ecost">Budgeted cost: </label>
418                 <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" readonly="readonly"  /> [% IF (listincgst == 1) %](tax inc.)[% ELSE %](tax exc.)[% END %]
419             </li>
420             <li>
421                 <label for="total">Total: </label>
422                 <input type="text" id="total" size="20" name="total" value="[% total %]" readonly="readonly" /> (budgeted cost * quantity)
423             </li>
424             <li>
425                 [% IF ( close ) %]
426                     <label for="unitprice">Actual cost: </label>
427                     <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" readonly="readonly" /> [% IF (invoiceincgst == 1) %](tax inc.)[% ELSE %](tax exc.)[% END %]
428                 [% ELSE %]
429                     <label for="unitprice">Actual cost: </label>
430                     <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" /> [% IF (invoiceincgst == 1) %](tax inc.)[% ELSE %](tax exc.)[% END %]
431                 [% END %]
432             </li>
433             <li>
434                 <label for="order_internalnote">Internal note: </label>
435                 <textarea id="order_internalnote" cols="30" rows="3" name="order_internalnote" >[% IF ( order_internalnote ) %][% order_internalnote %][% END %]</textarea>
436             </li>
437             <li>
438                 <label for="order_vendornote">Vendor note: </label>
439                 <textarea id="order_vendornote" cols="30" rows="3" name="order_vendornote" >[% IF ( order_vendornote ) %][% order_vendornote %][% END %]</textarea>
440             </li>
441             <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
442                 <label for="sort1">Statistic 1: </label>
443                 <input id="sort1" type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
444             <li>
445                 <label for="sort2">Statistic 2: </label>
446                 <input id="sort2" type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
447             </li>
448         </ol>
449     </fieldset>
450     <fieldset class="action">
451         <input type="hidden" name="subscriptionid" value="[% subscriptionid %]" />
452         <input type="submit" value="Save" />
453         [% IF (suggestionid) %]
454             <a class="cancel" href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Cancel</a>
455         [% ELSE %]
456             [% IF subscriptionid %]
457                 <a class="cancel" href="/cgi-bin/koha/acqui/newordersubscription.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Cancel</a>
458             [% ELSE %]
459                 <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
460             [% END %]
461         [% END %]
462     </fieldset>
463 </form>
464
465 <div id="procModal" data-backdrop="static" class="modal fade" aria-labelledby="procModal" aria-hidden="true">
466     <div class="modal-dialog">
467     <div class="modal-content">
468     <div class="modal-body">
469     <h3>Processing multiple items</h3>
470     </div>
471     </div>
472     </div>
473 </div>
474
475 <div id="multiCountModal" class="modal fade" aria-labelledby="multiCountModal" aria-hidden="true">
476     <div class="modal-dialog">
477     <div class="modal-content">
478     <h3>Invalid number of copies</h3>
479     <p>Please enter a <b>number</b>, greater than or equal to 1</p>
480     </div>
481     </div>
482 </div>
483
484 </div>
485 </div>
486 <div class="yui-b">
487 [% INCLUDE 'acquisitions-menu.inc' %]
488 </div>
489 </div>
490
491 [% MACRO jsinclude BLOCK %]
492     <script type="text/javascript" src="[% interface %]/[% theme %]/js/acquisitions-menu_[% KOHA_VERSION %].js"></script>
493     <script type="text/javascript" src="[% interface %]/[% theme %]/js/acq_[% KOHA_VERSION %].js"></script>
494     [% INCLUDE 'additem.js.inc' %]
495     <script type="text/javascript" src="[% interface %]/[% theme %]/js/additem_[% KOHA_VERSION %].js"></script>
496     <script type="text/javascript" src="[% interface %]/[% theme %]/js/cataloging_[% KOHA_VERSION %].js"></script>
497     <script type="text/javascript" src="[% interface %]/[% theme %]/js/prevent_submit_[% KOHA_VERSION %].js"></script>
498     <script type="text/javascript">
499         actTotal = "";
500
501         function Check(ff) {
502             [% IF (AcqCreateItemOrdering) %]
503                 // Remove last itemblock if it is not in items_list
504                 var lastitemblock = $("#outeritemblock > div:last");
505                 var tobedeleted = true;
506                 var listitems = $("#items_list tr");
507                 $(listitems).each(function(){
508                     if($(this).attr('idblock') == $(lastitemblock).attr('id')){
509                         tobedeleted = false;
510                     }
511                 });
512                 if(tobedeleted){
513                     $(lastitemblock).remove();
514                 }
515             [% END %]
516
517             var ok=0;
518             var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
519
520             _alertString +="-------------------------------------------------------------------\n\n";
521
522             if ( isNull(ff.title,1)  &&  isNull(ff.entertitle,1)   ){
523                 ok=1;
524                             _alertString += "\n- " + _("Title cannot be empty");
525             }
526
527             if(isNull(ff.budget_id,1)){
528                 ok=1;
529                 _alertString += "\n- "+ _("You must select a fund");
530             }
531
532             if (!(isNum(ff.quantity,0)) || ff.quantity.value == 0){
533                 ok=1;
534                             _alertString += "\n- " + _("Quantity must be greater than '0'");
535             }
536
537             if (!(isNum(ff.listprice,0))){
538                 ok=1;
539                             _alertString += "\n- " + _("Vendor price must be a number");
540             }
541
542             if (!(isNum(ff.total,0))){
543                 ok=1;
544                             _alertString += "\n- " + _("Total must be a number");
545             }
546
547             if (totalExceedsBudget(ff.budget_id.value, ff.total.value  )  ) {
548                 ok=1;
549                 _alertString += "\n- " + _("Order total (%s) exceeds budget available (%s)").format(ff.total.value, actTotal);
550             }
551
552             if ( ff.field_value ) {
553                 var empty_item_mandatory = CheckMandatorySubfields(ff);
554                 if (empty_item_mandatory > 0) {
555                     ok = 1;
556                     _alertString +=
557                         "\n- " + _("%s item mandatory fields empty").format(empty_item_mandatory);
558                 }
559
560             }
561
562             if (ok) {
563                 alert(_alertString);
564                 [% IF (AcqCreateItemOrdering) %]
565                     if(tobedeleted) {
566                         $(lastitemblock).appendTo('#outeritemblock');
567                     }
568                 [% END %]
569                 return false;
570             }
571
572             [% IF (AcqCreateItemOrdering) %]
573                 if(check_additem('[% UniqueItemFields %]') == false) {
574                     alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
575                     if(tobedeleted) {
576                         $(lastitemblock).appendTo('#outeritemblock');
577                     }
578                     return false;
579                 }
580             [% END %]
581         }
582
583         $(document).ready(function(){
584             [% IF AcqCreateItemOrdering and not basket.is_standing %]
585                 cloneItemBlock(0, '[% UniqueItemFields %]');
586             [% END %]
587
588             [% IF ( suggestionid ) %]updateCosts();[% END %]
589             $("#quantity").change(function() {
590                 updateCosts();
591             });
592
593             //We apply the fonction only for modify option
594             [% IF ( quantityrec ) %]
595                 [% IF ( acqcreate ) %]
596                     $('#quantity').blur(function(){
597                         // if user decreases the quantity
598                         if($(this).val() < [% quantityrec %]){
599                             alert(_("You have deleted item(s) in the order, don't forget to delete it(them) in the catalog"));
600                             return true;
601                         } else {
602                             // if user increases the quantity
603                             alert(_("You can't add a new item, please create a new order line"));
604                             // and we replace the original value
605                             $(this).val([% quantityrec %])
606                             updateCosts(); // blur is invoked after change which updated values
607                             return false;
608                         }
609                     });
610                 [% END %]
611             [% END %]
612
613             //keep a copy of all budgets before removing the inactives
614             disabledBudgetsCopy = $('#budget_id').html();
615             $('#budget_id .b_inactive').remove();
616
617             $('#showallbudgets').click(function() {
618                 if ($(this).is(":checked")) {
619                     $('#budget_id').html(disabledBudgetsCopy); //Puts back all the funds
620                 }
621                 else {
622                     $('#budget_id .b_inactive').remove();
623                 }
624             });
625
626             $("#budget_id").change(function(){
627                 var destination_sort1 = $(this).parents('fieldset.rows').find('input[name="sort1"]');
628                 var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
629                 var sort1 = $(destination_sort1).val() || "";
630                 if ( destination_sort1.length < 1 ) {
631                     destination_sort1 = $(this).parents('fieldset.rows').find('select[name="sort1"]');
632                 }
633                 var destination_sort2 = $(this).parents('fieldset.rows').find('input[name="sort2"]');
634                 var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
635                 var sort2 = $(destination_sort2).val() || "";
636                 if ( destination_sort2.length < 1 ) {
637                     destination_sort2 = $(this).parents('fieldset.rows').find('select[name="sort2"]');
638                 }
639                 getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
640                 getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
641             });
642             $("#budget_id").change();
643         });
644
645         function UserSearchPopup(f) {
646             window.open(
647                 "/cgi-bin/koha/acqui/add_user_search.pl",
648                 'UserSearchPopup',
649                 'width=740, height=450, scrollbars=yes, toolbar=no,'
650              );
651         }
652
653         function add_user(borrowernumber, borrowername) {
654             var ids = $("#users_ids").val();
655             if(ids.length > 0) {
656                 ids = ids.split(':');
657             } else {
658                 ids = new Array;
659             }
660         if (ids.indexOf(borrowernumber.toString()) < 0) {
661                 ids.push(borrowernumber);
662                 $("#users_ids").val(ids.join(':'));
663                 var li = '<li id="user_'+borrowernumber+'">'+borrowername
664                     + ' [<a style="cursor:pointer" onclick="del_user('+borrowernumber+');">'
665                     + _("Delete user") + '</a>]</li>';
666                 $("#users_names").append(li);
667                 return 0;
668             }
669             return -1;
670         }
671
672         function del_user(borrowernumber) {
673             $("#user_"+borrowernumber).remove();
674             var ids = $("#users_ids").val().split(':');
675             ids.splice(ids.indexOf(borrowernumber.toString()), 1);
676             $("#users_ids").val(ids.join(':'));
677         }
678     </script>
679 [% END %]
680
681 [% INCLUDE 'intranet-bottom.inc' %]