Merge remote-tracking branch 'origin/new/bug_6390'
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / neworderempty.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Acquisitions &rsaquo; Basket [% basketno %] &rsaquo; [% IF ( ordernumber ) %]Modify order details (line #[% ordernumber %])[% ELSE %]New order[% END %]</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4
5 <script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
6 <script type="text/javascript" src="[% themelang %]/js/additem.js"></script>
7 <script type="text/javascript">
8 //<![CDATA[
9 actTotal = "";
10
11 function Check(ff) {
12     var ok=0;
13     var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
14
15     _alertString +="-------------------------------------------------------------------\n\n";
16
17     if ( isNull(ff.title,1)  &&  isNull(ff.entertitle,1)   ){
18         ok=1;
19                     _alertString += "\n- " + _("Title cannot be empty");
20     }
21     
22     if(isNull(ff.budget_id,1)){
23                 ok=1;
24                                         _alertString += "\n- "+ _("You must select a budget");
25     }
26
27     if (!(isNum(ff.quantity,0))){
28         ok=1;
29                     _alertString += "\n- " + _("Quantity must be greater than '0'");
30     }
31
32     if (!(isNum(ff.listprice,0))){
33         ok=1;
34                     _alertString += "\n- " + _("Vendor price must be a number");
35     }
36
37     if (!(isNum(ff.total,0))){
38         ok=1;
39                     _alertString += "\n- " + _("Total must be a number");
40     }
41
42     if (totalExceedsBudget(ff.budget_id.value, ff.total.value  )  ) {
43         ok=1;
44         _alertString += "\n- " + _("Order total (") + ff.total.value +
45             _(") exceeds budget available (") + actTotal+")";
46     }
47
48     if ( ff.field_value ) {
49         var barcodes = [];
50         var empty_item_mandatory = 0;
51         for (i = 0; i < ff.field_value.length; i++) {
52             //alert("i = " + i + " => " + ff.kohafield[i] );
53             if (ff.field_value[i].value.length == 0 && ff.mandatory[i].value == 1) {
54                 empty_item_mandatory++;
55             }
56             if(ff.subfield[i].value === '[% barcode_subfield %]' && ff.field_value[i].value.length != 0) {
57                 barcodes.push(ff.field_value[i].value);
58             }
59         }
60         if (empty_item_mandatory > 0) {
61             ok = 1;
62             _alertString +=
63                 "\n- " + empty_item_mandatory + _(" item mandatory fields empty");
64         }
65
66         if(barcodes.length > 0) {
67             // Check for duplicate barcodes in the form
68             barcodes = barcodes.sort();
69             for(var i=0; i<barcodes.length-1; i++) {
70                 if(barcodes[i] == barcodes[i+1]) {
71                     ok = 1;
72                     _alertString += "\n- " + _("The barcode ") + barcodes[i] + _(" is used more than once in the form. Every barcode must be unique");
73                 }
74             }
75
76             // Check for duplicate barcodes in the database via an ajax call
77             $.ajax({
78                 url: "/cgi-bin/koha/acqui/check_duplicate_barcode_ajax.pl",
79                 async:false,
80                 method: "post",
81                 data: {barcodes : barcodes},
82                 dataType: 'json',
83
84                 error: function(xhr) {
85                     alert("Error: \n" + xhr.responseText);
86                 },
87                 success: function(json) {
88                     switch(json.status) {
89                         case 'UNAUTHORIZED':
90                             ok = 1;
91                             _alertString += "\n- " + _("Error: Duplicate barcode verification failed. Insufficient user permissions.");
92                             break;
93                         case 'DUPLICATES':
94                             ok = 1;
95                             $.each(json.barcodes, function(index, barcode) {
96                                 _alertString += "\n- " + _("The barcode ") + barcode + _(" already exists in the database");
97                             });
98                             break;
99                     }
100                 },
101             });
102         }
103     }
104
105     if (ok) {
106         alert(_alertString);
107         return false;
108     }
109
110     ff.submit();
111
112 }
113
114 $(document).ready(function() 
115     {
116         //We apply the fonction only for modify option
117         [% IF ( quantityrec ) %]
118         $('#quantity').blur(function() 
119         {
120             // if user decreases the quantity
121             if($(this).val() < [% quantityrec %]) 
122             {
123                 alert(_("You have deleted item(s) in the order, don't forget to delete it(them) in the catalog"));
124                 return true;
125             } 
126             else 
127             {
128                 // if user increases the quantity
129                 alert(_("You can't add a new item, please create a new order line"));
130                 // and we replace the original value
131                 $(this).val([% quantityrec %])
132                 return false;
133             }
134         });
135         [% END %]
136         
137         $('#showallbudgets').click(function() {
138             if ( $('#budget_id .b_inactive').is(":visible") )
139             {
140             $('#budget_id .b_inactive').hide();
141             }
142             else {
143             $('#budget_id .b_inactive').show();
144             }
145         });
146     });
147 //]]>
148 </script>
149 </head>
150 <body>
151
152 [% INCLUDE 'header.inc' %]
153 [% INCLUDE 'acquisitions-search.inc' %]
154
155 <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?supplierid=[% 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>
156
157 <div id="doc3" class="yui-t2">
158
159 <div id="bd">
160     <div id="yui-main">
161     <div class="yui-b">
162
163 <h2>
164     [% IF ( ordernumber ) %]
165         Modify order line
166     [% ELSE %]
167         New order
168     [% END %]
169         [% IF ( suggestionid ) %](defined from suggestion #[% suggestionid %])[% END %]
170 </h2>
171
172 [% IF ( basketno ) %]
173     <div id="acqui_basket_summary"  class="yui-g">
174         <fieldset class="rows">
175         <legend>Basket details</legend>
176                 <ol>
177         [% IF ( basketnote ) %]<li><span class="label">Internal note:</span> [% basketnote %]</li>[% END %]
178         [% IF ( basketbooksellernote ) %]<li><span class="label">Vendor note:</span> [% basketbooksellernote %]</li>[% END %]
179         [% IF ( basketcontractno ) %]
180             <li><span class="label">Contract number: </span>[% basketcontractno %]</li>
181             <li><span class="label">Contract name:</span> <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno %]">[% basketcontractname %]</a></li>
182         [% END %]
183         [% IF ( authorisedbyname ) %]<li><span class="label">Managed by:</span>  [% authorisedbyname %]</li>[% END %]
184         [% IF ( creationdate ) %]<li><span class="label">Open on:</span>  [% creationdate %]</li>[% END %]
185         [% IF ( closedate ) %]
186         <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="post">
187         <li><span class="label">Closed on:</span>  [% closedate %]</li>
188         [% IF ( basketgroups ) %]
189             <li>Basketgroup: <select id="basketgroupid" name="basketgroupid">
190                 [% FOREACH basketgroup IN basketgroups %]
191                     [% IF ( basketgroup.default ) %]
192                     <option value="[% basketgroup.id %]" selected="selected">[% basketgroup.name %]</option>
193                     [% ELSE %]
194                     <option value="[% basketgroup.id %]">[% basketgroup.name %]</option>
195                     [% END %]
196                 [% END %]
197                 </select>
198                 <input type="hidden" id="basketno" value="[% basketno %]" name="basketno" />
199                 <input type="hidden" value="mod_basket" name="op" />
200                 <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
201             </li>
202                 <fieldset class="action"><input type="submit" value="Change basketgroup" /></fieldset>
203         </form>
204         [% END %]
205         [% END %]
206                         </ol>
207 </fieldset>
208     </div>
209 [% END %]
210
211 <form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform">
212
213 <fieldset class="rows">
214         <legend>
215             Catalog details
216             [% IF ( biblionumber ) %]
217                 <span><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]"> Edit record</a></span>
218             [% END %]
219         </legend>
220         [% UNLESS ( existing ) %]
221         <input type="hidden" name="existing" value="no" />
222         [% END %]
223         <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
224         <input type="hidden" name="basketno" value="[% basketno %]" />
225         <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
226         <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
227         <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
228         <input type="hidden" name="discount" value="[% discount %]" />
229         <input type="hidden" name="listinc" value="[% listincgst %]" />
230 <!--        <input type="hidden" name="currency" value="[% currency %]" />-->
231         <input type="hidden" name="applygst" value="[% gstreg %]" />
232         <input type="hidden" name="invoiceincgst" value="[% invoiceincgst %]" />
233         <input type="hidden" name="gstrate" value="[% gstrate %]" />
234         <input type="hidden" name="suggestionid" value="[% suggestionid %]" />
235         <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
236
237         [% FOREACH loop_currencie IN loop_currencies %]
238             <input type="hidden" id="[% loop_currencie.currcode %]"  name="[% loop_currencie.currcode %]" value="[% loop_currencie.rate %]" />
239         [% END %]
240         <ol><li>
241             [% IF ( biblionumber ) %]
242             <span class="label">Title</span>
243                 <input type="hidden" size="50" name="title" value="[% title |html %]" /> <span class="title">[% title |html %]</span>
244             [% ELSE %]
245             <label for="entertitle" class="required">Title: </label>
246                 <input type="text" id="entertitle" size="50" name="title" value="[% title |html %]" />
247             [% END %]
248         </li>
249         <li>
250             [% IF ( biblionumber ) %]
251             <span class="label">Author: </span>
252                 <input type="hidden" size="50" name="author" id="author" value="[% author %]" />[% author %]
253             [% ELSE %]
254             <label for="author">Author: </label>
255                 <input type="text" size="50" name="author" id="author" value="[% author %]" />
256             [% END %]
257         </li>
258         <li>
259             [% IF ( biblionumber ) %]
260             <span class="label">Publisher: </span>
261                 <input type="hidden" size="50" name="publishercode" id="publishercode" value="[% publishercode %]" />[% publishercode %]
262             [% ELSE %]
263             <label for="publishercode"> Publisher: </label>
264                 <input type="text" size="50" name="publishercode" id="publishercode" value="[% publishercode %]" />
265             [% END %]
266         </li>
267         <li>
268             [% IF ( biblionumber ) %]
269             <span class="label">Publication year: </span>
270                 <input type="hidden" size="10" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />[% publicationyear %]
271             [% ELSE %]
272             <label for="publicationyear">Publication year: </label>
273                 <input type="text" size="10" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />
274             [% END %]
275         </li>
276         <li>
277             [% IF ( biblionumber ) %]
278             <span class="label">ISBN: </span>
279                 <input type="hidden" size="50" name="isbn" id="ISBN" value="[% isbn %]" />[% isbn %]
280             [% ELSE %]
281             <label for="ISBN">ISBN: </label>
282                 <input type="text" size="50" name="isbn" id="ISBN" value="[% isbn %]" />
283             [% END %]
284         </li>
285         <li>
286             [% IF ( biblionumber ) %]
287             <span class="label">Series: </span>
288                 <input type="hidden" size="50" name="series" id="series" value="[% seriestitle %]" />[% seriestitle %]
289             [% ELSE %]
290             <label for="series">Series: </label>
291                 <input type="text" size="50" name="series" id="series" value="[% seriestitle %]" />
292             [% END %]
293         </li>
294         </li>
295             [% UNLESS ( biblionumber ) %]
296             [% IF ( itemtypeloop ) %]
297             <li>
298                 <span class="label">Item type:</span>
299                 <select name="itemtype" style="width:12em;">
300                 [% FOREACH itemtype IN itemtypeloop %]
301                     [% IF ( itemtype.selected ) %]
302                         <option value="[% itemtype.itemtype %]" selected="selected">[% itemtype.description %]</option>
303                     [% ELSE %]
304                         <option value="[% itemtype.itemtype %]">[% itemtype.description %]</option>
305                     [% END %]
306                 [% END %]
307                 </select>
308             </li>
309             [% END %]
310             [% END %]
311         </ol>
312     </fieldset>
313     [% IF ( items ) %]
314     <fieldset class="rows">
315         <legend>Item</legend>
316         [% IF ( NoACQframework ) %]
317             <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
318         [% END %]
319
320         [% FOREACH item IN items %]
321         <div id="outeritemblock">
322         <div id="itemblock">
323             <ol>[% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];">
324                 <div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]">
325
326                     <label>[% iteminformatio.subfield %] - [% IF ( iteminformatio.mandatory ) %]<b>[% END %][% iteminformatio.marc_lib %][% IF ( iteminformatio.mandatory ) %] *</b>[% END %]</label>
327                     [% iteminformatio.marc_value %]
328                     <input type="hidden" name="itemid" value="1" />
329                     <input type="hidden" name="kohafield" value="[% iteminformatio.kohafield %]" />
330                     <input type="hidden" name="tag" value="[% iteminformatio.tag %]" />
331                     <input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" />
332                     <input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" />
333                     [% IF ( iteminformatio.ITEM_SUBFIELDS_ARE_NOT_REPEATABLE ) %]
334                         <span class="buttonPlus" onclick="CloneSubfield('subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]')">+</span>
335                     [% END %]
336
337                 </div></li>
338             [% END %]
339             </ol>
340             <a style="cursor: pointer; color: grey; font-size: 180%;" onclick="cloneItemBlock('itemblock[% item.itemBlockIndex %]')">+</a>
341             <a style="display:none; cursor: pointer; color: grey; font-size: 180%;" onclick="deleteItemBlock('itemblock[% item.itemBlockIndex %]')">-</a>
342         </div><!-- /iteminformation -->
343         </div>
344
345         [% END %] <!-- /items -->
346     </fieldset>
347     [% END %] <!-- items -->
348     <fieldset class="rows">
349         <legend>Accounting Details</legend>
350         <ol>
351             <li>
352                 [% IF ( close ) %]
353             <span class="label required">Quantity: </span>
354                     <input type="hidden" size="20" name="quantity" value="[% quantity %]" />[% quantity %]
355                 [% ELSE %]
356                 <label class="required" for="quantity">Quantity: </label>
357                     [% IF ( items ) %]
358                         <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" onchange="calcNeworderTotal();" />
359                     [% ELSE %]
360                         <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="calcNeworderTotal();" />
361                     [% END %]
362                 [% END %]
363                 <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
364                 <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
365             </li>
366             <li>
367                 [% IF ( close ) %]
368             <span class="label">Fund: </span>
369                     <input type="hidden" size="20" name="budget_id" id="budget_id" value="[% budget_id %]" />[% Budget_name %]
370                 [% ELSE %]
371                 <label for="budget_id">Fund: </label>
372                 <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
373                 [% FOREACH budget_loo IN budget_loop %]
374                     [% IF ( budget_loo.b_sel ) %]
375                         <option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
376                     [% ELSE %]
377                         [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id %]">[% budget_loo.b_txt %]</option>
378                         [% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive" style="display : none;">[% budget_loo.b_txt %]</option>    
379                         [% END %]
380                     [% END %]
381                 [% END %]
382                 </select>
383                 <label for="showallbudgets" style="float:none;width:auto;">&nbsp;Show all:</label>
384                 <input type="checkbox" id="showallbudgets" />
385                 [% END %]
386             </li>
387                 <li>
388                 [% IF ( close ) %]
389                         <span class="label">Currency: </span>
390                         <input type="hidden" size="10" name="currency" id="currency" value="[% currency %]" />[% currency %]
391                 [% ELSE %]
392                         <label for="currency">Currency:</label>
393                         <select name="currency" id="currency" onchange="calcNeworderTotal();">
394                         [% FOREACH loop_currencie IN loop_currencies %]
395                         [% IF ( loop_currencie.selected ) %]<option value="[% loop_currencie.currcode %]" selected="selected">[% loop_currencie.currcode %]</option>[% ELSE %]<option value="[% loop_currencie.currcode %]">[% loop_currencie.currcode %]</option>[% END %][% END %]
396                         </select>
397                 [% END %]
398                 </li>
399             <li>
400                 [% IF ( close ) %]
401             <span class="label">Vendor price: </span>
402                     <input type="hidden" size="20" name="listprice" id="listprice" value="[% listprice %]" />[% listprice %]
403                 [% ELSE %]
404                 <label for="listprice">Vendor price: </label>
405                     <input type="text" size="20" name="listprice" id="listprice" value="[% listprice %]" onchange="calcNeworderTotal()" />
406                 [% END %]
407             </li>
408             [% UNLESS ( close ) %]
409             <li>
410                     <label for="uncertainprice">Uncertain price: </label>
411                     [% IF ( uncertainprice ) %]
412                     <input type="checkbox" name="uncertainprice"  id="uncertainprice" value="1" checked="checked" />
413                     [% ELSE %]
414                     <input type="checkbox" name="uncertainprice" id="uncertainprice" value="1" />
415                 [% END %]
416             </li>
417             [% END %]
418                         <li>
419                 [% IF ( close ) %]
420             <span class="label">Replacement cost: </span>
421                     <input type="hidden" size="20" name="rrp" id="rrp" value="[% rrp %]" />[% rrp %]
422                 [% ELSE %]
423                 <label for="rrp">Replacement cost: </label>
424                     <input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /> (adjusted for [% cur_active %])
425                 [% END %]
426             </li>
427             <li>
428                 [% IF ( close ) %]
429             <label for="ecost">Budgeted cost: </label>
430                     <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" readonly="readonly"  />
431                 [% ELSE %]
432                 <label for="ecost">Budgeted cost: </label>
433                     <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" />
434                 [% END %]
435                 [% IF ( discount_2dp ) %]  (adjusted for [% discount_2dp %]% discount)  [% END %]
436
437             </li>
438             [% IF ( GST ) %]
439             <li>
440                 [% IF ( close ) %]
441             <label for="GST">Budgeted GST: </label>
442                 <input type="text" id="" size="20" name="gst" value="" id="GST" readonly="readonly" />
443                 [% ELSE %]
444                 <label for="GST">Budgeted GST: </label>
445                 <input type="text" size="20" name="gst" id="GST" value="" />
446                 [% END %]
447             </li>
448             [% END %]
449             <li>
450                 [% IF ( close ) %]
451             <label for="total">Total: </label>
452                 <input type="text" id="total" size="20" name="total" value="[% total %]" readonly="readonly" />
453                 [% ELSE %]
454                 <label for="total">Total: </label>
455                 <input type="text" id="total" size="20" name="total" value="[% total %]" /> (budgeted cost * quantity)
456                 [% END %]
457             </li>
458             <li>
459                 [% IF ( close ) %]
460             <label for="cost">Actual cost: </label>
461                 <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" readonly="readonly" />
462                 [% ELSE %]
463                 <label for="cost">Actual cost: </label>
464                 <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" />
465                 [% END %]
466             </li>
467             <li>
468                 <label for="notes">Notes: </label>
469                 <textarea id="notes" cols="30" rows="3" name="notes" >[% notes %]</textarea>
470             </li>
471             <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
472                 <label for="sort1">Statistic 1: </label>
473
474                 [% IF CGIsort1 %]
475                     <select id="sort1" size="1" name="sort1">
476                     [% FOREACH sort_opt IN CGIsort1 %]
477                        [% IF sort_opt.default %]
478                           <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
479                         [% ELSE %]
480                           <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
481                         [% END %]
482                     [% END %]
483                     </select>
484                 [% ELSE %]
485
486                     <input type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
487                 [% END %]
488             </li>
489             <li>
490                 <label for="sort2">Statistic 2: </label>
491
492                 [% IF CGIsort2 %]
493                     <select id="sort2" size="1" name="sort1">
494                     [% FOREACH sort_opt IN CGIsort2 %]
495                        [% IF sort_opt.default %]
496                           <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
497                         [% ELSE %]
498                           <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
499                         [% END %]
500                     [% END %]
501                     </select>
502                 [% ELSE %]
503                     <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
504                 [% END %]
505             </li>
506 </ol>
507     </fieldset>
508     <fieldset class="action">
509         <input type="button" value="Save" onclick="Check(this.form)" /> [% IF ( suggestionid ) %]<a class="cancel" href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Cancel</a>[% ELSE %]<a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>[% END %]
510     </fieldset>
511 </form>
512 </div>
513 </div>
514 <div class="yui-b">
515 [% INCLUDE 'acquisitions-menu.inc' %]
516 </div>
517 </div>
518 [% INCLUDE 'intranet-bottom.inc' %]