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

(-)a/C4/Members.pm (-34 lines)
Lines 113-119 BEGIN { Link Here
113
        &AddMember
113
        &AddMember
114
        &AddMember_Opac
114
        &AddMember_Opac
115
        &MoveMemberToDeleted
115
        &MoveMemberToDeleted
116
        &ExtendMemberSubscriptionTo
117
    );
116
    );
118
117
119
    #Check data
118
    #Check data
Lines 1577-1615 sub HandleDelBorrower { Link Here
1577
    #Koha::Virtualshelf->new->delete too.
1576
    #Koha::Virtualshelf->new->delete too.
1578
}
1577
}
1579
1578
1580
=head2 ExtendMemberSubscriptionTo (OUEST-PROVENCE)
1581
1582
    $date = ExtendMemberSubscriptionTo($borrowerid, $date);
1583
1584
Extending the subscription to a given date or to the expiry date calculated on ISO date.
1585
Returns ISO date.
1586
1587
=cut
1588
1589
sub ExtendMemberSubscriptionTo {
1590
    my ( $borrowerid,$date) = @_;
1591
    my $dbh = C4::Context->dbh;
1592
    my $borrower = GetMember('borrowernumber'=>$borrowerid);
1593
    unless ($date){
1594
      $date = (C4::Context->preference('BorrowerRenewalPeriodBase') eq 'dateexpiry') ?
1595
                                        eval { output_pref( { dt => dt_from_string( $borrower->{'dateexpiry'}  ), dateonly => 1, dateformat => 'iso' } ); }
1596
                                        :
1597
                                        output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } );
1598
      $date = Koha::Patron::Categories->find( $borrower->{categorycode} )->get_expiry_date( $date );
1599
    }
1600
    my $sth = $dbh->do(<<EOF);
1601
UPDATE borrowers 
1602
SET  dateexpiry='$date' 
1603
WHERE borrowernumber='$borrowerid'
1604
EOF
1605
1606
    AddEnrolmentFeeIfNeeded( $borrower->{categorycode}, $borrower->{borrowernumber} );
1607
1608
    logaction("MEMBERS", "RENEW", $borrower->{'borrowernumber'}, "Membership renewed")if C4::Context->preference("BorrowersLog");
1609
    return $date if ($sth);
1610
    return 0;
1611
}
1612
1613
=head2 GetHideLostItemsPreference
1579
=head2 GetHideLostItemsPreference
1614
1580
1615
  $hidelostitemspref = &GetHideLostItemsPreference($borrowernumber);
1581
  $hidelostitemspref = &GetHideLostItemsPreference($borrowernumber);
(-)a/Koha/Patron.pm (+27 lines)
Lines 23-28 use Modern::Perl; Link Here
23
use Carp;
23
use Carp;
24
24
25
use C4::Context;
25
use C4::Context;
26
use C4::Members;
26
use C4::Log;
27
use C4::Log;
27
use Koha::Database;
28
use Koha::Database;
28
use Koha::DateUtils;
29
use Koha::DateUtils;
Lines 208-213 sub update_password { Link Here
208
    return 1;
209
    return 1;
209
}
210
}
210
211
212
=head3 extend_subscription
213
214
my $new_expiry_date = $patron->extend_subscription
215
216
Extending the subscription to the expiry date.
217
218
=cut
219
220
sub extend_subscription {
221
    my ($self) = @_;
222
223
    my $date =
224
      C4::Context->preference('BorrowerRenewalPeriodBase') eq 'dateexpiry'
225
      ? dt_from_string( $self->dateexpiry )
226
      : dt_from_string;
227
    my $patron_category = Koha::Patron::Categories->find( $self->categorycode );    # FIXME Should be $self->category
228
    my $expiry_date     = $patron_category->get_expiry_date($date);
229
230
    $self->dateexpiry($expiry_date)->store;
231
232
    C4::Members::AddEnrolmentFeeIfNeeded( $self->categorycode, $self->borrowernumber );
233
234
    logaction( "MEMBERS", "RENEW", $self->borrowernumber, "Membership renewed" ) if C4::Context->preference("BorrowersLog");
235
    return dt_from_string( $expiry_date )->truncate( to => 'day' );
236
}
237
211
=head3 type
238
=head3 type
212
239
213
=cut
240
=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