Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
c127b088f6
@ -4224,23 +4224,45 @@ class ClientController extends AdminController
|
|||||||
|
|
||||||
public function get_client_policy_data_using_policy_no()
|
public function get_client_policy_data_using_policy_no()
|
||||||
{
|
{
|
||||||
|
$received_data = $this->request->getGet();
|
||||||
$policy_no = $this->request->getGet('policy_no');
|
$policy_no = $this->request->getGet('policy_no');
|
||||||
|
$client_id = $this->request->getGet('client_id');
|
||||||
|
$client_branch_id = $this->request->getGet('client_branch_id');
|
||||||
|
$policy_type_id = $this->request->getGet('policy_type_id');
|
||||||
|
|
||||||
$data = $this->clientPolicyModel
|
$data = $this->clientPolicyModel
|
||||||
->select("
|
->select("
|
||||||
client_policy.*,
|
client_policy.*,
|
||||||
|
policy_type.policy_type,
|
||||||
clients.client_type,
|
clients.client_type,
|
||||||
|
clients.client_name,
|
||||||
DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
|
DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
|
||||||
DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
|
DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
|
||||||
")
|
")
|
||||||
->join('clients', 'client_policy.client_id = clients.id')
|
->join('clients', 'client_policy.client_id = clients.id')
|
||||||
|
->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
|
||||||
->where('client_policy.policy_no', $policy_no)
|
->where('client_policy.policy_no', $policy_no)
|
||||||
->where('client_policy.is_active', 1)
|
->where('client_policy.is_active', 1)
|
||||||
|
->where('client_policy.policy_status', 1)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($data) {
|
if ($data) {
|
||||||
return $this->respond(['status' => true, 'data' => $data, 'code' => 200], 200);
|
if ($data['client_id'] == $client_id && $data['client_branch_id'] == $client_branch_id) {
|
||||||
|
|
||||||
|
if ($data['policy_type_id'] == $policy_type_id) {
|
||||||
|
return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200);
|
||||||
|
} else {
|
||||||
|
$policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first();
|
||||||
|
$message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.';
|
||||||
|
return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check';
|
||||||
|
return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404], 200);
|
return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1918,7 +1918,7 @@ class EmpDataServiceController extends BaseController
|
|||||||
$result_for_employees_policy = $this->employeePolicyModel
|
$result_for_employees_policy = $this->employeePolicyModel
|
||||||
->select('employee_polices.*')
|
->select('employee_polices.*')
|
||||||
->join('employees', 'employees.id = employee_polices.employee_id')
|
->join('employees', 'employees.id = employee_polices.employee_id')
|
||||||
->join('emp_endorsement', 'emp_endorsement.employee_id = employees.id') // assuming this is the correct join
|
->join('emp_endorsement', 'emp_endorsement.pk = employees.id') // assuming this is the correct join
|
||||||
->where('employees.emp_code', $emp_code)
|
->where('employees.emp_code', $emp_code)
|
||||||
->where('employees.name', $name)
|
->where('employees.name', $name)
|
||||||
->where('employees.client_id', $client_id)
|
->where('employees.client_id', $client_id)
|
||||||
|
|||||||
@ -344,9 +344,11 @@ class EmployeeController extends AdminController
|
|||||||
$query->where('cr.user_id', $user_id);
|
$query->where('cr.user_id', $user_id);
|
||||||
}
|
}
|
||||||
// ->where('files.created_by', get_session_userid())
|
// ->where('files.created_by', get_session_userid())
|
||||||
$data['fileList'] = $query->groupBy("c.id")->orderBy('files.created_at', 'desc')
|
$data['fileList'] = $query->groupBy("files.id")->orderBy('files.created_at', 'desc')
|
||||||
->limit(1500)
|
// $data['fileList'] = $query
|
||||||
|
->limit(2000)
|
||||||
->find();
|
->find();
|
||||||
|
// dd($this->fileModel->getLastQuery());
|
||||||
// dd($data['fileList']);
|
// dd($data['fileList']);
|
||||||
|
|
||||||
$query2 = $this->batchFileModel->select("
|
$query2 = $this->batchFileModel->select("
|
||||||
@ -395,7 +397,7 @@ class EmployeeController extends AdminController
|
|||||||
$query2->where('cr.user_id', $user_id);
|
$query2->where('cr.user_id', $user_id);
|
||||||
}
|
}
|
||||||
// ->where('files.created_by', get_session_userid())
|
// ->where('files.created_by', get_session_userid())
|
||||||
$data['batch_list'] = $query2->groupBy("clients.id")->orderBy('batch_files.id', 'desc')
|
$data['batch_list'] = $query2->groupBy("batch_files.id")->orderBy('batch_files.id', 'desc')
|
||||||
->limit(1500)
|
->limit(1500)
|
||||||
->find();
|
->find();
|
||||||
|
|
||||||
|
|||||||
@ -493,7 +493,7 @@ class LeadsController extends BaseController
|
|||||||
{
|
{
|
||||||
if ($this->leadsModel->where('id', $id)->set($data[0])->update()) {
|
if ($this->leadsModel->where('id', $id)->set($data[0])->update()) {
|
||||||
|
|
||||||
$this->insertMultiFilesData($data[0]['multi_file_data'], $id);
|
$this->insertMultiFilesData($data[0]['multi_file_data'], $id, $data[0]['lead_form_type']);
|
||||||
$this->insertLeadStatus($id, $data[0]['status'], 3);
|
$this->insertLeadStatus($id, $data[0]['status'], 3);
|
||||||
return $this->respond(['status' => true, 'lead_id' => $id, 'message' => "Lead updated successfully", 'data' => $data], 200);
|
return $this->respond(['status' => true, 'lead_id' => $id, 'message' => "Lead updated successfully", 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
@ -591,14 +591,18 @@ class LeadsController extends BaseController
|
|||||||
return $multi_file_data;
|
return $multi_file_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function insertMultiFilesData($data, $lead_id)
|
public function insertMultiFilesData($data, $lead_id, $lead_form_type = null)
|
||||||
{
|
{
|
||||||
// print_r($data); die;
|
log_message('info', 'insertMultiFilesData() called with lead_id: ' . $lead_id);
|
||||||
|
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
|
log_message('info', 'Data is not empty. Total items: ' . count($data));
|
||||||
|
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
|
log_message('info', "Processing item at index {$key}: " . json_encode($value));
|
||||||
|
|
||||||
if (!empty($value['id'])) {
|
if (!empty($value['id'])) {
|
||||||
|
log_message('info', "Record with ID {$value['id']} exists. Preparing to update.");
|
||||||
|
|
||||||
$lead_file_data = [
|
$lead_file_data = [
|
||||||
'lead_id' => $lead_id,
|
'lead_id' => $lead_id,
|
||||||
@ -607,10 +611,22 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
if (!empty($value['file_name'])) {
|
if (!empty($value['file_name'])) {
|
||||||
$lead_file_data['file_name'] = $value['file_name'];
|
$lead_file_data['file_name'] = $value['file_name'];
|
||||||
|
log_message('info', "file_name found: {$value['file_name']}");
|
||||||
|
|
||||||
|
if (!empty($lead_form_type) && $lead_form_type == 1 && $key == 0) {
|
||||||
|
//for this push the job to the calculateMembersDemography() function
|
||||||
|
$job_details = new Jobs();
|
||||||
|
$r = Jobs::addJob(['job_name' => 'calculateMembersDemography', 'payload' => [
|
||||||
|
'lead_id' => $lead_id,
|
||||||
|
]]);
|
||||||
|
log_message('info', "calculateMembersDemography JOB PUSHED");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_message('info', "Updating leadFilesModel where id = {$value['id']} with data: " . json_encode($lead_file_data));
|
||||||
$this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update();
|
$this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update();
|
||||||
} else {
|
} else {
|
||||||
|
log_message('info', "No ID found. Preparing to insert new record.");
|
||||||
|
|
||||||
if (!empty($value['file_name'])) {
|
if (!empty($value['file_name'])) {
|
||||||
$lead_file_data = [
|
$lead_file_data = [
|
||||||
@ -618,16 +634,24 @@ class LeadsController extends BaseController
|
|||||||
'docs_name' => $value['docs_name'],
|
'docs_name' => $value['docs_name'],
|
||||||
'file_name' => $value['file_name'],
|
'file_name' => $value['file_name'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
log_message('info', "Inserting into leadFilesModel: " . json_encode($lead_file_data));
|
||||||
$this->leadFilesModel->insert($lead_file_data);
|
$this->leadFilesModel->insert($lead_file_data);
|
||||||
|
} else {
|
||||||
|
log_message('warning', "Skipped insert: file_name missing in data at index {$key}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($key == 0 && !empty($value['file_name'])) {
|
if ($key == 0 && !empty($value['file_name'])) {
|
||||||
|
log_message('info', "Setting first file_name '{$value['file_name']}' to leadsModel for lead_id: {$lead_id}");
|
||||||
$this->leadsModel->where('id', $lead_id)->set('file_name', $value['file_name'])->update();
|
$this->leadsModel->where('id', $lead_id)->set('file_name', $value['file_name'])->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log_message('warning', 'insertMultiFilesData() received empty data array.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_message('info', 'insertMultiFilesData() completed successfully.');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1286,9 +1310,9 @@ class LeadsController extends BaseController
|
|||||||
'Policy Run Days' => $rfq_data['policy_run_days'],
|
'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||||
'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
|
'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
|
||||||
'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']),
|
'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']),
|
||||||
'Earned Premium' => $rfq_data['earned_premium'],
|
'Earned Premium' => formatIndianCurrency(intval($rfq_data['earned_premium'])),
|
||||||
'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']),
|
'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']),
|
||||||
'Annualised Claims' => formatIndianCurrency($rfq_data['annualised_claims']),
|
'Annualised Claims' => formatIndianCurrency(intval($rfq_data['annualised_claims'])),
|
||||||
'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %",
|
'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %",
|
||||||
'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %",
|
'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %",
|
||||||
];
|
];
|
||||||
|
|||||||
@ -2037,8 +2037,8 @@ class PolicyTransactionController extends BaseController
|
|||||||
//insurer statement list page
|
//insurer statement list page
|
||||||
public function statementList()
|
public function statementList()
|
||||||
{
|
{
|
||||||
// dd($this->validateInsurerStatement(['file_id' => 30]));
|
// dd($this->validateInsurerStatement(['file_id' => 49]));
|
||||||
// $data['insurers'] = $this->insurerModel->where('is_active',1)->findAll();
|
$data['insurers'] = $this->insurerModel->where('is_active',1)->findAll();
|
||||||
$today = date('Y-m-d');
|
$today = date('Y-m-d');
|
||||||
$fromday = $from_date = date('Y-m-d', strtotime('-180 days', strtotime($today)));
|
$fromday = $from_date = date('Y-m-d', strtotime('-180 days', strtotime($today)));
|
||||||
// echo $fromday;die();
|
// echo $fromday;die();
|
||||||
@ -2261,13 +2261,13 @@ class PolicyTransactionController extends BaseController
|
|||||||
// dd($highestRowAndColumn);
|
// dd($highestRowAndColumn);
|
||||||
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
$excel_data = $sheet->rangeToArray('A1:' . $highestRowAndColumn['column'] . $highestRowAndColumn['row']);
|
||||||
unset($excel_data[0]);
|
unset($excel_data[0]);
|
||||||
// Kint::dump($excel_data);
|
// Kint::dump($excel_data);die();
|
||||||
//get no of line items and update in DB
|
//get no of line items and update in DB
|
||||||
$line_items = 0;
|
$line_items = 0;
|
||||||
// get uploaded month transactions data
|
// get uploaded month transactions data
|
||||||
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id']);
|
$source_data = $this->PTCOShareDetailsModel->getNonReconcileredPolicyTransactions(insurer_id: $file['insurer_id'], insurer_branch_id: $file['branch_id']);
|
||||||
// var_dump($source_data);die();
|
// var_dump($source_data);die();
|
||||||
// Kint::dump($source_data);//die();
|
// Kint::dump($source_data);die();
|
||||||
|
|
||||||
|
|
||||||
// check policy no,insurer and etc in DB for this month
|
// check policy no,insurer and etc in DB for this month
|
||||||
@ -2277,17 +2277,24 @@ class PolicyTransactionController extends BaseController
|
|||||||
if (!$is_row_empty) {
|
if (!$is_row_empty) {
|
||||||
// $excel_row = ExcelSanitizeHelper::sanitizeArrayData($excel_row);
|
// $excel_row = ExcelSanitizeHelper::sanitizeArrayData($excel_row);
|
||||||
$is_source_found = 0;
|
$is_source_found = 0;
|
||||||
|
// Kint::dump($excel_key,$excel_row[1],$excel_row[2]);
|
||||||
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
|
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
|
||||||
$policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
|
$policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
|
||||||
|
|
||||||
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel
|
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel
|
||||||
$policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]); //policy_end_date from excel
|
$policy_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[1]); //policy_end_date from excel
|
||||||
|
|
||||||
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
||||||
|
|
||||||
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
|
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
|
||||||
// Kint::dump($policy_no);
|
$endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]); //policy_end_date from excel
|
||||||
|
|
||||||
|
// Kint::dump($excel_key,$policy_no,$endorsement_no,$policy_start_date,$policy_end_date);//die();
|
||||||
foreach ($source_data as $source_key => $source_row) {
|
foreach ($source_data as $source_key => $source_row) {
|
||||||
$source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null;
|
$source_endorsement_no = $source_row['endorsement_no'] !== null ? $source_row['endorsement_no'] : null;
|
||||||
// Kint::dump($source_endorsement_no);
|
// Kint::dump($source_endorsement_no);
|
||||||
if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name']) {
|
if (($policy_no == $source_row['policy_no']) && $endorsement_no == $source_endorsement_no && change_date_format($policy_start_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_start_date'] && change_date_format($policy_end_date, 'd-m-Y', 'Y-m-d') == $source_row['policy_end_date'] && $client_name == $source_row['client_name'])
|
||||||
|
{
|
||||||
$is_source_found = 1;
|
$is_source_found = 1;
|
||||||
$line_items = $line_items + 1;
|
$line_items = $line_items + 1;
|
||||||
unset($source_data[$source_key]);
|
unset($source_data[$source_key]);
|
||||||
|
|||||||
59
app/Models/HRAccessControlModel.php
Normal file
59
app/Models/HRAccessControlModel.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
|
||||||
|
class HRAccessControlModel extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'hr_access_control';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
protected $allowedFields = [
|
||||||
|
'id',
|
||||||
|
'pre_hr_id',
|
||||||
|
'post_hr_id',
|
||||||
|
'allowed_modules',
|
||||||
|
'allowed_pre_policies',
|
||||||
|
'allowed_active_policies',
|
||||||
|
'allowed_cd',
|
||||||
|
'created_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_at',
|
||||||
|
'updated_by',
|
||||||
|
'is_active'
|
||||||
|
];
|
||||||
|
|
||||||
|
// Callbacks
|
||||||
|
protected $allowCallbacks = true;
|
||||||
|
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||||
|
protected $afterInsert = [];
|
||||||
|
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||||
|
protected $afterUpdate = [];
|
||||||
|
protected $beforeFind = [];
|
||||||
|
protected $afterFind = [];
|
||||||
|
protected $beforeDelete = [];
|
||||||
|
protected $afterDelete = [];
|
||||||
|
|
||||||
|
protected function checkAndADDCreatedByValue(array $data)
|
||||||
|
{
|
||||||
|
// Check if 'updated_by' value is null or empty
|
||||||
|
if (empty($data['data']['created_by'])) {
|
||||||
|
// Set 'updated_by' value to the current session user ID
|
||||||
|
$data['data']['created_by'] = get_session_userid();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||||
|
{
|
||||||
|
// Check if 'updated_by' value is null or empty
|
||||||
|
if (empty($data['data']['updated_by'])) {
|
||||||
|
// Set 'updated_by' value to the current session user ID
|
||||||
|
$data['data']['updated_by'] = get_session_userid();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -112,6 +112,7 @@ class UserModel extends Model
|
|||||||
->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
||||||
->where('user_profiles.id', $user_id)
|
->where('user_profiles.id', $user_id)
|
||||||
->where('user_teams.is_active', 1)
|
->where('user_teams.is_active', 1)
|
||||||
|
->where("user_profiles.is_active", 1)
|
||||||
->get()
|
->get()
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
|
|
||||||
|
|||||||
@ -1423,7 +1423,9 @@
|
|||||||
console.log('Policy Run Days (Final):', policy_run_days);
|
console.log('Policy Run Days (Final):', policy_run_days);
|
||||||
|
|
||||||
let annualised_claims = policy_run_days > 0 ? (incurred_claims / policy_run_days) * 365 : 0;
|
let annualised_claims = policy_run_days > 0 ? (incurred_claims / policy_run_days) * 365 : 0;
|
||||||
let annualised_claims_roundoff = Math.round(annualised_claims);
|
// let annualised_claims_roundoff = annualised_claims.toFixed(2);
|
||||||
|
let annualised_claims_roundoff = Math.trunc(annualised_claims);
|
||||||
|
|
||||||
console.log('Annualised Claims:', annualised_claims);
|
console.log('Annualised Claims:', annualised_claims);
|
||||||
console.log('Annualised Claims (Rounded):', annualised_claims_roundoff);
|
console.log('Annualised Claims (Rounded):', annualised_claims_roundoff);
|
||||||
$('#annualised_claims').val(annualised_claims_roundoff);
|
$('#annualised_claims').val(annualised_claims_roundoff);
|
||||||
@ -1431,22 +1433,24 @@
|
|||||||
let premium_as_on_date = Number($('#premium_date').val()) || 0;
|
let premium_as_on_date = Number($('#premium_date').val()) || 0;
|
||||||
console.log('Premium as on Date:', premium_as_on_date);
|
console.log('Premium as on Date:', premium_as_on_date);
|
||||||
|
|
||||||
let incurred_claim_ratio = (annualised_claims > 0 && premium_as_on_date > 0)
|
let incurred_claim_ratio = (incurred_claims > 0 && premium_as_on_date > 0)
|
||||||
? (annualised_claims / premium_as_on_date)
|
? (incurred_claims / premium_as_on_date) * 100
|
||||||
: 0;
|
: 0;
|
||||||
let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio) ? Math.round(incurred_claim_ratio) : 0;
|
let incurred_claim_ratio_roundoff = isFinite(incurred_claim_ratio) ? incurred_claim_ratio.toFixed(2) : 0;
|
||||||
console.log('Incurred Claim Ratio:', incurred_claim_ratio);
|
console.log('Incurred Claim Ratio:', incurred_claim_ratio);
|
||||||
console.log('Incurred Claim Ratio (Rounded):', incurred_claim_ratio_roundoff);
|
console.log('Incurred Claim Ratio (Rounded):', incurred_claim_ratio_roundoff);
|
||||||
$('#incurred_claims_ratio').val(incurred_claim_ratio_roundoff);
|
$('#incurred_claims_ratio').val(incurred_claim_ratio_roundoff);
|
||||||
|
|
||||||
let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * 364 : 0;
|
let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * policy_run_days : 0;
|
||||||
let earned_premium_roundoff = Math.round(earned_premium);
|
// let earned_premium_roundoff = earned_premium.toFixed(2);
|
||||||
|
let earned_premium_roundoff = Math.trunc(earned_premium);
|
||||||
|
|
||||||
console.log('Earned Premium:', earned_premium);
|
console.log('Earned Premium:', earned_premium);
|
||||||
console.log('Earned Premium (Rounded):', earned_premium_roundoff);
|
console.log('Earned Premium (Rounded):', earned_premium_roundoff);
|
||||||
$('#earned_premium').val(earned_premium_roundoff);
|
$('#earned_premium').val(earned_premium_roundoff);
|
||||||
|
|
||||||
let earnedClaimsRatio = earned_premium > 0 ? annualised_claims / earned_premium : 0;
|
let earnedClaimsRatio = premium_as_on_date > 0 ? (annualised_claims / premium_as_on_date) * 100 : 0;
|
||||||
let earnedClaimsRatioRounded = Math.round(earnedClaimsRatio);
|
let earnedClaimsRatioRounded = earnedClaimsRatio.toFixed(2);
|
||||||
console.log('Earned Claims Ratio:', earnedClaimsRatio);
|
console.log('Earned Claims Ratio:', earnedClaimsRatio);
|
||||||
console.log('Earned Claims Ratio (Rounded):', earnedClaimsRatioRounded);
|
console.log('Earned Claims Ratio (Rounded):', earnedClaimsRatioRounded);
|
||||||
$('#earned_claims_ratio').val(earnedClaimsRatioRounded);
|
$('#earned_claims_ratio').val(earnedClaimsRatioRounded);
|
||||||
|
|||||||
@ -1391,6 +1391,8 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
|
|||||||
console.log('appendGridtHtml function ui_type', ui_type);
|
console.log('appendGridtHtml function ui_type', ui_type);
|
||||||
console.log('appendGridtHtml function secondary', secondary);
|
console.log('appendGridtHtml function secondary', secondary);
|
||||||
console.log('appendGridtHtml function typeof secondary', typeof secondary);
|
console.log('appendGridtHtml function typeof secondary', typeof secondary);
|
||||||
|
var default_unit = $('#hidden_unit').val();
|
||||||
|
// alert(default_unit);
|
||||||
|
|
||||||
// console.log('appendGridtHtml function data.unit', data.unit);
|
// console.log('appendGridtHtml function data.unit', data.unit);
|
||||||
// console.log('appendGridtHtml function data.unit type',typeof data.unit);
|
// console.log('appendGridtHtml function data.unit type',typeof data.unit);
|
||||||
|
|||||||
@ -3838,6 +3838,15 @@ $('#policy_no').change(function(){
|
|||||||
|
|
||||||
var policy_no = $(this).val();
|
var policy_no = $(this).val();
|
||||||
policy_no = policy_no.trim();
|
policy_no = policy_no.trim();
|
||||||
|
let client_id = $('#client_id').val()?.trim();
|
||||||
|
let client_branch_id = $('#client_branch_id').val()?.trim();
|
||||||
|
let policy_type_id = $('#policy_type_id').val()?.trim();
|
||||||
|
|
||||||
|
if (!client_id || !client_branch_id || !policy_type_id) {
|
||||||
|
toastr.warning('Please select the policy type, client and branch', "WARNING");
|
||||||
|
$('#policy_no').val('');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$pt_id = $('#policy_tranction_policy_number').val();
|
$pt_id = $('#policy_tranction_policy_number').val();
|
||||||
console.log('$pt_id', $pt_id);
|
console.log('$pt_id', $pt_id);
|
||||||
@ -3846,12 +3855,18 @@ $('#policy_no').change(function(){
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no/');?>',
|
url: '<?php echo base_url('util/get_client_policy_data_using_policy_no/');?>',
|
||||||
type: "GET",
|
type: "GET",
|
||||||
data : { policy_no : policy_no },
|
data : { policy_no : policy_no, client_id : client_id, client_branch_id : client_branch_id, policy_type_id : policy_type_id},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
|
|
||||||
console.log('get_client_policy_data_using_policy_no response', res)
|
console.log('get_client_policy_data_using_policy_no response', res)
|
||||||
|
|
||||||
|
if(res.status == true && res.code == 409){
|
||||||
|
toastr.warning(res.message,'WARNING');
|
||||||
|
$('#policy_no').val("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(res.status == true){
|
if(res.status == true){
|
||||||
$('#ct_type').val(1);
|
$('#ct_type').val(1);
|
||||||
$('#client_policy_id').val(res.data.id);
|
$('#client_policy_id').val(res.data.id);
|
||||||
|
|||||||
@ -212,8 +212,8 @@ $(document).ready(function() {
|
|||||||
customizeData: function (data) {
|
customizeData: function (data) {
|
||||||
for (var i = 0; i < data.body.length; i++) {
|
for (var i = 0; i < data.body.length; i++) {
|
||||||
for (var j = 0; j < data.body[i].length; j++) {
|
for (var j = 0; j < data.body[i].length; j++) {
|
||||||
// Check if the column is the 9th index (10th column)
|
// Check if the column is the 9th index (10th column) and 10th index (11th column)
|
||||||
if (j === 9) {
|
if (j === 9 || j === 10) {
|
||||||
data.body[i][j] = '\u200C' + data.body[i][j];
|
data.body[i][j] = '\u200C' + data.body[i][j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,12 +78,12 @@
|
|||||||
<i class="fa fa-info-circle text-primary"></i>
|
<i class="fa fa-info-circle text-primary"></i>
|
||||||
<div class="info-tooltip">
|
<div class="info-tooltip">
|
||||||
<strong>Formulas:</strong><br>
|
<strong>Formulas:</strong><br>
|
||||||
1. Incurred Claims = Paid Claims + Outstanding Claims<br>
|
1. Incurred Claims = Paid Claims + Outstanding Claims<br>
|
||||||
2. Policy Run Days = Incurred Claim Date - Policy Start Date + 1<br>
|
2. Policy Run Days = Incurred Claim Date - Policy Start Date + 1<br>
|
||||||
3. Earned Premium = (Premium as on Date / 365) × 364<br>
|
3. Earned Premium = (Premium as on Date / 365) × Policy Run Days<br>
|
||||||
4. Annualised Claims = (Incurred Claims / Policy Run Days) × 365<br>
|
4. Annualised Claims = (Incurred Claims / Policy Run Days) × 365<br>
|
||||||
5. Incurred Claim Ratio = Annualised Claims / Premium as on Date<br>
|
5. Incurred Claim Ratio = Incurred Claims / Premium as on Date<br>
|
||||||
6. Earned Claims Ratio = Annualised Claims / Earned Premium
|
6. Earned Claims Ratio = Annualised Claims / Premium as on Date
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -230,7 +230,7 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
<a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary" id>Export Excel</a>
|
<a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary" id>Export Excel</a>
|
||||||
<button id="submitInternalMail" class="btn btn-primary" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button>
|
<button id="submitInternalMail" class="btn btn-primary" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button>
|
||||||
<?php if (get_role_id() == 1 || in_array($user_team,[6,7])) { ?>
|
<?php if (in_array(get_role_id(), [1,5]) || in_array(BUSINESS_SUPPORT_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
|
||||||
<button id="submitMail" class="btn btn-primary"
|
<button id="submitMail" class="btn btn-primary"
|
||||||
onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button>
|
onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -2560,6 +2560,15 @@ function popInsurerInArray(proposal_name, insurerName) {
|
|||||||
|
|
||||||
function changeInsurer(event) {
|
function changeInsurer(event) {
|
||||||
|
|
||||||
|
console.log('change insure event', event);
|
||||||
|
|
||||||
|
let proposal_name = getParentHeaderTh(event);
|
||||||
|
console.log('proposel Name', proposal_name)
|
||||||
|
|
||||||
|
if(proposal_name == null || proposal_name == ""){
|
||||||
|
toastr.warning("Could not change the insurer", "WARNING")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// let newInsurerName = prompt("Enter New insurer name:");
|
// let newInsurerName = prompt("Enter New insurer name:");
|
||||||
const insurers = <?= json_encode($insurer); ?>;
|
const insurers = <?= json_encode($insurer); ?>;
|
||||||
@ -2577,77 +2586,164 @@ function changeInsurer(event) {
|
|||||||
console.log('newInsurerName', newInsurerName)
|
console.log('newInsurerName', newInsurerName)
|
||||||
console.log('newversion', newversion)
|
console.log('newversion', newversion)
|
||||||
|
|
||||||
if (newInsurerName) {
|
const closestTh = event.target.closest('th');
|
||||||
|
let oldInsurerName = closestTh.innerText.split('⋮')[0].trim();
|
||||||
|
console.log(oldInsurerName + ' - ' + newInsurerName);
|
||||||
|
|
||||||
const closestTh = event.target.closest('th');
|
|
||||||
let oldInsurerName = closestTh.innerText.split('⋮')[0].trim();
|
if (!checkExistingInsurer(proposal_name, newInsurerName) && oldInsurerName != newInsurerName) {
|
||||||
let subThIndex = closestTh.cellIndex;
|
|
||||||
console.log(oldInsurerName + ' - ' + newInsurerName);
|
Swal.fire({
|
||||||
// Iterate over child nodes to find the text node containing "Myname"
|
title: "Insurer Dublicate Found?",
|
||||||
closestTh.childNodes.forEach(node => {
|
text: "Do you want version control!",
|
||||||
if (node.nodeType === Node.TEXT_NODE && node.textContent.includes(oldInsurerName)) {
|
icon: "warning",
|
||||||
// Replace the old name with the new name
|
showCancelButton: true,
|
||||||
node.textContent = node.textContent.replace(oldInsurerName, newInsurerName);
|
confirmButtonColor: "#3085d6",
|
||||||
|
cancelButtonColor: "#d33",
|
||||||
|
confirmButtonText: "Yes, Procced!"
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
|
||||||
|
let modifiedInsurerName = constructInsurerNameWithVersion(proposal_name, newInsurerName);
|
||||||
|
console.log('modifiedInsurerName', modifiedInsurerName);
|
||||||
|
changeInsurerData(event, modifiedInsurerName, dataId)
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//find parent th index then it's text content
|
|
||||||
|
|
||||||
|
|
||||||
// Get the sub TH from the second header row
|
|
||||||
const table = document.getElementById('rfqTable');
|
|
||||||
const headerRows = table.querySelectorAll('thead tr');
|
|
||||||
const subTh = headerRows[1].children[subThIndex];
|
|
||||||
|
|
||||||
let accumulatedColspan = 0;
|
|
||||||
let parentTh = null;
|
|
||||||
const firstHeaderRow = headerRows[0];
|
|
||||||
// Find the parent TH for the specified sub TH index
|
|
||||||
for (let i = 0; i < firstHeaderRow.children.length; i++) {
|
|
||||||
const currentParentTh = firstHeaderRow.children[i];
|
|
||||||
const currentColspan = parseInt(currentParentTh.getAttribute('colspan')) || 1;
|
|
||||||
|
|
||||||
accumulatedColspan += currentColspan;
|
|
||||||
|
|
||||||
if (subThIndex < accumulatedColspan) {
|
|
||||||
parentTh = currentParentTh;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
changeInsurerForPremiumTable(event, newInsurerName, subThIndex)
|
|
||||||
|
|
||||||
let proposal_name = parentTh.innerText.split('⋮')[0].trim();
|
|
||||||
|
|
||||||
if (over_all_column_data[proposal_name]) {
|
|
||||||
// let tempInsurerList = over_all_column_data[proposal_name].insurers;
|
|
||||||
// console.log(tempInsurerList);
|
|
||||||
// if(!tempInsurerList.length) { return true; }
|
|
||||||
//replace the old insurer with the new insuren in global array
|
|
||||||
over_all_column_data[proposal_name].insurers.forEach(item => {
|
|
||||||
if (item.display_name === oldInsurerName) {
|
|
||||||
item.display_name = newInsurerName; // Replace with new name
|
|
||||||
item.ins_name = newInsurerName.split('-')[0].trim(); // Replace with new name
|
|
||||||
item.id = dataId
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// console.log(tempInsurerList);
|
|
||||||
// over_all_column_data[proposal_name].insurers = tempInsurerList;
|
|
||||||
console.log('insurer name replaced in golbal variable');
|
|
||||||
console.log(over_all_column_data[proposal_name].insurers);
|
|
||||||
// over_all_column_data[proposal_name].insurers = tempInsurerList
|
|
||||||
|
|
||||||
isFormDataModified = true; // if any value changeing in the table to set true
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('insurer name not replaced in golbal variable');
|
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
changeInsurerData(event, newInsurerName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeInsurerData(event, newInsurerName, dataId){
|
||||||
|
|
||||||
|
if (newInsurerName) {
|
||||||
|
|
||||||
|
const closestTh = event.target.closest('th');
|
||||||
|
let oldInsurerName = closestTh.innerText.split('⋮')[0].trim();
|
||||||
|
let subThIndex = closestTh.cellIndex;
|
||||||
|
console.log(oldInsurerName + ' - ' + newInsurerName);
|
||||||
|
// Iterate over child nodes to find the text node containing "Myname"
|
||||||
|
closestTh.childNodes.forEach(node => {
|
||||||
|
if (node.nodeType === Node.TEXT_NODE && node.textContent.includes(oldInsurerName)) {
|
||||||
|
// Replace the old name with the new name
|
||||||
|
node.textContent = node.textContent.replace(oldInsurerName, newInsurerName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//find parent th index then it's text content
|
||||||
|
|
||||||
|
|
||||||
|
// Get the sub TH from the second header row
|
||||||
|
const table = document.getElementById('rfqTable');
|
||||||
|
const headerRows = table.querySelectorAll('thead tr');
|
||||||
|
const subTh = headerRows[1].children[subThIndex];
|
||||||
|
|
||||||
|
let accumulatedColspan = 0;
|
||||||
|
let parentTh = null;
|
||||||
|
const firstHeaderRow = headerRows[0];
|
||||||
|
// Find the parent TH for the specified sub TH index
|
||||||
|
for (let i = 0; i < firstHeaderRow.children.length; i++) {
|
||||||
|
const currentParentTh = firstHeaderRow.children[i];
|
||||||
|
const currentColspan = parseInt(currentParentTh.getAttribute('colspan')) || 1;
|
||||||
|
|
||||||
|
accumulatedColspan += currentColspan;
|
||||||
|
|
||||||
|
if (subThIndex < accumulatedColspan) {
|
||||||
|
parentTh = currentParentTh;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
changeInsurerForPremiumTable(event, newInsurerName, subThIndex)
|
||||||
|
|
||||||
|
let proposal_name = parentTh.innerText.split('⋮')[0].trim();
|
||||||
|
|
||||||
|
if (over_all_column_data[proposal_name]) {
|
||||||
|
// let tempInsurerList = over_all_column_data[proposal_name].insurers;
|
||||||
|
// console.log(tempInsurerList);
|
||||||
|
// if(!tempInsurerList.length) { return true; }
|
||||||
|
//replace the old insurer with the new insuren in global array
|
||||||
|
over_all_column_data[proposal_name].insurers.forEach(item => {
|
||||||
|
if (item.display_name === oldInsurerName) {
|
||||||
|
item.display_name = newInsurerName; // Replace with new name
|
||||||
|
item.ins_name = newInsurerName.split('-')[0].trim(); // Replace with new name
|
||||||
|
item.id = dataId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// console.log(tempInsurerList);
|
||||||
|
// over_all_column_data[proposal_name].insurers = tempInsurerList;
|
||||||
|
console.log('insurer name replaced in golbal variable');
|
||||||
|
console.log(over_all_column_data[proposal_name].insurers);
|
||||||
|
// over_all_column_data[proposal_name].insurers = tempInsurerList
|
||||||
|
|
||||||
|
isFormDataModified = true; // if any value changeing in the table to set true
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('insurer name not replaced in golbal variable');
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
toastr.warning("Could not change the insurer", "WARNING")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getParentHeaderTh(event) {
|
||||||
|
|
||||||
|
const currentTh = event.target.closest('th');
|
||||||
|
if (!currentTh) return;
|
||||||
|
|
||||||
|
const colIndex = currentTh.cellIndex;
|
||||||
|
|
||||||
|
// Get all header rows
|
||||||
|
const thead = currentTh.closest('thead');
|
||||||
|
const headerRows = thead.querySelectorAll('tr');
|
||||||
|
|
||||||
|
if (headerRows.length < 2) return; // need at least 2 header rows
|
||||||
|
|
||||||
|
const secondRowThs = headerRows[1].querySelectorAll('th');
|
||||||
|
const firstRowThs = headerRows[0].querySelectorAll('th');
|
||||||
|
|
||||||
|
// Step 1: Find actual column span index of clicked th in 2nd row
|
||||||
|
let actualColIndex = 0;
|
||||||
|
for (let i = 0; i < secondRowThs.length; i++) {
|
||||||
|
const th = secondRowThs[i];
|
||||||
|
const colspan = parseInt(th.getAttribute('colspan')) || 1;
|
||||||
|
|
||||||
|
if (th === currentTh) break;
|
||||||
|
|
||||||
|
actualColIndex += colspan;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 2: Match it with first row <th>s
|
||||||
|
let colSpanCounter = 0;
|
||||||
|
for (let i = 0; i < firstRowThs.length; i++) {
|
||||||
|
const th = firstRowThs[i];
|
||||||
|
const colspan = parseInt(th.getAttribute('colspan')) || 1;
|
||||||
|
|
||||||
|
if (actualColIndex >= colSpanCounter && actualColIndex < colSpanCounter + colspan) {
|
||||||
|
let proposelName = th.innerText.split('⋮')[0].trim();
|
||||||
|
console.log("Parent TH Proposel innerText:", proposelName);
|
||||||
|
console.log("Parent TH Proposel textContent:", th.textContent.trim());
|
||||||
|
return proposelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
colSpanCounter += colspan;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Parent header not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function changeState(event) {
|
function changeState(event) {
|
||||||
|
|
||||||
console.log('changeState Function called')
|
console.log('changeState Function called')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user