FEAT_REPLY_AND_NOTE_IN_CLAIM_MODULE_SRI
This commit is contained in:
parent
55e4b9ec17
commit
dd4e947f42
@ -502,6 +502,8 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('view/(:any)','TicketController::view_ticket/$1');
|
||||
$routes->get('mail_template','TicketController::mailTemplate');
|
||||
$routes->post('crud_mail_template/(:any)','TicketController::crudTemplate/$1');
|
||||
$routes->post('note','TicketController::crudNote');
|
||||
$routes->post('note/(:any)','TicketController::crudNote/$1');
|
||||
$routes->post('reply','TicketController::saveReply');
|
||||
// $routes->post('ticket_messages','TicketController::getTicketMessage');
|
||||
});
|
||||
|
||||
|
||||
@ -1669,11 +1669,12 @@ class MasterController extends AdminController
|
||||
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
|
||||
["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
|
||||
];
|
||||
$email_id = 'hariharan@nhanceindia.in';
|
||||
$email_id = 'srinivas.saravanan@venbainfotech.com';
|
||||
$params = ['mail'=>$email_id];
|
||||
$common = ['mail_type'=>'test_mail_cli'];
|
||||
$bcc = "vijayalakshmi@nhanceindia.in,vitvelz@gmail.com,velmurugan.s@venbainfotech.com,hariharan@nhanceindia.in,hariharan@jubiliant.in,srinivas.saravanan@venbainfotech.com";
|
||||
// $bcc = "vijayalakshmi@nhanceindia.in,vitvelz@gmail.com,velmurugan.s@venbainfotech.com,hariharan@nhanceindia.in,hariharan@jubiliant.in,srinivas.saravanan@venbainfotech.com";
|
||||
// Send email and get response
|
||||
$result = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI','bcc'=>$bcc ,'message' => $message,'attachments' => $attachments,'common'=>$common]);
|
||||
$result = MailHelper::send_email(['mail' => $email_id, 'params'=>$params,'subject' => 'Mail Via CLI','message' => $message,'attachments' => $attachments,'common'=>$common]);
|
||||
|
||||
|
||||
log_message('error',json_encode($result));
|
||||
|
||||
@ -11,6 +11,8 @@ use App\Models\TicketHistoryModel;
|
||||
use App\Models\TicketMailTemplateModel;
|
||||
use App\Models\TicketMessageModel;
|
||||
use App\Models\TicketNoteModel;
|
||||
use App\Models\UserModel;
|
||||
use DOMDocument;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Kint\Kint;
|
||||
|
||||
@ -33,9 +35,10 @@ class TicketController extends BaseController
|
||||
protected $ticketMasterModel;
|
||||
protected $ticketHistoryModel;
|
||||
protected $ticketMailTemplateModel;
|
||||
protected $ticketMesageModel;
|
||||
protected $ticketMessageModel;
|
||||
protected $ticketNoteModel;
|
||||
protected $triggerType;
|
||||
protected $userModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -92,15 +95,17 @@ class TicketController extends BaseController
|
||||
7 => "Trigger 7"
|
||||
];
|
||||
|
||||
$this->placeHolders = ['member_name', 'nhance_logo', 'tpa_id', 'ecard_download_link',
|
||||
'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link',
|
||||
'client_name'];
|
||||
$this->placeHolders = ['employee_name', 'employee_id', 'corporate_name', 'relationship',
|
||||
'insured_name', 'acm_name', 'acm_contact', 'claim_no', 'pt_name'];
|
||||
|
||||
$this->ticketMasterModel = new TicketMasterModel();
|
||||
$this->claimStatus = new TicketClaimStatusModel();
|
||||
$this->clientModel = new ClientModel();
|
||||
$this->ticketHistoryModel = new TicketHistoryModel();
|
||||
$this->ticketMailTemplateModel = new TicketMailTemplateModel();
|
||||
$this->ticketNoteModel = new TicketNoteModel();
|
||||
$this->ticketMessageModel = new TicketMessageModel();
|
||||
$this->userModel = new UserModel();
|
||||
|
||||
}
|
||||
|
||||
@ -201,7 +206,16 @@ class TicketController extends BaseController
|
||||
// dd($ticket_data);
|
||||
$data = $this->ticket_form_data($ticket_data['ticket_type_id']);
|
||||
$data['ticket_data'] = $ticket_data;
|
||||
$data['ticket_note'] = $this->ticketNoteModel->where('is_active', 1)->findAll();
|
||||
$data['reply_data'] = $this->ticketMasterModel
|
||||
->join('ticket_claim_status','ticket_master.claim_status_id = ticket_claim_status.id and ticket_claim_status.is_active = 1')
|
||||
->join('ticket_mail_template','ticket_claim_status.trigger_type = ticket_mail_template.trigger_type and ticket_claim_status.ticket_type = ticket_mail_template.ticket_type and ticket_mail_template.is_active = 1')
|
||||
->where('ticket_master.id',$ticket_id)
|
||||
->where('ticket_master.is_active',1)
|
||||
->first();
|
||||
$data['placeHolders'] = $this->placeHolders;
|
||||
$data['message_data'] = $this->getTicketMessage($ticket_id);
|
||||
// dd($data);
|
||||
|
||||
return $this->loadLayout('ticket_edit_onbording', $data);
|
||||
}
|
||||
|
||||
@ -351,8 +365,77 @@ class TicketController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function crudNote(){
|
||||
public function crudNote($action){
|
||||
// action = 1 is read, action 2 is insert/update
|
||||
if ($action == 1){
|
||||
$ticket_master_id = $this->request->getPost('id');
|
||||
if (isset($ticket_master_id) && $ticket_master_id != ''){
|
||||
$data = $this->ticketNoteModel->where('is_active',1)->where('ticket_id',$ticket_master_id)->first();
|
||||
if ($data){
|
||||
return $this->respond(['status' => true, 'data' => $data],200);
|
||||
}else{
|
||||
return $this->respond(['status' => false],404);
|
||||
}
|
||||
}
|
||||
|
||||
}elseif ($action == 2){
|
||||
$data = $this->request->getPost();
|
||||
// if (isset($data['id']) && $data['id'] != ''){
|
||||
$status = $this->ticketNoteModel->save($data);
|
||||
// }
|
||||
if ($status){
|
||||
return $this->respond(['status'=>true],200);
|
||||
}else{
|
||||
return $this->respond(['status'=>false],404);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function saveReply(){
|
||||
|
||||
$received_data = $this->request->getPost();
|
||||
$received_data['sender'] = 'staff';
|
||||
$status = $this->ticketMessageModel->save($received_data);
|
||||
if ($status){
|
||||
return $this->respond(['status' => true,'code'=>200],200);
|
||||
}else{
|
||||
return $this->respond(['status' => false,'code' => 404],404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getTicketMessage($ticket_master_id){
|
||||
// log_message('error','Function called');die();
|
||||
// $ticket_master_id = $this->request->getPost('id');
|
||||
$user_id = get_session_userid();
|
||||
$logged_user = $this->userModel->select('first_name,last_name,profile')->where('id',$user_id)->first();
|
||||
$dataToSend = [];
|
||||
$dataToSend['user_name'] = $logged_user['first_name'].' '.$logged_user['last_name'];
|
||||
$dataToSend['messages'] = $this->ticketMessageModel->where('is_active',1)
|
||||
->where('ticket_id',$ticket_master_id)->orderBy('created_at', 'DESC')
|
||||
->findAll();
|
||||
foreach ($dataToSend['messages'] as $message){
|
||||
$mail_content_converted = $this->convertHtmlToText($message['mail_content']);
|
||||
$message['mail_content'] = $mail_content_converted;
|
||||
}
|
||||
$dataToSend['emp_name'] = $this->ticketMasterModel->select('emp_name')
|
||||
->where('id',$ticket_master_id)->where('is_active',1)
|
||||
->first()['emp_name'];
|
||||
// dd($dataToSend);
|
||||
if($dataToSend){
|
||||
return $dataToSend;
|
||||
}else{
|
||||
$data = [];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function convertHtmlToText($html) {
|
||||
$dom = new DOMDocument();
|
||||
@$dom->loadHTML($html);
|
||||
return strip_tags($dom->saveHTML());
|
||||
}
|
||||
|
||||
}
|
||||
@ -56,11 +56,12 @@ class GmailResponseHandler{
|
||||
// 'employee_id' => isset($params['params']['common']['employee_id']) ? $params['params']['common']['employee_id'] : null,
|
||||
// 'mail_type' => isset($params['params']['common']['mail_type']) ? $params['params']['common']['mail_type'] : null,
|
||||
// 'gmail_api_status' => isset($params['gmail_api']['status']) ? $params['gmail_api']['status'] : null,
|
||||
// 'gmail_api_id' => isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null
|
||||
// 'gmail_api_id' => isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null,
|
||||
// 'received_message' => isset($params['gmail_api']['data']['labelIds'])?json_encode($params['gmail_api']['data']['labelIds']): null
|
||||
// ];
|
||||
// Initialize data array
|
||||
$data = [];
|
||||
// print_r($params['params']['common']);die();
|
||||
// // print_r($params['params']['common']);die();
|
||||
if (isset($params['params']['common'])) {
|
||||
foreach ($params['params']['common'] as $key => $value) {
|
||||
$data[$key] = isset($value) ? $value : null;
|
||||
|
||||
@ -12,7 +12,7 @@ class TicketMessageModel extends Model
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [];
|
||||
protected $allowedFields = ['id','sender','ticket_id','mail_subject','emp_mail','mail_content','created_at'];
|
||||
|
||||
|
||||
// Callbacks
|
||||
|
||||
@ -1,28 +1,37 @@
|
||||
<div id="ticket_messages_div">
|
||||
<?php $messages = $message_data['messages'];
|
||||
foreach ($messages as $message) :
|
||||
?>
|
||||
<?php if ($message['sender'] == 'user') { ?>
|
||||
<div class="card mb-3" style="margin-right: 23px;">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-xl-2 col-lg-3">
|
||||
<div class="text-center">
|
||||
<div class="mb-3">
|
||||
<img src="https://venbait.in/nhance/helpdesk/dev/assets/helpdeskz/images/user.jpg"
|
||||
class="user-avatar rounded-circle img-fluid" style="max-width: 100px">
|
||||
<div style="padding-left: 10px;" class="mb-3">
|
||||
<div class="row">
|
||||
<img src="https://venbait.in/nhance/helpdesk/dev/assets/helpdeskz/images/user.jpg"
|
||||
class="user-avatar rounded-circle img-fluid col-mb-6" style="max-width: 70px">
|
||||
<div style="padding-left: 10px;padding-top: 15px;" class="col-mb-6"><?= $message_data['emp_name'] ?></div>
|
||||
</div>
|
||||
<span style="text-align: center; position: relative;text-align: center;bottom: 28px;left: 15px;" class="badge badge-dark">User</span>
|
||||
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div>RUPESH</div>
|
||||
<span class="badge badge-dark">User</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="mb-3">
|
||||
<div class="text-muted"><i class="fa fa-calendar"></i> 16 December 2024 04:15 pm</div>
|
||||
<div class="text-muted"><i class="fa fa-calendar"></i> <?php echo (new DateTime($message['created_at']))->format('j F Y h:i a');?></div>
|
||||
</div>
|
||||
<div id="msg_388" class="form-group">
|
||||
Body </div>
|
||||
<div class="form-group mt-5">
|
||||
<p><?= $message['mail_content'] ?></p>
|
||||
</div>
|
||||
<!-- <div class="form-group mt-5">
|
||||
<button class="btn btn-dark btn-sm" type="button" onclick="quoteMessage(388);"><i
|
||||
class="fa fa-quote-left"></i> Quote</button>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="border-top mt-3 pt-4 text-right">
|
||||
</div>
|
||||
</div>
|
||||
@ -30,38 +39,41 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } else { ?>
|
||||
<div class="card mb-3 bg-staff" style="margin-right: 23px;">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-xl-2 col-lg-3">
|
||||
<div class="text-center">
|
||||
<div class="mb-3">
|
||||
<img src="https://venbait.in/nhance/helpdesk/dev/assets/helpdeskz/images/agent.jpg"
|
||||
class="user-avatar rounded-circle img-fluid" style="max-width: 100px">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div>Venkatesh HelpDesk Admin</div>
|
||||
<span class="badge badge-primary">Staff</span>
|
||||
<div style="padding-left: 10px;" class="mb-3">
|
||||
<div class="row">
|
||||
<img src="https://venbait.in/nhance/helpdesk/dev/assets/helpdeskz/images/agent.jpg"
|
||||
class="user-avatar rounded-circle img-fluid col-mb-6" style="max-width: 70px">
|
||||
<div style="padding-left: 10px;padding-top: 15px;" class="col-mb-6"><?= $message_data['user_name'] ?></div>
|
||||
|
||||
</div>
|
||||
<span style="text-align: center; position: relative;text-align: center;bottom: 28px;left: 15px;" class="badge badge-primary">Staff</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="mb-3">
|
||||
<div class="text-muted"><i class="fa fa-calendar"></i> 24 January 2025 03:41 pm</div>
|
||||
<div class="text-muted"><i class="fa fa-calendar"></i> <?php echo (new DateTime($message['created_at']))->format('j F Y h:i a');?></div>
|
||||
</div>
|
||||
<div id="msg_394" class="form-group">
|
||||
<p>hi how are you i am fine</p>
|
||||
<p><?= $message['mail_content'] ?></p>
|
||||
</div>
|
||||
<div class="form-group mt-5">
|
||||
<!-- <div class="form-group mt-5">
|
||||
<button class="btn btn-dark btn-sm" type="button" onclick="quoteMessage(394);"><i
|
||||
class="fa fa-quote-left"></i> Quote</button>
|
||||
</div>
|
||||
<div class="border-top mt-3 pt-4 text-right">
|
||||
</div> -->
|
||||
<!-- <div class="border-top mt-3 pt-4 text-right">
|
||||
<i class="fa fa-globe"></i> 115.97.253.189
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } endforeach; ?>
|
||||
</div>
|
||||
|
||||
@ -106,16 +106,17 @@ function submitClaimForm(event, form) {
|
||||
contentType: false,
|
||||
success: function(response) {
|
||||
// Hide loader
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.log('Form submitted response:', response);
|
||||
|
||||
if (response.status === true) {
|
||||
location.reload();
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
} else {
|
||||
toastr.error(response.message, 'ERROR');
|
||||
}
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
@ -127,4 +128,6 @@ function submitClaimForm(event, form) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@ -182,10 +182,10 @@ table.dataTable tbody td {
|
||||
<select id="ticket_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;">
|
||||
<option value="">PlaceHolders</option>
|
||||
<?php foreach ($placeHolders as $value): ?>
|
||||
<?php if($value == 'member_name' || $value == 'member_mobile' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){ ?>member_mobile
|
||||
<?php // if($value == 'member_name' || $value == 'member_mobile' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){ ?>member_mobile
|
||||
<?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?>
|
||||
<option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option>
|
||||
<?php } ?>
|
||||
<?php //} ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
@ -259,14 +259,52 @@ $(document).ready(function() {
|
||||
|
||||
const editor = Jodit.make("#ticket_mail_editor", editorConfig);
|
||||
|
||||
let lastActiveField = null;
|
||||
|
||||
// Track last active input field
|
||||
$("#template_subject").on("focus", function() {
|
||||
lastActiveField = this;
|
||||
});
|
||||
|
||||
// Track Jodit editor focus separately
|
||||
editor.events.on("focus", function() {
|
||||
lastActiveField = editor;
|
||||
});
|
||||
|
||||
document.addEventListener('change', function(event) {
|
||||
var target = event.target;
|
||||
if (target.matches('#ticket_mail_customButton'))
|
||||
{
|
||||
editor.selection.insertHTML($(target).val());
|
||||
$(target).val('');
|
||||
}
|
||||
});
|
||||
var target = event.target;
|
||||
if (target.matches('#ticket_mail_customButton')) {
|
||||
let placeholderValue = $(target).val();
|
||||
if (!placeholderValue) return;
|
||||
|
||||
if (lastActiveField) {
|
||||
if (lastActiveField.id === "template_subject") {
|
||||
insertAtCursor(lastActiveField, placeholderValue);
|
||||
} else {
|
||||
editor.selection.insertHTML(placeholderValue);
|
||||
}
|
||||
}
|
||||
|
||||
$(target).val('');
|
||||
}
|
||||
});
|
||||
|
||||
function insertAtCursor(input, textToInsert) {
|
||||
if (document.selection) {
|
||||
input.focus();
|
||||
var sel = document.selection.createRange();
|
||||
sel.text = textToInsert;
|
||||
} else if (input.selectionStart || input.selectionStart === 0) {
|
||||
let startPos = input.selectionStart;
|
||||
let endPos = input.selectionEnd;
|
||||
input.value = input.value.substring(0, startPos) + textToInsert + input.value.substring(endPos, input.value.length);
|
||||
input.selectionStart = input.selectionEnd = startPos + textToInsert.length;
|
||||
} else {
|
||||
input.value += textToInsert;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$('.close').click(function () {
|
||||
$('#template_subject').val('');
|
||||
$('#template_name').val('');
|
||||
|
||||
@ -7,11 +7,11 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="ticket_note">Add Notes</label>
|
||||
<textarea class="form-control" id="ticket_note" name="ticket_note" rows="3"
|
||||
placeholder="Enter Text"><?= isset($client['addon_subheading']) ? $client['addon_subheading'] : '' ?></textarea>
|
||||
<textarea class="form-control" id="ticket_note" name="note" rows="3"
|
||||
placeholder="Enter Text"><?= isset($ticket_note['note']) ? $ticket_note['note'] : '' ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div><input type="hidden" value="">
|
||||
</div><input type="hidden" id="note_id">
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="submit" class="btn btn-primary" id="ticket_note_submit">Submit</button>
|
||||
</div>
|
||||
@ -24,6 +24,28 @@
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
url = '<?= base_url('ticket/note/1')?>';
|
||||
data = { id : $('#ticket_master_id').val()};
|
||||
$.ajax({
|
||||
url:url,
|
||||
data:data,
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
if (res.status == true){
|
||||
$('#ticket_note').val(res.data.note);
|
||||
$('#note_id').val(res.data.id);
|
||||
}
|
||||
},
|
||||
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);
|
||||
}
|
||||
})
|
||||
|
||||
$("#ticket_note_form").submit(function(event) {
|
||||
|
||||
@ -31,13 +53,23 @@ $(document).ready(function() {
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
var url = '<?= base_url("/ticket/note"); ?>';
|
||||
var formData = new FormData($('#ticket_note_form')[0]);
|
||||
|
||||
var url = '<?= base_url("/ticket/note/2"); ?>';
|
||||
var formData = $(this).serializeArray();
|
||||
var ticket_id = $('#ticket_master_id').val();
|
||||
if (ticket_id != null && ticket_id != ''){
|
||||
formData.push({ name: 'ticket_id', value: ticket_id});
|
||||
}
|
||||
var primary_key = $('#note_id').val();
|
||||
if (primary_key != null && primary_key != ''){
|
||||
formData.push({ name: 'id', value: primary_key});
|
||||
}
|
||||
console.log(formData);
|
||||
sendAjaxRequestForGlobal(url, 'POST', formData, function(response) {
|
||||
if (response.status == true) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
toastr.success('Note Added Successfully','Success');
|
||||
|
||||
|
||||
} else {
|
||||
$('.loader').fadeOut();
|
||||
|
||||
@ -7,28 +7,39 @@
|
||||
<!-- Email To Field -->
|
||||
<div class="form-group col-md-4">
|
||||
<label for="emp_mail_for_to">To</label>
|
||||
<input type="text" class="form-control" id="emp_mail_for_to" name="emp_mail_for_to" placeholder="Recipient email">
|
||||
<input type="text" value="<?= isset($reply_data['emp_mail'])?$reply_data['emp_mail']:'' ?>" class="form-control" id="emp_mail_for_to" name="emp_mail" placeholder="Recipient email" readonly>
|
||||
</div>
|
||||
|
||||
<!-- Subject Field -->
|
||||
<div class="form-group col-md-4">
|
||||
<label for="mail_subject">Subject</label>
|
||||
<input type="text" class="form-control" id="mail_subject" name="mail_subject" placeholder="Mail subject">
|
||||
<input type="text" class="form-control" value="<?= isset($reply_data['subject'])?$reply_data['subject']:'' ?>" id="mail_subject" name="mail_subject" placeholder="Mail subject">
|
||||
</div>
|
||||
|
||||
<!-- Mail Content Field -->
|
||||
<div class="form-group col-md-12">
|
||||
<label for="mail_content">Mail Content</label>
|
||||
<textarea class="form-control" id="mail_content" name="mail_content" rows="3" placeholder="Enter mail content">
|
||||
<?= isset($client['addon_subheading']) ? $client['addon_subheading'] : '' ?>
|
||||
</textarea>
|
||||
</div>
|
||||
<!-- <textarea class="form-control" rows="5" placeholder="Enter Mail Content"></textarea> -->
|
||||
<div class="form-row" id="rac_rate_dropdown">
|
||||
<div class="form-group col-md-12">
|
||||
<select id="ticket_mail_customButton" class="form-control" style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;">
|
||||
<option value="">PlaceHolders</option>
|
||||
<?php foreach ($placeHolders as $value): ?>
|
||||
<!-- <?php // if($value == 'member_name' || $value == 'member_mobile' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){ ?>member_mobile -->
|
||||
<?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?>
|
||||
<option value="[[<?php echo $value; ?>]]"><?php echo $valueChange; ?></option>
|
||||
<?php //} ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div id="ticket_mail_editor" name="content" style="height: 300px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Submit Button -->
|
||||
<div class="form-group text-right">
|
||||
<button type="submit" class="btn btn-primary" id="ticket_reply_submit">Submit</button>
|
||||
<button type="submit" class="btn btn-primary" id="ticket_reply_submit">Send Mail</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -37,31 +48,138 @@
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var toolbar = "bold,italic,strikethrough,|,superscript,subscript,|,align,";
|
||||
const editorConfig = {
|
||||
buttons: toolbar.concat(['fontsize']),
|
||||
fontsize: [8, 10, 12, 14, 16, 18, 20, 22, 24], // Customize font sizes
|
||||
showPlaceholder: false,
|
||||
toolbarButtonSize: 'small',
|
||||
toolbarAdaptive: false,
|
||||
saveHeightInStorage: true,
|
||||
minHeight: 400,
|
||||
extraButtons: [
|
||||
{
|
||||
name: 'info',
|
||||
iconURL: '<?= base_url()."public"; ?>/assets/images/image-solid.svg', // Replace with the actual icon URL
|
||||
exec: function (editor) {
|
||||
const fileInput = document.getElementById("Question_title_fileInput");
|
||||
fileInput.click();
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const editor = Jodit.make("#ticket_mail_editor", editorConfig);
|
||||
var mail_content = '<?=isset($reply_data['mail_content'])?$reply_data['mail_content']:'' ?>';
|
||||
$('.jodit-wysiwyg').html(mail_content);
|
||||
|
||||
let lastActiveField = null;
|
||||
|
||||
// Track last active input field
|
||||
$("#mail_subject").on("focus", function() {
|
||||
lastActiveField = this;
|
||||
});
|
||||
|
||||
// Track Jodit editor focus separately
|
||||
editor.events.on("focus", function() {
|
||||
lastActiveField = editor;
|
||||
});
|
||||
|
||||
document.addEventListener('change', function(event) {
|
||||
var target = event.target;
|
||||
if (target.matches('#ticket_mail_customButton')) {
|
||||
let placeholderValue = $(target).val();
|
||||
if (!placeholderValue) return;
|
||||
|
||||
if (lastActiveField) {
|
||||
if (lastActiveField.id === "mail_subject") {
|
||||
insertAtCursor(lastActiveField, placeholderValue);
|
||||
} else {
|
||||
editor.selection.insertHTML(placeholderValue);
|
||||
}
|
||||
}
|
||||
|
||||
$(target).val('');
|
||||
}
|
||||
});
|
||||
|
||||
function insertAtCursor(input, textToInsert) {
|
||||
if (document.selection) {
|
||||
input.focus();
|
||||
var sel = document.selection.createRange();
|
||||
sel.text = textToInsert;
|
||||
} else if (input.selectionStart || input.selectionStart === 0) {
|
||||
let startPos = input.selectionStart;
|
||||
let endPos = input.selectionEnd;
|
||||
input.value = input.value.substring(0, startPos) + textToInsert + input.value.substring(endPos, input.value.length);
|
||||
input.selectionStart = input.selectionEnd = startPos + textToInsert.length;
|
||||
} else {
|
||||
input.value += textToInsert;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$("#ticket_reply_form").submit(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// Show loaders
|
||||
$('.loader, .loader-mask').fadeIn();
|
||||
|
||||
var url = '<?= base_url("/ticket/reply"); ?>';
|
||||
var formData = new FormData(this);
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'POST', formData, function(response) {
|
||||
$('.loader, .loader-mask').fadeOut();
|
||||
|
||||
if (response.status) {
|
||||
toastr.success('Mail sent successfully.', 'Success');
|
||||
} else {
|
||||
toastr.error(response.message || 'Failed to send mail.', 'Error');
|
||||
var joditEditor = editor;
|
||||
if (joditEditor)
|
||||
{
|
||||
var mailContent = $(joditEditor.currentPlace.container).find('.jodit-wysiwyg').html();
|
||||
var formData = $(this).serializeArray();
|
||||
formData.push({ name: 'mail_content', value: mailContent });
|
||||
// formData.push({ name: 'client_id', value: $('#general_PrimaryKey').val() });
|
||||
// var isAutoMailEnabled = $('#statusSwitch').is(':checked') ? 1 : 0;
|
||||
// formData.push({ name: 'is_auto_mail', value: isAutoMailEnabled });
|
||||
var ticket_id = $('#ticket_master_id').val();
|
||||
if (ticket_id != null && ticket_id != ''){
|
||||
formData.push({ name: 'ticket_id', value: ticket_id});
|
||||
}
|
||||
// console.log(formData);
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
var form_action = '<?= base_url("/ticket/reply"); ?>';
|
||||
$.ajax({
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
success: function(res)
|
||||
{
|
||||
if(res.status == true){
|
||||
// $('#new_mail_template').find('.close').click();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
toastr.success('Message Sent successfully!', 'Success');
|
||||
reloadTicket_conversation();
|
||||
}else if (res.status == false){
|
||||
toastr.error('Failed to Send Message', 'error');
|
||||
}
|
||||
|
||||
},
|
||||
error: function (xhr, status, error)
|
||||
{
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
setTimeout(function()
|
||||
{
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
toastr.error('Something Wrong!', 'warning');
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
console.error("Jodit editor instance is not defined.");
|
||||
}
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error:', error);
|
||||
console.error('Response:', xhr.responseText);
|
||||
|
||||
$('.loader, .loader-mask').fadeOut();
|
||||
toastr.error('An error occurred while processing the request.', 'Error');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
function reloadTicket_conversation() {
|
||||
$("#ticket_messages_div").load(location.href + " #ticket_messages_div");
|
||||
}
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user