send notifications manually
This commit is contained in:
0
_ajax/EVERY_FILE_MUST_HAVE_644
Normal file
0
_ajax/EVERY_FILE_MUST_HAVE_644
Normal file
118
_ajax/send_notify.php
Normal file
118
_ajax/send_notify.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
//ini_set('include_path', '../_class/');
|
||||
|
||||
include '../_class/class_user_parent.php';
|
||||
foreach (glob("../_class/*.php") as $filename)
|
||||
{
|
||||
//echo $filename;
|
||||
$skip = array(
|
||||
'../_class/class_user_parent.php',
|
||||
'../_class/class_Exception.php',
|
||||
);
|
||||
if (in_array($filename, $skip)) continue;
|
||||
|
||||
include $filename;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
foreach ($_POST as $key => $value) {
|
||||
trigger_error($_SERVER['HTTP_HOST'], E_USER_NOTICE);
|
||||
}
|
||||
*/
|
||||
if ($_SERVER['HTTP_HOST'] == 'badmintoncoach.hu') $sql = new sql('bc_mysql','root','','badminton_coach');
|
||||
else $sql = new sql('localhost','tollashodos','uprRscU8bGpJ','tollashodos');
|
||||
|
||||
if (empty($_POST['uk_id'])) {
|
||||
echo json_encode(null);
|
||||
}
|
||||
|
||||
else {
|
||||
$toNotify = new user_kid();
|
||||
$toNotify->set_user_data_by_id($_POST['uk_id']);
|
||||
|
||||
if (null === $toNotify->get_uk_notify_email() || null === $toNotify->get_uk_notify_name()) {
|
||||
echo json_encode('missing-data');
|
||||
}
|
||||
else {
|
||||
$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();
|
||||
//var_dump($toNotify_array);
|
||||
//foreach ($toNotify_array as $toNotify) {
|
||||
$personalizedSubject = $emailTemplate->personalize($raw_subject, array(
|
||||
'uk_name' => $toNotify->get_uk_name(),
|
||||
));
|
||||
|
||||
$personalizedMessage = $emailTemplate->personalize($raw_message, array(
|
||||
'notify_name' => $toNotify->get_uk_notify_name(),
|
||||
'uk_name' => $toNotify->get_uk_name(),
|
||||
'uk_balance' => $toNotify->get_uk_balance(),
|
||||
'uk_password' => $toNotify->get_uk_password(),
|
||||
));
|
||||
|
||||
$mail = new PHPMailer(true); // Passing `true` enables exceptions
|
||||
try {
|
||||
//Server settings
|
||||
$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
|
||||
$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->addAddress($toNotify->get_uk_notify_email(), $toNotify->get_uk_notify_name());
|
||||
//$mail->addAddress('tricsusz@gmail.com', 'Tóth Richárd'); // TEST
|
||||
|
||||
|
||||
//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!';
|
||||
|
||||
//send mail
|
||||
$mail->send();
|
||||
//LOG SUCCESS
|
||||
email_log::create_email_log(
|
||||
$personalizedMessage,
|
||||
$personalizedSubject,
|
||||
$toNotify->get_uk_notify_name(),
|
||||
$toNotify->get_uk_notify_email(),
|
||||
$emailTemplate->get_et_id()
|
||||
);
|
||||
|
||||
//Update kids last noti date
|
||||
$sql->update_table('user_kid', array('uk_last_notification' => date('Y-m-d H:i:s')), array('uk_id' => $toNotify->get_uk_id()));
|
||||
|
||||
echo json_encode('success');
|
||||
|
||||
} catch (Exception $e) {
|
||||
//LOG ERROR
|
||||
email_log::create_email_log(
|
||||
$personalizedMessage,
|
||||
$personalizedSubject,
|
||||
$toNotify->get_uk_notify_name(),
|
||||
$toNotify->get_uk_notify_email(),
|
||||
$emailTemplate->get_et_id(),
|
||||
mysql_escape_string($e)
|
||||
);
|
||||
|
||||
echo json_encode(null);
|
||||
}
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SHUTTLE
|
||||
*/
|
||||
class camp_shuttle_type
|
||||
{
|
||||
private $cst_id;
|
||||
private $cst_name;
|
||||
|
||||
/**
|
||||
* Gets the value of cst_id.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_cst_id()
|
||||
{
|
||||
return $this->cst_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of cst_id.
|
||||
*
|
||||
* @param mixed $cst_id the cst id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
private function set_cst_id($cst_id)
|
||||
{
|
||||
$this->cst_id = $cst_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of cst_name.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_cst_name()
|
||||
{
|
||||
return $this->cst_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of cst_name.
|
||||
*
|
||||
* @param mixed $cst_name the cst name
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
private function set_cst_name($cst_name)
|
||||
{
|
||||
$this->cst_name = $cst_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_cst_data_by_id($_cst_id) {
|
||||
global $sql;
|
||||
$cst_assoc_array = $sql->assoc_array("select * from camp_shuttle_type where cst_id = " . $_cst_id);
|
||||
$cst_array = $cst_assoc_array[0];
|
||||
//alapadatok
|
||||
foreach ($cst_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -692,6 +692,24 @@ form#auto_filters > div > label {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.notification-text {
|
||||
margin: -3px 0px 0px 20px;
|
||||
padding: 3px 3px;
|
||||
background-color: cadetblue;
|
||||
}
|
||||
|
||||
.notification-text.in-progress {
|
||||
background-color: #f5ea16;
|
||||
}
|
||||
|
||||
.notification-text.success {
|
||||
background-color: #26f329;
|
||||
}
|
||||
|
||||
.notification-text.fail {
|
||||
background-color: #f6625c;
|
||||
}
|
||||
|
||||
@media (min-width: 680px) {
|
||||
|
||||
.categories {
|
||||
|
||||
@@ -3,26 +3,59 @@
|
||||
# HA NINCS ID, AKKOR EGYENLEGLISTA
|
||||
# HA VAN ID, AKKOR RENDEZÉS IS VAN
|
||||
|
||||
$where = '';
|
||||
if ($this->is_id()) {
|
||||
# RENDEZÉS
|
||||
|
||||
/*
|
||||
1 - egyenleg szerint növekvő
|
||||
*/
|
||||
|
||||
*/
|
||||
switch ($this->get_id()) {
|
||||
case 1:
|
||||
//1 - egyenleg szerint növekvő
|
||||
$order_by = 'uk_balance ASC, uk_name ASC';
|
||||
$url_postfix = '/' . $this->get_id();
|
||||
break;
|
||||
case 2:
|
||||
//2 - tartozások
|
||||
$where = ' AND uk_balance < 0';
|
||||
$order_by = 'uk_name ASC';
|
||||
$url_postfix = '/' . $this->get_id();
|
||||
break;
|
||||
case 3:
|
||||
//3 - tartozások csökkenőben
|
||||
$where = ' AND uk_balance < 0';
|
||||
$order_by = 'uk_balance ASC, uk_name ASC';
|
||||
$url_postfix = '/' . $this->get_id();
|
||||
break;
|
||||
case 4:
|
||||
//4 - tartozások növekvőben
|
||||
$where = ' AND uk_balance < 0';
|
||||
$order_by = 'uk_balance DESC, uk_name ASC';
|
||||
$url_postfix = '/' . $this->get_id();
|
||||
break;
|
||||
case 5:
|
||||
//5 - tartozások növekvőben
|
||||
$where = ' AND uk_balance < 0';
|
||||
$order_by = 'uk_last_notification DESC, uk_name ASC';
|
||||
$url_postfix = '/' . $this->get_id();
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
# EGYENLEG LISTA
|
||||
$order_by = 'uk_name ASC';
|
||||
$url_postfix = '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
$active_kid_assoc_array = $sql->assoc_array('select * from user_kid where uk_deleted = 0 and uk_is_active = 1 order by '. $order_by .';');
|
||||
$active_kid_assoc_array = $sql->assoc_array('select * from user_kid where uk_deleted = 0 and uk_is_active = 1'.$where.' order by '. $order_by .';');
|
||||
$user_kids = array();
|
||||
foreach ($active_kid_assoc_array as $kid) {
|
||||
$new_kid = new user_kid();
|
||||
@@ -30,6 +63,7 @@ foreach ($active_kid_assoc_array as $kid) {
|
||||
$user_kids[] = $new_kid;
|
||||
}
|
||||
|
||||
$smarty->assign('page_id', $this->is_id() ? $this->get_id() : null);
|
||||
$smarty->assign('user_kids', $user_kids);
|
||||
$smarty->assign('url_postfix', $url_postfix);
|
||||
$smarty->display('user_balance_list.tpl');
|
||||
|
||||
@@ -2,20 +2,70 @@
|
||||
|
||||
<a href="/admin/balance_list" class="addbutton big">Név szerinti rendezés</a>
|
||||
<a href="/admin/balance_list/1" class="addbutton big">Egyenleg szerinti rendezés</a>
|
||||
<a href="/admin/balance_list/2" class="addbutton big">Tartozások</a>
|
||||
<a href="/admin/money_update{$url_postfix}" class="addbutton add-big">Egyenleg frissítése</a>
|
||||
|
||||
</div>
|
||||
<br>
|
||||
{if $page_id == 2 || $page_id == 3 || $page_id == 4 || $page_id == 5}
|
||||
<div class="buttons">
|
||||
<a href="/admin/balance_list/3" class="addbutton big">Legnagyobb tartozás előre</a>
|
||||
<a href="/admin/balance_list/4" class="addbutton big">Legkisebb tartozás előre</a>
|
||||
<a href="/admin/balance_list/5" class="addbutton big">Kiküldés szerint rendezés</a>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="list">
|
||||
<div class="list half_width">
|
||||
{foreach $user_kids as $user}
|
||||
<a href="#">
|
||||
<a href="#" id="kid_{$user->get_uk_id()}">
|
||||
<div class="list_item">
|
||||
<img src="/_image/shuttlecock.png">
|
||||
{$user->get_uk_name()}
|
||||
{if $user->get_uk_last_notification() && $page_id >= 2}
|
||||
<span style="font-size: 14px; font-weight: normal; font-style: italic;">({$user->get_uk_last_notification()})</span>
|
||||
{/if}
|
||||
{if $user->get_uk_balance() < 0}
|
||||
<span class="float_right notification-text" id="{$user->get_uk_id()}">Értesítő e-mail</span>
|
||||
{/if}
|
||||
<span class="float_right">{$user->get_uk_balance()|number_format:0:'':' '} Ft</span>
|
||||
</div>
|
||||
</a>
|
||||
{/foreach}
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var clickFunction = function(event) {
|
||||
$(event.target).off('click', clickFunction)
|
||||
$(event.target).addClass('in-progress');
|
||||
$(event.target).html('Küldés folyamatban...');
|
||||
|
||||
$.post("/_ajax/send_notify.php",
|
||||
{
|
||||
uk_id: event.target.id,
|
||||
},
|
||||
function(data, status){
|
||||
var pdata = JSON.parse(data);
|
||||
|
||||
if (null == pdata) {
|
||||
//error
|
||||
$(event.target).removeClass('in-progress');
|
||||
$(event.target).addClass('fail');
|
||||
$(event.target).html('Küldés sikertelen');
|
||||
}
|
||||
else if ('missing-data' == pdata) {
|
||||
$(event.target).removeClass('in-progress');
|
||||
$(event.target).addClass('fail');
|
||||
$(event.target).html('Hiányzó adatok!');
|
||||
}
|
||||
else {
|
||||
$(event.target).removeClass('in-progress');
|
||||
$(event.target).addClass('success');
|
||||
$(event.target).html('Kiküldve');
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.notification-text').on('click', clickFunction);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user