Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
300eaf806d
@ -609,6 +609,17 @@ class TicketController extends BaseController
|
|||||||
$data['policy_type'] = $this->ticketType;
|
$data['policy_type'] = $this->ticketType;
|
||||||
$data['placeHolders'] = $this->placeHolders;
|
$data['placeHolders'] = $this->placeHolders;
|
||||||
$data['ticket_data'] = $this->ticketMailTemplateModel->where('is_active', 1)->findAll();
|
$data['ticket_data'] = $this->ticketMailTemplateModel->where('is_active', 1)->findAll();
|
||||||
|
|
||||||
|
foreach ($data['ticket_data'] as $key => $ticket_data) {
|
||||||
|
|
||||||
|
$tooltip_array = $this->claimStatus->select('claim_status')->where('ticket_type',$data['ticket_data'][$key]['ticket_type'])->where('trigger_type',$data['ticket_data'][$key]['trigger_type'])->where('is_active',1)->first();
|
||||||
|
if (isset($tooltip_array) && $tooltip_array != null){
|
||||||
|
$data['ticket_data'][$key]['tool_tip'] = $tooltip_array['claim_status'];
|
||||||
|
}else{
|
||||||
|
$data['ticket_data'][$key]['tool_tip'] =$data['ticket_data'][$key]['template_name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// dd($data['ticket_data']);
|
||||||
$data['ticket_type'] = $this->ticketType;
|
$data['ticket_type'] = $this->ticketType;
|
||||||
$data['trigger_type'] = $this->triggerType;
|
$data['trigger_type'] = $this->triggerType;
|
||||||
return $this->loadLayout('ticket_mail_template', $data);
|
return $this->loadLayout('ticket_mail_template', $data);
|
||||||
@ -637,6 +648,21 @@ class TicketController extends BaseController
|
|||||||
} elseif ($action == 2) {
|
} elseif ($action == 2) {
|
||||||
$table_id = (int)$this->request->getPost('id');
|
$table_id = (int)$this->request->getPost('id');
|
||||||
$data = $this->ticketMailTemplateModel->where('id', $table_id)->where('is_active', 1)->first();
|
$data = $this->ticketMailTemplateModel->where('id', $table_id)->where('is_active', 1)->first();
|
||||||
|
if ($data && isset($data['ticket_type']) && isset($data['trigger_type'])) {
|
||||||
|
$tooltip_array = $this->claimStatus->select('claim_status')
|
||||||
|
->where('ticket_type', $data['ticket_type'])
|
||||||
|
->where('trigger_type', $data['trigger_type'])
|
||||||
|
->where('is_active', 1)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$data['tool_tip'] = (isset($tooltip_array['claim_status']))
|
||||||
|
? $tooltip_array['claim_status']
|
||||||
|
: $data['template_name'];
|
||||||
|
} else {
|
||||||
|
// Handle case where $data is null or missing required fields
|
||||||
|
$data = $data ?: []; // Ensure $data is an array if null
|
||||||
|
$data['tool_tip'] = $data['template_name'];
|
||||||
|
}
|
||||||
if ($data) {
|
if ($data) {
|
||||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,56 +1,56 @@
|
|||||||
<style>
|
<style>
|
||||||
.table th,
|
.table th,
|
||||||
.table td {
|
.table td {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.dataTable tbody td {
|
table.dataTable tbody td {
|
||||||
padding: 4px 4px !important;
|
padding: 4px 4px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.col-12 {
|
.col-12 {
|
||||||
|
|
||||||
max-width: 98% !important;
|
max-width: 98% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataTables_filter {
|
.dataTables_filter {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-align-input {
|
.right-align-input {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.addbtnStyle {
|
.addbtnStyle {
|
||||||
margin-left: 20px !important;
|
margin-left: 20px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-dropdown-menu {
|
.custom-dropdown-menu {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: #ffffff !important;
|
background-color: #ffffff !important;
|
||||||
border: 1px solid rgba(0, 0, 0, 0.15);
|
border: 1px solid rgba(0, 0, 0, 0.15);
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
padding: 0.5rem 0;
|
padding: 0.5rem 0;
|
||||||
min-width: 10rem;
|
min-width: 10rem;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-dropdown-menu .dropdown-item {
|
.custom-dropdown-menu .dropdown-item {
|
||||||
display: block !important;
|
display: block !important;
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
padding: 0.5rem 1rem !important;
|
padding: 0.5rem 1rem !important;
|
||||||
color: #212529 !important;
|
color: #212529 !important;
|
||||||
text-decoration: none !important;
|
text-decoration: none !important;
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-dropdown-menu .dropdown-item:hover {
|
.custom-dropdown-menu .dropdown-item:hover {
|
||||||
background-color: #f8f9fa !important;
|
background-color: #f8f9fa !important;
|
||||||
color: #16181b !important;
|
color: #16181b !important;
|
||||||
cursor: pointer !important;
|
cursor: pointer !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@ -75,28 +75,37 @@ table.dataTable tbody td {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php if (isset($ticket_data)) { ?>
|
<?php if (isset($ticket_data)) { ?>
|
||||||
<?php foreach($ticket_data as $index => $row){ ?>
|
<?php foreach ($ticket_data as $index => $row) { ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $row['template_name'] ?? ""; ?></td>
|
<td> <?php echo $row['template_name'] ?? ""; ?>
|
||||||
<td><?php echo $ticket_type[$row['ticket_type']] ?? ""; ?></td>
|
<i class="fe-alert-circle"
|
||||||
<td><?php echo $trigger_type[$row['trigger_type']] ?? ""; ?></td>
|
style="color: #000;"
|
||||||
<td><?=$row['is_auto_mail'] == 1?'Auto':"Manual" ?></td>
|
aria-hidden="true"
|
||||||
<td>
|
data-toggle="tooltip"
|
||||||
<div class="btn-group dropdown">
|
data-placement="top"
|
||||||
<a href="javascript: void(0);"
|
title="<?php echo ($row['tool_tip'] ?? ''); ?>"></i>
|
||||||
class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"
|
|
||||||
aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
</td>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
|
||||||
<a class="dropdown-item" href="#"
|
<td><?php echo $ticket_type[$row['ticket_type']] ?? ""; ?></td>
|
||||||
onclick="getMailTemplateData(<?=$row['id']?>)"><i
|
<td><?php echo $trigger_type[$row['trigger_type']] ?? ""; ?></td>
|
||||||
class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
<td><?= $row['is_auto_mail'] == 1 ? 'Auto' : "Manual" ?></td>
|
||||||
<a class="dropdown-item" onclick="deleteTemplate(<?=$row['id']?>)"><i
|
<td>
|
||||||
class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
<div class="btn-group dropdown">
|
||||||
</div>
|
<a href="javascript: void(0);"
|
||||||
</div>
|
class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"
|
||||||
</td>
|
aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||||
</tr>
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
<?php } ?>
|
<a class="dropdown-item" href="#"
|
||||||
|
onclick="getMailTemplateData(<?= $row['id'] ?>)"><i
|
||||||
|
class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||||
|
<a class="dropdown-item" onclick="deleteTemplate(<?= $row['id'] ?>)"><i
|
||||||
|
class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@ -135,11 +144,11 @@ table.dataTable tbody td {
|
|||||||
<select class="form-control" id="policy_type" name="ticket_type" required>
|
<select class="form-control" id="policy_type" name="ticket_type" required>
|
||||||
<option value="">Select Policy Type</option>
|
<option value="">Select Policy Type</option>
|
||||||
<?php
|
<?php
|
||||||
if (isset($policy_type) && count($policy_type)) {
|
if (isset($policy_type) && count($policy_type)) {
|
||||||
foreach ($policy_type as $key => $value) {
|
foreach ($policy_type as $key => $value) {
|
||||||
echo "<option value=" . $key . ">" . $value . "</option>";
|
echo "<option value=" . $key . ">" . $value . "</option>";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -149,11 +158,11 @@ table.dataTable tbody td {
|
|||||||
<select class="form-control" id="trigger_type" name="trigger_type" required>
|
<select class="form-control" id="trigger_type" name="trigger_type" required>
|
||||||
<option value="">Select status</option>
|
<option value="">Select status</option>
|
||||||
<?php
|
<?php
|
||||||
if (isset($trigger_type) && count($trigger_type)) {
|
if (isset($trigger_type) && count($trigger_type)) {
|
||||||
foreach ($trigger_type as $key => $value) {
|
foreach ($trigger_type as $key => $value) {
|
||||||
echo "<option value=" . $key . ">" . $value . "</option>";
|
echo "<option value=" . $key . ">" . $value . "</option>";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</select> <input id="primaryKey" type="hidden">
|
</select> <input id="primaryKey" type="hidden">
|
||||||
</div>
|
</div>
|
||||||
@ -171,6 +180,12 @@ table.dataTable tbody td {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="claim_status_for_template">Claim Status</label>
|
||||||
|
<input type="text" readonly id="claim_status_for_template" class="form-control" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@ -191,12 +206,15 @@ table.dataTable tbody td {
|
|||||||
<select id="ticket_mail_customButton" class="form-control"
|
<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;">
|
style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;">
|
||||||
<option value="">PlaceHolders</option>
|
<option value="">PlaceHolders</option>
|
||||||
<?php foreach ($placeHolders as $key => $value): ?>
|
<?php foreach ($placeHolders as $key => $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'){
|
||||||
<?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?>
|
?>member_mobile
|
||||||
<option value="<?php echo $key; ?>"><?php echo $valueChange; ?></option>
|
<?php $valueChange = str_replace('_', ' ', $value);
|
||||||
</option>
|
$valueChange = ucwords($valueChange); ?>
|
||||||
<?php //} ?>
|
<option value="<?php echo $key; ?>"><?php echo $valueChange; ?></option>
|
||||||
|
</option>
|
||||||
|
<?php //}
|
||||||
|
?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -216,392 +234,397 @@ table.dataTable tbody td {
|
|||||||
</div><!-- /.modal -->
|
</div><!-- /.modal -->
|
||||||
|
|
||||||
<!-------------------------------------------------------------------------------------------------->
|
<!-------------------------------------------------------------------------------------------------->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Datatable document ready
|
$(document).ready(function() {
|
||||||
$(document).ready(function() {
|
$('[data-toggle="tooltip"]').tooltip();
|
||||||
|
|
||||||
var ticketsTable = $('#scroll-horizontal-datatable');
|
|
||||||
|
|
||||||
if (ticketsTable.length) {
|
|
||||||
|
|
||||||
ticketsTable.DataTable({
|
|
||||||
scrollX: true,
|
|
||||||
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
|
|
||||||
"<'row'<'col-sm-12'tr>>" +
|
|
||||||
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
|
||||||
buttons: [{
|
|
||||||
text: 'Add Template',
|
|
||||||
className: 'buttons-html5 addbtnStyle',
|
|
||||||
action: function(e, dt, node, config) {
|
|
||||||
openModal()
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
language: {
|
|
||||||
search: "_INPUT_",
|
|
||||||
searchPlaceholder: "Search..."
|
|
||||||
},
|
|
||||||
paging: true, // Enable pagination
|
|
||||||
pageLength: 25, // Set default number of rows per page (optional)
|
|
||||||
ordering: false,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.error("Table atet found.");
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
|
|
||||||
let lastActiveField = null;
|
|
||||||
|
|
||||||
// Track last active input field
|
|
||||||
$("#template_subject").on("focus", function() {
|
|
||||||
lastActiveField = this;
|
|
||||||
});
|
});
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
// Datatable document ready
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
// Track Jodit editor focus separately
|
var ticketsTable = $('#scroll-horizontal-datatable');
|
||||||
editor.events.on("focus", function() {
|
|
||||||
lastActiveField = editor;
|
|
||||||
});
|
|
||||||
|
|
||||||
document.addEventListener('change', function(event) {
|
if (ticketsTable.length) {
|
||||||
var target = event.target;
|
|
||||||
if (target.matches('#ticket_mail_customButton')) {
|
|
||||||
let placeholderValue = $(target).val();
|
|
||||||
if (!placeholderValue) return;
|
|
||||||
|
|
||||||
if (lastActiveField) {
|
ticketsTable.DataTable({
|
||||||
if (lastActiveField.id === "template_subject") {
|
scrollX: true,
|
||||||
insertAtCursor(lastActiveField, placeholderValue);
|
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
|
||||||
} else {
|
"<'row'<'col-sm-12'tr>>" +
|
||||||
editor.selection.insertHTML(placeholderValue);
|
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||||
}
|
buttons: [{
|
||||||
}
|
text: 'Add Template',
|
||||||
|
className: 'buttons-html5 addbtnStyle',
|
||||||
$(target).val('');
|
action: function(e, dt, node, config) {
|
||||||
}
|
openModal()
|
||||||
});
|
}
|
||||||
|
}],
|
||||||
function insertAtCursor(input, textToInsert) {
|
language: {
|
||||||
if (document.selection) {
|
search: "_INPUT_",
|
||||||
input.focus();
|
searchPlaceholder: "Search..."
|
||||||
var sel = document.selection.createRange();
|
},
|
||||||
sel.text = textToInsert;
|
paging: true, // Enable pagination
|
||||||
} else if (input.selectionStart || input.selectionStart === 0) {
|
pageLength: 25, // Set default number of rows per page (optional)
|
||||||
let startPos = input.selectionStart;
|
ordering: false,
|
||||||
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 {
|
} else {
|
||||||
input.value += textToInsert;
|
console.error("Table atet found.");
|
||||||
}
|
}
|
||||||
}
|
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);
|
||||||
|
|
||||||
$('.close').click(function() {
|
let lastActiveField = null;
|
||||||
$('#template_subject').val('');
|
|
||||||
$('#template_name').val('');
|
|
||||||
$('#primaryKey').val('');
|
|
||||||
$('#policy_type').val('').change();
|
|
||||||
$('#trigger_type').val('').change();
|
|
||||||
editor.setEditorValue('');
|
|
||||||
$('#primaryKey').val(null);
|
|
||||||
$('#statusSwitch').prop('checked', false);
|
|
||||||
|
|
||||||
})
|
// Track last active input field
|
||||||
$('#ticket_mail_editor_modal').submit(function(event) {
|
$("#template_subject").on("focus", function() {
|
||||||
|
lastActiveField = this;
|
||||||
|
});
|
||||||
|
|
||||||
event.preventDefault();
|
// Track Jodit editor focus separately
|
||||||
let isValid = true;
|
editor.events.on("focus", function() {
|
||||||
$('#ticket_mail_editor_modal [required]').each(function() {
|
lastActiveField = editor;
|
||||||
if (!this.value.trim()) {
|
});
|
||||||
isValid = false;
|
|
||||||
$(this).addClass('is-invalid'); // Add a red border for visibility
|
document.addEventListener('change', function(event) {
|
||||||
} else {
|
var target = event.target;
|
||||||
$(this).removeClass('is-invalid');
|
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('');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!isValid) {
|
function insertAtCursor(input, textToInsert) {
|
||||||
toastr.error('Please fill all required fields.', 'Validation Error');
|
if (document.selection) {
|
||||||
return; // Prevent submission
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var joditEditor = editor;
|
|
||||||
if (joditEditor) {
|
|
||||||
var mailContent = $(joditEditor.currentPlace.container).find('.jodit-wysiwyg').html();
|
$('.close').click(function() {
|
||||||
var formData = $(this).serializeArray();
|
$('#template_subject').val('');
|
||||||
formData.push({
|
$('#template_name').val('');
|
||||||
name: 'mail_content',
|
$('#primaryKey').val('');
|
||||||
value: mailContent
|
$('#policy_type').val('').change();
|
||||||
|
$('#trigger_type').val('').change();
|
||||||
|
editor.setEditorValue('');
|
||||||
|
$('#primaryKey').val(null);
|
||||||
|
$('#statusSwitch').prop('checked', false);
|
||||||
|
|
||||||
|
})
|
||||||
|
$('#ticket_mail_editor_modal').submit(function(event) {
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
let isValid = true;
|
||||||
|
$('#ticket_mail_editor_modal [required]').each(function() {
|
||||||
|
if (!this.value.trim()) {
|
||||||
|
isValid = false;
|
||||||
|
$(this).addClass('is-invalid'); // Add a red border for visibility
|
||||||
|
} else {
|
||||||
|
$(this).removeClass('is-invalid');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// formData.push({ name: 'client_id', value: $('#general_PrimaryKey').val() });
|
|
||||||
var isAutoMailEnabled = $('#statusSwitch').is(':checked') ? 1 : 0;
|
if (!isValid) {
|
||||||
formData.push({
|
toastr.error('Please fill all required fields.', 'Validation Error');
|
||||||
name: 'is_auto_mail',
|
return; // Prevent submission
|
||||||
value: isAutoMailEnabled
|
}
|
||||||
});
|
var joditEditor = editor;
|
||||||
var primary_key = $('#primaryKey').val();
|
if (joditEditor) {
|
||||||
if (primary_key != null && primary_key != '') {
|
var mailContent = $(joditEditor.currentPlace.container).find('.jodit-wysiwyg').html();
|
||||||
|
var formData = $(this).serializeArray();
|
||||||
formData.push({
|
formData.push({
|
||||||
name: 'id',
|
name: 'mail_content',
|
||||||
value: primary_key
|
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 primary_key = $('#primaryKey').val();
|
||||||
|
if (primary_key != null && primary_key != '') {
|
||||||
|
formData.push({
|
||||||
|
name: 'id',
|
||||||
|
value: primary_key
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
var form_action = '<?= base_url("ticket/crud_mail_template/1") ?>';
|
||||||
|
$.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('Template saved successfully!', 'Success');
|
||||||
|
location.reload();
|
||||||
|
} else if (res.status == false) {
|
||||||
|
toastr.error('Failed to Save Data', '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 openModal() {
|
||||||
|
var myModal = new bootstrap.Modal(document.getElementById('new_mail_template'));
|
||||||
|
myModal.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteTemplate(id) {
|
||||||
|
const url = '<?= base_url("ticket/crud_mail_template/3") ?>';
|
||||||
|
const data = {
|
||||||
|
id: id
|
||||||
|
}; // Ensure data is passed as an object
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: "Are you sure?",
|
||||||
|
text: "You need to remove this template.",
|
||||||
|
icon: "info",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: "#3085d6",
|
||||||
|
confirmButtonText: "Yes",
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: "POST",
|
||||||
|
data: data,
|
||||||
|
success: function(res) {
|
||||||
|
if (res.status === true) {
|
||||||
|
location.reload();
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
toastr.success('Template Deleted successfully!', 'Success');
|
||||||
|
} else if (res.status === false) {
|
||||||
|
toastr.error('Failed to Delete Template', 'Error');
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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 went wrong!', 'Warning');
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$('.loader').fadeIn();
|
});
|
||||||
$('.loader-mask').fadeIn();
|
|
||||||
var form_action = '<?= base_url("ticket/crud_mail_template/1") ?>';
|
|
||||||
$.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('Template saved successfully!', 'Success');
|
|
||||||
location.reload();
|
|
||||||
} else if (res.status == false) {
|
|
||||||
toastr.error('Failed to Save Data', '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 openModal() {
|
|
||||||
var myModal = new bootstrap.Modal(document.getElementById('new_mail_template'));
|
|
||||||
myModal.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteTemplate(id) {
|
|
||||||
const url = '<?= base_url("ticket/crud_mail_template/3") ?>';
|
|
||||||
const data = {
|
|
||||||
id: id
|
|
||||||
}; // Ensure data is passed as an object
|
|
||||||
|
|
||||||
Swal.fire({
|
|
||||||
title: "Are you sure?",
|
|
||||||
text: "You need to remove this template.",
|
|
||||||
icon: "info",
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonColor: "#3085d6",
|
|
||||||
confirmButtonText: "Yes",
|
|
||||||
}).then((result) => {
|
|
||||||
if (result.isConfirmed) {
|
|
||||||
$('.loader').fadeIn();
|
|
||||||
$('.loader-mask').fadeIn();
|
|
||||||
$.ajax({
|
|
||||||
url: url,
|
|
||||||
type: "POST",
|
|
||||||
data: data,
|
|
||||||
success: function(res) {
|
|
||||||
if (res.status === true) {
|
|
||||||
location.reload();
|
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
|
||||||
toastr.success('Template Deleted successfully!', 'Success');
|
|
||||||
} else if (res.status === false) {
|
|
||||||
toastr.error('Failed to Delete Template', 'Error');
|
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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 went wrong!', 'Warning');
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMailTemplateData(id) {
|
|
||||||
const template_name = 'new_mail_template';
|
|
||||||
$('.loader').fadeIn();
|
|
||||||
$('.loader-mask').fadeIn();
|
|
||||||
|
|
||||||
var form_action = '<?= base_url("ticket/crud_mail_template/2") ?>';
|
|
||||||
var data = {
|
|
||||||
id: id
|
|
||||||
};
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: form_action,
|
|
||||||
type: "POST",
|
|
||||||
data: data,
|
|
||||||
success: function(res) {
|
|
||||||
console.log('get Mail Template Data', res);
|
|
||||||
if (res) {
|
|
||||||
if (res.status == true) {
|
|
||||||
// Open the modal
|
|
||||||
openModal();
|
|
||||||
|
|
||||||
// Populate the form fields
|
|
||||||
$('#template_subject').val(res.data.subject);
|
|
||||||
$('#template_name').val(res.data.template_name);
|
|
||||||
$('#primaryKey').val(res.data.id);
|
|
||||||
$('#policy_type').val(res.data.ticket_type).change();
|
|
||||||
$('#trigger_type').val(res.data.trigger_type).change();
|
|
||||||
$('.jodit-wysiwyg').html(res.data.mail_content);
|
|
||||||
|
|
||||||
// Set the auto mail switch
|
|
||||||
if (res.data.is_auto_mail == 1) {
|
|
||||||
$('#statusSwitch').prop('checked', true);
|
|
||||||
} else {
|
|
||||||
$('#statusSwitch').prop('checked', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Populate any additional fields if necessary, like placeholders
|
|
||||||
// Assuming `placeholders` is an array in the response
|
|
||||||
if (res.placeholders) {
|
|
||||||
res.placeholders.forEach(function(placeholder) {
|
|
||||||
// You can populate any dropdown or field as required
|
|
||||||
$('#ticket_mail_customButton').val(placeholder);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
toastr.error('Data Not Found', 'error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$('.loader').fadeOut();
|
|
||||||
$('.loader-mask').delay(350).fadeOut('slow');
|
|
||||||
},
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
|
||||||
const table = document.getElementById("scroll-horizontal-datatable");
|
|
||||||
|
|
||||||
// Create custom dropdown
|
|
||||||
function createCustomDropdown(row) {
|
|
||||||
// Get the original dropdown items
|
|
||||||
const originalDropdown = row.querySelector('.dropdown-menu');
|
|
||||||
if (!originalDropdown) return null;
|
|
||||||
|
|
||||||
// Create new dropdown with proper background and spacing
|
|
||||||
const customDropdown = document.createElement('div');
|
|
||||||
customDropdown.className = 'custom-dropdown-menu';
|
|
||||||
|
|
||||||
// Copy inner content while maintaining icon alignment
|
|
||||||
customDropdown.innerHTML = originalDropdown.innerHTML;
|
|
||||||
|
|
||||||
return customDropdown;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let activeDropdown = null;
|
function getMailTemplateData(id) {
|
||||||
|
const template_name = 'new_mail_template';
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
|
|
||||||
// Add click event listener to rows
|
var form_action = '<?= base_url("ticket/crud_mail_template/2") ?>';
|
||||||
table.querySelectorAll("tbody tr").forEach(row => {
|
var data = {
|
||||||
const customDropdown = createCustomDropdown(row);
|
id: id
|
||||||
if (!customDropdown) return;
|
};
|
||||||
|
|
||||||
document.body.appendChild(customDropdown);
|
$.ajax({
|
||||||
|
url: form_action,
|
||||||
|
type: "POST",
|
||||||
|
data: data,
|
||||||
|
success: function(res) {
|
||||||
|
console.log('get Mail Template Data', res);
|
||||||
|
if (res) {
|
||||||
|
if (res.status == true) {
|
||||||
|
// Open the modal
|
||||||
|
openModal();
|
||||||
|
|
||||||
row.addEventListener("click", function(event) {
|
// Populate the form fields
|
||||||
// Ignore clicks on the action column
|
$('#template_subject').val(res.data.subject);
|
||||||
if (event.target.closest('td:last-child')) {
|
$('#template_name').val(res.data.template_name);
|
||||||
return;
|
$('#primaryKey').val(res.data.id);
|
||||||
|
$('#policy_type').val(res.data.ticket_type).change();
|
||||||
|
$('#trigger_type').val(res.data.trigger_type).change();
|
||||||
|
$('#claim_status_for_template').val(res.data.tool_tip);
|
||||||
|
$('.jodit-wysiwyg').html(res.data.mail_content);
|
||||||
|
|
||||||
|
// Set the auto mail switch
|
||||||
|
if (res.data.is_auto_mail == 1) {
|
||||||
|
$('#statusSwitch').prop('checked', true);
|
||||||
|
} else {
|
||||||
|
$('#statusSwitch').prop('checked', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate any additional fields if necessary, like placeholders
|
||||||
|
// Assuming `placeholders` is an array in the response
|
||||||
|
if (res.placeholders) {
|
||||||
|
res.placeholders.forEach(function(placeholder) {
|
||||||
|
// You can populate any dropdown or field as required
|
||||||
|
$('#ticket_mail_customButton').val(placeholder);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
toastr.error('Data Not Found', 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
|
},
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hide any active dropdown
|
|
||||||
if (activeDropdown) {
|
|
||||||
activeDropdown.style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get click position
|
|
||||||
const rect = event.target.getBoundingClientRect();
|
|
||||||
|
|
||||||
// Position the dropdown with some offset
|
|
||||||
customDropdown.style.display = 'block';
|
|
||||||
customDropdown.style.position = 'fixed';
|
|
||||||
customDropdown.style.left = `${rect.left}px`;
|
|
||||||
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
|
|
||||||
|
|
||||||
// Set as active dropdown
|
|
||||||
activeDropdown = customDropdown;
|
|
||||||
|
|
||||||
event.stopPropagation();
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
const table = document.getElementById("scroll-horizontal-datatable");
|
||||||
|
|
||||||
// Preserve click handlers and add auto-close
|
// Create custom dropdown
|
||||||
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
function createCustomDropdown(row) {
|
||||||
item.addEventListener('click', function(e) {
|
// Get the original dropdown items
|
||||||
const onclickAttr = this.getAttribute('onclick');
|
const originalDropdown = row.querySelector('.dropdown-menu');
|
||||||
if (onclickAttr) {
|
if (!originalDropdown) return null;
|
||||||
eval(onclickAttr);
|
|
||||||
|
// Create new dropdown with proper background and spacing
|
||||||
|
const customDropdown = document.createElement('div');
|
||||||
|
customDropdown.className = 'custom-dropdown-menu';
|
||||||
|
|
||||||
|
// Copy inner content while maintaining icon alignment
|
||||||
|
customDropdown.innerHTML = originalDropdown.innerHTML;
|
||||||
|
|
||||||
|
return customDropdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
let activeDropdown = null;
|
||||||
|
|
||||||
|
// Add click event listener to rows
|
||||||
|
table.querySelectorAll("tbody tr").forEach(row => {
|
||||||
|
const customDropdown = createCustomDropdown(row);
|
||||||
|
if (!customDropdown) return;
|
||||||
|
|
||||||
|
document.body.appendChild(customDropdown);
|
||||||
|
|
||||||
|
row.addEventListener("click", function(event) {
|
||||||
|
// Ignore clicks on the action column
|
||||||
|
if (event.target.closest('td:last-child')) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const href = this.getAttribute('href');
|
// Hide any active dropdown
|
||||||
if (href && href !== '#') {
|
|
||||||
window.location.href = href;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the dropdown after handling the click
|
|
||||||
if (activeDropdown) {
|
if (activeDropdown) {
|
||||||
activeDropdown.style.display = 'none';
|
activeDropdown.style.display = 'none';
|
||||||
activeDropdown = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e.stopPropagation();
|
// Get click position
|
||||||
|
const rect = event.target.getBoundingClientRect();
|
||||||
|
|
||||||
|
// Position the dropdown with some offset
|
||||||
|
customDropdown.style.display = 'block';
|
||||||
|
customDropdown.style.position = 'fixed';
|
||||||
|
customDropdown.style.left = `${rect.left}px`;
|
||||||
|
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
|
||||||
|
|
||||||
|
// Set as active dropdown
|
||||||
|
activeDropdown = customDropdown;
|
||||||
|
|
||||||
|
event.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Preserve click handlers and add auto-close
|
||||||
|
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
|
||||||
|
item.addEventListener('click', function(e) {
|
||||||
|
const onclickAttr = this.getAttribute('onclick');
|
||||||
|
if (onclickAttr) {
|
||||||
|
eval(onclickAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
const href = this.getAttribute('href');
|
||||||
|
if (href && href !== '#') {
|
||||||
|
window.location.href = href;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the dropdown after handling the click
|
||||||
|
if (activeDropdown) {
|
||||||
|
activeDropdown.style.display = 'none';
|
||||||
|
activeDropdown = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Close dropdown when clicking outside
|
// Close dropdown when clicking outside
|
||||||
document.addEventListener("click", function() {
|
document.addEventListener("click", function() {
|
||||||
if (activeDropdown) {
|
if (activeDropdown) {
|
||||||
activeDropdown.style.display = 'none';
|
activeDropdown.style.display = 'none';
|
||||||
activeDropdown = null;
|
activeDropdown = null;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user