[Koha-patches] [PATCH] members/readingrec add option to show only this year
Michael Hafen
mdhafen at tech.washk12.org
Tue Oct 6 21:23:56 CEST 2009
Adds an option to the Members Reading Record to show only circulation this year.
The first month of the year is selectable allowing schools to choose something
other than January as the beginning of the year.
The default is to show the year view.
---
C4/Members.pm | 7 ++-
.../prog/en/modules/members/readingrec.tmpl | 78 +++++++++++++++++++-
members/readingrec.pl | 19 ++++-
3 files changed, 97 insertions(+), 7 deletions(-)
diff --git a/C4/Members.pm b/C4/Members.pm
index 9ce2001..1523b9f 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -1030,11 +1030,14 @@ elements in C<$issues>
#'
sub GetAllIssues {
- my ( $borrowernumber, $order, $limit ) = @_;
+ my ( $borrowernumber, $order, $limit, $startDate ) = @_;
#FIXME: sanity-check order and limit
my $dbh = C4::Context->dbh;
my $count = 0;
+ if ( $startDate ) {
+ $startDate = "AND issuedate > '$startDate'";
+ }
my $query =
"SELECT *,issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp
FROM issues
@@ -1042,6 +1045,7 @@ sub GetAllIssues {
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber
WHERE borrowernumber=?
+ $startDate
UNION ALL
SELECT *,old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp
FROM old_issues
@@ -1049,6 +1053,7 @@ sub GetAllIssues {
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber
WHERE borrowernumber=?
+ $startDate
order by $order";
if ( $limit != 0 ) {
$query .= " limit $limit";
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tmpl
index f432eaf..d18cb2b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tmpl
@@ -16,9 +16,81 @@
<!-- TMPL_INCLUDE NAME="circ-toolbar.inc" -->
<h1>Reading Record</h1>
<form action="/cgi-bin/koha/members/readingrec.pl" method="get"><input type="hidden" name="borrowernumber" id="borrowernumber" value="<!-- TMPL_VAR NAME="borrowernumber" -->" /></form>
-<p><!-- TMPL_IF NAME="showfulllink" -->Showing All Items |
- <a href="readingrec.pl?borrowernumber=<!-- TMPL_VAR name="borrowernumber" -->&limit=50">Show Last 50 Items Only</a> <!-- TMPL_ELSE --> Showing Last 50 Items |
- <a href="readingrec.pl?borrowernumber=<!-- TMPL_VAR name="borrowernumber" -->&limit=full">Show All Items</a><!-- /TMPL_IF --></p>
+<div style="margin:.5em 0"><!-- TMPL_IF NAME="showfulllink" -->Showing All Items |
+ <a href="readingrec.pl?borrowernumber=<!-- TMPL_VAR name="borrowernumber" -->&limit=50">Show Last 50 Items Only</a> |
+ <form method="get" action="readingrec.pl">
+ Show A Years Items Only Starting:
+ <input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR name="borrowernumber" -->" />
+ <input type="hidden" name="limit" value="year" />
+ <select name="startmonth" onchange="this.form.submit()">
+ <option value="0"></option>
+ <option value="1">January</option>
+ <option value="2">February</option>
+ <option value="3">March</option>
+ <option value="4">April</option>
+ <option value="5">May</option>
+ <option value="6">June</option>
+ <option value="7">July</option>
+ <option value="8">August</option>
+ <option value="9">September</option>
+ <option value="10">October</option>
+ <option value="11">November</option>
+ <option value="12">December</option>
+ </select>
+ </form>
+ <!-- TMPL_ELSE -->
+ <!-- TMPL_IF NAME="showyearlink" -->
+ Showing This Years Items Starting:
+ <form id="showyear_selected" name="showyear_selected" method="get" action="readingrec.pl">
+ <input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR name="borrowernumber" -->" />
+ <input type="hidden" name="limit" value="year" />
+ <select name="startmonth" onchange="this.form.submit()">
+ <option value="1">January</option>
+ <option value="2">February</option>
+ <option value="3">March</option>
+ <option value="4">April</option>
+ <option value="5">May</option>
+ <option value="6">June</option>
+ <option value="7">July</option>
+ <option value="8">August</option>
+ <option value="9">September</option>
+ <option value="10">October</option>
+ <option value="11">November</option>
+ <option value="12">December</option>
+ </select>
+ </form> |
+ <!-- TMPL_IF name="showyear_selected" -->
+ <script type="text/javascript">
+ document.forms.showyear_selected.startmonth.options[<!-- TMPL_VAR name="showyear_selected" -->-1].selected = "selected";
+ </script>
+ <!-- /TMPL_IF -->
+ <a href="readingrec.pl?borrowernumber=<!-- TMPL_VAR name="borrowernumber" -->&limit=50">Show Last 50 Items Only</a> |
+ <a href="readingrec.pl?borrowernumber=<!-- TMPL_VAR name="borrowernumber" -->&limit=full">Show All Items</a>
+ <!-- TMPL_ELSE -->
+ Showing Last 50 Items |
+ <form method="get" action="readingrec.pl">
+ Show A Years Items Only Starting:
+ <input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR name="borrowernumber" -->" />
+ <input type="hidden" name="limit" value="year" />
+ <select name="startmonth" onchange="this.form.submit()">
+ <option value="0"></option>
+ <option value="1">January</option>
+ <option value="2">February</option>
+ <option value="3">March</option>
+ <option value="4">April</option>
+ <option value="5">May</option>
+ <option value="6">June</option>
+ <option value="7">July</option>
+ <option value="8">August</option>
+ <option value="9">September</option>
+ <option value="10">October</option>
+ <option value="11">November</option>
+ <option value="12">December</option>
+ </select>
+ </form> |
+ <a href="readingrec.pl?borrowernumber=<!-- TMPL_VAR name="borrowernumber" -->&limit=full">Show All Items</a>
+ <!-- /TMPL_IF -->
+<!-- /TMPL_IF --></div>
<table>
<tr>
<th>
diff --git a/members/readingrec.pl b/members/readingrec.pl
index ce3fb37..677b618 100755
--- a/members/readingrec.pl
+++ b/members/readingrec.pl
@@ -41,17 +41,28 @@ my $order2=$order;
if ($order2 eq ''){
$order2="date_due desc";
}
-my $limit=$input->param('limit');
+my $limit=$input->param('limit') || 'year'; # default to year view
+my $startMonth=$input->param('startmonth') || 1;
+my $startDate='';
if ($limit){
if ($limit eq 'full'){
$limit=0;
}
+ elsif ($limit eq 'year' && $startMonth) {
+ $limit=0;
+ my @dateArray = localtime();
+ if ( $dateArray[4] < $startMonth - 1 ) { # check month
+ # Handle a start of the year that is not January
+ $dateArray[5]--; # drop the year for month not past the first month
+ }
+ $startDate=$dateArray[5]+1900 .'-'. sprintf('%02d',$startMonth) .'-'. '01';
+ }
}
else {
$limit=50;
}
-my ($count,$issues)=GetAllIssues($borrowernumber,$order2,$limit);
+my ($count,$issues)=GetAllIssues($borrowernumber,$order2,$limit,$startDate);
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "members/readingrec.tmpl",
@@ -117,7 +128,9 @@ $template->param(
branchcode => $data->{'branchcode'},
is_child => ($data->{'category_type'} eq 'C'),
branchname => GetBranchName($data->{'branchcode'}),
- showfulllink => ($count > 50),
+ showfulllink => (! $limit),
+ showyearlink => ( $startDate ne '' ),
+ showyear_selected => $startMonth,
loop_reading => \@loop_reading);
output_html_with_http_headers $input, $cookie, $template->output;
--
1.6.0.4
More information about the Koha-patches
mailing list