[Koha-patches] [PATCH] BZ5961: follow-up, save currency

paul.poulain at biblibre.com paul.poulain at biblibre.com
Tue Apr 5 12:05:16 CEST 2011


From: Paul Poulain <paul.poulain at biblibre.com>

Cait noticed that currency was not saved properly in the aqorders table.

note a surprise, as the 3.2 had no currency feature and 5961 had been written against 3.2
anyway, this patch fixes the problem
---
 acqui/addorderiso2709.pl                           |   36 +++++++++++++++++++-
 .../prog/en/modules/acqui/addorderiso2709.tmpl     |    9 +++++
 2 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl
index a77b111..c46263a 100755
--- a/acqui/addorderiso2709.pl
+++ b/acqui/addorderiso2709.pl
@@ -87,8 +87,41 @@ if ($op eq ""){
 #
 } elsif ($op eq "batch_details"){
 #display lines inside the selected batch
+    # get currencies (for change rates calcs if needed)
+    my $active_currency = GetCurrency();
+    my $default_currency;
+    if (! $data->{currency} ) { # New order no currency set
+        if ( $bookseller->{listprice} ) {
+            $default_currency = $bookseller->{listprice};
+        }
+        else {
+            $default_currency = $active_currency->{currency};
+        }
+    }
+    my @rates = GetCurrencies();
+
+    # ## @rates
+
+    my @loop_currency = ();
+    for my $curr ( @rates ) {
+        my $selected;
+        if ($data->{currency} ) {
+            $selected = $curr->{currency} eq $data->{currency};
+        }
+        else {
+            $selected = $curr->{currency} eq $default_currency;
+        }
+        push @loop_currency, {
+            currcode => $curr->{currency},
+            rate     => $curr->{rate},
+            selected => $selected,
+        }
+    }
+
     $template->param("batch_details" => 1,
-                     "basketno"      => $cgiparams->{'basketno'});
+                     "basketno"      => $cgiparams->{'basketno'},
+                     loop_currencies  => \@loop_currency,
+                     );
     import_biblios_list($template, $cgiparams->{'import_batch_id'});
     if ( C4::Context->preference('AcqCreateItem') eq 'ordering' && !$ordernumber ) {
         # prepare empty item form
@@ -166,6 +199,7 @@ if ($op eq ""){
             "budget_id", $budget_id, "uncertainprice", 1,
             "sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'},
             "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
+            "currency",$cgiparams->{'currency'},
         );
         # get the price if there is one.
         # filter by storing only the 1st number
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl
index 7365030..1bd65e4 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tmpl
@@ -156,6 +156,14 @@
                         <span class="label">Budget: </span>
                                 <input type="hidden" size="20" name="budget_id" id="budget_id" value="<!-- TMPL_VAR NAME="budget_id" -->" /><!-- TMPL_VAR NAME="Budget_name" -->
                             <!-- TMPL_ELSE -->
+                            <li>
+                            <label for="currency">Currency:</label>
+                            <select name="currency" id="currency" onchange="calcNeworderTotal();">
+                            <!-- TMPL_LOOP name="loop_currencies" -->
+                                    <!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR name="currcode" -->" selected="selected"><!-- TMPL_VAR name="currcode" --></option><!-- TMPL_ELSE --><option value="<!-- TMPL_VAR name="currcode" -->"><!-- TMPL_VAR name="currcode" --></option><!-- /TMPL_IF --><!-- /TMPL_LOOP -->
+                            </select>
+                            </li>
+                            <li>
                             <label for="budget_id">Budget: </label>
                             <select id="budget_id" onchange="fetchSortDropbox(this.form)" size="1" name="budget_id">
                             <!-- TMPL_LOOP NAME="budget_loop" -->
@@ -166,6 +174,7 @@
                                 <!-- /TMPL_IF -->
                             <!-- /TMPL_LOOP -->
                             </select>
+                            </li>
                             <!--/TMPL_IF-->
                         </li>
                         <li>
-- 
1.7.1



More information about the Koha-patches mailing list