Koha-FFZG#1517: Actual cost kod zaprimanja je 0 a trebalo bi prepisati Budgeted cost
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / orderreceive.tt
index 1e19f8b..6d0e090 100644 (file)
@@ -1,34 +1,30 @@
+[% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Acquisitions &rsaquo; Receipt summary for : [% name %] [% IF ( invoice ) %]invoice, [% invoice %][% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
+[% INCLUDE 'calendar.inc' %]
 [% INCLUDE 'additem.js.inc' %]
-<script type="text/javascript" src="[% themelang %]/js/additem.js"> </script>
+<script type="text/javascript" src="[% themelang %]/js/additem.js"></script>
+<script type="text/javascript" src="[% themelang %]/js/cataloging.js"></script>
+<script type="text/javascript" src="[% themelang %]/js/prevent_submit.js"></script>
 <script type="text/javascript">
 //<![CDATA[
     function Check(form) {
         [% IF (AcqCreateItemReceiving) %]
-            var total_errors=0;
-            $("input[name='mandatory'],select[name='mandatory']").each(function(i){
-                if($(this).val() == 1){
-                    var mandatory_field = $("input[name='field_value'],select[name='field_value']").eq(i);
-                    if(mandatory_field.val() == ''){
-                        mandatory_field.addClass("missing");
-                        total_errors++;
-                    }
-                }
-            });
-
-            var alertString;
-            if (total_errors==0) {
-                return true;
-            } else {
-                alertString  = _("Form not submitted because of the following problem(s)");
+            var total_errors = CheckMandatorySubfields(form);
+            if (total_errors != 0) {
+                var alertString = _("Form not submitted because of the following problem(s)");
                 alertString += "\n------------------------------------------------------------------------------------\n";
-                alertString += "\n- "+ total_errors+_(" mandatory fields empty (highlighted)");
+                alertString += "\n- " + _("%s mandatory fields empty (highlighted)").format(total_errors);
                 alert(alertString);
                 return false;
             }
 
+            if(check_additem('[% UniqueItemFields %]') == false){
+                alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
+                return false;
+            };
+
             // Remove last itemblock if it is not in items_list
             var lastitemblock = $("#outeritemblock > div:last");
             var tobedeleted = true;
@@ -43,7 +39,7 @@
             }
 
             if(check_additem('[% UniqueItemFields %]') == false){
-                alert(_('Duplicate values detected. Please correct the errors and resubmit.') );
+                alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
                 if(tobedeleted) {
                     $(lastitemblock).appendTo("#outeritemblock");
                 }
@@ -75,7 +71,9 @@
                             var tds = $("#item_"+itemnumber+" td");
                             for(var i=2; i<tds.length; i++) {
                                 var column = items_columns[i];
-                                $(tds[i]).text(item[column]);
+                                var text = item[column];
+                                if ( text == null ) text = '';
+                                $(tds[i]).text(text);
                             }
                         }
                     );
     $(document).ready(function() {
         [% IF (AcqCreateItemReceiving) %]
             cloneItemBlock(0, '[% UniqueItemFields %]');
-        [% ELSIF (AcqCreateItem == 'ordering') %]
+        [% ELSIF (AcqCreateItem == 'ordering') && not subscriptionid %]
             $("input[name='items_to_receive']").change(function() {
                 CalcQtyToReceive();
             });
                             <th>&nbsp;</th>
                             <th>&nbsp;</th>
                             <th>Barcode</th>
-                            <th>Home branch</th>
-                            <th>Holding branch</th>
+                            <th>Home library</th>
+                            <th>Holding library</th>
                             <th>Not for loan</th>
                             <th>Restricted</th>
                             <th>Location</th>
                             <th>Call number</th>
                             <th>Copy number</th>
-                            <th>Stock number</th>
+                            <th>Inventory number</th>
                             <th>Collection code</th>
                             <th>Item type</th>
                             <th>Materials</th>
             </div>
         </div>
 
-        <fieldset class="rows" id="itemfieldset">
-            <legend>Item</legend>
-            [% IF ( NoACQframework ) %]
-                <p class="required">
-                    No ACQ framework, using default. You should create a
-                    framework with code ACQ, the items framework would be
-                    used
-                </p>
-            [% END %]
-            <div id="outeritemblock"></div>
-        </fieldset>
+        [% UNLESS subscriptionid %]
+          <fieldset class="rows" id="itemfieldset">
+              <legend>Item</legend>
+              [% IF ( NoACQframework ) %]
+                  <p class="required">
+                      No ACQ framework, using default. You should create a
+                      framework with code ACQ, the items framework would be
+                      used
+                  </p>
+              [% END %]
+              <div id="outeritemblock"></div>
+          </fieldset>
+        [% END %]
     [% ELSIF (AcqCreateItem == 'ordering') %]
         [% IF (items.size) %]
             <h5>Items</h5>
                             <th>Location</th>
                             <th>Call number</th>
                             <th>Copy number</th>
-                            <th>Stock number</th>
+                            <th>Inventory number</th>
                             <th>Collection code</th>
                             <th>Item type</th>
                             <th>Materials</th>
         [% END %]
     [% END %]
     <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
+    <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
     <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
-    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
     <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
-    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
-    <input type="hidden" name="freight" value="[% freight %]" />
-    <input type="hidden" name="gst" value="[% gst %]" />
+    <input type="hidden" name="gstrate" value="[% gstrate %]" />
        </div>
        <div class="yui-u">
     <fieldset class="rows">
     <legend>Accounting details</legend>
-       <ol>
-       <li><label for="datereceived">Date received: </label><span> [% datereceived %] </span></li>
-       <li><label for="bookfund">Budget: </label><span> [% bookfund %] </span></li>
+        <ol>
+            <li>
+                <label for="datereceived">Date received: </label>
+                <input type="text" size="10" id="datereceived" name="datereceived" value="[% datereceived | $KohaDates %]" class="datepicker" />
+            </li>
+       <li><label for="bookfund">Fund: </label><select id="bookfund" name="bookfund">
+            <option value="">Keep current ([% budget_period_description %] - [% bookfund %])</option>
+            [% FOREACH period IN budget_loop %]
+                <optgroup label="[% period.description %]">
+                [% FOREACH fund IN period.funds %]
+                    [% IF ( fund.b_sel ) %]
+                        <option value="[% fund.b_id %]" selected="selected">[% fund.b_txt %]</option>
+                    [% ELSE %]
+                        <option value="[% fund.b_id %]">[% fund.b_txt %]</option>
+                    [% END %]
+                [% END %]
+            [% END %]
+       </select></li>
+       <li><label>&nbsp;</label><span>(Current: [% budget_period_description %] - [% bookfund %])</span></li>
        <li><label for="creator">Created by: </label><span> [% IF ( memberfirstname and membersurname ) %][% IF ( memberfirstname ) %][% memberfirstname %][% END %] [% membersurname %][% ELSE %]No name[% END %]</span></li>
        <li><label for="quantity_to_receive">Quantity to receive: </label><span class="label">
-           [% IF ( edit ) %]
+           [% IF ( edit and not subscriptionid) %]
                <input type="text" id="quantity_to_receive" name="quantity" value="[% quantity %]" />
-           [% ELSE %]
+           [% ELSE%]
                <input type="text" readonly="readonly" id="quantity_to_receive" name="quantity" value="[% quantity %]" />
            [% END %]
            </span></li>
         <li><label for="quantity">Quantity received: </label>
           [% IF (AcqCreateItemReceiving) %]
-            <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="0" />
+            [% IF ( subscriptionid ) %]
+              <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="1" />
+            [% ELSE %]
+              <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="0" />
+            [% END %]
           [% ELSE %]
             [% IF ( quantityreceived ) %]
                 [% IF ( edit ) %]
                     <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceived %]" />
-                    <input id="origquantityrec" READONLY type="hidden" name="origquantityrec" value="[% quantityreceived %]" />
-                [% ELSE %]
-                [% IF ( items ) %]
-                    <input READONLY type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceivedplus1 %]" />
+                    <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% quantityreceived %]" />
                 [% ELSE %]
-                    <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceivedplus1 %]" />
-                [% END %]
-                <input id="origquantityrec" READONLY type="hidden" name="origquantityrec" value="[% quantityreceived %]" />
+                    [% IF ( items ) %]
+                        <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceivedplus1 %]" />
+                    [% ELSE %]
+                        <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceivedplus1 %]" />
+                    [% END %]
+                    <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% quantityreceived %]" />
                 [% END %]
             [% ELSE %]
