[Koha-patches] [PATCH] Custom Reports - Patrons by Category
Kyle M Hall
kyle.m.hall at gmail.com
Tue Jan 26 14:32:56 CET 2010
---
.../org.ccfls.patrons_by_category/report.ini | 5 ++
.../org.ccfls.patrons_by_category/step1.pl | 16 +++++
.../org.ccfls.patrons_by_category/step1.tmpl | 25 ++++++++
.../org.ccfls.patrons_by_category/step2.pl | 34 ++++++++++
.../org.ccfls.patrons_by_category/step2.tmpl | 65 ++++++++++++++++++++
5 files changed, 145 insertions(+), 0 deletions(-)
create mode 100644 reports/custom_reports/org.ccfls.patrons_by_category/report.ini
create mode 100755 reports/custom_reports/org.ccfls.patrons_by_category/step1.pl
create mode 100644 reports/custom_reports/org.ccfls.patrons_by_category/step1.tmpl
create mode 100755 reports/custom_reports/org.ccfls.patrons_by_category/step2.pl
create mode 100644 reports/custom_reports/org.ccfls.patrons_by_category/step2.tmpl
diff --git a/reports/custom_reports/org.ccfls.patrons_by_category/report.ini b/reports/custom_reports/org.ccfls.patrons_by_category/report.ini
new file mode 100644
index 0000000..6816500
--- /dev/null
+++ b/reports/custom_reports/org.ccfls.patrons_by_category/report.ini
@@ -0,0 +1,5 @@
+name=Patrons by Category
+author=Kyle M Hall
+description=A breakdown of library patrons by category code.
+start=patrons_by_category/step1.pl
+
diff --git a/reports/custom_reports/org.ccfls.patrons_by_category/step1.pl b/reports/custom_reports/org.ccfls.patrons_by_category/step1.pl
new file mode 100755
index 0000000..1c54a59
--- /dev/null
+++ b/reports/custom_reports/org.ccfls.patrons_by_category/step1.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use HTML::Template;
+use CGI qw(:all);
+
+use C4::Context;
+use C4::Branch;
+
+my $template = HTML::Template->new( filename => 'step1.tmpl' );
+
+$template->param(
+ branches_loop => GetBranchesLoop()
+);
+
+print header;
+print $template->output();
\ No newline at end of file
diff --git a/reports/custom_reports/org.ccfls.patrons_by_category/step1.tmpl b/reports/custom_reports/org.ccfls.patrons_by_category/step1.tmpl
new file mode 100644
index 0000000..f1a77f6
--- /dev/null
+++ b/reports/custom_reports/org.ccfls.patrons_by_category/step1.tmpl
@@ -0,0 +1,25 @@
+<html>
+<head>
+ <title>Patrons by Category</title>
+</head>
+<body>
+
+ <h1>Patrons by Category</h1>
+
+ <form action="step2.pl" method="get">
+
+ <label for="branch">Select Library:</label>
+ <select name="branch">
+ <!-- TMPL_LOOP NAME="branches_loop" -->
+ <option value="<!-- TMPL_VAR name="value" escape="html" -->" <!-- TMPL_IF NAME="selected" -->selected="selected"<!-- /TMPL_IF --> >
+ <!-- TMPL_VAR name="branchname" -->
+ </option>
+ <!-- /TMPL_LOOP -->
+ </select>
+
+ <input type="submit" value="Run Report" />
+
+ </form>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/reports/custom_reports/org.ccfls.patrons_by_category/step2.pl b/reports/custom_reports/org.ccfls.patrons_by_category/step2.pl
new file mode 100755
index 0000000..39fb486
--- /dev/null
+++ b/reports/custom_reports/org.ccfls.patrons_by_category/step2.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+use HTML::Template;
+use CGI qw(:all);
+
+use C4::Context;
+use C4::Branch;
+use C4::Dates;
+
+my $cgi = CGI->new;
+
+my $branch = $cgi->param('branch');
+
+my $template = HTML::Template->new( filename => 'step2.tmpl' );
+
+my $dbh = C4::Context->dbh;
+my $query = "SELECT COUNT(*) AS borrowersCount, categorycode FROM borrowers WHERE branchcode LIKE '$branch' GROUP BY categorycode";
+
+my $sth = $dbh->prepare( $query );
+$sth->execute();
+
+my @results;
+while ( my $row = $sth->fetchrow_hashref() ) {
+ push( @results, $row );
+}
+
+my $date = C4::Dates->new();
+
+$template->param( date_ran => $date->output() );
+$template->param( results_loop => \@results );
+$template->param( branch => $branch );
+
+print header;
+print $template->output();
diff --git a/reports/custom_reports/org.ccfls.patrons_by_category/step2.tmpl b/reports/custom_reports/org.ccfls.patrons_by_category/step2.tmpl
new file mode 100644
index 0000000..c1c8b88
--- /dev/null
+++ b/reports/custom_reports/org.ccfls.patrons_by_category/step2.tmpl
@@ -0,0 +1,65 @@
+<html>
+<head>
+ <title>Koha Report: Patrons by Category</title>
+
+ <link href="tablecloth.css" rel="stylesheet" type="text/css" media="screen" />
+ <script type="text/javascript" src="tablecloth.js"></script>
+</head>
+<body>
+
+ <h3>Patrons by Category</h3>
+
+ <h5>Library: <!-- TMPL_VAR NAME="branch" --></h5>
+ <h5>Date Ran: <!-- TMPL_VAR NAME="date_ran" --></h5>
+
+ <table border=1>
+ <tr>
+ <th>Category Code</th>
+ <th>Count</th>
+ </tr>
+
+ <!-- TMPL_LOOP NAME="results_loop" -->
+ <tr>
+ <td><!-- TMPL_VAR NAME="categorycode" --></td>
+ <td><!-- TMPL_VAR NAME="borrowersCount" --></td>
+ </tr>
+ <!-- /TMPL_LOOP -->
+ </table>
+</body>
+</html>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</body>
+</html>
\ No newline at end of file
--
1.5.6.5
More information about the Koha-patches
mailing list