Bug 5346: Small display changes
[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 </h2>
170
171 [% IF ( basketno ) %]
172     <div id="acqui_basket_summary"  class="yui-g">
173         <fieldset class="rows">
174         <legend>Basket details</legend>
175                 <ol>
176         [% IF ( basketnote ) %]<li><span class="label">Internal note:</span> [% basketnote %]</li>[% END %]
177         [% IF ( basketbooksellernote ) %]<li><span class="label">Vendor note:</span> [% basketbooksellernote %]</li>[% END %]
178         [% IF ( basketcontractno ) %]
179             <li><span class="label">Contract number: </span>[% basketcontractno %]</li>
180             <li><span class="label">Contract name:</span> <a href="/cgi-bin/koha/admin/aqcontract.pl?op=add_form&amp;contractnumber=[% basketcontractno %]">[% basketcontractname %]</a></li>
181         [% END %]
182         [% IF ( authorisedbyname ) %]<li><span class="label">Managed by:</span>  [% authorisedbyname %]</li>[% END %]
183         [% IF ( creationdate ) %]<li><span class="label">Open on:</span>  [% creationdate %]</li>[% END %]
184         [% IF ( closedate ) %]
185         <form action="/cgi-bin/koha/acqui/basketgroup.pl" method="post">
186         <li><span class="label">Closed on:</span>  [% closedate %]</li>
187         [% IF ( basketgroups ) %]
188             <li>Basketgroup: <select id="basketgroupid" name="basketgroupid">
189                 [% FOREACH basketgroup IN basketgroups %]
190                     [% IF ( basketgroup.default ) %]
191                     <option value="[% basketgroup.id %]" selected="selected">[% basketgroup.name %]</option>
192                     [% ELSE %]
193                     <option value="[% basketgroup.id %]">[% basketgroup.name %]</option>
194                     [% END %]
195                 [% END %]
196                 </select>
197                 <input type="hidden" id="basketno" value="[% basketno %]" name="basketno" />
198                 <input type="hidden" value="mod_basket" name="op" />
199                 <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
200             </li>
201                 <fieldset class="action"><input type="submit" value="Change basketgroup" /></fieldset>
202         </form>
203         [% END %]
204         [% END %]
205                         </ol>
206 </fieldset>
207     </div>
208 [% END %]
209
210 <form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform">
211
212 <fieldset class="rows">
213         <legend>
214             Catalog details
215             [% IF ( biblionumber ) %]
216                 <span><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]"> Edit record</a></span>
217             [% END %]
218         </legend>
219         [% UNLESS ( existing ) %]
220         <input type="hidden" name="existing" value="no" />
221         [% END %]
222         <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
223         <input type="hidden" name="basketno" value="[% basketno %]" />
224         <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
225         <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
226         <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
227         <input type="hidden" name="discount" value="[% discount %]" />
228         <input type="hidden" name="listinc" value="[% listincgst %]" />
229 <!--        <input type="hidden" name="currency" value="[% currency %]" />-->
230         <input type="hidden" name="applygst" value="[% gstreg %]" />
231         <input type="hidden" name="invoiceincgst" value="[% invoiceincgst %]" />
232         <input type="hidden" name="gstrate" value="[% gstrate %]" />
233         <input type="hidden" name="suggestionid" value="[% suggestionid %]" />
234         <input type="hidden" name="import_batch_id" value="[% import_batch_id %]" />
235
236         [% FOREACH loop_currencie IN loop_currencies %]
237             <input type="hidden" id="[% loop_currencie.currcode %]"  name="[% loop_currencie.currcode %]" value="[% loop_currencie.rate %]" />
238         [% END %]
239         <ol><li>
240             [% IF ( biblionumber ) %]
241             <span class="label">Title</span>
242                 <input type="hidden" size="50" name="title" value="[% title |html %]" /> <span class="title">[% title |html %]</span>
243             [% ELSE %]
244             <label for="entertitle" class="required">Title: </label>
245                 <input type="text" id="entertitle" size="50" name="title" value="[% title |html %]" />
246             [% END %]
247         </li>
248         <li>
249             [% IF ( biblionumber ) %]
250             <span class="label">Author: </span>
251                 <input type="hidden" size="50" name="author" id="author" value="[% author %]" />[% author %]
252             [% ELSE %]
253             <label for="author">Author: </label>
254                 <input type="text" size="50" name="author" id="author" value="[% author %]" />
255             [% END %]
256         </li>
257         <li>
258             [% IF ( biblionumber ) %]
259             <span class="label">Publisher: </span>
260                 <input type="hidden" size="50" name="publishercode" id="publishercode" value="[% publishercode %]" />[% publishercode %]
261             [% ELSE %]
262             <label for="publishercode"> Publisher: </label>
263                 <input type="text" size="50" name="publishercode" id="publishercode" value="[% publishercode %]" />
264             [% END %]
265         </li>
266         <li>
267             [% IF ( biblionumber ) %]
268             <span class="label">Publication year: </span>
269                 <input type="hidden" size="10" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />[% publicationyear %]
270             [% ELSE %]
271             <label for="publicationyear">Publication year: </label>
272                 <input type="text" size="10" name="publicationyear" id="publicationyear" value="[% publicationyear %]" />
273             [% END %]
274         </li>
275         <li>
276             [% IF ( biblionumber ) %]
277             <span class="label">ISBN: </span>
278                 <input type="hidden" size="50" name="isbn" id="ISBN" value="[% isbn %]" />[% isbn %]
279             [% ELSE %]
280             <label for="ISBN">ISBN: </label>
281                 <input type="text" size="50" name="isbn" id="ISBN" value="[% isbn %]" />
282             [% END %]
283         </li>
284         <li>
285             [% IF ( biblionumber ) %]
286             <span class="label">Series: </span>
287                 <input type="hidden" size="50" name="series" id="series" value="[% seriestitle %]" />[% seriestitle %]
288             [% ELSE %]
289             <label for="series">Series: </label>
290                 <input type="text" size="50" name="series" id="series" value="[% seriestitle %]" />
291             [% END %]
292         </li>
293         </li>
294             [% UNLESS ( biblionumber ) %]
295             [% IF ( itemtypeloop ) %]
296             <li>
297                 <span class="label">Item type:</span>
298                 <select name="itemtype" style="width:12em;">
299                 [% FOREACH itemtype IN itemtypeloop %]
300                     [% IF ( itemtype.selected ) %]
301                         <option value="[% itemtype.itemtype %]" selected="selected">[% itemtype.description %]</option>
302                     [% ELSE %]
303                         <option value="[% itemtype.itemtype %]">[% itemtype.description %]</option>
304                     [% END %]
305                 [% END %]
306                 </select>
307             </li>
308             [% END %]
309             [% END %]
310         </ol>
311     </fieldset>
312
313     [% IF ( suggestionid ) %]
314         <fieldset class="rows">
315         <legend>Suggestion</legend>
316         <ol>
317           <li>
318             <span class="label">Suggested by: </span>
319             [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]">suggestion #[% suggestionid %]</a>)
320           </li>
321         </ol>
322         </fieldset>
323     [% END %]
324
325     [% IF ( items ) %]
326     <fieldset class="rows">
327         <legend>Item</legend>
328         [% IF ( NoACQframework ) %]
329             <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
330         [% END %]
331
332         [% FOREACH item IN items %]
333         <div id="outeritemblock">
334         <div id="itemblock">
335             <ol>[% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];">
336                 <div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]">
337
338                     <label>[% iteminformatio.subfield %] - [% IF ( iteminformatio.mandatory ) %]<b>[% END %][% iteminformatio.marc_lib %][% IF ( iteminformatio.mandatory ) %] *</b>[% END %]</label>
339                     [% iteminformatio.marc_value %]
340                     <input type="hidden" name="itemid" value="1" />
341                     <input type="hidden" name="kohafield" value="[% iteminformatio.kohafield %]" />
342                     <input type="hidden" name="tag" value="[% iteminformatio.tag %]" />
343                     <input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" />
344                     <input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" />
345                     [% IF ( iteminformatio.ITEM_SUBFIELDS_ARE_NOT_REPEATABLE ) %]
346                         <span class="buttonPlus" onclick="CloneSubfield('subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]')">+</span>
347                     [% END %]
348
349                 </div></li>
350             [% END %]
351             </ol>
352             <a class="addItem" onclick="cloneItemBlock('itemblock[% item.itemBlockIndex %]')">Add</a>
353             <a class="delItem" style="display:none;" onclick="deleteItemBlock('itemblock[% item.itemBlockIndex %]')">Delete</a>
354         </div><!-- /iteminformation -->
355         </div>
356
357         [% END %] <!-- /items -->
358     </fieldset>
359     [% END %] <!-- items -->
360     <fieldset class="rows">
361         <legend>Accounting Details</legend>
362         <ol>
363             <li>
364                 [% IF ( close ) %]
365             <span class="label required">Quantity: </span>
366                     <input type="hidden" size="20" name="quantity" value="[% quantity %]" />[% quantity %]
367                 [% ELSE %]
368                 <label class="required" for="quantity">Quantity: </label>
369                     [% IF ( items ) %]
370                         <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" onchange="calcNeworderTotal();" />
371                     [% ELSE %]
372                         <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="calcNeworderTotal();" />
373                     [% END %]
374                 [% END %]
375                 <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
376                 <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="1" />
377             </li>
378             <li>
379                 [% IF ( close ) %]
380             <span class="label required">Fund: </span>
381                     <input type="hidden" size="20" name="budget_id" id="budget_id" value="[% budget_id %]" />[% Budget_name %]
382                 [% ELSE %]
383                 <label class="required" for="budget_id">Fund: </label>
384                 <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
385                         <option value="">Select a budget</option>
386                 [% FOREACH budget_loo IN budget_loop %]
387                     [% IF ( budget_loo.b_sel ) %]
388                         <option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
389                     [% ELSE %]
390                         [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id %]">[% budget_loo.b_txt %]</option>
391                         [% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive" style="display : none;">[% budget_loo.b_txt %]</option>    
392                         [% END %]
393                     [% END %]
394                 [% END %]
395                 </select>
396                 <label for="showallbudgets" style="float:none;width:auto;">&nbsp;Show all:</label>
397                 <input type="checkbox" id="showallbudgets" />
398                 [% END %]
399             </li>
400                 <li>
401                 [% IF ( close ) %]
402                         <span class="label">Currency: </span>
403                         <input type="hidden" size="10" name="currency" id="currency" value="[% currency %]" />[% currency %]
404                 [% ELSE %]
405                         <label for="currency">Currency:</label>
406                         <select name="currency" id="currency" onchange="calcNeworderTotal();">
407                         [% FOREACH loop_currencie IN loop_currencies %]
408                         [% 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 %]
409                         </select>
410                 [% END %]
411                 </li>
412             <li>
413                 [% IF ( close ) %]
414             <span class="label">Vendor price: </span>
415                     <input type="hidden" size="20" name="listprice" id="listprice" value="[% listprice %]" />[% listprice %]
416                 [% ELSE %]
417                 <label for="listprice">Vendor price: </label>
418                     <input type="text" size="20" name="listprice" id="listprice" value="[% listprice %]" onchange="calcNeworderTotal()" />
419                 [% END %]
420             </li>
421             [% UNLESS ( close ) %]
422             <li>
423                     <label for="uncertainprice">Uncertain price: </label>
424                     [% IF ( uncertainprice ) %]
425                     <input type="checkbox" name="uncertainprice"  id="uncertainprice" value="1" checked="checked" />
426                     [% ELSE %]
427                     <input type="checkbox" name="uncertainprice" id="uncertainprice" value="1" />
428                 [% END %]
429             </li>
430             [% END %]
431                         <li>
432                 [% IF ( close ) %]
433             <span class="label">Replacement cost: </span>
434                     <input type="hidden" size="20" name="rrp" id="rrp" value="[% rrp %]" />[% rrp %]
435                 [% ELSE %]
436                 <label for="rrp">Replacement cost: </label>
437                     <input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /> (adjusted for [% cur_active %])
438                 [% END %]
439             </li>
440             <li>
441                 [% IF ( close ) %]
442             <label for="ecost">Budgeted cost: </label>
443                     <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" readonly="readonly"  />
444                 [% ELSE %]
445                 <label for="ecost">Budgeted cost: </label>
446                     <input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" />
447                 [% END %]
448                 [% IF ( discount_2dp ) %]  (adjusted for [% discount_2dp %]% discount)  [% END %]
449
450             </li>
451             [% IF ( GST ) %]
452             <li>
453                 [% IF ( close ) %]
454             <label for="GST">Budgeted GST: </label>
455                 <input type="text" id="" size="20" name="gst" value="" id="GST" readonly="readonly" />
456                 [% ELSE %]
457                 <label for="GST">Budgeted GST: </label>
458                 <input type="text" size="20" name="gst" id="GST" value="" />
459                 [% END %]
460             </li>
461             [% END %]
462             <li>
463                 [% IF ( close ) %]
464             <label for="total">Total: </label>
465                 <input type="text" id="total" size="20" name="total" value="[% total %]" readonly="readonly" />
466                 [% ELSE %]
467                 <label for="total">Total: </label>
468                 <input type="text" id="total" size="20" name="total" value="[% total %]" /> (budgeted cost * quantity)
469                 [% END %]
470             </li>
471             <li>
472                 [% IF ( close ) %]
473             <label for="cost">Actual cost: </label>
474                 <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" readonly="readonly" />
475                 [% ELSE %]
476                 <label for="cost">Actual cost: </label>
477                 <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" />
478                 [% END %]
479             </li>
480             <li>
481                 <label for="notes">Notes: </label>
482                 <textarea id="notes" cols="30" rows="3" name="notes" >[% notes %]</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
487                 [% IF CGIsort1 %]
488                     <select id="sort1" size="1" name="sort1">
489                     [% FOREACH sort_opt IN CGIsort1 %]
490                        [% IF sort_opt.default %]
491                           <option value="[% sort_opt.value %]" selected="selected">[% sort_opt.label %]</option>
492                         [% ELSE %]
493                           <option value="[% sort_opt.value %]">[% sort_opt.label %]</option>
494                         [% END %]
495                     [% END %]
496                     </select>
497                 [% ELSE %]
498
499                     <input type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
500                 [% END %]
501             </li>
502             <li>
503                 <label for="sort2">Statistic 2: </label>
504
505                 [% IF CGIsort2 %]
506                     <select id="sort2" size="1" name="sort2">
507                     [% FOREACH sort_opt IN CGIsort2 %]
508                        [% IF sort_opt.default %]
509                           <option value="[% sort_opt.value %]" selected="selected">[% sort_opt.label %]</option>
510                         [% ELSE %]
511                           <option value="[% sort_opt.value %]">[% sort_opt.label %]</option>
512                         [% END %]
513                     [% END %]
514                     </select>
515                 [% ELSE %]
516                     <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
517                 [% END %]
518             </li>
519 </ol>
520     </fieldset>
521     <fieldset class="action">
522         <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 %]
523     </fieldset>
524 </form>
525 </div>
526 </div>
527 <div class="yui-b">
528 [% INCLUDE 'acquisitions-menu.inc' %]
529 </div>
530 </div>
531 [% INCLUDE 'intranet-bottom.inc' %]