Bug 7113: Standardize vendor id name in templates and scripts
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / neworderempty.tt
index d6c8459..a27d151 100644 (file)
@@ -46,26 +46,68 @@ function Check(ff) {
     }
 
     if ( ff.field_value ) {
+        var barcodes = [];
         var empty_item_mandatory = 0;
         for (i = 0; i < ff.field_value.length; i++) {
             //alert("i = " + i + " => " + ff.kohafield[i] );
             if (ff.field_value[i].value.length == 0 && ff.mandatory[i].value == 1) {
                 empty_item_mandatory++;
             }
+            if(ff.subfield[i].value === '[% barcode_subfield %]' && ff.field_value[i].value.length != 0) {
+                barcodes.push(ff.field_value[i].value);
+            }
         }
         if (empty_item_mandatory > 0) {
             ok = 1;
             _alertString +=
                 "\n- " + empty_item_mandatory + _(" item mandatory fields empty");
         }
+
+        if(barcodes.length > 0) {
+            // Check for duplicate barcodes in the form
+            barcodes = barcodes.sort();
+            for(var i=0; i<barcodes.length-1; i++) {
+                if(barcodes[i] == barcodes[i+1]) {
+                    ok = 1;
+                    _alertString += "\n- " + _("The barcode ") + barcodes[i] + _(" is used more than once in the form. Every barcode must be unique");
+                }
+            }
+
+            // Check for duplicate barcodes in the database via an ajax call
+            $.ajax({
+                url: "/cgi-bin/koha/acqui/check_duplicate_barcode_ajax.pl",
+                async:false,
+                method: "post",
+                data: {barcodes : barcodes},
+                dataType: 'json',
+
+                error: function(xhr) {
+                    alert("Error: \n" + xhr.responseText);
+                },
+                success: function(json) {
+                    switch(json.status) {
+                        case 'UNAUTHORIZED':
+                            ok = 1;
+                            _alertString += "\n- " + _("Error: Duplicate barcode verification failed. Insufficient user permissions.");
+                            break;
+                        case 'DUPLICATES':
+                            ok = 1;
+                            $.each(json.barcodes, function(index, barcode) {
+                                _alertString += "\n- " + _("The barcode ") + barcode + _(" already exists in the database");
+                            });
+                            break;
+                    }
+                },
+            });
+        }
     }
 
-if (ok) {
+    if (ok) {
         alert(_alertString);
-    return false;
+        return false;
     }
 
-ff.submit();
+    ff.submit();
 
 }
 
@@ -110,7 +152,7 @@ $(document).ready(function()
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'acquisitions-search.inc' %]
 
-<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>
+<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>
 
 <div id="doc3" class="yui-t2">
 
