View | Details | Raw Unified | Return to bug 929
Collapse All | Expand All

(-)a/acqui/ordered.pl (-17 / +20 lines)
Lines 1-7 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2008 - 2009 BibLibre SARL
3
# Copyright 2008 - 2009 BibLibre SARL
4
# Copyright 2010 Catalyst IT Limited
4
# Copyright 2010,2011 Catalyst IT Limited
5
# This file is part of Koha.
5
# This file is part of Koha.
6
#
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
7
# Koha is free software; you can redistribute it and/or modify it under the
Lines 27-45 this script is to show orders ordered but not yet received Link Here
27
  
27
  
28
=cut
28
=cut
29
29
30
31
use C4::Context;
30
use C4::Context;
32
use strict;
31
use strict;
33
use warnings;
32
use warnings;
34
use CGI;
33
use CGI;
35
use C4::Auth;
34
use C4::Auth;
36
use C4::Output;
35
use C4::Output;
36
use C4::Dates;
37
37
38
my $dbh      = C4::Context->dbh;
38
my $dbh     = C4::Context->dbh;
39
my $input    = new CGI;
39
my $input   = new CGI;
40
my $fund_id = $input->param('fund');
40
my $fund_id = $input->param('fund');
41
my $start    = $input->param('start');
41
my $start   = $input->param('start');
42
my $end      = $input->param('end');
42
my $end     = $input->param('end');
43
43
44
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
44
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
45
    {
45
    {
Lines 56-62 my $query = <<EOQ; Link Here
56
SELECT
56
SELECT
57
    aqorders.basketno, aqorders.ordernumber, 
57
    aqorders.basketno, aqorders.ordernumber, 
58
    quantity-quantityreceived AS tleft,
58
    quantity-quantityreceived AS tleft,
59
    ecost, budgetdate,
59
    ecost, budgetdate, entrydate,
60
    aqbasket.booksellerid,
60
    aqbasket.booksellerid,
61
    itype,
61
    itype,
62
    title
62
    title
Lines 73-85 WHERE Link Here
73
    (datecancellationprinted IS NULL OR 
73
    (datecancellationprinted IS NULL OR 
74
        datecancellationprinted='0000-00-00') AND
74
        datecancellationprinted='0000-00-00') AND
75
    (quantity > quantityreceived OR quantityreceived IS NULL)
75
    (quantity > quantityreceived OR quantityreceived IS NULL)
76
    GROUP BY aqorders.ordernumber
76
EOQ
77
EOQ
77
78
78
my $sth = $dbh->prepare($query);
79
my $sth = $dbh->prepare($query);
79
80
80
$sth->execute( $fund_id);
81
$sth->execute($fund_id);
81
if ($sth->err) {
82
if ( $sth->err ) {
82
    die "Error occurred fetching records: ".$sth->errstr;
83
    die "Error occurred fetching records: " . $sth->errstr;
83
}
84
}
84
my @ordered;
85
my @ordered;
85
86
Lines 91-108 while ( my $data = $sth->fetchrow_hashref ) { Link Here
91
    }
92
    }
92
    if ( $left && $left > 0 ) {
93
    if ( $left && $left > 0 ) {
93
        my $subtotal = $left * $data->{'ecost'};
94
        my $subtotal = $left * $data->{'ecost'};
94
        $data->{subtotal} =  sprintf ("%.2f",  $subtotal);
95
        $data->{subtotal} = sprintf( "%.2f", $subtotal );
95
        $data->{'left'} = $left;
96
        $data->{'left'} = $left;
96
        push @ordered, $data;
97
        push @ordered, $data;
97
        $total += $subtotal;
98
        $total += $subtotal;
98
    }
99
    }
100
    my $entrydate = C4::Dates->new( $data->{'entrydate'}, 'iso' );
101
    $data->{'entrydate'} = $entrydate->output("syspref");
99
}
102
}
100
$total =   sprintf ("%.2f",  $total);
103
$total = sprintf( "%.2f", $total );
101
$template->param(
104
102
    ordered     => \@ordered,
105
$template->{VARS}->{'fund'}    = $fund_id;
103
    total       => $total
106
$template->{VARS}->{'ordered'} = \@ordered;
104
);
107
$template->{VARS}->{'total'}   = $total;
108
105
$sth->finish;
109
$sth->finish;
106
$dbh->disconnect;
107
110
108
output_html_with_http_headers $input, $cookie, $template->output;
111
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/spent.pl (-26 / +20 lines)
Lines 3-9 Link Here
3
# script to show a breakdown of committed and spent budgets
3
# script to show a breakdown of committed and spent budgets
4
4
5
# Copyright 2002-2009 Katipo Communications Limited
5
# Copyright 2002-2009 Katipo Communications Limited
6
# Copyright 2010 Catalyst IT Limited
6
# Copyright 2010,2011 Catalyst IT Limited
7
# This file is part of Koha.
7
# This file is part of Koha.
8
#
8
#
9
# Koha is free software; you can redistribute it and/or modify it under the
9
# Koha is free software; you can redistribute it and/or modify it under the
Lines 14-20 Link Here
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
# 
17
#
18
# You should have received a copy of the GNU General Public License along
18
# You should have received a copy of the GNU General Public License along
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Lines 29-39 this script is designed to show the spent amount in budges Link Here
29
29
30
=cut
30
=cut
31
31
32
33
use C4::Context;
32
use C4::Context;
34
use C4::Auth;
33
use C4::Auth;
35
use C4::Output;
34
use C4::Output;
35
use C4::Dates;
36
use strict;
36
use strict;
37
use warnings;
37
use CGI;
38
use CGI;
38
39
39
my $dbh      = C4::Context->dbh;
40
my $dbh      = C4::Context->dbh;
Lines 82-90 WHERE Link Here
82
    GROUP BY aqorders.ordernumber
