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

(-)a/acqui/ordered.pl (+108 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2008 - 2009 BibLibre SARL
4
# Copyright 2010 Catalyst IT Limited
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
committed.pl
23
  
24
=head1 DESCRIPTION
25
26
this script is to show orders ordered but not yet received
27
  
28
=cut
29
30
31
use C4::Context;
32
use strict;
33
use warnings;
34
use CGI;
35
use C4::Auth;
36
use C4::Output;
37
38
my $dbh      = C4::Context->dbh;
39
my $input    = new CGI;
40
my $fund_id = $input->param('fund');
41
my $start    = $input->param('start');
42
my $end      = $input->param('end');
43
44
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
45
    {
46
        template_name   => "acqui/ordered.tt",
47
        query           => $input,
48
        type            => "intranet",
49
        authnotrequired => 0,
50
        flagsrequired   => { acquisition => 1 },
51
        debug           => 1,
52
    }
53
);
54
55
my $query = <<EOQ;
56
SELECT
57
    aqorders.basketno, aqorders.ordernumber, 
58
    quantity-quantityreceived AS tleft,
59
    ecost, budgetdate,
60
    aqbasket.booksellerid,
61
    itype,
62
    title
63
FROM (aqorders, aqbasket)
64
LEFT JOIN biblio ON
65
    biblio.biblionumber=aqorders.biblionumber
66
LEFT JOIN aqorders_items ON
67
    aqorders.ordernumber=aqorders_items.ordernumber
68
LEFT JOIN items ON
69
    items.itemnumber=aqorders_items.itemnumber  
70
WHERE 
71
    aqorders.basketno=aqbasket.basketno AND
72
    budget_id=? AND
73
    (datecancellationprinted IS NULL OR 
74
        datecancellationprinted='0000-00-00') AND
75
    (quantity > quantityreceived OR quantityreceived IS NULL)
76
EOQ
77
78
my $sth = $dbh->prepare($query);
79
80
$sth->execute( $fund_id);
81
if ($sth->err) {
82
    die "Error occurred fetching records: ".$sth->errstr;
83
}
84
my @ordered;
85
86
my $total = 0;
87
while ( my $data = $sth->fetchrow_hashref ) {
88
    my $left = $data->{'tleft'};
89
    if ( !$left || $left eq '' ) {
90
        $left = $data->{'quantity'};
91
    }
92
    if ( $left && $left > 0 ) {
93
        my $subtotal = $left * $data->{'ecost'};
94
        $data->{subtotal} =  sprintf ("%.2f",  $subtotal);
95
        $data->{'left'} = $left;
96
        push @ordered, $data;
97
        $total += $subtotal;
98
    }
99
}
100
$total =   sprintf ("%.2f",  $total);
101
$template->param(
102
    ordered     => \@ordered,
103
    total       => $total
104
);
105
$sth->finish;
106
$dbh->disconnect;
107
108
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/spent.pl (+121 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# script to show a breakdown of committed and spent budgets
4
5
# Copyright 2002-2009 Katipo Communications Limited
6
# Copyright 2010 Catalyst IT Limited
7
# This file is part of Koha.
8
#
9
# Koha is free software; you can redistribute it and/or modify it under the
10
# terms of the GNU General Public License as published by the Free Software
11
# Foundation; either version 2 of the License, or (at your option) any later
12
# version.
13
#
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
16
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
# 
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.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
=head1 NAME
23
24
 spent.pl
25
26
=head1 DESCRIPTION
27
28
this script is designed to show the spent amount in budges
29
30
=cut
31
32
33
use C4::Context;
34
use C4::Auth;
35
use C4::Output;
36
use strict;
37
use CGI;
38
39
my $dbh      = C4::Context->dbh;
40
my $input    = new CGI;
41
my $bookfund = $input->param('fund');
42
my $start    = $input->param('start');
43
my $end      = $input->param('end');
44
45
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46
    {
47
        template_name   => "acqui/spent.tt",
48
        query           => $input,
49
        type            => "intranet",
50
        authnotrequired => 0,
51
        flagsrequired   => { acquisition => 1 },
52
        debug           => 1,
53
    }
54
);
55
56
my $query = <<EOQ;
57
SELECT
58
    aqorders.basketno, aqorders.ordernumber, 
59
    quantity-quantityreceived AS tleft,
60
    ecost, budgetdate,
61
    aqbasket.booksellerid,
62
    itype,
63
    title,
64
    aqorders.booksellerinvoicenumber,
65
    quantityreceived,
66
    unitprice,
67
    freight,
68
    datereceived,
69
    aqorders.biblionumber
70
FROM (aqorders, aqbasket)
71
LEFT JOIN items ON
72
    items.biblioitemnumber=aqorders.biblioitemnumber
73
LEFT JOIN biblio ON
74
    biblio.biblionumber=aqorders.biblionumber
