CHANGE_CLIENT_BRANCH_ID_ON_ALL_PLACE : RV

This commit is contained in:
VENKATESHWARAN 2024-05-24 10:09:12 +05:30
parent e889e4ea5a
commit 17837196bb
13 changed files with 861 additions and 488 deletions

View File

@ -1962,91 +1962,89 @@ class ClientController extends AdminController
public function transformArray($data, $mapping) {
public function transformArray($data, $mapping)
{
// dd($data);
$transformedData = [];
// dd($data);
$transformedData = [];
if (!is_array($data)) {
return json_encode($transformedData, JSON_PRETTY_PRINT);
}
foreach ($data as $key => $value) {
if ($key == 'family_floaters') {
$transformedData[$key] = $this->transformFamilyFloaters($value, $data);
} else if (array_key_exists($key, $mapping)) {
$transformedData[$mapping[$key]] = $value;
} else if ($key == 'special_condition_label') {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['special_condition_input'][$key];
}
} else if ($key == 'gpa_special_condition_label') {
foreach ($value as $key => $value) {
$transformedData[$value] = $data['gpa_special_condition_input'][$key];
}
} else if ($key == 'age_ratio') {
if (isset($data['sumInsured2'])) {
$transformedData['Self'] = "(Min: " . $data['age_ratio']['self']['min'] . ", Max: " . $data['age_ratio']['self']['max'] . ")";
}
} else {
$transformedData[$key] = $value;
}
}
if (!is_array($data)) {
return json_encode($transformedData, JSON_PRETTY_PRINT);
}
foreach ($data as $key => $value) {
if ($key == 'family_floaters') {
$transformedData[$key] = $this->transformFamilyFloaters($value, $data);
}else if (array_key_exists($key, $mapping)) {
$transformedData[$mapping[$key]] = $value;
}else if($key == 'special_condition_label'){
foreach ($value as $key => $value) {
$transformedData[$value] = $data['special_condition_input'][$key];
}
public function transformFamilyFloaters($familyFloaters, $json)
{
$result = [];
}else if($key == 'gpa_special_condition_label'){
$min = $json['age_ratio']['self'];
$max = $json['age_ratio']['self'];
foreach ($value as $key => $value) {
$transformedData[$value] = $data['gpa_special_condition_input'][$key];
}
$spouse_min = $json['age_ratio']['spouse'];
$spouse_max = $json['age_ratio']['spouse'];
}else if($key == 'age_ratio'){
$child_min = $json['age_ratio']['child'];
$child_max = $json['age_ratio']['child'];
if(isset($data['sumInsured2'])){
$elders_min = $json['age_ratio']['elders'];
$elders_max = $json['age_ratio']['elders'];
$transformedData['Self'] = "(Min: " . $data['age_ratio']['self']['min'] . ", Max: " . $data['age_ratio']['self']['max'] . ")";
}
}else {
$transformedData[$key] = $value;
}
}
return json_encode($transformedData, JSON_PRETTY_PRINT);
}
public function transformFamilyFloaters($familyFloaters, $json) {
$result = [];
$min = $json['age_ratio']['self'];
$max = $json['age_ratio']['self'];
$spouse_min = $json['age_ratio']['spouse'];
$spouse_max = $json['age_ratio']['spouse'];
$child_min = $json['age_ratio']['child'];
$child_max = $json['age_ratio']['child'];
$elders_min = $json['age_ratio']['elders'];
$elders_max = $json['age_ratio']['elders'];
foreach ($familyFloaters as $key => $value) {
if ($value !== 0) {
switch ($key) {
case 'self':
$result[] = "Self (Min: {$min['min']}, Max: {$max['max']})";
break;
case 'spouse':
$result[] = "Spouse (Min: {$spouse_min['min']}, Max: {$spouse_max['max']})";
break;
case 'childrens':
$result[] = "Children(s) - $value (Min: {$child_min['min']}, Max: {$child_max['max']})";
break;
case 'parents':
$result[] = "Parent(s) - $value (Min: {$elders_min['min']}, Max: {$elders_max['max']})";
break;
case 'parents-in-law':
$result[] = "Parents-in-Law - $value (Min: {$elders_min['min']}, Max: {$elders_max['max']})";
break;
case 'either-parents-pil':
$result[] = "Either Parents Nor Parents-in-Law - $value (elders_min: {$elders_min['min']}, Max: {$elders_max['max']})";
break;
foreach ($familyFloaters as $key => $value) {
if ($value !== 0) {
switch ($key) {
case 'self':
$result[] = "Self (Min: {$min['min']}, Max: {$max['max']})";
break;
case 'spouse':
$result[] = "Spouse (Min: {$spouse_min['min']}, Max: {$spouse_max['max']})";
break;
case 'childrens':
$result[] = "Children(s) - $value (Min: {$child_min['min']}, Max: {$child_max['max']})";
break;
case 'parents':
$result[] = "Parent(s) - $value (Min: {$elders_min['min']}, Max: {$elders_max['max']})";
break;
case 'parents-in-law':
$result[] = "Parents-in-Law - $value (Min: {$elders_min['min']}, Max: {$elders_max['max']})";
break;
case 'either-parents-pil':
$result[] = "Either Parents Nor Parents-in-Law - $value (elders_min: {$elders_min['min']}, Max: {$elders_max['max']})";
break;
}
}
}
}
return implode(", ", $result);
}
return implode(", ", $result);
}

View File

@ -76,7 +76,13 @@ class EmployeeController extends AdminController
$data['status'] = ['draft' => 'Draft', 'active' => 'Active', 'inactive' => 'In-Active', 'expired' => 'Expired'];
if (count($this->request->getGet())) {
$filterData = $this->request->getGet();
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(client_id: $filterData['client_id'], policy_id: $filterData['policy_id'], status: $filterData['status']);
$data['employees'] = $this->employeePolicyModel->getEmployeePolicy(
client_id: $filterData['client_id'],
policy_id: $filterData['policy_id'],
status: $filterData['status'],
branch_id: $filterData['branch_id']
);
$data['getData'] = $filterData;
}
@ -89,6 +95,8 @@ class EmployeeController extends AdminController
//echo $this->request->isAJAX();die();
$result = $this->clientModel->clientsWithPolicies();
// dd($result);
// print_r($result);die();
if (!count($result)) {
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200);
@ -190,10 +198,11 @@ class EmployeeController extends AdminController
$client_id = $this->request->getPost('client_id');
$policy_id = $this->request->getPost('policy_id');
$branch_id = $this->request->getPost('branch_id');
$action = $this->request->getPost('upload-action-type');
$status = 'inprogress';
$file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => $action]); //here field policy_id have client_policy_id and not policy id from policy master
$file_id = $this->fileModel->insert(['file_name' => $filename, 'client_id' => $client_id, 'policy_id' => $policy_id, 'created_by' => $loggedInUserID, 'status' => $status, 'action' => $action, 'client_branch_id' => $branch_id]); //here field policy_id have client_policy_id and not policy id from policy master
$this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
//start validation process
@ -232,6 +241,7 @@ class EmployeeController extends AdminController
'up.first_name',
'pm.name as policy_name',
'c.short_name',
'cb.branch_name',
'cp.id as client_policy_id',
'(SELECT COUNT(*)
FROM employees e
@ -244,6 +254,7 @@ class EmployeeController extends AdminController
])
->join('user_profiles up', 'files.created_by = up.id')
->join('client_policy cp', 'files.policy_id = cp.id', 'left')
->join('client_branch cb', 'files.client_branch_id = cb.id', 'left')
->join('policies pm', 'cp.policy_id = pm.id', 'left')
->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_id', 'left')
->where('files.created_by', get_session_userid())
@ -251,8 +262,9 @@ class EmployeeController extends AdminController
->findAll();
// dd($data['fileList']);
$data['batch_list'] = $this->batchFileModel->select('batch_files.*, policies.name as policy_name, clients.short_name as client_short_name')
$data['batch_list'] = $this->batchFileModel->select('batch_files.*, policies.name as policy_name, clients.short_name as client_short_name, client_branch.branch_name')
->join('client_policy', 'client_policy.id = batch_files.client_policy_id')
->join('client_branch', 'client_branch.id = batch_files.client_branch_id')
->join('policies', 'policies.id = client_policy.policy_id')
->join('clients', 'clients.id = client_policy.client_id')
->orderBy('batch_files.id', 'desc')
@ -351,6 +363,7 @@ class EmployeeController extends AdminController
$client_id = $this->request->getPost('client_id');
$client_policy_id = $this->request->getPost('client_policy_id');
$client_branch_id = $this->request->getPost('client_branch_id');
$insurer_or_tpa = $this->request->getPost('insurer_or_tpa');
$event_type = $this->request->getPost('event_type');
$actions = $this->request->getPost('action_type');
@ -362,6 +375,7 @@ class EmployeeController extends AdminController
$batch_data = [
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
'client_branch_id' => $client_branch_id,
'insurer_or_tpa' => $insurer_or_tpa,
'event_type' => $event_type,
'actions' => $actions,
@ -544,8 +558,13 @@ class EmployeeController extends AdminController
$data['status'] = ['pending' => 'Pending', 'inprogress' => 'In-Progress', 'complete' => 'Complete'];
if (count($this->request->getGet())) {
$filterData = $this->request->getGet();
$data['employees'] = $this->employeePolicyModel->getEmployeeEndorsementList(client_id: $filterData['client_id'], policy_id: $filterData['policy_id'], status: $filterData['status']);
$data['getData'] = $filterData;
$data['employees'] = $this->employeePolicyModel->getEmployeeEndorsementList(
client_id: $filterData['client_id'],
policy_id: $filterData['policy_id'],
status: $filterData['status'],
branch_id: $filterData['branch_id']
);
$data['getData'] = $filterData;
// echo "<pre>";
// print_r($data); die;
}

View File

@ -24,6 +24,7 @@ class BatchFileModel extends Model
"amount",
"status",
"error_data",
"client_branch_id",
];
// Callbacks

