Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
VENKATESHWARAN 2025-11-28 08:57:18 +05:30
commit 15d272efb1
3 changed files with 213 additions and 125 deletions

View File

@ -217,40 +217,44 @@ class NotificationController extends AdminController
}
// This function for sent a mail for testing
public function sentTestMail($template_id, $test_mail)
// keep watching this
public function sentTestMail($template_id, $test_mail, $string_flag)
{
$notification_data = $this->notificationModel->where('id', $template_id)->first();
if(empty($notification_data)) {
return $this->respond(['status' => false,'code' => 200, 'message' => 'Notification Template not enabled']);
}
$client_data = $this->clientModel->where('id', $notification_data['client_id'])->where('is_active', 1)->first();
if(!empty($notification_data)){
$params = [
$params = [
'client_data' => $client_data,
'notification_data' => $notification_data,
'test_mail' => $test_mail
];
];
$testMailData = sendMailNotification::sendMailNotificationForTesting($notification_data['template_name'], $params);
// print_r($testMailData); die;
if (!empty($testMailData)) {
$testMailData = sendMailNotification::sendMailNotificationForTesting($notification_data['template_name'], $params);
$mail_send_return1 = MailHelper::send_email($testMailData);
$this->myLogger->logme("info", $mail_send_return1);
$this->myLogger->logme("info", $mail_send_return1);
if(empty($testMailData)) {
return $this->respond(['status' => false,'code' => 200, 'message' => 'Test Mail Data Does Not Exist']);
}
return $this->respond(['status' => true,'code' => 200, 'respond' => json_decode($mail_send_return1)]);
}else{
return $this->respond(['status' => false,'code' => 200, 'message' => 'Test Mail Data Does Not Exist']);
}
}else{
return $this->respond(['status' => false,'code' => 200, 'message' => 'Notification Template not enabled']);
if($string_flag == "send"){
$mail_send_return1 = MailHelper::send_email($testMailData);
$this->myLogger->logme("info", $mail_send_return1);
return $this->respond(['status' => true,'code' => 200, 'respond' => json_decode($mail_send_return1)]);
}
if($string_flag == "preview"){
return $this->respond([
'status' => true,
'code' => 200,
'content' => $testMailData
]);
}
}
public function sendCommonTestMail()

View File

@ -342,7 +342,7 @@
<!-- end -->
<!-- Modal content for the Large example => Common mail -->
<!-- 1 Modal content for the Large example => Common mail -->
<div class="modal fade" id="member_common_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 scrollb">
@ -354,7 +354,7 @@
<div class="modal-body">
<div class="text-center" id="no_data"></div>
<form role="form" class="parsley-examples" method="post" id="member_common_mail_form" enctype="multipart/form-data">
<input type="hidden" class="form-control" id="template_name" name="template_name" value="Common Mail" readonly>
@ -391,11 +391,13 @@
<input type="text" id="subject" name="subject" class="form-control" placeholder="Subject">
</div>
<div class="form-group col-md-2 testmail" >
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
<div class="form-group col-md-5 testmail" >
<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','member_common_mail')">Preview Mail</a>
</div>
</div>
<div class="member_common_mail_section">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select id="member_common_mail_modal_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)">
@ -435,19 +437,22 @@
</div>
<div class="form-group text-right m-b-0">
<div class="form-group text-right m-b-0 member_common_mail_action">
<button type="button" class="btn btn-primary waves-effect waves-light mr-1"
onclick="sendCommonMails()" > Send Common Mails </button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnGridSubmit_2">Submit</button>
</div>
</div>
<div class="member_common_mail_preview"></div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example => Welcome mail-->
<!-- 2 Modal content for the Large example => Welcome mail-->
<div class="modal fade" id="member_welcome_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 scrollb">
@ -474,11 +479,13 @@
<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-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
<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','member_welcome_mail')">Preview Mail</a>
</div>
</div>
<div class="member_welcome_mail_section">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select id="member_welcome_mailmodal_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)">
@ -516,18 +523,21 @@
</table>
</div>
</div>
<div class="member_welcome_mail_preview"></div>
<div class="form-group text-right m-b-0">
<div class="form-group text-right m-b-0 member_welcome_mail_action">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnGridSubmit_2">Submit</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example => Remainder mail -->
<!-- 3 Modal content for the Large example => Remainder mail -->
<div class="modal fade" id="member_reminder_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false" aria-modal="true">
<div class="modal-dialog modal-full-width">
<div class="modal-content">
@ -559,8 +569,9 @@
<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-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
<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','member_reminder_mail')">Preview Mail</a>
</div>
</div>
@ -575,6 +586,7 @@
</select>
</div>
</div> -->
<div class="member_reminder_mail_section">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select id="member_reminder_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)">
@ -618,19 +630,21 @@
</div>
<div class="form-group text-right m-b-0">
<div class="form-group text-right m-b-0 member_reminder_mail_action">
<button class="btn btn-primary waves-effect waves-light mr-1 preview_button"
id="">Preview</button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnGridSubmit_2">Submit</button>
</div>
</form>
</div>
<div class="member_reminder_mail_preview"></div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example => Ecard mail -->
<!-- 4 Modal content for the Large example => Ecard mail -->
<div class="modal fade" id="member_ecard_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">
@ -663,10 +677,12 @@
<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-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
<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','member_ecard_mail')">Preview Mail</a>
</div>
</div>
<div class="member_ecard_mail_section">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select id="member_ecard_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)">
@ -707,8 +723,10 @@
</table>
</div>
</div>
<div class="member_ecard_mail_preview"></div>
<div class="form-group text-right m-b-0">
<div class="form-group text-right m-b-0 member_ecard_mail_action">
<button class="btn btn-primary waves-effect waves-light mr-1 preview_button"
id="">Preview</button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
@ -720,7 +738,7 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example => Review And Summary mail -->
<!-- 5 Modal content for the Large example => Review And Summary mail -->
<div class="modal fade" id="member_review_and_summary_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">
@ -753,8 +771,9 @@
<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-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
<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','member_review_and_summary_mail')">Preview Mail</a>
</div>
</div>
@ -769,6 +788,7 @@
</select>
</div>
</div> -->
<div class="member_review_and_summary_mail_section">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select id="member_review_and_summary_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)">
@ -797,10 +817,12 @@
<input type="file" id="Question_title_fileInput" style="display: none;">
</div>
<div class="member_review_and_summary_mail_preview"></div>
</div>
<div class="form-group text-right m-b-0">
<div class="form-group text-right m-b-0 member_review_and_summary_mail_action">
<button class="btn btn-primary waves-effect waves-light mr-1 preview_button"
id="">Preview</button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
@ -812,7 +834,7 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example => Acc Manager Summary mail -->
<!-- 6 Modal content for the Large example => Acc Manager Summary mail -->
<div class="modal fade" id="account_maneger_summary_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">
@ -840,10 +862,12 @@
<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-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
<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','account_maneger_summary_mail')">Preview Mail</a>
</div>
</div>
<div class="account_maneger_summary_mail_section">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select id="account_maneger_summary_mail_modal_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)">
@ -866,7 +890,9 @@
<div id="account_maneger_summary_mail_editor_container" style="height: 600px"></div>
</div>
<!-- </div> -->
<div class="form-group text-right m-b-0">
</div>
<div class="account_maneger_summary_mail_preview"></div>
<div class="form-group text-right m-b-0 account_maneger_summary_mail_action">
<button class="btn btn-primary waves-effect waves-light mr-1 preview_button"
id="">Preview</button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
@ -879,14 +905,13 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal content for the Large example -->
<!-- 7 Modal content for the Large example => Client HR Summary mail -->
<div class="modal fade" id="client_hr_summary_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">Member Review and summary mail <span id="nameOfThePolicy"></span></h4>
<h4 class="modal-title" id="myLargeModalLabel">Member Review and Summary Mail <span id="nameOfThePolicy"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
@ -894,86 +919,74 @@
<div class="text-center" id="no_data"></div>
<form role="form" class="parsley-examples" method="post" id="client_hr_summary_mail_form" enctype="multipart/form-data">
<div class="form-group">
<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="Client HR Summary 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="emp_code">Template Name</label>
<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="form-group col-md-5">
<input type="text" id="template_name" name="template_name" value="Client HR Summary Mail" readonly class="form-control" placeholder="Template Name">
<div class="client_hr_summary_mail_section">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select id="client_hr_summary_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, ['member_name','nhance_logo','client_logo','app_link','client_name','member_summary'])): ?>
<?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="client_hr_summary_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 client_hr_summary_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="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-2">
<label for="emp_code">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-2 testmail" style="display: none;">
<a class="btn btn-primary waves-effect waves-light mr-1 setid" onclick="testMailSend(this)">Test Mail</a>
</div>
</div>
<!-- <div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select name="" id="" class="form-control" style="z-index: 1;float: right;position: absolute;margin-top: 18px;right: 53px;width: 100px;height: 30px;">
<option value="">1</option>
<option value="">2</option>
<option value="">3</option>
<option value="">4</option>
<option value="">6</option>
</select>
</div>
</div> -->
</div> -->
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select id="client_hr_summary_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 ($value == 'member_name' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name' || $value == 'member_summary') { ?>
<?php $valueChange = str_replace('_', ' ', $value);
$valueChange = ucwords($valueChange); ?>
<option value="{{<?php echo $value; ?>}}"><?php echo $valueChange; ?></option>
<?php } ?>
<?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="client_hr_summary_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 class="form-group text-right m-b-0">
<button class="btn btn-primary waves-effect waves-light mr-1 preview_button"
id="">Preview</button>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnGridSubmit_2">Submit</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
<!-- /.modal -->
<div class="client_hr_summary_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">
@ -990,6 +1003,7 @@
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- <script>
$(document).ready(function() {
const fileInput = document.getElementById("Question_title_fileInput");
@ -1286,6 +1300,8 @@
// Global editor variable
let editor = null;
let template_name = '';
var activeParentModalId = null;
$(document).ready(function() {
const fileInput = document.getElementById("Question_title_fileInput");
@ -1305,7 +1321,8 @@
})
function testMailSend(input) {
// keep watching
function testMailSend(input,StringFlag) {
let test_mail = prompt("Please enter test mail:");
console.log('mail address:', test_mail);
@ -1318,7 +1335,8 @@
console.log('templte id', template_id);
if (template_id) {
let url = '<?= base_url('util/sentTestMail/') ?>' + template_id + '/' + test_mail;
// let url = '<?= base_url('util/sentTestMail/') ?>' + template_id + '/' + test_mail;
let url = '<?= base_url('util/sentTestMail/') ?>' + template_id + '/' + test_mail + '/'+StringFlag;
console.log('testing mail url:', url);
$('.loader').fadeIn();
@ -2500,4 +2518,69 @@
}
});
})
function PreviewTheMail(button, StringFlag,className) {
let $btn = $(button);
let $formSection = $('.' + className + '_section');
let $actionButtons = $('.' + className + '_action');
let $previewSection= $('.' + className + '_preview');
console.log(":/");
console.log($formSection, $actionButtons, $previewSection);
// let $formSection = $('.client_hr_summary_mail_section');
// let $actionButtons = $('.client_hr_summary_mail_action');
// let $previewSection = $('.client_hr_summary_mail_preview');
// 2nd click → Close preview
if ($btn.data('previewing')) {
$formSection.show();
$actionButtons.show();
$previewSection.hide();
$btn.text('Preview Mail');
$btn.data('previewing', false);
return;
}
// 1st click → Open preview
let template_id = $btn.data('id');
let test_mail = "xyz@gmail.com";
if(!template_id){
toastr.warning('Template ID not exist', 'WARNING');
return;
}
let url = '<?= base_url('util/sentTestMail/') ?>' + template_id + '/' + test_mail + '/' + StringFlag;
$('.loader, .loader-mask').fadeIn();
$.ajax({
url: url,
type: "GET",
dataType: 'json',
success: function(res){
$('.loader, .loader-mask').fadeOut();
if(res.status){
let content = res.content || "No Data Found";
$previewSection.html(content.message);
$formSection.hide();
$actionButtons.hide();
$previewSection.show();
$btn.text('Close Preview');
$btn.data('previewing', true);
} else {
toastr.warning('Failed to load content', 'WARNING');
}
},
error: function(xhr){
$('.loader, .loader-mask').fadeOut();
console.error(xhr.responseText);
}
});
}
</script>

View File

@ -308,6 +308,7 @@
<label class="label-font-size" id="pod_no_label_1" for="pod_no">POD No with Courier Name <span id="pod_no_label_1_span" class="text-danger"></span></label>
<input type="text" class="form-control" id="pod_no" placeholder="Enter POD NO"
value="<?= isset($ticket_data['pod_no']) ? $ticket_data['pod_no'] : '' ?>"
oninput="this.value = this.value.replace(/[^0-9]/g, '');"
name="pod_no">
</div>