83
    GROUP BY aqorders.ordernumber
83
EOQ
84
EOQ
84
my $sth = $dbh->prepare($query);
85
my $sth = $dbh->prepare($query);
85
$sth->execute( $bookfund);
86
$sth->execute($bookfund);
86
if ($sth->err) {
87
if ( $sth->err ) {
87
    die "An error occurred fetching records: ".$sth->errstr;
88
    die "An error occurred fetching records: " . $sth->errstr;
88
}
89
}
89
my $total = 0;
90
my $total = 0;
90
my $toggle;
91
my $toggle;
Lines 92-122 my @spent; Link Here
92
while ( my $data = $sth->fetchrow_hashref ) {
93
while ( my $data = $sth->fetchrow_hashref ) {
93
    my $recv = $data->{'quantityreceived'};
94
    my $recv = $data->{'quantityreceived'};
94
    if ( $recv > 0 ) {
95
    if ( $recv > 0 ) {
95
        my $subtotal = $recv * ($data->{'unitprice'} + $data->{'freight'});
96
        my $subtotal = $recv * ( $data->{'unitprice'} + $data->{'freight'} );
96
        $data->{'subtotal'}  =   sprintf ("%.2f",  $subtotal); 
97
        $data->{'subtotal'}  = sprintf( "%.2f", $subtotal );
97
	$data->{'freight'}   =   sprintf ("%.2f", $data->{'freight'});
98
        $data->{'freight'}   = sprintf( "%.2f", $data->{'freight'} );
98
        $data->{'unitprice'} =   sprintf ("%.2f",   $data->{'unitprice'}  ); 
99
        $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
99
        $total               += $subtotal;
100
        $total += $subtotal;
100
101
        my $entrydate = C4::Dates->new( $data->{'entrydate'}, 'iso' );
101
        if ($toggle) {
102
        $data->{'entrydate'} = $entrydate->output("syspref");
102
            $toggle = 0;
103
        my $datereceived = C4::Dates->new( $data->{'datereceived'}, 'iso' );
103
        }
104
        $data->{'datereceived'} = $datereceived->output("syspref");
104
        else {
105
            $toggle = 1;
106
        }
107
        $data->{'toggle'} = $toggle;
108
        push @spent, $data;
105
        push @spent, $data;
109
    }
106
    }
110
107
111
}
108
}
112
$total =   sprintf ("%.2f",  $total); 
109
$total = sprintf( "%.2f", $total );
113
110
114
$template->param(
111
$template->{VARS}->{'fund'}  = $bookfund;
115
    spent       => \@spent,
112
$template->{VARS}->{'spent'} = \@spent;
116
    total       => $total
113
$template->{VARS}->{'total'} = $total;
117
);
118
$template->{VARS}->{'fund'} = $bookfund;
119
$sth->finish;
114
$sth->finish;
120
115
121
$dbh->disconnect;
122
output_html_with_http_headers $input, $cookie, $template->output;
116
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt (-6 / +10 lines)
Lines 6-12 Link Here
6
[% INCLUDE 'header.inc' %]
6
[% INCLUDE 'header.inc' %]
7
[% INCLUDE 'acquisitions-search.inc' %]
7
[% INCLUDE 'acquisitions-search.inc' %]
8
8
9
<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>
9
<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 - [% fund %]</div>
10
10
11
<div id="doc3" class="yui-t2">
11
<div id="doc3" class="yui-t2">
12
12
Lines 14-31 Link Here
14
    <div id="yui-main">
