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