Revert "CHANGE_TRUNCATED_ADDITION_ENDORSEMENT_ID_AND_OTHERS : RV"
This reverts commit 78f8e40175.
This commit is contained in:
parent
78f8e40175
commit
bf2a4f2045
@ -1091,7 +1091,7 @@ class ClientController extends AdminController
|
||||
$data['reminder_date'] = null;
|
||||
}
|
||||
|
||||
$data['created_by'] = get_session_userid();
|
||||
$data['created_by'] = get_session_userid();
|
||||
|
||||
$policy_tranction_data = [
|
||||
|
||||
@ -3842,7 +3842,7 @@ class ClientController extends AdminController
|
||||
|
||||
// dd($this->request);
|
||||
// $employeeRestController = new EmployeeServiceController();
|
||||
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 721]);
|
||||
// $employeeRestController->employeesEnrollmentInsert(['file_id' => 721]);
|
||||
|
||||
// $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]);
|
||||
|
||||
@ -3871,33 +3871,6 @@ class ClientController extends AdminController
|
||||
// $empServiceController = new EmployeeServiceController();
|
||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '319']);
|
||||
// dd($res);
|
||||
|
||||
// $EmpDataServiceController = new EmpDataServiceController();
|
||||
// $EmpDataServiceController->importInceptionFileValidation(['file_id' => 160]);
|
||||
|
||||
$EmpDataServiceController = new EmpDataServiceController();
|
||||
// $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 162]);
|
||||
// $EmpDataServiceController->importInceptionFileValidation(['file_id' => 162]);
|
||||
// $EmpDataServiceController->importDeletionValidation(['file_id' => 171]);
|
||||
// $EmpDataServiceController->importDeletionUpdateEndorsementID(['file_id' => 171]);
|
||||
$array = [
|
||||
"employeeIds" => ["12800", "12798", "12797", "12799"],
|
||||
"client_id" => "159",
|
||||
"client_policy_id" => "336",
|
||||
"client_branch_id" => "126",
|
||||
"cd_ac_no" => "Apple_123",
|
||||
"endorsement_no" => "ENDORSEMENT_ID",
|
||||
"count" => 4,
|
||||
"event_name" => "deletion",
|
||||
"policy_name" => "GMC",
|
||||
"user_id" => "1"
|
||||
];
|
||||
|
||||
$EmpDataServiceController->cashDepositCalculationForDeletion($array);
|
||||
|
||||
// $employeeRestController = new EmployeeServiceController();
|
||||
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 757]);
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -169,13 +169,13 @@ class EmpDataServiceController extends BaseController
|
||||
$cash_balance['balance'] = $balance['opening_bal'];
|
||||
}
|
||||
|
||||
// Calculate the total amount from the objects
|
||||
$totals = 0;
|
||||
foreach ($objects as $item) {
|
||||
$totals = $totals + $item->total;
|
||||
}
|
||||
|
||||
$totals = round($totals, 2);
|
||||
// Calculate the total amount from the objects
|
||||
$totals = 0;
|
||||
foreach ($objects as $item) {
|
||||
$totals = $totals + $item->total;
|
||||
}
|
||||
|
||||
$totals = round($totals, 2);
|
||||
|
||||
if($export_data['insurer_or_tpa'] == 'insurer') //check CD amt related issue for only insurer, not tpa
|
||||
{
|
||||
@ -423,18 +423,7 @@ class EmpDataServiceController extends BaseController
|
||||
'db_column_name' => 'total'
|
||||
]
|
||||
];
|
||||
|
||||
//for addition and dependent addition adding a ENDORSEMENT NO column
|
||||
if(in_array($export_data['event_type'], ['addition', 'dependent_addition'])){
|
||||
$excel_header_columns[] = [
|
||||
'column_index' => 18,
|
||||
'column_name' => 'ENDORSEMENT NO',
|
||||
'db_column_name' => ''
|
||||
];
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
// get excel export format structure array
|
||||
// $template_json = $this->clientPolicyModel
|
||||
// ->select('insurer_excel_export_template.jsoncolumns')
|
||||
@ -1289,7 +1278,6 @@ class EmpDataServiceController extends BaseController
|
||||
$this->myLogger->logme('info', 'Inception File Validation -- Function called');
|
||||
|
||||
$file_id = $params['file_id'];
|
||||
// dd($file_id);
|
||||
|
||||
$this->myLogger->logme('error', 'Inception File Validation -- Batch File Table Primary ID : {data}', ['data' => $file_id]);
|
||||
|
||||
@ -1322,36 +1310,30 @@ class EmpDataServiceController extends BaseController
|
||||
// array_pop($excel_data);
|
||||
|
||||
$inceptionHeader = [
|
||||
'S.No',
|
||||
'NAME OF EMP/DEP',
|
||||
'EMP ID',
|
||||
// 'EMP/DEP TYPE',
|
||||
// 'RELATIONSHIP CODE',
|
||||
'DOB',
|
||||
'GENDER',
|
||||
'PRE EXISTING AILMENTS',
|
||||
'BASIC COVER SI',
|
||||
'DATE OF COVERAGE',
|
||||
'AGE',
|
||||
'RELATIONSHIP',
|
||||
'REMARKS',
|
||||
'POLICY END DATE',
|
||||
'NO OF DAYS',
|
||||
'TPA ID',
|
||||
'UHID',
|
||||
// 'PREMIUM',
|
||||
'PRO RATA PREMIUM',
|
||||
'GST',
|
||||
'TOTAL AMOUNT',
|
||||
];
|
||||
'S.No',
|
||||
'NAME OF EMP/DEP',
|
||||
'EMP ID',
|
||||
// 'EMP/DEP TYPE',
|
||||
// 'RELATIONSHIP CODE',
|
||||
'DOB',
|
||||
'GENDER',
|
||||
'PRE EXISTING AILMENTS',
|
||||
'BASIC COVER SI',
|
||||
'DATE OF COVERAGE',
|
||||
'AGE',
|
||||
'RELATIONSHIP',
|
||||
'REMARKS',
|
||||
'POLICY END DATE',
|
||||
'NO OF DAYS',
|
||||
'TPA ID',
|
||||
'UHID',
|
||||
// 'PREMIUM',
|
||||
'PRO RATA PREMIUM',
|
||||
'GST',
|
||||
'TOTAL AMOUNT'
|
||||
];
|
||||
|
||||
if(in_array($file['event_type'], ['addition', 'dependent_addition'])){
|
||||
$inceptionHeader[] = 'ENDORSEMENT NO';
|
||||
}
|
||||
|
||||
// dd($inceptionHeader);
|
||||
foreach ($inceptionHeader as $key => $value) {
|
||||
|
||||
if($excel_header[$key] != $value){
|
||||
$data = [
|
||||
'status' => 'failed-5',
|
||||
@ -1370,9 +1352,47 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
$emp_count = count($excel_data);
|
||||
|
||||
//get the employee data for excel file validation
|
||||
$employee_data = $this->employeePolicyModel->getInceptionEmployeeDataForExportExcel($ref_data, 1);
|
||||
|
||||
// dd($employee_data, $excel_data);
|
||||
// ->select('
|
||||
|
||||
// employee_polices.id as emp_policy_id,
|
||||
// employees.name AS emp_name,
|
||||
// employees.emp_code AS emp_code,
|
||||
// "Has Define" as emp_type,
|
||||
// employees.relationship_code AS emp_relationship_code,
|
||||
// employees.dob AS emp_dob,
|
||||
// employees.gender AS emp_gender,
|
||||
// employee_polices.pre_existing_alignments,
|
||||
// employee_polices.basic_cover_si,
|
||||
// employee_polices.date_of_coverage,
|
||||
// TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
|
||||
// employees.relationship AS emp_relationship,
|
||||
// employees.change_event AS change_event,
|
||||
// employee_polices.policy_end_date,
|
||||
// employee_polices.days,
|
||||
// employee_polices.tpa_id,
|
||||
// employee_polices.uhid,
|
||||
// employee_polices.premium,
|
||||
// employee_polices.rata_premimum,
|
||||
// employee_polices.gst,
|
||||
// (employee_polices.rata_premimum + employee_polices.gst) AS total
|
||||
// ')
|
||||
|
||||
// ->join('employees', 'employees.id = employee_polices.employee_id')
|
||||
// ->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
// ->where('employees.client_id', $client_id)
|
||||
// ->where('employees.client_branch_id', $client_branch_id)
|
||||
// ->where("employee_polices.{$id} IS NULL OR employee_polices.{$id} = ''")
|
||||
// ->where('employee_polices.is_active', 1)
|
||||
// ->where('employee_polices.status', 'active')
|
||||
// ->where('employees.is_active', 1)
|
||||
// ->where('employees.emp_status', 'active')
|
||||
// ->findAll();
|
||||
|
||||
|
||||
|
||||
if ($employee_data == null || empty($employee_data)) {
|
||||
|
||||
if ($insurer_or_tpa == 'tpa') {
|
||||
@ -1405,6 +1425,7 @@ class EmpDataServiceController extends BaseController
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', 'Inception File Validation -- UHID or TPAID already updated or the uploadedfile is not correct');
|
||||
|
||||
}
|
||||
|
||||
$excel_data_count = count($excel_data);
|
||||
@ -1425,6 +1446,7 @@ class EmpDataServiceController extends BaseController
|
||||
$this->myLogger->logme('error', 'Inception File Validation -- excel file count partially : {data}', ['data' => $partially_updated_data]);
|
||||
}
|
||||
|
||||
|
||||
if ($emp_data_count < $excel_data_count) {
|
||||
|
||||
$data = [
|
||||
@ -1702,7 +1724,6 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
$file_id = $params['file_id'];
|
||||
$file = $this->batchFileModel->find($file_id);
|
||||
// dd($file);
|
||||
|
||||
if (!$file) {
|
||||
|
||||
@ -1735,20 +1756,22 @@ class EmpDataServiceController extends BaseController
|
||||
->first();
|
||||
|
||||
$get_policy_type = $this->clientPolicyModel
|
||||
->select('client_policy.*, policy_type.policy_type')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left')
|
||||
->select('policy_type.policy_type, policies.policy_type_id as policy_type_id')
|
||||
->join('policies', 'policies.id = client_policy.policy_id')
|
||||
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
||||
->where('client_policy.id', $client_policy_id)
|
||||
->first();
|
||||
|
||||
// dd($get_policy_type);
|
||||
|
||||
$status_val = 'success';
|
||||
if ($status == 'in-progress-partially') {
|
||||
|
||||
$status_val = 'partially success';
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', 'Inception Update TPA and UHID -- file name : {data}', ['data' => $file['file_name']]);
|
||||
|
||||
|
||||
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
|
||||
$excel_data = $this->readExcelFileToArray($file_name_with_path);
|
||||
unset($excel_data[0]); // Remove header row
|
||||
@ -1759,15 +1782,10 @@ class EmpDataServiceController extends BaseController
|
||||
$emp_details = [];
|
||||
$tpa_id = [];
|
||||
$uhid = [];
|
||||
$emp_endorsement_table_data = [];
|
||||
$enrollment_file_id = null;
|
||||
$endorsement_id = null;
|
||||
|
||||
$emp_count = count($excel_data);
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
// print_rr($excel_data); die;
|
||||
|
||||
foreach ($excel_data as $key => $value) {
|
||||
|
||||
$name = $value[1];
|
||||
@ -1807,54 +1825,11 @@ class EmpDataServiceController extends BaseController
|
||||
$emp_details[] = array('id' => $result['id'], 'tpa_id' => $value[13], 'uhid' => $value[14]);
|
||||
}
|
||||
|
||||
//for addition and dependent_addition endorsement , endorsement_id update functionality
|
||||
if(in_array($file['event_type'], ['addition', 'dependent_addition']) && isset($value[18])){
|
||||
|
||||
$action = 'a';
|
||||
if($file['event_type'] == "dependent_addition"){
|
||||
$action = 'da';
|
||||
}
|
||||
|
||||
$endorsement_id = $value[18];
|
||||
|
||||
$result_for_endorsement = $this->empEndorsementModel
|
||||
->select('emp_endorsement.*, employees.id as emp_id, employee_polices.id as emp_policy_id')
|
||||
->join('employee_polices', 'employee_polices.id = emp_endorsement.pk')
|
||||
->join('employees', 'employees.emp_code = emp_endorsement.emp_code')
|
||||
->where('employees.emp_code', $emp_code)
|
||||
->where('employees.name', $name)
|
||||
->where('employees.client_id', $client_id)
|
||||
->where('employees.client_branch_id', $client_branch_id)
|
||||
->where('emp_endorsement.actions', $action)
|
||||
->where('employee_polices.client_policy_id', $client_policy_id)
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employee_polices.status', 'active')
|
||||
->where('employees.is_active', 1)
|
||||
->where('employees.emp_status', 'active')
|
||||
->where('(emp_endorsement.endorsement_id IS NULL OR emp_endorsement.endorsement_id = "")')
|
||||
->groupBy('emp_endorsement.group_key')
|
||||
->first();
|
||||
|
||||
if (!empty($result_for_endorsement) && count($result_for_endorsement)) {
|
||||
$enrollment_file_id = $result_for_endorsement['file_id']; //files table primary key
|
||||
$emp_endorsement_table_data[] = array('id' => $result_for_endorsement['id'], 'group_key' => $result_for_endorsement['group_key'], 'endorsement_id' => $value[18], 'status' => 'complete');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// dd($emp_endorsement_table_data, $enrollment_file_id);
|
||||
|
||||
//update the employee policy data (TPAID or UHID)
|
||||
$return = $this->employeePolicyModel->bulkUpdate($emp_details);
|
||||
|
||||
if(in_array($file['event_type'], ['addition', 'dependent_addition']) && !empty($emp_endorsement_table_data)){
|
||||
$this->employeePolicyModel->updateEmpEndorsementAddition($emp_endorsement_table_data);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
}
|
||||
|
||||
// Update batch file status and amount
|
||||
$this->batchFileModel->update($file_id, [
|
||||
'count' => $emp_count,
|
||||
@ -1890,7 +1865,7 @@ class EmpDataServiceController extends BaseController
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
|
||||
'endorsement_no' => $endorsement_id,
|
||||
'endorsement_no' => null,
|
||||
'client_branch_id' => $client_branch_id,
|
||||
'count' => $emp_count,
|
||||
'event_name' => $file['event_type'],
|
||||
@ -2281,7 +2256,6 @@ class EmpDataServiceController extends BaseController
|
||||
$emp_details = [];
|
||||
$endorsement_id = [];
|
||||
$endorsement_details = [];
|
||||
$enrollment_file_id = null;
|
||||
|
||||
$emp_count = count($excel_data);
|
||||
$db = \Config\Database::connect();
|
||||
@ -2294,6 +2268,7 @@ class EmpDataServiceController extends BaseController
|
||||
$endorsement_id[] = $value[10];
|
||||
$uhid = $value[1];
|
||||
|
||||
|
||||
$result = $this->empEndorsementModel
|
||||
->select('emp_endorsement.*, employees.id as emp_id')
|
||||
->join('employees', 'employees.id = emp_endorsement.pk')
|
||||
@ -2314,8 +2289,8 @@ class EmpDataServiceController extends BaseController
|
||||
->first();
|
||||
|
||||
if (isset($result['id']) && $result['id'] !== null) {
|
||||
|
||||
// return $result;
|
||||
$enrollment_file_id = $result['file_id'];
|
||||
$emp_details[] = array('id' => $result['emp_id'], $result['field_name'] => $value[8]);
|
||||
$endorsement_details[] = array('group_key' => $result['group_key'], 'id' => $result['id'], 'endorsement_id' => $value[10], 'status' => 'complete');
|
||||
}
|
||||
@ -2326,7 +2301,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
$this->empEndorsementModel->updateBatch($endorsement_details, 'group_key');
|
||||
$this->employeePolicyModel->bulkUpdateForCorrection($emp_details);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id[0], $enrollment_file_id);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id[0]);
|
||||
|
||||
|
||||
// Update batch file status and amount
|
||||
@ -2840,7 +2815,6 @@ class EmpDataServiceController extends BaseController
|
||||
$employeeIds = [];
|
||||
$emp_details = [];
|
||||
$endorsement_id = '';
|
||||
$enrollment_file_id = '';
|
||||
$endorsement_details = [];
|
||||
$totals = 0;
|
||||
|
||||
@ -2872,8 +2846,6 @@ class EmpDataServiceController extends BaseController
|
||||
->first();
|
||||
|
||||
if (isset($result['id']) && $result['id'] !== null) {
|
||||
|
||||
$enrollment_file_id = $result['file_id'];
|
||||
$emp_policy_ids[] = array('id' => $result['emp_policy_id'], 'is_active' => 0);
|
||||
$employeeIds[] = $result['emp_policy_id'];
|
||||
$endorsement_details[] = array('id' => $result['id'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[19], 'status' => 'complete');
|
||||
@ -2933,7 +2905,7 @@ class EmpDataServiceController extends BaseController
|
||||
// }
|
||||
|
||||
$this->employeePolicyModel->bulkUpdateForEndorsement($endorsement_details);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id);
|
||||
|
||||
|
||||
// Update batch file status and amount
|
||||
@ -3018,7 +2990,7 @@ class EmpDataServiceController extends BaseController
|
||||
// array_pop($excel_data);
|
||||
|
||||
$headers = ['S.No','EMP ID','EMP NAME','DOB','GENDER','RELATIONSHIP','SUM INSURED','Date of Leaving','Policy End Date','No Of Days','Premium','Pro Rata Premium','GST','Total','Claim Status','ENDORSEMENT_ID'];
|
||||
// dd($headers, $excel_header);
|
||||
|
||||
|
||||
foreach ($headers as $key => $value) {
|
||||
if($excel_header[$key] != $value){
|
||||
@ -3350,7 +3322,6 @@ class EmpDataServiceController extends BaseController
|
||||
$employee_policy_table_data = [];
|
||||
$employee_policy_table_primaryKey = [];
|
||||
$endorsement_id = '';
|
||||
$enrollment_file_id = null; //files table primary key
|
||||
|
||||
$totals = 0;
|
||||
|
||||
@ -3371,15 +3342,12 @@ class EmpDataServiceController extends BaseController
|
||||
'emp_name' => $emp_name,
|
||||
'emp_code' => $emp_code
|
||||
];
|
||||
|
||||
$result = $this->employeePolicyModel->fetchEmpEndorsementData($fetch_data);
|
||||
// dd($result, db_connect()->getLastQuery());
|
||||
|
||||
if (isset($result['emp_endorsement_primarykey']) && $result['emp_endorsement_primarykey'] !== null) {
|
||||
|
||||
$enrollment_file_id = $result['file_id']; //files table primary key
|
||||
$employee_policy_table_primaryKey[] = $result['emp_policy_primarykey']; //for cash deposite
|
||||
$employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => $result['date_of_exit'], 'reason_for_exit' => $result['reason_for_exit'], 'claim_status' => $result['claim_status'], 'status' => $result['status']);
|
||||
$employee_policy_table_data[] = array('id' => $result['emp_policy_primarykey'], 'date_of_exit' => $result['date_of_exit'], 'reason_for_exit' => $result['reason_for_exit'], 'status' => $result['status']);
|
||||
// $employees_table_data[] = array('id' => $result['employees_id'], 'emp_status' => $result['status']);
|
||||
$emp_endorsement_table_data[] = array('id' => $result['emp_endorsement_primarykey'], 'group_key' => $result['group_key'], 'endorsement_id' => $value[15], 'status' => 'complete');
|
||||
}
|
||||
@ -3392,6 +3360,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
// dd($employees_table_data, $emp_endorsement_table_data, $employee_policy_table_data, $employee_policy_table_primaryKey, $totals, $emp_count);
|
||||
|
||||
|
||||
// Check if $employees_table_data is null or empty
|
||||
// if (empty($employees_table_data)) {
|
||||
// return ['status' => 'error', 'message' => 'Employees table data is empty or null.'];
|
||||
@ -3410,7 +3379,7 @@ class EmpDataServiceController extends BaseController
|
||||
// $this->employeeModel->updateBatch($employees_table_data, 'id');
|
||||
$this->employeePolicyModel->updateBatch($employee_policy_table_data, 'id');
|
||||
$this->employeePolicyModel->bulkUpdateForEndorsement($emp_endorsement_table_data);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id);
|
||||
|
||||
// Update batch file status and amount
|
||||
$this->batchFileModel->update($file_id, [
|
||||
@ -3419,12 +3388,12 @@ class EmpDataServiceController extends BaseController
|
||||
'amount' => $rounded_totals,
|
||||
]);
|
||||
|
||||
|
||||
$this->myLogger->logme('error', 'Deletion Update Endorsement ID -- Employee count : {data}', ['data' => $emp_count]);
|
||||
$this->myLogger->logme('error', 'Deletion Update Endorsement ID -- Batch File status : {data}', ['data' => $status_val]);
|
||||
|
||||
//call the cash deposite function
|
||||
if ($file['insurer_or_tpa'] == 'insurer') {
|
||||
|
||||
$policy_name = $this->getPolicyNameUsingClientPolicyId($client_policy_id);
|
||||
$job_details = new Jobs();
|
||||
$r = Jobs::addJob(['job_name' => 'cashDepositCalculationForDeletion', 'payload' => [
|
||||
@ -4052,11 +4021,10 @@ class EmpDataServiceController extends BaseController
|
||||
WHERE
|
||||
employee_polices.id IN (" . implode(',', $arrayData['employeeIds']) . ")
|
||||
AND emp_endorsement.pk IN (" . implode(',', $arrayData['employeeIds']) . ")
|
||||
AND employee_polices.claim_status = 0
|
||||
AND emp_endorsement.field_name = 'date_of_exit'
|
||||
")->getRow();
|
||||
|
||||
dd(db_connect()->getLastQuery(), $amount);
|
||||
// dd(db_connect()->getLastQuery(), $amount);
|
||||
|
||||
if($amount){
|
||||
|
||||
@ -4550,7 +4518,7 @@ class EmpDataServiceController extends BaseController
|
||||
$this->messageModel->insert($msg_data);
|
||||
}
|
||||
|
||||
public function storeEndorsementNumber($file_id, $endorsement_no, $enrollment_file_id)
|
||||
public function storeEndorsementNumber($file_id, $endorsement_no)
|
||||
{
|
||||
// Log the function entry with input parameters
|
||||
$this->myLogger->logme('error', "storeEndorsementNumber --- Starting function with file_id: $file_id and endorsement_no: $endorsement_no");
|
||||
@ -4586,7 +4554,6 @@ class EmpDataServiceController extends BaseController
|
||||
'insurer_id' => $filedata['insurer_id'],
|
||||
'tpa_id' => $filedata['tpa_id'],
|
||||
'endorsement_no' => $endorsement_no,
|
||||
'file_id' => $enrollment_file_id,
|
||||
'endorsement_type' => $filedata['event_type'],
|
||||
'created_by' => $filedata['created_by'],
|
||||
]);
|
||||
|
||||
@ -1236,19 +1236,17 @@ class EmployeeController extends AdminController
|
||||
$loggedInUserID = get_session_userid();
|
||||
|
||||
$policy_data = $this->clientPolicyModel->where('id', $client_policy_id)->first();
|
||||
|
||||
$cd_tranction = $this->cashDepositModel
|
||||
->where('client_id', $client_id) //client
|
||||
->where('insurer_id', $policy_data['insurer_id']) //insurer
|
||||
->where('event_name',$file['action']) //event
|
||||
->where('client_policy_id', $client_policy_id)//policy
|
||||
->where('client_id', $client_id)
|
||||
->where('insurer_id', $policy_data['insurer_id'])
|
||||
->where('event_name',$file['action'])
|
||||
->where('client_policy_id', $client_policy_id)
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
|
||||
|
||||
// $file['action'] = 'si_enhancement';
|
||||
// $result = [];
|
||||
// dd($file);
|
||||
// !dd($file);
|
||||
if ($file['action'] == 'inception' || $file['action'] == 'dependent_addition' || $file['action'] == 'addition' || $file['action'] == 'enrollment' || $file['action'] == 'missed_inception') {
|
||||
|
||||
|
||||
@ -1258,7 +1256,6 @@ class EmployeeController extends AdminController
|
||||
$result = $this->employeeModel->getEmpListByFileId(file_id: $file_id, emp_status: ['active'], policy_status: ['active']);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
// ~dd($result);
|
||||
if (count($result) && $role_id == null) {
|
||||
if(get_role_id() == 1 || get_role_id() == 5){
|
||||
@ -1268,57 +1265,18 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
} else {
|
||||
|
||||
$this->myLogger->logme('error', 'TRUNCATED STARTED WITH ADMIN OR HEAD PERMISSION');
|
||||
$this->myLogger->logme('error', 'Event Type : -- {data} --', ['data' => $file['action']]);
|
||||
|
||||
|
||||
// GET THE CD AMOUND
|
||||
//get cd amount for the particular file id to reverse entry to the cash deposite
|
||||
$cd_amount = $cd_tranction['amount'];
|
||||
if(in_array($file['action'], ['addition', 'dependent_addition'])){
|
||||
$cd_amount_total = $this->employeePolicyModel->getAdditionDataForTruncated($file_id, $file['action']);
|
||||
// dd($cd_amount_total);
|
||||
$cd_amount = $cd_amount_total['total'];
|
||||
|
||||
$this->myLogger->logme('error', 'Addition or Dependent Addition CD Amount : {data}', ['data' => $cd_amount]);
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', 'CD Amount : {data}', ['data' => $cd_amount]);
|
||||
|
||||
|
||||
if($file['action'] != 'enrollment')
|
||||
{
|
||||
//STEP: 1 - Update employee policy table
|
||||
{
|
||||
//update emp and emp plocies
|
||||
$db = db_connect();
|
||||
$query = "
|
||||
UPDATE employee_polices
|
||||
JOIN employees ON employees.id = employee_polices.employee_id
|
||||
SET employee_polices.status = 'truncated', employee_polices.is_active = 0
|
||||
WHERE employees.file_id = $file_id
|
||||
";
|
||||
|
||||
$query = "UPDATE employees JOIN employee_polices ON employees.id = employee_polices.employee_id and employees.file_id = $file_id SET employees.emp_status = 'truncated', employee_polices.status = 'truncated', employees.is_active = 0,employee_polices.is_active = 0 WHERE employees.file_id = $file_id";
|
||||
$db->query($query);
|
||||
$affectedRows = $db->affectedRows();
|
||||
$this->myLogger->logme('error', 'employee_polices table update query : {data}', ['data' => $query]);
|
||||
$this->myLogger->logme('error', 'employee_polices table updated - Affected Rows : {data}', ['data' => $affectedRows]);
|
||||
// print_r($db->getLastQuery()); die;
|
||||
// $affectedRows = 10;
|
||||
|
||||
//STEP:2 - Update emp_endorsement Table
|
||||
//update truncated status and is_active 0 to the Emp_endorsement table
|
||||
if(in_array($file['action'], ['addition', 'dependent_addition'])){
|
||||
$this->empEndorsementModel->where('file_id', $file_id)
|
||||
->set(['status' => 'truncated','is_active' => 0])
|
||||
->update();
|
||||
|
||||
$this->myLogger->logme('error', 'emp_endorsement table updated');
|
||||
}
|
||||
|
||||
//STEP:3 - Update files table
|
||||
//update file status
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
|
||||
$this->myLogger->logme('error', 'files table updated');
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1358,12 +1316,7 @@ class EmployeeController extends AdminController
|
||||
$db = db_connect();
|
||||
$emp_codes = '(' . implode(',', array_map(fn($code) => "'$code'", $emp_codes)) . ')';
|
||||
$dependent_policies = '(' . implode(',', $dependent_policies) . ')';
|
||||
$query = "
|
||||
UPDATE employee_polices
|
||||
JOIN employees ON employees.id = employee_polices.employee_id and employees.emp_code in $emp_codes
|
||||
SET employee_polices.status = 'truncated', employee_polices.is_active = 0
|
||||
WHERE employee_polices.client_policy_id in $dependent_policies
|
||||
";
|
||||
$query = "UPDATE employee_polices JOIN employees ON employees.id = employee_polices.employee_id and employees.emp_code in $emp_codes SET employee_polices.status = 'truncated', employee_polices.is_active = 0 WHERE employee_polices.client_policy_id in $dependent_policies";
|
||||
$db->query($query);
|
||||
$affectedRows = $db->affectedRows();
|
||||
|
||||
@ -1373,11 +1326,10 @@ class EmployeeController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
//FINAL STEP - Update reverse entry in cash_deposite table
|
||||
if($cd_tranction){
|
||||
|
||||
$cd_data = [
|
||||
'amount' => $cd_amount,
|
||||
'amount' => $cd_tranction['amount'],
|
||||
'sub_type_id' => 8,
|
||||
'endorsement_no' => null,
|
||||
'insurer_id' =>$policy_data['insurer_id'],
|
||||
@ -1387,17 +1339,12 @@ class EmployeeController extends AdminController
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'cd_ac_no' => $policy_data['cd_ac_no'] ?? null,
|
||||
'cd_ac_pk' => $policy_data['cd_ac_pk'] ?? null,
|
||||
'event_name' => $file['action'],
|
||||
];
|
||||
|
||||
$response = DepositHelper::saveDeposit($cd_data, $loggedInUserID);
|
||||
$this->myLogger->logme('error', 'cash_deposite table updated -- cd transaction');
|
||||
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', 'SUCCESSFULLY TRUNCATED');
|
||||
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => round($affectedRows / 2)], 200);
|
||||
}
|
||||
|
||||
@ -1414,57 +1361,23 @@ class EmployeeController extends AdminController
|
||||
|
||||
// print_r($this->empEndorsementModel->getLastQuery());
|
||||
// echo $res[0]->count;die();
|
||||
|
||||
if ($res[0]->count == 0 || $role_id == 5 || $role_id == 1) {
|
||||
|
||||
$this->myLogger->logme('error', 'TRUNCATED STARTED WITH ADMIN OR HEAD PERMISSION');
|
||||
$this->myLogger->logme('error', 'Event Type : -- {data} --', ['data' => $file['action']]);
|
||||
|
||||
$transaction_type = 'Credit';
|
||||
$cd_amount = $cd_tranction['amount'];
|
||||
|
||||
if($file['action'] == 'deletion'){
|
||||
$transaction_type = 'Debit';
|
||||
//get cd amount for the particular file id to reverse entry to the cash deposite for only deletion
|
||||
$cd_amount_total = $this->employeePolicyModel->getDeletionDataForTruncated($file['id']);
|
||||
$totalSum = array_sum(array_column($cd_amount_total, 'total'));
|
||||
$cd_amount = $totalSum;
|
||||
|
||||
$this->myLogger->logme('error', 'Deletion CD Amount : {data}', ['data' => $cd_amount]);
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', 'Endorsemnt CD Amount : {data}', ['data' => $cd_amount]);
|
||||
|
||||
|
||||
//STEP 1:
|
||||
//update truncated status to the Emp_endorsement table
|
||||
//update truncated status to db
|
||||
$this->empEndorsementModel->where('file_id', $file_id)
|
||||
->set(['status' => 'truncated','is_active' => 0])
|
||||
->update();
|
||||
|
||||
$this->myLogger->logme('error', 'emp_endorsement table updated');
|
||||
|
||||
//STEP 2:
|
||||
if($file['action'] == 'deletion') {
|
||||
//update the employee policy table reverse the data
|
||||
$this->employeePolicyModel->updateEmployeePolicyTruncateReverse($file_id);
|
||||
$this->myLogger->logme('error', 'employee_polices table updated for deletion');
|
||||
}
|
||||
|
||||
if($file['action'] == 'correction'){
|
||||
|
||||
}
|
||||
|
||||
// STEP 3:
|
||||
//update files table status to "truncated"
|
||||
//update file status
|
||||
$this->fileModel->where('id', $file_id)->set(['status' => 'truncated'])->update();
|
||||
$this->myLogger->logme('error', 'files table updated');
|
||||
|
||||
|
||||
if($cd_tranction && $file['action'] != 'correction'){
|
||||
|
||||
$transaction_type = 'Credit';
|
||||
if($file['action'] == 'deletion'){
|
||||
$transaction_type = 'Debit';
|
||||
}
|
||||
|
||||
$cd_data = [
|
||||
'amount' => $cd_amount,
|
||||
'amount' => $cd_tranction['amount'],
|
||||
'sub_type_id' => 8,
|
||||
'endorsement_no' => null,
|
||||
'insurer_id' =>$policy_data['insurer_id'],
|
||||
@ -1474,19 +1387,13 @@ class EmployeeController extends AdminController
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'cd_ac_no' => $policy_data['cd_ac_no'] ?? null,
|
||||
'cd_ac_pk' => $policy_data['cd_ac_pk'] ?? null,
|
||||
'event_name' => $file['action'],
|
||||
];
|
||||
|
||||
$response = DepositHelper::saveDeposit($cd_data, $loggedInUserID);
|
||||
$this->myLogger->logme('error', 'cash_deposite table updated -- cd transaction');
|
||||
|
||||
}
|
||||
|
||||
$this->myLogger->logme('error', 'SUCCESSFULLY TRUNCATED');
|
||||
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => 'success'], 200);
|
||||
|
||||
} else {
|
||||
if(get_role_id() == 1 || get_role_id() == 5){
|
||||
return $this->respond(['role' => get_role_id(), 'dataStatus' => false, 'code' => 404, 'message' => 'File data already processed. Do you want to truncate data from uploaded file?'], 200);
|
||||
|
||||
@ -864,12 +864,11 @@ class LeadsController extends BaseController
|
||||
{
|
||||
$lead_id = $params['lead_id'];
|
||||
$lead_data = $this->leadsModel->find($lead_id);
|
||||
$file_name_with_path = WRITEPATH . "/uploads/lead_files/" . $lead_data['file_name'];
|
||||
|
||||
if (!$lead_data) {
|
||||
return ['status' => 'failed', 'message' => 'Lead data not found'];
|
||||
}
|
||||
if ($lead_data['file_name']) {
|
||||
$file_name_with_path = WRITEPATH . "/uploads/lead_files/" . $lead_data['file_name'];
|
||||
// $file_name_with_path = WRITEPATH . "/uploads/lead_files/NonPrintableCharacters.xlsx";
|
||||
|
||||
//check physical file
|
||||
|
||||
@ -1313,31 +1313,12 @@ class MasterController extends AdminController
|
||||
->where('id', $id)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
$db = db_connect();
|
||||
$builder = $db->table('cd_master');
|
||||
$builder->select('cd_master.cd_ac_no, cd_master.id, COUNT(cash_deposit.cd_ac_no) AS cd_ac_no_count_cd_tranction');
|
||||
$builder->join('cash_deposit', 'cash_deposit.cd_ac_pk = cd_master.id');
|
||||
$builder->where('cash_deposit.is_active', 1);
|
||||
$builder->where('cd_master.is_active', 1);
|
||||
$builder->where('cd_master.id', $id);
|
||||
$builder->groupBy('cd_master.id');
|
||||
|
||||
$query = $builder->get();
|
||||
$result = $query->getResultArray();
|
||||
|
||||
// print_r($result); die;
|
||||
|
||||
$count = 0;
|
||||
if(isset($result[0])){
|
||||
$count = $result[0]['cd_ac_no_count_cd_tranction'];
|
||||
}
|
||||
|
||||
// convert the date formate 2000-01-01 to 01-01-2000
|
||||
// convert the date formate 2000-01-01 to 01-01-2000
|
||||
$cd_data['opening_date'] = date('d-m-Y', strtotime($cd_data['opening_date']));
|
||||
|
||||
if ($cd_data) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data, 'cd_transaction_count' => $count], 200);
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404], 200);
|
||||
}
|
||||
|
||||
@ -1160,7 +1160,7 @@ if (!function_exists('premium_calculation_manager'))
|
||||
{
|
||||
if($temp_slab_rates[0]['si_or_bp'] == 2)
|
||||
{
|
||||
$temp_si = $emp_data['basic_pay'] * $temp_slab_rates[0]['basic_multiplier'];
|
||||
$temp_si = $emp_data['basic_pay'] * $temp_slab_rates[0]['si_or_bp'];
|
||||
$temp_premium = ($temp_si * $temp_slab_rates[0]['multiplier']) / 1000;
|
||||
|
||||
$emp_data['policy_details']['basic_cover_si'] = $temp_si;
|
||||
|
||||
@ -65,37 +65,28 @@ class CDMasterModel extends Model
|
||||
{
|
||||
|
||||
$query = $this->db->table('cd_master')
|
||||
|
||||
->select('cd_master.*, clients.client_name, clients.short_name, insurers.name AS insurer_name, user_profiles.first_name AS user_name, IFNULL(cd_ac_counts.cd_ac_no_count, 0) AS cd_ac_no_count, IFNULL(cd_ac_counts_for_cdt.cd_ac_no_count_cd_tranction, 0) AS cd_ac_no_count_cd_tranction')
|
||||
->join('clients', 'clients.id = cd_master.client_id')
|
||||
->join('insurers', 'insurers.id = cd_master.insurer_id')
|
||||
->join('user_profiles', 'user_profiles.id = cd_master.created_by')
|
||||
->join(
|
||||
'(SELECT cd_master.cd_ac_no, cd_master.id, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count
|
||||
|
||||
FROM cd_master
|
||||
JOIN client_policy ON client_policy.cd_ac_pk = cd_master.id
|
||||
WHERE client_policy.is_active = 1
|
||||
AND cd_master.is_active = 1
|
||||
GROUP BY cd_master.id
|
||||
|
||||
) AS cd_ac_counts',
|
||||
|
||||
'cd_ac_counts.id = cd_master.id',
|
||||
'(SELECT cd_master.cd_ac_no, COUNT(client_policy.cd_ac_no) AS cd_ac_no_count
|
||||
FROM cd_master
|
||||
JOIN client_policy ON client_policy.cd_ac_no = cd_master.cd_ac_no
|
||||
WHERE client_policy.is_active = 1
|
||||
AND cd_master.is_active = 1
|
||||
GROUP BY cd_master.cd_ac_no) AS cd_ac_counts',
|
||||
'cd_ac_counts.cd_ac_no = cd_master.cd_ac_no',
|
||||
'left'
|
||||
)
|
||||
->join(
|
||||
'(SELECT cd_master.cd_ac_no, cd_master.id, COUNT(cash_deposit.cd_ac_no) AS cd_ac_no_count_cd_tranction
|
||||
|
||||
FROM cd_master
|
||||
JOIN cash_deposit ON cash_deposit.cd_ac_pk = cd_master.id
|
||||
WHERE cash_deposit.is_active = 1
|
||||
AND cd_master.is_active = 1
|
||||
GROUP BY cd_master.id
|
||||
|
||||
) AS cd_ac_counts_for_cdt',
|
||||
|
||||
'cd_ac_counts_for_cdt.id = cd_master.id',
|
||||
'(SELECT cd_master.cd_ac_no, COUNT(cash_deposit.cd_ac_no) AS cd_ac_no_count_cd_tranction
|
||||
FROM cd_master
|
||||
JOIN cash_deposit ON cash_deposit.cd_ac_no = cd_master.cd_ac_no
|
||||
WHERE cash_deposit.is_active = 1
|
||||
AND cd_master.is_active = 1
|
||||
GROUP BY cd_master.cd_ac_no) AS cd_ac_counts_for_cdt',
|
||||
'cd_ac_counts_for_cdt.cd_ac_no = cd_master.cd_ac_no',
|
||||
'left'
|
||||
)
|
||||
->where('cd_master.is_active', 1)
|
||||
|
||||
@ -806,26 +806,26 @@ class EmployeePolicyModel extends Model
|
||||
deletiondata.dateofexit,
|
||||
deletiondata.reasonforexit,
|
||||
deletiondata.status,
|
||||
deletiondata.claimstatus,
|
||||
|
||||
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
|
||||
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 THEN
|
||||
WHEN employee_polices.claim_status = 0 THEN
|
||||
ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2)
|
||||
ELSE
|
||||
0
|
||||
END AS pro_rata_premium,
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 THEN
|
||||
WHEN employee_polices.claim_status = 0 THEN
|
||||
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2)
|
||||
ELSE
|
||||
0
|
||||
END AS gst,
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 THEN
|
||||
WHEN employee_polices.claim_status = 0 THEN
|
||||
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) +
|
||||
(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2)
|
||||
ELSE
|
||||
@ -833,7 +833,7 @@ class EmployeePolicyModel extends Model
|
||||
END AS total,
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 THEN
|
||||
WHEN employee_polices.claim_status = 0 THEN
|
||||
'No claim'
|
||||
ELSE
|
||||
'Claim'
|
||||
@ -854,8 +854,7 @@ class EmployeePolicyModel extends Model
|
||||
MAX(CASE WHEN field_name = 'change_event' THEN new_value END) AS changeevent,
|
||||
MAX(CASE WHEN field_name = 'date_of_exit' THEN new_value END) AS dateofexit,
|
||||
MAX(CASE WHEN field_name = 'reason_for_exit' THEN new_value END) AS reasonforexit,
|
||||
MAX(CASE WHEN field_name = 'status' THEN new_value END) AS status,
|
||||
MAX(CASE WHEN field_name = 'claim_status' THEN new_value END) AS claimstatus
|
||||
MAX(CASE WHEN field_name = 'status' THEN new_value END) AS status
|
||||
FROM
|
||||
emp_endorsement
|
||||
WHERE
|
||||
@ -923,7 +922,6 @@ class EmployeePolicyModel extends Model
|
||||
ee.id as emp_endorsement_primarykey,
|
||||
ep.id as emp_policy_primarykey,
|
||||
e.id as employees_primarykey,
|
||||
ee.file_id,
|
||||
ee.group_key,
|
||||
(
|
||||
SELECT employees.id
|
||||
@ -951,12 +949,7 @@ class EmployeePolicyModel extends Model
|
||||
CASE
|
||||
WHEN ee.field_name = 'status' THEN ee.new_value
|
||||
END
|
||||
) AS status,
|
||||
MAX(
|
||||
CASE
|
||||
WHEN ee.field_name = 'claim_status' THEN ee.new_value
|
||||
END
|
||||
) AS claim_status
|
||||
) AS status
|
||||
FROM
|
||||
emp_endorsement AS ee
|
||||
JOIN employee_polices AS ep ON ep.id = ee.pk
|
||||
@ -966,7 +959,7 @@ class EmployeePolicyModel extends Model
|
||||
AND ep.client_policy_id = '$client_policy_id'
|
||||
AND e.client_branch_id = '$client_branch_id'
|
||||
AND ee.name = '$emp_name'
|
||||
AND ee.field_name IN ('date_of_exit', 'reason_for_exit', 'status', 'claim_status')
|
||||
AND ee.field_name IN ('date_of_exit', 'reason_for_exit', 'status')
|
||||
AND ep.is_active = 1
|
||||
AND ep.status = 'active'
|
||||
AND e.is_active = 1
|
||||
@ -1367,13 +1360,13 @@ class EmployeePolicyModel extends Model
|
||||
return "WHEN group_key = $id THEN $endorsement_id";
|
||||
}, $escapedIds, $escapedEndorsementIds);
|
||||
|
||||
// $caseStatus = array_map(function ($id, $status) {
|
||||
// return "WHEN status = $id THEN $status";
|
||||
// }, $escapedIds, $escapedStatuses);
|
||||
$caseStatus = array_map(function ($id, $status) {
|
||||
return "WHEN status = $id THEN $status";
|
||||
}, $escapedIds, $escapedStatuses);
|
||||
|
||||
// Convert cases to a string
|
||||
$caseEndorsementIdString = implode(' ', $caseEndorsementId);
|
||||
// $caseStatusString = implode(' ', $caseStatus);
|
||||
$caseStatusString = implode(' ', $caseStatus);
|
||||
|
||||
// Convert ids to a string
|
||||
$idsString = implode(', ', $escapedIds);
|
||||
@ -1383,12 +1376,10 @@ class EmployeePolicyModel extends Model
|
||||
UPDATE emp_endorsement
|
||||
SET
|
||||
endorsement_id = CASE {$caseEndorsementIdString} END,
|
||||
status = 'complete'
|
||||
status = CASE {$caseStatusString} END
|
||||
WHERE group_key IN ({$idsString})
|
||||
";
|
||||
|
||||
|
||||
// dd($sql);
|
||||
// Begin a transaction
|
||||
$this->db->transBegin();
|
||||
|
||||
@ -1405,7 +1396,6 @@ class EmployeePolicyModel extends Model
|
||||
// Otherwise, commit
|
||||
$this->db->transCommit();
|
||||
}
|
||||
// $this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
|
||||
return $this->db->getLastQuery();
|
||||
} catch (\Exception $e) {
|
||||
@ -1477,209 +1467,5 @@ class EmployeePolicyModel extends Model
|
||||
|
||||
}
|
||||
|
||||
//for truncate get deletion data
|
||||
public function getDeletionDataForTruncated($file_id)
|
||||
{
|
||||
|
||||
// Fetch the necessary details in a single query using JOINs
|
||||
$result = $this->db->table('files f')
|
||||
->select('i.deletion_add_day')
|
||||
->join('client_policy cp', 'cp.id = f.policy_id', 'left')
|
||||
->join('insurers i', 'i.id = cp.insurer_id', 'left')
|
||||
->where('f.id', $file_id)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
// Determine if one day should be added for deletion
|
||||
$add_one_day = (!empty($result) && $result['deletion_add_day'] == 1) ? 1 : 0;
|
||||
|
||||
|
||||
$query = $this->db->query("
|
||||
|
||||
SELECT DISTINCT
|
||||
|
||||
a.id as endorsement_primarykey,
|
||||
a.group_key,
|
||||
employee_polices.id as primaryKey,
|
||||
employees.name AS emp_name,
|
||||
employees.emp_code AS emp_code,
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employees.relationship AS emp_relationship,
|
||||
employees.relationship_code AS emp_relationship_code,
|
||||
employees.emp_type as emp_type,
|
||||
'D' as event_type_data,
|
||||
TIMESTAMPDIFF(YEAR, employees.dob, CURDATE()) AS emp_age,
|
||||
|
||||
employees.doj AS emp_doj,
|
||||
employees.mobile AS emp_mobile,
|
||||
employees.email_corporate AS emp_email_c,
|
||||
employees.email_personal AS emp_email_p,
|
||||
employees.band AS emp_grade,
|
||||
employees.designation AS emp_designation,
|
||||
employees.basic_pay AS emp_basic_pay,
|
||||
|
||||
employee_polices.basic_cover_si,
|
||||
employee_polices.uhid as uhid,
|
||||
employee_polices.policy_end_date,
|
||||
employee_polices.rata_premimum as premium,
|
||||
employee_polices.claim_status,
|
||||
|
||||
deletiondata.empstatus,
|
||||
deletiondata.changeevent,
|
||||
deletiondata.dateofexit,
|
||||
deletiondata.reasonforexit,
|
||||
deletiondata.status,
|
||||
deletiondata.claimstatus,
|
||||
|
||||
DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + '$add_one_day' AS no_of_days,
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 THEN
|
||||
ROUND((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365, 2)
|
||||
ELSE
|
||||
0
|
||||
END AS pro_rata_premium,
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 THEN
|
||||
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18, 2)
|
||||
ELSE
|
||||
0
|
||||
END AS gst,
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 THEN
|
||||
ROUND(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) +
|
||||
(((employee_polices.rata_premimum * (DATEDIFF(employee_polices.policy_end_date, deletiondata.dateofexit) + $add_one_day)) / 365) * 0.18), 2)
|
||||
ELSE
|
||||
0
|
||||
END AS total,
|
||||
|
||||
CASE
|
||||
WHEN deletiondata.claimstatus = 0 THEN
|
||||
'No claim'
|
||||
ELSE
|
||||
'Claim'
|
||||
END AS claim_status
|
||||
|
||||
FROM
|
||||
emp_endorsement a
|
||||
LEFT JOIN
|
||||
employee_polices ON a.pk = employee_polices.id
|
||||
LEFT JOIN
|
||||
employees ON employee_polices.employee_id = employees.id
|
||||
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
emp_code,
|
||||
group_key,
|
||||
MAX(CASE WHEN field_name = 'emp_status' THEN new_value END) AS empstatus,
|
||||
MAX(CASE WHEN field_name = 'change_event' THEN new_value END) AS changeevent,
|
||||
MAX(CASE WHEN field_name = 'date_of_exit' THEN new_value END) AS dateofexit,
|
||||
MAX(CASE WHEN field_name = 'reason_for_exit' THEN new_value END) AS reasonforexit,
|
||||
MAX(CASE WHEN field_name = 'status' THEN new_value END) AS status,
|
||||
MAX(CASE WHEN field_name = 'claim_status' THEN new_value END) AS claimstatus
|
||||
FROM
|
||||
emp_endorsement
|
||||
WHERE
|
||||
status != 'truncated'
|
||||
GROUP BY
|
||||
group_key
|
||||
|
||||
) AS deletiondata
|
||||
|
||||
ON a.emp_code = deletiondata.emp_code AND a.status != 'truncated'
|
||||
|
||||
WHERE a.file_id = {$file_id}
|
||||
AND a.actions = 'd'
|
||||
AND a.status != 'truncated'
|
||||
AND employee_polices.is_active = 1
|
||||
AND employees.is_active = 1
|
||||
group by group_key
|
||||
");
|
||||
|
||||
|
||||
$result = $query->getResultArray();
|
||||
// dd($this->db->getLastQuery(), $result);
|
||||
// dd($result);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
//for truncate get addition data
|
||||
public function getAdditionDataForTruncated($file_id, $event_type)
|
||||
{
|
||||
$action = "a";
|
||||
if($event_type == "dependent_addition"){
|
||||
$action = "da";
|
||||
}
|
||||
|
||||
$query = $this->db->query("
|
||||
|
||||
SELECT
|
||||
ROUND(SUM(ep.rata_premimum + ep.gst), 2) AS total
|
||||
FROM
|
||||
emp_endorsement ee
|
||||
JOIN
|
||||
employee_polices ep ON ee.pk = ep.id
|
||||
WHERE
|
||||
ee.file_id = $file_id
|
||||
AND ee.actions = '$action'
|
||||
AND ep.status != 'truncated'
|
||||
AND ee.status != 'truncated'
|
||||
AND ee.is_active = 1
|
||||
AND ep.is_active = 1;
|
||||
");
|
||||
|
||||
|
||||
$result = $query->getResultArray();
|
||||
// dd($this->db->getLastQuery(), $result);
|
||||
// dd($result);
|
||||
|
||||
return $result[0];
|
||||
|
||||
}
|
||||
|
||||
// reverse the employee policy table data for the truncated the deletion file
|
||||
public function updateEmployeePolicyTruncateReverse($file_id)
|
||||
{
|
||||
$this->db->query("
|
||||
UPDATE employee_polices
|
||||
SET
|
||||
is_active = 1,
|
||||
status = 'active',
|
||||
date_of_exit = NULL,
|
||||
reason_for_exit = NULL,
|
||||
claim_status = 0,
|
||||
WHERE
|
||||
id IN (
|
||||
SELECT pk
|
||||
FROM emp_endorsement
|
||||
WHERE file_id = $file_id
|
||||
GROUP BY group_key
|
||||
)
|
||||
AND status = 'inactive'
|
||||
");
|
||||
|
||||
}
|
||||
|
||||
//update employee policy table status truncated and is_active 0 for truncated to the addition file
|
||||
public function updateEmpEndorsementAddition($array)
|
||||
{
|
||||
$caseStatus = "CASE ";
|
||||
$caseEndorsementId = "CASE ";
|
||||
$ids = [];
|
||||
foreach ($array as $item) {
|
||||
$caseStatus .= "WHEN id = {$item['id']} THEN '{$item['status']}' ";
|
||||
$caseEndorsementId .= "WHEN id = {$item['id']} THEN '{$item['endorsement_id']}' ";
|
||||
$ids[] = $item['id'];
|
||||
}
|
||||
$caseStatus .= "END";
|
||||
$caseEndorsementId .= "END";
|
||||
$ids = implode(',', $ids);
|
||||
$query = "UPDATE emp_endorsement SET status = $caseStatus, endorsement_id = $caseEndorsementId WHERE id IN ($ids);"; // Execute the query
|
||||
$this->db->query($query);
|
||||
}
|
||||
}
|
||||
@ -57,18 +57,28 @@ table.dataTable thead th {
|
||||
<td><?php echo date('d-M-Y h:i A', strtotime($row['created_at'])) ?> by
|
||||
<?php echo $row['user_name']; ?></td>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<?php if($row['cd_ac_no_count'] == 0) { ?>
|
||||
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
||||
<?php } ?>
|
||||
<?php if($row['cd_ac_no_count'] > 0 && $row['cd_ac_no_count_cd_tranction'] > 1) {?>
|
||||
<div class="btn-group dropdown">
|
||||
<!-- <a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm"aria-expanded="false"></i></a> -->
|
||||
</div>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<?php if($row['cd_ac_no_count_cd_tranction'] <= 1) { ?>
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<?php } ?>
|
||||
<?php if($row['cd_ac_no_count'] == 0) { ?>
|
||||
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -161,7 +171,6 @@ table.dataTable thead th {
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#tickets-table').DataTable({
|
||||
@ -186,6 +195,7 @@ table.dataTable thead th {
|
||||
|
||||
})
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
<?php if (session()->has('error')) : ?>
|
||||
@ -207,6 +217,7 @@ table.dataTable thead th {
|
||||
|
||||
})
|
||||
|
||||
|
||||
$('#btnAdd').click(function(){
|
||||
$('#client_id').val('');
|
||||
$('#insurer_id').val('');
|
||||
@ -220,6 +231,7 @@ table.dataTable thead th {
|
||||
|
||||
})
|
||||
|
||||
|
||||
$('.close').click(function(){
|
||||
$('#CD_Master_ID').val('');
|
||||
$('#client_id').val('').change();
|
||||
@ -232,10 +244,10 @@ table.dataTable thead th {
|
||||
$('#client_id').prop("disabled", false);
|
||||
$('#insurer_id').prop("disabled", false);
|
||||
$('#cd_ac_no').prop("disabled", false);
|
||||
$('#opening_bal').prop("disabled", false)
|
||||
|
||||
})
|
||||
|
||||
|
||||
$('body').on('click', '.btnEdit', function () {
|
||||
|
||||
var cd_id = $(this).attr('data-id');
|
||||
@ -258,13 +270,8 @@ table.dataTable thead th {
|
||||
$('#insurer_id').prop("disabled", true);
|
||||
$('#opening_date').val(res.data.opening_date);
|
||||
$('#cd_ac_no').val(res.data.cd_ac_no);
|
||||
//$('#cd_ac_no').prop("disabled", true);
|
||||
$('#cd_ac_no').prop("disabled", true);
|
||||
$('#opening_bal').val(res.data.opening_bal);
|
||||
if(res.cd_transaction_count <= 1){
|
||||
$('#opening_bal').prop("disabled", false)
|
||||
}else{
|
||||
$('#opening_bal').prop("disabled", true)
|
||||
}
|
||||
$('#btnSubmit').html('Update');
|
||||
|
||||
},
|
||||
@ -275,6 +282,7 @@ table.dataTable thead th {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#cd_ac_no').change(function(){
|
||||
|
||||
var cd_ac_no = $(this).val();
|
||||
@ -303,55 +311,57 @@ table.dataTable thead th {
|
||||
|
||||
})
|
||||
|
||||
function removeCDMaster(element) {
|
||||
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
text: "You need to remove this CD.",
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
confirmButtonText: "Yes",
|
||||
}).then((result) => {
|
||||
function removeCDMaster(element) {
|
||||
|
||||
if (result.isConfirmed) {
|
||||
var id = element.getAttribute('data-id');
|
||||
var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id;
|
||||
$.ajax({
|
||||
url: form_action,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
// console.log(res.status == true);
|
||||
if(res){
|
||||
if (res.status == true) {
|
||||
toastr.success('CD removed successfully.', 'success');
|
||||
location.reload();
|
||||
} else {
|
||||
toastr.warning('Failed to remove CD.', 'warning');
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.log('Something Wrong!', 'warning');
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
text: "You need to remove this CD.",
|
||||
icon: "info",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
confirmButtonText: "Yes",
|
||||
}).then((result) => {
|
||||
|
||||
if (result.isConfirmed) {
|
||||
var id = element.getAttribute('data-id');
|
||||
var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id;
|
||||
$.ajax({
|
||||
url: form_action,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
// console.log(res.status == true);
|
||||
if(res){
|
||||
if (res.status == true) {
|
||||
toastr.success('CD removed successfully.', 'success');
|
||||
location.reload();
|
||||
} else {
|
||||
toastr.warning('Failed to remove CD.', 'warning');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.log('Something Wrong!', 'warning');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function onlyNumbers(event) {
|
||||
var charcode;
|
||||
charcode = event.which || event.keyCode;
|
||||
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function onlyNumbers(event) {
|
||||
var charcode;
|
||||
charcode = event.which || event.keyCode;
|
||||
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user