14
    <div id="yui-main">
15
        <div class="yui-b">
15
        <div class="yui-b">
16
16
17
<h1>Budgets &amp; Bookfunds</h1>
17
<h1>Bookfunds</h1>
18
<h2>Ordered</h2>
18
<h2>Ordered - [% fund %]</h2>
19
19
20
<table cellspacing="0" cellpadding="0" border="0" id="spent" class="collapse">
20
<table cellspacing="0" cellpadding="0" border="0" id="spent" class="collapse">
21
    <thead>
21
    <thead>
22
    <tr>
22
    <tr>
23
        <th> Title </th>
23
        <th> Title </th>
24
	<th> Order </th>
24
	<th> Order </th>
25
	<th> Vendor </th>
25
	<th> Itemtype </th>
26
	<th> Itemtype </th>
26
	<th> Left on Order </th>
27
	<th> Left on Order </th>
27
	<th> Estimated cost per unit </th>
28
	<th> Estimated cost per unit </th>
28
	<th> Budget Date </th>
29
	<th> Date Ordered </th>
29
	<th> Subtotal </th>
30
	<th> Subtotal </th>
30
    </tr>
31
    </tr>
31
    </thead>
32
    </thead>
Lines 43-48 Link Here
43
	    <a href=/cgi-bin/koha/acqui/neworderempty.pl?ordernumber=[% order.ordernumber %]&booksellerid=[% order.booksellerid %]&basketno=[% order.basketno %]">[% order.ordernumber %]</a>
44
	    <a href=/cgi-bin/koha/acqui/neworderempty.pl?ordernumber=[% order.ordernumber %]&booksellerid=[% order.booksellerid %]&basketno=[% order.basketno %]">[% order.ordernumber %]</a>
44
	</td>
45
	</td>
45
	<td class="cell">
46
	<td class="cell">
47
	    <a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=[% order.booksellerid %]">[% order.booksellerid %]</a>
48
	</td>
49
	<td class="cell">
46
	    [% order.itype %]	
50
	    [% order.itype %]	
47
	</td>
51
	</td>
48
	<td class="cell">
52
	<td class="cell">
Lines 52-58 Link Here
52
	    [% order.ecost %]	
56
	    [% order.ecost %]	
53
	</td>
57
	</td>
54
	<td class="cell">
58
	<td class="cell">
55
	    [% order.budgetdate %]	
59
	    [% order.entrydate %]	
56
	</td>
60
	</td>
57
	<td class="cell" align="right">
61
	<td class="cell" align="right">
58
	    [% order.subtotal %]
62
	    [% order.subtotal %]
Lines 68-73 Link Here
68
        <td> </td> 
72
        <td> </td> 
69
        <td> </td> 
73
        <td> </td> 
70
        <td> </td> 
74
        <td> </td> 
75
	<td> </td>
71
        <td align="right">
76
        <td align="right">
72
            [% total %]
77
            [% total %]
73
        </td>
78
        </td>
74
- 

Return to bug 929