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

This commit is contained in:
VENKATESHWARAN 2025-11-06 11:39:57 +05:30
commit 5c43b37091
3 changed files with 102 additions and 8 deletions

View File

@ -3878,6 +3878,7 @@ class EmployeeRestController extends AdminController
{
$emp_id = $this->request->getGet('emp_id');
$db = \Config\Database::connect();
$data = $db->table('employees e')
->select('pt.policy_type,
@ -3894,11 +3895,12 @@ class EmployeeRestController extends AdminController
->get()
->getResultArray();
// print_r($db->getLastQuery());die();
// print_r($data);die();
// Loop through $data and check for policy_type = GMC
$userParams = [];
foreach ($data as $row) {
if ($row['policy_type'] === 'GMC') {
// if ($row['policy_type'] === 'GMC') {
$userParams['name'] = $row['name'];
$userParams['email'] = $row['email'];
$userParams['phone'] = $row['phone'];
@ -3917,14 +3919,14 @@ class EmployeeRestController extends AdminController
$userParams['moduleName'] = 'home';
break; // stop after first GMC match
}
// }
}
if (empty($userParams)) {
return $this->respond(['status' => 'failed','message' => 'Coming soon........!'], 200);
}
// echo 'coming';die();
// Derive 32-byte key from SHA256
$derivedKey = hash('sha256', env('VISIT_SECRET_KEY'), true);

View File

@ -201,10 +201,17 @@ class NotificationController extends AdminController
}
if( isset($value['template_name']) && !empty($value['template_name']) && $value['template_name'] == "member_common_mail"){
$value['common_mails'] = $this->CommonEMailModel->where('notification_id',$value['id'])->findAll()??[];
$common_mails = $this->CommonEMailModel
->where('notification_id',$value['id'])
->where('is_active',1)
->findAll()??[];
$value['comman_mails'] = !empty($common_mails)
? trim(implode("," , array_column( $common_mails,'email') ))
: [];
}
return json_encode($value);

View File

@ -359,6 +359,7 @@
<input type="hidden" class="form-control" id="template_name" name="template_name" value="Common Mail" readonly>
<input type="hidden" id="member_common_mail_template_name" value="member_common_mail">
<input type="hidden" id="notification_temp_id" name="notification_temp_id">
<div class="form-group">
@ -372,7 +373,7 @@
</div>
</div>
<div class="form-row" id="email_list">
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-2">
<label for="emp_code">Email(s)</label>
</div>
@ -434,6 +435,8 @@
</div>
<div class="form-group text-right m-b-0">
<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>
@ -1359,6 +1362,77 @@
}
function sendCommonMails(){
let test_mail_list = $('#email_list').val();
test_mail_list = test_mail_list.split(',');
console.log("test_mail_list");
console.log(test_mail_list);
test_mail_list.forEach((element)=>{
test_mail = element;
if (test_mail !== null || test_mail !== "") {
if (isValidEmail(test_mail)) {
var template_id = $('#notification_temp_id').val();
if (template_id) {
console.log("testmail ..!!");
console.log(test_mail);
let url = '<?= base_url('util/sentTestMail/') ?>' + template_id + '/' + test_mail;
console.log('testing mail url:', url);
$.ajax({
url: url,
type: "GET",
dataType: 'json',
success: function(res) {
console.log('Test mail send function response', res)
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (res.status == true) {
let respond = res.respond;
console.log('Parsed respond', respond)
if (respond.status == 'success') {
toastr.success(respond.message, 'SUCCESS')
} else {
toastr.warning(respond.message, 'WARNING')
}
} else {
toastr.warning('Failed to sent mail', 'WARNING')
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
}
}
})
}
function isValidEmail(email) {
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return emailPattern.test(email);
@ -1761,7 +1835,11 @@
$('#attachment_table').toggle(!!res.id);
$('#attachment_table_ecard').toggle(!!res.id);
$('.setid').attr('data-id', res.id || '');
} else {
if (template_name == "member_common_mail"){
$('#notification_temp_id').val(res.id);
}
}
else{
console.log("Inside else");
let retryCount = 0;
const initWithRetry = function() {
@ -1786,6 +1864,13 @@
initWithRetry();
}
if(res.comman_mails != []){
console.log("common mails recieved here ........!!!!!!!!!!!");
console.log(res);
$('#email_list').val(res.comman_mails);
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
},