From f1649027619c0324a0abc08ac43c0a6ea1feb919 Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Thu, 9 Dec 2010 14:15:22 +0000 Subject: [PATCH] Bug 5464 Suggestions - adding more acq fields to staff interface More acq fields in staff interface - price, quantity, currency and totals Signed-off-by: Colin Campbell Signed-off-by: Chris Cormack --- installer/data/mysql/kohastructure.sql | 4 ++++ installer/data/mysql/updatedatabase.pl | 11 ++++++++++ koha-tmpl/intranet-tmpl/prog/en/js/acq.js | 18 +++++++++++++++++ .../en/modules/suggestion/suggestion.tmpl | 19 ++++++++++++++++-- kohaversion.pl | 2 +- suggestion/suggestion.pl | 20 +++++++++++++++++++ 6 files changed, 71 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 695129b0a2..5e0c6b65c8 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1836,6 +1836,10 @@ CREATE TABLE `suggestions` ( branchcode VARCHAR(10) default NULL, collectiontitle text default NULL, itemtype VARCHAR(30) default NULL, + quantity SMALLINT(6) default NULL, + currency VARCHAR(3) default NULL, + price DECIMAL(28,6) default NULL, + total DECIMAL(28,6) default NULL, PRIMARY KEY (`suggestionid`), KEY `suggestedby` (`suggestedby`), KEY `managedby` (`managedby`) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 80dca66203..4caadb31ce 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -3891,6 +3891,17 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = '3.03.00.007'; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("ALTER table suggestions ADD quantity SMALLINT(6) default NULL, + ADD currency VARCHAR(3) default NULL, + ADD price DECIMAL(28,6) default NULL, + ADD total DECIMAL(28,6) default NULL; + "); + print "Upgrade to $DBversion done (Added acq related columns to suggestions)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js index 4b65f829e7..326062db38 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js @@ -679,6 +679,24 @@ function calcNeworderTotal(){ return true; } +// Calculates total amount in a suggestion + +function calcNewsuggTotal(){ + //collect values + var quantity = new Number(document.getElementById('quantity').value); +// var currency = f.currency.value; + var currcode = new String(document.getElementById('currency').value); + var price = new Number(document.getElementById('price').value); + var exchangerate = new Number(document.getElementById(currcode).value); + + var total = new Number(quantity*price*exchangerate); + + document.getElementById('total').value = total.toFixed(2); + document.getElementById('price').value = listprice.toFixed(2); + return true; +} + + // ---------------------------------------- //USED BY NEWORDEREMPTY.PL /* diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tmpl index 6696b92c42..89e89b51ab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tmpl @@ -81,8 +81,9 @@ h4.collapse a { font-size : 80%; text-decoration: none; } fieldset.brief ol { di .overlay { top: 180px; left: 50%; position: absolute; margin-left: -100px; width: 200px; text-align: center; display: none; margin-top: -10px; background: #eeffd4; padding: .5em; color: #000; } + - + @@ -160,7 +161,21 @@ h4.collapse a { font-size : 80%; text-decoration: none; } fieldset.brief ol { di - +
  • + " onchange="calcNewsuggTotal();" /> +
  • + + " name="" value="" /> + + +
  • + " onchange="calcNewsuggTotal();" /> +
  • + "/> +
  • " /> ">Cancel Cancel
    diff --git a/kohaversion.pl b/kohaversion.pl index 29075d80a2..3b6d24c197 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts : use strict; sub kohaversion { - our $VERSION = '3.03.00.006'; + our $VERSION = '3.03.00.007'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 8ca17d01a1..f14c921cf1 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -269,6 +269,26 @@ foreach my $budget (@$budgets){ $template->param( budgetsloop => $budgets); +# get currencies and rates +my @rates = GetCurrencies(); +my $count = scalar @rates; + +my @loop_currency = (); +for ( my $i = 0 ; $i < $count ; $i++ ) { + my %line; + $line{currcode} = $rates[$i]->{'currency'}; + $line{rate} = $rates[$i]->{'rate'}; + $line{selected} = 1 if ($$suggestion_ref{'currency'} && $line{'currcode'} eq $$suggestion_ref{'currency'}); + push @loop_currency, \%line; +} + +$template->param(loop_currency => \@loop_currency); + +$template->param( + price => sprintf("%.2f", $$suggestion_ref{'price'}||0), + total => sprintf("%.2f", $$suggestion_ref{'total'}||0), +); + my %hashlists; foreach my $field qw(managedby acceptedby suggestedby budgetid STATUS) { my $values_list; -- 2.39.5