Bug 10875: ensure adding order from a staged file does not display inactive funds...
authorJonathan Druart <jonathan.druart@biblibre.com>
Wed, 11 Sep 2013 08:01:34 +0000 (10:01 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Sun, 4 May 2014 20:47:25 +0000 (20:47 +0000)
When adding an order from a staged file, a link
"show all funds" is now added on the top of the
page. All inactive funds are hidden by default.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Works as described.
- Loading the page, a fund needs to be selected. Before
  the patch the first fund was preselected.
- Checking the checkbox, inactive funds show up, but
  are not visible otherwise.
- If the fund is selected from the MARC file, the
  correct fund will be selected, even if it's inactive.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

acqui/addorderiso2709.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt

index 456e840..10d6549 100755 (executable)
@@ -306,9 +306,14 @@ foreach my $r ( @{$budgets_hierarchy} ) {
         b_txt => $r->{budget_name},
         b_sort1_authcat => $r->{'sort1_authcat'},
         b_sort2_authcat => $r->{'sort2_authcat'},
+        b_active => $r->{budget_period_active},
         b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
       };
 }
+
+@{$budget_loop} =
+  sort { uc( $a->{b_txt}) cmp uc( $b->{b_txt}) } @{$budget_loop};
+
 $template->param( budget_loop    => $budget_loop,);
 
 output_html_with_http_headers $input, $cookie, $template->output;
index 331cb03..a6a099a 100644 (file)
             "aaSorting": []
         } ) );
 
+        //keep a copy of all budgets before removing the inactives
+        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); //Puts back all the funds
+            }
+            else {
+                $("select[name='budget_id'] .b_inactive").remove();
+            }
+        });
+
+        $("#all_showallbudgets").click(function() {
+            if ($(this).is(":checked")) {
+                $("select[name='all_budget_id']").html(disabledBudgetsCopy); //Puts back all the funds
+            }
+            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');
                   <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 %]" />
                                   <input type="hidden" size="20" name="budget_id" value="[% budget_id %]" />[% Budget_name %]
                                 [% ELSE %]
                                   <select id="fund_record_[% biblio.import_record_id %]" size="1" name="budget_id">
-                                    <option value=""></option>
+                                    <option value="">Select a fund</option>
                                     [% FOREACH budget IN budget_loop %]
                                         [% IF ( budget.b_id == biblio.budget_id ) %]
                                             <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 %]">[% 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 %]</option>
+                                            [% END %]
                                         [% END %]
                                     [% END %]
                                   </select>
                                         <li>
                                             <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 %]</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>