Bug 10862: (follow-up) fix a couple of issues
[koha_fer] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / addorderiso2709.tt
index f0187d5..6f51956 100644 (file)
@@ -7,10 +7,11 @@
  › Batch list
 [% END %]
 </title>
+[% INCLUDE 'greybox.inc' %]
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
 [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'datatables.inc' %]
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
 <script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
 <script type="text/JavaScript">
 //<![CDATA[
             "aaSorting": []
         } ) );
 
+        // keep copy of the inactive budgets
+        disabledBudgetsCopy = $("select[name='all_budget_id']").html();
+        $("select[name='all_budget_id'] .b_inactive").remove();
+        $("select[name='budget_id'] .b_inactive").remove();
+
+        $("#showallbudgets").click(function() {
+            if ($(this).is(":checked")) {
+                $("select[name='budget_id']").html(disabledBudgetsCopy)
+            }
+            else {
+                $("select[name='budget_id'] .b_inactive").remove();
+            }
+        });
+
+        $("#all_showallbudgets").click(function() {
+            if ($(this).is(":checked")) {
+                $("select[name='all_budget_id']").html(disabledBudgetsCopy);
+            }
+            else {
+                $("select[name='all_budget_id'] .b_inactive").remove();
+            }
+        });
+
         $("select[name='budget_id']").change(function(){
             var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
             var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
-            var destination_sort1 = $(this).siblings('span.sort1').find('input[name="sort1"]');
-            var sort1 = $(destination_sort1).val();
+            var destination_sort1 = $(this).parents('fieldset').find('li.sort1').find('input[name="sort1"]');
+            var sort1 = $(destination_sort1).val() || "";
             if ( destination_sort1.length < 1 ) {
-                destination_sort1 = $(this).siblings('span.sort1').find('select[name="sort1"]');
+                destination_sort1 = $(this).parents('fieldset').find('li.sort1 > select[name="sort1"]');
             }
-            var destination_sort2 = $(this).siblings('span.sort2').find('input[name="sort2"]');
-            var sort2 = $(destination_sort2).val();
+            var destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('input[name="sort2"]');
+            var sort2 = $(destination_sort2).val() || "";
             if ( destination_sort2.length < 1 ) {
-                destination_sort2 = $(this).siblings('span.sort2').find('select[name="sort2"]');
+                destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('select[name="sort2"]');
             }
             getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
 
             $(this).parent().siblings('li').find('input[name="sort2"]').attr('name', 'all_sort2');
         } );
 
+        $("select[name='all_budget_id']").change();
+
+        $("#records_to_import fieldset.rows ol").hide();
         $('input:checkbox[name="import_record_id"]').change(function(){
+            var container = $(this).parents("fieldset");
             if ( $(this).is(':checked') ) {
-                $(this).parent().addClass("selected");
-                $(this).parent().removeClass("unselected");
+                $(container).addClass("selected");
+                $(container).removeClass("unselected");
+                $(container).find("ol").toggle(true);
             } else {
-                $(this).parent().addClass("unselected");
-                $(this).parent().removeClass("selected");
+                $(container).addClass("unselected");
+                $(container).removeClass("selected");
+                $(container).find("ol").toggle(false);
             }
         } );
 
             return false;
         });
 
