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

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

Return to bug 17569