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

(-)a/C4/Members.pm (-50 lines)
Lines 82-89 BEGIN { Link Here
82
        &GetBorrowersWhoHaveNeverBorrowed
82
        &GetBorrowersWhoHaveNeverBorrowed
83
        &GetBorrowersWithIssuesHistoryOlderThan
83
        &GetBorrowersWithIssuesHistoryOlderThan
84
84
85
        &GetUpcomingMembershipExpires
86
87
        &IssueSlip
85
        &IssueSlip
88
        GetBorrowersWithEmail
86
        GetBorrowersWithEmail
89
87
Lines 1164-1216 sub GetNoticeEmailAddress { Link Here
1164
    return $data->{'primaryemail'} || '';
1162
    return $data->{'primaryemail'} || '';
1165
}
1163
}
1166
1164
1167
=head2 GetUpcomingMembershipExpires
1168
1169
    my $expires = GetUpcomingMembershipExpires({
1170
        branch => $branch, before => $before, after => $after,
1171
    });
1172
1173
    $branch is an optional branch code.
1174
    $before/$after is an optional number of days before/after the date that
1175
    is set by the preference MembershipExpiryDaysNotice.
1176
    If the pref would be 14, before 2 and after 3, you will get all expires
1177
    from 12 to 17 days.
1178
1179
=cut
1180
1181
sub GetUpcomingMembershipExpires {
1182
    my ( $params ) = @_;
1183
    my $before = $params->{before} || 0;
1184
    my $after  = $params->{after} || 0;
1185
    my $branch = $params->{branch};
1186
1187
    my $dbh = C4::Context->dbh;
1188
    my $days = C4::Context->preference("MembershipExpiryDaysNotice") || 0;
1189
    my $date1 = dt_from_string->add( days => $days - $before );
1190
    my $date2 = dt_from_string->add( days => $days + $after );
1191
    $date1= output_pref({ dt => $date1, dateformat => 'iso', dateonly => 1 });
1192
    $date2= output_pref({ dt => $date2, dateformat => 'iso', dateonly => 1 });
1193
1194
    my $query = q|
1195
        SELECT borrowers.*, categories.description,
1196
        branches.branchname, branches.branchemail FROM borrowers
1197
        LEFT JOIN branches USING (branchcode)
1198
        LEFT JOIN categories USING (categorycode)
1199
    |;
1200
    if( $branch ) {
1201
        $query.= 'WHERE branchcode=? AND dateexpiry BETWEEN ? AND ?';
1202
    } else {
1203
        $query.= 'WHERE dateexpiry BETWEEN ? AND ?';
1204
    }
1205
1206
    my $sth = $dbh->prepare( $query );
1207
    my @pars = $branch? ( $branch ): ();
1208
    push @pars, $date1, $date2;
1209
    $sth->execute( @pars );
1210
    my $results = $sth->fetchall_arrayref( {} );
1211
    return $results;
1212
}
1213
1214
=head2 GetAge
1165
=head2 GetAge
1215
1166
1216
  $dateofbirth,$date = &GetAge($date);
1167
  $dateofbirth,$date = &GetAge($date);
1217
- 

Return to bug 17569