Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
ff63ea8ecd
@ -719,7 +719,8 @@ $routes->group('test', function($routes) {
|
||||
$routes->get('membervalidation', 'TestingController::membervalidation');
|
||||
$routes->get('generateExcel', 'TestingController::generateExcel');
|
||||
$routes->get('logo_renaming','TestingController::logo_renaming');
|
||||
// $routes->get('createDefaultMailTempalteInDB','TestingController::createDefaultMailTempalteInDB');
|
||||
// $routes->get('createDefaultMailTempalteInDB','TestingController::createDefaultMailTempalteInCrossDB');
|
||||
// $routes->get('createDefaultMailTempalteInSameDB','TestingController::createDefaultMailTempalteInSameDB');
|
||||
});
|
||||
$routes->cli('cli/testcli', 'TestingController::testcli');
|
||||
|
||||
|
||||
@ -7745,6 +7745,10 @@ class ClientController extends AdminController
|
||||
|
||||
$member_review_and_summary_mail_template = $this->notificationModel->where('client_id',NULL)->where('template_name','member_review_and_summary_mail')->get()->getResultArray()[0]??[];
|
||||
|
||||
$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]??[];
|
||||
|
||||
$default_member_welcome_mail_template = [
|
||||
'client_id' => $client_id,
|
||||
'template_name' => 'member_welcome_mail',
|
||||
@ -7787,6 +7791,34 @@ class ClientController extends AdminController
|
||||
'mail_content_copy'=> null
|
||||
];
|
||||
|
||||
$default_member_ecard_mail_template = [
|
||||
'client_id' => $client_id,
|
||||
'template_name' => 'member_ecard_mail',
|
||||
'subject' => $member_ecard_mail_template['subject']??'',
|
||||
'mail_content' => $member_ecard_mail_template['mail_content']??'',
|
||||
'mail_content_json'=> $member_ecard_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
|
||||
];
|
||||
|
||||
$default_member_common_mail_template = [
|
||||
'client_id' => $client_id,
|
||||
'template_name' => 'member_common_mail',
|
||||
'subject' => $member_common_mail_template['subject']??'',
|
||||
'mail_content' => $member_common_mail_template['mail_content']??'',
|
||||
'mail_content_json'=> $member_common_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,
|
||||
@ -7798,7 +7830,9 @@ class ClientController extends AdminController
|
||||
$default_templates_inserted = $this->notificationModel->insertBatch([
|
||||
$default_member_welcome_mail_template,
|
||||
$default_member_remainder_mail_template,
|
||||
$default_member_review_and_summary_mail_template
|
||||
$default_member_review_and_summary_mail_template,
|
||||
$default_member_ecard_mail_template,
|
||||
$default_member_common_mail_template
|
||||
]);
|
||||
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
// declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers;
|
||||
use App\Models\CommonEMailModel;
|
||||
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
@ -28,13 +29,16 @@ class NotificationController extends AdminController
|
||||
protected $notificationModel;
|
||||
protected $clientModel;
|
||||
protected $MailAttachmentModel;
|
||||
|
||||
protected $CommonEMailModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->myLogger = \Config\Services::mylogger();
|
||||
$this->notificationModel = new NotificationModel();
|
||||
$this->clientModel = new ClientModel();
|
||||
$this->MailAttachmentModel = new MailAttachmentModel();
|
||||
$this->MailAttachmentModel = new MailAttachmentModel();
|
||||
$this->CommonEMailModel = new CommonEMailModel();
|
||||
}
|
||||
|
||||
// This is for Template Name Camel Case to Snake Case for store in DB
|
||||
@ -53,33 +57,80 @@ class NotificationController extends AdminController
|
||||
$form_data['mail_content'] = $this->request->getPost('mailContent');
|
||||
$form_data['client_id'] = $this->request->getPost('client_id');
|
||||
$form_data['mail_content_json'] = $this->request->getPost('mailJson');
|
||||
$form_data['email_list'] = $this->request->getPost('email_list');
|
||||
$notificationModel = new NotificationModel();
|
||||
|
||||
$find_notification = $notificationModel->where('client_id',$form_data['client_id'])->where('template_name',$form_data['template_name'])->first();
|
||||
|
||||
if ($find_notification) {
|
||||
|
||||
$id = $find_notification['id'];
|
||||
$id = $find_notification['id'] ?? '';
|
||||
$form_data['updated_by'] = get_session_userid();
|
||||
$notificationModel->update($id,$form_data);
|
||||
$this->save_common_mail($id , $form_data);
|
||||
$complete = "Update";
|
||||
|
||||
}else{
|
||||
|
||||
$form_data['created_by'] = get_session_userid();
|
||||
$notificationModel->insert($form_data);
|
||||
$id = $notificationModel->insert($form_data);
|
||||
$this->save_common_mail($id , $form_data);
|
||||
$complete = "Inserted";
|
||||
}
|
||||
|
||||
return json_encode($complete);
|
||||
|
||||
|
||||
}
|
||||
private function save_common_mail($id, $form_data)
|
||||
{
|
||||
|
||||
$this->logger->debug("step 1 - inside save common mail");
|
||||
|
||||
if (empty($form_data['email_list'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->logger->debug("step 2 - id and form_data are present");
|
||||
|
||||
$emails = array_map('trim', explode(',', $form_data['email_list']));
|
||||
|
||||
|
||||
$this->logger->debug("step 3 common emails were present");
|
||||
|
||||
$common_mail_data = [];
|
||||
|
||||
foreach ($emails as $email) {
|
||||
$common_mail_data[] = ['notification_id' => $id , 'email' => $email , 'is_active' => 1];
|
||||
}
|
||||
|
||||
$this->logger->debug("step 4 common email data \n" . json_encode($common_mail_data));
|
||||
|
||||
|
||||
// Deactivate existing emails
|
||||
$this->CommonEMailModel
|
||||
->where('notification_id', $id)
|
||||
->set(['is_active' => 0])
|
||||
->update();
|
||||
|
||||
$this->logger->debug("step 5 deleted old common email data");
|
||||
|
||||
|
||||
|
||||
// Insert all at once
|
||||
$this->CommonEMailModel->insertBatch($common_mail_data);
|
||||
|
||||
$this->logger->debug("step 6 common mail data insertion done ..!!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
// This is for the Enabls in Notification area and Update the Recipient and HR Mail Id in( Enables -> Notification table and Mail id's -> Client table)
|
||||
public function update_enable()
|
||||
{
|
||||
$checkboxNames = [
|
||||
'member_welcome_mail_btn',
|
||||
'common_mail_btn',
|
||||
'member_reminder_mail_btn',
|
||||
'member_ecard_mail_btn',
|
||||
'member_review_and_summary_mail_btn',
|
||||
|
||||
@ -869,7 +869,7 @@ class TestingController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
public function createDefaultMailTempalteInDB()
|
||||
public function createDefaultMailTempalteInCrossDB()
|
||||
{
|
||||
$postDB = \Config\Database::connect(); // target DB
|
||||
$preDB = \Config\Database::connect('preDB'); // source DB
|
||||
@ -920,7 +920,66 @@ class TestingController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON(['message'=>"Created Default Mail Tempalte In DB "])->setStatusCode(200);
|
||||
return $this->response->setJSON(['message'=>"Created Default Mail Tempalte In Cross DB "])->setStatusCode(200);
|
||||
}
|
||||
|
||||
public function createDefaultMailTempalteInSameDB()
|
||||
{
|
||||
$postDB = \Config\Database::connect();
|
||||
|
||||
// Templates to copy
|
||||
$templateNames = [
|
||||
'member_welcome_mail',
|
||||
'member_reminder_mail',
|
||||
'member_review_and_summary_mail',
|
||||
'member_common_mail',
|
||||
'member_ecard_mail'
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
foreach ($templateNames as $template) {
|
||||
|
||||
$exists = $postDB->table('notifications')
|
||||
->where('client_id', NULL)
|
||||
->where('template_name', $template)
|
||||
->countAllResults();
|
||||
|
||||
if ($exists > 0 ) {
|
||||
continue; // Skip if already inserted
|
||||
}
|
||||
|
||||
// Fetch template from preDB
|
||||
$templateData = $postDB->table('notifications')
|
||||
|
||||
// this is where we want to replace 0 with the client id we want to replace
|
||||
->where('client_id', 0)
|
||||
|
||||
// template_name from which you want to create a common template from templateNames array.
|
||||
->where('template_name', $template)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if (!empty($templateData)) {
|
||||
|
||||
// Remove ID to avoid duplicate primary key issues
|
||||
unset($templateData['id']);
|
||||
|
||||
// Set created_by and timestamps if needed
|
||||
$templateData['client_id'] = NULL;
|
||||
$templateData['created_by'] = 1;
|
||||
$templateData['cretaed_at'] = date('Y-m-d H:i:s');
|
||||
$templateData['updated_by'] = NULL;
|
||||
$templateData['updated_at'] = NULL;
|
||||
|
||||
// Insert into postDB
|
||||
$postDB->table('notifications')->insert($templateData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON(['message'=>"Created Default Mail Tempalte In Same DB "])->setStatusCode(200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -163,7 +163,62 @@ class sendMailNotification
|
||||
|
||||
return $wholeData;
|
||||
|
||||
} else if($action == 'member_review_and_summary_mail'){
|
||||
} else if($action == 'member_common_mail'){
|
||||
|
||||
$notification = $params['notification'];
|
||||
$get_emp_email_and_other_details = $params['get_emp_email_and_other_details'];
|
||||
$rand_string = $params['rand_string'];
|
||||
$client_data = $params['client_data'];
|
||||
$tpa_id = $params['tpa_id'];
|
||||
$common = $params['common'];
|
||||
|
||||
|
||||
$mail_content = $notification['mail_content'];
|
||||
$mail = $get_emp_email_and_other_details['email_corporate'];
|
||||
$subject = $notification['subject'];
|
||||
|
||||
$cleanedText = mb_convert_encoding($subject, 'UTF-8', 'UTF-8'); // Normalize encoding
|
||||
$cleanedText = preg_replace('/[^\x20-\x7E]/', '', $cleanedText);
|
||||
|
||||
$subject = $cleanedText;
|
||||
|
||||
$link = generate_download_link($rand_string).'/1';
|
||||
|
||||
$app_link = $_ENV['App_Url'];
|
||||
$name = $get_emp_email_and_other_details['name'];
|
||||
$employee_mobile_no = $get_emp_email_and_other_details['mobile'];
|
||||
$mail_content = $notification['mail_content'];
|
||||
|
||||
$nhance_logo = $_ENV['NHANCE_LOGO'];
|
||||
|
||||
$post_enrollment_app_link = $_ENV['POST_ENROLLMENT_APP_LINK'];
|
||||
|
||||
$client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
|
||||
// $client_logo = $nhance_logo;
|
||||
|
||||
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
||||
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
||||
|
||||
$mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name, $mail_content);
|
||||
$mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $employee_mobile_no, $mail_content);
|
||||
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
||||
$mail_content = str_replace(["[[post_enrollment_app_link]]", "{{post_enrollment_app_link}}"], "<a href='$post_enrollment_app_link'>Review Details</a>", $mail_content);
|
||||
// $mail_content = str_replace("[[tpa_id]]", $tpa_id, $mail_content);
|
||||
$mail_content = str_replace(["[[ecard_download_link]]", "{{ecard_download_link}}"], "<a href='$link/1'>Download Insurance Card</a>", $mail_content);
|
||||
$mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
||||
|
||||
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
||||
|
||||
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
||||
$data['mail_content'] = $mail_content;
|
||||
$mail_content = view('mail_template', $data);
|
||||
|
||||
|
||||
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'], 'reply_to' => $client_data['reply_to'], 'common' => $common];
|
||||
|
||||
return $wholeData;
|
||||
|
||||
}else if($action == 'member_review_and_summary_mail'){
|
||||
|
||||
$array_list = $params['array_list'];//employeee lst
|
||||
$client_policy_id = $params['client_policy_id'];
|
||||
@ -1331,6 +1386,61 @@ class sendMailNotification
|
||||
|
||||
return $wholeData;
|
||||
|
||||
}else if($action == 'member_common_mail'){
|
||||
|
||||
$notification = $params['notification_data'];
|
||||
$client_data = $params['client_data'];
|
||||
$mail = $params['test_mail'];
|
||||
$mailAttachmentModel = new MailAttachmentModel();
|
||||
$attachment_data = $mailAttachmentModel
|
||||
->select('file_path, file_name')
|
||||
->where('notification_id', $notification['id'])
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$attachments = [];
|
||||
foreach ($attachment_data as $data) {
|
||||
$attachments[] = [
|
||||
"filePath" => WRITEPATH . $data['file_path'],
|
||||
"fileName" => $data['file_name']
|
||||
];
|
||||
}
|
||||
|
||||
$mail_content = $notification['mail_content'];
|
||||
$subject = $notification['subject'];
|
||||
|
||||
$rand_string = 'HX3kUh';
|
||||
$link = generate_download_link($rand_string).'/1';
|
||||
|
||||
$name = 'John Doe';
|
||||
$mobile = 9080706050;
|
||||
|
||||
$nhance_logo = $_ENV['NHANCE_LOGO'];
|
||||
$app_link = $_ENV['App_Url'];
|
||||
$post_enrollment_app_link = $_ENV['POST_ENROLLMENT_APP_LINK'];
|
||||
|
||||
$client_logo = base_url() . "public/uploads/logo/" . $client_data['client_logo'];
|
||||
|
||||
$mail_content = str_replace(["[[nhance_logo]]", "{{nhance_logo}}"], "<img src='$nhance_logo' alt='Nhance Logo' width='20'>", $mail_content);
|
||||
$mail_content = str_replace(["[[client_logo]]", "{{client_logo}}"], "<img src='$client_logo' alt='Client Logo' width='20'>", $mail_content);
|
||||
|
||||
$mail_content = str_replace(["[[member_name]]", "{{member_name}}"], $name, $mail_content);
|
||||
$mail_content = str_replace(["[[member_mobile]]", "{{member_mobile}}"], $mobile, $mail_content);
|
||||
$mail_content = str_replace(["[[app_link]]", "{{app_link}}"], "<a href='$app_link'>Review Details</a>", $mail_content);
|
||||
$mail_content = str_replace(["[[post_enrollment_app_link]]", "{{post_enrollment_app_link}}"], "<a href='$post_enrollment_app_link'>Review Details</a>", $mail_content);
|
||||
$mail_content = str_replace(["[[ecard_download_link]]", "{{ecard_download_link}}"], "<a href='$link/1'>Download Insurance Card</a>", $mail_content);
|
||||
$mail_content = str_replace(["[[client_name]]", "{{client_name}}"], $client_data['client_name'], $mail_content);
|
||||
|
||||
$mail_content = preg_replace('/<p[^>]*>( |\s)*<\/p>/i', '', $mail_content);
|
||||
|
||||
$data['params'] = $params;$data['client_logo'] = $client_logo;
|
||||
$data['mail_content'] = $mail_content;
|
||||
$mail_content = view('mail_template', $data);
|
||||
|
||||
$wholeData = ['mail' => $mail, 'subject' => $subject,'message'=> $mail_content,'bcc'=> $client_data['common_mails'],'attachments' => $attachments, 'reply_to' => $client_data['reply_to']];
|
||||
|
||||
return $wholeData;
|
||||
|
||||
} else if($action == 'member_review_and_summary_mail'){
|
||||
|
||||
$array_list = [
|
||||
|
||||
42
app/Models/CommonEMailModel.php
Normal file
42
app/Models/CommonEMailModel.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class CommonEMailModel extends Model
|
||||
{
|
||||
protected $table = 'common_mail';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = ['email','notification_id','is_active'];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
}
|
||||
@ -125,6 +125,7 @@
|
||||
|
||||
// print_r($notification);
|
||||
$member_welcome_mail = 0;
|
||||
$member_common_mail = 0 ;
|
||||
$member_reminder_mail = 0;
|
||||
$member_ecard_mail = 0;
|
||||
$member_review_and_summary_mail = 0;
|
||||
@ -137,6 +138,10 @@
|
||||
$member_welcome_mail = $value['enabled'];
|
||||
}
|
||||
|
||||
if ($value['template_name'] == 'member_common_mail') {
|
||||
$member_common_mail = $value['enabled'];
|
||||
}
|
||||
|
||||
if ($value['template_name'] == 'member_reminder_mail') {
|
||||
$member_reminder_mail = $value['enabled'];
|
||||
}
|
||||
@ -187,11 +192,9 @@
|
||||
<!-- mail section -->
|
||||
|
||||
|
||||
<!-- Member welcome mail row-->
|
||||
<div class="form-row">
|
||||
|
||||
<!-- Example: Member welcome mail -->
|
||||
<div class="form-group col-md-6 mail-row">
|
||||
<!-- <div class="form-group col-md-6 mail-row">
|
||||
<div class="mail-section">
|
||||
<div class="left">
|
||||
<label class="switch">
|
||||
@ -206,10 +209,9 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> -->
|
||||
<!-- Example: Member reminder mail -->
|
||||
<div class="form-group col-md-6 mail-row">
|
||||
<!-- <div class="form-group col-md-6 mail-row">
|
||||
<div class="mail-section">
|
||||
<div class="left">
|
||||
<label class="switch">
|
||||
@ -224,12 +226,12 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<!-- Member Ecard mail row-->
|
||||
|
||||
<div class="form-row">
|
||||
<!-- Member Ecard mail row-->
|
||||
<div class="form-group col-md-6 mail-row">
|
||||
<div class="mail-section">
|
||||
<div class="left">
|
||||
@ -246,7 +248,25 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6 mail-row">
|
||||
<div class="mail-section">
|
||||
<div class="left">
|
||||
<label class="switch">
|
||||
<input id="member_common_mail_btn" type="checkbox" name="member_common_mail_btn" <?= $member_common_mail == 1 ? 'checked' : '' ?>>
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
<span class="ml-2"> Common Mail </span>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a href="" data-toggle="modal" id="member_common_mail" onclick="getMailTemplateData(this)" data-target="#member_common_mail_modal">
|
||||
<i class="mdi mdi-pencil"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- member review and summary mail -->
|
||||
<!-- <div class="form-group col-md-6 mail-row">
|
||||
<div class="mail-section">
|
||||
<div class="left">
|
||||
<label class="switch">
|
||||
@ -263,12 +283,13 @@
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<!-- Account Manager Summary Mail row-->
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6 mail-row">
|
||||
<!-- Account Manager Summary Mail row-->
|
||||
<!-- <div class="form-group col-md-6 mail-row">
|
||||
<div class="mail-section">
|
||||
<div class="left">
|
||||
<label class="switch">
|
||||
@ -283,8 +304,9 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-6 mail-row">
|
||||
</div> -->
|
||||
<!-- client hr summary mail -->
|
||||
<!-- <div class="form-group col-md-6 mail-row">
|
||||
<div class="mail-section">
|
||||
<div class="left">
|
||||
<label class="switch">
|
||||
@ -299,7 +321,7 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
@ -320,6 +342,107 @@
|
||||
<!-- end -->
|
||||
|
||||
|
||||
<!-- Modal content for the Large example -->
|
||||
<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">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myLargeModalLabel">Common 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="member_common_mail_form" enctype="multipart/form-data">
|
||||
|
||||
<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">
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-2">
|
||||
<label for="emp_code">Template Name</label>
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<input type="text" id="template_name" name="template_name" class="form-control" value="Member Common Mail" readonly placeholder="Template Name">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="email_list">
|
||||
<div class="form-group col-md-2">
|
||||
<label for="emp_code">Email(s)</label>
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<input type="text" id="email_list" name="email_list" class="form-control" placeholder="Enter Emails">
|
||||
<p style="color: black;font-size:12px;"> (* Multiple Emails Should Be Comma Seperated)</p>
|
||||
</div>
|
||||
</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" >
|
||||
<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 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)">
|
||||
<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="member_common_mail_editor_container" style="height: 600px"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="file" id="Question_title_fileInput" style="display: none;">
|
||||
|
||||
<table data-custom-table-css="table" id="attachment_table" class="table table-sm mb-0" style="margin-top: 30px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Attachments</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="attachment_tbody">
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<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 -->
|
||||
<div class="modal fade" id="member_welcome_mail_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
||||
@ -1221,7 +1344,7 @@
|
||||
});
|
||||
|
||||
} else {
|
||||
let alert_msg = 'Template ID not exist'
|
||||
let alert_msg = 'Template ID not exist , Kindly Save to Send Test Mails ..!!'
|
||||
toastr.warning(alert_msg, 'WARNING');
|
||||
}
|
||||
|
||||
@ -1248,7 +1371,8 @@
|
||||
var container = '';
|
||||
if (template_name == 'member_welcome_mail') {
|
||||
container = document.getElementById('attachment_tbody');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
container = document.getElementById('attachment_tbody_ecard');
|
||||
}
|
||||
|
||||
@ -1563,7 +1687,7 @@
|
||||
function getMailTemplateData(element) {
|
||||
template_name = element.id;
|
||||
const validTemplates = [
|
||||
"account_maneger_summary_mail", "member_reminder_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"
|
||||
];
|
||||
|
||||
if (!validTemplates.includes(template_name)) {
|
||||
@ -1916,6 +2040,64 @@
|
||||
});
|
||||
});
|
||||
|
||||
$('#member_common_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 = $('#member_common_mail_form').serializeArray();
|
||||
|
||||
// Append Unlayer editor data
|
||||
formData.push({
|
||||
name: 'mailContent',
|
||||
value: data.html
|
||||
});
|
||||
formData.push({
|
||||
name: 'client_id',
|
||||
value: $('#general_PrimaryKey').val()
|
||||
});
|
||||
formData.push({
|
||||
name: 'mailJson',
|
||||
value: JSON.stringify(data.design)
|
||||
});
|
||||
|
||||
// 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',
|
||||
success: function(res) {
|
||||
$('#member_common_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);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#member_review_and_summary_mail_form').submit(function(event) {
|
||||
event.preventDefault();
|
||||
@ -2082,6 +2264,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on('click', '#notification_enable_form_submit', function() {
|
||||
var formData = [];
|
||||
console.log($('#hr_mail_id').val());
|
||||
@ -2118,6 +2301,10 @@
|
||||
name: 'member_ecard_mail_btn',
|
||||
value: $('#member_ecard_mail_btn').prop('checked')
|
||||
});
|
||||
formData.push({
|
||||
name: 'member_common_mail_btn',
|
||||
value: $('#member_common_mail_btn').prop('checked')
|
||||
});
|
||||
formData.push({
|
||||
name: 'member_review_and_summary_mail_btn',
|
||||
value: $('#member_review_and_summary_mail_btn').prop('checked')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user