Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
bb7ffbb997
@ -358,7 +358,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('getPolicyTypeFields', 'LeadsController::getPolicyTypeFields');
|
||||
$routes->get('removeMultiFile', 'LeadsController::removeMultiFile');
|
||||
$routes->get('removeInstallments', 'LeadsController::removeInstallments');
|
||||
$routes->get('constructHrAccessData', 'ClientController::constructHrAccessData');
|
||||
$routes->get('viewHrAccessData', 'ClientController::viewHrAccessData');
|
||||
$routes->post('saveHrAccessData', 'ClientController::saveHrAccessData');
|
||||
});
|
||||
|
||||
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
|
||||
@ -487,6 +488,7 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
||||
|
||||
$routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin");
|
||||
$routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin");
|
||||
$routes->post("employeeRest/getPostEmployeeDataForAuth", "RestAuthenticationController::getPostEmployeeDataForAuth");
|
||||
|
||||
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
@ -542,6 +544,8 @@ $routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEm
|
||||
$routes->get("sendPushNotification", "EmployeeRestController::sendPushNotification");
|
||||
$routes->post("sendEmail", "EmployeeRestController::send_email");
|
||||
$routes->get("getPolicyLevelEmployeeSummaryData", "EmployeeRestController::getPolicyLevelEmployeeSummaryData");
|
||||
$routes->get("cdTransactionData", "EmployeeRestController::cdTransactionData");
|
||||
$routes->match( ['get', 'post'], 'claimsSearch','EmployeeRestController::claimsSearch');
|
||||
|
||||
$routes->get("getBackToEnrolledDetails", "EmployeeRestController::getBackToEnrolledDetails");
|
||||
|
||||
|
||||
@ -2316,7 +2316,7 @@ class EmployeeRestController extends AdminController
|
||||
|
||||
|
||||
|
||||
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type, client_policy.policy_no as policy_no, client_policy.insurer_id as insurer_id ')
|
||||
$ClientPolicyData = $this->clientPolicyModel->select('client_policy.id as client_policy_id , client_policy.client_id as client_id, client_policy.policy_type_id as policy_type_id, client_policy.is_addon as is_addon , client_policy.open_for_enrollment as OpenForEnrollment , client_policy.inception_type as inception_type, client_policy.policy_no as policy_no, client_policy.insurer_id as insurer_id, DATE_FORMAT(client_policy.policy_end_date, "%d-%m-%Y") AS policy_expiry_date ')
|
||||
->where('client_policy.client_id', $this->request->getGet('client_id') )
|
||||
->where('client_policy.client_branch_id', $this->request->getGet('client_branch_id') )
|
||||
->where('client_policy.is_active', 1 )
|
||||
@ -2552,12 +2552,16 @@ class EmployeeRestController extends AdminController
|
||||
'tm.awb_no_courier_name',
|
||||
'tm.non_id_reason',
|
||||
'tm.pay_initiate_date',
|
||||
'tm.approved_description'
|
||||
'tm.approved_description',
|
||||
'pt.policy_type as policy_type',
|
||||
'cp.policy_no as client_policy_no',
|
||||
]);
|
||||
|
||||
$builder->join('insurers i', 'i.id = tm.insurer_id AND i.is_active = 1', 'left');
|
||||
$builder->join('clients c', 'c.id = tm.client_id AND c.is_active = 1', 'left');
|
||||
$builder->join('ticket_claim_status tcs', 'tcs.id = tm.claim_status_id AND tcs.is_active = 1', 'left');
|
||||
$builder->join('client_policy cp', 'tm.client_policy_id = cp.id', 'left');
|
||||
$builder->join('policy_type pt', 'cp.policy_type_id = pt.id', 'left');
|
||||
|
||||
$builder->where('tm.is_active', 1);
|
||||
|
||||
|
||||
@ -1280,8 +1280,8 @@ class LeadsController extends BaseController
|
||||
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
// 'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
// 'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
];
|
||||
}
|
||||
@ -1322,11 +1322,11 @@ class LeadsController extends BaseController
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
// 'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
// 'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
'Existing Insurer' => $rfq_data['insurer_name'],
|
||||
'TPA ' => $rfq_data['tpa_name'],
|
||||
// 'TPA ' => $rfq_data['tpa_name'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ use App\Models\EmployeeModel;
|
||||
use App\Models\AuthHistoryModel;
|
||||
use App\Models\LevelContactModel;
|
||||
use App\Models\HRAccessControlModel;
|
||||
use App\Models\ClientModel;
|
||||
|
||||
use Firebase\JWT\JWT;
|
||||
// require_once('../vendor/autoload.php');
|
||||
@ -37,6 +38,7 @@ class RestAuthenticationController extends AdminController
|
||||
protected $authHistoryModel;
|
||||
protected $hrModel;
|
||||
protected $hrAccessControlModel;
|
||||
protected $clientModel;
|
||||
|
||||
|
||||
public function __construct()
|
||||
@ -48,6 +50,7 @@ class RestAuthenticationController extends AdminController
|
||||
$this->authHistoryModel = new AuthHistoryModel();
|
||||
$this->hrModel = new LevelContactModel();
|
||||
$this->hrAccessControlModel = new HRAccessControlModel();
|
||||
$this->clientModel = new ClientModel();
|
||||
|
||||
}
|
||||
|
||||
@ -103,6 +106,7 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
$this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine()));
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
@ -110,10 +114,13 @@ class RestAuthenticationController extends AdminController
|
||||
public function verifyEmployeeWithEmailId()
|
||||
{
|
||||
try {
|
||||
|
||||
log_message('error', json_encode($this->request->getJSON()));
|
||||
$email = $this->request->getJSON()->email;
|
||||
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->select('
|
||||
$builder = $this->employeeModel->select('
|
||||
employees.relationship,
|
||||
EP.employee_id,
|
||||
employees.client_id,
|
||||
@ -124,19 +131,38 @@ class RestAuthenticationController extends AdminController
|
||||
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
|
||||
->where('employees.is_active', 1)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employees.emp_status !=', 'truncated')
|
||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||
->where('employees.email_corporate', $email)
|
||||
->where('EP.is_active', 1)
|
||||
->whereIn('EP.status', ['active', 'expired'])
|
||||
->first();
|
||||
->whereIn('EP.status', ['active', 'expired']);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$builder->orderBy('employees.id', 'desc');
|
||||
$employeeData = $builder->first();
|
||||
|
||||
if (isset($employeeData['employee_id'])) {
|
||||
|
||||
$otp = random_int(100000, 999999);
|
||||
|
||||
$update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self')
|
||||
->where('is_active', 1)->set(array('otp' => $otp))
|
||||
->update();
|
||||
// $update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self')
|
||||
// ->where('is_active', 1)->set(array('otp' => $otp))
|
||||
// ->update();
|
||||
|
||||
$builder = $this->employeeModel
|
||||
->where('email_corporate', $email)
|
||||
->where('relationship', 'Self')
|
||||
->where('is_active', 1)
|
||||
->where('id', $employeeData['employee_id']);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('client_id', $client_id);
|
||||
}
|
||||
|
||||
$update = $builder->set(['otp' => $otp])->update();
|
||||
|
||||
if ($update) {
|
||||
|
||||
$common = [
|
||||
@ -164,11 +190,14 @@ class RestAuthenticationController extends AdminController
|
||||
$result = ['user_verification' => false, 'message' => "Verification failed , try again"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
|
||||
} else {
|
||||
$result = ['user_verification' => false, 'message' => "User not found"];
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
|
||||
}
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
$this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine()));
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
|
||||
}
|
||||
}
|
||||
@ -178,53 +207,163 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
$email = $this->request->getJSON()->email;
|
||||
$otp = $this->request->getJSON()->otp;
|
||||
|
||||
$this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self')
|
||||
->where('is_active', 1)->set(array('otp' => $otp))
|
||||
->update();
|
||||
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||
$employee_id = $this->request->getJSON()->employee_id ?? null;
|
||||
|
||||
$builder = $this->employeeModel
|
||||
->where('email_corporate', $email)
|
||||
->where('relationship', 'Self')
|
||||
->where('is_active', 1);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('client_id', $client_id);
|
||||
}
|
||||
|
||||
if (!empty($employee_id)) {
|
||||
$builder->where('id', $employee_id);
|
||||
}
|
||||
|
||||
$builder->set(['otp' => $otp])->update();
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// public function updateEmpMPIN()
|
||||
// {
|
||||
// $requestData = $this->request->getJSON();
|
||||
// print_r($requestData); die;
|
||||
// $mobile_number = $requestData->mobile_number ?? null;
|
||||
// $email_id = $requestData->email_id ?? null;
|
||||
// $new_mpin = $requestData->new_mpin ?? $requestData->mpin ?? null;
|
||||
// $old_mpin = $requestData->old_mpin ?? null;
|
||||
// $is_mpin_skipped = $requestData->is_mpin_skipped ?? null;
|
||||
// $is_biometric_enabled = $requestData->is_biometric_enabled ?? null;
|
||||
|
||||
// if (!$new_mpin) {
|
||||
// return $this->response->setJSON(['status' => false, 'message' => 'MPIN is required.']);
|
||||
// }
|
||||
|
||||
// $query = $this->employeeModel->where('relationship', 'self');
|
||||
|
||||
// if ($mobile_number) {
|
||||
// $query->where('mobile', $mobile_number);
|
||||
// } elseif ($email_id) {
|
||||
// $query->where('email_corporate', $email_id);
|
||||
// } else {
|
||||
// return $this->response->setJSON(['status' => false, 'message' => 'Mobile number or Email ID is required.']);
|
||||
// }
|
||||
|
||||
// if (!empty($old_mpin)) {
|
||||
// $query->where('mpin', $old_mpin);
|
||||
// }
|
||||
|
||||
// // Fetch employee data
|
||||
// $employeeData = $query->first();
|
||||
|
||||
// if (!$employeeData) {
|
||||
// return $this->response->setJSON(['status' => false, 'message' => 'Employee not found or invalid MPIN.']);
|
||||
// }
|
||||
|
||||
// if(!empty($is_mpin_skipped) && !empty($is_biometric_enabled)){
|
||||
// $mpin_data_to_updata = [
|
||||
// 'mpin' => $new_mpin,
|
||||
// 'is_mpin_skipped' => $is_mpin_skipped,
|
||||
// 'is_biometric_enabled' => $is_biometric_enabled
|
||||
// ];
|
||||
// }else{
|
||||
// $mpin_data_to_updata = ['mpin' => $new_mpin];
|
||||
// }
|
||||
|
||||
// // Update MPIN
|
||||
// $updated = $this->employeeModel->update($employeeData['id'], $mpin_data_to_updata);
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
public function updateEmpMPIN()
|
||||
{
|
||||
$requestData = $this->request->getJSON();
|
||||
$mobile_number = $requestData->mobile_number ?? null;
|
||||
$email_id = $requestData->email_id ?? null;
|
||||
$new_mpin = $requestData->new_mpin ?? $requestData->mpin ?? null;
|
||||
$old_mpin = $requestData->old_mpin ?? null;
|
||||
|
||||
if (!$new_mpin) {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'MPIN is required.']);
|
||||
try {
|
||||
log_message('info', 'MPIN update request received.');
|
||||
|
||||
$requestData = $this->request->getJSON();
|
||||
log_message('debug', 'Request data: ' . json_encode($requestData));
|
||||
|
||||
$mobile_number = $requestData->mobile_number ?? null;
|
||||
$email_id = $requestData->email_id ?? null;
|
||||
$new_mpin = $requestData->new_mpin ?? $requestData->mpin ?? null;
|
||||
$old_mpin = $requestData->old_mpin ?? null;
|
||||
$is_mpin_skipped = $requestData->is_mpin_skipped ?? null;
|
||||
$is_biometric_enabled = $requestData->is_biometric_enabled ?? null;
|
||||
|
||||
if (!$new_mpin) {
|
||||
log_message('warning', 'MPIN is missing.');
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'MPIN is required.']);
|
||||
}
|
||||
|
||||
$query = $this->employeeModel->where('relationship', 'self');
|
||||
log_message('info', 'Query initialized with relationship=self');
|
||||
|
||||
if ($mobile_number) {
|
||||
$query->where('mobile', $mobile_number);
|
||||
log_message('info', "Filtering by mobile number: {$mobile_number}");
|
||||
} elseif ($email_id) {
|
||||
$query->where('email_corporate', $email_id);
|
||||
log_message('info', "Filtering by email ID: {$email_id}");
|
||||
} else {
|
||||
log_message('warning', 'Neither mobile number nor email ID provided.');
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Mobile number or Email ID is required.']);
|
||||
}
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$query->where('mpin', $old_mpin);
|
||||
log_message('info', "Verifying old MPIN: {$old_mpin}");
|
||||
}
|
||||
|
||||
$employeeData = $query->first();
|
||||
log_message('debug', 'Employee lookup result: ' . json_encode($employeeData));
|
||||
|
||||
if (!$employeeData) {
|
||||
log_message('warning', 'Employee not found or invalid old MPIN.');
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Employee not found or invalid MPIN.']);
|
||||
}
|
||||
|
||||
$mpin_data_to_update = ['mpin' => $new_mpin];
|
||||
|
||||
if ($is_mpin_skipped != null && $is_biometric_enabled != null) {
|
||||
$mpin_data_to_update['is_mpin_skipped'] = $is_mpin_skipped;
|
||||
$mpin_data_to_update['is_biometric_enabled'] = $is_biometric_enabled;
|
||||
log_message('info', 'Updating MPIN, MPIN skip flag, and biometric flag.');
|
||||
} else {
|
||||
log_message('info', 'Updating MPIN only.');
|
||||
}
|
||||
|
||||
$updated = $this->employeeModel->update($employeeData['id'], $mpin_data_to_update);
|
||||
|
||||
if ($updated) {
|
||||
log_message('info', "MPIN updated successfully for employee ID: {$employeeData['id']}");
|
||||
return $this->response->setJSON([
|
||||
'status' => true,
|
||||
'message' => 'MPIN updated successfully.'
|
||||
]);
|
||||
} else {
|
||||
log_message('error', "Failed to update MPIN for employee ID: {$employeeData['id']}");
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Failed to update MPIN.'
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
log_message('critical', 'Exception in updateEmpMPIN: ' . $e->getMessage());
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Unexpected error occurred.',
|
||||
'error' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
$query = $this->employeeModel->where('relationship', 'self');
|
||||
|
||||
if ($mobile_number) {
|
||||
$query->where('mobile', $mobile_number);
|
||||
} elseif ($email_id) {
|
||||
$query->where('email_corporate', $email_id);
|
||||
} else {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Mobile number or Email ID is required.']);
|
||||
}
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$query->where('mpin', $old_mpin);
|
||||
}
|
||||
|
||||
// Fetch employee data
|
||||
$employeeData = $query->first();
|
||||
|
||||
if (!$employeeData) {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Employee not found or invalid MPIN.']);
|
||||
}
|
||||
|
||||
// Update MPIN
|
||||
$updated = $this->employeeModel->update($employeeData['id'], ['mpin' => $new_mpin]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -237,6 +376,7 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
$otp = isset($this->request->getJSON()->otp) ? $this->request->getJSON()->otp : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||
|
||||
if (isset($this->request->getJSON()->login_by_hr))
|
||||
{
|
||||
@ -244,9 +384,41 @@ class RestAuthenticationController extends AdminController
|
||||
}else{
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.mobile', $mobile_number)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['active', 'expired']);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
|
||||
} else {
|
||||
$employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->where('emp_status !=', 'truncated')->where('is_active', 1)->first();
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.email_corporate', $email_id)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||
->where('otp', $otp);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,7 +440,7 @@ class RestAuthenticationController extends AdminController
|
||||
$result = JWTToken::encode($employeeData);
|
||||
|
||||
if(isset($this->request->getJSON()->otp)){
|
||||
$this->employeeModel->where('email_corporate', $email_id)->where('otp', $otp)->where('relationship', 'self')->set(['otp'=>null])->update();
|
||||
$this->employeeModel->where('id', $employeeData['id'])->where('otp', $otp)->where('relationship', 'self')->set(['otp'=>null])->update();
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
@ -504,11 +676,43 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||
|
||||
if (isset($mobile_number)) {
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.mobile', $mobile_number)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['active', 'expired']);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
|
||||
} else {
|
||||
$employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
||||
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.email_corporate', $email_id)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['active', 'expired']);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
}
|
||||
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
@ -541,6 +745,7 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
$this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine()));
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
@ -553,15 +758,54 @@ class RestAuthenticationController extends AdminController
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$old_mpin = $this->request->getJSON()->old_mpin;
|
||||
$mpin = $this->request->getJSON()->new_mpin;
|
||||
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
// if (isset($mobile_number))
|
||||
// {
|
||||
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
// }else{
|
||||
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
// }
|
||||
|
||||
if (isset($mobile_number)) {
|
||||
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.mobile', $mobile_number)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['active'])
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['active'])
|
||||
->where('employees.mpin', $old_mpin);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
|
||||
} else {
|
||||
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.email_corporate', $email_id)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['active'])
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['active'])
|
||||
->where('employees.mpin', $old_mpin);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
@ -581,49 +825,164 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
$this->myLogger->logme("error", ($th->getMessage().' --- '.$th->getLine()));
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
|
||||
// public function verifyMpin()
|
||||
// {
|
||||
// try {
|
||||
|
||||
// $mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
// $email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
// $mpin = $this->request->getJSON()->mpin;
|
||||
// if (isset($mobile_number))
|
||||
// {
|
||||
// // $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
// $employeeData = $this->employeeModel
|
||||
// ->select('employees.*')
|
||||
// ->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
// ->where('employees.mobile', $mobile_number)
|
||||
// ->where('employees.relationship', 'Self')
|
||||
// ->where('employee_polices.is_active', 1)
|
||||
// ->whereIn('employee_polices.status', ['active'])
|
||||
// ->where('employees.is_active', 1)
|
||||
// ->whereIn('employees.emp_status', ['active'])
|
||||
// ->get();
|
||||
// }else{
|
||||
// // $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
||||
// $employeeData = $this->employeeModel
|
||||
// ->select('employees.*')
|
||||
// ->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
// ->where('employees.email_corporate', $email_id)
|
||||
// ->where('employee_polices.is_active', 1)
|
||||
// ->whereIn('employee_polices.status', ['active'])
|
||||
// ->where('employees.is_active', 1)
|
||||
// ->whereIn('employees.emp_status', ['active'])
|
||||
// ->where("employees.relationship", "Self") // RAW SQL condition
|
||||
// ->first();
|
||||
|
||||
// }
|
||||
// if ($employeeData && $mpin == $employeeData["mpin"]) {
|
||||
|
||||
// $auth = HttpRequestHelper::getRequestInfo();
|
||||
// if ($auth) {
|
||||
// $data = [
|
||||
// 'user_id' => $employeeData['id'],
|
||||
// 'user_type' => 'employee',
|
||||
// 'ip' => $auth['ip'],
|
||||
// 'platform' => $auth['platform'],
|
||||
// 'broswer' => $auth['browser'],
|
||||
// ];
|
||||
|
||||
// $authdata= $this->authHistoryModel->insert($data);
|
||||
|
||||
// }
|
||||
|
||||
// $result = JWTToken::encode($employeeData);
|
||||
// // $result = $employeeData;
|
||||
// return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
// } else {
|
||||
// return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
|
||||
// }
|
||||
// } catch (\Exception $e) {
|
||||
// return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
|
||||
// }
|
||||
// }
|
||||
|
||||
public function verifyMpin()
|
||||
{
|
||||
try {
|
||||
$requestData = $this->request->getJSON(true);
|
||||
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
||||
$mobile_number = $requestData['mobile_number'] ?? null;
|
||||
$email_id = $requestData['email_id'] ?? null;
|
||||
$mpin = $requestData['mpin'] ?? null;
|
||||
$client_id = $requestData['client_id'] ?? null;
|
||||
// print_r($mpin);
|
||||
|
||||
if (!$mpin) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'MPIN is required'], 400);
|
||||
}
|
||||
if ($employeeData && $mpin == $employeeData["mpin"]) {
|
||||
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
$data = [
|
||||
'user_id' => $employeeData['id'],
|
||||
'user_type' => 'employee',
|
||||
'ip' => $auth['ip'],
|
||||
'platform' => $auth['platform'],
|
||||
'broswer' => $auth['browser'],
|
||||
];
|
||||
if ($mobile_number) {
|
||||
|
||||
$authdata= $this->authHistoryModel->insert($data);
|
||||
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.mobile', $mobile_number)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['active'])
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['active']);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
|
||||
|
||||
$result = JWTToken::encode($employeeData);
|
||||
// $result = $employeeData;
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
} elseif ($email_id) {
|
||||
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.email_corporate', $email_id)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['active'])
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['active']);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
|
||||
} else {
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
|
||||
return $this->respond(['status' => 'failed', 'code' => 400, 'data' => 'Mobile number or Email ID is required'], 400);
|
||||
}
|
||||
|
||||
// print_r($employeeData); die;
|
||||
|
||||
if ($employeeData && isset($employeeData['mpin']) && $mpin === $employeeData['mpin']) {
|
||||
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
$this->authHistoryModel->insert([
|
||||
'user_id' => $employeeData['id'],
|
||||
'user_type' => 'employee',
|
||||
'ip' => $auth['ip'],
|
||||
'platform' => $auth['platform'],
|
||||
'broswer' => $auth['browser'], // Note: typo in 'broswer' retained if it's your actual DB field
|
||||
]);
|
||||
}
|
||||
|
||||
$token = JWTToken::encode($employeeData);
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'data' => $token
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'code' => 404,
|
||||
'data' => 'Invalid MPIN'
|
||||
], 200);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
|
||||
$this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine()));
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'code' => 500,
|
||||
'data' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,15 +992,45 @@ class RestAuthenticationController extends AdminController
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
// $mpin = $this->request->getJSON()->mpin;
|
||||
$client_id = $this->request->getJSON()->client_id ?? null;
|
||||
|
||||
|
||||
if (isset($mobile_number))
|
||||
{
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
}else{
|
||||
$employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
||||
}
|
||||
|
||||
// $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.mobile', $mobile_number)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['active', 'expired']);
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
|
||||
}else{
|
||||
// $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.email_corporate', $email_id)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->whereIn('employee_polices.status', ['active', 'expired'])
|
||||
->where('employees.is_active', 1)
|
||||
->whereIn('employees.emp_status', ['active', 'expired']);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
}
|
||||
|
||||
|
||||
if ($employeeData && $employeeData["mpin"] != null) {
|
||||
@ -651,6 +1040,7 @@ class RestAuthenticationController extends AdminController
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Mpin - not found", 'Mpin' =>null],200);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine()));
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
|
||||
}
|
||||
}
|
||||
@ -663,6 +1053,7 @@ class RestAuthenticationController extends AdminController
|
||||
$json = $this->request->getJSON();
|
||||
$mobile_number = $json->mobile_number ?? null;
|
||||
$email_id = $json->email_id ?? null;
|
||||
$client_id = $json->client_id ?? null;
|
||||
|
||||
log_message('info', 'Received input - Mobile: ' . var_export($mobile_number, true) . ', Email: ' . var_export($email_id, true));
|
||||
|
||||
@ -678,19 +1069,46 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
// Step 2: Fetch employee data
|
||||
if ($mobile_number) {
|
||||
|
||||
log_message('info', 'Looking up employee by mobile number: ' . $mobile_number);
|
||||
$employeeData = $this->employeeModel
|
||||
->where('mobile', $mobile_number)
|
||||
->where('relationship', 'self')
|
||||
->first();
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.mobile', $mobile_number)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employee_polices.status', ['active'])
|
||||
->where('employees.is_active', 1)
|
||||
->where('employees.emp_status', ['active']);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
|
||||
} else {
|
||||
|
||||
log_message('info', 'Looking up employee by email: ' . $email_id);
|
||||
$employeeData = $this->employeeModel
|
||||
->where('email_corporate', $email_id)
|
||||
->where('relationship', 'self')
|
||||
->first();
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.*')
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||
->where('employees.email_corporate', $email_id)
|
||||
->where('employees.relationship', 'Self')
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employee_polices.status', ['active'])
|
||||
->where('employees.is_active', 1)
|
||||
->where('employees.emp_status', ['active']);
|
||||
|
||||
if (!empty($client_id)) {
|
||||
$builder->where('employees.client_id', $client_id);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
}
|
||||
|
||||
log_message('info', '$employeeData : ' . json_encode($employeeData));
|
||||
|
||||
// Step 3: Found employee
|
||||
if (!empty($employeeData)) {
|
||||
log_message('info', 'Employee found: ID = ' . $employeeData['id']);
|
||||
@ -728,7 +1146,7 @@ class RestAuthenticationController extends AdminController
|
||||
log_message('warning', 'Employee not found locally. Falling back to third-party API.');
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Employee not found"],200); }
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', 'Exception in forgotMPIN(): ' . $e->getMessage());
|
||||
$this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine()));
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'code' => 500,
|
||||
@ -763,6 +1181,81 @@ class RestAuthenticationController extends AdminController
|
||||
return redirect()->to($url);
|
||||
}
|
||||
|
||||
public function getPostEmployeeDataForAuth()
|
||||
{
|
||||
$params = $this->request->getJSON(true);
|
||||
// print_r( $params); die;
|
||||
|
||||
$mobile_number = $params['mobile_number'] ?? null;
|
||||
$email_id = $params['email_id'] ?? null;
|
||||
$otp = $params['otp'] ?? null;
|
||||
$old_mpin = $params['old_mpin'] ?? null;
|
||||
|
||||
if (empty($mobile_number) && empty($email_id)) {
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'message' => 'Mobile number or Email ID is required.',
|
||||
'data' => [],
|
||||
], 400);
|
||||
}
|
||||
|
||||
if (!empty($mobile_number)) {
|
||||
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.id as employee_id, employees.*')
|
||||
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
|
||||
->where('employees.is_active', 1)
|
||||
->where("TRIM(employees.relationship) = 'self'", null, false)
|
||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||
->where('employees.mobile', $mobile_number)
|
||||
->where('EP.is_active', 1)
|
||||
->whereIn('EP.status', ['active', 'expired']);
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$builder->where('employees.mpin', $old_mpin);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
|
||||
} else {
|
||||
$builder = $this->employeeModel
|
||||
->select('employees.id as employee_id, employees.*')
|
||||
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
|
||||
->where('employees.is_active', 1)
|
||||
->where("TRIM(employees.relationship) = 'self'", null, false)
|
||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||
->where('employees.email_corporate', $email_id)
|
||||
->where('EP.is_active', 1)
|
||||
->whereIn('EP.status', ['active', 'expired']);
|
||||
|
||||
if (!empty($otp)) {
|
||||
$builder->where('employees.otp', $otp);
|
||||
}
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$builder->where('employees.mpin', $old_mpin);
|
||||
}
|
||||
|
||||
$employeeData = $builder->orderBy('employees.id', 'desc')->first();
|
||||
}
|
||||
|
||||
if ($employeeData) {
|
||||
|
||||
$client_data = $this->clientModel->where('is_active', 1)->where('id', $employeeData['client_id'])->first();
|
||||
$employeeData['client_short_name'] = $client_data['short_name'];
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'data' => $employeeData,
|
||||
], 200);
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'message' => 'No employee found.',
|
||||
'data' => [],
|
||||
], 404);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -249,8 +249,19 @@ class ClientPolicyModel extends Model
|
||||
}
|
||||
|
||||
|
||||
public function getDepositData($clientId, $insurerId, $cd_ac_pk = null)
|
||||
{
|
||||
public function getDepositData($clientId, $insurerId, $cd_ac_pk = null, $subTypeOptions = null)
|
||||
{
|
||||
|
||||
if($subTypeOptions != null){
|
||||
$caseSql = "CASE cash_deposit.sub_type";
|
||||
foreach ($subTypeOptions as $key => $label) {
|
||||
$caseSql .= " WHEN {$key} THEN " . $this->db->escape($label);
|
||||
}
|
||||
$caseSql .= " ELSE 'Unknown' END AS sub_type_text";
|
||||
}else{
|
||||
$caseSql = "";
|
||||
}
|
||||
|
||||
// Fetch the deposit data based on client and insurer IDs
|
||||
$query = $this->db->table('cash_deposit')
|
||||
->select('cash_deposit.*')
|
||||
@ -260,6 +271,7 @@ class ClientPolicyModel extends Model
|
||||
// ->select('policies.name as policy_name')
|
||||
->select('policy_type.policy_type')
|
||||
->select('user_profiles.first_name as username')
|
||||
->select($caseSql)
|
||||
->join('user_profiles', 'user_profiles.id = cash_deposit.created_by', 'left')
|
||||
->join('insurers', 'insurers.id = cash_deposit.insurer_id', 'left')
|
||||
->join('clients', 'clients.id = cash_deposit.client_id', 'left')
|
||||
@ -269,7 +281,8 @@ class ClientPolicyModel extends Model
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id', 'left')
|
||||
->where('cash_deposit.client_id', $clientId)
|
||||
->where('cash_deposit.insurer_id', $insurerId)
|
||||
->where('cash_deposit.is_active', 1);
|
||||
->where('cash_deposit.is_active', 1)
|
||||
->where('cd_master.is_active', 1);
|
||||
// ->where('cash_deposit.cd_ac_pk = cd_master.id')
|
||||
if(!empty($cd_ac_pk)){
|
||||
$query->where('cash_deposit.cd_ac_pk', $cd_ac_pk);
|
||||
@ -342,15 +355,32 @@ class ClientPolicyModel extends Model
|
||||
|
||||
public function getDepositlistsummary($id)
|
||||
{
|
||||
return $this->db->table('cash_deposit')
|
||||
->select('insurer_id, cd_ac_pk')
|
||||
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
->where('client_id', $id)
|
||||
->where('is_active', 1)
|
||||
->groupBy('insurer_id')
|
||||
// ->groupBy('cd_ac_pk')
|
||||
->get()
|
||||
->getResult();
|
||||
// return $this->db->table('cash_deposit')
|
||||
// ->select('insurer_id, cd_ac_pk, balance')
|
||||
// // ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
|
||||
// ->where('client_id', $id)
|
||||
// ->where('is_active', 1)
|
||||
// ->orderBy('id', 'desc')
|
||||
// ->groupBy('insurer_id')
|
||||
// // ->groupBy('cd_ac_pk')
|
||||
// ->get()
|
||||
// ->getResult();
|
||||
|
||||
$sql = "
|
||||
SELECT cd.insurer_id, cd.cd_ac_pk, cd.balance
|
||||
FROM cash_deposit cd
|
||||
INNER JOIN (
|
||||
SELECT insurer_id, MAX(id) AS max_id
|
||||
FROM cash_deposit
|
||||
WHERE client_id = ?
|
||||
AND is_active = 1
|
||||
GROUP BY insurer_id
|
||||
) latest ON cd.insurer_id = latest.insurer_id AND cd.id = latest.max_id
|
||||
ORDER BY cd.id DESC
|
||||
";
|
||||
|
||||
return $this->db->query($sql, [$id])->getResult();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -271,6 +271,8 @@ class EmployeeModel extends Model
|
||||
->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
|
||||
->where('employees.is_active', 1)
|
||||
->where('employee_polices.is_active', 1)
|
||||
->where('employees.emp_status', "active")
|
||||
->where('employee_polices.status', "active")
|
||||
->where('employees.emp_code', $emp_code);
|
||||
|
||||
if(!empty($client_id)){
|
||||
|
||||
@ -224,7 +224,28 @@ class EmployeePolicyModel extends Model
|
||||
public function getEmployeePolicy($client_id = 0, $policy_id = 0, $status = [], $branch_id = 0, $emp_code = "", $emp_name = "")
|
||||
{
|
||||
// dd($status);
|
||||
|
||||
$ecard_download_link = "
|
||||
CASE
|
||||
WHEN
|
||||
LOWER(emp.relationship) = 'self' AND
|
||||
employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id != '' AND
|
||||
employee_polices.uhid IS NOT NULL AND employee_polices.uhid != ''
|
||||
THEN
|
||||
CASE
|
||||
WHEN
|
||||
(employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id != '')
|
||||
AND
|
||||
(employee_polices.uhid IS NOT NULL AND employee_polices.uhid != '')
|
||||
THEN
|
||||
CONCAT('" . base_url('download-e-card/') . "', employee_polices.rand_string, '/1')
|
||||
ELSE
|
||||
null
|
||||
END
|
||||
ELSE
|
||||
NULL
|
||||
END AS ecard_download_link
|
||||
";
|
||||
|
||||
$result = $this->select([
|
||||
'employee_polices.*',
|
||||
'policy_type.policy_type as policy_name',
|
||||
@ -257,6 +278,7 @@ class EmployeePolicyModel extends Model
|
||||
'client_branch.branch_code as client_branch_code',
|
||||
'cp.policy_no',
|
||||
'cp.policy_type_id',
|
||||
$ecard_download_link
|
||||
])
|
||||
->join('employees emp', 'employee_polices.employee_id = emp.id')
|
||||
->join('client_policy cp', 'employee_polices.client_policy_id = cp.id') //cp - client policy
|
||||
@ -603,6 +625,7 @@ class EmployeePolicyModel extends Model
|
||||
$insurer_or_tpa = $ref_data['insurer_or_tpa'];
|
||||
|
||||
$endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "AND (a.endorsement_id IS NOT NULL OR a.endorsement_id != '')" : "AND (a.endorsement_id IS NULL OR a.endorsement_id = '')";
|
||||
$subquery_endorsement_condition = "{$insurer_or_tpa}" === 'tpa' ? "WHERE (endorsement_id IS NOT NULL OR endorsement_id != '')" : "WHERE (endorsement_id IS NULL OR endorsement_id = '')";
|
||||
|
||||
|
||||
$query = $this->db->query("
|
||||
@ -676,6 +699,7 @@ class EmployeePolicyModel extends Model
|
||||
CAST(MAX(CASE WHEN field_name = 'premium' THEN old_value END) AS DECIMAL(10,2)) AS old_si_premium,
|
||||
MAX(CASE WHEN field_name = 'si_enhancement_date' THEN new_value END) AS date_of_coverage
|
||||
FROM emp_endorsement
|
||||
$subquery_endorsement_condition
|
||||
GROUP BY emp_code
|
||||
) AS sidata ON a.emp_code = sidata.emp_code
|
||||
WHERE employee_polices.client_policy_id = '{$client_policy_id}'
|
||||
|
||||
@ -47,6 +47,7 @@ class InsurerModel extends Model
|
||||
->where('client_policy.insurer_id', $insurerId)
|
||||
->where('client_policy.client_id', $client_id)
|
||||
->where('cd_master.id = client_policy.cd_ac_pk')
|
||||
->where('cd_master.is_active', 1)
|
||||
->get();
|
||||
|
||||
if ($query->resultID->num_rows > 0) {
|
||||
|
||||
@ -92,7 +92,6 @@
|
||||
<div class="tab-pane fade active show" id="primary_rack_rate_tab">
|
||||
<form role="form" class="parsley-examples" method="post" id="GridForm_"
|
||||
enctype="multipart/form-data">
|
||||
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||||
<input type="hidden" name="client_id" id="Client_id"
|
||||
value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
|
||||
<input type="hidden" name="client_policy_id" id="client_policy_id" />
|
||||
@ -144,7 +143,7 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button class="btn btn-primary waves-effect waves-light mr-1" id="btnGridSubmit_2">Submit</button>
|
||||
<button type="submit" class="btn btn-primary" id="btnGridSubmit_2">Submit</button>
|
||||
<a class="btn btn-secondary waves-effect waves-light mr-1" id="btnGridrename" onclick="renameRackRateTab(this, null)">Rename</a>
|
||||
</div>
|
||||
</form>
|
||||
@ -191,10 +190,9 @@ $(document).on('click', '.close', function() {
|
||||
var rarc_rate_json_array = [];
|
||||
|
||||
$(document).on('submit', 'form[id^="GridForm_"]', function(event) {
|
||||
|
||||
console.log('submitted function called')
|
||||
|
||||
event.preventDefault(); // Prevent the default form submission
|
||||
console.log('submitted function called')
|
||||
|
||||
var form = $(this);
|
||||
console.log('form', form)
|
||||
@ -393,6 +391,8 @@ $('body').on('click', '.btnPolicyModel', function()
|
||||
$("#hidden_unit").val(branch_units[0]);
|
||||
console.log('unit', branch_units[0]);
|
||||
$("#gpa_unit1").val(branch_units[0]);
|
||||
$("#gpa_unit2").val(branch_units[0]);
|
||||
$("#gpa_unit3").val(branch_units[0]);
|
||||
}
|
||||
var data_for_the_rack_rate = JSON.parse(res.premiumData) ?? [];
|
||||
var groupedData = groupByRackRateName(data_for_the_rack_rate) ?? [];
|
||||
@ -747,7 +747,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
|
||||
|
||||
var id_var = 'grid_';
|
||||
|
||||
var default_unit = $('#hidden_unit').val();
|
||||
var default_unit = $('#hidden_unit').val() ?? "";
|
||||
|
||||
|
||||
var dataIdValue = ''
|
||||
@ -787,7 +787,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
|
||||
<div class="form-row" style="width:101%;padding: 10px;" id="removeChild_${Count}">
|
||||
<div class="form-group col-md-3 unitDiv">
|
||||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '3' ? data.unit : '') : ''}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_3[]" id="gpa_unit3" required>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '3' ? data.unit : default_unit) : default_unit}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_3[]" id="gpa_unit3" required>
|
||||
</div>
|
||||
<div class="form-group col-md-1" id="">
|
||||
<label for="mobile">Grade<span class="text-danger">*</span></label>
|
||||
@ -828,12 +828,12 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="">
|
||||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.si : '') : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_sum_si[]" id="gpa_sum_si" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)" required>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.si : '') : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_sum_si[]" id="gpa_sum_si" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)">
|
||||
<div id='gpa_sum_si_number_word' class="text-danger-2" ></div>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.premium : '') : ''}" type="text" class="form-control" placeholder="Enter Premium" name="gpa_sum_premium[]" id="gpa_sum_premium" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)" required>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '1' ? data.premium : '') : ''}" type="text" class="form-control" placeholder="Enter Premium" name="gpa_sum_premium[]" id="gpa_sum_premium" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)">
|
||||
<div id='gpa_sum_premium_number_word' class="text-danger-2" ></div>
|
||||
|
||||
</div>
|
||||
@ -864,7 +864,7 @@ function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = fa
|
||||
<div class="form-row" style="padding: 10px;">
|
||||
<div class="form-group col-md-3 unitDiv">
|
||||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '2' ? data.unit : '') : ''}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit[]" id="gpa_unit2" required>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? (data.si_or_bp == '2' ? data.unit : default_unit) : default_unit}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit[]" id="gpa_unit2" required>
|
||||
</div>
|
||||
<div class="form-col col-md-2">
|
||||
<label for="mobile">Basic Pay<span class="text-danger">*</span></label>
|
||||
@ -1422,16 +1422,16 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
|
||||
html = `<div class="form-row gpa_sum_insure_remove" style="width:101%" id="removeChild_${Count}">
|
||||
<div class="form-group col-md-3 unitDiv">
|
||||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== default_unit ? data.unit : default_unit}"}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_1[]" id="gpa_unit1" required>
|
||||
<input value="${data !== false && data !== undefined && data !== default_unit ? data.unit : default_unit}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_1[]" id="gpa_unit1" required>
|
||||
</div>
|
||||
<div class="form-group col-md-3" id="">
|
||||
<label for="mobile">Sum Insured<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_sum_si[]" id="gpa_sum_si" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)" required>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? data.si : ''}" type="text" class="form-control" placeholder="Enter Sum Insured" name="gpa_sum_si[]" id="gpa_sum_si" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)">
|
||||
<div id='gpa_si_number_word' class="text-danger-2" ></div>
|
||||
</div>
|
||||
<div class="form-group col-md-3">
|
||||
<label for="mobile">Premium<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="gpa_sum_premium[]" id="gpa_sum_premium" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)" required>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? data.premium : ''}" type="text" class="form-control" placeholder="Enter Premium" name="gpa_sum_premium[]" id="gpa_sum_premium" onkeypress = "return onlyNumbers(event)" onchange="formatNumber(this)" >
|
||||
<div id='gpa_premium_number_word' class="text-danger-2" ></div>
|
||||
|
||||
</div>
|
||||
@ -1448,7 +1448,7 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
|
||||
html = `<div class="form-row gpa_band_remove" style="width:101%" id="removeChild_${Count}">
|
||||
<div class="form-group col-md-3 unitDiv">
|
||||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}"}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_3[]" id="gpa_unit3" required>
|
||||
<input value="${data !== false && data !== undefined && data !== default_unit ? data.unit : default_unit}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit_3[]" id="gpa_unit3" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-1" id="">
|
||||
@ -1482,7 +1482,7 @@ function appendGridtHtml(ui_type = false, secondary = false, data = false)
|
||||
<div class="form-row gpa_basic_pay_remove" style="width:101%" id="removeChild_${Count}">
|
||||
<div class="form-group col-md-3 unitDiv">
|
||||
<label for="mobile">Units<span class="text-danger">*</span></label>
|
||||
<input value="${data !== false && data !== undefined && data !== '' ? data.unit : ''}"}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit[]" id="gpa_unit2" required>
|
||||
<input value="${data !== false && data !== undefined && data !== default_unit ? data.unit : default_unit}" type="text" class="form-control" placeholder="Enter Unit" name="gpa_unit[]" id="gpa_unit2" required>
|
||||
</div>
|
||||
|
||||
<div class="form-col col-md-2">
|
||||
@ -3356,7 +3356,6 @@ function appendNewTab(tabNameData = null, data = null)
|
||||
newTabPane.innerHTML = `
|
||||
<form role="form" class="parsley-examples" method="post" id="GridForm_${tabId}"
|
||||
enctype="multipart/form-data">
|
||||
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||||
<input type="hidden" name="client_id" id="Client_id"value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
|
||||
<input type="hidden" name="client_policy_id" id="client_policy_id_${tabId}" value="`+client_policy_for_additional_rack_rate+`"/>
|
||||
<input type="hidden" name="rack_rate_name" id="rack_rate_name_${tabId}" value="${tabName}">
|
||||
@ -3407,7 +3406,7 @@ function appendNewTab(tabNameData = null, data = null)
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn_${tabId}">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnGridSubmit_2_${tabId}">Submit</button>
|
||||
<button type="submit" class="btn btn-primary" id="btnGridSubmit_2_${tabId}">Submit</button>
|
||||
<a class="btn btn-danger waves-effect waves-light mr-1" id="btnGridremove_2_${tabId}" onclick="removeTab(this, '${tabId}', '${tabName}')">Delete</a>
|
||||
<a class="btn btn-secondary waves-effect waves-light mr-1" id="btnGridrename_${tabId}" onclick="renameRackRateTab(this, '${tabId}', '${tabName}')">Rename</a>
|
||||
</div>
|
||||
|
||||
@ -43,18 +43,16 @@
|
||||
|
||||
|
||||
<?php
|
||||
if (!isset($view_ticket_page)) {
|
||||
if ($selected_ticket_type == 1) {
|
||||
include('ticket_form_gmc.php');
|
||||
} else {
|
||||
include('ticket_form_gpa.php');
|
||||
if (!isset($view_ticket_page)) {
|
||||
if ($selected_ticket_type == 1) {
|
||||
include('ticket_form_gmc.php');
|
||||
} else {
|
||||
include('ticket_form_gpa.php');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="modal fade" id="empDetailsModal" tabindex="-1" role="dialog" aria-labelledby="empDetailsModalLabel"
|
||||
aria-hidden="true" aria-modal="true" data-backdrop="static">
|
||||
<div class="modal fade" id="empDetailsModal" role="dialog" aria-labelledby="empDetailsModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -312,44 +310,73 @@ if (!isset($view_ticket_page)) {
|
||||
}
|
||||
|
||||
//append the clients data to the modal
|
||||
function appendClients(data) {
|
||||
$('#emp_client_data_list').empty();
|
||||
// function appendClients(data) {
|
||||
// $('#emp_client_data_list').empty();
|
||||
|
||||
$('#emp_client_data_list').append($('<option>', {
|
||||
value: '0',
|
||||
text: 'Select Client'
|
||||
}));
|
||||
// $('#emp_client_data_list').append($('<option>', {
|
||||
// value: '0',
|
||||
// text: 'Select Client'
|
||||
// }));
|
||||
|
||||
// $.each(data, function(index, item) {
|
||||
// var option = $('<option>', {
|
||||
// value: item.id,
|
||||
// text: item.client_name,
|
||||
// 'data-name': item.client_name,
|
||||
// });
|
||||
|
||||
// $('#emp_client_data_list').append(option).select2();
|
||||
// });
|
||||
|
||||
// }
|
||||
|
||||
function appendClients(data) {
|
||||
let $select = $('#emp_client_data_list');
|
||||
$select.empty();
|
||||
|
||||
let options = '<option value="0">Select Client</option>';
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.client_name,
|
||||
'data-name': item.client_name,
|
||||
});
|
||||
|
||||
$('#emp_client_data_list').append(option).select2();
|
||||
options += `<option value="${item.id}" data-name="${item.client_name}">${item.client_name}</option>`;
|
||||
});
|
||||
|
||||
$select.html(options);
|
||||
$select.select2(); // ✅ Only call once after building all options
|
||||
}
|
||||
|
||||
//append the clients data for mobile search to the modal
|
||||
function appendClientsForMobileSearch(data) {
|
||||
$('#mobile_emp_client_data_list').empty();
|
||||
|
||||
$('#mobile_emp_client_data_list').append($('<option>', {
|
||||
value: '0',
|
||||
text: 'Select Client'
|
||||
}));
|
||||
//append the clients data for mobile search to the modal
|
||||
// function appendClientsForMobileSearch(data) {
|
||||
// $('#mobile_emp_client_data_list').empty();
|
||||
|
||||
// $('#mobile_emp_client_data_list').append($('<option>', {
|
||||
// value: '0',
|
||||
// text: 'Select Client'
|
||||
// }));
|
||||
|
||||
// $.each(data, function(index, item) {
|
||||
// var option = $('<option>', {
|
||||
// value: item.id,
|
||||
// text: item.short_name,
|
||||
// });
|
||||
|
||||
// $('#mobile_emp_client_data_list').append(option).select2();
|
||||
// });
|
||||
|
||||
// }
|
||||
|
||||
function appendClientsForMobileSearch(data) {
|
||||
let $select = $('#mobile_emp_client_data_list');
|
||||
$select.empty();
|
||||
|
||||
let options = '<option value="0">Select Client</option>';
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.short_name,
|
||||
});
|
||||
|
||||
$('#mobile_emp_client_data_list').append(option).select2();
|
||||
options += `<option value="${item.id}">${item.short_name}</option>`;
|
||||
});
|
||||
|
||||
$select.html(options);
|
||||
$select.select2(); // ✅ Only once
|
||||
}
|
||||
|
||||
//append the clients branch data to the modal
|
||||
@ -388,10 +415,10 @@ if (!isset($view_ticket_page)) {
|
||||
$.each(data, function(index, item) {
|
||||
|
||||
if (ticket_type == 1) {
|
||||
console.log("inside if 1");
|
||||
// console.log("inside if 1");
|
||||
if (item.policy_type_id == 2 || item.policy_type_id == 3 || item.policy_type_id == 4 || item
|
||||
.policy_type_id == 5) {
|
||||
console.log("inside if 2");
|
||||
// console.log("inside if 2");
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.policy_type + '-' + item.policy_no,
|
||||
@ -401,9 +428,9 @@ if (!isset($view_ticket_page)) {
|
||||
}
|
||||
|
||||
} else if (ticket_type == 2) {
|
||||
console.log("inside if 3");
|
||||
// console.log("inside if 3");
|
||||
if (item.policy_type_id == 1) {
|
||||
console.log("inside if 4");
|
||||
// console.log("inside if 4");
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.policy_type + '-' + item.policy_no,
|
||||
@ -435,7 +462,7 @@ if (!isset($view_ticket_page)) {
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("inside else condition");
|
||||
// console.log("inside else condition");
|
||||
}
|
||||
|
||||
});
|
||||
@ -498,6 +525,8 @@ if (!isset($view_ticket_page)) {
|
||||
|
||||
function getEmpData(input) {
|
||||
|
||||
console.log('STEP 1', new Date().toLocaleString());
|
||||
|
||||
console.log(input)
|
||||
let param = $(input).val();
|
||||
let url = '<?= base_url('util/getTheEmpDataForClaim/') ?>' + param;
|
||||
@ -513,6 +542,7 @@ if (!isset($view_ticket_page)) {
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
console.log('STEP 2', new Date().toLocaleString());
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status) {
|
||||
@ -625,26 +655,48 @@ if (!isset($view_ticket_page)) {
|
||||
|
||||
}
|
||||
|
||||
// function appendEmployee(data, attrId) {
|
||||
|
||||
// console.log('STEP 3', new Date().toLocaleString());
|
||||
// console.log('data', data)
|
||||
|
||||
// $('#' + attrId).empty();
|
||||
// $('#' + attrId).append($('<option>', {
|
||||
// value: '0',
|
||||
// text: 'Select Employee'
|
||||
// }));
|
||||
|
||||
// $.each(data, function(index, item) {
|
||||
// // console.log(item)
|
||||
// var option = $('<option>', {
|
||||
// value: item.emp_code,
|
||||
// text: item.emp_name + ' - ' + item.emp_code,
|
||||
// });
|
||||
|
||||
// $('#' + attrId).append(option).select2();
|
||||
// });
|
||||
|
||||
// console.log('STEP 4', new Date().toLocaleString());
|
||||
|
||||
// }
|
||||
|
||||
function appendEmployee(data, attrId) {
|
||||
console.log('STEP 3', new Date().toLocaleString());
|
||||
console.log('data', data);
|
||||
|
||||
console.log('data', data)
|
||||
let $select = $('#' + attrId);
|
||||
$select.empty();
|
||||
|
||||
$('#' + attrId).empty();
|
||||
$('#' + attrId).append($('<option>', {
|
||||
value: '0',
|
||||
text: 'Select Employee'
|
||||
}));
|
||||
let options = '<option value="0">Select Employee</option>';
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
console.log(item)
|
||||
var option = $('<option>', {
|
||||
value: item.emp_code,
|
||||
text: item.emp_name + ' - ' + item.emp_code,
|
||||
});
|
||||
|
||||
$('#' + attrId).append(option).select2();
|
||||
options += `<option value="${item.emp_code}">${item.emp_name} - ${item.emp_code}</option>`;
|
||||
});
|
||||
|
||||
$select.html(options); // ⬅ Append all at once
|
||||
$select.select2(); // ⬅ Initialize once after options are set
|
||||
|
||||
console.log('STEP 4', new Date().toLocaleString());
|
||||
}
|
||||
|
||||
function appendMember(data, attrId) {
|
||||
@ -808,40 +860,40 @@ if (!isset($view_ticket_page)) {
|
||||
|
||||
function setMemberData(input) {
|
||||
|
||||
var selectedOption = $(input).find(':selected');
|
||||
var selectedOption = $(input).find(':selected');
|
||||
|
||||
// Retrieve the data-* attributes
|
||||
var empId = selectedOption.data('empid');
|
||||
var empName = selectedOption.data('empname');
|
||||
var policyNo = selectedOption.data('policyno');
|
||||
var tpaNo = selectedOption.data('tpano');
|
||||
var relationship = selectedOption.data('relationship');
|
||||
// Retrieve the data-* attributes
|
||||
var empId = selectedOption.data('empid');
|
||||
var empName = selectedOption.data('empname');
|
||||
var policyNo = selectedOption.data('policyno');
|
||||
var tpaNo = selectedOption.data('tpano');
|
||||
var relationship = selectedOption.data('relationship');
|
||||
|
||||
$('#tpa_no').val(tpaNo);
|
||||
$('#insured_emp_id').val(empId);
|
||||
$('#insured_name').val(empName);
|
||||
// $('#policy_no').val(policyNo);
|
||||
$('#tpa_no').val(tpaNo);
|
||||
$('#insured_emp_id').val(empId);
|
||||
$('#insured_name').val(empName);
|
||||
// $('#policy_no').val(policyNo);
|
||||
|
||||
$('#relationship option').each(function() {
|
||||
if ($(this).text() === relationship) {
|
||||
$(this).prop('selected', true);
|
||||
}
|
||||
});
|
||||
$('#relationship option').each(function() {
|
||||
if ($(this).text() === relationship) {
|
||||
$(this).prop('selected', true);
|
||||
}
|
||||
});
|
||||
|
||||
if (tpaNo == "") {
|
||||
if (tpaNo == "") {
|
||||
|
||||
$('#claim_status_id').val(1)
|
||||
$('#non_id_reason').attr('required', true);
|
||||
var $label = $("#non_id_reason_lable_id");
|
||||
$label.text('*');
|
||||
$('#claim_status_id').val(1)
|
||||
$('#non_id_reason').attr('required', true);
|
||||
var $label = $("#non_id_reason_lable_id");
|
||||
$label.text('*');
|
||||
|
||||
} else {
|
||||
$('#claim_status_id').val(2)
|
||||
$('#non_id_reason').attr('required', false);
|
||||
var $label = $("#non_id_reason_lable_id");
|
||||
$label.text("");
|
||||
} else {
|
||||
$('#claim_status_id').val(2)
|
||||
$('#non_id_reason').attr('required', false);
|
||||
var $label = $("#non_id_reason_lable_id");
|
||||
$label.text("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// $('#employee_data_points').on('change', function() {
|
||||
|
||||
@ -870,25 +922,25 @@ if (!isset($view_ticket_page)) {
|
||||
|
||||
function toResetTheModelFields() {
|
||||
|
||||
$('#emp_mobile_number_for_claim').val('');
|
||||
$('#employee_data_points').val();
|
||||
$('#employee_by_number').val('');
|
||||
$('#member_by_number').val('0').select2();
|
||||
$('#emp_client_data_list').val('0').select2();
|
||||
$('#emp_client_branch_data_list').val('0').select2();
|
||||
$('#emp_client_policy_data_list').val('0').select2();
|
||||
$('#search_by_client_employee').val('0').select2();
|
||||
$('#search_by_client_member').val('0').select2();
|
||||
}
|
||||
$('#emp_mobile_number_for_claim').val('');
|
||||
$('#employee_data_points').val();
|
||||
$('#employee_by_number').val('');
|
||||
$('#member_by_number').val('0').select2();
|
||||
$('#emp_client_data_list').val('0').select2();
|
||||
$('#emp_client_branch_data_list').val('0').select2();
|
||||
$('#emp_client_policy_data_list').val('0').select2();
|
||||
$('#search_by_client_employee').val('0').select2();
|
||||
$('#search_by_client_member').val('0').select2();
|
||||
}
|
||||
|
||||
$('#tpa_no').on('input', function() {
|
||||
let tpaNo = $(this).val().trim();
|
||||
console.log('tpaNo:', tpaNo);
|
||||
$('#tpa_no').on('input', function() {
|
||||
let tpaNo = $(this).val().trim();
|
||||
console.log('tpaNo:', tpaNo);
|
||||
|
||||
let isEmpty = tpaNo === "";
|
||||
$('#claim_status_id').val(isEmpty ? 1 : 2);
|
||||
$('#non_id_reason').prop('required', isEmpty);
|
||||
$('#non_id_reason_lable_id').text(isEmpty ? '*' : '');
|
||||
});
|
||||
let isEmpty = tpaNo === "";
|
||||
$('#claim_status_id').val(isEmpty ? 1 : 2);
|
||||
$('#non_id_reason').prop('required', isEmpty);
|
||||
$('#non_id_reason_lable_id').text(isEmpty ? '*' : '');
|
||||
});
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user