Bug 19754: Move template JavaScript to the footer: Acquisitions, part 2
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / orderreceive.tt
index cd52267..8ec42ad 100644 (file)
 [% USE KohaDates %]
 [% USE Branches %]
 [% USE Price %]
+[% SET footerjs = 1 %]
 [% 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="[% interface %]/[% theme %]/js/additem_[% KOHA_VERSION %].js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/cataloging_[% KOHA_VERSION %].js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/prevent_submit_[% KOHA_VERSION %].js"></script>
-<script type="text/javascript">
-//<![CDATA[
-    function Check(form) {
-        [% IF (AcqCreateItemReceiving) %]
-            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- " + _("%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;
-            var listitems = $("#items_list tr");
-            $(listitems).each(function(){
-                if($(this).attr('idblock') == $(lastitemblock).attr('id')){
-                    tobedeleted = false;
-                }
-            });
-            if(tobedeleted){
-                $(lastitemblock).remove();
-            }
-
-            if(check_additem('[% UniqueItemFields %]') == false){
-                alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
-                if(tobedeleted) {
-                    $(lastitemblock).appendTo("#outeritemblock");
-                }
-                return false;
-            };
-        [% END %]
-
-        return true;
-    }
-
-    [% IF (AcqCreateItem == 'ordering') %]
-        var items_columns = [null, null, 'barcode', 'homebranchname',
-            'holdingbranchname', 'notforloan', 'restricted', 'location',
-            'itemcallnumber', 'copynumber', 'stocknumber', 'collection',
-            'itemtype', 'materials', 'itemnotes'];
-
-        function PopupEditPage(biblionumber, itemnumber) {
-            var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber="
-                + biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem";
-            var w = window.open(url);
-            var watchClose = setInterval(function() {
-                if (w.closed) {
-                    clearTimeout(watchClose);
-                    $.getJSON('/cgi-bin/koha/catalogue/getitem-ajax.pl',
-                        {
-                            'itemnumber': itemnumber
-                        },
-                        function(item) {
-                            var tds = $("#item_"+itemnumber+" td");
-                            for(var i=2; i<tds.length; i++) {
-                                var column = items_columns[i];
-                                var text = item[column];
-                                if ( text == null ) text = '';
-                                $(tds[i]).text(text);
-                            }
-                        }
-                    );
-                }
-            }, 500);
-        }
-
-        function CalcQtyToReceive() {
-            var qty = $("input[name='items_to_receive']:checked").length;
-            $("#quantity").val(qty);
-        }
-
-        function CheckNItems(n) {
-            $("input[name='items_to_receive']").each(function() {
-                $(this).prop('checked', false);
-            });
-            $("input[name='items_to_receive']:lt("+n+")").each(function () {
-                $(this).prop('checked', true);
-            });
-        }
-    [% END %]
-
-    $(document).ready(function() {
-        [% IF (AcqCreateItemReceiving) %]
-            cloneItemBlock(0, '[% UniqueItemFields %]');
-        [% ELSIF (AcqCreateItem == 'ordering') && not subscriptionid %]
-            $("input[name='items_to_receive']").change(function() {
-                CalcQtyToReceive();
-            });
-            CalcQtyToReceive();
-            $("#quantity").keyup(function() {
-                var qty = parseInt($("#quantity").val());
-                var qtyto = parseInt($("#quantity_to_receive").val());
-                if(qty > qtyto) {
-                    $("#qtyrecerror").show();
-                } else {
-                    $("#qtyrecerror").hide();
-                }
-                CheckNItems($(this).val());
-            });
-        [% END %]
-    });
-//]]>
-</script>
 </head>
+
 <body id="acq_orderreceive" class="acq">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'acquisitions-search.inc' %]
 [% INCLUDE 'acquisitions-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/acquisitions-menu_[% KOHA_VERSION %].js"></script>
+[% INCLUDE 'calendar.inc' %]
+    [% INCLUDE 'additem.js.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/additem_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/cataloging_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/prevent_submit_[% KOHA_VERSION %].js"></script>
+    <script type="text/javascript">
+        function Check(form) {
+            [% IF (AcqCreateItemReceiving) %]
+                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- " + _("%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;
+                var listitems = $("#items_list tr");
+                $(listitems).each(function(){
+                    if($(this).attr('idblock') == $(lastitemblock).attr('id')){
+                        tobedeleted = false;
+                    }
+                });
+                if(tobedeleted){
+                    $(lastitemblock).remove();
+                }
+
+                if(check_additem('[% UniqueItemFields %]') == false){
+                    alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
+                    if(tobedeleted) {
+                        $(lastitemblock).appendTo("#outeritemblock");
+                    }
+                    return false;
+                };
+            [% END %]
+
+            return true;
+        }
+
+        [% IF (AcqCreateItem == 'ordering') %]
+            var items_columns = [null, null, 'barcode', 'homebranchname',
+                'holdingbranchname', 'notforloan', 'restricted', 'location',
+                'itemcallnumber', 'copynumber', 'stocknumber', 'collection',
+                'itemtype', 'materials', 'itemnotes'];
+
+            function PopupEditPage(biblionumber, itemnumber) {
+                var url = "/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber="
+                    + biblionumber + "&itemnumber=" + itemnumber + "&popup=1#edititem";
+                var w = window.open(url);
+                var watchClose = setInterval(function() {
+                    if (w.closed) {
+                        clearTimeout(watchClose);
+                        $.getJSON('/cgi-bin/koha/catalogue/getitem-ajax.pl',
+                            {
+                                'itemnumber': itemnumber
+                            },
+                            function(item) {
+                                var tds = $("#item_"+itemnumber+" td");
+                                for(var i=2; i<tds.length; i++) {
+                                    var column = items_columns[i];
+                                    var text = item[column];
+                                    if ( text == null ) text = '';
+                                    $(tds[i]).text(text);
+                                }
+                            }
+                        );
+                    }
+                }, 500);
+            }
+
+            function CalcQtyToReceive() {
+                var qty = $("input[name='items_to_receive']:checked").length;
+                $("#quantity").val(qty);
+            }
+
+            function CheckNItems(n) {
+                $("input[name='items_to_receive']").each(function() {
+                    $(this).prop('checked', false);
+                });
+                $("input[name='items_to_receive']:lt("+n+")").each(function () {
+                    $(this).prop('checked', true);
+                });
+            }
+        [% END %]
+
+        $(document).ready(function() {
+            [% IF (AcqCreateItemReceiving) %]
+                cloneItemBlock(0, '[% UniqueItemFields %]');
+            [% ELSIF (AcqCreateItem == 'ordering') && not subscriptionid %]
+                $("input[name='items_to_receive']").change(function() {
+                    CalcQtyToReceive();
+                });
+                CalcQtyToReceive();
+                $("#quantity").keyup(function() {
+                    var qty = parseInt($("#quantity").val());
+                    var qtyto = parseInt($("#quantity_to_receive").val());
+                    if(qty > qtyto) {
+                        $("#qtyrecerror").show();
+                    } else {
+                        $("#qtyrecerror").hide();
+                    }
+                    CheckNItems($(this).val());
+                });
+            [% END %]
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]