View | Details | Raw Unified | Return to bug 16911
Collapse All | Expand All

(-)a/C4/Members.pm (-34 lines)
Lines 116-122 BEGIN { Link Here
116
        &AddMember
116
        &AddMember
117
        &AddMember_Opac
117
        &AddMember_Opac
118
        &MoveMemberToDeleted
118
        &MoveMemberToDeleted
119
        &ExtendMemberSubscriptionTo
120
    );
119
    );
121
120
122
    #Check data
121
    #Check data
Lines 1682-1720 sub HandleDelBorrower { Link Here
1682
    #Koha::Virtualshelf->new->delete too.
1681
    #Koha::Virtualshelf->new->delete too.
1683
}
1682
}
1684
1683
1685
=head2 ExtendMemberSubscriptionTo (OUEST-PROVENCE)
1686
1687
    $date = ExtendMemberSubscriptionTo($borrowerid, $date);
1688
1689
Extending the subscription to a given date or to the expiry date calculated on ISO date.
1690
Returns ISO date.
1691
1692
=cut
1693
1694
sub ExtendMemberSubscriptionTo {
1695
    my ( $borrowerid,$date) = @_;
1696
    my $dbh = C4::Context->dbh;
1697
    my $borrower = GetMember('borrowernumber'=>$borrowerid);
1698
    unless ($date){
1699
      $date = (C4::Context->preference('BorrowerRenewalPeriodBase') eq 'dateexpiry') ?
1700
                                        eval { output_pref( { dt => dt_from_string( $borrower->{'dateexpiry'}  ), dateonly => 1, dateformat => 'iso' } ); }
1701
                                        :
1702
                                        output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
1703
      $date = Koha::Patron::Categories->find( $borrower->{categorycode} )->get_expiry_date( $date );
1704
    }
1705
    my $sth = $dbh->do(<<EOF);
1706
UPDATE borrowers 
1707
SET  dateexpiry='$date' 
1708
WHERE borrowernumber='$borrowerid'
1709
EOF
1710
1711
    AddEnrolmentFeeIfNeeded( $borrower->{categorycode}, $borrower->{borrowernumber} );
1712
1713
    logaction("MEMBERS", "RENEW", $borrower->{'borrowernumber'}, "Membership renewed")if C4::Context->preference("BorrowersLog");
1714
    return $date if ($sth);
1715
    return 0;
1716
}
1717
1718
=head2 GetTitles (OUEST-PROVENCE)
1684
=head2 GetTitles (OUEST-PROVENCE)
1719
1685
1720
  ($borrowertitle)= &GetTitles();
1686
  ($borrowertitle)= &GetTitles();
(-)a/Koha/Patron.pm (+28 lines)
Lines 23-29 use Modern::Perl; Link Here
23
use Carp;
23
use Carp;
24
24
25
use C4::Context;
25
use C4::Context;
26
use C4::Log;
26
use Koha::Database;
27
use Koha::Database;
28
use Koha::DateUtils;
27
use Koha::Issues;
29
use Koha::Issues;
28
use Koha::OldIssues;
30
use Koha::OldIssues;
29
use Koha::Patron::Categories;
31
use Koha::Patron::Categories;
Lines 168-173 sub do_check_for_previous_checkout { Link Here
168
    return $old_issues->count;  # 0 || N
170
    return $old_issues->count;  # 0 || N
169
}
171
}
170
172
173
=head3 extend_subscription
174
175
my $new_expiry_date = $patron->extend_subscription
176
177
Extending the subscription to the expiry date.
178
179
=cut
180
181
sub extend_subscription {
182
    my ($self) = @_;
183
184
    my $date =
185
      C4::Context->preference('BorrowerRenewalPeriodBase') eq 'dateexpiry'
186
      ? dt_from_string( $self->dateexpiry )
187
      : dt_from_string;
188
    my $patron_category = Koha::Patron::Categories->find( $self->categorycode );    # FIXME Should be $self->category
189
    my $expiry_date     = $patron_category->get_expiry_date($date);
190
191
    $self->dateexpiry($expiry_date)->store;
192
193
    C4::Members::AddEnrolmentFeeIfNeeded( $self->categorycode, $self->borrowernumber );
194
195
    logaction( "MEMBERS", "RENEW", $self->borrowernumber, "Membership renewed" ) if C4::Context->preference("BorrowersLog");
196
    return dt_from_string( $expiry_date )->truncate( to => 'day' );
197
}
198
171
=head3 type
199
=head3 type
172
200
173
=cut
201
=cut
(-)a/members/setstatus.pl (-3 / +3 lines)
Lines 30-35 use CGI qw ( -utf8 ); Link Here
30
use C4::Context;
30
use C4::Context;
31
use C4::Members;
31
use C4::Members;
32
use C4::Auth;
32
use C4::Auth;
33
use Koha::Patrons;
33
34
34
35
35
my $input = new CGI;
36
my $input = new CGI;
Lines 45-52 my $dbh = C4::Context->dbh; Link Here
45
my $dateexpiry;
46
my $dateexpiry;
46
47
47
if ( $reregistration eq 'y' ) {
48
if ( $reregistration eq 'y' ) {
48
	# re-reregistration function to automatic calcul of date expiry
49
    # re-reregistration function to automatic calcul of date expiry
49
	$dateexpiry = ExtendMemberSubscriptionTo( $borrowernumber );
50
    $dateexpiry = Koha::Patrons->find( $borrowernumber )->extend_subscription;
50
} else {
51
} else {
51
    my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
52
    my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
52
    $sth->execute( $status, $borrowernumber );
53
    $sth->execute( $status, $borrowernumber );
53
- 

Return to bug 16911