Lines 2745-2750
sub CanBookBeRenewed {
Link Here
|
2745 |
return ( 0, "too_many" ) |
2745 |
return ( 0, "too_many" ) |
2746 |
if not $issuing_rule or $issuing_rule->renewalsallowed <= $issue->renewals; |
2746 |
if not $issuing_rule or $issuing_rule->renewalsallowed <= $issue->renewals; |
2747 |
|
2747 |
|
|
|
2748 |
return ( 0, "too_unseen" ) |
2749 |
if C4::Context->preference('UnseenRenewals') && |
2750 |
$issuing_rule->unseen_renewals_allowed && |
2751 |
$issuing_rule->unseen_renewals_allowed <= $issue->unseen_renewals; |
2752 |
|
2748 |
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); |
2753 |
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); |
2749 |
my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing'); |
2754 |
my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing'); |
2750 |
$patron = Koha::Patrons->find($borrowernumber); # FIXME Is this really useful? |
2755 |
$patron = Koha::Patrons->find($borrowernumber); # FIXME Is this really useful? |
Lines 2835-2841
sub CanBookBeRenewed {
Link Here
|
2835 |
|
2840 |
|
2836 |
=head2 AddRenewal |
2841 |
=head2 AddRenewal |
2837 |
|
2842 |
|
2838 |
&AddRenewal($borrowernumber, $itemnumber, $branch, [$datedue], [$lastreneweddate]); |
2843 |
&AddRenewal($borrowernumber, $itemnumber, $branch, [$datedue], [$lastreneweddate], [$seen]); |
2839 |
|
2844 |
|
2840 |
Renews a loan. |
2845 |
Renews a loan. |
2841 |
|
2846 |
|
Lines 2855-2860
this parameter is not supplied, lastreneweddate is set to the current date.
Link Here
|
2855 |
If C<$datedue> is the empty string, C<&AddRenewal> will calculate the due date automatically |
2860 |
If C<$datedue> is the empty string, C<&AddRenewal> will calculate the due date automatically |
2856 |
from the book's item type. |
2861 |
from the book's item type. |
2857 |
|
2862 |
|
|
|
2863 |
C<$seen> is a boolean flag indicating if the item was seen or not during the renewal. This |
2864 |
informs the incrementing of the unseen_renewals column. If this flag is not supplied, we |
2865 |
fallback to a true value |
2866 |
|
2858 |
=cut |
2867 |
=cut |
2859 |
|
2868 |
|
2860 |
sub AddRenewal { |
2869 |
sub AddRenewal { |
Lines 2863-2868
sub AddRenewal {
Link Here
|
2863 |
my $branch = shift; |
2872 |
my $branch = shift; |
2864 |
my $datedue = shift; |
2873 |
my $datedue = shift; |
2865 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz); |
2874 |
my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz); |
|
|
2875 |
my $seen = shift; |
2876 |
|
2877 |
# Fallback on a 'seen' renewal |
2878 |
$seen = defined $seen && $seen == 0 ? 0 : 1; |
2866 |
|
2879 |
|
2867 |
my $item_object = Koha::Items->find($itemnumber) or return; |
2880 |
my $item_object = Koha::Items->find($itemnumber) or return; |
2868 |
my $biblio = $item_object->biblio; |
2881 |
my $biblio = $item_object->biblio; |
Lines 2915-2929
sub AddRenewal {
Link Here
|
2915 |
} |
2928 |
} |
2916 |
); |
2929 |
); |
2917 |
|
2930 |
|
|
|
2931 |
# Increment the unseen renewals, if appropriate |
2932 |
# We only do so if the syspref is enabled and |
2933 |
# a maximum value has been set in the circ rules |
2934 |
my $unseen_renewals = $issue->unseen_renewals; |
2935 |
if (C4::Context->preference('UnseenRenewals')) { |
2936 |
my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( |
2937 |
{ categorycode => $patron->categorycode, |
2938 |
itemtype => $item_object->effective_itemtype, |
2939 |
branchcode => $circ_library->branchcode |
2940 |
} |
2941 |
); |
2942 |
if (!$seen && $issuing_rule && $issuing_rule->unseen_renewals_allowed) { |
2943 |
$unseen_renewals++; |
2944 |
} else { |
2945 |
# If the renewal is seen, unseen should revert to 0 |
2946 |
$unseen_renewals = 0; |
2947 |
} |
2948 |
} |
2949 |
|
2918 |
# Update the issues record to have the new due date, and a new count |
2950 |
# Update the issues record to have the new due date, and a new count |
2919 |
# of how many times it has been renewed. |
2951 |
# of how many times it has been renewed. |
2920 |
my $renews = $issue->renewals + 1; |
2952 |
my $renews = $issue->renewals + 1; |
2921 |
my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, lastreneweddate = ? |
2953 |
my $sth = $dbh->prepare("UPDATE issues SET date_due = ?, renewals = ?, unseen_renewals = ?, lastreneweddate = ? |
2922 |
WHERE borrowernumber=? |
2954 |
WHERE borrowernumber=? |
2923 |
AND itemnumber=?" |
2955 |
AND itemnumber=?" |
2924 |
); |
2956 |
); |
2925 |
|
2957 |
|
2926 |
$sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $lastreneweddate, $borrowernumber, $itemnumber ); |
2958 |
$sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $borrowernumber, $itemnumber ); |
2927 |
|
2959 |
|
2928 |
# Update the renewal count on the item, and tell zebra to reindex |
2960 |
# Update the renewal count on the item, and tell zebra to reindex |
2929 |
$renews = $item_object->renewals + 1; |
2961 |
$renews = $item_object->renewals + 1; |
Lines 3005-3012
sub GetRenewCount {
Link Here
|
3005 |
my ( $bornum, $itemno ) = @_; |
3037 |
my ( $bornum, $itemno ) = @_; |
3006 |
my $dbh = C4::Context->dbh; |
3038 |
my $dbh = C4::Context->dbh; |
3007 |
my $renewcount = 0; |
3039 |
my $renewcount = 0; |
|
|
3040 |
my $unseencount = 0; |
3008 |
my $renewsallowed = 0; |
3041 |
my $renewsallowed = 0; |
|
|
3042 |
my $unseenallowed = 0; |
3009 |
my $renewsleft = 0; |
3043 |
my $renewsleft = 0; |
|
|
3044 |
my $unseenleft = 0; |
3010 |
|
3045 |
|
3011 |
my $patron = Koha::Patrons->find( $bornum ); |
3046 |
my $patron = Koha::Patrons->find( $bornum ); |
3012 |
my $item = Koha::Items->find($itemno); |
3047 |
my $item = Koha::Items->find($itemno); |
Lines 3025-3030
sub GetRenewCount {
Link Here
|
3025 |
$sth->execute( $bornum, $itemno ); |
3060 |
$sth->execute( $bornum, $itemno ); |
3026 |
my $data = $sth->fetchrow_hashref; |
3061 |
my $data = $sth->fetchrow_hashref; |
3027 |
$renewcount = $data->{'renewals'} if $data->{'renewals'}; |
3062 |
$renewcount = $data->{'renewals'} if $data->{'renewals'}; |
|
|
3063 |
$unseencount = $data->{'unseen_renewals'} if $data->{'unseen_renewals'}; |
3028 |
# $item and $borrower should be calculated |
3064 |
# $item and $borrower should be calculated |
3029 |
my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed); |
3065 |
my $branchcode = _GetCircControlBranch($item->unblessed, $patron->unblessed); |
3030 |
|
3066 |
|
Lines 3036-3044
sub GetRenewCount {
Link Here
|
3036 |
); |
3072 |
); |
3037 |
|
3073 |
|
3038 |
$renewsallowed = $issuing_rule ? $issuing_rule->renewalsallowed : 0; |
3074 |
$renewsallowed = $issuing_rule ? $issuing_rule->renewalsallowed : 0; |
|
|
3075 |
$unseenallowed = $issuing_rule ? $issuing_rule->unseen_renewals_allowed : 0; |
3039 |
$renewsleft = $renewsallowed - $renewcount; |
3076 |
$renewsleft = $renewsallowed - $renewcount; |
|
|
3077 |
$unseenleft = $unseenallowed - $unseencount; |
3040 |
if($renewsleft < 0){ $renewsleft = 0; } |
3078 |
if($renewsleft < 0){ $renewsleft = 0; } |
3041 |
return ( $renewcount, $renewsallowed, $renewsleft ); |
3079 |
if($unseenleft < 0){ $unseenleft = 0; } |
|
|
3080 |
return ( |
3081 |
$renewcount, |
3082 |
$renewsallowed, |
3083 |
$renewsleft, |
3084 |
$unseencount, |
3085 |
$unseenallowed, |
3086 |
$unseenleft |
3087 |
); |
3042 |
} |
3088 |
} |
3043 |
|
3089 |
|
3044 |
=head2 GetSoonestRenewDate |
3090 |
=head2 GetSoonestRenewDate |