FEAT_HR_NOTIFICATION
This commit is contained in:
parent
e70245ff77
commit
8f8b082f8c
@ -648,7 +648,7 @@ class ClientController extends AdminController
|
||||
|
||||
// echo "<pre>";
|
||||
// print_r($data); die;
|
||||
$data['placeHolders'] = ['member_name', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
|
||||
$data['placeHolders'] = ['hr_name', 'member_name', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
|
||||
|
||||
// dd($data['placeHolders']);
|
||||
|
||||
@ -952,7 +952,7 @@ class ClientController extends AdminController
|
||||
}, $rawList)) : [];
|
||||
$editData['client_policy']['role'] = get_role_id();
|
||||
$editData['notification'] = $this->notificationModel->select('template_name,enabled')->where('client_id', $id)->findAll();
|
||||
$editData['placeHolders'] = ['member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
|
||||
$editData['placeHolders'] = ['hr_name', 'member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
|
||||
$editData['api_data'] = $this->clientApi->where("client_id", $id)->where("is_active", 1)->first();
|
||||
// dd($editData);
|
||||
|
||||
@ -8728,6 +8728,8 @@ class ClientController extends AdminController
|
||||
$member_ecard_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'member_ecard_mail')->get()->getResultArray()[0] ?? [];
|
||||
|
||||
$member_common_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'member_common_mail')->get()->getResultArray()[0] ?? [];
|
||||
|
||||
$hr_cd_insufficient_balance_mail_template = $this->notificationModel->where('client_id', NULL)->where('template_name', 'hr_cd_insufficient_balance_mail')->get()->getResultArray()[0] ?? [];
|
||||
|
||||
$default_member_welcome_mail_template = [
|
||||
'client_id' => $client_id,
|
||||
@ -8799,6 +8801,20 @@ class ClientController extends AdminController
|
||||
'mail_content_copy' => null
|
||||
];
|
||||
|
||||
$hr_cd_insufficient_balance_mail_template = [
|
||||
'client_id' => $client_id,
|
||||
'template_name' => 'hr_cd_insufficient_balance_mail',
|
||||
'subject' => $hr_cd_insufficient_balance_mail_template['subject'] ?? '',
|
||||
'mail_content' => $hr_cd_insufficient_balance_mail_template['mail_content'] ?? '',
|
||||
'mail_content_json' => $hr_cd_insufficient_balance_mail_template['mail_content_json'] ?? '',
|
||||
|
||||
'created_by' => get_session_userid(),
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_by' => null,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'mail_content_copy' => null
|
||||
];
|
||||
|
||||
$this->myLogger->logme('error', 'Default Mail Template Data ' . json_encode([
|
||||
$default_member_welcome_mail_template,
|
||||
$default_member_remainder_mail_template,
|
||||
@ -8812,7 +8828,8 @@ class ClientController extends AdminController
|
||||
$default_member_remainder_mail_template,
|
||||
$default_member_review_and_summary_mail_template,
|
||||
$default_member_ecard_mail_template,
|
||||
$default_member_common_mail_template
|
||||
$default_member_common_mail_template,
|
||||
$hr_cd_insufficient_balance_mail_template,
|
||||
]);
|
||||
|
||||
|
||||
|
||||
@ -734,17 +734,23 @@ class EmpDataServiceController extends BaseController
|
||||
if($export_data['insurer_or_tpa'] == 'insurer')
|
||||
{
|
||||
if (!empty($cash_balance)) {
|
||||
if ((int) $cash_balance['balance'] < (int) $rounded_totals) {
|
||||
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
|
||||
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
|
||||
session()->set('cd_balance', false);
|
||||
session()->set('cd_amount', $cash_balance['balance']);
|
||||
session()->set('excel_file_amt', $rounded_totals);
|
||||
if ((int) $cash_balance['balance'] < (int) $totals) {
|
||||
clear_cd_balance_session(); // Clear old junk first
|
||||
|
||||
$cd_session_data = json_encode([
|
||||
'cd_balance' => false,
|
||||
'cd_amount' => $cash_balance['balance'],
|
||||
'excel_file_amt' => $totals
|
||||
]);
|
||||
|
||||
session()->set('cd_balance_info', $cd_session_data);
|
||||
session()->set('cd_balance', 'insufficient'); // Use a string status for clarity
|
||||
|
||||
$hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']);
|
||||
session()->set('hr_data', json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]));
|
||||
}else{
|
||||
session()->set('cd_balance', true);
|
||||
session()->set('cd_amount', $cash_balance['balance']);
|
||||
session()->set('excel_file_amt', $rounded_totals);
|
||||
|
||||
session()->set('cd_balance', 'sufficient'); // Use a string status for clarity
|
||||
session()->set('cd_balance_info', null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1065,17 +1071,23 @@ class EmpDataServiceController extends BaseController
|
||||
if($export_data['insurer_or_tpa'] != 'tpa')// check overal emp premium amt with cd balance only for insurer export, not tpa export
|
||||
{
|
||||
if (!empty($cash_balance)) {
|
||||
if ((int) $cash_balance['balance'] < (int) $totals) {
|
||||
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount.');
|
||||
$this->myLogger->logme('error', 'Inception export failed due to insufficient deposit amount. CASH BALANCE : {balance} and TOTAL AMOUNT : {total}', ['balance' => $cash_balance['balance'], 'total' => $totals]);
|
||||
session()->set('cd_balance', false);
|
||||
session()->set('cd_amount', $cash_balance['balance']);
|
||||
session()->set('excel_file_amt', $totals);
|
||||
if ((int) $cash_balance['balance'] < (int) $totals) {
|
||||
clear_cd_balance_session(); // Clear old junk first
|
||||
|
||||
$cd_session_data = json_encode([
|
||||
'cd_balance' => false,
|
||||
'cd_amount' => $cash_balance['balance'],
|
||||
'excel_file_amt' => $totals
|
||||
]);
|
||||
|
||||
session()->set('cd_balance_info', $cd_session_data);
|
||||
session()->set('cd_balance', 'insufficient'); // Use a string status for clarity
|
||||
|
||||
$hr_data = $this->getHrdataForInsufficientMailSend($export_data['client_branch_id']);
|
||||
session()->set('hr_data', json_encode(['client_id' => $export_data['client_id'], 'hr_data' => $hr_data]));
|
||||
}else{
|
||||
session()->set('cd_balance', true);
|
||||
session()->set('cd_amount', $cash_balance['balance']);
|
||||
session()->set('excel_file_amt', $totals);
|
||||
|
||||
session()->set('cd_balance', 'sufficient'); // Use a string status for clarity
|
||||
session()->set('cd_balance_info', null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@ use App\Models\UserModel;
|
||||
use App\Models\PartnerEndorsementRequestModel;
|
||||
use App\Models\TpaApiDataModel;
|
||||
use App\Models\LevelContactModel;
|
||||
use App\Models\NotificationModel;
|
||||
|
||||
|
||||
use App\Controllers\Jobs;
|
||||
@ -4555,29 +4556,39 @@ class EmployeeController extends AdminController
|
||||
|
||||
$client_data = $this->clientModel->where('is_active', 1)->where('id', $post_data['client_id'])->first();
|
||||
|
||||
$common['mail_type'] = "insufficient_cd_balance_by_hr";
|
||||
if(empty($client_data)){
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'No client found'], 200);
|
||||
}
|
||||
|
||||
$notificationModal = new NotificationModel();
|
||||
$notification_data = $notificationModal
|
||||
->where('client_id', $post_data['client_id'])
|
||||
->where('template_name', 'hr_cd_insufficient_balance_mail')
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if(empty($notification_data)){
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'No template found'], 200);
|
||||
}
|
||||
|
||||
if(empty($notification_data['subject']) || empty($notification_data['mail_content'])){
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Template subject or mail content is empty'], 200);
|
||||
}
|
||||
|
||||
if(empty($notification_data['enabled']) || $notification_data['enabled'] != 1){
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Template is disabled'], 200);
|
||||
|
||||
}
|
||||
|
||||
$common['mail_type'] = "hr_cd_insufficient_balance_mail";
|
||||
$common['client_id'] = $post_data['client_id'];
|
||||
$subject = 'Insufficient CD Balance Notification';
|
||||
$mail_content = '
|
||||
Dear {{HR_NAME}},
|
||||
|
||||
Greetings from Nhance.
|
||||
|
||||
We would like to inform you that the CD balance for {{CLIENT_NAME}} is currently low / insufficient, which may impact further processing of insurance-related activities.
|
||||
|
||||
Kindly request you to credit the required amount at the earliest to avoid any service disruption.
|
||||
|
||||
Please let us know once the amount is credited, or if you need any clarification from our end.
|
||||
|
||||
Thank you for your support and cooperation.
|
||||
';
|
||||
|
||||
$subject = $notification_data['subject'];
|
||||
$mail_content = $notification_data['mail_content'];
|
||||
|
||||
foreach ($post_data['mails'] as $hr_id => $hr_data) {
|
||||
|
||||
$mail_content = str_ireplace('{{HR_NAME}}', $hr_data['name'], $mail_content);
|
||||
$mail_content = str_ireplace('{{CLIENT_NAME}}', $client_data['client_name'], $mail_content);
|
||||
|
||||
$mail_content = str_ireplace('{{hr_name}}', $hr_data['name'], $mail_content);
|
||||
$mail_content = str_ireplace('{{client_name}}', $client_data['client_name'], $mail_content);
|
||||
$res = MailHelper::send_email(['mail' => $hr_data['mail'], 'subject' => $subject, 'message' => $mail_content, 'common' => $common]);
|
||||
}
|
||||
|
||||
|
||||
@ -94,7 +94,8 @@ class NotificationController extends AdminController
|
||||
'member_ecard_mail_btn',
|
||||
'member_review_and_summary_mail_btn',
|
||||
'account_maneger_summary_mail_btn',
|
||||
'client_hr_summary_mail_btn'
|
||||
'client_hr_summary_mail_btn',
|
||||
'hr_cd_insufficient_balance_mail_btn',
|
||||
];
|
||||
$data = [];
|
||||
$emptyTemplate = [];
|
||||
|
||||
@ -131,6 +131,8 @@
|
||||
$member_review_and_summary_mail = 0;
|
||||
$account_maneger_summary_mail = 0;
|
||||
$client_hr_summary_mail = 0;
|
||||
$hr_cd_insufficient_balance_mail = 0;
|
||||
|
||||
if (isset($notification)) {
|
||||
foreach ($notification as $value) {
|
||||
|
||||
@ -161,6 +163,10 @@
|
||||
if ($value['template_name'] == 'client_hr_summary_mail') {
|
||||
$client_hr_summary_mail = $value['enabled'];
|
||||
}
|
||||
|
||||
if ($value['template_name'] == 'hr_cd_insufficient_balance_mail') {
|
||||
$hr_cd_insufficient_balance_mail = $value['enabled'];
|
||||
}
|
||||
}
|
||||
}
|
||||
?></p>
|
||||
@ -265,6 +271,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- member review and summary mail -->
|
||||
<div class="form-group col-md-6 mail-row">
|
||||
<div class="mail-section">
|
||||
@ -283,6 +290,26 @@
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Hr cd insifficient mail -->
|
||||
<div class="form-group col-md-6 mail-row">
|
||||
<div class="mail-section">
|
||||
<div class="left">
|
||||
<label class="switch">
|
||||
<input id="hr_cd_insufficient_balance_mail_btn" type="checkbox" name="hr_cd_insufficient_balance_mail_btn" <?= $hr_cd_insufficient_balance_mail == 1 ? 'checked' : '' ?>>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
<span class="ml-2"> HR CD Insufficient Balance Mail</span>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a href="" data-toggle="modal" id="hr_cd_insufficient_balance_mail" onclick="getMailTemplateData(this)" data-target="#hr_cd_insufficient_balance_mail_modal">
|
||||
<i class="mdi mdi-pencil"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -988,6 +1015,89 @@
|
||||
</div> <!-- /.modal-dialog -->
|
||||
</div> <!-- /.modal -->
|
||||
|
||||
<!-- 7 Modal content for the Large example => CD balance insufficent HR mail sent -->
|
||||
<div class="modal fade" id="hr_cd_insufficient_balance_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
||||
aria-hidden="true" aria-modal="true" data-backdrop="static">
|
||||
<div class="modal-dialog modal-full-width">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myLargeModalLabel"> HR CD Insufficient Balance Mail <span id="nameOfThePolicy"></span></h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="text-center" id="no_data"></div>
|
||||
|
||||
<form role="form" class="parsley-examples" method="post" id="hr_cd_insufficient_balance_mail_form" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-2">
|
||||
<label for="template_name">Template Name</label>
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<input type="text" id="template_name" name="template_name" value="HR CD Insufficient Balance Mail" readonly class="form-control" placeholder="Template Name">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-2">
|
||||
<label for="subject">Subject</label>
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
|
||||
</div>
|
||||
<div class="form-group col-md-5 testmail" style="display: none;">
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this,'send')">Test Mail</a>
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="PreviewTheMail(this,'preview','client_hr_summary_mail')">Preview Mail</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hr_cd_insufficient_balance_mail_section">
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-12">
|
||||
<select id="hr_cd_insufficient_balance_mail_customButton" class="form-control" style="border:none; right:6px; width:auto; position:absolute; z-index:1; top:17px; height:32px; float:right;" onchange="copyToClipboard(this)">
|
||||
<option value="">PlaceHolders</option>
|
||||
<?php foreach ($placeHolders as $value): ?>
|
||||
<?php if (in_array($value, ['hr_name', 'client_name'])): ?>
|
||||
<?php $valueChange = ucwords(str_replace('_',' ',$value)); ?>
|
||||
<option value="{{<?php echo $value; ?>}}"><?php echo $valueChange; ?></option>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<span id="copy-feedback" style="display: none; position: absolute; top:50px; right:10px; color:green; font-size:12px;">Copied to clipboard!</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<!-- Unlayer editor -->
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-12">
|
||||
<div id="hr_cd_insufficient_balance_mail_editor_container" style="height:600px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="editor"></div>
|
||||
<input type="file" id="Question_title_fileInput" style="display:none;">
|
||||
</div>
|
||||
|
||||
</div> <!-- /.form-group -->
|
||||
|
||||
|
||||
<div class="form-group text-right m-b-0 hr_cd_insufficient_balance_mail_action">
|
||||
<button type="button" class="btn btn-primary waves-effect waves-light mr-1 preview_button">Preview</button>
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnGridSubmit_2">Submit</button>
|
||||
</div>
|
||||
|
||||
<div class="hr_cd_insufficient_balance_mail_preview"></div>
|
||||
|
||||
</form>
|
||||
|
||||
</div> <!-- /.modal-body -->
|
||||
</div> <!-- /.modal-content -->
|
||||
</div> <!-- /.modal-dialog -->
|
||||
</div> <!-- /.modal -->
|
||||
|
||||
<div class="modal fade" id="preview_modal" tabindex="-1" role="dialog" aria-hidden="false" aria-modal="true" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
@ -1841,7 +1951,14 @@
|
||||
function getMailTemplateData(element) {
|
||||
template_name = element.id;
|
||||
const validTemplates = [
|
||||
"account_maneger_summary_mail", "member_reminder_mail","member_common_mail", "member_ecard_mail", "member_welcome_mail", "member_review_and_summary_mail", "client_hr_summary_mail"
|
||||
"account_maneger_summary_mail",
|
||||
"member_reminder_mail",
|
||||
"member_common_mail",
|
||||
"member_ecard_mail",
|
||||
"member_welcome_mail",
|
||||
"member_review_and_summary_mail",
|
||||
"client_hr_summary_mail",
|
||||
"hr_cd_insufficient_balance_mail"
|
||||
];
|
||||
console.log(`:) getMailTemplateData function called for ${template_name}`); // REF : PS
|
||||
if (!validTemplates.includes(template_name)) {
|
||||
@ -2347,6 +2464,61 @@
|
||||
});
|
||||
});
|
||||
|
||||
$('#hr_cd_insufficient_balance_mail_form').submit(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// Check if editor instance exists
|
||||
if (!editor) {
|
||||
console.error("Editor not initialized");
|
||||
toastr.error("Editor not ready. Please try again.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the editor instance instead of unlayer directly
|
||||
editor.exportHtml(function(data) {
|
||||
|
||||
var formData = new FormData($('#hr_cd_insufficient_balance_mail_form')[0]);
|
||||
|
||||
// Append Unlayer data
|
||||
formData.append('mailContent', data.html);
|
||||
formData.append('client_id', $('#general_PrimaryKey').val());
|
||||
formData.append('mailJson', JSON.stringify(data.design));
|
||||
|
||||
console.log([...formData.entries()]);
|
||||
|
||||
|
||||
// Show loading indicators
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
var form_action = '<?= base_url("client/notification/create") ?>';
|
||||
|
||||
$.ajax({
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
$('#client_hr_summary_mail_modal').find('.close').click();
|
||||
toastr.success('Template saved successfully');
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
setTimeout(function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
toastr.warning('Something Went Wrong!', 'warning');
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function hideBranding() {
|
||||
$('iframe').on('load', function() {
|
||||
console.log('Iframe loaded.');
|
||||
@ -2445,6 +2617,10 @@
|
||||
name: 'client_hr_summary_mail_btn',
|
||||
value: $('#client_hr_summary_mail_btn').prop('checked')
|
||||
});
|
||||
formData.push({
|
||||
name: 'hr_cd_insufficient_balance_mail_btn',
|
||||
value: $('#hr_cd_insufficient_balance_mail_btn').prop('checked')
|
||||
});
|
||||
|
||||
var form_action = '<?= base_url("client/notification/update_enable") ?>';
|
||||
$('.loader').fadeIn();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user