[Koha-patches] [SIGNED OFF] Bug 5464 Suggestions - adding more acq fields to staff interface
Colin Campbell
colin.campbell at ptfs-europe.com
Thu Dec 9 15:15:22 CET 2010
From: Amit Gupta <amit.gupta at osslabs.biz>
More acq fields in staff interface - price, quantity, currency and totals
Signed-off-by: Colin Campbell <colin.campbell at ptfs-europe.com>
---
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(-)
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 9148970..a2281cb 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/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`)
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index d093946..415632e 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/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)
diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js
index 4b65f82..326062d 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 7489cb6..bb80b0f 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; }
</style>
<!--/TMPL_IF-->
+<script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/acq.js"></script>
</head>
-<body>
+<body onload="calcNewsuggTotal();">
<!-- TMPL_INCLUDE name="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> › <!-- TMPL_IF name="op_save" --> <a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a> › <!-- TMPL_IF name="suggestionid" -->Suggestion edit #<!-- TMPL_VAR name="suggestionid" --><!--TMPL_ELSE-->New purchase suggestion<!-- /TMPL_IF --><!--TMPL_ELSE-->Suggestions Management<!-- /TMPL_IF --> </div>
@@ -160,7 +161,21 @@ h4.collapse a { font-size : 80%; text-decoration: none; } fieldset.brief ol { di
<option value="">Any</option><!-- TMPL_LOOP name="budgetsloop" -->
<!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR name="budget_id" -->" selected="selected"><!-- TMPL_VAR name="budget_name" --></option><!-- TMPL_ELSE --><option value="<!-- TMPL_VAR name="budget_id" -->"><!-- TMPL_VAR name="budget_name" --></option><!-- /TMPL_IF --><!-- /TMPL_LOOP -->
</select>
- </li></ol>
+ </li><li><label for="quantity">Copies:</label>
+ <input type="text" size="10" id="quantity" name="quantity" value="<!-- TMPL_VAR name="quantity" -->" onchange="calcNewsuggTotal();" />
+ </li><li><label for="currency">Currency:</label>
+ <!-- TMPL_LOOP NAME="loop_currency" -->
+ <input type="hidden" id="<!-- TMPL_VAR NAME="currcode" -->" name="<!-- TMPL_VAR NAME="currcode" -->" value="<!-- TMPL_VAR NAME="rate" -->" />
+ <!-- /TMPL_LOOP -->
+ <select name="currency" id="currency" onchange="calcNewsuggTotal();">
+ <!-- TMPL_LOOP name="loop_currency" -->
+ <!-- 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="price">Price:</label>
+ <input type="text" size="20" name="price" id="price" value="<!-- TMPL_VAR NAME="price" -->" onchange="calcNewsuggTotal();" />
+ </li><li><label for="total">Total</label>
+ <input type="text" readonly="readonly" id="total" name="total" size="10" value="<!--TMPL_VAR Name="total"-->"/>
+ </li></ol>
</fieldset>
<fieldset class="action"><input type="hidden" name="op" value="<!--TMPL_VAR Name="op"-->" /><!--TMPL_IF Name="suggestionid"--><input type="submit" value="Save" /> <a class="cancel" href="suggestion.pl?suggestionid=<!--TMPL_VAR Name="suggestionid"-->">Cancel</a><!--TMPL_ELSE--><input type="submit" value="Submit Your Suggestion" /> <a class="cancel" href="suggestion.pl">Cancel</a><!--/TMPL_IF-->
</fieldset>
diff --git a/kohaversion.pl b/kohaversion.pl
index 53c1724..ec6c2b3 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.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
diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl
index 57a1ba7..deda252 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;
--
1.7.3.2
More information about the Koha-patches
mailing list