Bug 929 : Reinstating the breakdown of budgets

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
(cherry picked from commit 9638053a25)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
(cherry picked from commit 95a44070fd)

Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
Chris Cormack 2011-12-28 09:47:56 +13:00 committed by Chris Nighswonger
parent e1dbb445d0
commit ce536c2cc9
5 changed files with 419 additions and 4 deletions

108
acqui/ordered.pl Executable file
View File

@ -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 = <<EOQ;
SELECT
aqorders.basketno, aqorders.ordernumber,
quantity-quantityreceived AS tleft,
ecost, budgetdate,
aqbasket.booksellerid,
itype,
title
FROM (aqorders, aqbasket)
LEFT JOIN biblio ON
biblio.biblionumber=aqorders.biblionumber
LEFT JOIN aqorders_items ON
aqorders.ordernumber=aqorders_items.ordernumber
LEFT JOIN items ON
items.itemnumber=aqorders_items.itemnumber
WHERE
aqorders.basketno=aqbasket.basketno AND
budget_id=? AND
(datecancellationprinted IS NULL OR
datecancellationprinted='0000-00-00') AND
(quantity > 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;

121
acqui/spent.pl Executable file
View File

@ -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 = <<EOQ;
SELECT
aqorders.basketno, aqorders.ordernumber,
quantity-quantityreceived AS tleft,
ecost, budgetdate,
aqbasket.booksellerid,
itype,
title,
aqorders.booksellerinvoicenumber,
quantityreceived,
unitprice,
freight,
datereceived,
aqorders.biblionumber
FROM (aqorders, aqbasket)
LEFT JOIN items ON
items.biblioitemnumber=aqorders.biblioitemnumber
LEFT JOIN biblio ON
biblio.biblionumber=aqorders.biblionumber
LEFT JOIN aqorders_items ON
aqorders.ordernumber=aqorders_items.ordernumber
WHERE
aqorders.basketno=aqbasket.basketno AND
budget_id=? AND
(datecancellationprinted IS NULL OR
datecancellationprinted='0000-00-00')
GROUP BY aqorders.ordernumber
EOQ
my $sth = $dbh->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;

View File

@ -122,8 +122,8 @@ $(document).ready(function() {
<td align="center">[% loop_budge.budget_owner %]</td>
<td align="center">[% loop_budge.budget_branchname %]</td>
<td align="right" >[% loop_budge.budget_amount %]</td>
<td align="right" >[% loop_budge.budget_ordered %]</td>
<td align="right" >[% loop_budge.budget_spent %]</td>
<td align="right" ><a href="ordered.pl?fund=[% loop_budge.budget_id %]">[% loop_budge.budget_ordered %]</a></td>
<td align="right" ><a href="spent.pl?fund=[% loop_budge.budget_id %]">[% loop_budge.budget_spent %]</a></td>
<td align="right" >[% loop_budge.budget_avail %]</td>
</tr>
[% ELSE %]
@ -136,8 +136,8 @@ $(document).ready(function() {
<td align="center">[% loop_budge.budget_owner %]</td>
<td align="center">[% loop_budge.budget_branchname %]</td>
<td align="right" >[% loop_budge.budget_amount %]</td>
<td align="right" >[% loop_budge.budget_ordered %]</td>
<td align="right" >[% loop_budge.budget_spent %]</td>
<td align="right" ><a href="ordered.pl?fund=[% loop_budge.budget_id %]">[% loop_budge.budget_ordered %]</a></td>
<td align="right" ><a href="spent.pl?fund=[% loop_budge.budget_id %]">[% loop_budge.budget_spent %]</a></td>
<td align="right" >[% loop_budge.budget_avail %]</td>
[% END %]
[% END %]

View File

@ -0,0 +1,85 @@
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Acquisitions &rsaquo; Ordered</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body>
[% INCLUDE 'header.inc' %]
[% INCLUDE 'acquisitions-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; Ordered </div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<h1>Budgets &amp; Bookfunds</h1>
<h2>Ordered</h2>
<table cellspacing="0" cellpadding="0" border="0" id="spent" class="collapse">
<thead>
<tr>
<th> Title </th>
<th> Order </th>
<th> Itemtype </th>
<th> Left on Order </th>
<th> Estimated cost per unit </th>
<th> Budget Date </th>
<th> Subtotal </th>
</tr>
</thead>
[% FOREACH order IN ordered %]
[% IF loop.odd %]
<tr class="highlight">
[% ELSE %]
<tr>
[% END %]
<td class="cell">
[% order.title %]
</td>
<td class="cell">
<a href=/cgi-bin/koha/acqui/neworderempty.pl?ordernumber=[% order.ordernumber %]&booksellerid=[% order.booksellerid %]&basketno=[% order.basketno %]">[% order.ordernumber %]</a>
</td>
<td class="cell">
[% order.itype %]
</td>
<td class="cell">
[% order.left %]
</td>
<td class="cell" align="right">
[% order.ecost %]
</td>
<td class="cell">
[% order.budgetdate %]
</td>
<td class="cell" align="right">
[% order.subtotal %]
</td>
</tr>
[% END %]
<tfoot>
<tr>
<td> Total </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td align="right">
[% total %]
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="yui-b">
[% INCLUDE 'acquisitions-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]

View File

@ -0,0 +1,101 @@
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Acquisitions &rsaquo; Spent</title>
[% INCLUDE 'doc-head-close.inc' %]
</head>
<body>
[% INCLUDE 'header.inc' %]
[% INCLUDE 'acquisitions-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; Spent </div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<h1>Budgets &amp; Bookfunds</h1>
<h2>Spent</h2>
<table cellspacing="0" cellpadding="0" border="0" id="spent" class="collapse">
<thead>
<tr>
<th> Title </th>
<th> Order </th>
<th> Supplier </th>
<th> Invoice </th>
<th> Itemtype </th>
<th> Receieved </th>
<th> Unit Price </th>
<th> Freight per Item </th>
<th> Date Received </th>
<th> Subtotal </th>
</tr>
</thead>
[% FOREACH order IN spent %]
[% IF loop.odd %]
<tr class="highlight">
[% ELSE %]
<tr>
[% END %]
<td class="cell">
[% order.title %]
</td>
<td class="cell">
<a href="/cgi-bin/koha/acqui/orderreceive.pl?ordernumber=[% order.ordernumber %]&biblio=[% order.biblionumber %]&invoice=[% order.booksellerinvoicenumber %]&supplierid=[% order.booksellerid %]&catview=yes">[% order.ordernumber %]</a>
</td>
<td class="cell">
[% order.booksellerid %]
</td>
<td class="cell">
<a href="/cgi-bin/koha/acqui/parcel.pl?invoice=[% order.booksellerinvoicenumber %]&supplierid=[% order.booksellerid %]&datereceived=[% order.datereceived %]">[% order.booksellerinvoicenumber %]</a>
</td>
<td class="cell">
[% order.itype %]
</td>
<td class="cell">
[% order.quantityreceived %]
</td>
<td class="cell" align="right">
[% order.unitprice %]
</td>
<td class="cell" align="right">
[% order.freight %]
</td>
<td class="cell">
[% order.datereceived %]
</td>
<td class="cell" align="right">
[% order.subtotal %]
</td>
</tr>
[% END %]
<tfoot>
<tr valign="top">
<td> Total </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td align="right">
[% total %]
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<div class="yui-b">
[% INCLUDE 'acquisitions-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]