View File

@ -4,6 +4,7 @@ namespace App\Models;
use CodeIgniter\Model;
use App\Models\ClientPolicyModel;
use App\Models\ClientBranchModel;
class ClientModel extends Model
{
@ -41,7 +42,8 @@ class ClientModel extends Model
foreach ($clients as &$client) {
$clientPolicyModel = new ClientPolicyModel();
$clientPolicies = $clientPolicyModel->select(['client_policy.id','p.name','pt.policy_type'])
$clientPolicies = $clientPolicyModel->select(['client_branch.id as branch_id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id', 'client_policy.id as client_policy_id','p.name','pt.policy_type',])
->join('client_branch', 'client_branch.id = client_policy.client_branch_id')
->join('policies p', 'p.id = client_policy.policy_id')
->join('policy_type pt','client_policy.policy_type_id = pt.id')
->where('client_policy.client_id',$client['id'])
@ -50,6 +52,13 @@ class ClientModel extends Model
->findAll();
$client['policies'] = $clientPolicies;
$clientBranchModel = new ClientBranchModel();
$clientBranchs = $clientBranchModel->select(['client_branch.id','client_branch.branch_name','client_branch.branch_code', 'client_branch.client_id'])
->where('client_branch.client_id',$client['id'])
->findAll();
$client['branchs'] = $clientBranchs;
}
//print_r(($clients));die();
return $clients;

View File

@ -37,7 +37,8 @@ class EmployeeModel extends Model
"is_active",
"file_id",
"is_addon_value",
"is_createdby_hr"
"is_createdby_hr",
"client_branch_id"
];
// Callbacks

View File

