698 lines
27 KiB
PHP
Executable File
698 lines
27 KiB
PHP
Executable File
<style>
|
||
.table-responsive {
|
||
overflow-x: auto;
|
||
}
|
||
|
||
.truncate {
|
||
max-width: 80px;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
}
|
||
|
||
.select2-hidden-accessible + .select2-container .select2-dropdown {
|
||
display: none !important;
|
||
}
|
||
|
||
.select2-container .select2-selection--multiple .select2-selection__choice {
|
||
color: #000000;
|
||
}
|
||
</style>
|
||
|
||
<style>
|
||
#dynamic-form-container {
|
||
overflow-y: auto;
|
||
overflow-x: hidden;
|
||
max-height: 300px;
|
||
}
|
||
|
||
/* Custom scrollbar styles */
|
||
#dynamic-form-container::-webkit-scrollbar {
|
||
width: 8px; /* Set the width of the scrollbar */
|
||
}
|
||
|
||
#dynamic-form-container::-webkit-scrollbar-thumb {
|
||
background-color: #888; /* Color of the scrollbar thumb */
|
||
border-radius: 4px; /* Rounded corners of the scrollbar thumb */
|
||
}
|
||
|
||
#dynamic-form-container::-webkit-scrollbar-thumb:hover {
|
||
background-color: #555; /* Color of the scrollbar thumb on hover */
|
||
}
|
||
|
||
#dynamic-form-container::-webkit-scrollbar-track {
|
||
background-color: #f1f1f1; /* Background color of the scrollbar track */
|
||
}
|
||
</style>
|
||
|
||
<div class="tab-pane fade" id="template-tab">
|
||
|
||
<input type="hidden" id="insurer_templete_count" value="<?= isset($insurer_templete_count) ? $insurer_templete_count : ''?>">
|
||
<input type="hidden" id="insurer_id" value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>">
|
||
|
||
<div class="row">
|
||
<div class="form-group col-md-4">
|
||
<label for="email">Existing Insurer Export<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="insurer" name="insurer" required>
|
||
<option value="">Select Insurer</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-6" style="position: relative;top: 28px;">
|
||
<label for="email"><span class="text-danger"></span></label>
|
||
<a href="#" class="btn btn-primary waves-effect waves-light" onclick="checkInsurerTemplete(this)">Copy</a>
|
||
</div>
|
||
|
||
<div class="form-group col-md-2" style="position: relative;top: 28px;left: 80px;">
|
||
<label for="email"><span class="text-danger"></span></label>
|
||
<a href="#" class="btn btn-primary waves-effect waves-light" onclick="addNewJsonExportTemplate(this)">Add New</a>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<hr>
|
||
|
||
<div class="table-responsive" id="branch_table" >
|
||
|
||
<table class="table table-borderless table-nowrap mb-0">
|
||
<thead class="thead-light">
|
||
<tr>
|
||
<th>S.NO</th>
|
||
<th>Policy Type</th>
|
||
<th>Event Type</th>
|
||
<th>Import/Export</th>
|
||
<th>Template</th>
|
||
<th>Action</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php if(isset($insurer_templete_list)){ ?>
|
||
<?php foreach($insurer_templete_list as $key => $value ){ ?>
|
||
<tr>
|
||
<td><?= $key+1; ?></td>
|
||
<td><?= $value['policy_type']; ?></td>
|
||
<td><?= $events[$value['event_name']]; ?></td>
|
||
<td><?= $value['type_name']; ?></td>
|
||
<td style="overflow: hidden;" class="truncate" ><?= $value['jsoncolumns']; ?></td>
|
||
<td>
|
||
<div class="btn-group dropdown">
|
||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||
<div class="dropdown-menu dropdown-menu-right">
|
||
<a class="dropdown-item" href="#" onclick="editJSONExportTemplate(this, '<?= $value['id']; ?>')"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||
<a class="dropdown-item" id="template_id_for_duplicate" data-id="<?= $value['id']; ?>" data-toggle="modal" data-target="#centermodal"><i class="mdi mdi-content-duplicate mr-2 text-muted font-18 vertical-middle"></i>Duplicate</a>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Center modal content -->
|
||
<div class="modal fade" id="template_modal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
|
||
aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right: 15px">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myCenterModalLabel">Create Template</h4>
|
||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="parsley-examples" method="post" id="templateForm" enctype="multipart/form-data">
|
||
<input type="hidden" name="insurer_id" value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>">
|
||
<input type="hidden" name="template_id" id="template_id">
|
||
<div class="form-group">
|
||
<div class="form-row">
|
||
<div class="form-group col-md-5">
|
||
<label for="policy_type">Policy Type<span class="text-danger">*</span></label>
|
||
<select name="policy_type" class="form-control" id="policy_type" required>
|
||
<option value="">Select</option>
|
||
<?php if (!empty($policy_type)){ ?>
|
||
<?php foreach ($policy_type as $key => $value) { ?>
|
||
<option value="<?= $value['id'] ?>"><?= $value['policy_type']?></option>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="form-group col-md-5">
|
||
<label for="event_name">Event<span class="text-danger">*</span></label>
|
||
<select name="event" class="form-control" id="event" required>
|
||
<option value="">Select</option>
|
||
<?php if (!empty($events)){ ?>
|
||
<?php foreach ($events as $key => $event) { ?>
|
||
<option value="<?= $key ?>"><?= $event?></option>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
<!-- <div class="form-group col-md-4">
|
||
<label for="action">Action<span class="text-danger">*</span></label>
|
||
<select name="import_or_export" class="form-control" id="import_or_export" required>
|
||
<option value="">Select</option>
|
||
<?php if (!empty($action)){ ?>
|
||
<?php foreach ($action as $key => $value) { ?>
|
||
<option value="<?= $key ?>"><?= $value?></option>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</select>
|
||
</div> -->
|
||
|
||
</div>
|
||
|
||
<hr>
|
||
|
||
<!-- <div class="form-row dynamic-form-row">
|
||
<div class="form-group col-md-5">
|
||
<label for="excel_column_name">Header Name<span class="text-danger">*</span></label>
|
||
<input class="form-control" type="text" name="excel_column_name[]">
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<label for="db_column_name">DataBase Column Name<span class="text-danger">*</span></label>
|
||
<select class="form-control" name="db_column_name[]" required>
|
||
<option selected>Select DB Column</option>
|
||
<?php if (!empty($db_column_name)){ ?>
|
||
<?php foreach ($db_column_name as $key => $value) { ?>
|
||
<option value="<?= $value ?>"><?= $key ?></option>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
<div class="form-group col-md-2" style="position: relative;top: 28px;">
|
||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(this)">+</a>
|
||
</div>
|
||
</div> -->
|
||
|
||
<div id="dynamic-form-container"></div>
|
||
|
||
</div>
|
||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
<!-- Center modal content -->
|
||
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="myCenterModalLabel">Duplicate Template</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<input type="hidden" id="insurer_id_for_dub_temp" value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>">
|
||
|
||
<div class="form-row">
|
||
|
||
<!-- <div class="form-group col-md-12">
|
||
<label for="event_name">Event<span class="text-danger">*</span></label>
|
||
<select class="form-control" name="event_name_for_duplicate" id="event_name_for_duplicate">
|
||
<option value="">Select</option>
|
||
<option value="inception">Inception</option>
|
||
<option value="addition">Addition</option>
|
||
<option value="dependent_addition">Dependent Addition</option>
|
||
<option value="deletion">Deletion</option>
|
||
<option value="correction">Correction</option>
|
||
<option value="si_enhancement">SI Enhancement</option>
|
||
<option value="si_enhancement">All</option>
|
||
</select>
|
||
</div> -->
|
||
|
||
<div class="form-group col-md-12">
|
||
<label for="event_name">Event<span class="text-danger">*</span></label>
|
||
<select name="event_name_for_duplicate" class="form-control" id="event_name_for_duplicate" required>
|
||
<option value="">Select</option>
|
||
<?php if (!empty($events)){ ?>
|
||
<?php foreach ($events as $key => $event) { ?>
|
||
<option value="<?= $key ?>"><?= $event?></option>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="dublicateTemplate(this)">Duplicate</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
<script>
|
||
|
||
$(document).ready(function(){
|
||
$('#insurer').select2();
|
||
// $('#event').select2();
|
||
featchInsurerList()
|
||
})
|
||
|
||
$('#templateForm').submit(function(event) {
|
||
|
||
event.preventDefault();
|
||
|
||
var jsonString = createFormArray();; // Convert the array to a JSON string
|
||
console.log(jsonString);
|
||
|
||
var formData = new FormData($('#templateForm')[0]);
|
||
var url = '<?= base_url("util/create_excel_template") ?>';
|
||
|
||
formData.append('json_data', jsonString);
|
||
|
||
$.ajax({
|
||
url: url,
|
||
type: 'POST',
|
||
data: formData,
|
||
processData: false,
|
||
contentType: false,
|
||
headers: {
|
||
"X-Requested-With": "XMLHttpRequest"
|
||
},
|
||
beforeSend: function() {
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
},
|
||
success: function(response) {
|
||
console.log('Export template list:', response);
|
||
|
||
if(response.status == false){
|
||
toastr.error(response.message,'Error');
|
||
}else{
|
||
toastr.success(response.message,'Success');
|
||
}
|
||
|
||
window.location.reload();
|
||
},
|
||
error: function(xhr, status, error) {
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
// Detailed error handling
|
||
console.error("Request failed with status: " + status + ", error: " + error);
|
||
|
||
// Log detailed response information
|
||
console.error('Response status code:', xhr.status);
|
||
console.error('Response status text:', xhr.statusText);
|
||
console.error('Response readyState:', xhr.readyState);
|
||
console.error('Response text:', xhr.responseText);
|
||
|
||
// Optionally log additional details
|
||
console.error('Response headers:', xhr.getAllResponseHeaders());
|
||
console.error('Response URL:', xhr.responseURL);
|
||
|
||
// Example of throwing a detailed error for further handling
|
||
throw new Error(`AJAX Request failed:
|
||
Status: ${status},
|
||
Error: ${error},
|
||
Status Code: ${xhr.status},
|
||
Status Text: ${xhr.statusText},
|
||
Response: ${xhr.responseText}
|
||
`);
|
||
},
|
||
complete: function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
});
|
||
|
||
function featchInsurerList()
|
||
{
|
||
|
||
$.ajax({
|
||
url: '<?= base_url("util/get_insurer_by_export_templete") ?>',
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('featchInsurerList list', res)
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
appendInsurer(res.data)
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
function appendInsurer(data)
|
||
{
|
||
var insurer_id = $('#insurer_id').val();
|
||
console.log('insurer_id', insurer_id);
|
||
$('#insurer').empty();
|
||
$('#insurer').append($('<option>', {
|
||
value: '',
|
||
text: 'Select',
|
||
selected: true
|
||
}));
|
||
|
||
$.each(data, function(index, item) {
|
||
if(insurer_id != item.id){
|
||
var option = $('<option>', {
|
||
value: item.id,
|
||
text: item.insurer_name
|
||
});
|
||
$('#insurer').append(option);
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
function checkInsurerTemplete(input)
|
||
{
|
||
var existing_insurer_id = $('#insurer').val();
|
||
var copy_insurer_id = $('#insurer_General_PrimaryKey').val()
|
||
var insurer_templete_count = $('#insurer_templete_count').val()
|
||
|
||
if(existing_insurer_id == '')
|
||
{
|
||
Swal.fire({
|
||
title: "warning!",
|
||
text: 'Please select the Insurer',
|
||
icon: "warning"
|
||
});
|
||
return false;
|
||
}
|
||
|
||
console.log('existing_insurer_id', existing_insurer_id)
|
||
console.log('copy_insurer_id', copy_insurer_id)
|
||
console.log('insurer_templete_count', insurer_templete_count)
|
||
|
||
$('#insurer').val('').change();
|
||
|
||
if(insurer_templete_count == 0){
|
||
copyTemplateAJAX(existing_insurer_id, copy_insurer_id)
|
||
|
||
}else{
|
||
|
||
Swal.fire({
|
||
title: "The insurer already have export template?",
|
||
text: "If you want to approve this the existing template will be deleted!",
|
||
icon: "warning",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
confirmButtonText: "Yes",
|
||
}).then((result) => {
|
||
|
||
|
||
if (result.isConfirmed) {
|
||
copyTemplateAJAX(existing_insurer_id, copy_insurer_id)
|
||
}
|
||
|
||
});
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
function copyTemplateAJAX(existing_insurer_id, copy_insurer_id)
|
||
{
|
||
$.ajax({
|
||
url: '<?= base_url("util/copy_insurer_templete/") ?>' + existing_insurer_id + '/' + copy_insurer_id,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('checkInsurerTemplete response', res)
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if(res.status == false){
|
||
toastr.error(res.message, 'Error');
|
||
}else{
|
||
toastr.success(res.message, 'Success');
|
||
}
|
||
|
||
window.location.reload(true);
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
}
|
||
|
||
function addNewJsonExportTemplate(input)
|
||
{
|
||
$('#myCenterModalLabel').text('Create Template');
|
||
$('#dynamic-form-container').empty();
|
||
addHTMLInput();
|
||
var myModal = new bootstrap.Modal(document.getElementById('template_modal'));
|
||
myModal.show();
|
||
}
|
||
|
||
function addHTMLInput(element = null, data = null)
|
||
{
|
||
const container = document.getElementById('dynamic-form-container');
|
||
const newRow = document.createElement('div');
|
||
newRow.className = 'form-row dynamic-form-row';
|
||
newRow.innerHTML = `
|
||
<div class="form-group col-md-5">
|
||
<label for="excel_column_name">Header Name<span class="text-danger">*</span></label>
|
||
<input id="excel_column_name" value="${data !== null && data !== undefined && data !== '' ? data.column_name : ''}" class="form-control" type="text" name="excel_column_name[]" placeholder="Excel Header Column Name">
|
||
</div>
|
||
<div class="form-group col-md-5">
|
||
<label for="db_column_name">DataBase Column Name<span class="text-danger"></span></label>
|
||
<select class="form-control db-column-name-select" name="db_column_name[]" onchange="checkForDuplicates(this)">
|
||
<option value="" selected >Select</option>
|
||
<?php if (!empty($db_column_name)){ ?>
|
||
<?php foreach ($db_column_name as $key => $value) { ?>
|
||
<option value="<?= $value ?>"><?= $key ?></option>
|
||
<?php } ?>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
<div class="form-group col-md-2" style="position: relative;top: 28px;">
|
||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(this)">+</a>
|
||
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
|
||
</div>
|
||
`;
|
||
container.appendChild(newRow);
|
||
|
||
if (data !== null && data.db_column_name !== undefined) {
|
||
const selectElement = newRow.querySelector('.db-column-name-select');
|
||
selectElement.value = data.db_column_name;
|
||
}
|
||
}
|
||
|
||
// function removeHTMLInput(element)
|
||
// {
|
||
// const row = element.closest('.dynamic-form-row');
|
||
// row.remove();
|
||
// }
|
||
|
||
|
||
function removeHTMLInput(element)
|
||
{
|
||
const container = document.getElementById('dynamic-form-container');
|
||
const rows = container.querySelectorAll('.dynamic-form-row');
|
||
|
||
if (rows.length > 1) {
|
||
const row = element.closest('.dynamic-form-row');
|
||
row.remove();
|
||
}
|
||
}
|
||
|
||
function createFormArray()
|
||
{
|
||
var formArray = [];
|
||
|
||
try {
|
||
var columnNames = $('input[name="excel_column_name[]"]');
|
||
var dbColumnNames = $('select[name="db_column_name[]"]');
|
||
|
||
// Check if both arrays are of the same length
|
||
if (columnNames.length !== dbColumnNames.length) {
|
||
throw new Error('Mismatch between the number of column names and database column names.');
|
||
}
|
||
|
||
// Iterate over the column names and build the formArray
|
||
columnNames.each(function(index) {
|
||
var columnName = $(this).val();
|
||
var dbColumnName = dbColumnNames.eq(index).val() ?? null;
|
||
|
||
// if (!columnName) {
|
||
// throw new Error(`Column name at index ${index} is empty.`);
|
||
// }
|
||
// if (!dbColumnName) {
|
||
// throw new Error(`Database column name at index ${index} is empty.`);
|
||
// }
|
||
|
||
var columnObj = {
|
||
'column_index': index,
|
||
'column_name': columnName,
|
||
'db_column_name': dbColumnName
|
||
};
|
||
formArray.push(columnObj);
|
||
});
|
||
|
||
console.log('Form array successfully created:', formArray);
|
||
var jsonString = JSON.stringify(formArray);
|
||
console.log('Form array successfully created: jsonString', jsonString);
|
||
return jsonString;
|
||
|
||
} catch (error) {
|
||
console.error('Error creating form array:', error.message);
|
||
// Optionally, display an error message to the user
|
||
alert('An error occurred while processing the form: ' + error.message);
|
||
return null; // Return null to indicate that an error occurred
|
||
}
|
||
}
|
||
|
||
function editJSONExportTemplate(input, id)
|
||
{
|
||
console.log(id);
|
||
$('#template_id').val(id);
|
||
$('#myCenterModalLabel').text('Edit Template');
|
||
var url = '<?php echo base_url('util/get_single_excel_template/'); ?>' + id;
|
||
|
||
$('.loader').fadeIn();
|
||
$('.loader-mask').fadeIn();
|
||
|
||
$.ajax({
|
||
url: url,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
console.log('editJSONExportTemplate response', res)
|
||
|
||
$('#policy_type').val(res.data.policy_type_id);
|
||
$('#event').val(res.data.event_name);
|
||
|
||
// console.log(res.data.jsoncolumns);
|
||
var data = JSON.parse(res.data.jsoncolumns)
|
||
// console.log(JSON.parse(res.data.jsoncolumns));
|
||
|
||
$('#dynamic-form-container').empty();
|
||
|
||
$.each(data, function(index, item) {
|
||
|
||
addHTMLInput(null, item)
|
||
|
||
});
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
|
||
var myModal = new bootstrap.Modal(document.getElementById('template_modal'));
|
||
myModal.show();
|
||
}
|
||
|
||
function checkForDuplicates(selectElement)
|
||
{
|
||
|
||
const selectedValue = selectElement.value;
|
||
const selects = document.querySelectorAll('#dynamic-form-container .db-column-name-select');
|
||
|
||
let isDuplicate = false;
|
||
|
||
selects.forEach(select => {
|
||
if (select !== selectElement && select.value === selectedValue) {
|
||
isDuplicate = true;
|
||
}
|
||
});
|
||
|
||
if (isDuplicate) {
|
||
toastr.warning('This value is already selected in another dropdown.', 'Warning');
|
||
selectElement.value = '';
|
||
}
|
||
}
|
||
|
||
$('.close').click(function()
|
||
{
|
||
$('#dynamic-form-container').empty();
|
||
$('#policy_type').val('');
|
||
$('#event').val('').change();
|
||
$('#excel_column_name').val('');
|
||
$('#template_id').val('')
|
||
});
|
||
|
||
function dublicateTemplate()
|
||
{
|
||
var template_id = $('#template_id_for_duplicate').attr('data-id');
|
||
var event_name = $('#event_name_for_duplicate').val();
|
||
var insurer_id = $('#insurer_id_for_dub_temp').val();
|
||
|
||
console.log('template_id_for_duplicate', template_id)
|
||
console.log('event_name_for_duplicate', event_name)
|
||
console.log('insurer_id', insurer_id)
|
||
|
||
if(event_name == ""){
|
||
|
||
Swal.fire({
|
||
title: "warning!",
|
||
text: 'Please select the Event',
|
||
icon: "warning"
|
||
});
|
||
|
||
return false
|
||
}
|
||
|
||
var url = '<?= base_url('util/dublicate_template/') ?>' + template_id + '/' + event_name + '/' +insurer_id
|
||
|
||
$.ajax({
|
||
url: url,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function(res) {
|
||
|
||
console.log('dublicateTemplate response', res)
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
|
||
if(res.status == false){
|
||
toastr.error(res.message, 'Error');
|
||
}else{
|
||
toastr.success(res.message, 'Success');
|
||
}
|
||
|
||
window.location.reload(true);
|
||
},
|
||
error: function(xhr, status, error) {
|
||
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}
|
||
});
|
||
}
|
||
|
||
</script>
|