@@ -, +, @@ --- installer/data/mysql/kohastructure.sql | 4 ++++ installer/data/mysql/updatedatabase.pl | 12 ++++++++++++ koha-tmpl/intranet-tmpl/prog/en/js/acq.js | 18 ++++++++++++++++++ .../prog/en/modules/suggestion/suggestion.tmpl | 19 +++++++++++++++++-- kohaversion.pl | 2 +- suggestion/suggestion.pl | 20 ++++++++++++++++++++ 6 files changed, 72 insertions(+), 3 deletions(-) --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -1835,6 +1835,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`) --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -3876,6 +3876,18 @@ VALUES SetVersion ($DBversion); }; +$DBversion = '3.03.00.005'; +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 =head2 DropAllForeignKeys($table) --- a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js +++ a/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 /* --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tmpl +++ a/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
    --- a/kohaversion.pl +++ a/kohaversion.pl @@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts : use strict; sub kohaversion { - our $VERSION = '3.03.00.004'; + our $VERSION = '3.03.00.005'; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install --- a/suggestion/suggestion.pl +++ a/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; --