MERGE_TEST_EXCEL_TEMPLATE_UI
This commit is contained in:
commit
c475a9ad5d
@ -273,6 +273,11 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("featch_dashboard_data/(:any)", "DashboardController::featch_dashboard_data/$1");
|
||||
$routes->get("remove_rack_rate/(:any)", "ClientController::removeRackRate/$1");
|
||||
$routes->get("rename_rack_rate_tab/(:any)", "ClientController::renameRackRateTab/$1");
|
||||
$routes->post("create_excel_template", "MasterController::createExcelTemplate");
|
||||
$routes->get("get_insurer_by_export_templete", "MasterController::getInsurerByExportTemplete");
|
||||
$routes->get("copy_insurer_templete/(:any)", "MasterController::copyInsurerTemplete/$1");
|
||||
$routes->get("get_single_excel_template/(:any)", "MasterController::getSingleExcelTemplate/$1");
|
||||
$routes->get("dublicate_template/(:any)", "MasterController::duplicateTemplate/$1");
|
||||
});
|
||||
|
||||
$routes->cli('cli/processjob', 'JobWorker::processJob');
|
||||
|
||||
@ -751,7 +751,7 @@ class ClientController extends AdminController
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'Cannot delete config units',
|
||||
'message' => "Deleted unit(s) in use. couldn't complete this operation.",
|
||||
'uncommonValues' => $uncommonValues,
|
||||
'data' => $branchData,
|
||||
], 200);
|
||||
|
||||
@ -943,7 +943,7 @@ class EmpDataServiceController extends BaseController
|
||||
->select('insurer_excel_export_template.jsoncolumns')
|
||||
->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = client_policy.insurer_id and insurer_excel_export_template.policy_type_id = client_policy.policy_type_id')
|
||||
->where('client_policy.id', $export_data['client_policy_id'])
|
||||
->where('insurer_excel_export_template.event_name', 'inception')
|
||||
->where('insurer_excel_export_template.event_name', 'all')
|
||||
->where('insurer_excel_export_template.type_name', $export_data['actions'])
|
||||
->first();
|
||||
|
||||
|
||||
@ -254,6 +254,7 @@ class EmployeeController extends AdminController
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'file upload success'], 200);
|
||||
}
|
||||
|
||||
$data['page_name'] = 'View Inception';
|
||||
|
||||
//for TPA/insurer upload
|
||||
$data['events'] = ['inception' => 'Inception (Employee + Dependents)', 'missed_inception' => 'Missed Inception (Employee + Dependents)', 'addition' => 'Addition (Employee + Dependents)', 'dependent_addition' => 'Dependent Addition (Only Dependents)', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement'];
|
||||
@ -415,7 +416,6 @@ class EmployeeController extends AdminController
|
||||
$event_type = $this->request->getPost('event_type');
|
||||
}
|
||||
|
||||
|
||||
$this->myLogger->logme('error', 'Import Export -- Function called');
|
||||
$empDataServiceController = new EmpDataServiceController();
|
||||
|
||||
@ -534,7 +534,6 @@ class EmployeeController extends AdminController
|
||||
$batch_data['event_type'] = $array;
|
||||
$return = $empDataServiceController->generateExcelForAllEventType($batch_data);
|
||||
|
||||
|
||||
if($return === 6){
|
||||
|
||||
session()->setFlashdata('error', "The Insurer does not have an Excel export template format.");
|
||||
@ -549,6 +548,7 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if ($actions == 'import') {
|
||||
|
||||
$batch_data['file'] = $this->request->getFile('import_file_data');
|
||||
|
||||
@ -160,8 +160,56 @@ class MasterController extends AdminController
|
||||
$editData['policy_type'] = $this->policyTypeModel->whereIn('id', [1,2,6,7])->findAll();
|
||||
$editData['events'] = ['inception' => 'Inception', 'addition' => 'Addition', 'dependent_addition' => 'Dependent Addition', 'deletion' => 'Deletion', 'correction' => 'Correction', 'si_enhancement' => 'SI Enhancement', 'all' => 'All'];
|
||||
$editData['action'] = ['import' => 'Import', 'export' => 'Export'];
|
||||
$editData['db_column_name'] = ['Employee Name' => 'emp_name', 'Employee ID' => 'emp_code'];
|
||||
$editData['db_column_name'] = [
|
||||
|
||||
'Employee Name' => 'emp_name',
|
||||
'Employee ID' => 'emp_code',
|
||||
'Date of Birth' => 'emp_dob',
|
||||
'Gender' => 'emp_gender',
|
||||
'Change Event' => 'change_event',
|
||||
'Relationship' => 'emp_relationship',
|
||||
'Relationship Code' => 'emp_relationship_code',
|
||||
'Event Type' => 'event_type_data',
|
||||
'Date of Joining' => 'emp_doj',
|
||||
'Mobile' => 'emp_mobile',
|
||||
'Corporate Email' => 'emp_email_c',
|
||||
'Personal Email' => 'emp_email_p',
|
||||
'Grade' => 'emp_grade',
|
||||
'Designation' => 'emp_designation',
|
||||
'Basic Pay' => 'emp_basic_pay',
|
||||
'Age' => 'emp_age',
|
||||
'Employee Type' => 'emp_type',
|
||||
'Primary Key' => 'primaryKey',
|
||||
'TPA ID' => 'tpa_id',
|
||||
'UHID' => 'uhid',
|
||||
'Pre-existing Alignments' => 'pre_existing_alignments',
|
||||
'Basic Cover SI' => 'basic_cover_si',
|
||||
'Date of Coverage' => 'date_coverage',
|
||||
'Policy End Date' => 'policy_end_date',
|
||||
'Number of Days' => 'no_of_days',
|
||||
'Premium' => 'premium',
|
||||
'Pro Rata Premium' => 'pro_rata_premium',
|
||||
'GST' => 'gst',
|
||||
'Total' => 'total',
|
||||
'Policy ID' => 'emp_policy_id',
|
||||
'SEZ' => 'sez',
|
||||
'Endorsement ID' => 'endorsement_id',
|
||||
'Old Value' => 'old_value',
|
||||
'New Value' => 'new_value',
|
||||
'Field Name' => 'field_name',
|
||||
'Remarks' => 'remarks',
|
||||
'Actions' => 'actions',
|
||||
'Date of Exit' => 'dateofexit',
|
||||
'Reason for Exit' => 'reasonforexit',
|
||||
'Status' => 'status',
|
||||
'Old Basic Cover SI' => 'old_basic_cover_si',
|
||||
'Old SI Premium' => 'old_si_premium',
|
||||
'New Basic Cover SI' => 'new_basic_cover_si',
|
||||
'New SI Premium' => 'new_si_premium',
|
||||
'Date of Coverage' => 'date_of_coverage',
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
@ -356,6 +404,8 @@ class MasterController extends AdminController
|
||||
$insurer_data = $this->insurerModel
|
||||
->select('insurers.name as insurer_name, insurers.id, insurers.is_multi_event')
|
||||
->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = insurers.id')
|
||||
->where('insurer_excel_export_template.is_active', 1)
|
||||
->where('insurers.is_active', 1)
|
||||
->groupBy('insurers.id')
|
||||
->findAll();
|
||||
|
||||
@ -364,8 +414,8 @@ class MasterController extends AdminController
|
||||
|
||||
public function copyInsurerTemplete($existing_insurer_id, $copy_insurer_id)
|
||||
{
|
||||
$insurer_templete_data = $this->insurerTemplateModel->where('insurer_id', $existing_insurer_id)->findAll();
|
||||
$existing_insurer_templete_data = $this->insurerTemplateModel->where('insurer_id', $copy_insurer_id)->delete();
|
||||
$insurer_templete_data = $this->insurerTemplateModel->where('insurer_id', $existing_insurer_id)->where('is_active', 1)->findAll();
|
||||
$existing_insurer_templete_data = $this->insurerTemplateModel->where('insurer_id', $copy_insurer_id)->set('is_active', 0)->update();
|
||||
|
||||
$data_to_insert = [];
|
||||
foreach ($insurer_templete_data as $value) {
|
||||
@ -381,12 +431,31 @@ class MasterController extends AdminController
|
||||
}
|
||||
|
||||
$insert_result = $this->insurerTemplateModel->insertBatch($data_to_insert);
|
||||
|
||||
if($insert_result){
|
||||
return $this->respond(['status' => true, 'message' => 'Template added successfully', $insurer_templete_data]);
|
||||
}else{
|
||||
return $this->respond(['status' => true, 'message' => 'Failed to add template', $insurer_templete_data]);
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to add template', $insurer_templete_data]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getSingleExcelTemplate($id = null)
|
||||
{
|
||||
$insurer_templete_data = $this->insurerTemplateModel
|
||||
->where('id', $id)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if($insurer_templete_data){
|
||||
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $insurer_templete_data, 'message' => 'data found'], 200);
|
||||
|
||||
}else{
|
||||
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
}
|
||||
|
||||
}
|
||||
// Insurer Ends
|
||||
|
||||
|
||||
@ -1113,7 +1182,8 @@ class MasterController extends AdminController
|
||||
|
||||
//start CD Master list
|
||||
public function CDMasterList()
|
||||
{
|
||||
{
|
||||
$data['page_name'] = 'CD Master List';
|
||||
$data['CD_Master_Data'] = $this->CDMasterModel->getCDMasterList();
|
||||
$data['insurers'] = $this->insurerModel->where('is_active', 1)->findAll();
|
||||
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
|
||||
@ -1265,23 +1335,99 @@ class MasterController extends AdminController
|
||||
|
||||
|
||||
|
||||
//excel export template
|
||||
public function createExcelTemplate()
|
||||
{
|
||||
{
|
||||
// return $this->respond($this->request->getPost());
|
||||
$template_id = $this->request->getPost('template_id');
|
||||
|
||||
$data = [
|
||||
'insurer_id' => $this->request->getPost('insurer_id'),
|
||||
'policy_type_id' => $this->request->getPost('policy_type'),
|
||||
'event_name' => $this->request->getPost('event'),
|
||||
'type_name' => $this->request->getPost('import_or_export'),
|
||||
'type_name' => 'export',
|
||||
'jsoncolumns' => $this->request->getPost('json_data'),
|
||||
'is_active' => 1,
|
||||
'created_by' => get_session_userid(),
|
||||
];
|
||||
|
||||
$insert = $this->insurerTemplateModel->insert($data);
|
||||
if($template_id){
|
||||
|
||||
$update = $this->insurerTemplateModel->where('id', $template_id)->set($data)->update();
|
||||
|
||||
if($update){
|
||||
return $this->respond(['status' => true, 'message' => 'Template updated successfully', $data]);
|
||||
}else{
|
||||
return $this->respond(['status' => true, 'message' => 'Failed to update template', $data]);
|
||||
}
|
||||
|
||||
if($insert){
|
||||
return $this->respond(['status' => true, 'message' => 'Template created successfully', $data]);
|
||||
}else{
|
||||
return $this->respond(['status' => true, 'message' => 'Failed to create template', $data]);
|
||||
|
||||
$insert = $this->insurerTemplateModel->insert($data);
|
||||
|
||||
if($insert){
|
||||
return $this->respond(['status' => true, 'message' => 'Template created successfully', $data]);
|
||||
}else{
|
||||
return $this->respond(['status' => true, 'message' => 'Failed to create template', $data]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function duplicateTemplate($template_id, $event_name)
|
||||
{
|
||||
// Fetch the template data based on the provided ID and ensure it is active
|
||||
$insurer_template_data = $this->insurerTemplateModel->where('id', $template_id)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
|
||||
if ($insurer_template_data) {
|
||||
|
||||
// Check if the event name matches the existing template's event name
|
||||
if ($insurer_template_data['event_name'] == $event_name) {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'message' => 'Template with the same event already exists.',
|
||||
'data' => $insurer_template_data
|
||||
]);
|
||||
}
|
||||
|
||||
// Prepare data for insertion as a duplicate
|
||||
$data_to_insert = [
|
||||
"insurer_id" => $insurer_template_data['insurer_id'],
|
||||
"policy_type_id" => $insurer_template_data['policy_type_id'],
|
||||
"event_name" => $event_name,
|
||||
"type_name" => $insurer_template_data['type_name'],
|
||||
"jsoncolumns" => $insurer_template_data['jsoncolumns'],
|
||||
"created_by" => get_session_user(),
|
||||
"is_active" => 1,
|
||||
];
|
||||
|
||||
// Insert the duplicate template data
|
||||
$insert_result = $this->insurerTemplateModel->insert($data_to_insert);
|
||||
|
||||
if ($insert_result) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'message' => 'Template duplicated successfully.',
|
||||
'data' => $insurer_template_data
|
||||
]);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'message' => 'Failed to duplicate template.',
|
||||
'data' => $insurer_template_data
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
// No matching active template found
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'message' => 'No active template data found.',
|
||||
'data' => null
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -205,10 +205,11 @@ class EmployeePolicyModel extends Model
|
||||
employees.emp_code AS emp_code,
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employees.change_event AS change_event,
|
||||
employees.relationship AS emp_relationship,
|
||||
employees.relationship_code AS emp_relationship_code,
|
||||
'$datas' as event_type_data,
|
||||
employees.change_event AS change_event,
|
||||
|
||||
|
||||
employees.doj AS emp_doj,
|
||||
employees.mobile AS emp_mobile,
|
||||
@ -297,10 +298,11 @@ class EmployeePolicyModel extends Model
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employees.client_id AS emp_client_id,
|
||||
employees.emp_type as emp_temp_codeype,
|
||||
employees.emp_type as emp_type,
|
||||
employee_polices.uhid,
|
||||
employees.relationship_code,
|
||||
employees.relationship,
|
||||
employee_polices.tpa_id,
|
||||
employees.relationship_code as emp_relationship_code,
|
||||
employees.relationship as emp_relationship,
|
||||
'C' as event_type_data,
|
||||
|
||||
employees.doj AS emp_doj,
|
||||
@ -388,7 +390,7 @@ class EmployeePolicyModel extends Model
|
||||
employees.designation AS emp_designation,
|
||||
employees.basic_pay AS emp_basic_pay,
|
||||
|
||||
employee_polices.uhid AS risk_id,
|
||||
employee_polices.uhid AS uhid,
|
||||
employee_polices.pre_existing_alignments,
|
||||
employee_polices.policy_end_date,
|
||||
employee_polices.basic_cover_si as old_basic_cover_si,
|
||||
|
||||
@ -56,12 +56,14 @@ class InsurerModel extends Model
|
||||
public function getInsurerTemplateByInsurerID($insurer_id)
|
||||
{
|
||||
$insurer_data = $this->db->table('insurer_excel_export_template')
|
||||
->select('insurers.name as insurer_name, insurers.id, insurers.is_multi_event')
|
||||
->select('CASE WHEN insurers.is_multi_event = 1 THEN "multiple" ELSE insurer_excel_export_template.event_name END as event_name', false)
|
||||
->select('insurer_excel_export_template.*, insurers.name as insurer_name, insurers.is_multi_event')
|
||||
->select('CASE WHEN insurers.is_multi_event = 1 THEN "All" ELSE insurer_excel_export_template.event_name END as event_name', false)
|
||||
->select('insurer_excel_export_template.type_name, insurer_excel_export_template.jsoncolumns, policy_type.policy_type')
|
||||
->join('insurers', 'insurers.id = insurer_excel_export_template.insurer_id')
|
||||
->join('policy_type', 'policy_type.id = insurer_excel_export_template.policy_type_id')
|
||||
->where('insurers.id', $insurer_id)
|
||||
->where('insurers.is_active', 1)
|
||||
->where('insurer_excel_export_template.is_active', 1)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
|
||||
@ -1,6 +1,55 @@
|
||||
<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_templete_count" value="<?= isset($insurer_templete_count) ? $insurer_templete_count : ''?>">
|
||||
<input type="hidden" id="insurer_id" value="<?= $insurer['id'] ?>">
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="email">Existing Insurer Export<span class="text-danger">*</span></label>
|
||||
@ -14,10 +63,10 @@
|
||||
<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;">
|
||||
<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>
|
||||
|
||||
</div>
|
||||
|
||||
@ -33,17 +82,27 @@
|
||||
<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>
|
||||
<th><?= $key+1; ?></th>
|
||||
<th><?= $value['policy_type']; ?></th>
|
||||
<th><?= $value['event_name']; ?></th>
|
||||
<th><?= $value['type_name']; ?></th>
|
||||
<th><?= $value['jsoncolumns']; ?></th>
|
||||
<td><?= $key+1; ?></td>
|
||||
<td><?= $value['policy_type']; ?></td>
|
||||
<td><?= $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 } ?>
|
||||
@ -54,19 +113,20 @@
|
||||
|
||||
<!-- 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">
|
||||
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">New Template</h4>
|
||||
<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="<?= $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-4">
|
||||
<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>
|
||||
@ -77,7 +137,7 @@ aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<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>
|
||||
@ -88,7 +148,8 @@ aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
|
||||
<!-- <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>
|
||||
@ -98,32 +159,36 @@ aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
|
||||
<div id="dynamic-form-container">
|
||||
<div class="form-row dynamic-form-row">
|
||||
<div class="form-group col-md-5">
|
||||
<label for="header_name">Header Name<span class="text-danger">*</span></label>
|
||||
<input class="form-control" type="text" name="header_name[]">
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<label for="policy_id">DataBase Column Name<span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="policy_id[]" required>
|
||||
<option selected>Select Client Policy</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>
|
||||
<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>
|
||||
<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>
|
||||
@ -133,50 +198,117 @@ aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right
|
||||
</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">
|
||||
|
||||
<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>
|
||||
|
||||
<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(){
|
||||
|
||||
$('#templateForm').submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
$.ajax({
|
||||
url: $(this).attr("action"),
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
headers: {
|
||||
"X-Requested-With": "XMLHttpRequest"
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
},
|
||||
success: function(response) {
|
||||
var jsonString = createFormArray();; // Convert the array to a JSON string
|
||||
console.log(jsonString);
|
||||
|
||||
console.log('Expoer template list:', response);
|
||||
var formData = new FormData($('#templateForm')[0]);
|
||||
var url = '<?= base_url("util/create_excel_template") ?>';
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
formData.append('json_data', jsonString);
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Request failed, handle error
|
||||
console.error("Request failed:", status, error);
|
||||
console.error('Response:', xhr.responseText);
|
||||
},
|
||||
complete: function() {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$.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()
|
||||
@ -208,7 +340,8 @@ aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right
|
||||
|
||||
function appendInsurer(data)
|
||||
{
|
||||
|
||||
var insurer_id = $('#insurer_id').val();
|
||||
console.log('insurer_id', insurer_id);
|
||||
$('#insurer').empty();
|
||||
$('#insurer').append($('<option>', {
|
||||
value: '',
|
||||
@ -217,11 +350,13 @@ aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right
|
||||
}));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.insurer_name
|
||||
});
|
||||
$('#insurer').append(option);
|
||||
if(insurer_id != item.id){
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.insurer_name
|
||||
});
|
||||
$('#insurer').append(option);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@ -305,25 +440,28 @@ aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right
|
||||
}
|
||||
|
||||
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)
|
||||
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="header_name">Header Name<span class="text-danger">*</span></label>
|
||||
<input class="form-control" type="text" name="header_name[]">
|
||||
<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="policy_id">DataBase Column Name<span class="text-danger">*</span></label>
|
||||
<select class="form-control" name="db_column_name[]" required>
|
||||
<option selected>Select Client Policy</option>
|
||||
<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>
|
||||
@ -337,12 +475,205 @@ aria-hidden="true" aria-modal="true" data-backdrop="static" style="padding-right
|
||||
</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 row = element.closest('.dynamic-form-row');
|
||||
row.remove();
|
||||
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();
|
||||
|
||||
console.log('template_id_for_duplicate', template_id)
|
||||
console.log('event_name_for_duplicate', event_name)
|
||||
|
||||
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
|
||||
|
||||
$.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>
|
||||
Loading…
Reference in New Issue
Block a user