-                [% IF ( items ) %]
-                    <input type="text" id="quantity" size="20" name="quantityrec" value="1" />
+                [% IF ( subscriptionid ) %]
+                    <input type="text" readonly="readonly" id="quantity" size="20" name="quantityrec" value="1" />
                 [% ELSE %]
-                    <input type="text" size="20" id="quantity" name="quantityrec" value="1" />
+                    <input type="text" id="quantity" size="20" name="quantityrec" value="1" />
                 [% END %]
-                <input id="origquantityrec" READONLY type="hidden" name="origquantityrec" value="0" />
+                <input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="0" />
             [% END %]
             <div id="qtyrecerror" style="display:none">
                 <p class="error">Warning, you have entered more items than expected.
         <li><label for="rrp">Replacement cost: </label><input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /></li>
         <li><label for="ecost">Budgeted cost: </label><input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" /></li>
         <li><label for="cost">Actual cost:</label>
-        [% IF ( unitprice ) %]
+        [% IF ( unitprice > 0 ) %]
          <input type="text" size="20" name="cost" id="cost" value="[% unitprice %]" />
         [% ELSE %]
             <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
-        [% END %]</li></ol>
-        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
-        <input type="hidden" name="invoice" value="[% invoice %]" />
+        [% END %]</li>
+        <li><label for="order_internalnote">Internal note: </label><textarea name="order_internalnote" width="40" rows="8" >[% order_internalnote %]</textarea></li>
+        [% IF order_vendornote %]
+            <li><label for="order_vendornote">Vendor note: </label><span>[% order_vendornote %]</span></li>
+        [% END %]
+        </ol>
     </fieldset>
 
 </div>
 </div><div class="yui-g"><fieldset class="action">
