working on issues reports
This commit is contained in:
parent
79d81be2a4
commit
22bc0fcc98
4 changed files with 86 additions and 9 deletions
14
C4/Output.pm
14
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=<FILE>;
|
||||
close FILE;
|
||||
my $count=@string;
|
||||
$string[$count]="<BLOCKQUOTE>";
|
||||
# $string[$count]="<BLOCKQUOTE>";
|
||||
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=<FILE>;
|
||||
close FILE;
|
||||
return @string;
|
||||
|
|
56
C4/Stats.pm
56
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)
|
||||
|
|
12
countissues.pl
Executable file
12
countissues.pl
Executable file
|
@ -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;
|
13
reports.pl
13
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();
|
||||
|
|
Loading…
Reference in a new issue