75
LEFT JOIN aqorders_items ON
76
    aqorders.ordernumber=aqorders_items.ordernumber
77
WHERE 
78
    aqorders.basketno=aqbasket.basketno AND
79
    budget_id=? AND
80
    (datecancellationprinted IS NULL OR 
81
        datecancellationprinted='0000-00-00')
82
    GROUP BY aqorders.ordernumber
83
EOQ
84
my $sth = $dbh->prepare($query);
85
$sth->execute( $bookfund);
86
if ($sth->err) {
87
    die "An error occurred fetching records: ".$sth->errstr;
88
}
89
my $total = 0;
90
my $toggle;
91
my @spent;
92
while ( my $data = $sth->fetchrow_hashref ) {
93
    my $recv = $data->{'quantityreceived'};
94
    if ( $recv > 0 ) {
95
        my $subtotal = $recv * ($data->{'unitprice'} + $data->{'freight'});
96
        $data->{'subtotal'}  =   sprintf ("%.2f",  $subtotal); 
97
	$data->{'freight'}   =   sprintf ("%.2f", $data->{'freight'});
98
        $data->{'unitprice'} =   sprintf ("%.2f",   $data->{'unitprice'}  ); 
99
        $total               += $subtotal;
100
101
        if ($toggle) {
102
            $toggle = 0;
103
        }
104
        else {
105
            $toggle = 1;
106
        }
107
        $data->{'toggle'} = $toggle;
108
        push @spent, $data;
109
    }
110
111
}
112
$total =   sprintf ("%.2f",  $total); 
113
114
$template->param(
115
    spent       => \@spent,
116
    total       => $total
117
);
118
$sth->finish;
119
120
$dbh->disconnect;
121
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt (-4 / +4 lines)
Lines 122-129 $(document).ready(function() { Link Here
122
                <td align="center">[% loop_budge.budget_owner %]</td>
122
                <td align="center">[% loop_budge.budget_owner %]</td>
123
                <td align="center">[% loop_budge.budget_branchname %]</td>
123
                <td align="center">[% loop_budge.budget_branchname %]</td>
124
                <td align="right" >[% loop_budge.budget_amount %]</td>
124
                <td align="right" >[% loop_budge.budget_amount %]</td>
125
                <td align="right" >[% loop_budge.budget_ordered %]</td>
125
                <td align="right" ><a href="ordered.pl?fund=[% loop_budge.budget_id %]">[% loop_budge.budget_ordered %]</a></td>
126
                <td align="right" >[% loop_budge.budget_spent %]</td>
126
                <td align="right" ><a href="spent.pl?fund=[% loop_budge.budget_id %]">[% loop_budge.budget_spent %]</a></td>
127
                <td align="right" >[% loop_budge.budget_avail %]</td>
127
                <td align="right" >[% loop_budge.budget_avail %]</td>
128
            </tr>
128
            </tr>
129
            [% ELSE %]
129
            [% ELSE %]
Lines 136-143 $(document).ready(function() { Link Here
136
                <td align="center">[% loop_budge.budget_owner %]</td>
136
                <td align="center">[% loop_budge.budget_owner %]</td>
137
                <td align="center">[% loop_budge.budget_branchname %]</td>
137
                <td align="center">[% loop_budge.budget_branchname %]</td>
138
                <td align="right" >[% loop_budge.budget_amount %]</td>
138
                <td align="right" >[% loop_budge.budget_amount %]</td>
139
                <td align="right" >[% loop_budge.budget_ordered %]</td>
139
                <td align="right" ><a href="ordered.pl?fund=[% loop_budge.budget_id %]">[% loop_budge.budget_ordered %]</a></td>
140
                <td align="right" >[% loop_budge.budget_spent %]</td>
140
                <td align="right" ><a href="spent.pl?fund=[% loop_budge.budget_id %]">[% loop_budge.budget_spent %]</a></td>
141
                <td align="right" >[% loop_budge.budget_avail %]</td>
141
                <td align="right" >[% loop_budge.budget_avail %]</td>
142
            [% END %]
142
            [% END %]
143
        [% END %]
143
        [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt (+86 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Acquisitions &rsaquo; Ordered</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
<body>
6
[% INCLUDE 'header.inc' %]
7
[% INCLUDE 'acquisitions-search.inc' %]
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>
10
11
<div id="doc3" class="yui-t2">
12
13
<div id="bd">
14
    <div id="yui-main">
15
        <div class="yui-b">
16
17
<h1>Budgets &amp; Bookfunds</h1>
18
<h2>Ordered</h2>
19
20
<table cellspacing="0" cellpadding="0" border="0" id="spent" class="collapse">
21
    <thead>
22
    <tr>
23
        <th> Title </th>
24
	<th> Order </th>
25
	<th> Itemtype </th>
26
	<th> Left on Order </th>
27
	<th> Estimated cost per unit </th>
28
	<th> Budget Date </th>
29
	<th> Subtotal </th>
30
    </tr>
31
    </thead>
32
33
[% FOREACH order IN ordered %]
34
    [% IF loop.odd %]
35
        <tr class="highlight">
36
    [% ELSE %]
37
        <tr>
38
    [% END %]
39
	<td class="cell">
40
	    [% order.title %]	
41
	</td>
42
	<td class="cell">
43
	    <a href=/cgi-bin/koha/acqui/neworderempty.pl?ordernumber=[% order.ordernumber %]&booksellerid=[% order.booksellerid %]&basketno=[% order.basketno %]">[% order.ordernumber %]</a>
44
	</td>
45
	<td class="cell">
46
	    [% order.itype %]	
47
	</td>
48
	<td class="cell">
49
	    [% order.left %]	
50
	</td>
51
	<td class="cell" align="right">
52
	    [% order.ecost %]	
53
	</td>
54
	<td class="cell">
55
	    [% order.budgetdate %]	
56
	</td>
57
	<td class="cell" align="right">
58
	    [% order.subtotal %]
59
	</td>
60
    </tr>
61
[% END %]
62
63
    <tfoot>
64
    <tr>
65
        <td> Total </td> 
66
        <td> </td> 
67
        <td> </td> 
68
        <td> </td> 
69
        <td> </td> 
70
        <td> </td> 
71
        <td align="right">
72
            [% total %]
73
        </td>
74
    </tr>
75
    </tfoot>
76
77
</table>
78
79
</div>
80
</div>
81
<div class="yui-b">
82
[% INCLUDE 'acquisitions-menu.inc' %]
83
</div>
84
</div>
85
[% INCLUDE 'intranet-bottom.inc' %]
86
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/spent.tt (-1 / +101 lines)
Line 0 Link Here
0
- 
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Acquisitions &rsaquo; Spent</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
<body>
6
[% INCLUDE 'header.inc' %]
7
[% INCLUDE 'acquisitions-search.inc' %]
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; Spent </div>
10
11
<div id="doc3" class="yui-t2">
12
13
<div id="bd">
14
    <div id="yui-main">
15
        <div class="yui-b">
16
17
<h1>Budgets &amp; Bookfunds</h1>
18
<h2>Spent</h2>
19
20
21
<table cellspacing="0" cellpadding="0" border="0" id="spent" class="collapse">
22
    <thead>
23
    <tr>
24
        <th> Title </th>
25
	<th> Order </th>
26
	<th> Supplier </th>
27
	<th> Invoice </th>
28
	<th> Itemtype </th>
29
	<th> Receieved </th>
30
	<th> Unit Price </th>
31
	<th> Freight per Item </th>
32
	<th> Date Received </th>
33
	<th> Subtotal </th>
34
    </tr>
35
    </thead>
36
37
[% FOREACH order IN spent %]
38
    [% IF loop.odd %]
39
    <tr class="highlight">
40
    [% ELSE %]
41
    <tr>
42
    [% END %]
43
	
44
	<td class="cell">
45
	    [% order.title %]	
46
	</td>
47
	<td class="cell">
48
            <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>
49
	</td>
50
	<td class="cell">
51
	    [% order.booksellerid %]	
52
	</td>
53
	<td class="cell">
54
	    <a href="/cgi-bin/koha/acqui/parcel.pl?invoice=[% order.booksellerinvoicenumber %]&supplierid=[% order.booksellerid %]&datereceived=[% order.datereceived %]">[% order.booksellerinvoicenumber %]</a>
55
	</td>
56
	<td class="cell">
57
	    [% order.itype %]
58
	</td>
59
	<td class="cell">
60
	    [% order.quantityreceived %]	
61
	</td>
62
	<td class="cell" align="right">
63
	    [% order.unitprice %]		
64
	</td>
65
	<td class="cell" align="right">
66
	    [% order.freight %]		
67
	</td>
68
	<td class="cell">
69
	    [% order.datereceived %]		
70
	</td>
71
	<td class="cell" align="right">
72
	    [% order.subtotal %]		
73
	</td>
74
    </tr>
75
[% END %]
76
    <tfoot>
77
        <tr valign="top">
78
        <td> Total </td>
79
        <td> </td>
80
        <td> </td>
81
        <td> </td>
82
        <td> </td>
83
        <td> </td>
84
        <td> </td>
85
        <td> </td>
86
	<td> </td>
87
        <td align="right">
88
		[% total %]
89
	</td>
90
        </tr>
91
    </tfoot>
92
93
</table>
94
95
</div>
96
</div>
97
<div class="yui-b">
98
[% INCLUDE 'acquisitions-menu.inc' %]
99
</div>
100
</div>
101
[% INCLUDE 'intranet-bottom.inc' %]

Return to bug 929