diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index a6cef1ed..ad4ae1aa 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -66,6 +66,7 @@ $routes->group("/user", ["filter" => "authMVC"], function ($routes) {
$routes->get("getuser/(:hash)", "UserController::getuser/$1");
$routes->get("deactive/(:hash)", "UserController::deactive/$1");
$routes->get("rolesandteams", "UserController::getRolesAndTeams");
+ $routes->get("getUserActivityHistory", "UserController::getUserActivityHistory");
});
$routes->group("/dashboard", ["filter" => "authMVC"], function ($routes) {
@@ -360,6 +361,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get('removeInstallments', 'LeadsController::removeInstallments');
$routes->get('viewHrAccessData', 'ClientController::viewHrAccessData');
$routes->post('saveHrAccessData', 'ClientController::saveHrAccessData');
+ $routes->get('removeLevelContacts', 'ClientController::removeLevelContacts');
});
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
@@ -489,10 +491,12 @@ $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->post("logHrActivity", "RestAuthenticationController::logHrActivity");
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
+ $routes->post("logHrActivity", "RestAuthenticationController::logHrActivity");
$routes->post("getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
$routes->post("storeFireBase", "EmployeeRestController::storeFireBase");
@@ -581,6 +585,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
$routes->post('getPolicyStartDate','TicketController::getPolicyStartDate');
$routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID");
$routes->post("getMoreInfo","TicketController::getMoreInfo");
+ $routes->get("getMoreInfo","TicketController::getMoreInfo");
// $routes->post('ticket_messages','TicketController::getTicketMessage');
});
@@ -607,4 +612,5 @@ $routes->get('createEnrollmentBatch','ICICILombardController::createEnrollmentBa
$routes->get('getEnrollmentBatchStatus','ICICILombardController::getEnrollmentBatchStatus');
$routes->get('fetchUHIDDetails','ICICILombardController::fetchUHIDDetails');
-$routes->get('testTracelog','TestBusinessController::a');
\ No newline at end of file
+$routes->get('testTracelog','TestBusinessController::a');
+$routes->get("claimView", "EmployeeRestController::claimView");
diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php
index a1eb3002..26d3ac81 100755
--- a/app/Controllers/ClientController.php
+++ b/app/Controllers/ClientController.php
@@ -143,7 +143,7 @@ class ClientController extends AdminController
// Perform the query
$builder = $db->table($table);
- $isDuplicate = $builder->where($field, $value)->countAllResults() > 0;
+ $isDuplicate = $builder->where($field, $value)->where('is_active', 1)->countAllResults() > 0;
// Return the result
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
@@ -1171,6 +1171,40 @@ class ClientController extends AdminController
}
}
+ public function removeLevelContacts()
+ {
+ $id = $this->request->getGet('id');
+ try {
+ if (empty($id)) {
+ return $this->respond([
+ 'status' => false,
+ 'message' => 'Invalid ID provided. ID is empty',
+ 'data' => $id
+ ], 400);
+ }
+
+ $updated = $this->levelContactModel->update($id, ['is_active' => 0]);
+
+ if ($updated === false) {
+ return $this->respond([
+ 'status' => false,
+ 'message' => 'Failed to remove contact'
+ ], 500);
+ }
+
+ return $this->respond([
+ 'status' => true,
+ 'message' => 'Contact removed successfully'
+ ]);
+ } catch (\Exception $e) {
+ return $this->respond([
+ 'status' => false,
+ 'message' => 'An error occurred: ' . $e->getMessage()
+ ], 500);
+ }
+ }
+
+
public function createClientPolicy()
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index 8a77865c..d8ec8b0e 100755
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -2376,41 +2376,46 @@ class EmployeeRestController extends AdminController
$hr_id = $this->request->getGet('hr_id');
$HRAccessData = $this->getHRAccessData($hr_id,'post_enrollment');
-
- if(isset($HRAccessData['allowed_active_policies']))
+ // print_rr($HRAccessData);die();
+ if(isset($HRAccessData['allowed_cd']))
{
- $policyId = json_decode($HRAccessData['allowed_active_policies'],true);
+ $allowed_cd = json_decode($HRAccessData['allowed_cd'],true);
}else{
- $policyId = [];
+ $allowed_cd = [];
}
-
- if(count($policyId) == 0){
- return $this->respond(['status' => 'failed','code' => (count($policyId) ? 200 : 404),'data' => [] ], 200);
+ // $allowed_cd = [125];
+ // print_r($allowed_cd);die();
+ if(count($allowed_cd) == 0){
+ return $this->respond(['status' => 'failed','code' => (count($allowed_cd) ? 200 : 404),'data' => [] ], 200);
}
$clientId = $this->request->getGet('client_id');
$clientController = new ClientController;
- $result = $clientController->deposit($clientId , $requestFrom = 'rest' , $policyId);
-
+ $result = $clientController->deposit($clientId , $requestFrom = 'rest' , []);
+ // print_rr($result);die();
$data = [];
foreach ($result['clientData'] as $key => $value)
{
- $temp['client_id'] = $value->client_id;
- $temp['insurer_id'] = $value->insurer_id;
- $temp['cd_ac_pk'] = $value->cd_ac_pk;
- $temp['insurer_name'] = $value->insurer_name;
- $temp['cd_master_account_no'] = $value->cd_master_account_no;
- if (isset($result['balances'][$temp['insurer_id']])) {
- $balance = $result['balances'][$temp['insurer_id']]->balance;
- $temp['balance'] = $balance;
- } else {
- $temp['balance'] = "N/A";
+ if( in_array($value->cd_ac_pk, $allowed_cd) )
+ {
+ $temp['client_id'] = $value->client_id;
+ $temp['insurer_id'] = $value->insurer_id;
+ $temp['cd_ac_pk'] = $value->cd_ac_pk;
+ $temp['insurer_name'] = $value->insurer_name;
+ $temp['cd_master_account_no'] = $value->cd_master_account_no;
+
+ if (isset($result['balances'][$temp['insurer_id'].'-'.$temp['cd_ac_pk']])) {
+ $balance = $result['balances'][$temp['insurer_id'].'-'.$temp['cd_ac_pk']]->balance;
+ $temp['balance'] = $balance;
+ } else {
+ $temp['balance'] = "N/A";
+ }
+
+ array_push($data,$temp);
}
-
- array_push($data,$temp);
}
diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php
index 4aa0d89d..daec5ee3 100755
--- a/app/Controllers/RestAuthenticationController.php
+++ b/app/Controllers/RestAuthenticationController.php
@@ -23,6 +23,7 @@ use App\Models\AuthHistoryModel;
use App\Models\LevelContactModel;
use App\Models\HRAccessControlModel;
use App\Models\ClientModel;
+use App\Models\UserActivityHistoryModel;
use Firebase\JWT\JWT;
// require_once('../vendor/autoload.php');
@@ -39,6 +40,7 @@ class RestAuthenticationController extends AdminController
protected $hrModel;
protected $hrAccessControlModel;
protected $clientModel;
+ protected $userActivityHistoryModel;
public function __construct()
@@ -51,6 +53,7 @@ class RestAuthenticationController extends AdminController
$this->hrModel = new LevelContactModel();
$this->hrAccessControlModel = new HRAccessControlModel();
$this->clientModel = new ClientModel();
+ $this->userActivityHistoryModel = new UserActivityHistoryModel();
}
@@ -210,19 +213,19 @@ class RestAuthenticationController extends AdminController
$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);
-
$builder = $this->employeeModel
- ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
- ->where('employees.email_corporate', $email)
- ->where('employees.relationship', 'Self')
- ->where('employees.is_active', 1)
- ->whereIn('employees.emp_status', ['active', 'expired'])
- ->where('EP.is_active', 1)
- ->whereIn('EP.status', ['active', 'expired']);
+ ->where('email_corporate', $email)
+ ->where('relationship', 'Self')
+ ->where('is_active', 1);
+
+ // $builder = $this->employeeModel
+ // ->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
+ // ->where('employees.email_corporate', $email)
+ // ->where('employees.relationship', 'Self')
+ // ->where('employees.is_active', 1)
+ // ->whereIn('employees.emp_status', ['active', 'expired'])
+ // ->where('EP.is_active', 1)
+ // ->whereIn('EP.status', ['active', 'expired']);
if (!empty($client_id)) {
@@ -420,10 +423,10 @@ class RestAuthenticationController extends AdminController
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
} else {
- return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
+ return $this->respond(['status' => 'failed','code' => 404,'data' => []],200);
}
} catch (\Exception $e) {
- return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
+ return $this->respond(['status' => 'failed','code' => 500,'data' =>[], 'error' => $e->getMessage()],500);
}
}
@@ -1231,6 +1234,15 @@ class RestAuthenticationController extends AdminController
], 404);
}
+ public function logHrActivity()
+ {
+ $log_data = $this->request->getJSON();
+ // print_r($json);die();
+ $this->userActivityHistoryModel->insert($log_data);
+ return $this->respond(['status' => 'success','code' => 200,'data' => "logged",],200);
+
+ }
+
}
\ No newline at end of file
diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php
index 139b63e1..1e49aa67 100644
--- a/app/Controllers/TicketController.php
+++ b/app/Controllers/TicketController.php
@@ -50,6 +50,7 @@ class TicketController extends BaseController
protected $employeeModel;
protected $clientPolicyModel;
protected $employeePolicyModel;
+ protected $extraFieldsDisplayForFrontend;
public function __construct()
{
@@ -128,6 +129,7 @@ class TicketController extends BaseController
'((APPROVED_DESCRIBTION))' => 'approved_description',
];
$this->extraFields = [
+
1 => ['non_id_reason'],
10 => ['pay_initiate_date'],
3 => ['raised_date'],
@@ -151,87 +153,124 @@ class TicketController extends BaseController
47 => ['cancel_remark'],
53 => ['cancel_remark'],
58 => ['cancel_remark'],
- ];
+ 2 => [],
+ 6 => [],
+ 12 => [],
+ 15 => [],
+ 16 => [],
+ 17 => [],
+ 18 => [],
+ 19 => [],
+ 21 => [],
+ 22 => [],
+ 23 => [],
+ 25 => [],
+ 26 => [],
+ 27 => [],
+ 28 => [],
+ 29 => [],
+ 31 => [],
+ 32 => [],
+ 33 => [],
+ 35 => [],
+ 36 => [],
+ 37 => [],
+ 38 => [],
+ 39 => [],
+ 41 => [],
+ 42 => [],
+ 43 => [],
+ 45 => [],
+ 46 => [],
+ 49 => [],
+ 50 => [],
+ 51 => [],
+ 52 => [],
+ 55 => [],
+ 56 => [],
+ 57 => [],
+ 60 => []
+ ];
$this->extraFieldsDisplayForFrontend = [
- 1 => [ 'non_id_reason' => 'Non ID Reason' ],
- 10 => [ 'pay_initiate_date' => 'Payment Initiated Date' ],
- 3 => [ 'raised_date' => 'Raised Date' ],
- 4 => [ 'raised_date' => 'Raised Date' ],
- 5 => [
- 'claim_number' => 'Claim Number',
- 'registration_date' => 'Registration Date'
- ],
- 7 => [ 'query_received_date' => 'Query Received Date' ],
- 8 => [
- 'denial_reason' => 'Denial Reason',
- 'denial_date' => 'Denial Date'
- ],
- 9 => [
- 'approved_amount' => 'Approved Amount',
- 'approved_date' => 'Approved Date',
- 'approved_letter' => 'Approved Letter',
- 'approved_description' => 'Approved Description'
- ],
- 11 => [
- 'utr_details' => 'UTR Details',
- 'settled_date' => 'Settled Date',
- 'settle_letter' => 'Settle Letter'
- ],
- 40 => [
- 'approved_amount' => 'Approved Amount',
- 'approved_date' => 'Approved Date',
- 'approved_letter' => 'Approved Letter',
- 'approved_description' => 'Approved Description'
- ],
- 44 => [
- 'utr_details' => 'UTR Details',
- 'settled_date' => 'Settled Date',
- 'settle_letter' => 'Settle Letter'
- ],
- 30 => [
- 'approved_amount' => 'Approved Amount',
- 'approved_date' => 'Approved Date',
- 'approved_letter' => 'Approved Letter',
- 'approved_description' => 'Approved Description'
- ],
- 34 => [
- 'utr_details' => 'UTR Details',
- 'settled_date' => 'Settled Date',
- 'settle_letter' => 'Settle Letter'
- ],
- 20 => [
- 'approved_amount' => 'Approved Amount',
- 'approved_date' => 'Approved Date',
- 'approved_letter' => 'Approved Letter',
- 'approved_description' => 'Approved Description'
- ],
- 24 => [
- 'utr_details' => 'UTR Details',
- 'settled_date' => 'Settled Date',
- 'settle_letter' => 'Settle Letter'
- ],
- 14 => [
- 'return_remark' => 'Return Remark',
- 'awb_no_courier_name' => 'AWB No Courier Name'
- ],
- 48 => [
- 'return_remark' => 'Return Remark',
- 'awb_no_courier_name' => 'AWB No Courier Name'
- ],
- 59 => [
- 'return_remark' => 'Return Remark',
- 'awb_no_courier_name' => 'AWB No Courier Name'
- ],
- 54 => [
- 'return_remark' => 'Return Remark',
- 'awb_no_courier_name' => 'AWB No Courier Name'
- ],
- 13 => [ 'cancel_remark' => 'Cancel Remark' ],
- 47 => [ 'cancel_remark' => 'Cancel Remark' ],
- 53 => [ 'cancel_remark' => 'Cancel Remark' ],
- 58 => [ 'cancel_remark' => 'Cancel Remark' ]
-];
+ 1 => ['non_id_reason' => 'Non ID Reason'],
+ 10 => ['pay_initiate_date' => 'Payment Initiated Date'],
+ 3 => ['raised_date' => 'Raised Date'],
+ 4 => ['raised_date' => 'Raised Date'],
+ 5 => [
+ 'claim_number' => 'Claim Number',
+ 'registration_date' => 'Registration Date'
+ ],
+ 7 => ['query_received_date' => 'Query Received Date'],
+ 8 => [
+ 'denial_reason' => 'Denial Reason',
+ 'denial_date' => 'Denial Date'
+ ],
+ 9 => [
+ 'approved_amount' => 'Approved Amount',
+ 'approved_date' => 'Approved Date',
+ 'approved_letter' => 'Approved Letter',
+ 'approved_description' => 'Approved Description'
+ ],
+ 11 => [
+ 'utr_details' => 'UTR Details',
+ 'settled_date' => 'Settled Date',
+ 'settle_letter' => 'Settle Letter'
+ ],
+ 40 => [
+ 'approved_amount' => 'Approved Amount',
+ 'approved_date' => 'Approved Date',
+ 'approved_letter' => 'Approved Letter',
+ 'approved_description' => 'Approved Description'
+ ],
+ 44 => [
+ 'utr_details' => 'UTR Details',
+ 'settled_date' => 'Settled Date',
+ 'settle_letter' => 'Settle Letter'
+ ],
+ 30 => [
+ 'approved_amount' => 'Approved Amount',
+ 'approved_date' => 'Approved Date',
+ 'approved_letter' => 'Approved Letter',
+ 'approved_description' => 'Approved Description'
+ ],
+ 34 => [
+ 'utr_details' => 'UTR Details',
+ 'settled_date' => 'Settled Date',
+ 'settle_letter' => 'Settle Letter'
+ ],
+ 20 => [
+ 'approved_amount' => 'Approved Amount',
+ 'approved_date' => 'Approved Date',
+ 'approved_letter' => 'Approved Letter',
+ 'approved_description' => 'Approved Description'
+ ],
+ 24 => [
+ 'utr_details' => 'UTR Details',
+ 'settled_date' => 'Settled Date',
+ 'settle_letter' => 'Settle Letter'
+ ],
+ 14 => [
+ 'return_remark' => 'Return Remark',
+ 'awb_no_courier_name' => 'AWB No Courier Name'
+ ],
+ 48 => [
+ 'return_remark' => 'Return Remark',
+ 'awb_no_courier_name' => 'AWB No Courier Name'
+ ],
+ 59 => [
+ 'return_remark' => 'Return Remark',
+ 'awb_no_courier_name' => 'AWB No Courier Name'
+ ],
+ 54 => [
+ 'return_remark' => 'Return Remark',
+ 'awb_no_courier_name' => 'AWB No Courier Name'
+ ],
+ 13 => ['cancel_remark' => 'Cancel Remark'],
+ 47 => ['cancel_remark' => 'Cancel Remark'],
+ 53 => ['cancel_remark' => 'Cancel Remark'],
+ 58 => ['cancel_remark' => 'Cancel Remark']
+ ];
$this->nonIDReason = [
@@ -865,9 +904,10 @@ class TicketController extends BaseController
$ticket_id = $this->request->getPost('ticket_master_id');
$ticket_data = $this->request->getPost();
$ticket_data = $this->formatDateForClaim($ticket_data);
- $ticket_data['claim_status_id'] = $this->getLastMatchedStatus($ticket_data);
- // print_rr($ticket_data); die;
$old_ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first();
+ $ticket_data['claim_status_id'] = $this->getLastMatchedStatus($ticket_data, $old_ticket_data);
+ // print_rr($ticket_data); die;
+
if ($ticket_data) {
$return_value = $this->ticketMasterModel->where('id', $ticket_id)->set($ticket_data)->update();
@@ -1646,7 +1686,7 @@ class TicketController extends BaseController
}
}
- public function getLastMatchedStatus($incoming_form_values)
+ public function getLastMatchedStatus($incoming_form_values, $old_ticket_data)
{
if (empty($incoming_form_values) || !isset($incoming_form_values['claim_status_id']) || !isset($incoming_form_values['extra_fields_array_for_validate'])) {
return null;
@@ -1657,37 +1697,40 @@ class TicketController extends BaseController
// Use the provided `extra_fields_array_for_validate` from the incoming data
$statusMapping = json_decode($incoming_form_values['extra_fields_array_for_validate']);
- foreach ($statusMapping as $status => $requiredFields) {
+ if($incoming_form_values['claim_status_id'] != $old_ticket_data['claim_status_id']){
+ foreach ($statusMapping as $status => $requiredFields) {
- // Ensure requiredFields is an array
- if (!is_array($requiredFields)) {
- $requiredFields = [$requiredFields];
+ if(!empty($requiredFields) && $status != $old_ticket_data['claim_status_id']){
+ // Ensure requiredFields is an array
+ if (!is_array($requiredFields)) {
+ $requiredFields = [$requiredFields];
+ }
+
+ // Check if all required fields exist and are not empty in the incoming form values
+ $allFieldsMatched = true;
+ foreach ($requiredFields as $field) {
- }
-
- // Check if all required fields exist and are not empty in the incoming form values
- $allFieldsMatched = true;
- foreach ($requiredFields as $field) {
+ if(in_array($field, ['approved_description'])){
+ continue;
+ }
- if(in_array($field, ['approved_description'])){
- continue;
- }
-
- if (!isset($incoming_form_values[$field]) || empty($incoming_form_values[$field])) {
- $allFieldsMatched = false;
- break;
+ if (!isset($incoming_form_values[$field]) || empty($incoming_form_values[$field])) {
+ $allFieldsMatched = false;
+ break;
+ }
+ }
+
+ // Update the last matched status if all fields are validated
+ if ($allFieldsMatched) {
+ $lastMatchedStatus = $status;
+ }
}
}
-
- // Update the last matched status if all fields are validated
- if ($allFieldsMatched) {
- $lastMatchedStatus = $status;
- }
- }
- if($lastMatchedStatus == 1){
- if(!empty($incoming_form_values['tpa_no'])){
- $lastMatchedStatus = 2;
+ if($lastMatchedStatus == 1){
+ if(!empty($incoming_form_values['tpa_no'])){
+ $lastMatchedStatus = 2;
+ }
}
}
@@ -1997,11 +2040,11 @@ class TicketController extends BaseController
} else {
// If field is not an array, handle it as a single field
// Check if the field exists in the ticket data
- $data_to_send[$claim_status][$f] = ['display_name' => $displayFields[$status['old_value']][$f] ,'display_value' => isset($ticket_data[$f]) ? $ticket_data[$f] : null];
+ $data_to_send[$claim_status] = ['display_name' => $displayFields[$status['old_value']] ,'display_value' => isset($ticket_data) ? $ticket_data : null];
// Check if the field contains a date and format it
if ($this->isDate($data_to_send[$claim_status][$field])) {
- $data_to_send[$claim_status][$f] = ['display_name' => $displayFields[$status['old_value']][$f] ,'display_value' => date('d-m-Y', strtotime($data_to_send[$claim_status][$f]['display_value']))];
+ // $data_to_send[$claim_status] = ['display_name' => $displayFields[$status['old_value']] ,'display_value' => date('d-m-Y', strtotime($data_to_send[$claim_status]['display_value']))];
}
// $this->myLogger->logme("error", "Data for field {$field}: " . json_encode($data_to_send[$claim_status][$field]));
diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php
index cc23a148..78d3a6c0 100755
--- a/app/Controllers/UserController.php
+++ b/app/Controllers/UserController.php
@@ -6,6 +6,9 @@ use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
+use CodeIgniter\API\ResponseTrait;
+
+use App\Controllers\ClientController;
use App\Models\UserModel;
@@ -13,16 +16,22 @@ use App\Models\RoleModel;
use App\Models\TeamModel;
use App\Models\UserTeamsModel;
use App\Helpers\BookStackUserHelper;
+use App\Models\AuthHistoryModel;
+use App\Models\UserActivityHistoryModel;
class UserController extends AdminController
-{
+{
+ use ResponseTrait;
+
protected $myLogger;
protected $userModel;
protected $roleModel;
protected $teamModel;
protected $userTeamsModel;
protected $bookStack;
+ protected $authHistoryModel;
+ protected $userActivityHistoryModel;
public function __construct()
{
@@ -34,6 +43,8 @@ class UserController extends AdminController
$this->teamModel = new TeamModel();
$this->userTeamsModel = new UserTeamsModel();
$this->bookStack = new BookStackUserHelper();
+ $this->authHistoryModel = new AuthHistoryModel();
+ $this->userActivityHistoryModel = new UserActivityHistoryModel();
}
public function list()
@@ -256,4 +267,300 @@ class UserController extends AdminController
$teamData = $this->teamModel->select('id, name')->findAll();
echo json_encode(array("status" => true , 'roleData' => $roleData, 'teamData' => $teamData,));
}
+
+
+ // public function getUserActivityHistory()
+ // {
+ // $user_id = $this->request->getVar('user_id');
+ // $pre_hr_id = $this->request->getVar('pre_hr_id');
+ // $user_type = $this->request->getVar('user_type');
+
+ // // echo $user_id.' - '.$pre_hr_id;
+ // $field_for_where_condition = 'user_id';
+ // if($user_id == 0 || $user_id == NULL)
+ // {
+ // $field_for_where_condition = 'pre_hr_id';
+ // $user_id = $pre_hr_id;
+ // }
+
+ // if($field_for_where_condition == "pre_hr_id"){
+ // //get login history
+ // $auth_data = $this->authHistoryModel->where('is_active', 1)->where('user_id',$user_id)->where('user_type', $user_type)->findAll();
+ // }else{
+ // $preDB = \Config\Database::connect('preDB');
+ // $auth_data = $preDB->table('auth_history')->where('is_active', 1)->where('user_id',$user_id)->where('user_type', $user_type)->get()->getResultArray();
+ // }
+
+ // //get activity history
+ // $activity_data = $this->userActivityHistoryModel->where($field_for_where_condition,$user_id)->where('user_type', $user_type)->findAll();
+
+ // }
+
+
+ // public function getUserActivityHistory()
+ // {
+ // try {
+ // $client_id = $this->request->getVar('client_id');
+ // $user_id = $this->request->getVar('user_id');
+ // $pre_hr_id = $this->request->getVar('pre_hr_id');
+ // $user_type = $this->request->getVar('user_type');
+
+ // $clientController = new ClientController;
+
+ // if (empty($client_id)) {
+ // return $this->respond(['status' => false,'message' => 'Client Id is required'], 400);
+ // }
+
+ // if (empty($user_type)) {
+ // return $this->respond(['status' => false,'message' => 'User type is required'], 400);
+ // }
+
+ // $field_for_where_condition = 'user_id';
+
+ // if (empty($user_id) || $user_id == 0) {
+ // if (empty($pre_hr_id)) {
+ // return $this->respond(['status' => false,'message' => 'user_id or pre_hr_id must be provided'], 400);
+ // }
+
+ // $field_for_where_condition = 'pre_hr_id';
+ // $user_id = $pre_hr_id;
+ // }
+
+ // // Get login/auth history
+ // if ($field_for_where_condition == 'user_id') {
+ // $auth_data = $this->authHistoryModel
+ // ->where('is_active', 1)
+ // ->where('user_id', $user_id)
+ // ->where('user_type', $user_type)
+ // ->orderBy('created_at', 'desc')
+ // ->findAll();
+ // // print_r(db_connect()->getLastQuery()); die;
+ // } else {
+ // $preDB = \Config\Database::connect('preDB');
+ // $auth_data = $preDB->table('auth_history')
+ // ->where('is_active', 1)
+ // ->where('user_id', $user_id)
+ // ->where('user_type', $user_type)
+ // ->orderBy('created_at', 'desc')
+ // ->get()
+ // ->getResultArray();
+ // }
+
+ // // Get activity history
+ // $activity_data = $this->userActivityHistoryModel
+ // ->where($field_for_where_condition, $user_id)
+ // ->where('user_type', $user_type)
+ // ->findAll();
+
+ // $merged_data = $this->getMergedUserHistory($auth_data, $activity_data);
+
+ // return $this->respond([
+ // 'status' => true,
+ // 'message' => 'User history fetched successfully',
+ // 'auth_history' => $auth_data,
+ // 'activity_log' => $activity_data,
+ // 'merged_data' => $merged_data,
+ // ]);
+
+ // } catch (\Exception $e) {
+ // $this->myLogger->logme("error", ($e->getMessage().' --- '.$e->getLine() . '----' . $e->getTraceAsString()));
+ // return $this->respond([
+ // 'status' => false,
+ // 'message' => 'Error: ' . $e->getMessage()
+ // ], 500);
+ // }
+ // }
+
+ public function getUserActivityHistory()
+ {
+ try {
+ $this->myLogger->logme("error", "User activity history fetch initiated.");
+
+ $client_id = $this->request->getVar('client_id');
+ $startDate = $this->request->getVar('startDate');
+ $endDate = $this->request->getVar('endDate');
+ $user_type = 'hr';
+ $clientController = new ClientController;
+
+ // Convert to DB format with full time range
+ $startDateTime = null;
+ $endDateTime = null;
+
+ if (!empty($startDate)) {
+ $startDateTime = \DateTime::createFromFormat('d-m-Y', $startDate)->format('Y-m-d 00:00:00');
+ $endDateTime = \DateTime::createFromFormat('d-m-Y', $endDate)->format('Y-m-d 23:59:59');
+ }
+
+
+ $this->myLogger->logme("error", "Received client_id: " . $client_id);
+
+ if (empty($client_id)) {
+ $this->myLogger->logme("warning", "Client ID is missing.");
+ return $this->respond(['status' => false, 'message' => 'Client Id is required'], 400);
+ }
+
+ $hr_access_data = $clientController->getHrAccessData($client_id)['hr_access_data'] ?? [];
+ $this->myLogger->logme("error", "Fetched HR access data: " . json_encode($hr_access_data));
+
+ if (empty($hr_access_data)) {
+ $this->myLogger->logme("error", "No HR access data found for client_id: $client_id");
+ $html = view('hr_activity_history');
+ return $this->respond(['status' => true, 'data' => $html, 'list_of_activity_data' => []], 200);
+ }
+
+ $activityMap = [
+ 'export_empdata' => 'Exporting post employee data',
+ 'export_cddata' => 'Exporting cd data',
+ 'export_cdsummary' => 'Exporting cd summary data',
+ 'export_preempdata' => 'Exporting pre employee data',
+ 'import_enrollempdata' => 'Import enrolment file',
+ ];
+
+ $list_of_activity_data = [];
+
+ foreach ($hr_access_data as $key => $value) {
+ $this->myLogger->logme("error", "Processing HR user: " . json_encode($value));
+
+ $auth_data = [];
+ $activity_data = [];
+
+ $hr_name = $value['hr_name'] ?? '';
+ $hr_mail = $value['hr_mail'] ?? '';
+
+ if (!empty($value['pre_hr_id']) && !empty($value['post_hr_id'])) {
+ $this->myLogger->logme("error", "Both pre_hr_id and post_hr_id found. Using post DB for user_id: {$value['post_hr_id']}");
+
+ // Fetch Auth History
+ $auth_query = $this->authHistoryModel
+ ->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at")
+ ->where('is_active', 1)
+ ->where('user_id', $value['post_hr_id'])
+ ->where('user_type', $user_type);
+
+ if (!empty($startDate)) {
+ $auth_query->where('created_at >=', $startDateTime)
+ ->where('created_at <=', $endDateTime);
+ }
+
+ $auth_data = $auth_query->orderBy('created_at', 'desc')->findAll();
+
+
+ // Fetch User Activity
+ $activity_query = $this->userActivityHistoryModel
+ ->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at, activity")
+ ->where('user_id', $value['post_hr_id'])
+ ->where('user_type', $user_type);
+
+ if (!empty($startDate)) {
+ $activity_query->where('created_at >=', $startDateTime)
+ ->where('created_at <=', $endDateTime);
+ }
+
+ $activity_data = $activity_query->findAll();
+
+
+ } elseif (!empty($value['post_hr_id'])) {
+ $this->myLogger->logme("error", "Only post_hr_id found. user_id: {$value['post_hr_id']}");
+
+ $auth_query = $this->authHistoryModel
+ ->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at")
+ ->where('is_active', 1)
+ ->where('user_id', $value['post_hr_id'])
+ ->where('user_type', $user_type);
+
+ if (!empty($startDate)) {
+ $auth_query->where('created_at >=', $startDateTime)
+ ->where('created_at <=', $endDateTime);
+ }
+
+ $auth_data = $auth_query->orderBy('created_at', 'desc')->findAll();
+
+ $activity_query = $this->userActivityHistoryModel
+ ->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at, activity")
+ ->where('user_id', $value['post_hr_id'])
+ ->where('user_type', $user_type);
+
+ if (!empty($startDate)) {
+ $activity_query->where('created_at >=', $startDateTime)
+ ->where('created_at <=', $endDateTime);
+ }
+
+ $activity_data = $activity_query->findAll();
+
+ } elseif (!empty($value['pre_hr_id'])) {
+ $this->myLogger->logme("error", "Only pre_hr_id found. user_id: {$value['pre_hr_id']}");
+
+ $preDB = \Config\Database::connect('preDB');
+
+ $auth_query = $preDB->table('auth_history')
+ ->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at")
+ ->where('is_active', 1)
+ ->where('user_id', $value['pre_hr_id'])
+ ->where('user_type', $user_type);
+
+ if (!empty($startDate)) {
+ $auth_query->where('created_at >=', $startDateTime)
+ ->where('created_at <=', $endDateTime);
+ }
+
+ $auth_data = $auth_query->orderBy('created_at', 'desc')->get()->getResultArray();
+
+ $activity_query = $this->userActivityHistoryModel
+ ->select("DATE_FORMAT(created_at, '%d-%m-%Y %r') AS created_at, activity")
+ ->where('pre_hr_id', $value['pre_hr_id'])
+ ->where('user_type', $user_type);
+
+ if (!empty($startDate)) {
+ $activity_query->where('created_at >=', $startDateTime)
+ ->where('created_at <=', $endDateTime);
+ }
+
+ $activity_data = $activity_query->findAll();
+ }
+
+ foreach ($auth_data as &$entry) {
+ $entry['user_name'] = $hr_name;
+ $entry['user_mail'] = $hr_mail;
+ $entry['activity'] = "Login";
+ }
+
+ foreach ($activity_data as &$entry) {
+ $entry['user_name'] = $hr_name;
+ $entry['user_mail'] = $hr_mail;
+
+ if (!empty($entry['activity']) && isset($activityMap[$entry['activity']])) {
+ $entry['activity'] = $activityMap[$entry['activity']];
+ }
+ }
+
+ $merged_data = array_merge($auth_data, $activity_data);
+ $list_of_activity_data = array_merge($list_of_activity_data, $merged_data);
+
+ $this->myLogger->logme("error", "Merged data count after processing: " . count($list_of_activity_data));
+ }
+
+ usort($list_of_activity_data, function ($a, $b) {
+ return strtotime($b['created_at']) <=> strtotime($a['created_at']);
+ });
+
+ $this->myLogger->logme("error", "Final sorted list_of_activity_data count: " . count($list_of_activity_data));
+
+ $html = view('hr_activity_history', ['data' => $list_of_activity_data]);
+
+ return $this->respond([
+ 'status' => true,
+ 'message' => 'User history fetched successfully',
+ 'data' => $html,
+ 'list_of_activity_data' => $list_of_activity_data,
+ ]);
+
+ } catch (\Exception $e) {
+ $this->myLogger->logme("error", $e->getMessage() . ' --- ' . $e->getLine() . ' ---- ' . $e->getTraceAsString());
+ return $this->respond([
+ 'status' => false,
+ 'message' => 'Error: ' . $e->getMessage()
+ ], 500);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/app/Helpers/excel_util_helper.php b/app/Helpers/excel_util_helper.php
index 00dc0a9d..a2695618 100755
--- a/app/Helpers/excel_util_helper.php
+++ b/app/Helpers/excel_util_helper.php
@@ -252,7 +252,7 @@ if (!function_exists('check_si')) {
if (!$is_si_found && $slab_value['si'] == $received_si) //match si amount
{
- echo 'found - ' . $slab_value['si']. ' - ' . $received_si;
+ // echo 'found - ' . $slab_value['si']. ' - ' . $received_si;
$is_si_found = true;
}
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index f571659e..1ad8e8bb 100755
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -295,11 +295,23 @@ class ClientPolicyModel extends Model
public function getDepositSummary($clientId, $insurerId, $cd_ac_pk)
{
+
+ $subQuery = $this->db->table('cash_deposit')
+ ->select('balance')
+ ->where('client_id', $clientId)
+ ->where('insurer_id', $insurerId)
+ ->where('cd_ac_pk', $cd_ac_pk)
+ ->where('is_active', 1)
+ ->orderBy('id', 'DESC')
+ ->limit(1)
+ ->getCompiledSelect();
+
// Fetch the sum of credit and debit transactions and calculate the balance
- return $this->db->table('cash_deposit')
+ $data = $this->db->table('cash_deposit')
+ ->select("($subQuery) AS balance", false)
->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE 0 END) AS total_credit')
->select('SUM(CASE WHEN transaction_type = "Debit" THEN amount ELSE 0 END) AS total_withdraw')
- ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
+ // ->select('SUM(CASE WHEN transaction_type = "Credit" THEN amount ELSE -amount END) AS balance')
->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
->where('client_id', $clientId)
->where('insurer_id', $insurerId)
@@ -307,6 +319,9 @@ class ClientPolicyModel extends Model
->where('cash_deposit.is_active', 1)
->get()
->getRow();
+
+ // dd($this->db->getLastQuery());
+ return $data;
}
// Inside your clientPolicyModel
// Inside your clientPolicyModel
@@ -347,7 +362,8 @@ class ClientPolicyModel extends Model
foreach ($depositsummary as $summary) {
$insurerId = $summary->insurer_id;
- $balances[$insurerId] = $summary;
+ $cd_ac_pk = $summary->cd_ac_pk;
+ $balances[$insurerId . '-'. $cd_ac_pk] = $summary;
}
return $balances;
@@ -366,20 +382,35 @@ class ClientPolicyModel extends Model
// ->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
+ // ";
+
$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
+ JOIN cd_master cdm ON cdm.id = cd.cd_ac_pk
+ JOIN (
+ SELECT 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
+ WHERE is_active = 1 AND client_id = $id
+ GROUP BY insurer_id, cd_ac_pk
+ ) latest ON latest.max_id = cd.id
+ JOIN insurers on cd.insurer_id = insurers.id
+ WHERE cd.is_active = 1 AND cd.client_id = $id AND cdm.is_active = 1
+ ORDER BY cd.insurer_id;
";
- return $this->db->query($sql, [$id])->getResult();
+ return $this->db->query($sql)->getResult();
}
diff --git a/app/Models/UserActivityHistoryModel.php b/app/Models/UserActivityHistoryModel.php
new file mode 100644
index 00000000..d2f218f1
--- /dev/null
+++ b/app/Models/UserActivityHistoryModel.php
@@ -0,0 +1,19 @@
+ {
+ if(confirmed){
+ if (contactSection) {
- if (contactCount < 3) {
- var addButton = document.querySelector('.ac');
- if (addButton) {
- addButton.style.display = 'block';
+ let unique_param = uniqueId + '_branch_table_pk';
+ console.log('unique_param', unique_param);
+ let other_id = $('#' + unique_param).val();
+ console.log('other_id', other_id);
+
+ contactSection.parentNode.removeChild(contactSection);
+ contactCount--;
+
+ if (contactCount < 3) {
+ var addButton = document.querySelector('.ac');
+ if (addButton) {
+ addButton.style.display = 'block';
+ }
+ }
+
+ if(other_id){
+ removeLevelContacts(other_id);
+ }
+
+ }else{
+
+ $("#name").val('');
+ $("#email").val('');
+ $("#mobile").val('');
+ $("#designation").val('');
+
+ let first_id = $('#branch_table_pk').val();
+ console.log('first_id', first_id);
+ if(first_id){
+ removeLevelContacts(first_id);
+ }
}
}
- }
+ });
}
function storeButtonId(id) {
@@ -839,6 +886,30 @@ function getContactsData() {
return contacts;
}
+function removeLevelContacts(id){
+
+ let url = '= base_url('util/removeLevelContacts') ?>';
+
+ let requestData = {
+ id: id,
+ };
+
+ // Send AJAX request
+ sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
+
+ console.log('Data fetched successfully:', response);
+ if (response.status == true) {
+ toastr.success(response.message, 'SUCCESS');
+ } else {
+ toastr.warning(response.message, 'WARNING');
+ }
+
+ }, function(xhr, status, error) {
+ console.error('Error fetching data:', error);
+ console.error(xhr.responseText);
+ });
+}
+
\ No newline at end of file
diff --git a/app/Views/ticket_form_gmc.php b/app/Views/ticket_form_gmc.php
index b27cd4ee..56e299aa 100644
--- a/app/Views/ticket_form_gmc.php
+++ b/app/Views/ticket_form_gmc.php
@@ -1168,7 +1168,7 @@
$("#infoIcon").click(function() {
var ticket_id = $('#ticket_master_id').val();
getDataForInfo(ticket_id, function(data) {
- console.log("data: ", data);
+ console.log("claims history data response : ", data);
if (data && Object.keys(data).length) {
// openModal();
var myModal = new bootstrap.Modal(document.getElementById('moreInfoModal'));
@@ -1214,7 +1214,11 @@
// Iterate over each status in the data
for (let status in data) {
- if (data.hasOwnProperty(status)) {
+
+ let length = Object.keys(data[status]).length;
+ console.log('length', length);
+
+ if (data.hasOwnProperty(status) && length > 0) {
// Create the status subheading
var statusHeading = document.createElement('h5');
statusHeading.textContent = status;
@@ -1233,7 +1237,8 @@
// Create a label for the field
var fieldLabel = document.createElement('label');
- fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
+ // fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
+ fieldLabel.textContent = field.display_name; // Convert underscores to spaces and capitalize
fieldContainer.appendChild(fieldLabel);
// Create either an input field or a textarea based on the field name
@@ -1242,13 +1247,13 @@
// Create a textarea for 'approved_letter'
fieldInput = document.createElement('textarea');
fieldInput.classList.add('form-control');
- fieldInput.textContent = data[status][field]; // Set the value to the field content
+ fieldInput.textContent = data[status][field].display_value; // Set the value to the field content
} else {
// Create an input field for other fields
fieldInput = document.createElement('input');
fieldInput.type = 'text';
fieldInput.classList.add('form-control');
- fieldInput.value = data[status][field];
+ fieldInput.value = data[status][field].display_value;
}
fieldInput.setAttribute('readonly', 'readonly'); // Set field as readonly
diff --git a/app/Views/ticket_form_gpa.php b/app/Views/ticket_form_gpa.php
index 6aa32e3f..84bedac6 100644
--- a/app/Views/ticket_form_gpa.php
+++ b/app/Views/ticket_form_gpa.php
@@ -932,7 +932,15 @@
// Iterate over each status in the data
for (let status in data) {
- if (data.hasOwnProperty(status)) {
+ console.log('status', status)
+ console.log('data[status]', data[status])
+ console.log('data[status].length', data[status].length)
+
+ let length = Object.keys(data[status]).length;
+ console.log('length', length);
+
+
+ if (data.hasOwnProperty(status) && length > 0) {
// Create the status subheading
var statusHeading = document.createElement('h5');
statusHeading.textContent = status;
@@ -951,7 +959,8 @@
// Create a label for the field
var fieldLabel = document.createElement('label');
- fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
+ // fieldLabel.textContent = field.replace(/_/g, ' ').toUpperCase(); // Convert underscores to spaces and capitalize
+ fieldLabel.textContent = field.display_name;
fieldContainer.appendChild(fieldLabel);
// Create either an input field or a textarea based on the field name
@@ -960,13 +969,13 @@
// Create a textarea for 'approved_letter'
fieldInput = document.createElement('textarea');
fieldInput.classList.add('form-control');
- fieldInput.textContent = data[status][field]; // Set the value to the field content
+ fieldInput.textContent = data[status][field].display_value; // Set the value to the field content
} else {
// Create an input field for other fields
fieldInput = document.createElement('input');
fieldInput.type = 'text';
fieldInput.classList.add('form-control');
- fieldInput.value = data[status][field];
+ fieldInput.value = data[status][field].display_value;
}
fieldInput.setAttribute('readonly', 'readonly'); // Set field as readonly