CHANGE_Post_app_having_pre_branch_id - VADIVEL J 2025-09-03
This commit is contained in:
parent
a58b397e47
commit
ae0d624911
@ -124,6 +124,8 @@ $routes->group("/client", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("edit", "ClientController::editClientBranch");
|
||||
$routes->get("list/(:any)", "ClientController::getSingleBranchDataById/$1");
|
||||
$routes->get("remove/(:any)", "ClientController::removeClientBranch/$1");
|
||||
$routes->post("auto_fetch_branch","ClientController::auto_fetch_branch");
|
||||
$routes->post("auto_fetch_branch_details","ClientController::auto_fetch_branch_details");
|
||||
});
|
||||
|
||||
$routes->group("relation", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
@ -143,9 +143,9 @@ class ClientController extends AdminController
|
||||
|
||||
// Perform the query
|
||||
$builder = $db->table($table);
|
||||
if(is_array($value)){
|
||||
if (is_array($value)) {
|
||||
$isDuplicate = $builder->where($value)->where('is_active', 1)->countAllResults() > 0;
|
||||
}else{
|
||||
} else {
|
||||
$isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0;
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ class ClientController extends AdminController
|
||||
// ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
|
||||
// ];
|
||||
$attachments = [];
|
||||
$res = MailHelper::send_email(['mail' => $email, 'subject' => 'Mail Via Attachment Testing URL', 'message' => $message,'attachments' => $attachments]);
|
||||
$res = MailHelper::send_email(['mail' => $email, 'subject' => 'Mail Via Attachment Testing URL', 'message' => $message, 'attachments' => $attachments]);
|
||||
|
||||
print_rr($res);
|
||||
echo '------------------------------------------------------------------------------------------';
|
||||
@ -205,21 +205,20 @@ class ClientController extends AdminController
|
||||
|
||||
// dd($client_id, $emp_code, $policy_id, $mail_active);
|
||||
|
||||
if(empty($policy_id)){
|
||||
if (empty($policy_id)) {
|
||||
|
||||
$client_policy_ids = $this->employeeModel
|
||||
->select('employee_polices.client_policy_id')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.client_id', $client_id )
|
||||
->where('employees.emp_code', $emp_code )
|
||||
->where('employee_polices.is_active', 1 )
|
||||
->where('employees.is_active', 1 )
|
||||
->where('employees.client_id', $client_id)
|
||||
->where('employees.emp_code', $emp_code)
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employees.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$client_policy_ids2 = array_column($client_policy_ids, 'client_policy_id');
|
||||
$client_policy_id = array_unique($client_policy_ids2);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$client_policy_id = json_decode($policy_id, true);
|
||||
}
|
||||
|
||||
@ -233,36 +232,34 @@ class ClientController extends AdminController
|
||||
$mail_send_return1 = '';
|
||||
$mail_send_return2 = '';
|
||||
|
||||
if (!is_null($client_policy_id) && is_array($client_policy_id))
|
||||
{
|
||||
if (!is_null($client_policy_id) && is_array($client_policy_id)) {
|
||||
|
||||
$empData = $this->employeeModel->where('emp_code', $emp_code )->where('client_id', $client_id ) ->where('is_active', 1 )->findAll();
|
||||
$empData = $this->employeeModel->where('emp_code', $emp_code)->where('client_id', $client_id)->where('is_active', 1)->findAll();
|
||||
// dd($empData);
|
||||
$filteredEmpData = array_filter($empData, fn($item) => $item['relationship'] === 'Self');
|
||||
|
||||
// dd($filteredEmpData);
|
||||
|
||||
$array_list = [];
|
||||
foreach ($client_policy_id as $key => $value)
|
||||
{
|
||||
$find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value,emp_code: $emp_code,client_id: $client_id,emp_status:['draft','enrolled'],policy_status:['draft','enrolled']);
|
||||
if(count($find) > 0){
|
||||
foreach ($client_policy_id as $key => $value) {
|
||||
$find = $this->employeeModel->getEmpFamilybyEmpCode(client_policy_id: $value, emp_code: $emp_code, client_id: $client_id, emp_status: ['draft', 'enrolled'], policy_status: ['draft', 'enrolled']);
|
||||
if (count($find) > 0) {
|
||||
$array_list[] = $find;
|
||||
}
|
||||
}
|
||||
|
||||
// dd($array_list);
|
||||
|
||||
$notification = $this->notificationModel->where('client_id' ,$client_id)->where('template_name', 'member_review_and_summary_mail')->first();
|
||||
$notification = $this->notificationModel->where('client_id', $client_id)->where('template_name', 'member_review_and_summary_mail')->first();
|
||||
|
||||
|
||||
if (isset($notification) && $notification['enabled'] == 1) {
|
||||
|
||||
$params ['array_list'] = $array_list;
|
||||
$params ['client_policy_id'] = $client_policy_id;
|
||||
$params ['emp_code'] = $emp_code;
|
||||
$params ['client_id'] = $client_id;
|
||||
$params ['notification'] = $notification;
|
||||
$params['array_list'] = $array_list;
|
||||
$params['client_policy_id'] = $client_policy_id;
|
||||
$params['emp_code'] = $emp_code;
|
||||
$params['client_id'] = $client_id;
|
||||
$params['notification'] = $notification;
|
||||
$params['common'] = [
|
||||
'client_id' => $filteredEmpData[0]['client_id'],
|
||||
'client_branch_id' => $filteredEmpData[0]['client_branch_id'],
|
||||
@ -274,10 +271,10 @@ class ClientController extends AdminController
|
||||
|
||||
// dd($params);
|
||||
|
||||
$wholeData =sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params);
|
||||
$wholeData = sendMailNotification::sendMailNotification('member_review_and_summary_mail', $params);
|
||||
// print_r($wholeData); die;
|
||||
|
||||
if($mail_active == 1){
|
||||
if ($mail_active == 1) {
|
||||
$mail_send_return = MailHelper::send_email($wholeData[0]);
|
||||
$this->myLogger->logme("error", $mail_send_return);
|
||||
}
|
||||
@ -322,10 +319,9 @@ class ClientController extends AdminController
|
||||
// }
|
||||
// }
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$this->myLogger->logme("error", 'Member Review Mail Configuration not Enable for this client');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print_r($wholeData);
|
||||
@ -346,21 +342,20 @@ class ClientController extends AdminController
|
||||
{
|
||||
// dd($client_id, $emp_code, $policy_id, $mail_active);
|
||||
|
||||
if(empty($policy_id)){
|
||||
if (empty($policy_id)) {
|
||||
|
||||
$client_policy_ids = $this->employeeModel
|
||||
->select('employee_polices.client_policy_id')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.client_id', $client_id )
|
||||
->where('employees.emp_code', $emp_code )
|
||||
->where('employee_polices.is_active', 1 )
|
||||
->where('employees.is_active', 1 )
|
||||
->where('employees.client_id', $client_id)
|
||||
->where('employees.emp_code', $emp_code)
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employees.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$client_policy_ids2 = array_column($client_policy_ids, 'client_policy_id');
|
||||
$client_policy_id = array_unique($client_policy_ids2);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$client_policy_id = json_decode($policy_id, true);
|
||||
}
|
||||
|
||||
@ -623,19 +618,23 @@ class ClientController extends AdminController
|
||||
|
||||
// dd($data['placeHolders']);
|
||||
|
||||
// auto fetch client list and branch list from pre
|
||||
$data['auto_fetch_client_list'] = $this->getClientListFromPre();
|
||||
|
||||
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('client_onboarding', $data);
|
||||
echo view('layout/footer');
|
||||
}
|
||||
|
||||
// In your controller
|
||||
public function deposit($id = null , $requestFrom = null , $policyId = null)
|
||||
public function deposit($id = null, $requestFrom = null, $policyId = null)
|
||||
{
|
||||
$headerData['tab_name'] = 'Client Deposit';
|
||||
$headerData['page_name'] = 'Clients';
|
||||
|
||||
$data['clientName'] = $this->clientModel->where('id', $id)->find();
|
||||
$data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id,$policyId);
|
||||
$data['clientData'] = $this->clientPolicyModel->getinsurerswithclientid($id, $policyId);
|
||||
|
||||
$data['depositsummary'] = $this->clientPolicyModel->getDepositlistsummary($id);
|
||||
|
||||
@ -644,14 +643,16 @@ class ClientController extends AdminController
|
||||
$data['balances'] = $balances;
|
||||
|
||||
// dd($data);
|
||||
if($requestFrom == 'rest'){ return $data; }
|
||||
if ($requestFrom == 'rest') {
|
||||
return $data;
|
||||
}
|
||||
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('client_deposit_list', $data);
|
||||
echo view('layout/footer');
|
||||
}
|
||||
|
||||
public function view_Deposit($insurerId , $requestFrom = null , $param = null)
|
||||
public function view_Deposit($insurerId, $requestFrom = null, $param = null)
|
||||
{
|
||||
// Load your model to fetch data based on $clientId and $insurerId
|
||||
// $subTypeOptions = [
|
||||
@ -677,11 +678,10 @@ class ClientController extends AdminController
|
||||
$headerData['page_name'] = 'Clients';
|
||||
$loggedInUserID = get_session_userid();
|
||||
// $data['clientData']= $this->clientPolicyModel->getinsurerswithinsurenceid($insurerId);
|
||||
if($requestFrom == 'rest')
|
||||
{
|
||||
if ($requestFrom == 'rest') {
|
||||
$clientId = $param['client_id'];
|
||||
$cd_ac_pk = $param['cd_ac_pk'];
|
||||
}else{
|
||||
} else {
|
||||
$clientId = $this->request->getGet('client_id');
|
||||
$cd_ac_pk = $this->request->getGet('cd_ac_pk');
|
||||
}
|
||||
@ -692,7 +692,9 @@ class ClientController extends AdminController
|
||||
$data['deposiamount'] = $this->clientPolicyModel->getDepositSummary($clientId, $insurerId, $cd_ac_pk);
|
||||
$data['cd_ac_pk'] = $cd_ac_pk;
|
||||
|
||||
if($requestFrom == 'rest'){ return $data; }
|
||||
if ($requestFrom == 'rest') {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Load the view for the new list page;
|
||||
echo view('layout/header', $headerData);
|
||||
@ -716,11 +718,11 @@ class ClientController extends AdminController
|
||||
->first();
|
||||
|
||||
|
||||
if(!empty($record_date)){
|
||||
if (!empty($record_date)) {
|
||||
// Prepare the array with data
|
||||
$date = \DateTime::createFromFormat('d/m/Y', $record_date);
|
||||
$record_date = $date->format('Y-m-d');
|
||||
}else{
|
||||
} else {
|
||||
$record_date = null;
|
||||
}
|
||||
|
||||
@ -796,8 +798,12 @@ class ClientController extends AdminController
|
||||
$editData['client_policy']['role'] = get_role_id();
|
||||
$editData['notification'] = $this->notificationModel->select('template_name,enabled')->where('client_id', $id)->findAll();
|
||||
$editData['placeHolders'] = ['member_name', 'member_mobile', 'nhance_logo', 'tpa_id', 'ecard_download_link', 'client_logo', 'policy_no', 'member_summary', 'app_link', 'post_enrollment_app_link', 'client_name'];
|
||||
$editData['api_data'] = $this->clientApi->where("client_id", $id)->where("is_active",1)->first();
|
||||
$editData['api_data'] = $this->clientApi->where("client_id", $id)->where("is_active", 1)->first();
|
||||
// dd($editData);
|
||||
|
||||
$editData['auto_fetch_client_list'] = $this->getClientListFromPre();
|
||||
|
||||
|
||||
echo view('layout/header', $headerData);
|
||||
echo view('client_onboarding', $editData);
|
||||
echo view('layout/footer');
|
||||
@ -821,7 +827,7 @@ class ClientController extends AdminController
|
||||
$data['is_download_btn'] = 1;
|
||||
}
|
||||
|
||||
if(empty($data['parent_client_id'])){
|
||||
if (empty($data['parent_client_id'])) {
|
||||
$data['parent_client_id'] = null;
|
||||
}
|
||||
|
||||
@ -855,7 +861,7 @@ class ClientController extends AdminController
|
||||
$data['is_download_btn'] = 1;
|
||||
}
|
||||
|
||||
if(empty($data['parent_client_id'])){
|
||||
if (empty($data['parent_client_id'])) {
|
||||
$data['parent_client_id'] = null;
|
||||
}
|
||||
// print_r($data);die;
|
||||
@ -894,9 +900,9 @@ class ClientController extends AdminController
|
||||
$insert = $this->clientKYCDocsModel->insert($data);
|
||||
if ($insert) {
|
||||
// $kycDocs = $this->clientKYCDocsModel->where('client_id', $this->request->getPost('client_id'))->findAll();
|
||||
if($form_type == "others"){
|
||||
if ($form_type == "others") {
|
||||
$kycDocs = $this->generateKycOthersTable($this->request->getPost('client_id'));
|
||||
}else{
|
||||
} else {
|
||||
$kycDocs = $this->generateKycPrimaryTable($this->request->getPost('client_id'));
|
||||
}
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $kycDocs, 'file_name' => $File], 200);
|
||||
@ -924,9 +930,9 @@ class ClientController extends AdminController
|
||||
|
||||
if ($insert) {
|
||||
// $kycDocs = $this->clientKYCDocsModel->getKycDocsName($id);
|
||||
if($form_type == "others"){
|
||||
if ($form_type == "others") {
|
||||
$kycDocs = $this->generateKycOthersTable($this->request->getPost('client_id'));
|
||||
}else{
|
||||
} else {
|
||||
$kycDocs = $this->generateKycPrimaryTable($this->request->getPost('client_id'));
|
||||
}
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $kycDocs], 200);
|
||||
@ -1074,7 +1080,7 @@ class ClientController extends AdminController
|
||||
|
||||
$this->myLogger->logme('error', 'Client branch CREATE function called');
|
||||
$data = $this->request->getPost();
|
||||
// var_dump($data); die;
|
||||
|
||||
if (!isset($data['sez'])) {
|
||||
$data['sez'] = 0;
|
||||
} elseif ($data['sez']) {
|
||||
@ -1387,9 +1393,9 @@ class ClientController extends AdminController
|
||||
$data['insurer_id'] = $insurerId;
|
||||
|
||||
$tpaValue = (string) $this->request->getPost('tpa');
|
||||
if(!empty($tpaValue) || $tpaValue !== ''){
|
||||
if (!empty($tpaValue) || $tpaValue !== '') {
|
||||
list($tpaBranchId, $tpaId) = explode('-', $tpaValue);
|
||||
}else{
|
||||
} else {
|
||||
$tpaBranchId = null;
|
||||
$tpaId = null;
|
||||
}
|
||||
@ -1465,7 +1471,7 @@ class ClientController extends AdminController
|
||||
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($client_id);
|
||||
$clientPoliceData['role'] = get_role_id();
|
||||
|
||||
if($policy_transaction_data > 0){
|
||||
if ($policy_transaction_data > 0) {
|
||||
$r = Jobs::addJob(['job_name' => 'updatePolicyTransactionDataWhileClinetPolicyUpdate', 'payload' => [
|
||||
'old_client_policy_data' => $old_client_policy_data ?? null,
|
||||
'new_client_policy_data' => $new_client_policy_data ?? null,
|
||||
@ -1508,7 +1514,6 @@ class ClientController extends AdminController
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove policy'], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'The policy has active employees'], 200);
|
||||
@ -1994,8 +1999,15 @@ class ClientController extends AdminController
|
||||
|
||||
// Check differences and prepare update data
|
||||
$fields_to_check = [
|
||||
'client_branch_id', 'policy_type', 'insurer_id', 'insurer_branch_id',
|
||||
'cd_ac_pk', 'policy_end_date', 'policy_start_date', 'tpa_id', 'tpa_branch_id'
|
||||
'client_branch_id',
|
||||
'policy_type',
|
||||
'insurer_id',
|
||||
'insurer_branch_id',
|
||||
'cd_ac_pk',
|
||||
'policy_end_date',
|
||||
'policy_start_date',
|
||||
'tpa_id',
|
||||
'tpa_branch_id'
|
||||
];
|
||||
|
||||
foreach ($fields_to_check as $field) {
|
||||
@ -2049,12 +2061,10 @@ class ClientController extends AdminController
|
||||
'message' => "Policy transaction(s) updated.",
|
||||
'updated_ids' => $updated_pt_ids
|
||||
];
|
||||
|
||||
} else {
|
||||
$this->myLogger->logme("error", "No active policy_transaction records found for update.");
|
||||
return ['status' => "Failed", 'message' => "No active policy_transaction records found."];
|
||||
}
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
$this->myLogger->logme("error", "Exception during policy_transaction update: " . $e->getMessage());
|
||||
return [
|
||||
@ -2100,7 +2110,6 @@ class ClientController extends AdminController
|
||||
$errors[] = "No change or failed update for ID {$row['id']}";
|
||||
}
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$errors[] = "Error updating pt_id {$pt_id}: " . $e->getMessage();
|
||||
}
|
||||
@ -2189,7 +2198,8 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function generateKycPrimaryTable($client_id){
|
||||
public function generateKycPrimaryTable($client_id)
|
||||
{
|
||||
|
||||
$db = db_connect();
|
||||
$builder = $db->table('kyc_docs kd');
|
||||
@ -2214,7 +2224,8 @@ class ClientController extends AdminController
|
||||
|
||||
}
|
||||
|
||||
public function generateKycOthersTable($client_id){
|
||||
public function generateKycOthersTable($client_id)
|
||||
{
|
||||
|
||||
$result['data'] = $this->clientKYCDocsModel
|
||||
->where('is_active', 1)
|
||||
@ -2704,7 +2715,7 @@ class ClientController extends AdminController
|
||||
|
||||
if ($value !== null && $value !== '') {
|
||||
$data[$field] = $needsCleanup ? str_replace(',', '', $value) : $value;
|
||||
}else{
|
||||
} else {
|
||||
$data[$field] = $value;
|
||||
}
|
||||
}
|
||||
@ -3119,7 +3130,7 @@ class ClientController extends AdminController
|
||||
$value = $this->request->getPost($field);
|
||||
if ($value !== null) {
|
||||
$data[$field] = str_replace(',', '', $value);
|
||||
}else{
|
||||
} else {
|
||||
$data[$field] = $value;
|
||||
}
|
||||
}
|
||||
@ -3129,7 +3140,7 @@ class ClientController extends AdminController
|
||||
$value = $this->request->getPost($field);
|
||||
if ($value !== null) {
|
||||
$data[$field] = $value;
|
||||
}else{
|
||||
} else {
|
||||
$data[$field] = $value;
|
||||
}
|
||||
}
|
||||
@ -3823,10 +3834,10 @@ class ClientController extends AdminController
|
||||
|
||||
$cd_data = array_merge($cd_data, $client_cd_data);
|
||||
|
||||
if($return_type == "internal"){
|
||||
if(!empty($cd_data)){
|
||||
if ($return_type == "internal") {
|
||||
if (!empty($cd_data)) {
|
||||
return $cd_data;
|
||||
}else{
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -3867,7 +3878,6 @@ class ClientController extends AdminController
|
||||
$newKey = implode(' ', array_map('ucfirst', explode('_', $original_key)));
|
||||
|
||||
$data['enrollment_display_key'][$newKey] = $policy_terms[$original_key] ?? " ";
|
||||
|
||||
} else {
|
||||
|
||||
$data[$key] = $value;
|
||||
@ -4425,9 +4435,9 @@ class ClientController extends AdminController
|
||||
$cd_data = array_merge($cd_data, $client_cd_data);
|
||||
|
||||
if (!empty($cd_data)) {
|
||||
return $this->respond([ 'status' => true,'code' => 200, 'data' => $cd_data], 200);
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false,'code' => 404,'client_id' => $client_id,'insurer_id' => $insurer_id,'insurer_branch_id' => $insurer_branch_id ], 200);
|
||||
return $this->respond(['status' => false, 'code' => 404, 'client_id' => $client_id, 'insurer_id' => $insurer_id, 'insurer_branch_id' => $insurer_branch_id], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4465,7 +4475,7 @@ class ClientController extends AdminController
|
||||
// Add additional fields if client type is 2
|
||||
if ($client_type == 2) {
|
||||
$client_data = array_merge($client_data, [
|
||||
'dob' => change_date_format($postData['dob'],'d/m/Y','Y-m-d'),
|
||||
'dob' => change_date_format($postData['dob'], 'd/m/Y', 'Y-m-d'),
|
||||
'aadhar' => $postData['aadhar'],
|
||||
'phone' => $postData['phone'],
|
||||
'entity_type_id' => 7
|
||||
@ -4523,7 +4533,7 @@ class ClientController extends AdminController
|
||||
$client_type = $postData['client_type'] ?? null;
|
||||
|
||||
$client_insert = null;
|
||||
if($client_type == 2){
|
||||
if ($client_type == 2) {
|
||||
|
||||
$client_data = [
|
||||
'client_type' => $postData['client_type'],
|
||||
@ -4534,8 +4544,7 @@ class ClientController extends AdminController
|
||||
];
|
||||
|
||||
$client_insert = $this->clientModel->insert($client_data);
|
||||
|
||||
}else if($client_type == 1){
|
||||
} else if ($client_type == 1) {
|
||||
|
||||
$client_data = [
|
||||
'client_type' => $postData['client_type'],
|
||||
@ -4660,7 +4669,6 @@ class ClientController extends AdminController
|
||||
];
|
||||
|
||||
$client_insert = $this->clientModel->insert($client_data);
|
||||
|
||||
} else if ($client_type == 1) {
|
||||
|
||||
$client_data = [
|
||||
@ -4738,11 +4746,9 @@ class ClientController extends AdminController
|
||||
'vehicles' => $vehicles,
|
||||
'message' => 'Vehicle created successfully'
|
||||
], 200);
|
||||
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200);
|
||||
}
|
||||
|
||||
} else if (isset($data['owner']) && !empty($data['owner'])) {
|
||||
|
||||
$vehicle_data = [
|
||||
@ -4784,7 +4790,6 @@ class ClientController extends AdminController
|
||||
'vehicles' => $vehicles,
|
||||
'message' => 'Vehicle created successfully'
|
||||
], 200);
|
||||
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200);
|
||||
}
|
||||
@ -5040,30 +5045,28 @@ class ClientController extends AdminController
|
||||
$is_addon = $data[$i]['is_addon'];
|
||||
|
||||
$payable_arr = [];
|
||||
if (in_array($data[$i]['policy_type_id'], [2,3]) && $is_addon == 1) {
|
||||
|
||||
$payable_arr = [ "self" => 0, "spouse" => 0, "childern" => 0, "elders" => 0, ];
|
||||
if (in_array($data[$i]['policy_type_id'], [2, 3]) && $is_addon == 1) {
|
||||
|
||||
$payable_arr = ["self" => 0, "spouse" => 0, "childern" => 0, "elders" => 0,];
|
||||
} else if ($data[$i]['policy_type_id'] == 3 && $is_addon == 3) {
|
||||
|
||||
$payable_arr = ["self" => 1,"spouse" => 1,"childern" => 1,"elders" => 1,];
|
||||
|
||||
$payable_arr = ["self" => 1, "spouse" => 1, "childern" => 1, "elders" => 1,];
|
||||
} else if (in_array($data[$i]['policy_type_id'], [4, 5])) {
|
||||
|
||||
$payable_arr = ["self" => 1,"spouse" => 1,"childern" => 1,"elders" => 1,];
|
||||
$payable_arr = ["self" => 1, "spouse" => 1, "childern" => 1, "elders" => 1,];
|
||||
}
|
||||
|
||||
// Initialize an empty array for the ordered policy terms
|
||||
$orderedPolicyTerms = [];
|
||||
|
||||
if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){
|
||||
if (in_array($data[$i]['policy_type_id'], [2, 3, 4, 5])) {
|
||||
|
||||
// Set default value of copayzonewisecopay to "empty"
|
||||
// $ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty';
|
||||
|
||||
// add is_payable_employee for the GMC Policy
|
||||
if (isset($policyTerms['age_ratio'])) {
|
||||
if(!isset($policyTerms['is_payable_employee'])){
|
||||
if (!isset($policyTerms['is_payable_employee'])) {
|
||||
$aliment_index = array_search('age_ratio', array_keys($policyTerms));
|
||||
$orderedPolicyTerms[] = [
|
||||
"key" => "is_payable_employee",
|
||||
@ -5101,7 +5104,7 @@ class ClientController extends AdminController
|
||||
|
||||
// Add ailmentcapping and ailmentcappingdata if they exist
|
||||
if (isset($policyTerms['ailmentcapping'])) {
|
||||
if(!isset($policyTerms['ailment_capping_details'])){
|
||||
if (!isset($policyTerms['ailment_capping_details'])) {
|
||||
$aliment_index = array_search('ailmentcapping', array_keys($policyTerms));
|
||||
$orderedPolicyTerms[] = [
|
||||
"key" => "ailment_capping_details",
|
||||
@ -5110,12 +5113,11 @@ class ClientController extends AdminController
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}else {
|
||||
} else {
|
||||
|
||||
// add is_payable_employee for the GMC Policy
|
||||
if (isset($policyTerms['age_ratio'])) {
|
||||
if(!isset($policyTerms['is_payable_employee'])){
|
||||
if (!isset($policyTerms['is_payable_employee'])) {
|
||||
$aliment_index = array_search('age_ratio', array_keys($policyTerms));
|
||||
$orderedPolicyTerms[] = [
|
||||
"key" => "is_payable_employee",
|
||||
@ -5125,9 +5127,9 @@ class ClientController extends AdminController
|
||||
"position" => $aliment_index + 1,
|
||||
];
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
|
||||
if(!isset($policyTerms['is_payable_employee'])){
|
||||
if (!isset($policyTerms['is_payable_employee'])) {
|
||||
$orderedPolicyTerms[] = [
|
||||
"key" => "is_payable_employee",
|
||||
"value" => [
|
||||
@ -5137,7 +5139,6 @@ class ClientController extends AdminController
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach ($orderedPolicyTerms as $term) {
|
||||
@ -5159,7 +5160,7 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array($data[$i]['policy_type_id'], [2,3,4,5])){
|
||||
if (in_array($data[$i]['policy_type_id'], [2, 3, 4, 5])) {
|
||||
|
||||
if (!isset($policyTerms['waiver_of_90_days_waiting_period'])) {
|
||||
$policyTerms['waiver_of_90_days_waiting_period'] = "";
|
||||
@ -5208,8 +5209,7 @@ class ClientController extends AdminController
|
||||
if (!isset($policyTerms['enrollment_display_key'])) {
|
||||
$policyTerms['enrollment_display_key'] = $this->existingGMCDisplayValueTransform($policyTerms);
|
||||
}
|
||||
|
||||
} else if($data[$i]['policy_type_id'] == 1){
|
||||
} else if ($data[$i]['policy_type_id'] == 1) {
|
||||
|
||||
if (!isset($policyTerms['medical_expenses_medical_extension'])) {
|
||||
$policyTerms['medical_expenses_medical_extension'] = "";
|
||||
@ -5254,7 +5254,6 @@ class ClientController extends AdminController
|
||||
if (!isset($policyTerms['enrollment_display_key'])) {
|
||||
$policyTerms['enrollment_display_key'] = $this->existingGPADisplayValueTransform($policyTerms);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// dd($policyTerms);
|
||||
@ -5561,7 +5560,7 @@ class ClientController extends AdminController
|
||||
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']);
|
||||
// $res = $empServiceController->employeeDisembark(['file_id' => '1681']);
|
||||
// $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']);
|
||||
dd( $res);
|
||||
dd($res);
|
||||
|
||||
$EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController();
|
||||
// $res = $EmployeeMultiEventServiceController->constructMultiEventData(['file_id' => '1069']);
|
||||
@ -5835,19 +5834,15 @@ class ClientController extends AdminController
|
||||
|
||||
public function enrollmentAddonSIAmountDropdown($client_policy_id)
|
||||
{
|
||||
if(!empty($client_policy_id)){
|
||||
if (!empty($client_policy_id)) {
|
||||
$client_policy_details = $this->clientPolicyModel->where('id', $client_policy_id)->where('policy_status', 1)->where('is_active', 1)->first();
|
||||
|
||||
if(!empty($client_policy_details) && $client_policy_details['policy_type_id'] == 3 && $client_policy_details['is_addon'] == 3){
|
||||
if (!empty($client_policy_details) && $client_policy_details['policy_type_id'] == 3 && $client_policy_details['is_addon'] == 3) {
|
||||
|
||||
$base_policy_id = $client_policy_details['base_policy'] ?? 0;
|
||||
|
||||
if(!empty($base_policy_id)){
|
||||
|
||||
|
||||
|
||||
if (!empty($base_policy_id)) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5862,7 +5857,7 @@ class ClientController extends AdminController
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
|
||||
if($cd_amount){
|
||||
if ($cd_amount) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_amount], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
@ -6577,7 +6572,7 @@ class ClientController extends AdminController
|
||||
if ($subKey !== 'Quote Asked' && isset($subVal['Total'])) {
|
||||
$proposals[$key] = $value;
|
||||
break;
|
||||
}else{
|
||||
} else {
|
||||
$proposals[$key] = $value;
|
||||
}
|
||||
}
|
||||
@ -6586,16 +6581,15 @@ class ClientController extends AdminController
|
||||
if ($key === '' && isset($value['']) && is_array($value[''])) {
|
||||
// Capture empty key to push it later
|
||||
$emptyKeyData[$key] = $value;
|
||||
}else{
|
||||
} else {
|
||||
$others[$key] = $value;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dd($proposals, $others, $emptyKeyData);
|
||||
// Sort proposals by their insurer's total
|
||||
uasort($proposals, function($a, $b) {
|
||||
uasort($proposals, function ($a, $b) {
|
||||
$totalA = 0;
|
||||
$totalB = 0;
|
||||
|
||||
@ -6662,9 +6656,9 @@ class ClientController extends AdminController
|
||||
if (in_array($header['parentHeader'], array_keys($sortedProposalOrder))) {
|
||||
$proposalHeaders[$header['parentHeader']] = $header;
|
||||
} else {
|
||||
if($header['parentHeader'] == "Action"){
|
||||
if ($header['parentHeader'] == "Action") {
|
||||
$actionHeader[] = $header;
|
||||
}else{
|
||||
} else {
|
||||
$staticHeaders[] = $header;
|
||||
}
|
||||
}
|
||||
@ -6700,9 +6694,9 @@ class ClientController extends AdminController
|
||||
if (in_array($entry['parentth'], array_keys($sortedProposalOrder))) {
|
||||
$proposalData[$entry['parentth']][] = $entry;
|
||||
} else {
|
||||
if($entry['parentth'] == "Action"){
|
||||
if ($entry['parentth'] == "Action") {
|
||||
$actionData[] = $entry;
|
||||
}else{
|
||||
} else {
|
||||
$staticData[] = $entry;
|
||||
}
|
||||
}
|
||||
@ -6721,9 +6715,9 @@ class ClientController extends AdminController
|
||||
$increament = 0;
|
||||
foreach ($reorderedProposalData as $key => &$value) {
|
||||
|
||||
if($dubParTh == $value['parentth']){
|
||||
if ($dubParTh == $value['parentth']) {
|
||||
$value['parentth'] = 'Proposal ' . ($increament);
|
||||
}else{
|
||||
} else {
|
||||
$dubParTh = $value['parentth'];
|
||||
$increament = $increament + 1;
|
||||
$value['parentth'] = 'Proposal ' . ($increament);
|
||||
@ -6768,20 +6762,18 @@ class ClientController extends AdminController
|
||||
|
||||
$receivedData = $this->request->getPost();
|
||||
|
||||
if (!empty($receivedData['id'])){
|
||||
if (!empty($receivedData['id'])) {
|
||||
$status = $this->clientApi->save($receivedData);
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$status = $this->clientApi->insert($receivedData);
|
||||
}
|
||||
|
||||
|
||||
if ($status){
|
||||
return $this->respond(['status'=>"Sucesss",'message'=>"Submitted Successfully"],200);
|
||||
}else{
|
||||
return $this->respond(['status'=>"Failed",'message'=>"Submission Faild"],500);
|
||||
if ($status) {
|
||||
return $this->respond(['status' => "Sucesss", 'message' => "Submitted Successfully"], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => "Failed", 'message' => "Submission Faild"], 500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function sendToken()
|
||||
@ -6791,10 +6783,10 @@ class ClientController extends AdminController
|
||||
|
||||
$token = ClientTokenHelper::generateKey($client_id);
|
||||
|
||||
if ($token){
|
||||
return $this->respond(['status' => 'success', 'token' => $token,'message' => "Token Generated Successfully"],200);
|
||||
}else{
|
||||
return $this->respond(['status' => "Failed","message"=>"Token Generation Failed, Try Again After some time"],500);
|
||||
if ($token) {
|
||||
return $this->respond(['status' => 'success', 'token' => $token, 'message' => "Token Generated Successfully"], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => "Failed", "message" => "Token Generation Failed, Try Again After some time"], 500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6821,7 +6813,8 @@ class ClientController extends AdminController
|
||||
$post_client_data = $this->clientModel->where('id', $client_id)->where('is_active', 1)->first();
|
||||
|
||||
$hrAccessData['post_hr_data'] = $this->clientBranchModel
|
||||
->select('lc.id as post_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail')
|
||||
->select('lc.id as post_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail ,
|
||||
client_branch.id as post_branch_id , client_branch.branch_name as post_branch_name')
|
||||
->join('level_contacts lc', 'client_branch.id = lc.ref_id')
|
||||
->where('client_branch.is_active', 1)
|
||||
->where('lc.is_active', 1)
|
||||
@ -6830,7 +6823,7 @@ class ClientController extends AdminController
|
||||
->findAll();
|
||||
|
||||
$hrAccessData['post_policy_data'] = $this->clientPolicyModel
|
||||
->select('client_policy.id as client_policy_id, client_policy.policy_no as policy_no, policy_type.policy_type, client_policy.policy_status')
|
||||
->select('client_policy.id as client_policy_id, client_policy.policy_no as policy_no, policy_type.policy_type, client_policy.policy_status , client_policy.client_branch_id as branch_id')
|
||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.client_id', $client_id)
|
||||
@ -6859,22 +6852,23 @@ class ClientController extends AdminController
|
||||
|
||||
$hrAccessData['pre_hr_data'] = [];
|
||||
$hrAccessData['pre_policy_data'] = [];
|
||||
$combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id);
|
||||
$combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id , $pre_client_data['id']??'');
|
||||
return $combinedHrAccessData;
|
||||
}
|
||||
|
||||
$pre_client_data = $db2->table('clients')->where('is_active', 1)->where('short_name', $post_client_data['short_name'])->get()->getRowArray();
|
||||
|
||||
if(empty($pre_client_data)){
|
||||
if (empty($pre_client_data)) {
|
||||
|
||||
$hrAccessData['pre_hr_data'] = [];
|
||||
$hrAccessData['pre_policy_data'] = [];
|
||||
$combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id);
|
||||
$combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id , $pre_client_data['id']??'');
|
||||
return $combinedHrAccessData;
|
||||
}
|
||||
|
||||
$hrAccessData['pre_hr_data'] = $db2->table('client_branch')
|
||||
->select('lc.id as pre_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail')
|
||||
->select('lc.id as pre_hr_id, lc.name as hr_name, lc.mobile as hr_mobile, lc.email as hr_mail
|
||||
, client_branch.id as pre_branch_id , client_branch.branch_name as pre_branch_name ' )
|
||||
->join('level_contacts lc', 'client_branch.id = lc.ref_id')
|
||||
->where('client_branch.is_active', 1)
|
||||
->where('lc.is_active', 1)
|
||||
@ -6884,7 +6878,7 @@ class ClientController extends AdminController
|
||||
->getResultArray();
|
||||
|
||||
$hrAccessData['pre_policy_data'] = $db2->table('client_policy')
|
||||
->select('client_policy.id as client_policy_id, client_policy.policy_no as policy_no, policy_type.policy_type, client_policy.policy_status')
|
||||
->select('client_policy.id as client_policy_id, client_policy.policy_no as policy_no, policy_type.policy_type, client_policy.policy_status , client_policy.client_branch_id as branch_id')
|
||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.client_id', $pre_client_data['id'])
|
||||
@ -6892,16 +6886,16 @@ class ClientController extends AdminController
|
||||
->orderBy('client_policy.policy_status', 'desc')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
// dd($hrAccessData);
|
||||
|
||||
$combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id);
|
||||
$combinedHrAccessData = $this->constructHrAccessData($hrAccessData, $client_id ,$pre_client_data['id']);
|
||||
return $combinedHrAccessData;
|
||||
}
|
||||
|
||||
public function constructHrAccessData($data, $client_id)
|
||||
public function constructHrAccessData($data, $client_id , $pre_client_id)
|
||||
{
|
||||
// dd($data);
|
||||
// print_rr($data);die;
|
||||
|
||||
$preHrs = $data['pre_hr_data'];
|
||||
$postHrs = $data['post_hr_data'];
|
||||
$hrAccessTableData = $data['hr_access_table_data'];
|
||||
@ -6917,7 +6911,10 @@ class ClientController extends AdminController
|
||||
'post_hr_id' => $post['post_hr_id'],
|
||||
'hr_name' => $post['hr_name'],
|
||||
'hr_mobile' => $post['hr_mobile'],
|
||||
'hr_mail' => $post['hr_mail']
|
||||
'hr_mail' => $post['hr_mail'],
|
||||
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $post['post_branch_id'] ?? null,
|
||||
'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
];
|
||||
unset($preHrs[$index]); // remove matched pre_hr
|
||||
$found = true;
|
||||
@ -6931,7 +6928,10 @@ class ClientController extends AdminController
|
||||
'post_hr_id' => $post['post_hr_id'],
|
||||
'hr_name' => $post['hr_name'],
|
||||
'hr_mobile' => $post['hr_mobile'],
|
||||
'hr_mail' => $post['hr_mail']
|
||||
'hr_mail' => $post['hr_mail'],
|
||||
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $post['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -6943,7 +6943,10 @@ class ClientController extends AdminController
|
||||
'post_hr_id' => null,
|
||||
'hr_name' => $pre['hr_name'],
|
||||
'hr_mobile' => $pre['hr_mobile'],
|
||||
'hr_mail' => $pre['hr_mail']
|
||||
'hr_mail' => $pre['hr_mail'],
|
||||
'pre_branch_id' => $pre['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $post['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $post['post_branch_name'] ?? null
|
||||
];
|
||||
}
|
||||
|
||||
@ -6968,9 +6971,12 @@ class ClientController extends AdminController
|
||||
'hr_name' => $hr['hr_name'] ?? null,
|
||||
'hr_mobile' => $hr['hr_mobile'] ?? null,
|
||||
'hr_mail' => $hr['hr_mail'] ?? null,
|
||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
'pre_client_id' => $pre_client_id ?? null
|
||||
];
|
||||
}
|
||||
|
||||
} else {
|
||||
// First create a map of HR data by post_hr_id for quick lookup
|
||||
$hrMap = [];
|
||||
@ -7004,7 +7010,11 @@ class ClientController extends AdminController
|
||||
'allowed_cd' => json_decode($access['allowed_cd'], true) ?? [],
|
||||
'hr_name' => $hr['hr_name'],
|
||||
'hr_mobile' => $hr['hr_mobile'],
|
||||
'hr_mail' => $hr['hr_mail']
|
||||
'hr_mail' => $hr['hr_mail'],
|
||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
'pre_client_id' => $pre_client_id ?? null
|
||||
];
|
||||
|
||||
// Remove from map so we know it's been processed
|
||||
@ -7029,6 +7039,10 @@ class ClientController extends AdminController
|
||||
'hr_name' => $hr['hr_name'] ?? null,
|
||||
'hr_mobile' => $hr['hr_mobile'] ?? null,
|
||||
'hr_mail' => $hr['hr_mail'] ?? null,
|
||||
'pre_branch_id' => $hr['pre_branch_id'] ?? null,
|
||||
'post_branch_id' => $hr['post_branch_id'] ?? null ,
|
||||
'post_branch_name' => $hr['post_branch_name'] ?? null ,
|
||||
'pre_client_id' => $pre_client_id ?? null
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -7038,8 +7052,6 @@ class ClientController extends AdminController
|
||||
$resultData['pre_policy_data'] = $data['pre_policy_data'];
|
||||
$resultData['post_policy_data'] = $data['post_policy_data'];
|
||||
$resultData['post_cd_data'] = $data['post_cd_data'];
|
||||
// echo '**********************************************';
|
||||
// print_rr($resultData);die();
|
||||
|
||||
return $resultData;
|
||||
}
|
||||
@ -7082,6 +7094,10 @@ class ClientController extends AdminController
|
||||
|
||||
// INSERT or UPDATE
|
||||
if (empty($value['pk']) || (int)$value['pk'] === 0) {
|
||||
print_rr("inside insert block");
|
||||
print_rr($value);die;
|
||||
|
||||
|
||||
unset($value['pk']); // Prevent insert error
|
||||
$insertedId = $this->HRAccessControlModel->insert($value);
|
||||
if ($insertedId === false) {
|
||||
@ -7090,6 +7106,9 @@ class ClientController extends AdminController
|
||||
$success[] = "Inserted row at index {$index} with ID {$insertedId}.";
|
||||
} else {
|
||||
$update = $this->HRAccessControlModel->update($value['pk'], $value);
|
||||
print_rr("inside update block");
|
||||
print_rr($value);die;
|
||||
|
||||
if ($update === false) {
|
||||
throw new \Exception('Update failed for ID ' . $value['pk'] . ': ' . json_encode($this->HRAccessControlModel->errors()));
|
||||
}
|
||||
@ -7123,7 +7142,6 @@ class ClientController extends AdminController
|
||||
'details' => $success,
|
||||
'data' => $html,
|
||||
], 200);
|
||||
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
@ -7461,6 +7479,84 @@ class ClientController extends AdminController
|
||||
|
||||
return $this->respond(['status' => true, 'message' => 'Demo client data wiped successfully'], 200);
|
||||
}
|
||||
|
||||
private function getClientlistFromPre (){
|
||||
$db2 = \Config\Database::connect('preDB');
|
||||
|
||||
$auto_fetch_client_list = $db2->table('clients')
|
||||
->select('id,client_name')
|
||||
->where('is_active',1)
|
||||
->get()->getResultArray()??[];
|
||||
|
||||
return $auto_fetch_client_list;
|
||||
|
||||
}
|
||||
|
||||
public function auto_fetch_branch(){
|
||||
|
||||
$data = $this->request->getPost();
|
||||
|
||||
$db2 = \Config\Database::connect('preDB');
|
||||
|
||||
$auto_fetch_branch_list = $db2->table('client_branch')
|
||||
->select('id,branch_name')
|
||||
->where('client_id',$data['client_id'])
|
||||
->where('is_active',1)
|
||||
->get()->getResultArray()??[];
|
||||
|
||||
return
|
||||
|
||||
empty($auto_fetch_branch_list)
|
||||
|
||||
? $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'branch list is empty',
|
||||
'data' => []
|
||||
])->setStatusCode(400)
|
||||
|
||||
: $this->response->setJSON([
|
||||
'status' => true,
|
||||
'message' => 'branch list is found' ,
|
||||
'data' => $auto_fetch_branch_list
|
||||
])->setStatusCode(200);
|
||||
}
|
||||
|
||||
public function auto_fetch_branch_details(){
|
||||
|
||||
$data = $this->request->getPost();
|
||||
|
||||
$db2 = \Config\Database::connect('preDB');
|
||||
|
||||
$auto_fetch_branch_details = $db2->table('client_branch')
|
||||
->where('client_id',$data['client_id'])
|
||||
->where('id',$data['branch_id'])
|
||||
->where('is_active',1)
|
||||
->get()->getResultArray()??[];
|
||||
|
||||
return empty($auto_fetch_branch_details)
|
||||
|
||||
? $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'branch details is empty',
|
||||
'data' => []
|
||||
])->setStatusCode(400)
|
||||
|
||||
: $this->response->setJSON([
|
||||
'status' => true,
|
||||
'message' => 'branch details found' ,
|
||||
'data' => $auto_fetch_branch_details
|
||||
])->setStatusCode(200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ class ClientBranchModel extends Model
|
||||
"gst",
|
||||
"sez",
|
||||
"units",
|
||||
"pre_branch_id"
|
||||
];
|
||||
|
||||
public function getBranchAndContactByBranchId($branch_id){
|
||||
|
||||
@ -13,6 +13,9 @@ class HRAccessControlModel extends Model
|
||||
'pre_hr_id',
|
||||
'post_hr_id',
|
||||
'post_client_id',
|
||||
'pre_client_id',
|
||||
'pre_branch_id',
|
||||
'post_branch_id',
|
||||
'allowed_modules',
|
||||
'allowed_pre_policies',
|
||||
'allowed_active_policies',
|
||||
|
||||
@ -70,6 +70,13 @@
|
||||
<div class="row" id="add_branch">
|
||||
<div class="col-12">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<div class="row float-left" style="position: relative; bottom: 20px; left: 13px;">
|
||||
<button type="button" id="btnAutoBranchFetch"
|
||||
class="btn btn-primary waves-effect waves-light btn-sm "> Auto Fetch branch Details</button>
|
||||
</div>
|
||||
|
||||
<div class="row float-right" style="position: relative; bottom: 20px; right: 13px;">
|
||||
<button type="button" id="btnBranchBack"
|
||||
class="btn btn-primary waves-effect waves-light btn-sm btnBack"><span class="mdi mdi-format-list-bulleted"
|
||||
@ -82,7 +89,12 @@
|
||||
<input type="hidden" class="form-control" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||||
<input type="hidden" name="client_id" id="client_id_branch"
|
||||
value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
|
||||
|
||||
<input type="hidden" name="pre_branch_id" id="pre_branch_id"
|
||||
value="<?= isset($pre_branch_id) ? $pre_branch_id : '' ?>" />
|
||||
|
||||
<input type="hidden" name="branch_id_primarykey" id="branch_id_primarykey" />
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
|
||||
@ -401,6 +401,57 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="autoFetchBranchModal" tabindex="-1" role="dialog" aria-labelledby="autoFetchBranchModalLabel" accesskey=""
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" style="margin-left: 400px !important;">
|
||||
<div class="modal-content modal-lg">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="autoFetchBranchModalLabel">Auto Fetch Branch Details</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" style="min-height:auto !important;">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="auto_fetch_client">Client List<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="auto_fetch_client" name="auto_fetch_client" required>
|
||||
<option value="">Select Client</option>
|
||||
<?php if (!empty($auto_fetch_client_list)): ?>
|
||||
<?php foreach ($auto_fetch_client_list as $client_list): ?>
|
||||
<option value="<?= esc($client_list['id']) ?>">
|
||||
<?= esc($client_list['client_name']) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="auto_fetch_branch">Branch List<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="auto_fetch_branch" name="auto_fetch_branch" required>
|
||||
<option value="">Select Branch</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn cancel-btn" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary submit-btn" id="submitAutoFetch">Submit</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
let hrAccessControlHtmlAppended = false;
|
||||
let hrActivityHistoryHtmlAppended = false;
|
||||
@ -699,7 +750,10 @@
|
||||
allowed_pre_policies: getCheckedValues(`${userId}_pre_policies`),
|
||||
allowed_active_policies: getCheckedValues(`${userId}_active_policies`),
|
||||
allowed_cd: getCheckedValues(`${userId}_cd`),
|
||||
allowed_claims: getCheckedValues(`${userId}_claims`)
|
||||
allowed_claims: getCheckedValues(`${userId}_claims`),
|
||||
pre_branch_id: formData.get(`${userId}_pre_branch_id`),
|
||||
post_branch_id: formData.get(`${userId}_post_branch_id`),
|
||||
pre_client_id: formData.get(`${userId}_pre_client_id`)
|
||||
};
|
||||
|
||||
users.push(user);
|
||||
@ -717,7 +771,10 @@
|
||||
allowed_pre_policies: user.allowed_pre_policies.length ? `[${user.allowed_pre_policies.join(',')}]` : '[]',
|
||||
allowed_active_policies: user.allowed_active_policies.length ? `[${user.allowed_active_policies.join(',')}]` : '[]',
|
||||
allowed_cd: user.allowed_cd.length ? `[${user.allowed_cd.join(',')}]` : '[]',
|
||||
allowed_claims: user.allowed_claims.length ? `[${user.allowed_claims.join(',')}]` : '[]'
|
||||
allowed_claims: user.allowed_claims.length ? `[${user.allowed_claims.join(',')}]` : '[]',
|
||||
pre_client_id: user.pre_client_id || "",
|
||||
pre_branch_id: user.pre_branch_id || "",
|
||||
post_branch_id: user.post_branch_id || ""
|
||||
};
|
||||
});
|
||||
|
||||
@ -972,3 +1029,130 @@
|
||||
// console.log('--- END ---');
|
||||
// });
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
$('#btnAutoBranchFetch').click(function() {
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('autoFetchBranchModal'));
|
||||
myModal.show();
|
||||
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$('#auto_fetch_client').change(function() {
|
||||
|
||||
$('#auto_fetch_branch').html(`<option value="">Select Branch</option>`);
|
||||
|
||||
$.ajax({
|
||||
url: "<?php echo base_url('client/branch/auto_fetch_branch'); ?>",
|
||||
type: "POST",
|
||||
data: {
|
||||
client_id: $('#auto_fetch_client').val()
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(response, textStatus, xhr) {
|
||||
if (xhr.status === 200) {
|
||||
let options = `<option value="">Select Branch</option>`;
|
||||
|
||||
response.data.forEach((data) => {
|
||||
options += `<option value="${data.id}">${data.branch_name}</option>`;
|
||||
});
|
||||
|
||||
$('#auto_fetch_branch').html(options);
|
||||
} else {
|
||||
$('#auto_fetch_branch').html('<option value="">No Branch Found</option>');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error("Error occurred:", status, error);
|
||||
},
|
||||
complete: function() {
|
||||
console.log("auto_fetch_client call is completed..!!");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$('#submitAutoFetch').click(function() {
|
||||
|
||||
let client_id = $('#auto_fetch_client').val();
|
||||
let branch_id = $('#auto_fetch_branch').val();
|
||||
|
||||
if (client_id == "" || branch_id == "") {
|
||||
Swal.fire({
|
||||
icon: 'warning',
|
||||
title: 'Missing Data',
|
||||
text: 'Please select both Client and its Branch!',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "<?php echo base_url('client/branch/auto_fetch_branch_details'); ?>",
|
||||
type: "POST",
|
||||
data: {
|
||||
client_id,
|
||||
branch_id
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(response, textStatus, xhr) {
|
||||
if (xhr.status === 200) {
|
||||
|
||||
let result = response.data[0]??[];
|
||||
|
||||
if(response.data[0] == []){
|
||||
console.log("Empty array ..!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
let units = JSON.parse(result['units']);
|
||||
|
||||
let $select = $('#selected');
|
||||
$select.empty();
|
||||
|
||||
units.forEach(unit => {
|
||||
// If you want to mark them as selected, set 'selected' attribute
|
||||
$select.append(`<option value="${unit}" selected>${unit}</option>`);
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#pre_branch_id').val(branch_id);
|
||||
$('#branch_name').val(result['branch_name']??'');
|
||||
$('#branch_code').val(result['branch_code']??'');
|
||||
$('#address1').val(result['address1']??'');
|
||||
$('#address2').val(result['address2']??'');
|
||||
$('#state').val(result['state']??'');
|
||||
$('#district').val(result['district']??'');
|
||||
$('#branch_city').val(result['city']??'');
|
||||
$('#pincode').val(result['pincode']??'');
|
||||
$('#gst').val(result['gst']??'');
|
||||
$('#sez').val(result['sez']??'');
|
||||
|
||||
} else {
|
||||
console.log("User Error thrown");
|
||||
console.log("status" + xhr.status);
|
||||
}
|
||||
|
||||
closeModalById('autoFetchBranchModal');
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error("Error occurred:", status, error);
|
||||
},
|
||||
complete: function() {
|
||||
console.log("auto_fetch_branch_details call is completed..!!");
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
})
|
||||
</script>
|
||||
@ -65,7 +65,10 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
<?php if (isset($hr_access_data) && !empty($hr_access_data)) { ?>
|
||||
<?php if (isset($hr_access_data) && !empty($hr_access_data)) {
|
||||
$listed_pre = [];
|
||||
$listed_post = [];
|
||||
?>
|
||||
<form id="insuranceForm" onsubmit="submitForm(event)">
|
||||
|
||||
<?php foreach ($hr_access_data as $key => $value) {
|
||||
@ -79,13 +82,17 @@
|
||||
<input type="hidden" name="<?= 'user' . $key ?>_pre_hr_id" value="<?= $value['pre_hr_id'] ?>">
|
||||
<input type="hidden" name="<?= 'user' . $key ?>_post_hr_id" value="<?= $value['post_hr_id'] ?>">
|
||||
<input type="hidden" name="<?= 'user' . $key ?>_post_client_id" value="<?= $value['post_client_id'] ?>">
|
||||
<input type="hidden" name="<?= 'user' . $key ?>_pre_branch_id" value="<?= $value['pre_branch_id'] ?>">
|
||||
<input type="hidden" name="<?= 'user' . $key ?>_post_branch_id" value="<?= $value['post_branch_id'] ?>">
|
||||
<input type="hidden" name="<?= 'user' . $key ?>_pre_client_id" value="<?= $value['pre_client_id'] ?>">
|
||||
|
||||
<div class="card-header" onclick="toggleAccordion(this)" style="background-color: #F5FFFF;">
|
||||
<div class="user-info">
|
||||
<h5 class="mb-0"><?= $value['hr_name'] ?>
|
||||
<h5 class="mb-0"> Name -<?= $value['hr_name'] ?>
|
||||
<!-- <i class="mdi mdi-information-outline" aria-hidden="true" data-id="<?= (!empty($value['pre_hr_id']) ? $value['pre_hr_id'] : 0) . '-' . (!empty($value['post_hr_id']) ? $value['post_hr_id'] : 0) ?>"></i> -->
|
||||
</h5>
|
||||
<p class="user-email"><?= $value['hr_mail'] ?></p>
|
||||
<p style="color: black;"> <b>branch - <?= $value['post_branch_name']?></b></p>
|
||||
<p class="user-email"> Mail - <?= $value['hr_mail'] ?></p>
|
||||
</div>
|
||||
<div class="accordion-icon">
|
||||
<i class="mdi mdi-chevron-down"></i>
|
||||
@ -128,6 +135,15 @@
|
||||
<?php foreach ($pre_policy_data as $key1 => $policies) {
|
||||
$statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active';
|
||||
$statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive';
|
||||
if (
|
||||
in_array($policies['branch_id'].'-'.$policies['policy_no'], $listed_pre)
|
||||
&&
|
||||
$value['pre_branch_id'] != $policies['branch_id']
|
||||
) {
|
||||
continue;
|
||||
} else {
|
||||
$listed_pre[] = $policies['branch_id'].'-'.$policies['policy_no'];
|
||||
}
|
||||
?>
|
||||
<div class="checkbox-item">
|
||||
<input type="checkbox" class="policy-checkbox <?= $statusClass ?>" name="<?= 'user' . $key ?>_pre_policies" data-user="<?= $key ?>" data-group="pre" value="<?= $policies['client_policy_id'] ?>"
|
||||
@ -180,12 +196,26 @@
|
||||
<?php foreach ($post_policy_data as $key2 => $policies) {
|
||||
$statusText = $policies['policy_status'] == 1 ? 'Active' : 'In-Active';
|
||||
$statusClass = $policies['policy_status'] == 1 ? 'active' : 'inactive';
|
||||
if(
|
||||
in_array($policies['branch_id'].'-'.$policies['policy_no'] , $listed_post)
|
||||
&&
|
||||
$value['post_branch_id'] != $policies['branch_id']
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$listed_post[] = $policies['branch_id'].'-'.$policies['policy_no'];
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="checkbox-item">
|
||||
<input type="checkbox" class="policy-checkbox <?= $statusClass ?>" id="<?= 'user' . $key ?>-gmc2" name="<?= 'user' . $key ?>_active_policies" data-user="<?= $key ?>" data-group="post"
|
||||
value="<?= $policies['client_policy_id'] ?>" <?php if (in_array($policies['client_policy_id'], $value['allowed_active_policies'])) {
|
||||
echo 'checked';
|
||||
} ?>>
|
||||
|
||||
<label for="<?= 'user' . $key ?>-gmc2" style="<?php if ($policies['policy_status'] == 0) {
|
||||
echo 'color:#ff5757';
|
||||
} ?>">
|
||||
|
||||
@ -1122,6 +1122,29 @@ $(function(){
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function closeModalById(modalId) {
|
||||
// Get the modal element
|
||||
var modal = document.getElementById(modalId);
|
||||
if (!modal) return; // Exit if no modal found
|
||||
|
||||
// Hide it by removing "show" or "in" classes and setting display:none
|
||||
modal.style.display = 'none';
|
||||
modal.classList.remove('in', 'show'); // 'in' for BS3, 'show' for BS4/5
|
||||
modal.setAttribute('aria-hidden', 'true');
|
||||
modal.removeAttribute('aria-modal'); // optional
|
||||
modal.removeAttribute('role'); // optional
|
||||
|
||||
// Remove backdrop if present
|
||||
var backdrop = document.querySelector('.modal-backdrop');
|
||||
if (backdrop) backdrop.remove();
|
||||
|
||||
// Allow page scrolling again
|
||||
document.body.classList.remove('modal-open');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user