From 171c9abdbbba1a6b12a71318cdd92978435bff36 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Thu, 6 Nov 2025 16:57:17 +0530 Subject: [PATCH] CHANGE_help_desk_tickets - VADIVEL J 2025-11-05 16:57 --- app/Helpers/sendMailNotification.php | 36 ++++++++++++- app/Views/notification.php | 76 +++++++++++++++++++++++++--- 2 files changed, 104 insertions(+), 8 deletions(-) diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 358b362..859cd08 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -81,6 +81,21 @@ class sendMailNotification $client_data = $params['client_data']; $common = $params['common']; + $mailAttachmentModel = new MailAttachmentModel(); + $attachment_data = $mailAttachmentModel + ->select('file_path, file_name') + ->where('notification_id', $notification_data['id']) + ->where('is_active', 1) + ->findAll()??[]; + + $attachments = []; + foreach ($attachment_data as $data) { + $attachments[] = [ + "filePath" => WRITEPATH . $data['file_path'], + "fileName" => $data['file_name'] + ]; + } + $subject = $notification_data['subject']; $app_link = $_ENV['App_Url']; $mail_content = $notification_data['mail_content']; @@ -109,7 +124,7 @@ class sendMailNotification $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]; + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'bcc' => $client_data['common_mails'], 'attachments' => $attachments, 'reply_to' => $client_data['reply_to'], 'common' => $common]; return $wholeData; } else if ($action == 'member_ecard_mail') { @@ -1264,6 +1279,23 @@ class sendMailNotification $client_data = $params['client_data']; $mail = $params['test_mail']; + $mailAttachmentModel = new MailAttachmentModel(); + $attachment_data = $mailAttachmentModel + ->select('file_path, file_name') + ->where('notification_id', $notification_data['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_data['mail_content']; $subject = $notification_data['subject']; @@ -1293,7 +1325,7 @@ class sendMailNotification $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']]; + $wholeData = ['mail' => $mail, 'subject' => $subject, 'message' => $mail_content, 'bcc' => $client_data['common_mails'], 'attachments' => $attachments , 'reply_to' => $client_data['reply_to']]; } } diff --git a/app/Views/notification.php b/app/Views/notification.php index 6d5908c..cba44f6 100755 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -370,6 +370,18 @@ + + + + + + + + + +
AttachmentsAction
+ +
@@ -1142,15 +1154,58 @@ console.log('addHTMLInput function called'); console.log(template_name); var container = ''; - if (template_name == 'member_welcome_mail') { + if( template_name == 'member_welcome_mail' ) { container = document.getElementById('attachment_tbody'); - } //else { + } + else if( template_name == "member_reminder_mail" ){ + container = document.getElementById('attachment_tbody_reminder_mail_attachments'); + } + //else { // container = document.getElementById('attachment_tbody_ecard'); - // } + // } + + if (data && template_name == "member_welcome_mail") { - if (data) { + $('#attachment_tbody').empty(); - $(container).empty(); + data.forEach(item => { + const newRow = document.createElement('tr'); + newRow.className = 'dynamic-form-row'; + + newRow.innerHTML = ` + ${item.file_name} + + `; + + container.appendChild(newRow); + }); + + // Creating another row for the form with file input + const newFormRow = document.createElement('tr'); + newFormRow.className = 'dynamic-form-row'; + + newFormRow.innerHTML = ` + +
+
+
+ +
+
+ +
+
+
+ + `; + + container.appendChild(newFormRow); + + } + + else if (data && template_name == "member_reminder_mail") { + + $('#attachment_tbody_reminder_mail_attachments').empty(); data.forEach(item => { const newRow = document.createElement('tr'); @@ -1186,6 +1241,8 @@ container.appendChild(newFormRow); } else { + + // If no data is passed, create a new empty row const newRow = document.createElement('tr'); newRow.className = 'dynamic-form-row'; @@ -1518,7 +1575,14 @@ initWithRetry(); - if (res.data && template_name == 'member_welcome_mail') { + if (res.data && (template_name == 'member_welcome_mail' )) { + console.log("file attachment for member_welcome_mail"); + console.log(template_name); + addHTMLInput(res.data); + } + if (res.data && ( template_name == "member_reminder_mail" )) { + console.log("file attachment for member_reminder_mail"); + console.log(template_name); addHTMLInput(res.data); } //else { // addHTMLInput();