diff --git a/app/Controllers/NotificationController.php b/app/Controllers/NotificationController.php index 6efe58e3..82771ba4 100755 --- a/app/Controllers/NotificationController.php +++ b/app/Controllers/NotificationController.php @@ -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); diff --git a/app/Views/notification.php b/app/Views/notification.php index 99be6c3d..c6d84602 100755 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -359,6 +359,7 @@ +
@@ -372,7 +373,7 @@
-
+
@@ -434,6 +435,8 @@
+
@@ -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 = '' + 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'); },