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,7 +1962,8 @@ class ClientController extends AdminController
public function transformArray($data, $mapping) { public function transformArray($data, $mapping)
{
// dd($data); // dd($data);
$transformedData = []; $transformedData = [];
@ -1974,38 +1975,35 @@ public function transformArray($data, $mapping) {
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if ($key == 'family_floaters') { if ($key == 'family_floaters') {
$transformedData[$key] = $this->transformFamilyFloaters($value, $data); $transformedData[$key] = $this->transformFamilyFloaters($value, $data);
}else if (array_key_exists($key, $mapping)) { } else if (array_key_exists($key, $mapping)) {
$transformedData[$mapping[$key]] = $value; $transformedData[$mapping[$key]] = $value;
}else if($key == 'special_condition_label'){ } else if ($key == 'special_condition_label') {
foreach ($value as $key => $value) { foreach ($value as $key => $value) {
$transformedData[$value] = $data['special_condition_input'][$key]; $transformedData[$value] = $data['special_condition_input'][$key];
} }
} else if ($key == 'gpa_special_condition_label') {
}else if($key == 'gpa_special_condition_label'){
foreach ($value as $key => $value) { foreach ($value as $key => $value) {
$transformedData[$value] = $data['gpa_special_condition_input'][$key]; $transformedData[$value] = $data['gpa_special_condition_input'][$key];
} }
} else if ($key == 'age_ratio') {
}else if($key == 'age_ratio'){ if (isset($data['sumInsured2'])) {
if(isset($data['sumInsured2'])){
$transformedData['Self'] = "(Min: " . $data['age_ratio']['self']['min'] . ", Max: " . $data['age_ratio']['self']['max'] . ")"; $transformedData['Self'] = "(Min: " . $data['age_ratio']['self']['min'] . ", Max: " . $data['age_ratio']['self']['max'] . ")";
} }
} else {
}else {
$transformedData[$key] = $value; $transformedData[$key] = $value;
} }
} }
return json_encode($transformedData, JSON_PRETTY_PRINT); return json_encode($transformedData, JSON_PRETTY_PRINT);
} }
public function transformFamilyFloaters($familyFloaters, $json) { public function transformFamilyFloaters($familyFloaters, $json)
{
$result = []; $result = [];
$min = $json['age_ratio']['self']; $min = $json['age_ratio']['self'];
@ -2046,7 +2044,7 @@ public function transformFamilyFloaters($familyFloaters, $json) {
} }
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']; $data['status'] = ['draft' => 'Draft', 'active' => 'Active', 'inactive' => 'In-Active', 'expired' => 'Expired'];
if (count($this->request->getGet())) { if (count($this->request->getGet())) {
$filterData = $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; $data['getData'] = $filterData;
} }
@ -89,6 +95,8 @@ class EmployeeController extends AdminController
//echo $this->request->isAJAX();die(); //echo $this->request->isAJAX();die();
$result = $this->clientModel->clientsWithPolicies(); $result = $this->clientModel->clientsWithPolicies();
// dd($result);
// print_r($result);die(); // print_r($result);die();
if (!count($result)) { if (!count($result)) {
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200); 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'); $client_id = $this->request->getPost('client_id');
$policy_id = $this->request->getPost('policy_id'); $policy_id = $this->request->getPost('policy_id');
$branch_id = $this->request->getPost('branch_id');
$action = $this->request->getPost('upload-action-type'); $action = $this->request->getPost('upload-action-type');
$status = 'inprogress'; $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]); $this->myLogger->logme("error", '{file_id} uploaded success', ['file_id' => $file_id]);
//start validation process //start validation process
@ -232,6 +241,7 @@ class EmployeeController extends AdminController
'up.first_name', 'up.first_name',
'pm.name as policy_name', 'pm.name as policy_name',
'c.short_name', 'c.short_name',
'cb.branch_name',
'cp.id as client_policy_id', 'cp.id as client_policy_id',
'(SELECT COUNT(*) '(SELECT COUNT(*)
FROM employees e FROM employees e
@ -244,6 +254,7 @@ class EmployeeController extends AdminController
]) ])
->join('user_profiles up', 'files.created_by = up.id') ->join('user_profiles up', 'files.created_by = up.id')
->join('client_policy cp', 'files.policy_id = cp.id', 'left') ->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('policies pm', 'cp.policy_id = pm.id', 'left')
->join('clients c', 'files.client_id = c.id and files.client_id = cp.client_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()) ->where('files.created_by', get_session_userid())
@ -251,8 +262,9 @@ class EmployeeController extends AdminController
->findAll(); ->findAll();
// dd($data['fileList']); // 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_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('policies', 'policies.id = client_policy.policy_id')
->join('clients', 'clients.id = client_policy.client_id') ->join('clients', 'clients.id = client_policy.client_id')
->orderBy('batch_files.id', 'desc') ->orderBy('batch_files.id', 'desc')
@ -351,6 +363,7 @@ class EmployeeController extends AdminController
$client_id = $this->request->getPost('client_id'); $client_id = $this->request->getPost('client_id');
$client_policy_id = $this->request->getPost('client_policy_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'); $insurer_or_tpa = $this->request->getPost('insurer_or_tpa');
$event_type = $this->request->getPost('event_type'); $event_type = $this->request->getPost('event_type');
$actions = $this->request->getPost('action_type'); $actions = $this->request->getPost('action_type');
@ -362,6 +375,7 @@ class EmployeeController extends AdminController
$batch_data = [ $batch_data = [
'client_id' => $client_id, 'client_id' => $client_id,
'client_policy_id' => $client_policy_id, 'client_policy_id' => $client_policy_id,
'client_branch_id' => $client_branch_id,
'insurer_or_tpa' => $insurer_or_tpa, 'insurer_or_tpa' => $insurer_or_tpa,
'event_type' => $event_type, 'event_type' => $event_type,
'actions' => $actions, 'actions' => $actions,
@ -544,7 +558,12 @@ class EmployeeController extends AdminController
$data['status'] = ['pending' => 'Pending', 'inprogress' => 'In-Progress', 'complete' => 'Complete']; $data['status'] = ['pending' => 'Pending', 'inprogress' => 'In-Progress', 'complete' => 'Complete'];
if (count($this->request->getGet())) { if (count($this->request->getGet())) {
$filterData = $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['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; $data['getData'] = $filterData;
// echo "<pre>"; // echo "<pre>";
// print_r($data); die; // print_r($data); die;

View File

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

View File

@ -4,6 +4,7 @@ namespace App\Models;
use CodeIgniter\Model; use CodeIgniter\Model;
use App\Models\ClientPolicyModel; use App\Models\ClientPolicyModel;
use App\Models\ClientBranchModel;
class ClientModel extends Model class ClientModel extends Model
{ {
@ -41,7 +42,8 @@ class ClientModel extends Model
foreach ($clients as &$client) { foreach ($clients as &$client) {
$clientPolicyModel = new ClientPolicyModel(); $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('policies p', 'p.id = client_policy.policy_id')
->join('policy_type pt','client_policy.policy_type_id = pt.id') ->join('policy_type pt','client_policy.policy_type_id = pt.id')
->where('client_policy.client_id',$client['id']) ->where('client_policy.client_id',$client['id'])
@ -50,6 +52,13 @@ class ClientModel extends Model
->findAll(); ->findAll();
$client['policies'] = $clientPolicies; $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(); //print_r(($clients));die();
return $clients; return $clients;

View File

@ -37,7 +37,8 @@ class EmployeeModel extends Model
"is_active", "is_active",
"file_id", "file_id",
"is_addon_value", "is_addon_value",
"is_createdby_hr" "is_createdby_hr",
"client_branch_id"
]; ];
// Callbacks // 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']) $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') ->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('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id') //tpab - tpa brach
->join('clients cm', 'cp.client_id = cm.id') //cm - client master ->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->where('emp.client_id',$client_id) ->where('emp.client_id',$client_id)
->where('emp.client_branch_id',$branch_id)
->where('employee_polices.is_active',1) ->where('employee_polices.is_active',1)
->where('emp.is_active',1) ->where('emp.is_active',1)
->where('employee_polices.client_policy_id',$policy_id) ->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 = $this->db->table('emp_endorsement e');
$query1->select(' $query1->select('
@ -609,14 +610,15 @@ class EmployeePolicyModel extends Model
insurers.short_name as insurer_short_name insurers.short_name as insurer_short_name
'); ');
$query1->distinct(); $query1->distinct();
$query1->join('employee_polices ep', 'ep.id = e.pk', 'left'); $query1->join('employee_polices ep', 'ep.id = e.pk');
$query1->join('employees', 'employees.id = ep.employee_id', 'left'); $query1->join('employees', 'employees.id = ep.employee_id');
$query1->join('client_policy', 'client_policy.id = ep.client_policy_id', 'left'); $query1->join('client_policy', 'client_policy.id = ep.client_policy_id');
$query1->join('policies', 'policies.id = client_policy.policy_id', 'left'); $query1->join('policies', 'policies.id = client_policy.policy_id');
$query1->join('insurers', 'insurers.id = policies.insurer_id', 'left'); $query1->join('insurers', 'insurers.id = policies.insurer_id');
$query1->whereIn('e.actions', ['c']); $query1->whereIn('e.actions', ['c']);
$query1->where('ep.client_policy_id', $client_id); $query1->where('ep.client_policy_id', $policy_id);
$query1->where('employees.client_id', $policy_id); $query1->where('employees.client_id', $client_id);
$query1->where('employees.client_branch_id', $branch_id);
if($status != 0 && !empty($status)){ if($status != 0 && !empty($status)){
$query1->where('e.status', $status); $query1->where('e.status', $status);
@ -640,14 +642,15 @@ class EmployeePolicyModel extends Model
policies.name as policy_name, policies.name as policy_name,
insurers.short_name as insurer_short_name insurers.short_name as insurer_short_name
'); ');
$query2->join('employee_polices ep', 'ep.id = e.pk', 'left'); $query2->join('employee_polices ep', 'ep.id = e.pk');
$query2->join('employees', 'employees.id = ep.employee_id', 'left'); $query2->join('employees', 'employees.id = ep.employee_id');
$query2->join('client_policy', 'client_policy.id = ep.client_policy_id', 'left'); $query2->join('client_policy', 'client_policy.id = ep.client_policy_id');
$query2->join('policies', 'policies.id = client_policy.policy_id', 'left'); $query2->join('policies', 'policies.id = client_policy.policy_id');
$query2->join('insurers', 'insurers.id = policies.insurer_id', 'left'); $query2->join('insurers', 'insurers.id = policies.insurer_id');
$query2->whereIn('e.actions', ['si', 'd']); $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); $query2->where('employees.client_id', $policy_id);
$query1->where('employees.client_branch_id', $branch_id);
if($status != 0 && !empty($status)){ if($status != 0 && !empty($status)){
$query2->where('e.status', $status); $query2->where('e.status', $status);

View File

@ -17,7 +17,8 @@ class FileModel extends Model
"reason", "reason",
"action", "action",
"client_id", "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">Batch <br> Code</th>
<th class="font-weight-medium">File Name</th> <th class="font-weight-medium">File Name</th>
<th class="font-weight-medium">Client</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">Client Policy</th>
<th class="font-weight-medium">Event <br> Type</th> <th class="font-weight-medium">Event <br> Type</th>
<th class="font-weight-medium">Insurer/ <br> TPA</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'] ?> <?php echo strlen($file['file_name']) > 5 ? substr($file['file_name'], 0, 10) . "..." : $file['file_name'] ?>
</td> </td>
<td><?php echo $file['client_short_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['policy_name'] ?></td>
<td><?php echo $file['event_type'] ?></td> <td><?php echo $file['event_type'] ?></td>
<td><?php echo $file['insurer_or_tpa'] ?></td> <td><?php echo $file['insurer_or_tpa'] ?></td>

View File

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

View File

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

View File

@ -1,18 +1,17 @@
<style> <style>
.table th, .table th,
.table td { .table td {
padding: 8px; padding: 8px;
} }
table.dataTable tbody td { table.dataTable tbody td {
padding: 4px 4px !important; padding: 4px 4px !important;
} }
.btn .btn-secondary .buttons-csv .buttons-html5 .my_class{ .btn .btn-secondary .buttons-csv .buttons-html5 .my_class {
position: relative; position: relative;
left: 79px; left: 79px;
} }
</style> </style>
<div class="row"> <div class="row">
@ -20,8 +19,7 @@ table.dataTable tbody td {
<div id="accordion" class="mb-3"> <div id="accordion" class="mb-3">
<div class="card mb-1"> <div class="card mb-1">
<h5 class="m-1"> <h5 class="m-1">
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" <a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseOne" aria-expanded="true">
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i> <i id="icon" class="mdi mdi-chevron-down mr-1 text-primary" style="font-size: 28px;"></i>
</a> </a>
</h5> </h5>
@ -36,6 +34,14 @@ table.dataTable tbody td {
</select> </select>
</div> </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"> <div class="form-group col-md-4">
<label>Policy</label> <br /> <label>Policy</label> <br />
<select class="form-control" id="policies"> <select class="form-control" id="policies">
@ -47,9 +53,8 @@ table.dataTable tbody td {
<label>Status</label> <br /> <label>Status</label> <br />
<select class="form-control" id="status1"> <select class="form-control" id="status1">
<option value="0">Select</option> <option value="0">Select</option>
<?php foreach($status as $key => $value) { ?> <?php foreach ($status as $key => $value) { ?>
<option value="<?= $key ?>" <option value="<?= $key ?>" <?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
<?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
<?= $value ?> <?= $value ?>
</option> </option>
<?php } ?> <?php } ?>
@ -59,9 +64,7 @@ table.dataTable tbody td {
</div> </div>
<div class="row"> <div class="row">
<div class="col-12" style="text-align: right;"> <div class="col-12" style="text-align: right;">
<a href="<?= base_url("employee/endorsement-list"); ?>" <a href="<?= base_url("employee/endorsement-list"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
class="btn btn-primary waves-effect waves-light" id="get-emp-list"
onclick="fetchEmpolyeeList(event);">Submit</a>
</div> </div>
</div> </div>
<!-- </div> --> <!-- </div> -->
@ -84,8 +87,7 @@ table.dataTable tbody td {
</div> </div>
</div> </div>
<table class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" <table class="table table-hover m-0 table-centered dt-responsive nowrap w-100" cellspacing="0" id="tickets-table">
id="tickets-table">
<thead class="bg-light"> <thead class="bg-light">
<tr> <tr>
<th class="font-weight-medium">SNO</th> <th class="font-weight-medium">SNO</th>
@ -102,18 +104,17 @@ table.dataTable tbody td {
<tbody class="font-12"> <tbody class="font-12">
<?php <?php
if(isset($employees)) if (isset($employees)) {
{
foreach ($employees as $key => $employee) { ?> foreach ($employees as $key => $employee) { ?>
<tr> <tr>
<td><b><?php echo ($key + 1)?></b></td> <td><b><?php echo ($key + 1) ?></b></td>
<td><?php echo $employee['name']?>( <?php echo $employee['emp_code']?> )</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 isset($employee['policy_name']) ? $employee['policy_name'] : '' ?></td>
<td><?php echo $employee['endorsement_id']?></td> <td><?php echo $employee['endorsement_id'] ?></td>
<td><?php echo isset($employee['insurer_short_name']) ? $employee['insurer_short_name'] : '' ?> <td><?php echo isset($employee['insurer_short_name']) ? $employee['insurer_short_name'] : '' ?>
</td> </td>
<td><?php echo $employee['remarks']?></td> <td><?php echo $employee['remarks'] ?></td>
<td> <td>
<?php <?php
if ($employee['actions'] == 'c') { if ($employee['actions'] == 'c') {
@ -136,12 +137,11 @@ table.dataTable tbody td {
} }
?> ?>
</td> </td>
<td class="text-center"><a href="#" data-id="<?php echo $employee['id']?>" <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>
class="fa fa-eye emp_data_model" aria-hidden="true" data-toggle="modal"
data-target="#centermodal"></a>
</td> </td>
</tr> </tr>
<?php }}?> <?php }
} ?>
</tbody> </tbody>
</table> </table>
@ -179,27 +179,31 @@ table.dataTable tbody td {
<script> <script>
$(document).ready(function() {
$(document).ready(function() {
// Initialize select2 // Initialize select2
$("#clients").select2(); $("#clients").select2();
$("#policies").select2(); $("#policies").select2();
}); $("#branch_id").select2();
});
// Declare a global variable to store API response data // Declare a global variable to store API response data
var clientPolicies = []; var clientPolicies = [];
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>'; var clientPoliciesWithBranch = {
policies: []
};
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
var client_branch_id = '<?= isset($getData) ? $getData['branch_id'] : '0' ?>';
$(window).on("load", function() { $(window).on("load", function() {
console.log("window loaded"); console.log("window loaded");
fetchClientPolicies(); fetchClientPolicies();
}); });
function fetchClientPolicies() { function fetchClientPolicies() {
$('#loader').show(); $('#loader').show();
var apiURL = '<?php echo base_url();?>' + 'util/clients-with-policies'; var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
console.log('fetchClientPolicies'); console.log('fetchClientPolicies');
console.log(apiURL); console.log(apiURL);
$.ajax({ $.ajax({
@ -216,20 +220,44 @@ function fetchClientPolicies() {
if (response.code === 200 && response.dataStatus === true && response.data !== "") { if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try { try {
clientPolicies = (response.data); clientPolicies = (response.data);
response.data.forEach(policy => {
console.log('policies', policy.policies);
policy.policies.forEach(p => {
clientPoliciesWithBranch.policies.push(p);
});
});
console.log(clientPolicies); console.log(clientPolicies);
appendClients(clientPolicies); appendClients(clientPolicies);
//this function for reselect policy
setTimeout(function() { setTimeout(function() {
if (client_id) { if (client_id) {
var foundPolicies = clientPolicies.find(function(item) { var foundPolicies = clientPolicies.find(function(item) {
console.log(typeof item.id) console.log(typeof item.id)
return item.id == client_id; return item.id == client_id;
}); });
appendPolicies(foundPolicies.policies); 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); }, 500);
//end
} catch (error) { } catch (error) {
console.error('Error parsing API response data:', error); console.error('Error parsing API response data:', error);
@ -246,10 +274,10 @@ function fetchClientPolicies() {
}); });
$('#loader').hide(); $('#loader').hide();
} }
function appendClients(data) { function appendClients(data) {
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>; var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
$.each(data, function(index, item) { $.each(data, function(index, item) {
@ -262,10 +290,30 @@ function appendClients(data) {
} }
$('#clients').append(option); $('#clients').append(option);
}); });
} }
function appendPolicies(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(); $('#policies').empty();
$('#policies').append($('<option>', { $('#policies').append($('<option>', {
@ -273,23 +321,30 @@ function appendPolicies(data) {
text: 'Select' text: 'Select'
})); }));
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0'?>; var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0' ?>;
console.log(PolicyID) console.log(PolicyID)
$.each(data, function(index, item) { $.each(data, function(index, item) {
var option = $('<option>', { var option = $('<option>', {
value: item.id, value: item.client_policy_id,
text: item.name text: item.name
}); });
if (PolicyID == item.id) { if (PolicyID == item.client_policy_id) {
option.attr('selected', true); option.attr('selected', true);
} }
$('#policies').append(option); $('#policies').append(option);
}); });
} }
$(document).ready(function() { $(document).ready(function() {
$('#clients').on('change', function() { $('#clients').on('change', function() {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var selectedClient = $(this).val(); var selectedClient = $(this).val();
console.log(selectedClient); console.log(selectedClient);
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption); // $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
@ -298,23 +353,49 @@ $(document).ready(function() {
var foundPolicies = clientPolicies.find(function(item) { var foundPolicies = clientPolicies.find(function(item) {
return item.id === selectedClient; return item.id === selectedClient;
}); });
console.log(foundPolicies.policies); console.log(foundPolicies.branchs);
appendPolicies(foundPolicies.policies); appendBranch(foundPolicies.branchs);
}); });
}); });
// Function to convert object to query parameters $(document).ready(function() {
function objectToQueryString(obj) {
$('#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('&'); return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
} }
function fetchEmpolyeeList(event) { function fetchEmpolyeeList(event) {
event.preventDefault(); // Prevent default action event.preventDefault(); // Prevent default action
var client_id = $('#clients').val(); var client_id = $('#clients').val();
var policy_id = $('#policies').val(); var policy_id = $('#policies').val();
var status = $('#status1').val(); var status = $('#status1').val();
var branch_id = $('#branch_id').val();
console.log(client_id + '-' + policy_id); console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') { if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.'); alert('Please select values in both dropdowns.');
@ -324,6 +405,7 @@ function fetchEmpolyeeList(event) {
var queryParams = { var queryParams = {
client_id: client_id, client_id: client_id,
policy_id: policy_id, policy_id: policy_id,
branch_id: branch_id,
status: status, status: status,
}; };
@ -332,29 +414,29 @@ function fetchEmpolyeeList(event) {
console.log(apiURL); console.log(apiURL);
window.location.href = apiURL; window.location.href = apiURL;
} }
document.getElementById('toggleIcon').addEventListener('click', function() { document.getElementById('toggleIcon').addEventListener('click', function() {
var icon = document.getElementById('icon'); var icon = document.getElementById('icon');
icon.classList.toggle('mdi-chevron-down'); icon.classList.toggle('mdi-chevron-down');
icon.classList.toggle('mdi-chevron-up'); icon.classList.toggle('mdi-chevron-up');
}); });
$('.emp_data_model').click(function() { $('.emp_data_model').click(function() {
var myVal = $(this).data('id'); var myVal = $(this).data('id');
console.log(myVal); console.log(myVal);
fetchEmpEndorsementData(myVal) fetchEmpEndorsementData(myVal)
}); });
function fetchEmpEndorsementData(id) { function fetchEmpEndorsementData(id) {
$('.loader').fadeIn(); $('.loader').fadeIn();
$('.loader-mask').fadeIn(); $('.loader-mask').fadeIn();
var apiURL = '<?php echo base_url();?>' + 'util/get-emp-endorsement/' + id; var apiURL = '<?php echo base_url(); ?>' + 'util/get-emp-endorsement/' + id;
console.log('fetchEmpEndorsementData'); console.log('fetchEmpEndorsementData');
console.log(apiURL); console.log(apiURL);
$.ajax({ $.ajax({
@ -392,7 +474,7 @@ function fetchEmpEndorsementData(id) {
$('#table_head_data').empty(); $('#table_head_data').empty();
if(e_actions == 'd'){ if (e_actions == 'd') {
$.each(endorsementData, function(index, item) { $.each(endorsementData, function(index, item) {
var tableHtml = ` var tableHtml = `
@ -449,9 +531,9 @@ function fetchEmpEndorsementData(id) {
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
}, 200); }, 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) // 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') { if (!isNaN(value) && !isNaN(parseFloat(value)) && field_name != 'No of Days') {
@ -459,23 +541,23 @@ function formatNumberToIndianLocale(value, field_name, action) {
// Convert the value to a number and format it using Indian English locale // Convert the value to a number and format it using Indian English locale
var return_val = parseFloat(value).toLocaleString('en-IN'); 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'){ if (field_name == 'Total Amount') {
return '₹ ' + return_val + ' ( To be Refunded )'; return '₹ ' + return_val + ' ( To be Refunded )';
} }
if(field_name == 'Total'){ if (field_name == 'Total') {
if(action == 'd'){ if (action == 'd') {
return '₹ ' + return_val + ' ( To be Refunded )'; return '₹ ' + return_val + ' ( To be Refunded )';
}else if(action == 'si'){ } else if (action == 'si') {
return '₹ ' + return_val + ' ( To be paid )'; return '₹ ' + return_val + ' ( To be paid )';
} }
@ -488,17 +570,17 @@ function formatNumberToIndianLocale(value, field_name, action) {
// Return the original value if it's not a valid number // Return the original value if it's not a valid number
return value; return value;
} }
} }
$('.close').click(function(){ $('.close').click(function() {
$('#table_data').empty(); $('#table_data').empty();
}) })
$(document).ready(function(){ $(document).ready(function() {
$('#tickets-table').DataTable({ $('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" + dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", "<'row'<'col-sm-5'i><'col-sm-7'p>>",
"buttons": [{ "buttons": [{
@ -519,11 +601,10 @@ dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
language: { language: {
search: "_INPUT_", search: "_INPUT_",
searchPlaceholder: "Search..." searchPlaceholder: "Search..."
}, },
paging: true , paging: true,
// pagingType: 'full_numbers' // pagingType: 'full_numbers'
}); });
});
});
</script> </script>

View File

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

View File

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