From 95a44070fdc746b3ede17296650852747ef067c4 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Wed, 28 Dec 2011 09:47:56 +1300 Subject: [PATCH] Bug 929 : Reinstating the breakdown of budgets Signed-off-by: Katrin Fischer (cherry picked from commit 9638053a25a89040c21a38196dc6c4bb09e6010a) Signed-off-by: Chris Nighswonger --- acqui/ordered.pl | 108 ++++++++++++++++ acqui/spent.pl | 121 ++++++++++++++++++ .../prog/en/modules/acqui/acqui-home.tt | 8 +- .../prog/en/modules/acqui/ordered.tt | 85 ++++++++++++ .../prog/en/modules/acqui/spent.tt | 101 +++++++++++++++ 5 files changed, 419 insertions(+), 4 deletions(-) create mode 100755 acqui/ordered.pl create mode 100755 acqui/spent.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/spent.tt diff --git a/acqui/ordered.pl b/acqui/ordered.pl new file mode 100755 index 0000000000..9d319f6af6 --- /dev/null +++ b/acqui/ordered.pl @@ -0,0 +1,108 @@ +#!/usr/bin/perl + +# Copyright 2008 - 2009 BibLibre SARL +# Copyright 2010 Catalyst IT Limited +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +=head1 NAME + +committed.pl + +=head1 DESCRIPTION + +this script is to show orders ordered but not yet received + +=cut + + +use C4::Context; +use strict; +use warnings; +use CGI; +use C4::Auth; +use C4::Output; + +my $dbh = C4::Context->dbh; +my $input = new CGI; +my $fund_id = $input->param('fund'); +my $start = $input->param('start'); +my $end = $input->param('end'); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "acqui/ordered.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { acquisition => 1 }, + debug => 1, + } +); + +my $query = < quantityreceived OR quantityreceived IS NULL) +EOQ + +my $sth = $dbh->prepare($query); + +$sth->execute( $fund_id); +if ($sth->err) { + die "Error occurred fetching records: ".$sth->errstr; +} +my @ordered; + +my $total = 0; +while ( my $data = $sth->fetchrow_hashref ) { + my $left = $data->{'tleft'}; + if ( !$left || $left eq '' ) { + $left = $data->{'quantity'}; + } + if ( $left && $left > 0 ) { + my $subtotal = $left * $data->{'ecost'}; + $data->{subtotal} = sprintf ("%.2f", $subtotal); + $data->{'left'} = $left; + push @ordered, $data; + $total += $subtotal; + } +} +$total = sprintf ("%.2f", $total); +$template->param( + ordered => \@ordered, + total => $total +); +$sth->finish; +$dbh->disconnect; + +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/acqui/spent.pl b/acqui/spent.pl new file mode 100755 index 0000000000..80a89d3dd7 --- /dev/null +++ b/acqui/spent.pl @@ -0,0 +1,121 @@ +#!/usr/bin/perl + +# script to show a breakdown of committed and spent budgets + +# Copyright 2002-2009 Katipo Communications Limited +# Copyright 2010 Catalyst IT Limited +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +=head1 NAME + + spent.pl + +=head1 DESCRIPTION + +this script is designed to show the spent amount in budges + +=cut + + +use C4::Context; +use C4::Auth; +use C4::Output; +use strict; +use CGI; + +my $dbh = C4::Context->dbh; +my $input = new CGI; +my $bookfund = $input->param('fund'); +my $start = $input->param('start'); +my $end = $input->param('end'); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "acqui/spent.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { acquisition => 1 }, + debug => 1, + } +); + +my $query = <prepare($query); +$sth->execute( $bookfund); +if ($sth->err) { + die "An error occurred fetching records: ".$sth->errstr; +} +my $total = 0; +my $toggle; +my @spent; +while ( my $data = $sth->fetchrow_hashref ) { + my $recv = $data->{'quantityreceived'}; + if ( $recv > 0 ) { + my $subtotal = $recv * ($data->{'unitprice'} + $data->{'freight'}); + $data->{'subtotal'} = sprintf ("%.2f", $subtotal); + $data->{'freight'} = sprintf ("%.2f", $data->{'freight'}); + $data->{'unitprice'} = sprintf ("%.2f", $data->{'unitprice'} ); + $total += $subtotal; + + if ($toggle) { + $toggle = 0; + } + else { + $toggle = 1; + } + $data->{'toggle'} = $toggle; + push @spent, $data; + } + +} +$total = sprintf ("%.2f", $total); + +$template->param( + spent => \@spent, + total => $total +); +$sth->finish; + +$dbh->disconnect; +output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt index 86650eb0c6..09ec87428e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt @@ -122,8 +122,8 @@ $(document).ready(function() { [% loop_budge.budget_owner %] [% loop_budge.budget_branchname %] [% loop_budge.budget_amount %] - [% loop_budge.budget_ordered %] - [% loop_budge.budget_spent %] + [% loop_budge.budget_ordered %] + [% loop_budge.budget_spent %] [% loop_budge.budget_avail %] [% ELSE %] @@ -136,8 +136,8 @@ $(document).ready(function() { [% loop_budge.budget_owner %] [% loop_budge.budget_branchname %] [% loop_budge.budget_amount %] - [% loop_budge.budget_ordered %] - [% loop_budge.budget_spent %] + [% loop_budge.budget_ordered %] + [% loop_budge.budget_spent %] [% loop_budge.budget_avail %] [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt new file mode 100644 index 0000000000..9bba1adb8f --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt @@ -0,0 +1,85 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Acquisitions › Ordered +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'acquisitions-search.inc' %] + + + +
+ +
+
+
+ +

Budgets & Bookfunds

+

Ordered

+ + + + + + + + + + + + + + +[% FOREACH order IN ordered %] + [% IF loop.odd %] + + [% ELSE %] + + [% END %] + + + + + + + + +[% END %] + + + + + + + + + + + + + +
Title Order Itemtype Left on Order Estimated cost per unit Budget Date Subtotal
+ [% order.title %] + + [% order.ordernumber %] + + [% order.itype %] + + [% order.left %] + + [% order.ecost %] + + [% order.budgetdate %] + + [% order.subtotal %] +
Total + [% total %] +
+ +
+
+
+[% INCLUDE 'acquisitions-menu.inc' %] +
+
+[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/spent.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/spent.tt new file mode 100644 index 0000000000..4bd095fa2c --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/spent.tt @@ -0,0 +1,101 @@ +[% INCLUDE 'doc-head-open.inc' %] +Koha › Acquisitions › Spent +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'acquisitions-search.inc' %] + + + +
+ +
+
+
+ +

Budgets & Bookfunds

+

Spent

+ + + + + + + + + + + + + + + + + + +[% FOREACH order IN spent %] + [% IF loop.odd %] + + [% ELSE %] + + [% END %] + + + + + + + + + + + + +[% END %] + + + + + + + + + + + + + + + +
Title Order Supplier Invoice Itemtype Receieved Unit Price Freight per Item Date Received Subtotal
+ [% order.title %] + + [% order.ordernumber %] + + [% order.booksellerid %] + + [% order.booksellerinvoicenumber %] + + [% order.itype %] + + [% order.quantityreceived %] + + [% order.unitprice %] + + [% order.freight %] + + [% order.datereceived %] + + [% order.subtotal %] +
Total + [% total %] +
+ +
+
+
+[% INCLUDE 'acquisitions-menu.inc' %] +
+
+[% INCLUDE 'intranet-bottom.inc' %] -- 2.39.5