CHANGE_help_desk_tickets - VADIVEL J 2025-11-05 16:57

This commit is contained in:
vadivelJ96 2025-11-06 16:57:17 +05:30
parent 6aefa5e5ba
commit 171c9abdbb
2 changed files with 104 additions and 8 deletions

View File

@ -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']];
}
}

View File

@ -370,6 +370,18 @@
<input type="file" id="Question_title_fileInput" style="display: none;">
<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_reminder_mail_attachments">
</tbody>
</table>
</div>
<div class="form-group text-right m-b-0">
@ -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 = `
<td> ${item.file_name} </td>
<td> <a class="fa fa-trash" data-id="${item.id}" onclick="removeAttachment('${item.id}')"></a></td>
`;
container.appendChild(newRow);
});
// Creating another row for the form with file input
const newFormRow = document.createElement('tr');
newFormRow.className = 'dynamic-form-row';
newFormRow.innerHTML = `
<td>
<form class="ajax" onsubmit="submitAttachmentForm(event, this)">
<div class="form-row">
<div class="form-group col-3">
<input type="file" class="file-input__input" name="file" required>
</div>
<div class="form-group col-2">
<button type="submit" class="btn btn-sm btn-primary">Submit</button>
</div>
</div>
</form>
</td>
`;
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();