3 # script to show a breakdown of committed and spent budgets
5 # needs to be templated at some point
13 my $dbh = C4
::Context
->dbh;
15 my $bookfund = $input->param('bookfund');
16 my $start = $input->param('start');
17 my $end = $input->param('end');
19 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
21 template_name
=> "acqui/spent.tmpl",
25 flagsrequired
=> { acquisition
=> 1 },
31 "Select quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived
32 as qrev,subscription,title,itemtype,aqorders.biblionumber,aqorders.booksellerinvoicenumber,
33 quantity-quantityreceived as tleft,
35 as ordnum,entrydate,budgetdate,booksellerid,aqbasket.basketno
36 from aqorders,aqorderbreakdown,aqbasket
37 left join biblioitems on biblioitems.biblioitemnumber=aqorders.biblioitemnumber
38 where bookfundid=? and
39 aqorders.ordernumber=aqorderbreakdown.ordernumber and
40 aqorders.basketno=aqbasket.basketno
42 (datereceived >= ? and datereceived < ?))
43 and (datecancellationprinted is NULL or
44 datecancellationprinted='0000-00-00')
48 my $sth = $dbh->prepare($query);
49 $sth->execute( $bookfund, $start, $end );
54 while ( my $data = $sth->fetchrow_hashref ) {
55 my $recv = $data->{'qrev'};
57 my $subtotal = $recv * $data->{'unitprice'};
58 $data->{'subtotal'} = $subtotal;
59 $data->{'unitprice'} += 0;
67 $data->{'toggle'} = $toggle;
68 push @spent_loop, $data;
74 SPENTLOOP
=> \
@spent_loop,
80 output_html_with_http_headers
$input, $cookie, $template->output;