Exemple #1
0
$query = prepare("SELECT *\n                    FROM reminder\n                   WHERE reminderActive = 1\n                     AND reminderAdvNoticeSent = 0\n                     AND NOW() > \n                         CASE\n                           WHEN reminderAdvNoticeInterval = 'Minute' THEN DATE_SUB(reminderTime, INTERVAL reminderAdvNoticeValue MINUTE)\n                           WHEN reminderAdvNoticeInterval = 'Hour'   THEN DATE_SUB(reminderTime, INTERVAL reminderAdvNoticeValue HOUR)\n                           WHEN reminderAdvNoticeInterval = 'Day'    THEN DATE_SUB(reminderTime, INTERVAL reminderAdvNoticeValue DAY)\n                           WHEN reminderAdvNoticeInterval = 'Week'   THEN DATE_SUB(reminderTime, INTERVAL reminderAdvNoticeValue WEEK)\n                           WHEN reminderAdvNoticeInterval = 'No'     THEN NULL\n                         END\n                 ");
$db->query($query);
while ($db->next_record()) {
    $reminder = new reminder();
    $reminder->read_db_record($db);
    //echo "<br>Adv: ".$reminder->get_id();
    $current_user = new person();
    $current_user->load_current_user($db->f('reminderCreatedUser'));
    singleton("current_user", $current_user);
    if (!$reminder->is_alive()) {
        $reminder->deactivate();
    } else {
        $reminder->mail_advnotice();
    }
}
// do reminders
$query = prepare("SELECT *\n                    FROM reminder\n                   WHERE reminderActive = 1\n                     AND (reminderTime IS NULL OR NOW() > reminderTime)\n                 ");
$db->query($query);
while ($db->next_record()) {
    $reminder = new reminder();
    $reminder->read_db_record($db);
    //echo "<br>Rem: ".$reminder->get_id();
    $current_user = new person();
    $current_user->load_current_user($db->f('reminderCreatedUser'));
    singleton("current_user", $current_user);
    if (!$reminder->is_alive()) {
        $reminder->deactivate();
    } else {
        $reminder->mail_reminder();
    }
}