You are here

function library_notify_overdue in Library 7

Same name and namespace in other branches
  1. 5.2 library.admin.inc \library_notify_overdue()
  2. 6.2 library.admin.inc \library_notify_overdue()
  3. 6 library.admin.inc \library_notify_overdue()

Send email to patrons with overdue items.

1 string reference to 'library_notify_overdue'
library_menu in ./library.module
Implements hook_menu().

File

./library.admin.inc, line 483
Administrative settings for the library module

Code

function library_notify_overdue() {
  if (library_duedates_enabled()) {
    $records = library_get_overdue_items();
    if (empty($records)) {
      drupal_set_message(t('No patrons with overdue items at this time.'));
    }
    else {
      $num_emails = 0;
      foreach ($records as $patron_uid => $record) {
        $params = $record;
        drupal_mail('library', 'notify_overdue', $params['patron']['patron_email'], language_default(), $params);
        watchdog('library', 'Overdue notice sent to %email', array(
          '%email' => $params['patron']['patron_email'],
        ));
        $num_emails++;
      }
      drupal_set_message(t('@number email(s) sent successfully.', array(
        '@number' => $num_emails,
      )));
      watchdog('library', '%number overdue email notifications sent successfully.', array(
        '%number' => $num_emails,
      ));
    }
  }
  else {
    drupal_set_message(t('Library due dates are not enabled.'));
  }
  drupal_goto('library-items/overdue');
}