-        <input type="submit"  value="Save" />
-        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% supplierid %]&amp;invoice=[% invoice %]&amp;gst=[% gst %]&amp;freight=[% freight %]">Cancel</a>
+        <input type="submit"  value="Save" class="button" accesskey="w" />
+        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]&sticky_filters=1">Cancel</a>
 </fieldset></div>    </form>
 [% ELSE %]
-<div id="acqui_acquire_orderlist">
-    <table>
-    <tr>
-        <th>Basket</th>
-        <th>ISBN</th>
-        <th>Title</th>
-        <th>Author</th>
-        <th>Qty</th>
-        <th>Received</th>
-    </tr>
-    [% FOREACH loo IN loop %]
-        <tr>
-            <td>[% loo.basketno %]</td>
-            <td>[% loo.isbn %]</td>
-         <td><a href="orderreceive.pl?datereceived=[% loo.datereceived %]&amp;receive=[% loo.ordernumber %]&amp;biblio=[% loo.biblionumber %]&amp;invoice=[% loo.invoice %]&amp;freight=[% loo.freight %]&amp;gst=[% loo.gst %]&amp;id=[% loo.id %]">[% loo.title |html %]</a></td>
-            <td>[% loo.author %]</td>
-            <td>[% loo.quantity %]</td>
-            <td>[% loo.quantityreceived %]</td>
-        </tr>
-    [% END %]
-    </table>
-</div>
+    This ordernumber does not exist.
 [% END %]
 
 </div>