Beispiel #1
0
$mysqlim = connectdb(true);
$mysqlim2 = connectdb(true);
//Send the mail for stuff coming due that hasnt been completed yet
$mailstmt = $mysqlim->prepare("SELECT notify.NotifyID, tasks_working.Scheduled, tasks_master.Title, users.Email, CURRENT_TIMESTAMP from tasks_working LEFT JOIN tasks_master on tasks_master.TaskID=tasks_working.TaskID LEFT JOIN notify ON notify.TaskID=tasks_master.TaskID LEFT JOIN users on notify.UserID=users.UserID WHERE tasks_working.Scheduled<DATE_ADD(CURRENT_TIMESTAMP, INTERVAL 30 MINUTE) AND tasks_master.Active='Y' AND notify.LastSent<>DATE(NOW()) AND users.Active='Y' AND (tasks_working.CompletedBy='' OR tasks_working.CompletedBy IS NULL OR tasks_working.CompletedBy=0)");
$mailstmt->execute();
$mailstmt->bind_result($rmid, $rmscheduled, $rmtitle, $rmemail, $thistime);
$mailstmt2 = $mysqlim2->prepare("UPDATE notify SET LastSent = NOW() WHERE NotifyID = ?");
while ($mailstmt->fetch()) {
    echo $thistime . "Mail to be sent to " . $rmemail . " for " . $rmtitle . " scheduled for " . $rmscheduled . "<br />";
    $to = $rmemail;
    $subject = "Task Reminder: " . $rmtitle;
    $body = "Due: " . $rmscheduled . "\r\n" . "Title: " . $rmtitle;
    $headers = 'From: t-sirt-alerts@telecom.co.nz' . "\r\n" . 'Reply-To: t-sirt-alerts@telecom.co.nz' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    if (mail($to, $subject, $body, $headers)) {
        echo "Email successfully sent!<br />";
    } else {
        echo "Email delivery failed -> Please check you web servers mail settings <br />";
    }
    if (!$mailstmt2->bind_param('i', $rmid)) {
        echo "Binding parameters failed: (" . $mailstmt2->errno . ") " . $mailstmt2->error;
    }
    if (!$mailstmt2->execute()) {
        $json[0]['Result'] = "Failed";
        $json[0]['Message'] = "Failed to set notification sent NotifyID " . $rmnotify . " error message: (" . $mailstmt2->errno . ") " . $mailstmt2->error;
    }
}
$mysqlim->close();
$mysqlim2->close();
//Generate the tasks
generate_tasks();
Beispiel #2
0
        }
        if (!$statement->execute()) {
            $json[0]['Result'] = "error";
            $json[0]['Message'] = "Failed to remove notify for TaskID " . $_GET['taskid'] . " error message: (" . $statement->errno . ") " . $statement->error;
        } else {
            $json[0]['Result'] = "success";
            $json[0]['Frame'] = '';
            $json[0]['Message'] = "Successfully removed notify TaskID " . $_GET['taskid'];
        }
    } else {
        $statement = $mysqli->prepare("INSERT INTO notify (TaskID, UserID) VALUES (?,?)");
        if (!$statement->bind_param('ii', $_GET['taskid'], $_SESSION['userid'])) {
            echo "Binding parameters failed: (" . $statement->errno . ") " . $statement->error;
        }
        if (!$statement->execute()) {
            $json[0]['Result'] = "error";
            $json[0]['Message'] = "Failed to added notify for " . $_GET['taskid'] . " error message: (" . $statement->errno . ") " . $statement->error;
        } else {
            $json[0]['Result'] = "success";
            $json[0]['Frame'] = '<div id="mail' . $_GET['taskid'] . '" style="display: inline-block; cursor:pointer;">
			<span style="margin-top:-1px;" class="ui-icon uis-icon-clock usercompletedselect" title="You have email notifications for this task"></span>
		</div>';
            $json[0]['Message'] = "Successfully added notify for TaskID " . $_GET['taskid'];
        }
    }
    generate_tasks(false);
    audit("notifytoggle", $json[0]['Result'] . " " . $json[0]['Message'] . " POSTDATA:" . implode(",", $_POST) . " GETDATA:" . implode(",", $_GET), true);
    echo json_encode($json);
    $mysqli->close();
    exit;
}