+        $("#Aform").on("submit", function(){
+            if ( $("input:checkbox[name='import_record_id']:checked").length < 1 ) {
+                alert(_("There is no record selected"));
+                return false;
+            }
+
+            var error = 0;
+            $("input:checkbox[name='import_record_id']:checked").parents('fieldset').find('input[name="quantity"]').each(function(){
+                if ( $(this).val().length < 1 || isNaN( $(this).val() ) ) {
+                    error++;
+                }
+            });
+            if ( error > 0 ) {
+                alert(error + " " + _("quantity values are not filled in or are not numbers"));
+                return false;
+            }
+
+            return disableUnchecked($(this));
+        });
+        $('#tabs').tabs();
     });
 
     function disableUnchecked(form){
-        $("div.biblio.unselected").each(function(){
-            $(this).find('select').attr('disabled', 'disabled');
-            $(this).find('input').attr('disabled', 'disabled');
+        $("fieldset.biblio.unselected").each(function(){
+            $(this).remove();
         });
-        form.submit();
+        return 1;
     }
 //]]>
 </script>
                 <h1>Add orders from [% comments %]
                     ([% file_name %] staged on [% upload_timestamp | $KohaDates with_hours => 1 %])
                 </h1>
-                <div>
-                    <span class="checkall"><a id="checkAll" href="#">Check All</a></span>
-                    <span class="uncheckall"><a id="unCheckAll" href="#">Uncheck All</a></span>
-                    <form action="/cgi-bin/koha/acqui/addorderiso2709.pl" method="post" id="Aform" onsubmit="disableUnchecked(this); return false;">
+                <form action="/cgi-bin/koha/acqui/addorderiso2709.pl" method="post" id="Aform">
+                <div id="tabs" class="toptabs">
+                  <ul>
+                    <li><a href="#records_to_import">Select to import</a></li>
+                    <li><a href="#items_info" class="items_info">Item information</a></li>
+                    <li><a href="#accounting_details">Default accounting details</a></li>
+                  </ul>
+
+                  <div id="records_to_import">
+                    <span class="checkall"><a id="checkAll" href="#">Check all</a></span>
+                    <span class="uncheckall"><a id="unCheckAll" href="#">Uncheck all</a></span>
+                    <label for="showallbudgets" style="float:none;width:auto;">&nbsp;Show all funds:</label>
+                    <input type="checkbox" id="showallbudgets" />
                         <input type="hidden" name="op" value="import_records"/>
                         <input type="hidden" name="basketno" value="[% basketno %]" />
                         <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
                         [% END %]
 
                         [% FOREACH biblio IN biblio_list %]
-                        <div class="biblio unselected" style="border-radius: 5px 5px; -moz-border-radius: 5px; padding: 5px; margin:5px; border-style : solid; border-color : grey; border-width:1px;">
-                            <input type="checkbox" name="import_record_id" id="record_[% biblio.import_record_id %]" value="[% biblio.import_record_id %]" />
-                            <input type="hidden" value="[% biblio.rrp %]" name="rrp" />
-                            <label for="record_[% biblio.import_record_id %]"><span class="citation" style="font-weight:bold;">[% biblio.citation %]</span></label>
-                            <span class="match" style="display:block;">
+                        <fieldset class="biblio unselected rows" style="float:none;">
+                          <legend>
+                            <label for="record_[% biblio.import_record_id %]" style="width:auto;">
+                              <input type="checkbox" name="import_record_id" id="record_[% biblio.import_record_id %]" value="[% biblio.import_record_id %]" />
+                              <span class="citation">[% biblio.citation %]</span>
+                            </label>
+                            <span class="links" style="font-weight: normal;">
+                              ( <a href="/cgi-bin/koha/catalogue/showmarc.pl?importid=[% biblio.import_record_id %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;importid=[% biblio.import_record_id %]" title="Card" rel="gb_page_center[600,500]">Card</a> | <a href="/cgi-bin/koha/acqui/neworderempty.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]&amp;breedingid=[% biblio.import_record_id %]&amp;import_batch_id=[% biblio.import_batch_id %]&amp;biblionumber=[% biblio.match_biblionumber %]">Add order</a> )
+                            </span>
+                          </legend>
+                          <ol>
+                            <li class="status">
+                              <span class="match">
                                 [% IF ( biblio_lis.overlay_status == 'no_match' ) %]
                                     No match
                                 [% ELSIF ( biblio_lis.overlay_status == 'match_applied' ) %]
                                 [% ELSE %]
                                     [% biblio_lis.overlay_status %]
                                 [% END %]
-                            </span>
-                            [% IF ( biblio.match_biblionumber ) %]
-                                Matches biblio [% biblio.match_biblionumber %] (score = [% biblio.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.match_biblionumber %]">[% biblio.match_citation %]</a>
-                            [% END %]
-                            <span class="quantity" style="display:block;">
-                                Quantity: <input type="text" value="[% biblio.quantity %]" name="quantity" />
-                            </span>
-                            <span class="price" style="display:block;">
-                                Price: <input type="text" value="[% biblio.price %]" name="price" />
-                            </span>
-                            <span class="discount" style="display:block;">
-                                Discount: <input type="text" value="[% biblio.discount %]" name="discount" />
-                            </span>
-                            <span class="budget" style="display:block;">
+                                [% IF ( biblio.match_biblionumber ) %]
+                                  Matches biblio [% biblio.match_biblionumber %] (score = [% biblio.match_score %]): <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.match_biblionumber %]">[% biblio.match_citation %]</a>
+                                [% END %]
+                              </span>
+                            </li>
+                            <li class="quantity">
+                                <label for="quantity_record_[% biblio.import_record_id %]" class="required">Quantity: </label>
+                                <input id="quantity_record_[% biblio.import_record_id %]" type="text" value="[% biblio.quantity.length ? biblio.quantity : 1 %]" name="quantity" />
+                            </li>
+                            <li class="price">
+                                <label for="price_record_[% biblio.import_record_id %]">Price: </label>
+                                <input id="price_record_[% biblio.import_record_id %]" type="text" value="[% biblio.price %]" name="price" />
+                            </li>
+                            <li class="discount">
+                                <label for="discount_record_[% biblio.import_record_id %]">Discount: </label>
+                                <input id="discount_record_[% biblio.import_record_id %]" type="text" value="[% biblio.discount %]" name="discount" size="6" /> %
+                                (If empty, discount rate from vendor will be used)
+                            </li>
+                            <li class="budget">
+                                <label for="fund_record_[% biblio.import_record_id %]">Fund: </label>
                                 [% IF ( close ) %]
-                                <span class="label">Budget: </span>
-                                    <input type="hidden" size="20" name="budget_id" value="[% budget_id %]" />[% Budget_name %]
+                                  <input type="hidden" size="20" name="budget_id" value="[% budget_id %]" />[% Budget_name %]
                                 [% ELSE %]
-                                <label for="budget_id">Budget: </label>
-                                <select size="1" name="budget_id">
-                                    <option value=""></option>
+                                  <select id="fund_record_[% biblio.import_record_id %]" size="1" name="budget_id">
+                                    <option value="">Select a fund</option>
                                     [% FOREACH budget IN budget_loop %]
                                         [% IF ( budget.b_id == biblio.budget_id ) %]
+                                          [% IF budget.b_active %]
                                             <option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]" selected="selected">[% budget.b_txt %]</option>
+                                          [% ELSE %]
+                                            <option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]" selected="selected">[% budget.b_txt %] (inactive)</option>
+                                          [% END %]
                                         [% ELSE %]
