diff --git a/app/Controllers/BDSReportController.php b/app/Controllers/BDSReportController.php
index 80e71ec9..59fd54e1 100644
--- a/app/Controllers/BDSReportController.php
+++ b/app/Controllers/BDSReportController.php
@@ -62,7 +62,7 @@ class BDSReportController extends AdminController
left join pt_co_share_details pt_co on ins.id = pt_co.insurer_id and pt_co.is_active = 1
left join co_share_stmt_details stmt on pt_co.id = stmt.co_share_id and stmt.is_active = 1
left join policy_transaction pt on pt_co.pt_id = pt.id and pt.is_active = 1 and pt.policy_issue_date >= '$fromDate' and pt.policy_issue_date <= '$toDate'
- left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $insurerCategory
+ left join policy_type ptp on pt.policy_type_id = ptp.id and ptp.policy_category = $insurerCategory and ptp.is_active = 1
where ins.is_active = 1 and (ptp.policy_category = $insurerCategory or ptp.policy_category is null)
group by ins.id
";
diff --git a/app/Helpers/ExcelSanitizeHelper.php b/app/Helpers/ExcelSanitizeHelper.php
index 67aaa55e..5c2836a7 100644
--- a/app/Helpers/ExcelSanitizeHelper.php
+++ b/app/Helpers/ExcelSanitizeHelper.php
@@ -1,4 +1,5 @@
$value) {
if (is_array($value)) {
$cleanData[$key] = self::sanitizeArrayData($value); // Recursive call for nested arrays
} elseif (is_string($value)) {
// Remove non-printable characters and trim whitespace from strings
- $cleanData[$key] = trim(str_replace(self::$nonPrintableChars, '', $value));
+ $cleanData[$key] = trim(preg_replace(self::$nonPrintablePattern, '', $value));
} else {
$cleanData[$key] = $value; // Keep non-string/non-array data as is
}
}
-
return $cleanData;
} catch (\Exception $e) {
// Log the error and the problematic data for debugging
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
@@ -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);
+ });
+ }
+ }
+
+
+
diff --git a/tests/unit/ExcelSanitizeHelperTest.php b/tests/unit/ExcelSanitizeHelperTest.php
new file mode 100644
index 00000000..f098ece7
--- /dev/null
+++ b/tests/unit/ExcelSanitizeHelperTest.php
@@ -0,0 +1,67 @@
+ "HelloWorld",
+ "withNonPrintable" => "71030034240400000016",
+ "withWhitespace" => " Trim me ",
+ "nonStringValue" => 'Hello
+World',
+ ];
+ $expected = [
+ "validString" => "HelloWorld",
+ "withNonPrintable" => "71030034240400000016",
+ "withWhitespace" => "Trim me",
+ "nonStringValue" => 'HelloWorld',
+ ];
+ $result = ExcelSanitizeHelper::sanitizeArrayData($input);
+ // var_dump($input);
+ // var_dump($result);
+ $this->assertSame($expected, ExcelSanitizeHelper::sanitizeArrayData($input));
+
+ // Test with nested arrays
+ $input = [
+ "nested" => [
+ "validString" => "71030034240400000016",
+ "withNonPrintable" => "Nested\x01\x02String_x000A_",
+ ],
+ "withWhitespace" => " Outer whitespace ",
+ ];var_dump($input);
+ $expected = [
+ "nested" => [
+ "validString" => "71030034240400000016",
+ "withNonPrintable" => "NestedString",
+ ],
+ "withWhitespace" => "Outer whitespace",
+ ];
+ $this->assertSame($expected, ExcelSanitizeHelper::sanitizeArrayData($input));
+
+ // Test with empty array
+ $this->assertSame([], ExcelSanitizeHelper::sanitizeArrayData([]));
+
+ // Test with an array containing only non-string values
+ $input = [
+ "integer" => 42,
+ "float" => 3.14,
+ "boolean" => true,
+ "null" => null,
+ ];
+ $this->assertSame($input, ExcelSanitizeHelper::sanitizeArrayData($input));
+
+ // Test with invalid input to ensure graceful handling (edge case)
+ $input = ["invalid" => "\x00\x01\x7F_x000D_", "normal" => "Text"];
+ $expected = ["invalid" => "", "normal" => "Text"];
+ $this->assertSame($expected, ExcelSanitizeHelper::sanitizeArrayData($input));
+ }
+}