Browse Source

adding back count of remaining renewals to OPAC

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
3.0.x
Joshua Ferraro 17 years ago
parent
commit
52d9e90655
  1. 30
      C4/Circulation.pm
  2. 4
      koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
  3. 1
      opac/opac-user.pl

30
C4/Circulation.pm

@ -77,6 +77,7 @@ push @EXPORT, qw(
&CanBookBeRenewed
&AddIssue
&AddRenewal
&GetRenewCount
&GetItemIssue
&GetItemIssues
&GetBorrowerIssues
@ -1662,6 +1663,35 @@ sub AddRenewal {
UpdateStats( C4::Context->userenv->{'branchcode'}, 'renew', $charge, '', $itemnumber );
}
sub GetRenewCount {
# check renewal status
my ($bornum,$itemno)=@_;
my $dbh = C4::Context->dbh;
my $renewcount = 0;
my $renewsallowed = 0;
my $renewsleft = 0;
# Look in the issues table for this item, lent to this borrower,
# and not yet returned.
# FIXME - I think this function could be redone to use only one SQL call.
my $sth = $dbh->prepare("select * from issues
where (borrowernumber = ?)
and (itemnumber = ?)
and returndate is null");
$sth->execute($bornum,$itemno);
my $data = $sth->fetchrow_hashref;
$renewcount = $data->{'renewals'} if $data->{'renewals'};
my $sth2 = $dbh->prepare("select renewalsallowed from items,biblioitems,itemtypes
where (items.itemnumber = ?)
and (items.biblioitemnumber = biblioitems.biblioitemnumber)
and (biblioitems.itemtype = itemtypes.itemtype)");
$sth2->execute($itemno);
my $data2 = $sth2->fetchrow_hashref();
$renewsallowed = $data2->{'renewalsallowed'};
$renewsleft = $renewsallowed - $renewcount;
warn "Renewcount:$renewcount RenewsAll:$renewsallowed RenewLeft:$renewsleft";
return ($renewcount,$renewsallowed,$renewsleft);
}
=head2 GetIssuingCharges
($charge, $item_type) = &GetIssuingCharges($itemnumber, $borrowernumber);

4
koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl

@ -161,7 +161,7 @@
<!-- TMPL_UNLESS name="patron_flagged" -->
<td>
<!-- TMPL_IF NAME="status" -->
<a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=<!-- TMPL_VAR NAME="itemnumber" -->&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Renew</a>
<a href="/cgi-bin/koha/opac-renew.pl?from=opac_user&amp;item=<!-- TMPL_VAR NAME="itemnumber" -->&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->">Renew</a> <span class="renewals">(<!-- TMPL_VAR NAME="renewsleft" --> of <!-- TMPL_VAR NAME="renewsallowed" --> renewals remaining)</span>
<!-- TMPL_ELSE -->
Not renewable
<!-- /TMPL_IF -->
@ -268,4 +268,4 @@ No renewals left
<!-- TMPL_INCLUDE name="usermenu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->

1
opac/opac-user.pl

@ -113,6 +113,7 @@ foreach my $issue ( @$issues ) {
# check if item is renewable
my $status = CanBookBeRenewed( $borrowernumber, $issue->{'itemnumber'} );
($issue->{'renewcount'},$issue->{'renewsallowed'},$issue->{'renewsleft'}) = GetRenewCount($borrowernumber, $issue->{'itemnumber'});
$issue->{'status'} = $status;

Loading…
Cancel
Save