-                                            <option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]">[% budget.b_txt %]</option>
+                                            [% IF budget.b_active %]<option value="[% budget.b_id %]" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]">[% budget.b_txt %]</option>
+                                            [% ELSE %]<option value="[% budget.b_id %]" class="b_inactive" data-sort1-authcat="[% budget.b_sort1_authcat %]" data-sort2-authcat="[% budget.b_sort2_authcat %]">[% budget.b_txt %] (inactive)</option>
+                                            [% END %]
                                         [% END %]
                                     [% END %]
-                                </select>
+                                  </select>
                                 [% END %]
-                                <span class="sort1">
-                                    <label for="sort1">Planning value1: </label>
-                                    <input type="text" id="sort1" size="20" name="sort1" value="[% biblio.sort1 %]" />
-                                </span>
-                                <span class="sort2">
-                                    <label for="sort2">Planning value2: </label>
-                                    <input type="text" id="sort2" size="20" name="sort2" value="[% biblio.sort2 %]" />
-                                </span>
-                            </span>
-                        </div>
+                            </li>
+                            <li class="sort1">
+                                <label for="sort1_record_[% biblio.import_record_id %]">Statistic 1: </label>
+                                <input id="sort1_record_[% biblio.import_record_id %]" type="text" id="sort1" size="20" name="sort1" value="[% biblio.sort1 %]" />
+                            </li>
+                            <li class="sort2">
+                                <label for="sort2_record_[% biblio.import_record_id %]">Statistic 2: </label>
+                                <input id="sort2_record_[% biblio.import_record_id %]" type="text" id="sort2" size="20" name="sort2" value="[% biblio.sort2 %]" />
+                            </li>
+                          </ol>
+                        </fieldset>
                         [% END %]
-                        <div>
-                        <h2>Import all</h2>
-                        <p>Import all the lines in the basket with the following parameters:</p>
+                      </div>
+                      <div id="items_info">
+                        <h2>Item information</h2>
+                        <p>Import all the checked items in the basket with the following parameters:</p>
 
                         [% IF ( items ) %]