@@ -124,7 +166,6 @@ $(document).ready(function()
     [% ELSE %]
         New order
     [% END %]
-        [% IF ( suggestionid ) %](defined from suggestion #[% suggestionid %])[% END %]
 </h2>
 
 [% IF ( basketno ) %]
@@ -222,6 +263,16 @@ $(document).ready(function()
                 <input type="text" size="50" name="publishercode" id="publishercode" value="[% publishercode %]" />
             [% END %]
         </li>
+        <li>
+            [% IF ( biblionumber ) %]
+            <span class="label">Edition: </span>
+                <input type="hidden" size="20" name="editionstatement" id="editionstatement" value="[% editionstatement %]" />[% editionstatement %]
+
+            [% ELSE %]
+            <label for="editionstatement">Edition: </label>
+                <input type="text" size="20" name="editionstatement" id="editionstatement" value="[% editionstatement %]" />
+            [% END %]
+        </li>
         <li>
             [% IF ( biblionumber ) %]
             <span class="label">Publication year: </span>
@@ -249,8 +300,38 @@ $(document).ready(function()
                 <input type="text" size="50" name="series" id="series" value="[% seriestitle %]" />
             [% END %]
         </li>
+        </li>
+            [% UNLESS ( biblionumber ) %]
+            [% IF ( itemtypeloop ) %]
+            <li>
+                <span class="label">Item type:</span>
+                <select name="itemtype" style="width:12em;">
+                [% FOREACH itemtype IN itemtypeloop %]
+                    [% IF ( itemtype.selected ) %]
+                        <option value="[% itemtype.itemtype %]" selected="selected">[% itemtype.description %]</option>
+                    [% ELSE %]
+                        <option value="[% itemtype.itemtype %]">[% itemtype.description %]</option>
+                    [% END %]
+                [% END %]
+                </select>
+            </li>
+            [% END %]
+            [% END %]
         </ol>
     </fieldset>
+
+    [% IF ( suggestionid ) %]
+        <fieldset class="rows">
+        <legend>Suggestion</legend>
+        <ol>
+          <li>
+            <span class="label">Suggested by: </span>
+            [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]">suggestion #[% suggestionid %]</a>)
+          </li>
+        </ol>
+        </fieldset>
+    [% END %]
+
     [% IF ( items ) %]
     <fieldset class="rows">
         <legend>Item</legend>
@@ -261,8 +342,8 @@ $(document).ready(function()
         [% FOREACH item IN items %]
         <div id="outeritemblock">
         <div id="itemblock">
-            <ol>[% FOREACH iteminformatio IN item.iteminformation %]<li>
-                <div class="subfield_line" style="[% iteminformatio.hidden %];" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]">
+            <ol>[% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];">
+                <div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]">
 
                     <label>[% iteminformatio.subfield %] - [% IF ( iteminformatio.mandatory ) %]<b>[% END %][% iteminformatio.marc_lib %][% IF ( iteminformatio.mandatory ) %] *</b>[% END %]</label>
                     [% iteminformatio.marc_value %]
@@ -278,8 +359,8 @@ $(document).ready(function()
                 </div></li>
             [% END %]
             </ol>
-            <a style="cursor: pointer; color: grey; font-size: 180%;" onclick="cloneItemBlock('itemblock[% item.itemBlockIndex %]')">+</a>
-            <a style="display:none; cursor: pointer; color: grey; font-size: 180%;" onclick="deleteItemBlock('itemblock[% item.itemBlockIndex %]')">-</a>
+            <a class="addItem" onclick="cloneItemBlock('itemblock[% item.itemBlockIndex %]')">Add</a>
+            <a class="delItem" style="display:none;" onclick="deleteItemBlock('itemblock[% item.itemBlockIndex %]')">Delete</a>
         </div><!-- /iteminformation -->
         </div>
 
@@ -306,11 +387,12 @@ $(document).ready(function()
             </li>
             <li>
                 [% IF ( close ) %]
-            <span class="label">Fund: </span>
+            <span class="label required">Fund: </span>
                     <input type="hidden" size="20" name="budget_id" id="budget_id" value="[% budget_id %]" />[% Budget_name %]
                 [% ELSE %]
-                <label for="budget_id">Fund: </label>
+                <label class="required" for="budget_id">Fund: </label>
                 <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
+                        <option value="">Select a budget</option>
                 [% FOREACH budget_loo IN budget_loop %]
                     [% IF ( budget_loo.b_sel ) %]
                         <option value="[% budget_loo.b_id %]" selected="selected">[% budget_loo.b_txt %]</option>
@@ -399,10 +481,10 @@ $(document).ready(function()
             <li>
                 [% IF ( close ) %]
             <label for="cost">Actual cost: </label>
-                <input type="text" id="cost" size="20" name="cost" value="[% ecost %]" readonly="readonly" />
+                <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" readonly="readonly" />
                 [% ELSE %]
                 <label for="cost">Actual cost: </label>
-                <input type="text" id="cost" size="20" name="cost" value="[% ecost %]" />
+                <input type="text" id="unitprice" size="20" name="unitprice" value="[% unitprice %]" />
                 [% END %]
             </li>
             <li>
@@ -412,8 +494,16 @@ $(document).ready(function()
             <li><div class="hint">The 2 following fields are available for your own usage. They can be useful for statistical purposes</div>
                 <label for="sort1">Statistic 1: </label>
 
-                [% IF ( CGIsort1 ) %]
-                    [% CGIsort1 %]
+                [% IF CGIsort1 %]
+                    <select id="sort1" size="1" name="sort1">
+                    [% FOREACH sort_opt IN CGIsort1 %]
+                       [% IF sort_opt.default %]
+                          <option value="[% sort_opt.value %]" selected="selected">[% sort_opt.label %]</option>
+                        [% ELSE %]
+                          <option value="[% sort_opt.value %]">[% sort_opt.label %]</option>
+                        [% END %]
+                    [% END %]
+                    </select>
                 [% ELSE %]
 
                     <input type="text" id="sort1" size="20" name="sort1" value="[% sort1 %]" />
@@ -422,8 +512,16 @@ $(document).ready(function()
             <li>
                 <label for="sort2">Statistic 2: </label>
 
-                [% IF ( CGIsort2 ) %]
-                    [% CGIsort2 %]
+                [% IF CGIsort2 %]
+                    <select id="sort2" size="1" name="sort2">
+                    [% FOREACH sort_opt IN CGIsort2 %]
+                       [% IF sort_opt.default %]
+                          <option value="[% sort_opt.value %]" selected="selected">[% sort_opt.label %]</option>
+                        [% ELSE %]
+                          <option value="[% sort_opt.value %]">[% sort_opt.label %]</option>
+                        [% END %]
+                    [% END %]
+                    </select>
                 [% ELSE %]
                     <input type="text" id="sort2" size="20" name="sort2" value="[% sort2 %]" />
                 [% END %]