Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
bb3e7bd878
@ -362,7 +362,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
$routes->group("inception", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get("list", "PolicyTransactionController::viewInception");
|
||||
$routes->match(['get', 'post'], 'list', 'PolicyTransactionController::viewInception');
|
||||
$routes->post("create", "PolicyTransactionController::createInceptionPolicy");
|
||||
$routes->get("list/(:any)", "PolicyTransactionController::getInceptionDataForEdit/$1");
|
||||
$routes->get("remove/(:any)", "PolicyTransactionController::removeCDMaster/$1");
|
||||
|
||||
@ -4602,7 +4602,7 @@ class ClientController extends AdminController
|
||||
$empServiceController = new EmployeeServiceController();
|
||||
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '873']);
|
||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '874']);
|
||||
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '874']);
|
||||
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '829']);
|
||||
// dd('-----', $res);
|
||||
|
||||
|
||||
@ -4627,8 +4627,10 @@ class ClientController extends AdminController
|
||||
// $ids = array_column($emp_data, 'id');
|
||||
// $EmpDataServiceController->sendMailForDownloadingECard($ids);
|
||||
|
||||
// $EmpDataServiceController = new EmpDataServiceController();
|
||||
$EmpDataServiceController = new EmpDataServiceController();
|
||||
// $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live
|
||||
// $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 1199]); //for live
|
||||
// $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 1205]); //for live
|
||||
|
||||
// $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data);
|
||||
// print_rr($result); die;
|
||||
|
||||
@ -755,12 +755,13 @@ class DashboardController extends AdminController
|
||||
case 'instalment_pending':
|
||||
$groupedData['instalment_pending'][] = $row;
|
||||
break;
|
||||
default:
|
||||
case 'under_process':
|
||||
$groupedData['under_process'][] = $row;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $groupedData;
|
||||
}
|
||||
|
||||
|
||||
@ -2420,8 +2420,17 @@ class EmpDataServiceController extends BaseController
|
||||
$client_policy_id = $file['client_policy_id'];
|
||||
$client_branch_id = $file['client_branch_id'];
|
||||
$batch_code = $file['batch_code'];
|
||||
$insurer_or_tpa = $file['insurer_or_tpa'];
|
||||
$user_id = $file['created_by'];
|
||||
|
||||
$ref_data = [
|
||||
'client_id' => $client_id,
|
||||
'client_policy_id' => $client_policy_id,
|
||||
'client_branch_id' => $client_branch_id,
|
||||
'insurer_or_tpa' => $insurer_or_tpa,
|
||||
'event_type' => $file['event_type'],
|
||||
];
|
||||
|
||||
|
||||
$file_name_with_path = WRITEPATH . "/uploads/import_excel/" . $file['file_name'];
|
||||
|
||||
@ -2453,92 +2462,92 @@ class EmpDataServiceController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
$endorsement_data = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($ref_data, 1);
|
||||
// $db = \Config\Database::connect();
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
// // Raw SQL query
|
||||
// $sql = "
|
||||
// SELECT
|
||||
// a.id as endorsement_primarykey,
|
||||
// a.group_key,
|
||||
// employee_polices.id AS primaryKey,
|
||||
// employees.id AS emp_primary,
|
||||
// employees.name AS emp_name,
|
||||
// employees.emp_code AS emp_code,
|
||||
// employees.dob AS emp_dob,
|
||||
// employees.gender AS emp_gender,
|
||||
// employees.relationship_code AS emp_relationship_code,
|
||||
// 'Has Define' AS emp_type,
|
||||
// employee_polices.uhid AS risk_id,
|
||||
// employee_polices.pre_existing_alignments,
|
||||
// employee_polices.policy_end_date,
|
||||
// employee_polices.basic_cover_si as old_basic_cover_si,
|
||||
// employee_polices.rata_premimum as old_si_premium,
|
||||
// sidata.new_basic_cover_si,
|
||||
// sidata.new_si_premium,
|
||||
// sidata.date_of_coverage,
|
||||
// DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days,
|
||||
// sidata.new_si_premium - employee_polices.rata_premimum AS difference_premium,
|
||||
// ROUND((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365, 2) AS pro_rata_premimum,
|
||||
// ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS gst,
|
||||
// ((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) + ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS total
|
||||
// FROM
|
||||
// emp_endorsement a
|
||||
// LEFT JOIN
|
||||
// employees ON employees.emp_code = a.emp_code
|
||||
// LEFT JOIN
|
||||
// employee_polices ON employees.id = employee_polices.employee_id
|
||||
// LEFT JOIN (
|
||||
// SELECT
|
||||
// aa.emp_code,
|
||||
// aa.new_value as new_basic_cover_si,
|
||||
// bb.new_value as new_si_premium,
|
||||
// cc.new_value as date_of_coverage
|
||||
// FROM (
|
||||
// SELECT
|
||||
// a1.emp_code,
|
||||
// a1.field_name,
|
||||
// a1.new_value
|
||||
// FROM
|
||||
// emp_endorsement as a1
|
||||
// WHERE
|
||||
// a1.field_name = 'basic_cover_si'
|
||||
// ) aa
|
||||
// LEFT JOIN (
|
||||
// SELECT
|
||||
// b1.emp_code,
|
||||
// b1.field_name,
|
||||
// b1.new_value
|
||||
// FROM
|
||||
// emp_endorsement as b1
|
||||
// WHERE
|
||||
// b1.field_name = 'premium'
|
||||
// ) bb ON aa.emp_code = bb.emp_code
|
||||
// LEFT JOIN (
|
||||
// SELECT
|
||||
// c1.emp_code,
|
||||
// c1.field_name,
|
||||
// c1.new_value
|
||||
// FROM
|
||||
// emp_endorsement as c1
|
||||
// WHERE
|
||||
// c1.field_name = 'si_enhancement_date'
|
||||
// ) cc ON aa.emp_code = cc.emp_code
|
||||
// ) as sidata ON a.emp_code = sidata.emp_code
|
||||
// WHERE
|
||||
// employee_polices.client_policy_id = '$client_policy_id'
|
||||
// AND employees.client_branch_id = '$client_branch_id'
|
||||
// AND employee_polices.is_active = '1'
|
||||
// AND (a.endorsement_id IS NULL OR a.endorsement_id = '')
|
||||
// AND a.actions = 'si'
|
||||
// GROUP BY group_key
|
||||
// ";
|
||||
|
||||
// Raw SQL query
|
||||
$sql = "
|
||||
SELECT
|
||||
a.id as endorsement_primarykey,
|
||||
a.group_key,
|
||||
employee_polices.id AS primaryKey,
|
||||
employees.id AS emp_primary,
|
||||
employees.name AS emp_name,
|
||||
employees.emp_code AS emp_code,
|
||||
employees.dob AS emp_dob,
|
||||
employees.gender AS emp_gender,
|
||||
employees.relationship_code AS emp_relationship_code,
|
||||
'Has Define' AS emp_type,
|
||||
employee_polices.uhid AS risk_id,
|
||||
employee_polices.pre_existing_alignments,
|
||||
employee_polices.policy_end_date,
|
||||
employee_polices.basic_cover_si as old_basic_cover_si,
|
||||
employee_polices.rata_premimum as old_si_premium,
|
||||
sidata.new_basic_cover_si,
|
||||
sidata.new_si_premium,
|
||||
sidata.date_of_coverage,
|
||||
DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days,
|
||||
sidata.new_si_premium - employee_polices.rata_premimum AS difference_premium,
|
||||
ROUND((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365, 2) AS pro_rata_premimum,
|
||||
ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS gst,
|
||||
((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) + ROUND(((sidata.new_si_premium - employee_polices.rata_premimum) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS total
|
||||
FROM
|
||||
emp_endorsement a
|
||||
LEFT JOIN
|
||||
employees ON employees.emp_code = a.emp_code
|
||||
LEFT JOIN
|
||||
employee_polices ON employees.id = employee_polices.employee_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
aa.emp_code,
|
||||
aa.new_value as new_basic_cover_si,
|
||||
bb.new_value as new_si_premium,
|
||||
cc.new_value as date_of_coverage
|
||||
FROM (
|
||||
SELECT
|
||||
a1.emp_code,
|
||||
a1.field_name,
|
||||
a1.new_value
|
||||
FROM
|
||||
emp_endorsement as a1
|
||||
WHERE
|
||||
a1.field_name = 'basic_cover_si'
|
||||
) aa
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
b1.emp_code,
|
||||
b1.field_name,
|
||||
b1.new_value
|
||||
FROM
|
||||
emp_endorsement as b1
|
||||
WHERE
|
||||
b1.field_name = 'premium'
|
||||
) bb ON aa.emp_code = bb.emp_code
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
c1.emp_code,
|
||||
c1.field_name,
|
||||
c1.new_value
|
||||
FROM
|
||||
emp_endorsement as c1
|
||||
WHERE
|
||||
c1.field_name = 'si_enhancement_date'
|
||||
) cc ON aa.emp_code = cc.emp_code
|
||||
) as sidata ON a.emp_code = sidata.emp_code
|
||||
WHERE
|
||||
employee_polices.client_policy_id = '$client_policy_id'
|
||||
AND employees.client_branch_id = '$client_branch_id'
|
||||
AND employee_polices.is_active = '1'
|
||||
AND (a.endorsement_id IS NULL OR a.endorsement_id = '')
|
||||
AND a.actions = 'si'
|
||||
GROUP BY group_key
|
||||
";
|
||||
// // Execute the query
|
||||
// $query = $db->query($sql);
|
||||
|
||||
// Execute the query
|
||||
$query = $db->query($sql);
|
||||
|
||||
// Fetch the results
|
||||
$endorsement_data = $query->getResultArray();
|
||||
// // Fetch the results
|
||||
// $endorsement_data = $query->getResultArray();
|
||||
|
||||
|
||||
|
||||
@ -2745,11 +2754,11 @@ class EmpDataServiceController extends BaseController
|
||||
];
|
||||
}
|
||||
|
||||
if ($endorsement_value['pro_rata_premimum'] != $excel_data[$key][16]) {
|
||||
if ($endorsement_value['pro_rata_premium'] != $excel_data[$key][16]) {
|
||||
$errors[$key][] = [
|
||||
'row' => $key,
|
||||
'column' => 16,
|
||||
'db_data' => $endorsement_value['pro_rata_premimum'],
|
||||
'db_data' => $endorsement_value['pro_rata_premium'],
|
||||
'excel_data' => $excel_data[$key][16]
|
||||
];
|
||||
}
|
||||
@ -2950,7 +2959,7 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
$empData['basic_cover_si'] = $value[8];
|
||||
$empData['premium'] = $value[14];
|
||||
$empData['si_enhancement_date'] = $value[10];
|
||||
$empData['si_enhancement_date'] = date('Y-m-d', strtotime($value[10])) ?? null;
|
||||
$empData['rata_premimum'] = $value[16];
|
||||
$empData['gst'] = $value[17];
|
||||
$empData['created_by'] = $user_id;
|
||||
@ -2964,26 +2973,20 @@ class EmpDataServiceController extends BaseController
|
||||
|
||||
$this->employeePolicyModel->updateBatch($emp_policy_ids, 'id');
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
$db->transStart();
|
||||
|
||||
$this->employeePolicyModel->insertBatch($emp_details);
|
||||
// $this->employeePolicyModel->insertBatch($emp_details);
|
||||
// $insertedIds = [];
|
||||
// $startId = $db->insertID(); // Get the first inserted ID
|
||||
|
||||
// for ($i = 0; $i < count($emp_details); $i++) {
|
||||
// $insertedIds[] = $startId + $i;
|
||||
// }
|
||||
|
||||
$insertedIds = [];
|
||||
$startId = $db->insertID(); // Get the first inserted ID
|
||||
|
||||
for ($i = 0; $i < count($emp_details); $i++) {
|
||||
$insertedIds[] = $startId + $i;
|
||||
foreach ($emp_details as $emp) {
|
||||
$insertedIds[] = $this->employeePolicyModel->insert($emp);
|
||||
}
|
||||
|
||||
$db->transComplete();
|
||||
|
||||
// if ($db->transStatus() === FALSE) {
|
||||
// // Handle the error, rollback, etc.
|
||||
// } else {
|
||||
// // Transaction successful
|
||||
// print_r($insertedIds); // This will print the array of inserted IDs
|
||||
// }
|
||||
// dd($insertedIds);
|
||||
|
||||
$this->employeePolicyModel->bulkUpdateForEndorsement($endorsement_details);
|
||||
$this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
|
||||
@ -3226,18 +3226,12 @@ class EmployeeRestController extends AdminController
|
||||
$message = 'Claim Iniated Successfully';
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200);
|
||||
} else {
|
||||
$mail_sent_status = json_decode($mail_sent_status);
|
||||
$mail_sent_status_object = json_decode($mail_sent_status);
|
||||
}
|
||||
// dd(gettype($mail_sent_status));
|
||||
|
||||
if ($mail_sent_status->status == 'success') {
|
||||
$sent_message_data['ticket_id'] = $ticket_id;
|
||||
$sent_message_data['sender'] = 'staff';
|
||||
$sent_message_data['emp_mail'] = $mail_sent_status->data->params->mail;
|
||||
$sent_message_data['mail_subject'] = $mail_sent_status->data->params->subject;
|
||||
$sent_message_data['mail_content'] = $mail_sent_status->data->params->message;
|
||||
if ($mail_sent_status_object->status == 'success') {
|
||||
|
||||
$message_insert_status = $this->ticketMessage->insert($sent_message_data);
|
||||
$message_insert_status = $this->ticketController->autoMessageInsertBasedOnMailResponse($mail_sent_status, $ticket_id);
|
||||
|
||||
if ($message_insert_status) {
|
||||
$message = 'Claim Initiated Successfully';
|
||||
@ -3248,11 +3242,11 @@ class EmployeeRestController extends AdminController
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
|
||||
}
|
||||
} else {
|
||||
|
||||
$message = 'Claim Initiated, Failed to send Mail ';
|
||||
$this->myLogger->logme('error', "Claim initiated, Failed to send Mail :$ticket_id ");
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
$message = 'Something Went Wrong';
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
|
||||
|
||||
@ -1530,8 +1530,21 @@ class EmployeeServiceController extends AdminController
|
||||
break;
|
||||
}
|
||||
// echo '<br>START- ' . $row[2];
|
||||
$employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->where('client_branch_id',$file['client_branch_id'])->first();
|
||||
$employee_policy = $this->employeePolicyModel->where('employee_id',$employee['id'])->where('client_policy_id',$file['policy_id'])->first();
|
||||
$employee = $this->employeeModel
|
||||
->where('emp_code', $row[1])
|
||||
->where('name',$row[2])
|
||||
->where('client_id',$file['client_id'])
|
||||
->where('client_branch_id',$file['client_branch_id'])
|
||||
->where('emp_status', 'active')
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
$employee_policy = $this->employeePolicyModel
|
||||
->where('employee_id',$employee['id'])
|
||||
->where('client_policy_id',$file['policy_id'])
|
||||
->where('status', 'active')
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
// dd($employee, $employee_policy);
|
||||
|
||||
$existing_endorsements = $this->empEndorsementModel->where('actions','si')
|
||||
->where('table_name','employee_polices')
|
||||
@ -1573,6 +1586,8 @@ class EmployeeServiceController extends AdminController
|
||||
|
||||
$data = transform_si_excel_row_to_calculatable_format(employee: $employee,employee_policy: $employee_policy,maxage_and_maxcount: $max_age_and_max_count_of_current_member,slab_details: $slab_details,applicable_slab_name: $applicable_rack_rate_name,augmented_si: $row[3],grid_master: $applicable_rack_rate_master);
|
||||
$policy_terms = $this->clientPolicyModel->getPolicyDetails($file['client_id'],$file['policy_id']);
|
||||
$policy_terms = (array) $policy_terms[0];
|
||||
// dd($policy_terms);
|
||||
//grouping slab details by rack rate name
|
||||
$temp_slab_rates = group_slab_rates_basedon_name($slab_details);
|
||||
|
||||
|
||||
@ -169,17 +169,38 @@ class PolicyTransactionController extends BaseController
|
||||
$issuer = empty($issuer) ? 0 : $issuer;
|
||||
$status = empty($status) ? 0 : $status; // Corrected from `$issuer`
|
||||
|
||||
// Fetch inception data list
|
||||
$data['inception_data_list'] = $this->policyTransactionModel->getInceptionTranctionListData(
|
||||
$start_date,
|
||||
$end_date,
|
||||
$client_id,
|
||||
$insurer_id,
|
||||
$policy_type_id,
|
||||
$date_type,
|
||||
$issuer,
|
||||
$status
|
||||
);
|
||||
if ($this->request->is('get')) {
|
||||
|
||||
// Fetch inception data list
|
||||
$data['inception_data_list'] = $this->policyTransactionModel->getInceptionTranctionListData(
|
||||
$start_date,
|
||||
$end_date,
|
||||
$client_id,
|
||||
$insurer_id,
|
||||
$policy_type_id,
|
||||
$date_type,
|
||||
$issuer,
|
||||
$status
|
||||
);
|
||||
|
||||
}else{
|
||||
|
||||
$ids = $this->request->getPost('ids');
|
||||
$ids = array_filter(explode(',', $ids));
|
||||
$data['inception_data_list'] = $this->policyTransactionModel->getInceptionTranctionListData(
|
||||
$start_date = 0,
|
||||
$end_date = 0,
|
||||
$client_id = 0,
|
||||
$insurer_id = 0,
|
||||
$policy_type_id = 0,
|
||||
$date_type = 0,
|
||||
$issuer = 0,
|
||||
$status = 0,
|
||||
$ids
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Fetch additional data
|
||||
$data['client'] = $this->clientModel->where('is_active', 1)->findAll();
|
||||
|
||||
@ -1701,7 +1701,7 @@ class TicketController extends BaseController
|
||||
} else {
|
||||
|
||||
$this->myLogger->logme('error', "Failed to send Mail :$ticket_id ");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -594,7 +594,7 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
|
||||
public function getSIEnhancementEmployeesDataForExportExcel($ref_data)
|
||||
public function getSIEnhancementEmployeesDataForExportExcel($ref_data, $return_type = 0)
|
||||
{
|
||||
|
||||
$client_id = $ref_data['client_id'];
|
||||
@ -732,7 +732,14 @@ class EmployeePolicyModel extends Model
|
||||
|
||||
// Get the result set
|
||||
$results = $query->getResult();
|
||||
// dd($this->db->getLastQuery(), $results);
|
||||
|
||||
if($return_type == 1){
|
||||
$results = $query->getResultArray();
|
||||
}else{
|
||||
$results = $query->getResult();
|
||||
}
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
return $results;
|
||||
|
||||
}
|
||||
@ -1528,73 +1535,120 @@ class EmployeePolicyModel extends Model
|
||||
}
|
||||
|
||||
|
||||
public function bulkUpdateForEndorsement($endorsement_details)
|
||||
// public function bulkUpdateForEndorsement($endorsement_details)
|
||||
// {
|
||||
// // dd($endorsement_details, '---');
|
||||
// // Extract IDs, endorsement_ids, and statuses
|
||||
// $ids = array_column($endorsement_details, 'group_key');
|
||||
// $endorsement_ids = array_column($endorsement_details, 'endorsement_id');
|
||||
// $statuses = array_column($endorsement_details, 'status');
|
||||
|
||||
// // Escape values for SQL
|
||||
// $escapedIds = array_map([$this->db, 'escape'], $ids);
|
||||
// $escapedEndorsementIds = array_map([$this->db, 'escape'], $endorsement_ids);
|
||||
// $escapedStatuses = array_map([$this->db, 'escape'], $statuses);
|
||||
|
||||
// // Construct the CASE statements
|
||||
// $caseEndorsementId = array_map(function ($id, $endorsement_id) {
|
||||
// return "WHEN group_key = $id THEN $endorsement_id";
|
||||
// }, $escapedIds, $escapedEndorsementIds);
|
||||
|
||||
// // $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);
|
||||
|
||||
// // Convert ids to a string
|
||||
// $idsString = implode(', ', $escapedIds);
|
||||
|
||||
// // Construct the SQL query
|
||||
// $sql = "
|
||||
// UPDATE emp_endorsement
|
||||
// SET
|
||||
// endorsement_id = CASE {$caseEndorsementIdString} END,
|
||||
// status = 'complete'
|
||||
// WHERE group_key IN ({$idsString})
|
||||
// ";
|
||||
|
||||
|
||||
// // dd($sql);
|
||||
// // Begin a transaction
|
||||
// $this->db->transBegin();
|
||||
|
||||
// try {
|
||||
// // Start the transaction
|
||||
// $this->db->transBegin();
|
||||
|
||||
// // Execute the query
|
||||
// $this->db->query($sql);
|
||||
|
||||
// // Check transaction status
|
||||
// if ($this->db->transStatus() === false) {
|
||||
// $error = $this->db->error(); // Get the last database error
|
||||
// $this->db->transRollback();
|
||||
|
||||
// // Optionally log the error
|
||||
// log_message('error', 'Bulk update failed. Error: ' . json_encode($error));
|
||||
|
||||
// throw new \Exception('Bulk update failed. Error: ' . $error['message']);
|
||||
// }
|
||||
|
||||
// // Commit if everything is fine
|
||||
// $this->db->transCommit();
|
||||
|
||||
// return $this->db->getLastQuery(); // Optional: return last executed query for debugging
|
||||
// } catch (\Exception $e) {
|
||||
// $this->db->transRollback();
|
||||
|
||||
// // Optionally log the exception
|
||||
// log_message('error', 'Exception during bulk update: ' . $e->getMessage());
|
||||
|
||||
// // Re-throw with detailed context
|
||||
// throw new \RuntimeException('Exception during bulk update: ' . $e->getMessage(), $e->getCode(), $e);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
public function bulkUpdateForEndorsement(array $endorsement_details)
|
||||
{
|
||||
|
||||
// Extract IDs, endorsement_ids, and statuses
|
||||
$ids = array_column($endorsement_details, 'group_key');
|
||||
$endorsement_ids = array_column($endorsement_details, 'endorsement_id');
|
||||
$statuses = array_column($endorsement_details, 'status');
|
||||
|
||||
// Escape values for SQL
|
||||
$escapedIds = array_map([$this->db, 'escape'], $ids);
|
||||
$escapedEndorsementIds = array_map([$this->db, 'escape'], $endorsement_ids);
|
||||
$escapedStatuses = array_map([$this->db, 'escape'], $statuses);
|
||||
|
||||
// Construct the CASE statements
|
||||
$caseEndorsementId = array_map(function ($id, $endorsement_id) {
|
||||
return "WHEN group_key = $id THEN $endorsement_id";
|
||||
}, $escapedIds, $escapedEndorsementIds);
|
||||
|
||||
// $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);
|
||||
|
||||
// Convert ids to a string
|
||||
$idsString = implode(', ', $escapedIds);
|
||||
|
||||
// Construct the SQL query
|
||||
if (empty($endorsement_details)) {
|
||||
throw new \InvalidArgumentException("No endorsement details provided.");
|
||||
}
|
||||
|
||||
$caseParts = [];
|
||||
$groupKeys = [];
|
||||
|
||||
foreach ($endorsement_details as $row) {
|
||||
$groupKey = $this->db->escape($row['group_key']);
|
||||
$endorsementId = $this->db->escape($row['endorsement_id']);
|
||||
$caseParts[] = "WHEN group_key = {$groupKey} THEN {$endorsementId}";
|
||||
$groupKeys[] = $groupKey;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
UPDATE emp_endorsement
|
||||
SET
|
||||
endorsement_id = CASE {$caseEndorsementIdString} END,
|
||||
endorsement_id = CASE " . implode(' ', $caseParts) . " END,
|
||||
status = 'complete'
|
||||
WHERE group_key IN ({$idsString})
|
||||
WHERE group_key IN (" . implode(', ', $groupKeys) . ")
|
||||
";
|
||||
|
||||
|
||||
// dd($sql);
|
||||
// Begin a transaction
|
||||
$this->db->transBegin();
|
||||
|
||||
try {
|
||||
// Execute the query
|
||||
$this->db->query($sql);
|
||||
|
||||
// Commit the transaction
|
||||
if ($this->db->transStatus() === FALSE) {
|
||||
// If something went wrong, rollback
|
||||
$this->db->transRollback();
|
||||
throw new \Exception('Bulk update failed.');
|
||||
} else {
|
||||
// Otherwise, commit
|
||||
$this->db->transCommit();
|
||||
}
|
||||
// $this->storeEndorsementNumber($file_id, $endorsement_id, $enrollment_file_id);
|
||||
|
||||
return $this->db->getLastQuery();
|
||||
} catch (\Exception $e) {
|
||||
// Rollback the transaction on error
|
||||
$this->db->transRollback();
|
||||
throw $e;
|
||||
|
||||
$this->db->query($sql);
|
||||
|
||||
// Check if query was successful
|
||||
if ($this->db->affectedRows() === 0) {
|
||||
throw new \RuntimeException('No rows were updated.');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function bulkUpdateForCorrection($emp_details){
|
||||
|
||||
foreach ($emp_details as $employee) {
|
||||
|
||||
@ -863,7 +863,7 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
if ($client_id == 0 && $insurer_id == 0 && $policy_type_id == 0 && $date_type == 0 && $issuer == 0) {
|
||||
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
$fromDate = date('Y-m-d', strtotime('-60 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
if (empty($where)) {
|
||||
@ -962,7 +962,7 @@ class PolicyTransactionModel extends Model
|
||||
// return $result;
|
||||
// }
|
||||
|
||||
public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
public function getInceptionTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0, $where = null)
|
||||
{
|
||||
$builder = $this->db->table('policy_transaction')
|
||||
->select('
|
||||
@ -1026,14 +1026,18 @@ class PolicyTransactionModel extends Model
|
||||
}
|
||||
|
||||
// Default to Last 30 Days if No Filters Are Applied
|
||||
if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer)) {
|
||||
$fromDate = date('Y-m-d', strtotime('-30 days'));
|
||||
if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer) && empty($where)) {
|
||||
$fromDate = date('Y-m-d', strtotime('-60 days'));
|
||||
$toDate = date('Y-m-d 23:59:59');
|
||||
|
||||
$builder->where('policy_transaction.created_at >=', $fromDate)
|
||||
->where('policy_transaction.created_at <=', $toDate);
|
||||
}
|
||||
|
||||
if (!empty($where)) {
|
||||
$builder->whereIn('policy_transaction.id', $where);
|
||||
}
|
||||
|
||||
// Optimize Query Execution
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
|
||||
|
||||
@ -268,13 +268,13 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
|
||||
}
|
||||
|
||||
function linkRedirectForPolicy(ids){
|
||||
var url = "<?= base_url("policy_tranction/report/list") ?>";
|
||||
var url = "<?= base_url("policy_tranction/inception/list") ?>";
|
||||
var data = {
|
||||
ids : ids,
|
||||
is_dashboard : 1
|
||||
}
|
||||
|
||||
redirectWithPost(url,data);
|
||||
redirectWithPost(url,data, "POST");
|
||||
}
|
||||
|
||||
function linkRedirectForLeads(status,ids){
|
||||
@ -285,14 +285,14 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID,user_t
|
||||
is_dashboard : 1
|
||||
}
|
||||
|
||||
redirectWithPost(url,data);
|
||||
redirectWithPost(url,data, "POST");
|
||||
}
|
||||
|
||||
function redirectWithPost(url, data = {}) {
|
||||
function redirectWithPost(url, data = {}, method = "GET") {
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
const form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.method = method;
|
||||
form.action = url;
|
||||
|
||||
for (const key in data) {
|
||||
|
||||
@ -599,6 +599,27 @@
|
||||
$('#claim_status_id').on('change', function() {
|
||||
updateClaimStatusDisplay($(this).val());
|
||||
// claimStatusFieldChanges()
|
||||
const selectedVal = $(this).val();
|
||||
const elementId = $(this).attr('id');
|
||||
|
||||
console.log('Selected Value:', selectedVal);
|
||||
console.log('Element ID:', elementId);
|
||||
|
||||
if(selectedVal == 2 || selectedVal == 14){
|
||||
$field = $('#non_id_reason')
|
||||
$field.prop('required', false);
|
||||
}else if(selectedVal == 1){
|
||||
|
||||
if($('#tpa_no').val() != ""){
|
||||
$field = $('#non_id_reason')
|
||||
$field.prop('required', false);
|
||||
var $parentDiv = $field.closest("div");
|
||||
$parentDiv.find("label[for='non_id_reason'] .text-danger").remove();
|
||||
}else{
|
||||
$field = $('#non_id_reason')
|
||||
$field.prop('required', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function claimStatusFieldChanges(fields) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user