-                        <fieldset class="rows">
+                        <fieldset class="rows" style="float:none;">
                             <legend>Item</legend>
                             [% IF ( NoACQframework ) %]
                                 <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
                             [% END %] <!-- /items -->
                         </fieldset>
                         [% END %] <!-- items -->
-
-                        <fieldset class="rows">
+                      </div>
+                      <div id="accounting_details">
+                        <p>Import all the checked items in the basket with the following accounting details (used only if no information is filled for the item):</p>
+                        <fieldset class="rows" style="float:none;">
                             <legend>Accounting details</legend>
                             <ol>
                                 <li>
                                 </li>
                                 <li>
                                     [% IF ( close ) %]
-                                        <span class="label">Budget: </span>
+                                        <span class="label">Fund: </span>
                                         <input type="hidden" size="20" name="budget_id" id="budget_id" value="[% budget_id %]" />[% Budget_name %]
                                     [% ELSE %]
                                         <li>
                                             </select>
                                         </li>
                                         <li>
-                                            <label for="all_budget_id">Budget: </label>
+                                            <label for="all_budget_id">Fund: </label>
                                             <select id="all_budget_id" size="1" name="all_budget_id">
+                                              <option value="">Select a fund</option>
                                             [% FOREACH budget_loo IN budget_loop %]
-                                                [% IF ( budget_loo.b_sel ) %]
-                                                    <option value="[% budget_loo.b_id %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]" selected="selected">[% budget_loo.b_txt %]</option>
-                                                [% ELSE %]
-                                                    <option value="[% budget_loo.b_id %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]">[% budget_loo.b_txt %]</option>
+                                                [% IF ( budget_loo.b_active ) %]<option value="[% budget_loo.b_id %]" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]">[% budget_loo.b_txt %]</option>
+                                                [% ELSE %]<option value="[% budget_loo.b_id %]" class="b_inactive" data-sort1-authcat="[% budget_loo.b_sort1_authcat %]" data-sort2-authcat="[% budget_loo.b_sort2_authcat %]">[% budget_loo.b_txt %] (inactive)</option>
                                                 [% END %]
                                             [% END %]
                                             </select>
+                                            <label for="all_showallbudgets" style="float:none;width:auto;">&nbsp;Show all:</label>
+                                            <input type="checkbox" id="all_showallbudgets" />
                                         </li>
                                     [% END %]
                                 </li>
                                 </li>
                                 <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">Planning value1: </label>
-                                    [% IF CGIsort1 %]
-                                        <select id="all_sort1" size="1" name="all_sort1">
-                                        [% FOREACH sort_opt IN CGIsort1 %]
-                                            [% IF sort_opt.default %]
-                                                <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
-                                            [% ELSE %]
-                                                <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
-                                            [% END %]
-                                        [% END %]
-                                        </select>
-                                    [% ELSE %]
-                                        <input type="text" id="all_sort1" size="20" name="all_sort1" value="[% sort1 %]" />
-                                    [% END %]
+                                    <label for="all_sort1">Statistic 1: </label>
+                                    <input type="text" id="all_sort1" size="20" name="all_sort1" value="" />
                                 </li>
                                 <li>
-                                  <span id="sort2_zone">
-                                    <label for="sort2">Planning value2: </label>
-                                    [% IF CGIsort2 %]
-                                        <select id="all_sort2" size="1" name="all_sort1">
-                                        [% FOREACH sort_opt IN CGIsort2 %]
-                                            [% IF sort_opt.default %]
-                                                <option value="[% sort_opt.id %]" selected="selected">[% sort_opt.label %]</option>
-                                            [% ELSE %]
-                                                <option value="[% sort_opt.id %]">[% sort_opt.label %]</option>
-                                            [% END %]
-                                        [% END %]
-                                        </select>
-                                    [% ELSE %]
-                                         <input type="text" id="all_sort2" size="20" name="all_sort2" value="[% sort2 %]" />
-                                    [% END %]
-                                  </span>
+                                    <label for="all_sort2">Statistic 2: </label>
+                                    <input type="text" id="all_sort2" size="20" name="all_sort2" value="" />
                                 </li>
                             </ol>
                         </fieldset>
-                        <fieldset class="action">
-                            <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
-                        </fieldset>
+                      </div>
+                      </div>
 
-                        </div>
+                      <fieldset class="action">
+                          <input type="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
+                      </fieldset>
                     </form>
                 [% ELSE %]
                 <div>