diff --git a/C4/Output.pm b/C4/Output.pm index d3c8d8a..a926ef3 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -55,17 +55,27 @@ sub startpage{ } sub startmenu{ - open (FILE,'/usr/local/www/hdl/htdocs/includes/cat-top.inc'); + my ($type)=@_; + if ($type eq 'issue'){ + open (FILE,'/usr/local/www/hdl/htdocs/includes/issues-top.inc'); + } else { + open (FILE,'/usr/local/www/hdl/htdocs/includes/cat-top.inc'); + } my @string=; close FILE; my $count=@string; - $string[$count]="
"; +# $string[$count]="
"; return @string; } sub endmenu{ + my ($type)=@_; + if ($type eq 'issue'){ + open (FILE,'/usr/local/www/hdl/htdocs/includes/issues-bottom.inc'); + } else { open (FILE,'/usr/local/www/hdl/htdocs/includes/cat-bottom.inc'); + } my @string=; close FILE; return @string; diff --git a/C4/Stats.pm b/C4/Stats.pm index 0a574fe..2d60e29 100644 --- a/C4/Stats.pm +++ b/C4/Stats.pm @@ -13,7 +13,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 0.01; @ISA = qw(Exporter); -@EXPORT = qw(&UpdateStats &statsreport); +@EXPORT = qw(&UpdateStats &statsreport &Count); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -52,7 +52,7 @@ my $priv_func = sub { sub UpdateStats { #module to insert stats data into stats table - my ($branch,$type,$amount)=@_; + my ($env,$branch,$type,$amount)=@_; my $dbh=C4Connect(); my $sth=$dbh->prepare("Insert into statistics (datetime,branch,type) values (datetime('now'::abstime),'$branch','$type')"); @@ -64,7 +64,57 @@ sub UpdateStats { sub statsreport { #module to return a list of stats for a given day,time,branch type #or to return search stats - + my ($type,$time)=@_; + my @data; +# print "here"; + if ($type eq 'issue'){ + @data=issuesrep($time); + } + return(@data); +} + +sub issuesrep { + my ($time)=@_; + my $dbh=C4Connect; + my $query="Select * from statistics"; + if ($time eq 'today'){ + $query=$query." where type='issue' and datetime + >=datetime('yesterday'::date)"; + } + my $sth=$dbh->prepare($query); + $sth->execute; + my $i=0; + my @results; + while (my $data=$sth->fetchrow_hashref){ + $results[$i]="$data->{'datetime'}\t$data->{'branch'}"; + $i++; + } + $sth->finish; +# print $query; + $dbh->disconnect; + return(@results); + +} + +sub Count { + my ($type,$time)=@_; + my $dbh=C4Connect; + my $query="Select * from statistics where type='$type'"; + if ($time eq 'today'){ + $query=$query." and datetime + >=datetime('yesterday'::date)"; + } + my $sth=$dbh->prepare($query); + $sth->execute; + my $i=0; + while (my $data=$sth->fetchrow_hashref){ + $i++; + } + $sth->finish; +# print $query; + $dbh->disconnect; + return($i); + } END { } # module clean-up code here (global destructor) diff --git a/countissues.pl b/countissues.pl new file mode 100755 index 0000000..815786b --- /dev/null +++ b/countissues.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl + +#script to keep total of number of issues; + +use C4::Output; +use C4::Stats; +use CGI; + +my $input=new CGI; +print $input->header; +my $count=Count('issue','today'); +print $count; diff --git a/reports.pl b/reports.pl index c68e4af..7bda0c3 100755 --- a/reports.pl +++ b/reports.pl @@ -12,12 +12,17 @@ my $input = new CGI; print $input->header; my $type=$input->param('type'); print startpage(); -print startmenu(); +print startmenu('issue'); +my @data; if ($type eq 'search'){ - my $data=updatestats('search','something'); + @data=statsreport('search','something'); +} +if ($type eq 'issue'){ + @data=statsreport('issue','today'); } -if ($type eq +print mkheadr(1,"$type reports"); +print @data; -print endmenu(); +print endmenu('issue'); print endpage();