FIX_SI_ENHANCEMENT_QUERY : RV
This commit is contained in:
parent
4937ae7b1d
commit
26dc9f1dfa
@ -1274,7 +1274,12 @@ class ClientController extends AdminController
|
||||
$data['insurer_id'] = $insurerId;
|
||||
|
||||
$tpaValue = (string) $this->request->getPost('tpa');
|
||||
list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
|
||||
if(!empty($tpaValue) || $tpaValue !== ''){
|
||||
list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
|
||||
}else{
|
||||
$tpaBranchId = null;
|
||||
$tpaId = null;
|
||||
}
|
||||
|
||||
$data['tpa_branch_id'] = $tpaBranchId;
|
||||
$data['client_id'] = $client_id;
|
||||
@ -4825,20 +4830,24 @@ class ClientController extends AdminController
|
||||
|
||||
// ----------EMP DATA SERVICE CONTROLLER--------------------------------------------------------------------------------
|
||||
|
||||
$batch_data = [
|
||||
'client_id' => 13,
|
||||
'client_policy_id' => 17,
|
||||
'client_branch_id' => 15,
|
||||
'insurer_or_tpa' => "insurer",
|
||||
'event_type' => "deletion",
|
||||
];
|
||||
// $batch_data = [
|
||||
// 'client_id' => 29,
|
||||
// 'client_policy_id' => 17,
|
||||
// 'client_branch_id' => 15,
|
||||
// 'insurer_or_tpa' => "insurer",
|
||||
// 'event_type' => "deletion",
|
||||
// ];
|
||||
|
||||
$batch_data = [
|
||||
'client_id' => 29,
|
||||
'client_policy_id' => 78,
|
||||
'client_branch_id' => 46,
|
||||
'insurer_or_tpa' => "insurer",
|
||||
];
|
||||
// $batch_data = [
|
||||
// 'client_id' => 89,
|
||||
// 'client_policy_id' => 328,
|
||||
// 'client_branch_id' => 88,
|
||||
// 'insurer_or_tpa' => "insurer",
|
||||
// // 'insurer_or_tpa' => "tpa",
|
||||
// 'event_type' => "si_enhancement",
|
||||
// 'file_name' => "si_enhancement_test_file.xlsx",
|
||||
// 'actions' => "export",
|
||||
// ];
|
||||
|
||||
// $batch_data['insurer_or_tpa'] = 'insurer';
|
||||
// $batch_data['insurer_or_tpa'] = 'tpa';
|
||||
@ -4853,14 +4862,16 @@ class ClientController extends AdminController
|
||||
// $EmpDataServiceController->sendMailForDownloadingECard($ids);
|
||||
|
||||
$EmpDataServiceController = new EmpDataServiceController();
|
||||
// $EmpDataServiceController->generateExcelForSIEnhancement($batch_data); die;
|
||||
// $EmpDataServiceController->importDeletionValidation(['file_id' => 304]); //for live
|
||||
// $EmpDataServiceController->importSIEnhancementUpdateEndorsementID(['file_id' => 1199]); //for live
|
||||
// $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 1205]); //for live
|
||||
// $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 214]); //for live
|
||||
|
||||
// $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data);
|
||||
// $result = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($batch_data);
|
||||
// print_rr($result); die;
|
||||
// $result = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($batch_data, 1);
|
||||
// return $this->downloadInsurerExcelExport($batch_data);
|
||||
// dd($result); die;
|
||||
|
||||
// $empServiceController = new EmployeeServiceController();
|
||||
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => '741']);
|
||||
@ -4869,7 +4880,7 @@ class ClientController extends AdminController
|
||||
// $res = $PolicyTransactionController->validateInsurerStatement(['file_id' => '36']);
|
||||
|
||||
// $empServiceController = new EmployeeServiceController();
|
||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '319']);
|
||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '1101']);
|
||||
// dd($res);
|
||||
|
||||
// $EmpDataServiceController = new EmpDataServiceController();
|
||||
|
||||
@ -3355,6 +3355,17 @@ class LeadsController extends BaseController
|
||||
if (!is_array($lead_data)) {
|
||||
$lead_data = [];
|
||||
}
|
||||
|
||||
if (isset($lead_data['pincode']) && isset($lead_data['address'])) {
|
||||
// Reorder keys: address first, then pincode, then the rest
|
||||
$reordered = ['address' => $lead_data['address'], 'pincode' => $lead_data['pincode']];
|
||||
|
||||
// Remove existing keys
|
||||
unset($lead_data['address'], $lead_data['pincode']);
|
||||
|
||||
// Merge reordered with the rest
|
||||
$lead_data = $reordered + $lead_data;
|
||||
}
|
||||
$lead_data = array_merge(['Insured' => $rfq_data['client_name']], $lead_data);
|
||||
|
||||
$policy_registration_data = [];
|
||||
|
||||
@ -597,17 +597,17 @@ class EmployeePolicyModel extends Model
|
||||
public function getSIEnhancementEmployeesDataForExportExcel($ref_data, $return_type = 0)
|
||||
{
|
||||
|
||||
$client_id = $ref_data['client_id'];
|
||||
$client_policy_id = $ref_data['client_policy_id'];
|
||||
$client_branch_id = $ref_data['client_branch_id'];
|
||||
$insurer_or_tpa = $ref_data['insurer_or_tpa'];
|
||||
$client_id = $ref_data['client_id'];
|
||||
$client_policy_id = $ref_data['client_policy_id'];
|
||||
$client_branch_id = $ref_data['client_branch_id'];
|
||||
$insurer_or_tpa = $ref_data['insurer_or_tpa'];
|
||||
|
||||
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
|
||||
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
|
||||
|
||||
|
||||
$query = $this->db->query("
|
||||
SELECT
|
||||
a.id as endorsement_primarykey,
|
||||
$query = $this->db->query("
|
||||
SELECT
|
||||
a.id AS endorsement_primarykey,
|
||||
a.group_key,
|
||||
employee_polices.id AS primaryKey,
|
||||
employees.name AS emp_name,
|
||||
@ -616,10 +616,8 @@ class EmployeePolicyModel extends Model
|
||||
employees.gender AS emp_gender,
|
||||
employees.relationship_code AS emp_relationship_code,
|
||||
employees.relationship AS emp_relationship,
|
||||
employees.emp_type as emp_type,
|
||||
'SI' as event_type_data,
|
||||
|
||||
|
||||
employees.emp_type AS emp_type,
|
||||
'SI' AS event_type_data,
|
||||
employees.doj AS emp_doj,
|
||||
employees.mobile AS emp_mobile,
|
||||
employees.email_corporate AS emp_email_c,
|
||||
@ -627,103 +625,59 @@ class EmployeePolicyModel extends Model
|
||||
employees.band AS emp_grade,
|
||||
employees.designation AS emp_designation,
|
||||
employees.basic_pay AS emp_basic_pay,
|
||||
|
||||
employee_polices.uhid AS uhid,
|
||||
employee_polices.pre_existing_alignments,
|
||||
employee_polices.policy_end_date,
|
||||
employee_polices.basic_cover_si as old_basic_cover_si,
|
||||
employee_polices.premium as old_si_premium,
|
||||
employee_polices.rata_premimum as old_rata_premium,
|
||||
employee_polices.basic_cover_si AS old_basic_cover_si,
|
||||
employee_polices.premium AS old_si_premium,
|
||||
employee_polices.rata_premimum AS old_rata_premium,
|
||||
employee_polices.age_band,
|
||||
|
||||
batch_data.emp_policy_id,
|
||||
batch_data.bl AS batch_list_batch_code,
|
||||
batch_data.bf AS batch_files_batch_code,
|
||||
|
||||
sidata.new_basic_cover_si,
|
||||
sidata.new_basic_cover_si,
|
||||
sidata.new_si_premium,
|
||||
sidata.old_si_premium,
|
||||
sidata.date_of_coverage,
|
||||
|
||||
DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days,
|
||||
|
||||
ROUND(sidata.new_si_premium - sidata.old_si_premium, 2) AS difference_premium,
|
||||
|
||||
ROUND((sidata.new_si_premium - sidata.old_si_premium) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365, 2) AS pro_rata_premium,
|
||||
|
||||
ROUND(((sidata.new_si_premium - sidata.old_si_premium) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS gst,
|
||||
|
||||
ROUND(
|
||||
((sidata.new_si_premium - sidata.old_si_premium) *
|
||||
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) +
|
||||
(sidata.new_si_premium - sidata.old_si_premium) *
|
||||
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365,
|
||||
2
|
||||
) AS pro_rata_premium,
|
||||
ROUND(
|
||||
(
|
||||
(sidata.new_si_premium - sidata.old_si_premium) *
|
||||
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
|
||||
) * 0.18,
|
||||
2
|
||||
) AS gst,
|
||||
ROUND(
|
||||
(
|
||||
(sidata.new_si_premium - sidata.old_si_premium) *
|
||||
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
|
||||
) +
|
||||
ROUND(
|
||||
((sidata.new_si_premium - sidata.old_si_premium) *
|
||||
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2
|
||||
), 2
|
||||
(
|
||||
(sidata.new_si_premium - sidata.old_si_premium) *
|
||||
(DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365
|
||||
) * 0.18,
|
||||
2
|
||||
),
|
||||
2
|
||||
) AS total
|
||||
|
||||
FROM
|
||||
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 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',
|
||||
bb.old_value as 'old_si_premium',
|
||||
cc.new_value as 'date_of_coverage'
|
||||
FROM (
|
||||
SELECT
|
||||
a1.emp_code,
|
||||
a1.field_name,
|
||||
a1.new_value,
|
||||
a1.old_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,
|
||||
b1.old_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,
|
||||
c1.old_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
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT
|
||||
batch_list.emp_policy_id,
|
||||
batch_list.batch_code AS bl,
|
||||
batch_files.batch_code AS bf
|
||||
FROM
|
||||
batch_files
|
||||
LEFT JOIN
|
||||
batch_list ON batch_files.batch_code = batch_list.batch_code
|
||||
WHERE
|
||||
batch_files.event_type = 'si_enhancement'
|
||||
AND batch_files.actions = 'export'
|
||||
AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
|
||||
) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
|
||||
SELECT
|
||||
emp_code,
|
||||
CAST(MAX(CASE WHEN field_name = 'basic_cover_si' THEN new_value END) AS UNSIGNED) AS new_basic_cover_si,
|
||||
CAST(MAX(CASE WHEN field_name = 'premium' THEN new_value END) AS DECIMAL(10,2)) AS new_si_premium,
|
||||
CAST(MAX(CASE WHEN field_name = 'premium' THEN old_value END) AS DECIMAL(10,2)) AS old_si_premium,
|
||||
MAX(CASE WHEN field_name = 'si_enhancement_date' THEN new_value END) AS date_of_coverage
|
||||
FROM emp_endorsement
|
||||
GROUP BY 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}'
|
||||
$endorsement_condition
|
||||
@ -736,20 +690,177 @@ class EmployeePolicyModel extends Model
|
||||
group by group_key
|
||||
");
|
||||
|
||||
// Get the result set
|
||||
$results = $query->getResult();
|
||||
// Get the result set
|
||||
$results = $query->getResult();
|
||||
|
||||
if($return_type == 1){
|
||||
$results = $query->getResultArray();
|
||||
}else{
|
||||
$results = $query->getResult();
|
||||
}
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
return $results;
|
||||
if ($return_type == 1) {
|
||||
$results = $query->getResultArray();
|
||||
} else {
|
||||
$results = $query->getResult();
|
||||
}
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
return $results;
|
||||
}
|
||||
|
||||
// DO NOT DELETE this SI ENHANCEMENT QUERY FUNCTION
|
||||
|
||||
// public function getSIEnhancementEmployeesDataForExportExcel($ref_data, $return_type = 0)
|
||||
// {
|
||||
|
||||
// $client_id = $ref_data['client_id'];
|
||||
// $client_policy_id = $ref_data['client_policy_id'];
|
||||
// $client_branch_id = $ref_data['client_branch_id'];
|
||||
// $insurer_or_tpa = $ref_data['insurer_or_tpa'];
|
||||
|
||||
// $endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
|
||||
|
||||
|
||||
// $query = $this->db->query("
|
||||
// SELECT
|
||||
// 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_code AS emp_relationship_code,
|
||||
// employees.relationship AS emp_relationship,
|
||||
// employees.emp_type as emp_type,
|
||||
// 'SI' as event_type_data,
|
||||
|
||||
|
||||
// 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.uhid AS uhid,
|
||||
// employee_polices.pre_existing_alignments,
|
||||
// employee_polices.policy_end_date,
|
||||
// employee_polices.basic_cover_si as old_basic_cover_si,
|
||||
// employee_polices.premium as old_si_premium,
|
||||
// employee_polices.rata_premimum as old_rata_premium,
|
||||
// employee_polices.age_band,
|
||||
|
||||
// batch_data.emp_policy_id,
|
||||
// batch_data.bl AS batch_list_batch_code,
|
||||
// batch_data.bf AS batch_files_batch_code,
|
||||
|
||||
// sidata.new_basic_cover_si,
|
||||
// sidata.new_si_premium,
|
||||
// sidata.old_si_premium,
|
||||
// sidata.date_of_coverage,
|
||||
|
||||
// DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1 AS no_of_days,
|
||||
|
||||
// ROUND(sidata.new_si_premium - sidata.old_si_premium, 2) AS difference_premium,
|
||||
|
||||
// ROUND((sidata.new_si_premium - sidata.old_si_premium) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365, 2) AS pro_rata_premium,
|
||||
|
||||
// ROUND(((sidata.new_si_premium - sidata.old_si_premium) * (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2) AS gst,
|
||||
|
||||
// ROUND(
|
||||
// ((sidata.new_si_premium - sidata.old_si_premium) *
|
||||
// (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) +
|
||||
// ROUND(
|
||||
// ((sidata.new_si_premium - sidata.old_si_premium) *
|
||||
// (DATEDIFF(employee_polices.policy_end_date, sidata.date_of_coverage) + 1) / 365) * 0.18, 2
|
||||
// ), 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',
|
||||
// bb.old_value as 'old_si_premium',
|
||||
// cc.new_value as 'date_of_coverage'
|
||||
// FROM (
|
||||
// SELECT
|
||||
// a1.emp_code,
|
||||
// a1.field_name,
|
||||
// a1.new_value,
|
||||
// a1.old_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,
|
||||
// b1.old_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,
|
||||
// c1.old_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
|
||||
// LEFT JOIN (
|
||||
// SELECT DISTINCT
|
||||
// batch_list.emp_policy_id,
|
||||
// batch_list.batch_code AS bl,
|
||||
// batch_files.batch_code AS bf
|
||||
// FROM
|
||||
// batch_files
|
||||
// LEFT JOIN
|
||||
// batch_list ON batch_files.batch_code = batch_list.batch_code
|
||||
// WHERE
|
||||
// batch_files.event_type = 'si_enhancement'
|
||||
// AND batch_files.actions = 'export'
|
||||
// AND batch_files.insurer_or_tpa = '{$insurer_or_tpa}'
|
||||
// ) AS batch_data ON employee_polices.id = batch_data.emp_policy_id
|
||||
|
||||
// WHERE employee_polices.client_policy_id = '{$client_policy_id}'
|
||||
// AND employees.client_branch_id = '{$client_branch_id}'
|
||||
// $endorsement_condition
|
||||
// AND a.actions = 'si'
|
||||
// AND a.status != 'truncated'
|
||||
// AND employee_polices.is_active = 1
|
||||
// AND employee_polices.status = 'active'
|
||||
// AND employees.is_active = 1
|
||||
// AND employees.emp_status = 'active'
|
||||
// group by group_key
|
||||
// ");
|
||||
|
||||
// // Get the result set
|
||||
// $results = $query->getResult();
|
||||
|
||||
// if($return_type == 1){
|
||||
// $results = $query->getResultArray();
|
||||
// }else{
|
||||
// $results = $query->getResult();
|
||||
// }
|
||||
|
||||
// // dd($this->db->getLastQuery());
|
||||
// return $results;
|
||||
|
||||
// }
|
||||
|
||||
// DO NOT DELETE this DELETION QUERY FUNCTION
|
||||
|
||||
// public function getDeletionEmployeeDataForExportExcel($ref_data, $return_type = 0)
|
||||
|
||||
@ -627,10 +627,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
if (isDuplicate) {
|
||||
toastr.warning('This value is already selected in another dropdown.', 'Warning');
|
||||
selectElement.value = '';
|
||||
}
|
||||
// if (isDuplicate) {
|
||||
// toastr.warning('This value is already selected in another dropdown.', 'Warning');
|
||||
// selectElement.value = '';
|
||||
// }
|
||||
}
|
||||
|
||||
$('.close').click(function()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user