From a1bebbbbf240dbd785d585eabd3eea2c2ace6ca7 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Mon, 27 Jan 2025 09:03:22 +0530 Subject: [PATCH] FIX_UNLAYER_SUBMIT,FEAT_ATTACHMENTS_FOR_ECARD,FEAT_PLACEHOLDERS_IN_UNLAYER --- app/Helpers/sendMailNotification.php | 16 ++- app/Views/notification.php | 140 ++++++++++++++++++++++++--- 2 files changed, 141 insertions(+), 15 deletions(-) diff --git a/app/Helpers/sendMailNotification.php b/app/Helpers/sendMailNotification.php index 9136801e..a5af0834 100755 --- a/app/Helpers/sendMailNotification.php +++ b/app/Helpers/sendMailNotification.php @@ -1226,6 +1226,20 @@ class sendMailNotification $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']; @@ -1252,7 +1266,7 @@ class sendMailNotification $mail_content = str_replace("[[ecard_download_link]]", "Download Insurance Card", $mail_content); $mail_content = str_replace("[[client_name]]", $client_data['client_name'], $mail_content); - $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']]; return $wholeData; diff --git a/app/Views/notification.php b/app/Views/notification.php index 87671314..cb738661 100755 --- a/app/Views/notification.php +++ b/app/Views/notification.php @@ -175,7 +175,7 @@     - Edit + Edit
@@ -446,6 +446,16 @@ + + + + + + + + + +
AttachmentsAction
@@ -664,7 +674,24 @@ -
+ +
+
+ + +
+
+
@@ -897,7 +924,7 @@ } else if (target.matches('#account_maneger_summary_mail_modal_customButton')) { - editor4.selection.insertHTML($(target).val()); + // editor4.selection.insertHTML($(target).val()); $(target).val(''); } else if (target.matches('#client_hr_summary_mail_modal_customButton')) @@ -913,7 +940,7 @@ editor.setEditorValue(''); editor2.setEditorValue(''); editor3.setEditorValue(''); - editor4.setEditorValue(''); + // editor4.setEditorValue(''); editor5.setEditorValue(''); editor6.setEditorValue(''); @@ -1275,10 +1302,10 @@ return word.charAt(0).toUpperCase() + word.slice(1); }).join(' '); } - +template_name = ''; function getMailTemplateData(element) { - var template_name = $(element).attr('id'); + template_name = $(element).attr('id'); if (template_name == "member_welcome_mail" || template_name == "member_reminder_mail" || template_name == "member_ecard_mail" || template_name == "member_review_and_summary_mail" || template_name == "client_hr_summary_mail") { @@ -1311,16 +1338,19 @@ if(res.id){ $('.testmail').show(); $('#attachment_table').show(); + $('#attachment_table_ecard') $('.setid').attr('data-id', res.id); }else{ $('.testmail').hide(); $('#attachment_table').hide(); + $('#attachment_table_ecard').hide(); $('.setid').attr('data-id', ''); } }else{ $('.testmail').hide(); $('#attachment_table').hide(); + $('#attachment_table_ecard').hide(); $('.setid').attr('data-id', ''); } @@ -1448,8 +1478,13 @@ function addHTMLInput(data = null) { console.log('addHTMLInput function called'); - - const container = document.getElementById('attachment_tbody'); + console.log(template_name); + var container = ''; + if (template_name == 'member_welcome_mail'){ + container = document.getElementById('attachment_tbody'); + }else{ + container = document.getElementById('attachment_tbody_ecard'); + } if (data) { @@ -1512,7 +1547,11 @@ } function removeHTMLInput(element) { - const container = document.getElementById('attachment_tbody'); + if (template_name == 'member_welcome_mail'){ + const container = document.getElementById('attachment_tbody'); + }else{ + const container = document.getElementById('attachment_tbody_ecard'); + } const rows = container.querySelectorAll('.dynamic-form-row'); if (rows.length > 1) { @@ -1525,13 +1564,14 @@ event.preventDefault(); // Prevent the default form submission - var template_name = $('#member_welcome_mail_template_name').val(); + // var template_name = template_name; var client_id = $('#general_PrimaryKey').val(); + // console.log(client_id); const formData = new FormData(form); formData.append('template_name', template_name); formData.append('client_id', client_id); - + console.log(formData.template_name); const fileInput = form.querySelector('input[type="file"]'); // Check if a file is selected @@ -1597,7 +1637,7 @@ function removeAttachment(id){ - var template_name = $('#member_welcome_mail_template_name').val(); + // var template_name = template_name var client_id = $('#general_PrimaryKey').val(); $('.loader').fadeIn(); @@ -1751,10 +1791,10 @@ function initializeEditor(callback) { } // Modified template data function with better error handling -function getMailTemplateData(element) { +function getMailTemplateData2(element) { const template_name = element.id; const validTemplates = [ - "account_maneger_summary_mail", + "account_maneger_summary_mail","member_reminder_mail","member_ecard_mail" ]; if (!validTemplates.includes(template_name)) { @@ -1824,6 +1864,7 @@ function getMailTemplateData(element) { // Update UI elements $('.testmail').toggle(!!res.id); $('#attachment_table').toggle(!!res.id); + $('#attachment_table_ecard').toggle(!!res.id); $('.setid').attr('data-id', res.id || ''); }else{ console.log("Inside else"); @@ -1949,5 +1990,76 @@ function hideBranding(){ console.log('Overlay added to hide branding.'); }); } +function copyToClipboard(selectElement) { + const value = selectElement.value; // Get the selected value + if (value) { + // Use the Clipboard API to copy the value + navigator.clipboard.writeText(value) + .then(() => { + const feedback = document.getElementById('copy-feedback'); + feedback.style.display = 'inline'; // Show the feedback message + setTimeout(() => { + feedback.style.display = 'none'; // Hide the feedback message after 2 seconds + }, 2000); + }) + .catch(err => { + console.error('Failed to copy text: ', err); + }); + } + } + + +