This commit is contained in:
Tóth Richárd
2018-10-18 23:50:57 +02:00
parent 59c984dd9b
commit 19aaa4a770
15 changed files with 8753 additions and 1653 deletions

View File

@@ -1,33 +1,119 @@
<?php
# EDZÉS ZÁROLÁS
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)
),
array(
'tr_id' => $this->get_id()
)
);
log::register(($locked?'training_open':'training_close'), $this->get_id());
header('Location: /admin/presence/' . $this->get_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)
),
array(
'tr_id' => $this->get_id()
)
);
log::register(($locked?'training_open':'training_close'), $this->get_id());
*/
//SEND NOTIFICATION
if (!$locked) {
//get kids from training
$kid_ids = $sql->assoc_array('SELECT pr_user_kid_uk_id FROM presence WHERE pr_training_tr_id = ' . $this->get_id());
//iterate and collect them
$kid_array = array();
foreach ($kid_ids as $k_array) {
$kid = new user_kid();
$kid->set_user_data_by_id($k_array['pr_user_kid_uk_id']);
$kid->update_balance();
if (null === $kid->get_uk_last_notification() && null !== $kid->get_uk_notify_email() && $kid->get_uk_balance() < 0) {
$kid_array[] = $kid;
}
elseif (null !== $kid->get_uk_last_notification() && null !== $kid->get_uk_notify_email() && $kid->get_uk_balance() < 0) {
$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ő";
;');
if (null !== $notify_hours) {
$timestamp = strtotime($kid->get_uk_last_notification()) + $notify_hours*60;
$expireDate = date('Y-m-d H:i:s', $timestamp);
if (time() >= $timestamp) {
$kid_array[] = $kid;
}
}
}
}
//send email
$email_template_id = $sql->single_variable('select et_id from email_template where et_name = \'below_zero\'');
if (null !== $email_template_id) {
$emailTemplate = new email_template();
$emailTemplate->set_et_data_by_id($email_template_id);
$raw_subject = $emailTemplate->get_et_subject();
$raw_message = $emailTemplate->get_et_message();
foreach ($kid_array as $kid) {
$personalizedSubject = $emailTemplate->personalize($raw_subject, array(
'uk_name' => $kid->get_uk_name(),
));
$personalizedMessage = $emailTemplate->personalize($raw_message, array(
'notify_name' => $kid->get_uk_notify_name(),
'uk_name' => $kid->get_uk_name(),
'uk_balance' => $kid->get_uk_balance(),
'uk_password' => $kid->get_uk_password(),
));
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.gginternet.com '; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'hirlevel@tollaslabda.info'; // SMTP username
$mail->Password = 'tollas12'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
//Recipients
$mail->setFrom($emailTemplate->get_et_from_email(), $emailTemplate->get_et_from_name());
$mail->addBCC('tricsusz@gmail.com', 'Tóth Richárd'); // TEST
$mail->addBCC($kid->get_uk_notify_email(), $kid->get_uk_notify_name());
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $personalizedSubject;
$mail->Body = $personalizedMessage;
$mail->AltBody = 'Az Ön levelezője nem támogatja a HTML tartalom megjelenítését!';
//$mail->send();
//LOG SUCCESS
} catch (Exception $e) {
//LOG ERROR
}
}
}
}
//header('Location: /admin/presence/' . $this->get_id());
}
else {
# NEM LEHET
}
?>
?>

View File

@@ -8,11 +8,7 @@
$user->set_user_data_by_id($value['uk_id']);
# EDZÉS LISTA
$action_list_query = "
$action_list_query = "
SELECT
object_id,
timestamp(object_date) as object_date,

View File

@@ -0,0 +1,45 @@
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
//use PHPMailer\PHPMailer\PHPMailer;
//use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
//require 'vendor/autoload.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.gginternet.com '; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'hirlevel@tollaslabda.info'; // SMTP username
$mail->Password = 'tollas12'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
//Recipients
$mail->setFrom('from@example.com', 'Mailer');
$mail->addAddress('tricsusz@gmail.com', 'Tóth Richárd'); // Add a recipient
//$mail->addAddress('ellen@example.com'); // Name is optional
//$mail->addReplyTo('info@example.com', 'Information');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//Attachments
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}