forked from kevinowino869/mitrobill
User Notification Option to Email
This commit is contained in:
parent
79585d54a1
commit
922f24b630
159
pages_template/Email.html
Normal file
159
pages_template/Email.html
Normal file
@ -0,0 +1,159 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>[[Subject]]</title>
|
||||
<style media="all" type="text/css">
|
||||
@media all {
|
||||
.btn-primary table td:hover {
|
||||
background-color: #ec0867 !important;
|
||||
}
|
||||
|
||||
.btn-primary a:hover {
|
||||
background-color: #ec0867 !important;
|
||||
border-color: #ec0867 !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 640px) {
|
||||
|
||||
.main p,
|
||||
.main td,
|
||||
.main span {
|
||||
font-size: 16px !important;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
padding: 8px !important;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 0 !important;
|
||||
padding-top: 8px !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.main {
|
||||
border-left-width: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
border-right-width: 0 !important;
|
||||
}
|
||||
|
||||
.btn table {
|
||||
max-width: 100% !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.btn a {
|
||||
font-size: 16px !important;
|
||||
max-width: 100% !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media all {
|
||||
.ExternalClass {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ExternalClass,
|
||||
.ExternalClass p,
|
||||
.ExternalClass span,
|
||||
.ExternalClass font,
|
||||
.ExternalClass td,
|
||||
.ExternalClass div {
|
||||
line-height: 100%;
|
||||
}
|
||||
|
||||
.apple-link a {
|
||||
color: inherit !important;
|
||||
font-family: inherit !important;
|
||||
font-size: inherit !important;
|
||||
font-weight: inherit !important;
|
||||
line-height: inherit !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
#MessageViewBody a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
font-size: inherit;
|
||||
font-family: inherit;
|
||||
font-weight: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body
|
||||
style="font-family: Helvetica, sans-serif; -webkit-font-smoothing: antialiased; font-size: 16px; line-height: 1.3; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; background-color: #f4f5f6; margin: 0; padding: 0;">
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="body"
|
||||
style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f4f5f6; width: 100%;"
|
||||
width="100%" bgcolor="#f4f5f6">
|
||||
<tr>
|
||||
<td style="font-family: Helvetica, sans-serif; font-size: 16px; vertical-align: top;" valign="top">
|
||||
</td>
|
||||
<td class="container"
|
||||
style="font-family: Helvetica, sans-serif; font-size: 16px; vertical-align: top; max-width: 600px; padding: 0; padding-top: 24px; width: 600px; margin: 0 auto;"
|
||||
width="600" valign="top">
|
||||
<div class="content"
|
||||
style="box-sizing: border-box; display: block; margin: 0 auto; max-width: 600px; padding: 0;">
|
||||
<!-- START CENTERED WHITE CONTAINER -->
|
||||
<span class="preheader"
|
||||
style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;">This
|
||||
is preheader text. Some clients will show this text as a preview.</span>
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0" class="main"
|
||||
style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background: #ffffff; border: 1px solid #eaebed; border-radius: 16px; width: 100%;"
|
||||
width="100%">
|
||||
<!-- START MAIN CONTENT AREA -->
|
||||
<tr>
|
||||
<td align="center"><h3>[[Company_Name]]</h3></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="wrapper"
|
||||
style="font-family: Helvetica, sans-serif; font-size: 16px; vertical-align: top; box-sizing: border-box; padding: 24px;"
|
||||
valign="top">
|
||||
<p
|
||||
style="font-family: Helvetica, sans-serif; font-size: 16px; font-weight: normal; margin: 0; margin-bottom: 16px;">
|
||||
[[Body]]</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- END MAIN CONTENT AREA -->
|
||||
</table>
|
||||
|
||||
<!-- START FOOTER -->
|
||||
<div class="footer" style="clear: both; padding-top: 24px; text-align: center; width: 100%;">
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0"
|
||||
style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;"
|
||||
width="100%">
|
||||
<tr>
|
||||
<td class="content-block"
|
||||
style="font-family: Helvetica, sans-serif; vertical-align: top; color: #9a9ea6; font-size: 16px; text-align: center;"
|
||||
valign="top" align="center">
|
||||
<span class="apple-link"
|
||||
style="color: #9a9ea6; font-size: 16px; text-align: center;">[[Company_Address]]</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- END FOOTER -->
|
||||
|
||||
<!-- END CENTERED WHITE CONTAINER -->
|
||||
</div>
|
||||
</td>
|
||||
<td style="font-family: Helvetica, sans-serif; font-size: 16px; vertical-align: top;" valign="top">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -96,10 +96,13 @@ class Message
|
||||
|
||||
public static function sendEmail($to, $subject, $body)
|
||||
{
|
||||
global $config;
|
||||
global $config, $PAGES_PATH, $_app_stage;
|
||||
if (empty($body)) {
|
||||
return "";
|
||||
}
|
||||
if (empty($to)) {
|
||||
return "";
|
||||
}
|
||||
run_hook('send_email', [$to, $subject, $body]); #HOOK
|
||||
if (empty($config['smtp_host'])) {
|
||||
$attr = "";
|
||||
@ -113,7 +116,9 @@ class Message
|
||||
} else {
|
||||
$mail = new PHPMailer();
|
||||
$mail->isSMTP();
|
||||
if ($_app_stage == 'Dev') {
|
||||
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
|
||||
}
|
||||
$mail->Host = $config['smtp_host'];
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $config['smtp_user'];
|
||||
@ -126,17 +131,37 @@ class Message
|
||||
if (!empty($config['mail_reply_to'])) {
|
||||
$mail->addReplyTo($config['mail_reply_to']);
|
||||
}
|
||||
$mail->isHTML(false);
|
||||
|
||||
$mail->addAddress($to);
|
||||
$mail->Subject = $subject;
|
||||
|
||||
if (!file_exists($PAGES_PATH . DIRECTORY_SEPARATOR . 'Email.html')) {
|
||||
if (!copy($PAGES_PATH . '_template' . DIRECTORY_SEPARATOR . 'Email.html', $PAGES_PATH . DIRECTORY_SEPARATOR . 'Email.html')) {
|
||||
file_put_contents($PAGES_PATH . DIRECTORY_SEPARATOR . 'Email.html', Http::getData('https://raw.githubusercontent.com/hotspotbilling/phpnuxbill/master/pages_template/Email.html'));
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists($PAGES_PATH . DIRECTORY_SEPARATOR . 'Email.html')) {
|
||||
$html = file_get_contents($PAGES_PATH . DIRECTORY_SEPARATOR . 'Email.html');
|
||||
$html = str_replace('[[Subject]]', $subject, $html);
|
||||
$html = str_replace('[[Company_Address]]', nl2br($config['address']), $html);
|
||||
$html = str_replace('[[Company_Name]]', nl2br($config['CompanyName']), $html);
|
||||
$html = str_replace('[[Body]]', nl2br($body), $html);
|
||||
$mail->isHTML(true);
|
||||
$mail->Body = $html;
|
||||
} else {
|
||||
$mail->isHTML(false);
|
||||
$mail->Body = $body;
|
||||
}
|
||||
$mail->send();
|
||||
|
||||
//<p style="font-family: Helvetica, sans-serif; font-size: 16px; font-weight: normal; margin: 0; margin-bottom: 16px;">
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendPackageNotification($customer, $package, $price, $message, $via)
|
||||
{
|
||||
global $ds;
|
||||
global $ds, $config;
|
||||
if (empty($message)) {
|
||||
return "";
|
||||
}
|
||||
@ -167,6 +192,8 @@ class Message
|
||||
) {
|
||||
if ($via == 'sms') {
|
||||
echo Message::sendSMS($customer['phonenumber'], $msg);
|
||||
} else if ($via == 'email') {
|
||||
self::sendEmail($customer['email'], '[' . $config['CompanyName'] . '] ' . Lang::T("Internet Plan Reminder"), $msg);
|
||||
} else if ($via == 'wa') {
|
||||
echo Message::sendWhatsapp($customer['phonenumber'], $msg);
|
||||
}
|
||||
@ -174,17 +201,21 @@ class Message
|
||||
return "$via: $msg";
|
||||
}
|
||||
|
||||
public static function sendBalanceNotification($phone, $name, $balance, $balance_now, $message, $via)
|
||||
public static function sendBalanceNotification($cust, $balance, $balance_now, $message, $via)
|
||||
{
|
||||
$msg = str_replace('[[name]]', $name, $message);
|
||||
global $config;
|
||||
$msg = str_replace('[[name]]', $cust['fullname'] . ' (' . $cust['username'] . ')', $message);
|
||||
$msg = str_replace('[[current_balance]]', Lang::moneyFormat($balance_now), $msg);
|
||||
$msg = str_replace('[[balance]]', Lang::moneyFormat($balance), $msg);
|
||||
$phone = $cust['phonenumber'];
|
||||
if (
|
||||
!empty($phone) && strlen($phone) > 5
|
||||
&& !empty($message) && in_array($via, ['sms', 'wa'])
|
||||
&& !empty($message) && in_array($via, ['sms', 'wa', 'email'])
|
||||
) {
|
||||
if ($via == 'sms') {
|
||||
Message::sendSMS($phone, $msg);
|
||||
} else if ($config['user_notification_payment'] == 'email') {
|
||||
self::sendEmail($cust['email'], '[' . $config['CompanyName'] . '] ' . Lang::T("Balance Notification"), $msg);
|
||||
} else if ($via == 'wa') {
|
||||
Message::sendWhatsapp($phone, $msg);
|
||||
}
|
||||
@ -221,6 +252,8 @@ class Message
|
||||
|
||||
if ($config['user_notification_payment'] == 'sms') {
|
||||
Message::sendSMS($cust['phonenumber'], $textInvoice);
|
||||
} else if ($config['user_notification_payment'] == 'email') {
|
||||
self::sendEmail($cust['email'], '[' . $config['CompanyName'] . '] ' . Lang::T("Invoice") . ' #' . $trx['invoice'], $textInvoice);
|
||||
} else if ($config['user_notification_payment'] == 'wa') {
|
||||
Message::sendWhatsapp($cust['phonenumber'], $textInvoice);
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ if (_post('send') == 'balance') {
|
||||
$d->pg_url_payment = 'balance';
|
||||
$d->status = 2;
|
||||
$d->save();
|
||||
Message::sendBalanceNotification($user['phonenumber'], $target['fullname'] . ' (' . $target['username'] . ')', $balance, ($user['balance'] - $balance), Lang::getNotifText('balance_send'), $config['user_notification_payment']);
|
||||
Message::sendBalanceNotification($target['phonenumber'], $user['fullname'] . ' (' . $user['username'] . ')', $balance, ($target['balance'] + $balance), Lang::getNotifText('balance_received'), $config['user_notification_payment']);
|
||||
Message::sendBalanceNotification($user, $balance, ($user['balance'] - $balance), Lang::getNotifText('balance_send'), $config['user_notification_payment']);
|
||||
Message::sendBalanceNotification($target, $balance, ($target['balance'] + $balance), Lang::getNotifText('balance_received'), $config['user_notification_payment']);
|
||||
Message::sendTelegram("#u$user[username] send balance to #u$target[username] \n" . Lang::moneyFormat($balance));
|
||||
r2(U . 'home', 's', Lang::T('Sending balance success'));
|
||||
}
|
||||
|
@ -476,6 +476,8 @@
|
||||
{/if}>Whatsapp</option>
|
||||
<option value="sms" {if $_c['user_notification_expired']=='sms' }selected="selected"
|
||||
{/if}>SMS</option>
|
||||
<option value="email" {if $_c['user_notification_expired']=='email' }selected="selected"
|
||||
{/if}>Email</option>
|
||||
</select>
|
||||
</div>
|
||||
<p class="help-block col-md-4">{Lang::T('User will get notification when package expired')}</p>
|
||||
@ -490,6 +492,8 @@
|
||||
{/if}>Whatsapp</option>
|
||||
<option value="sms" {if $_c['user_notification_payment']=='sms' }selected="selected"
|
||||
{/if}>SMS</option>
|
||||
<option value="email" {if $_c['user_notification_payment']=='email' }selected="selected"
|
||||
{/if}>Email</option>
|
||||
</select>
|
||||
</div>
|
||||
<p class="help-block col-md-4">
|
||||
@ -505,6 +509,8 @@
|
||||
{/if}>Whatsapp</option>
|
||||
<option value="sms" {if $_c['user_notification_reminder']=='sms' }selected="selected"
|
||||
{/if}>SMS</option>
|
||||
<option value="sms" {if $_c['user_notification_reminder']=='email' }selected="selected"
|
||||
{/if}>Email</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -634,7 +640,9 @@
|
||||
</select>
|
||||
</div>
|
||||
<p class="help-block col-md-4">
|
||||
{Lang::T('Hotspot Authentication Method. Make sure you have changed your hotspot login page.')}<br><a href="https://github.com/agstrxyz/phpnuxbill-login-hotspot" target="_blank">Download phpnuxbill-login-hotspot</a>
|
||||
{Lang::T('Hotspot Authentication Method. Make sure you have changed your hotspot login page.')}<br><a
|
||||
href="https://github.com/agstrxyz/phpnuxbill-login-hotspot" target="_blank">Download
|
||||
phpnuxbill-login-hotspot</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user