koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/acqui spent.pl


From: Chris Cormack
Subject: [Koha-cvs] koha/acqui spent.pl
Date: Wed, 07 Jun 2006 01:53:15 +0000

CVSROOT:        /sources/koha
Module name:    koha
Changes by:     Chris Cormack <rangi>   06/06/07 01:53:15

Added files:
        acqui          : spent.pl 

Log message:
        Merging from Katipo work
        
        Script to show the breakdown of the amount spent in a budget

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/acqui/spent.pl?cvsroot=koha&rev=1.1

Patches:
Index: spent.pl
===================================================================
RCS file: spent.pl
diff -N spent.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ spent.pl    7 Jun 2006 01:53:15 -0000       1.1
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+
+# script to show a breakdown of committed and spent budgets
+
+# needs to be templated at some point
+
+use C4::Context;
+use C4::Auth;
+use C4::Interface::CGI::Output;
+use strict;
+use CGI;
+
+my $dbh      = C4::Context->dbh;
+my $input    = new CGI;
+my $bookfund = $input->param('bookfund');
+my $start    = $input->param('start');
+my $end      = $input->param('end');
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "acqui/spent.tmpl",
+        query           => $input,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { acquisition => 1 },
+        debug           => 1,
+    }
+);
+
+my $query =
+"Select 
quantity,datereceived,freight,unitprice,listprice,ecost,quantityreceived
+    as 
qrev,subscription,title,itemtype,aqorders.biblionumber,aqorders.booksellerinvoicenumber,
+    quantity-quantityreceived as tleft,
+    aqorders.ordernumber
+    as ordnum,entrydate,budgetdate,booksellerid,aqbasket.basketno
+    from aqorders,aqorderbreakdown,aqbasket 
+    left join biblioitems on  
biblioitems.biblioitemnumber=aqorders.biblioitemnumber 
+    where bookfundid=? and
+    aqorders.ordernumber=aqorderbreakdown.ordernumber and
+    aqorders.basketno=aqbasket.basketno
+   and (
+       (datereceived >= ? and datereceived < ?))
+    and (datecancellationprinted is NULL or
+          datecancellationprinted='0000-00-00')
+
+
+  ";
+my $sth = $dbh->prepare($query);
+$sth->execute( $bookfund, $start, $end );
+
+my $total = 0;
+my $toggle;
+my @spent_loop;
+while ( my $data = $sth->fetchrow_hashref ) {
+    my $recv = $data->{'qrev'};
+    if ( $recv > 0 ) {
+        my $subtotal = $recv * $data->{'unitprice'};
+        $data->{'subtotal'} = $subtotal;
+        $data->{'unitprice'} += 0;
+        $total               += $subtotal;
+        if ($toggle) {
+            $toggle = 0;
+        }
+        else {
+            $toggle = 1;
+        }
+        $data->{'toggle'} = $toggle;
+        push @spent_loop, $data;
+    }
+
+}
+
+$template->param(
+    SPENTLOOP => address@hidden,
+    total     => $total
+);
+$sth->finish;
+
+$dbh->disconnect;
+output_html_with_http_headers $input, $cookie, $template->output;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]