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