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

(-)a/C4/Members.pm (-50 lines)
Lines 76-83 BEGIN { Link Here
76
        &GetBorrowersWhoHaveNeverBorrowed
76
        &GetBorrowersWhoHaveNeverBorrowed
77
        &GetBorrowersWithIssuesHistoryOlderThan
77
        &GetBorrowersWithIssuesHistoryOlderThan
78
78
79
        &GetUpcomingMembershipExpires
80
81
        &IssueSlip
79
        &IssueSlip
82
        GetBorrowersWithEmail
80
        GetBorrowersWithEmail
83
81
Lines 1059-1111 sub GetNoticeEmailAddress { Link Here
1059
    return $data->{'primaryemail'} || '';
1057
    return $data->{'primaryemail'} || '';
1060
}
1058
}
1061
1059
1062
=head2 GetUpcomingMembershipExpires
1063
1064
    my $expires = GetUpcomingMembershipExpires({
1065
        branch => $branch, before => $before, after => $after,
1066
    });
1067
1068
    $branch is an optional branch code.
1069
    $before/$after is an optional number of days before/after the date that
1070
    is set by the preference MembershipExpiryDaysNotice.
1071
    If the pref would be 14, before 2 and after 3, you will get all expires
1072
    from 12 to 17 days.
1073
1074
=cut
1075
1076
sub GetUpcomingMembershipExpires {
1077
    my ( $params ) = @_;
1078
    my $before = $params->{before} || 0;
1079
    my $after  = $params->{after} || 0;
1080
    my $branch = $params->{branch};
1081
1082
    my $dbh = C4::Context->dbh;
1083
    my $days = C4::Context->preference("MembershipExpiryDaysNotice") || 0;
1084
    my $date1 = dt_from_string->add( days => $days - $before );
1085
    my $date2 = dt_from_string->add( days => $days + $after );
1086
    $date1= output_pref({ dt => $date1, dateformat => 'iso', dateonly => 1 });
1087
    $date2= output_pref({ dt => $date2, dateformat => 'iso', dateonly => 1 });
1088
1089
    my $query = q|
1090
        SELECT borrowers.*, categories.description,
1091
        branches.branchname, branches.branchemail FROM borrowers
1092
        LEFT JOIN branches USING (branchcode)
1093
        LEFT JOIN categories USING (categorycode)
1094
    |;
1095
    if( $branch ) {
1096
        $query.= 'WHERE branchcode=? AND dateexpiry BETWEEN ? AND ?';
1097
    } else {
1098
        $query.= 'WHERE dateexpiry BETWEEN ? AND ?';
1099
    }
1100
1101
    my $sth = $dbh->prepare( $query );
1102
    my @pars = $branch? ( $branch ): ();
1103
    push @pars, $date1, $date2;
1104
    $sth->execute( @pars );
1105
    my $results = $sth->fetchall_arrayref( {} );
1106
    return $results;
1107
}
1108
1109
=head2 GetBorrowersToExpunge
1060
=head2 GetBorrowersToExpunge
1110
1061
1111
  $borrowers = &GetBorrowersToExpunge(
1062
  $borrowers = &GetBorrowersToExpunge(
1112
- 

Return to bug 17569