send email; manage notis and email logs
This commit is contained in:
9
_include/include_delete_notification.php
Normal file
9
_include/include_delete_notification.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if ($this->is_id()) {
|
||||
$sql->update_table('user_kid', array('uk_last_notification' => 'null'), array('uk_id' => $this->get_id()));
|
||||
header("Location: /admin/notifications");
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -7,7 +7,7 @@ if ($this->is_id()) {
|
||||
$email_log = new email_log();
|
||||
$email_log->set_el_data_by_id($this->get_id());
|
||||
|
||||
$smarty->assign('email_log', $email_log);
|
||||
$smarty->assign('email', $email_log);
|
||||
$smarty->display('email.tpl');
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -5,7 +5,7 @@ if ($this->is_id()) {
|
||||
# EMAIL LISTA (50 / oldal)
|
||||
|
||||
$all_emails_query = "SELECT count(DISTINCT el_id) FROM email_log";
|
||||
$emails_query = "SELECT * FROM email_log LIMIT ".($this->is_id()?($this->get_id()-1) * 50:"0").",50";
|
||||
$emails_query = "SELECT * FROM email_log ORDER BY el_sent_date DESC LIMIT ".($this->is_id()?($this->get_id()-1) * 50:"0").",50";
|
||||
$el_assoc_array = $sql->assoc_array($emails_query);
|
||||
$el_count = $sql->single_variable($all_emails_query);
|
||||
$next_link = true;
|
||||
|
||||
@@ -7,7 +7,6 @@ if ($this->is_id()) {
|
||||
# EDZÉS ZÁROLÁS/FELOLDÁS
|
||||
|
||||
$locked = $sql->single_variable('select tr_locked from training where tr_id =' . $this->get_id());
|
||||
/*
|
||||
$sql->update_table('training', array(
|
||||
'tr_locked' => ($locked?0:1)
|
||||
),
|
||||
@@ -16,7 +15,6 @@ if ($this->is_id()) {
|
||||
)
|
||||
);
|
||||
log::register(($locked?'training_open':'training_close'), $this->get_id());
|
||||
*/
|
||||
//SEND NOTIFICATION
|
||||
|
||||
if (!$locked) {
|
||||
@@ -83,8 +81,9 @@ if ($this->is_id()) {
|
||||
$mail = new PHPMailer(true); // Passing `true` enables exceptions
|
||||
try {
|
||||
//Server settings
|
||||
$mail->SMTPDebug = 2; // Enable verbose debug output
|
||||
$mail->SMTPDebug = 0; // Enable verbose debug output
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->CharSet = PHPMailer::CHARSET_UTF8; // UTF-8
|
||||
$mail->Host = 'mail.gginternet.com '; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = 'hirlevel@tollaslabda.info'; // SMTP username
|
||||
@@ -94,8 +93,8 @@ if ($this->is_id()) {
|
||||
|
||||
//Recipients
|
||||
$mail->setFrom($emailTemplate->get_et_from_email(), $emailTemplate->get_et_from_name());
|
||||
$mail->addBCC($kid->get_uk_notify_email(), $kid->get_uk_notify_name());
|
||||
$mail->addBCC('tricsusz@gmail.com', 'Tóth Richárd'); // TEST
|
||||
//$mail->addBCC($kid->get_uk_notify_email(), $kid->get_uk_notify_name());
|
||||
|
||||
|
||||
//Content
|
||||
@@ -104,7 +103,8 @@ if ($this->is_id()) {
|
||||
$mail->Body = $personalizedMessage;
|
||||
$mail->AltBody = 'Az Ön levelezője nem támogatja a HTML tartalom megjelenítését!';
|
||||
|
||||
//$mail->send();
|
||||
//send mail
|
||||
$mail->send();
|
||||
//LOG SUCCESS
|
||||
email_log::create_email_log(
|
||||
$personalizedMessage,
|
||||
@@ -114,7 +114,8 @@ if ($this->is_id()) {
|
||||
$emailTemplate->get_et_id()
|
||||
);
|
||||
|
||||
//TODO: Update kids last noti date
|
||||
//Update kids last noti date
|
||||
$sql->update_table('user_kid', array('uk_last_notification' => date('Y-m-d H:i:s')), array('uk_id' => $kid->get_uk_id()));
|
||||
|
||||
} catch (Exception $e) {
|
||||
//LOG ERROR
|
||||
@@ -124,7 +125,7 @@ if ($this->is_id()) {
|
||||
$kid->get_uk_notify_name(),
|
||||
$kid->get_uk_notify_email(),
|
||||
$emailTemplate->get_et_id(),
|
||||
$e
|
||||
mysql_escape_string($e)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -132,7 +133,7 @@ if ($this->is_id()) {
|
||||
}
|
||||
}
|
||||
|
||||
//header('Location: /admin/presence/' . $this->get_id());
|
||||
header('Location: /admin/presence/' . $this->get_id());
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
36
_include/include_notifications.php
Normal file
36
_include/include_notifications.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
# HA NINCS ID, AKKOR ÉRTESÍTÉSEK
|
||||
|
||||
if ($this->is_id()) {
|
||||
|
||||
}
|
||||
else {
|
||||
# ÉRTESÍTÉSEK
|
||||
|
||||
//hány óránként küldünk emailt
|
||||
$notify_hours = $sql->single_variable(' SELECT
|
||||
setv_int
|
||||
FROM
|
||||
setting_value
|
||||
JOIN
|
||||
setting ON setv_setting_set_id = set_id
|
||||
WHERE
|
||||
set_name = "Értesítések közt eltelt idő";
|
||||
;');
|
||||
|
||||
//akiket értesítettünk az elmúlt x órában
|
||||
$notifiedKids = $sql->assoc_array('select * from user_kid WHERE DATE_SUB(CURDATE(),INTERVAL '.$notify_hours.' HOUR) <= uk_last_notification order by uk_name ASC;');
|
||||
|
||||
$kid_array = array();
|
||||
foreach ($notifiedKids as $key => $kid) {
|
||||
$new_kid = new user_kid();
|
||||
$new_kid->set_user_data_by_id($kid['uk_id']);
|
||||
$kid_array[] = $new_kid;
|
||||
}
|
||||
$smarty->assign('kid_array', $kid_array);
|
||||
$smarty->display('notifications.tpl');
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user