[Koha-patches] [PATCH] Bug 4163 Preserve budget value unless changed by user

Colin Campbell colin.campbell at ptfs-europe.com
Thu Feb 11 20:38:34 CET 2010


---
 acqui/neworderempty.pl                             |   30 ++++++++-----------
 .../prog/en/modules/acqui/neworderempty.tmpl       |    8 ++++-
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl
index 9fb1870..cedec85 100755
--- a/acqui/neworderempty.pl
+++ b/acqui/neworderempty.pl
@@ -230,23 +230,19 @@ my ( $flags, $homebranch )= ($borrower->{'flags'},$borrower->{'branchcode'});
 
 my $budget =  GetBudget($budget_id);
 # build budget list
-my %labels;
-my @values;
-my $budgets = GetBudgetHierarchy('','',$borrower->{'borrowernumber'});
-foreach my $r (@$budgets) {
-    $labels{"$r->{budget_id}"} = $r->{budget_name};
-    next if  sprintf ("%00d",  $r->{budget_amount})  ==   0;
-    push @values, $r->{budget_id};
+my $budget_loop = [];
+my $budgets = GetBudgetHierarchy(q{},q{},$borrower->{borrowernumber});
+foreach my $r (@{$budgets}) {
+    if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) {
+        next;
+    }
+    push @{$budget_loop}, {
+        b_id  => $r->{budget_id},
+        b_txt => $r->{budget_name},
+        b_sel => ( $r->{budget_id} == $budget_id ) ? 1 : 0,
+    };
 }
-# if no budget_id is passed then its an add
-my $budget_dropbox = CGI::scrolling_list(
-    -name    => 'budget_id',
-    -id      => 'budget_id',
-    -values  => \@values,
-    -size    => 1,
-    -labels  => \%labels,
-    -onChange   => "fetchSortDropbox(this.form)",
-);
+
 
 if ($close) {
     $budget_id      =  $data->{'budget_id'};
@@ -345,7 +341,7 @@ $template->param(
     title            => $data->{'title'},
     author           => $data->{'author'},
     publicationyear  => $data->{'publicationyear'},
-    budget_dropbox   => $budget_dropbox,
+    budget_loop      => $budget_loop,
     isbn             => $data->{'isbn'},
     seriestitle      => $data->{'seriestitle'},
     quantity         => $data->{'quantity'},
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl
index a77e214..f42e58e 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl
@@ -252,7 +252,13 @@ ff.submit();
                     <input type="hidden" size="20" name="budget_id" id="budget_id" value="<!-- TMPL_VAR NAME="budget_id" -->" /><!-- TMPL_VAR NAME="Budget_name" -->
                 <!-- TMPL_ELSE -->
                 <label for="budget_id">Budget: </label>
-                    <!-- TMPL_VAR NAME="budget_dropbox" -->
+                <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
+                <!-- TMPL_LOOP NAME="budget_loop" -->
+                    <option value="<!-- TMPL_VAR NAME='b_id' -->"<!-- TMPL_IF NAME="b_sel" -->selected="1"<!-- /TMPL_IF --> >
+                          <!-- TMPL_VAR NAME="b_txt" -->
+                    </option>
+                <!-- /TMPL_LOOP -->
+                </select>
                 <!--/TMPL_IF-->
             </li>
             <li>
-- 
1.6.6




More information about the Koha-patches mailing list