@ -76,7 +76,7 @@ class EmployeePolicyModel extends Model
}
// -----------------------------------------------------------------------------------------------------
public function getEmployeePolicy($client_id,$policy_id,$status)
public function getEmployeePolicy($client_id,$policy_id,$status, $branch_id)
{
$result = $this->select(['employee_polices.*','pm.name as policy_name','im.short_name as insurer_short_name','ib.branch_name as insurer_branch_name','ib.branch_code as insurer_branch_code','tpam.name as tpa_name','tpam.short_name as tpa_short_name','tpab.branch_code as tpa_branch_code','cm.client_name','cm.short_name as client_short_name','emp.relationship','emp.relationship_code','emp.change_event','emp.emp_code','emp.name','emp.email_corporate','emp.dob','emp.gender','emp.emp_status','emp.is_active as emp_is_active','emp.mobile as mobile'])
->join('employees emp', 'employee_polices.employee_id = emp.id')
@ -88,6 +88,7 @@ class EmployeePolicyModel extends Model
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id') //tpab - tpa brach
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->where('emp.client_id',$client_id)
->where('emp.client_branch_id',$branch_id)
->where('employee_polices.is_active',1)
->where('emp.is_active',1)
->where('employee_polices.client_policy_id',$policy_id)
@ -592,7 +593,7 @@ class EmployeePolicyModel extends Model
}
public function getEmployeeEndorsementList($client_id, $policy_id, $status)
public function getEmployeeEndorsementList($client_id, $policy_id, $status, $branch_id)
{
$query1 = $this->db->table('emp_endorsement e');
$query1->select('
@ -609,14 +610,15 @@ class EmployeePolicyModel extends Model
insurers.short_name as insurer_short_name
');
$query1->distinct();
$query1->join('employee_polices ep', 'ep.id = e.pk', 'left');
$query1->join('employees', 'employees.id = ep.employee_id', 'left');
$query1->join('client_policy', 'client_policy.id = ep.client_policy_id', 'left');
$query1->join('policies', 'policies.id = client_policy.policy_id', 'left');
$query1->join('insurers', 'insurers.id = policies.insurer_id', 'left');
$query1->join('employee_polices ep', 'ep.id = e.pk');
$query1->join('employees', 'employees.id = ep.employee_id');
$query1->join('client_policy', 'client_policy.id = ep.client_policy_id');
$query1->join('policies', 'policies.id = client_policy.policy_id');
$query1->join('insurers', 'insurers.id = policies.insurer_id');
$query1->whereIn('e.actions', ['c']);
$query1->where('ep.client_policy_id', $client_id);
$query1->where('employees.client_id', $policy_id);
$query1->where('ep.client_policy_id', $policy_id);
$query1->where('employees.client_id', $client_id);
$query1->where('employees.client_branch_id', $branch_id);
if($status != 0 && !empty($status)){
$query1->where('e.status', $status);
@ -640,14 +642,15 @@ class EmployeePolicyModel extends Model
policies.name as policy_name,
insurers.short_name as insurer_short_name
');
$query2->join('employee_polices ep', 'ep.id = e.pk', 'left');
$query2->join('employees', 'employees.id = ep.employee_id', 'left');
$query2->join('client_policy', 'client_policy.id = ep.client_policy_id', 'left');
$query2->join('policies', 'policies.id = client_policy.policy_id', 'left');
$query2->join('insurers', 'insurers.id = policies.insurer_id', 'left');
$query2->join('employee_polices ep', 'ep.id = e.pk');
$query2->join('employees', 'employees.id = ep.employee_id');
$query2->join('client_policy', 'client_policy.id = ep.client_policy_id');
$query2->join('policies', 'policies.id = client_policy.policy_id');
$query2->join('insurers', 'insurers.id = policies.insurer_id');
$query2->whereIn('e.actions', ['si', 'd']);
$query2->where('ep.client_policy_id', $client_id);
$query2->where('ep.client_policy_id', $policy_id);
$query2->where('employees.client_id', $policy_id);
$query1->where('employees.client_branch_id', $branch_id);
if($status != 0 && !empty($status)){
$query2->where('e.status', $status);

View File

@ -17,7 +17,8 @@ class FileModel extends Model
"reason",
"action",
"client_id",
"policy_id"
"policy_id",
"client_branch_id",
];

View File

@ -25,6 +25,7 @@
<th class="font-weight-medium">Batch <br> Code</th>
<th class="font-weight-medium">File Name</th>
<th class="font-weight-medium">Client</th>
<th class="font-weight-medium">Client <br> Branch</th>
<th class="font-weight-medium">Client Policy</th>
<th class="font-weight-medium">Event <br> Type</th>
<th class="font-weight-medium">Insurer/ <br> TPA</th>
@ -50,6 +51,7 @@
<?php echo strlen($file['file_name']) > 5 ? substr($file['file_name'], 0, 10) . "..." : $file['file_name'] ?>
</td>
<td><?php echo $file['client_short_name'] ?></td>
<td><?php echo $file['branch_name'] ?></td>
<td><?php echo $file['policy_name'] ?></td>
<td><?php echo $file['event_type'] ?></td>
<td><?php echo $file['insurer_or_tpa'] ?></td>

View File

@ -29,6 +29,15 @@ table.dataTable tbody td {
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Branch</label> <br />
<select name="branch_id" class="form-control" id="branch_id">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Policy</label> <br />
@ -80,6 +89,7 @@ $(document).ready(function() {
// Initialize select2
$("#clients").select2();
$("#policies").select2();
$("#branch_id").select2();
// if ($('.select2-selection__arrow').length > 0) {
// $('.select2-selection__arrow').removeClass('select2-selection__arrow').addClass('fa fa-chevron-down');
@ -88,7 +98,12 @@ $(document).ready(function() {
// Declare a global variable to store API response data
var clientPolicies = [];
var clientPoliciesWithBranch = {
policies: []
};
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>';
$(document).ready(function() {
@ -122,6 +137,14 @@ function fetchClientPolicies() {
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
clientPolicies = (response.data);
response.data.forEach(policy => {
console.log('policies', policy.policies);
policy.policies.forEach(p => {
clientPoliciesWithBranch.policies.push(p);
});
});
console.log('1',clientPolicies);
appendClients(clientPolicies);
@ -132,7 +155,24 @@ function fetchClientPolicies() {
console.log(typeof item.id)
return item.id == client_id;
});
appendPolicies(foundPolicies.policies);
appendBranch(foundPolicies.branchs);
}
}, 500);
setTimeout(function() {
if (client_branch_id != 0 ) {
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
console.log('item', item);
return item.branch_id === client_branch_id;
});
if (foundPolicies) {
console.log('foundPolicies', foundPolicies);
appendPolicies(foundPolicies);
} else {
console.log('No policies found for the selected client');
}
}
}, 500);
//end
@ -170,6 +210,26 @@ function appendClients(data) {
}
function appendBranch(data) {
$('#branch_id').empty();
$('#branch_id').append($('<option>', {
value: '0',
text: 'Select'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
if (client_branch_id == item.id) {
option.attr('selected', true);
}
$('#branch_id').append(option);
});
}
function appendPolicies(data) {
$('#policies').empty();
@ -182,10 +242,10 @@ function appendPolicies(data) {
console.log(PolicyID)
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
value: item.client_policy_id,
text: item.name + ' - ' + item.policy_type
});
if (PolicyID == item.id) {
if (PolicyID == item.client_policy_id) {
option.attr('selected', true);
}
$('#policies').append(option);
@ -195,6 +255,13 @@ function appendPolicies(data) {
$(document).ready(function() {
$('#clients').on('change', function() {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var selectedClient = $(this).val();
console.log('selectedClient', selectedClient);
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
@ -203,12 +270,37 @@ $(document).ready(function() {
var foundPolicies = clientPolicies.find(function(item) {
return item.id === selectedClient;
});
console.log(foundPolicies.policies);
appendPolicies(foundPolicies.policies);
console.log(foundPolicies.branchs);
appendBranch(foundPolicies.branchs);
});
});
$(document).ready(function() {
$('#branch_id').on('change', function() {
var selectedClient = $(this).val();
console.log('selectedBranch', selectedClient);
console.log('clientPolicies', clientPoliciesWithBranch);
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
console.log('item', item);
return item.branch_id === selectedClient;
});
if (foundPolicies) {
console.log('foundPolicies', foundPolicies);
appendPolicies(foundPolicies);
} else {
console.log('No policies found for the selected client');
}
});
});
// Function to convert object to query parameters
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
@ -221,6 +313,7 @@ function fetchEmpolyeeList(event) {
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var status = $('#status2').val();
var branch_id = $('#branch_id').val();
console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
@ -232,6 +325,7 @@ function fetchEmpolyeeList(event) {
client_id: client_id,
policy_id: policy_id,
branch_id: branch_id,
status : status,
};

View File

@ -36,6 +36,13 @@ option:disabled {
</select>
</div>
<div class="form-group col-md-4">
<label>Branch</label> <br />
<select name="branch_id" class="form-control" id="branch_id" onchange="checkPolicyTermsAndRackRatesHasDefiend(event)">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Policy</label> <br />
<select name="policy_id" class="form-control" id="policy_id" onchange="checkPolicyTermsAndRackRatesHasDefiend(event)">
@ -43,6 +50,10 @@ option:disabled {
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label>Event</label> <br />
<select name="upload-action-type" class="form-control"
@ -166,24 +177,27 @@ $(document).ready(function() {
// Initialize select2
$("#client_id").select2();
$("#policy_id").select2();
$("#branch_id").select2();
});
// Declare a global variable to store API response data
var clientPolicies = [];
var clientPoliciesWithBranch = {
policies: []
};
var client_id_param = 0;
var client_policy_param = 0;
$(document).ready(function() {
console.log("document loaded");
// console.log("document loaded");
//fetchClientPolicies();
//for modal pop up
$('#file-err-modal').on('show.bs.modal', function(event) {
// console.log(event.relatedTarget);
var myVal = $(event.relatedTarget).data('err');
console.log(myVal);
// console.log(myVal);
var loader =
'<div style="text-align: center;"><img src="<?php echo base_url()?>public/assets/images/simple_loader.gif" height="50px" width="50px" ></div>';
$('#file-err-modal').find(".modal-body").html(loader);
@ -196,7 +210,7 @@ $(document).ready(function() {
//for form submit
$("#emp-upload-form").submit(function(event) {
event.preventDefault(); // Prevent default form submission
console.log('submit called');
// console.log('submit called');
var isValid = $('#emp-upload-form').parsley().validate();
@ -207,7 +221,7 @@ $(document).ready(function() {
var action_item = $('#upload-action-type').val();
var policy_id = $('#policy_id').val();
console.log('action_item - ' + action_item);
// console.log('action_item - ' + action_item);
if (action_item != 'correction' && policy_id == "") {
// $('#policy_id').attr('required', true);
// $('#policy_id').prop('title', 'plz choose policy');
@ -248,7 +262,7 @@ $(document).ready(function() {
success: function(response) {
// Request successful, handle response
$('#policy_id').attr('required', false);
console.log(response);
// console.log(response);
if (response.code === 200 && response.dataStatus === true && response
.data !== "") {
toastr.success(
@ -300,9 +314,9 @@ $(window).on("load", function() {
client_policy_param = params.get('client_policy_id');
inception_param = params.get('actions');
console.log('client_id:', client_id_param);
console.log('client_policy_id:', client_policy_param);
console.log('inception_param:', inception_param);
// console.log('client_id:', client_id_param);
// console.log('client_policy_id:', client_policy_param);
// console.log('inception_param:', inception_param);
if(inception_param != null){
$('#upload-action-type').val('inception').change()
@ -324,8 +338,8 @@ $(window).on("load", function() {
function fetchClientPolicies() {
$('#loader').show();
var apiURL = '<?php echo base_url();?>' + 'util/clients-with-policies';
console.log('fetchClientPolicies');
console.log(apiURL);
// console.log('fetchClientPolicies');
// console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
@ -334,13 +348,23 @@ function fetchClientPolicies() {
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
// console.log(response.code);
console.log(response);
// console.log(response.dataStatus);
// console.log(response.data);
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
clientPolicies = (response.data);
// console.log(clientPolicies);
clientPolicies = (response.data)
console.log(clientPolicies);
response.data.forEach(policy => {
console.log('policies', policy.policies);
policy.policies.forEach(p => {
clientPoliciesWithBranch.policies.push(p);
});
});
console.log(clientPoliciesWithBranch);
appendClients(clientPolicies);
@ -348,7 +372,7 @@ function fetchClientPolicies() {
setTimeout(function() {
if (client_id_param != null ) {
var foundPolicies = clientPolicies.find(function(item) {
console.log(typeof item.id)
// console.log(typeof item.id)
return item.id == client_id_param;
});
appendPolicies(foundPolicies.policies);
@ -377,8 +401,8 @@ function fetchClientPolicies() {
function fetchFileError(file_id) {
$('#loader').show();
var apiURL = '<?php echo base_url();?>' + 'util/get-file-error/' + file_id;
console.log('fetchFileError');
console.log(apiURL);
// console.log('fetchFileError');
// console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
@ -390,7 +414,7 @@ function fetchFileError(file_id) {
$(this).find(".modal-body").html("");
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
console.log((JSON.parse(response.data)));
// console.log((JSON.parse(response.data)));
var file_error_data = (JSON.parse(response.data));
var file_error_html = "";
@ -515,7 +539,7 @@ function fetchFileError(file_id) {
function appendClients(data) {
console.log('client_id_param', client_id_param)
// console.log('client_id_param', client_id_param)
$.each(data, function(index, item) {
var option = $('<option>', {
@ -530,28 +554,65 @@ function appendClients(data) {
}
function appendPolicies(data) {
function appendBranch(data) {
$('#policy_id').empty();
$('#policy_id').append($('<option>', {
$('#branch_id').empty();
$('#branch_id').append($('<option>', {
value: '0',
text: 'Select'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.name + ' - ' + item.policy_type
text: item.branch_name
});
if (client_policy_param == item.id) {
option.attr('selected', true);
}
$('#branch_id').append(option);
});
}
function appendPolicies(data) {
// console.log(data)
$('#policy_id').empty();
$('#policy_id').append($('<option>', {
value: '0',
text: 'Select',
selected: true
}));
$.each(data, function(index, item) {
// console.log(item)
var option = $('<option>', {
value: item.client_policy_id,
text: item.name + ' - ' + item.policy_type
});
if (client_policy_param == item.client_policy_id) {
option.attr('selected', true);
}
$('#policy_id').append(option);
});
}
$(document).ready(function() {
$('#client_id').on('change', function() {
$('#policy_id').empty();
$('#policy_id').append($('<option>', {
value: '',
text: 'Select'
}));
var selectedClient = $(this).val();
console.log('selectedClient', selectedClient);
@ -561,13 +622,37 @@ $(document).ready(function() {
var foundPolicies = clientPolicies.find(function(item) {
return item.id === selectedClient;
});
console.log(foundPolicies.policies);
appendPolicies(foundPolicies.policies);
console.log('foundPolicies.branchs', foundPolicies.branchs);
appendBranch(foundPolicies.branchs);
});
});
$(document).ready(function() {
$('#branch_id').on('change', function() {
var selectedClient = $(this).val();
console.log('selectedBranch', selectedClient);
console.log('clientPolicies', clientPoliciesWithBranch);
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
console.log('item', item);
return item.branch_id === selectedClient;
});
if (foundPolicies) {
console.log('foundPolicies', foundPolicies);
appendPolicies(foundPolicies);
} else {
console.log('No policies found for the selected client');
}
});
});
// Function to convert object to query parameters
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
@ -579,7 +664,7 @@ function fetchEmpolyeeList(event) {
var client_id = $('#client_id').val();
var policy_id = $('#policy_id').val();
console.log(client_id + '-' + policy_id);
// console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
toastr.warning('Please select values in both dropdowns.');
return;
@ -592,7 +677,7 @@ function fetchEmpolyeeList(event) {
const queryString = objectToQueryString(queryParams);
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
console.log(apiURL);
// console.log(apiURL);
window.location.href = apiURL;
@ -641,7 +726,7 @@ $('#excel_download').click(function() {
// If href attribute is not set, show an error message
toastr.warning('Please select an Action to download a sample Excel.', 'Warning');
} else {
console.log('Download action triggered.');
// console.log('Download action triggered.');
}
});
@ -657,15 +742,15 @@ $('#fetch_enrolled_data').click(function()
var policy_id = $('#policy_id').val();
var uri = '<?= base_url('util/init-Emp-onboard/') ?>' + policy_id;
console.log(policy_id);
console.log(uri);
// console.log(policy_id);
// console.log(uri);
$('#fetch_btn').attr('href', uri);
$('#emp_data').empty();
var client_id = $('#client_id').val();
var policy_id = $('#policy_id').val();
var action = $('#upload-action-type').val();
console.log(client_id + '-' + policy_id);
// console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
toastr.warning('please select the client and policy for this uploaing event', 'warning')
$('#full-width-modal').modal('hide');
@ -678,14 +763,14 @@ $('#fetch_enrolled_data').click(function()
action: action
};
console.log('queryParams', queryParams)
// console.log('queryParams', queryParams)
const queryString = objectToQueryString(queryParams);
console.log('queryString', queryString)
// console.log('queryString', queryString)
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var uri = '<?= base_url('util/featch-emp-list')?>?' + queryString
console.log(uri)
// console.log(uri)
$.ajax({
url: uri,
@ -699,7 +784,7 @@ $('#fetch_enrolled_data').click(function()
contentType: false,
success: function(res) {
console.log(res);
// console.log(res);
if (res) {
setTimeout(function() {
@ -729,13 +814,13 @@ $(document).ready(function() {
$('#policy_id').change(function(){
var selectedpolicy = $(this).val();
console.log('selectedpolicy',selectedpolicy)
// console.log('selectedpolicy',selectedpolicy)
$('#upload-action-type').val('').change();
$('#file_upload').hide();
$('#excel_download').removeAttr('href');
var apiURL = '<?php echo base_url();?>' + 'util/fetch-emp-count/' + selectedpolicy;
console.log(apiURL);
// console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
@ -745,7 +830,7 @@ $(document).ready(function() {
},
success: function(response) {
console.log('responce data emp_count', response);
// console.log('responce data emp_count', response);
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
@ -800,11 +885,11 @@ $(document).ready(function() {
function checkPolicyTermsAndRackRatesHasDefiend(event)
{
console.log(event.target.id);
// console.log(event.target.id);
var policy_id = (event.target.value);
console.log('checkPolicyTermsAndRackRatesHasDefiend called ' + policy_id);
// console.log('checkPolicyTermsAndRackRatesHasDefiend called ' + policy_id);
var apiURL = '<?php echo base_url();?>' + 'util/has_policy_config_completed/' + policy_id;
console.log(apiURL);
// console.log(apiURL);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
@ -824,7 +909,7 @@ function checkPolicyTermsAndRackRatesHasDefiend(event)
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000);
console.log('check policy responce', response);
// console.log('check policy responce', response);
if (response.code === 200 && response.dataStatus === true && response.message !== null) {
toastr.error(response.message, 'Error');

View File

@ -1,18 +1,17 @@
<style>
.table th,
.table td {
padding: 8px;
}
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.btn .btn-secondary .buttons-csv .buttons-html5 .my_class{
position: relative;
left: 79px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.btn .btn-secondary .buttons-csv .buttons-html5 .my_class {
position: relative;
left: 79px;
}
</style>
<div class="row">
@ -20,8 +19,7 @@ table.dataTable tbody td {
<div id="accordion" class="mb-3">
<div class="card mb-1">
<h5 class="m-1">
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne"
aria-expanded="true">
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</h5>
@ -36,6 +34,14 @@ table.dataTable tbody td {
</select>
</div>
<div class="form-group col-md-4">
<label>Branch</label> <br />
<select name="branch_id" class="form-control" id="branch_id">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Policy</label> <br />
<select class="form-control" id="policies">
@ -47,11 +53,10 @@ table.dataTable tbody td {
<label>Status</label> <br />
<select class="form-control" id="status1">
<option value="0">Select</option>
<?php foreach($status as $key => $value) { ?>
<option value="<?= $key ?>"
<?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
<?= $value ?>
</option>
<?php foreach ($status as $key => $value) { ?>
<option value="<?= $key ?>" <?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
<?= $value ?>
</option>
<?php } ?>
</select>
</div>
@ -59,9 +64,7 @@ table.dataTable tbody td {
</div>
<div class="row">
<div class="col-12" style="text-align: right;">
<a href="<?= base_url("employee/endorsement-list"); ?>"
class="btn btn-primary waves-effect waves-light" id="get-emp-list"
onclick="fetchEmpolyeeList(event);">Submit</a>
<a href="<?= base_url("employee/endorsement-list"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
</div>
</div>
<!-- </div> -->
@ -84,8 +87,7 @@ table.dataTable tbody td {
</div>
</div>
<table class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0"
id="tickets-table">
<table class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">SNO</th>
@ -101,47 +103,45 @@ table.dataTable tbody td {
</thead>
<tbody class="font-12">
<?php
if(isset($employees))
{
foreach ($employees as $key => $employee) { ?>
<?php
if (isset($employees)) {
foreach ($employees as $key => $employee) { ?>
<tr>
<td><b><?php echo ($key + 1)?></b></td>
<td><?php echo $employee['name']?>( <?php echo $employee['emp_code']?> )</td>
<td><?php echo isset($employee['policy_name']) ? $employee['policy_name'] : '' ?></td>
<td><?php echo $employee['endorsement_id']?></td>
<td><?php echo isset($employee['insurer_short_name']) ? $employee['insurer_short_name'] : '' ?>
</td>
<td><?php echo $employee['remarks']?></td>
<td>
<?php
if ($employee['actions'] == 'c') {
echo 'Correction';
} elseif ($employee['actions'] == 'si') {
echo 'SI Enhancement';
} elseif ($employee['actions'] == 'd') {
echo 'Deletion';
}
?>
</td>
<td>
<?php
if ($employee['status'] == 'pending') {
echo '<span class="badge badge-danger">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'inprogress') {
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'complete') {
echo '<span class="badge badge-success">' . $employee['status'] . '</span>';
}
?>
</td>
<td class="text-center"><a href="#" data-id="<?php echo $employee['id']?>"
class="fa fa-eye emp_data_model" aria-hidden="true" data-toggle="modal"
data-target="#centermodal"></a>
</td>
</tr>
<?php }}?>
<tr>
<td><b><?php echo ($key + 1) ?></b></td>
<td><?php echo $employee['name'] ?>( <?php echo $employee['emp_code'] ?> )</td>
<td><?php echo isset($employee['policy_name']) ? $employee['policy_name'] : '' ?></td>
<td><?php echo $employee['endorsement_id'] ?></td>
<td><?php echo isset($employee['insurer_short_name']) ? $employee['insurer_short_name'] : '' ?>
</td>
<td><?php echo $employee['remarks'] ?></td>
<td>
<?php
if ($employee['actions'] == 'c') {
echo 'Correction';
} elseif ($employee['actions'] == 'si') {
echo 'SI Enhancement';
} elseif ($employee['actions'] == 'd') {
echo 'Deletion';
}
?>
</td>
<td>
<?php
if ($employee['status'] == 'pending') {
echo '<span class="badge badge-danger">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'inprogress') {
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'complete') {
echo '<span class="badge badge-success">' . $employee['status'] . '</span>';
}
?>
</td>
<td class="text-center"><a href="#" data-id="<?php echo $employee['id'] ?>" class="fa fa-eye emp_data_model" aria-hidden="true" data-toggle="modal" data-target="#centermodal"></a>
</td>
</tr>
<?php }
} ?>
</tbody>
</table>
@ -153,7 +153,7 @@ table.dataTable tbody td {
<!-- Center modal content -->
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
@ -179,351 +179,432 @@ table.dataTable tbody td {
<script>
$(document).ready(function() {
// Initialize select2
$("#clients").select2();
$("#policies").select2();
$("#branch_id").select2();
});
$(document).ready(function() {
// Initialize select2
$("#clients").select2();
$("#policies").select2();
});
// Declare a global variable to store API response data
var clientPolicies = [];
var clientPoliciesWithBranch = {
policies: []
};
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>';
// Declare a global variable to store API response data
var clientPolicies = [];
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
$(window).on("load", function() {
console.log("window loaded");
fetchClientPolicies();
});
$(window).on("load", function() {
console.log("window loaded");
fetchClientPolicies();
});
function fetchClientPolicies() {
function fetchClientPolicies() {
$('#loader').show();
var apiURL = '<?php echo base_url();?>' + 'util/clients-with-policies';
console.log('fetchClientPolicies');
console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
// console.log(response.code);
// console.log(response.dataStatus);
// console.log(response.data);
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
clientPolicies = (response.data);
console.log(clientPolicies);
appendClients(clientPolicies);
$('#loader').show();
var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
console.log('fetchClientPolicies');
console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
// console.log(response.code);
// console.log(response.dataStatus);
// console.log(response.data);
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
clientPolicies = (response.data);
//this function for reselect policy
setTimeout(function() {
if (client_id) {
var foundPolicies = clientPolicies.find(function(item) {
console.log(typeof item.id)
return item.id == client_id;
response.data.forEach(policy => {
console.log('policies', policy.policies);
policy.policies.forEach(p => {
clientPoliciesWithBranch.policies.push(p);
});
appendPolicies(foundPolicies.policies);
}
}, 500);
//end
});
} catch (error) {
console.error('Error parsing API response data:', error);
console.log(clientPolicies);
appendClients(clientPolicies);
setTimeout(function() {
if (client_id) {
var foundPolicies = clientPolicies.find(function(item) {
console.log(typeof item.id)
return item.id == client_id;
});
appendBranch(foundPolicies.branchs);
}
}, 500);
setTimeout(function() {
if (client_branch_id) {
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
console.log('item', item);
return item.branch_id === client_branch_id;
});
if (foundPolicies) {
console.log('foundPolicies', foundPolicies);
appendPolicies(foundPolicies);
} else {
console.log('No policies found for the selected client');
}
}
}, 500);
} catch (error) {
console.error('Error parsing API response data:', error);
}
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
} else {
console.error('Something went wrong!');
}
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
} else {
console.error('Something went wrong!');
},
error: function(xhr, status, error) {
console.error('Error fetching data from API:', error);
}
},
error: function(xhr, status, error) {
console.error('Error fetching data from API:', error);
}
});
$('#loader').hide();
}
function appendClients(data) {
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.client_name
});
if (clientID == item.id) {
option.attr('selected', true);
}
$('#clients').append(option);
});
}
function appendPolicies(data) {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0'?>;
console.log(PolicyID)
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.name
});
if (PolicyID == item.id) {
option.attr('selected', true);
}
$('#policies').append(option);
});
}
$(document).ready(function() {
$('#clients').on('change', function() {
var selectedClient = $(this).val();
console.log(selectedClient);
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
// Check if the selected option exists in apiData
var foundPolicies = clientPolicies.find(function(item) {
return item.id === selectedClient;
});
console.log(foundPolicies.policies);
appendPolicies(foundPolicies.policies);
});
});
// Function to convert object to query parameters
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
function fetchEmpolyeeList(event) {
event.preventDefault(); // Prevent default action
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var status = $('#status1').val();
console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
return;
$('#loader').hide();
}
var queryParams = {
client_id: client_id,
policy_id: policy_id,
status: status,
};
const queryString = objectToQueryString(queryParams);
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
console.log(apiURL);
window.location.href = apiURL;
function appendClients(data) {
}
document.getElementById('toggleIcon').addEventListener('click', function() {
var icon = document.getElementById('icon');
icon.classList.toggle('mdi-chevron-down');
icon.classList.toggle('mdi-chevron-up');
});
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.client_name
});
if (clientID == item.id) {
option.attr('selected', true);
}
$('#clients').append(option);
});
}
$('.emp_data_model').click(function() {
var myVal = $(this).data('id');
console.log(myVal);
fetchEmpEndorsementData(myVal)
function appendBranch(data) {
});
$('#branch_id').empty();
$('#branch_id').append($('<option>', {
value: '0',
text: 'Select'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
if (client_branch_id == item.id) {
option.attr('selected', true);
}
$('#branch_id').append(option);
});
}
function fetchEmpEndorsementData(id) {
function appendPolicies(data) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var apiURL = '<?php echo base_url();?>' + 'util/get-emp-endorsement/' + id;
console.log('fetchEmpEndorsementData');
console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
console.log(response);
if (response.code === 200 && response.dataStatus === true) {
try {
endorsementData = (response.data);
endorsementData2 = (response.data2);
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0' ?>;
console.log(PolicyID)
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.client_policy_id,
text: item.name
});
if (PolicyID == item.client_policy_id) {
option.attr('selected', true);
}
$('#policies').append(option);
});
}
e_actions = endorsementData2[0]['actions'];
$(document).ready(function() {
$('#clients').on('change', function() {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var selectedClient = $(this).val();
console.log(selectedClient);
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
// Check if the selected option exists in apiData
var foundPolicies = clientPolicies.find(function(item) {
return item.id === selectedClient;
});
console.log(foundPolicies.branchs);
appendBranch(foundPolicies.branchs);
});
});
$(document).ready(function() {
$('#branch_id').on('change', function() {
var selectedClient = $(this).val();
console.log('selectedBranch', selectedClient);
console.log('clientPolicies', clientPoliciesWithBranch);
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
console.log('item', item);
return item.branch_id === selectedClient;
});
var heading = "";
if (endorsementData2[0]['actions'] == 'si') {
heading = ' - ' + 'SI Enhancement';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
} else if (endorsementData2[0]['actions'] == 'd') {
heading = ' - ' + 'Deletion';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
} else if (endorsementData2[0]['actions'] == 'c') {
heading = ' - ' + 'Correction';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
}
if (foundPolicies) {
console.log('foundPolicies', foundPolicies);
appendPolicies(foundPolicies);
} else {
console.log('No policies found for the selected client');
}
});
$('#heading').html(heading);
$('#table_data').empty();
$('#table_head_data').empty();
});
if(e_actions == 'd'){
// Function to convert object to query parameters
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
$.each(endorsementData, function(index, item) {
var tableHtml = `
function fetchEmpolyeeList(event) {
event.preventDefault(); // Prevent default action
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var status = $('#status1').val();
var branch_id = $('#branch_id').val();
console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
return;
}
var queryParams = {
client_id: client_id,
policy_id: policy_id,
branch_id: branch_id,
status: status,
};
const queryString = objectToQueryString(queryParams);
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
console.log(apiURL);
window.location.href = apiURL;
}
document.getElementById('toggleIcon').addEventListener('click', function() {
var icon = document.getElementById('icon');
icon.classList.toggle('mdi-chevron-down');
icon.classList.toggle('mdi-chevron-up');
});
$('.emp_data_model').click(function() {
var myVal = $(this).data('id');
console.log(myVal);
fetchEmpEndorsementData(myVal)
});
function fetchEmpEndorsementData(id) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var apiURL = '<?php echo base_url(); ?>' + 'util/get-emp-endorsement/' + id;
console.log('fetchEmpEndorsementData');
console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
console.log(response);
if (response.code === 200 && response.dataStatus === true) {
try {
endorsementData = (response.data);
endorsementData2 = (response.data2);
e_actions = endorsementData2[0]['actions'];
var heading = "";
if (endorsementData2[0]['actions'] == 'si') {
heading = ' - ' + 'SI Enhancement';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
} else if (endorsementData2[0]['actions'] == 'd') {
heading = ' - ' + 'Deletion';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
} else if (endorsementData2[0]['actions'] == 'c') {
heading = ' - ' + 'Correction';
heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
}
$('#heading').html(heading);
$('#table_data').empty();
$('#table_head_data').empty();
if (e_actions == 'd') {
$.each(endorsementData, function(index, item) {
var tableHtml = `
<tr>
<td>${item.field_name}</td>
<td>${formatNumberToIndianLocale(item.data, item.field_name, e_actions)}</td>
</tr>
`;
$('#table_data').append(tableHtml);
});
$('#table_data').append(tableHtml);
});
} else {
var table_head = `
} else {
var table_head = `
<tr>
<th class="font-weight-medium"></th>
<th class="font-weight-medium">Old Value</th>
<th class="font-weight-medium">New Value</th>
</tr>
`;
$('#table_head_data').append(table_head);
$('#table_head_data').append(table_head);
$.each(endorsementData, function(index, item) {
var tableHtml = `
$.each(endorsementData, function(index, item) {
var tableHtml = `
<tr>
<td>${item.field_name}</td>
<td>${formatNumberToIndianLocale(item.old_value, item.field_name)}</td>
<td>${formatNumberToIndianLocale(item.new_value, item.field_name, e_actions)}</td>
</tr>
`;
$('#table_data').append(tableHtml);
});
$('#table_data').append(tableHtml);
});
}
} catch (error) {
console.error('Error parsing API response data:', error);
}
} catch (error) {
console.error('Error parsing API response data:', error);
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
} else {
console.error('Something went wrong!');
}
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
} else {
console.error('Something went wrong!');
},
error: function(xhr, status, error) {
console.error('Error fetching data from API:', error);
}
},
error: function(xhr, status, error) {
console.error('Error fetching data from API:', error);
}
});
});
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 200);
}
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 200);
}
function formatNumberToIndianLocale(value, field_name, action) {
function formatNumberToIndianLocale(value, field_name, action) {
// Check if the value is a valid number (either as a number or as a string)
if (!isNaN(value) && !isNaN(parseFloat(value)) && field_name != 'No of Days') {
// Check if the value is a valid number (either as a number or as a string)
if (!isNaN(value) && !isNaN(parseFloat(value)) && field_name != 'No of Days') {
// Convert the value to a number and format it using Indian English locale
var return_val = parseFloat(value).toLocaleString('en-IN');
// Convert the value to a number and format it using Indian English locale
var return_val = parseFloat(value).toLocaleString('en-IN');
if(field_name == 'Period of non coverage'){
if (field_name == 'Period of non coverage') {
return value + ' days';
}
return value + ' days';
}
if(field_name == 'Total Amount'){
return '₹ ' + return_val + ' ( To be Refunded )';
}
if(field_name == 'Total'){
if(action == 'd'){
if (field_name == 'Total Amount') {
return '₹ ' + return_val + ' ( To be Refunded )';
}else if(action == 'si'){
return '₹ ' + return_val + ' ( To be paid )';
}
if (field_name == 'Total') {
if (action == 'd') {
return '₹ ' + return_val + ' ( To be Refunded )';
} else if (action == 'si') {
return '₹ ' + return_val + ' ( To be paid )';
}
}
return '₹ ' + return_val;
} else {
// Return the original value if it's not a valid number
return value;
}
return '₹ ' + return_val;
} else {
// Return the original value if it's not a valid number
return value;
}
}
$('.close').click(function(){
$('.close').click(function() {
$('#table_data').empty();
})
$('#table_data').empty();
})
$(document).ready(function(){
$(document).ready(function() {
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"buttons": [{
"extend": 'csv',
"text": 'CSV',
"title": 'Endorsement-List',
"className": 'my_class',
"exportOptions": {
"columns": ':not(:last-child)'
},
}],
"initComplete": function(settings, json) {
$('.my_class').css({
"position": "relative",
"left": "79px"
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"buttons": [{
"extend": 'csv',
"text": 'CSV',
"title": 'Endorsement-List',
"className": 'my_class',
"exportOptions": {
"columns": ':not(:last-child)'
},
}],
"initComplete": function(settings, json) {
$('.my_class').css({
"position": "relative",
"left": "79px"
});
},
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true,
// pagingType: 'full_numbers'
});
},
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true ,
// pagingType: 'full_numbers'
});
});
});
</script>

View File

@ -25,6 +25,7 @@
<th class="font-weight-medium">SNO</th>
<th class="font-weight-medium">File name</th>
<th class="font-weight-medium">Client</th>
<th class="font-weight-medium">Client Branch</th>
<th class="font-weight-medium">Policy</th>
<th class="font-weight-medium">Event</th>
<th class="font-weight-medium">User/Time</th>
@ -47,6 +48,7 @@
<td><b><?php echo ($key + 1)?></b></td>
<td><?php echo $file['file_name']?></td>
<td><?php echo $file['short_name']?></td>
<td><?php echo $file['branch_name']?></td>
<td><?php echo $file['policy_name']?></td>
<td><?php echo $file['action']?></td>
<td><?php echo fancy_date_time_format($file['created_at']).' by <strong>'.$file['first_name'].'</strong>'?>

View File

@ -23,6 +23,13 @@
</select>
</div>
<div class="form-group col-md-4">
<label>Branch</label> <br />
<select name="client_branch_id" class="form-control" id="client_branch_id" onchange="checkPolicyTermsAndRackRatesHasDefiend(event)">
<option value="0">Select</option>
</select>
</div>
<div class="form-group col-md-4">
<label>Policy<span class="text-danger" id="policy_danger">*</span></label> <br />
<select name="client_policy_id" class="form-control" id="policy" required>
@ -30,6 +37,10 @@
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label>Insurer/TPA Data<span class="text-danger">*</span></label> <br />
<select name="insurer_or_tpa" class="form-control" id="insurer_or_tpa" required>
@ -43,9 +54,6 @@
?>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label>Action<span class="text-danger">*</span></label> <br />
@ -121,11 +129,15 @@
// Initialize select2
$("#client").select2();
$("#policy").select2();
$("#client_branch_id").select2();
});
// Declare a global variable to store API response data
var clientPolicies = [];
var clientPoliciesWithBranch2 = {
policies: []
};
var client_id_param2 = 0;
var client_policy_param2 = 0;
@ -293,6 +305,16 @@
try {
clientPolicies = (response.data);
console.log(clientPolicies);
response.data.forEach(policy => {
console.log('policies', policy.policies);
policy.policies.forEach(p => {
clientPoliciesWithBranch2.policies.push(p);
});
});
appendClients2(clientPolicies);
//this function for reselect the policy
@ -342,6 +364,28 @@
}
function appendBranch2(data) {
console.log(data)
$('#client_branch_id').empty();
$('#client_branch_id').append($('<option>', {
value: '0',
text: 'Select'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
if (client_policy_param == item.id) {
option.attr('selected', true);
}
$('#client_branch_id').append(option);
});
}
function appendPolicies2(data) {
$('#policy').empty();
@ -352,10 +396,10 @@
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
value: item.client_policy_id,
text: item.name + ' - ' + item.policy_type
});
if (client_policy_param2 == item.id) {
if (client_policy_param2 == item.client_policy_id) {
option.attr('selected', true);
}
$('#policy').append(option);
@ -365,6 +409,13 @@
$(document).ready(function() {
$('#client').on('change', function() {
$('#policy').empty();
$('#policy').append($('<option>', {
value: '0',
text: 'Select'
}));
var selectedClient = $(this).val();
console.log(selectedClient);
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
@ -373,8 +424,34 @@
var foundPolicies = clientPolicies.find(function(item) {
return item.id === selectedClient;
});
console.log(foundPolicies.policies);
appendPolicies2(foundPolicies.policies);
console.log(foundPolicies.branchs);
appendBranch2(foundPolicies.branchs);
});
});
$(document).ready(function() {
$('#client_branch_id').on('change', function() {
var selectedClient = $(this).val();
console.log('selectedBranch', selectedClient);
console.log('clientPolicies', clientPoliciesWithBranch2);
var foundPolicies = clientPoliciesWithBranch2.policies.filter(function(item) {
console.log('item', item);
return item.branch_id === selectedClient;
});
if (foundPolicies) {
console.log('foundPolicies', foundPolicies);
appendPolicies2(foundPolicies);
} else {
console.log('No policies found for the selected client');
}
});
});