GWM : claim type update in all tpa
This commit is contained in:
parent
14e7dda615
commit
eaa2e9d5e4
@ -976,6 +976,11 @@ $routes->group('sales', function($routes) {
|
||||
|
||||
// Delete note
|
||||
$routes->delete('notes/(:num)', 'SalesController::deleteNote/$1');
|
||||
|
||||
|
||||
//Dashboard
|
||||
$routes->get('branchLevelDashboard', 'SalesController::branchLevelDashboard');
|
||||
$routes->get('salesManagerLevelDashboard', 'SalesController::salesManagerLevelDashboard');
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ class FhplApiController extends BaseController
|
||||
|
||||
|
||||
if (count($data) && $data['filePath'] == null) {
|
||||
log_message('error', "TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' - Claim or File Missing");
|
||||
log_message('error', "FHPL - Claim Push FAILED | claimId: '.$claimId.' - Claim or File Missing");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ class FhplApiController extends BaseController
|
||||
$pdfPath = WRITEPATH . 'uploads/claim_files/' . $filename;
|
||||
|
||||
if (!file_exists($pdfPath)) {
|
||||
log_message('error', "TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' - PDF not found on server");
|
||||
log_message('error', "FHPL - Claim Push FAILED | claimId: '.$claimId.' - PDF not found on server");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ class FhplApiController extends BaseController
|
||||
// Generate FHPL Token
|
||||
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
|
||||
if (empty($tokenResponse['data']['access_token'])) {
|
||||
log_message('error', "TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' - FHPL Token generation failed");
|
||||
log_message('error', "FHPL - Claim Push FAILED | claimId: '.$claimId.' - FHPL Token generation failed");
|
||||
return;
|
||||
}
|
||||
$token = $tokenResponse['data']['access_token'];
|
||||
@ -152,14 +152,14 @@ class FhplApiController extends BaseController
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH FHPL | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||
log_message('error', 'FHPL - Claim Push | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body);
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH FHPL RESPONSE | ' . json_encode($response));
|
||||
log_message('error', 'FHPL - Claim Push RESPONSE | ' . json_encode($response));
|
||||
|
||||
if($response['status'] != true){
|
||||
log_message('error', 'TPA CLAIM PUSH FAILED FHPL | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
log_message('error', 'FHPL - Claim Push FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_push_response' => json_encode($response) ]);
|
||||
@ -184,10 +184,10 @@ class FhplApiController extends BaseController
|
||||
'updated_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH SUCCESS FHPL | claimId: '.$claimId.' | claimNO: '.$fhplClaimNo);
|
||||
log_message('error', 'FHPL - Claim Push SUCCESS | claimId: '.$claimId.' | claimNO: '.$fhplClaimNo);
|
||||
|
||||
}else {
|
||||
log_message('error', 'TPA CLAIM PUSH API SUCCESS BUT claimsInfo EMPTY | response: '.json_encode($response));
|
||||
log_message('error', 'FHPL - Claim Push API SUCCESS BUT claimsInfo EMPTY | response: '.json_encode($response));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -235,21 +235,18 @@ class FhplApiController extends BaseController
|
||||
// dd($response);
|
||||
|
||||
if (empty($response['data'][0])) {
|
||||
log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
|
||||
log_message('error', 'FHPL - Claim status FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
|
||||
return ['status' => false,'message' => 'API call failed.','data' => $response ];
|
||||
}
|
||||
|
||||
// Extract claim status
|
||||
$claimData = $response['data'][0];
|
||||
$tpa_claim_no = $claimData['CLAIM_ID'] ?? '';
|
||||
$currentStatus = $claimData['CLAIM_STATUS'] ?? '';
|
||||
$tpa_claim_type = $claimData['CLAIM_TYPE'] ?? '';
|
||||
$tpa_ailments = $claimData['AILMENT'] ?? '';
|
||||
|
||||
$status = null;
|
||||
|
||||
// find this claim
|
||||
foreach($response['data'] as $row){
|
||||
if($row['CLAIM_ID']==$ticket['claimNo']){
|
||||
$status = $row['CLAIM_STATUS'];
|
||||
}
|
||||
}
|
||||
|
||||
$map = [
|
||||
$validStatuses = [
|
||||
"In-Progress" => 5,
|
||||
"Under Process" => 5,
|
||||
"Query" => 4,
|
||||
@ -259,14 +256,28 @@ class FhplApiController extends BaseController
|
||||
"Required Information" => 4,
|
||||
];
|
||||
|
||||
if( $status != null && isset($map[$status]))
|
||||
{
|
||||
$this->db->table('ticket_master')->where('id',$claimId)->update(['claim_status_id'=>$map[$status],'tpa_claim_status'=>$status]);
|
||||
log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $status");
|
||||
$updateArray = [
|
||||
'tpa_claim_status' => $currentStatus,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
if (isset($validStatuses[$currentStatus])) {
|
||||
$updateArray['claim_status_id'] = $validStatuses[$currentStatus];
|
||||
}
|
||||
if (!empty($tpa_claim_type)) {
|
||||
$updateArray['tpa_claim_type'] = $tpa_claim_type;
|
||||
}
|
||||
if (!empty($tpa_ailments)) {
|
||||
$updateArray['tpa_ailments'] = $tpa_ailments;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return ['status' => true,'message' => 'Claim status updated.','updated_status' => $status,'api_response' => $response];
|
||||
$this->db->table('ticket_master')->where('id',$claimId)->update($updateArray);
|
||||
log_message('error', "FHPL - Claim status SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||
|
||||
|
||||
|
||||
return ['status' => true,'message' => 'Claim status updated.','updated_status' => $currentStatus,'api_response' => $response];
|
||||
|
||||
}
|
||||
|
||||
@ -297,7 +308,7 @@ class FhplApiController extends BaseController
|
||||
// Generate FHPL Token
|
||||
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
|
||||
if (empty($tokenResponse['data']['access_token'])) {
|
||||
log_message('error', 'Ecard Request FAILED | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | Message: FHPL Token generation failed');
|
||||
log_message('error', 'FHPL - Ecard Request FAILED | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | Message: FHPL Token generation failed');
|
||||
return null;
|
||||
}
|
||||
$token = $tokenResponse['data']['access_token'];
|
||||
@ -317,12 +328,12 @@ class FhplApiController extends BaseController
|
||||
// dd($response);
|
||||
|
||||
if (($response['status'] ?? false) !== true) {
|
||||
log_message('error', 'Ecard Request FAILED | response: ' . json_encode($response));
|
||||
log_message('error', 'FHPL - Ecard Request FAILED | response: ' . json_encode($response));
|
||||
return null;
|
||||
}
|
||||
|
||||
if (empty($response['data'][0])) {
|
||||
log_message('error', 'Ecard Request FAILED | Empty data | response: ' . json_encode($response));
|
||||
log_message('error', 'FHPL - Ecard Request FAILED | Empty data | response: ' . json_encode($response));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -334,8 +345,8 @@ class FhplApiController extends BaseController
|
||||
|
||||
if (!empty($ecardUrl)) {
|
||||
log_message(
|
||||
'info',
|
||||
'Ecard Request PUSH SUCCESS | employeeId: ' . $employeeId .
|
||||
'error',
|
||||
'FHPL - Ecard Request PUSH SUCCESS | employeeId: ' . $employeeId .
|
||||
' | policyNo: ' . $policyNo .
|
||||
' | ecardUrl: ' . $ecardUrl
|
||||
);
|
||||
@ -343,7 +354,7 @@ class FhplApiController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
log_message('error', 'Ecard Request FAILED | response: ' . json_encode($response));
|
||||
log_message('error', 'FHPL - Ecard Request FAILED | response: ' . json_encode($response));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -360,7 +371,7 @@ class FhplApiController extends BaseController
|
||||
$client_policy_id = $requestData['client_policy_id'] ?? null;
|
||||
|
||||
if (empty($policyNo)) {
|
||||
log_message('error', 'TPA ID PULL | policy_no missing in request');
|
||||
log_message('error', 'FHPL - TPA ID Pull | policy_no missing in request');
|
||||
if($function_calling_type == "job"){
|
||||
return ['status' => false, 'message' => 'policy_no required'];
|
||||
}else{
|
||||
@ -369,7 +380,7 @@ class FhplApiController extends BaseController
|
||||
}
|
||||
|
||||
if (empty($client_policy_id)) {
|
||||
log_message('error', 'TPA ID PULL | client_policy_id missing in request');
|
||||
log_message('error', 'FHPL - TPA ID Pull | client_policy_id missing in request');
|
||||
if($function_calling_type == "job"){
|
||||
return ['status' => false, 'message' => 'client_policy_id required'];
|
||||
}else{
|
||||
@ -377,7 +388,7 @@ class FhplApiController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
log_message('error', "TPA ID PULL | called for policy_no: {$policyNo} , client_policy_id: {$client_policy_id}");
|
||||
log_message('error', "FHPL - TPA ID Pull | called for policy_no: {$policyNo} , client_policy_id: {$client_policy_id}");
|
||||
|
||||
// Fetch file download dates
|
||||
$batchFiles = $this->db->table('batch_files f')
|
||||
@ -389,7 +400,7 @@ class FhplApiController extends BaseController
|
||||
->getResultArray();
|
||||
|
||||
if (empty($batchFiles)) {
|
||||
log_message('error', 'TPA ID PULL FAILED | batchFiles is empty for this tpa id pull request');
|
||||
log_message('error', 'FHPL - TPA ID Pull FAILED | batchFiles is empty for this tpa id pull request');
|
||||
if($function_calling_type == "job"){
|
||||
return ['status' => false, 'message' => 'batchFiles not found'];
|
||||
}else{
|
||||
@ -400,7 +411,7 @@ class FhplApiController extends BaseController
|
||||
// Generate FHPL Token
|
||||
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
|
||||
if (empty($tokenResponse['data']['access_token'])) {
|
||||
log_message('error', 'TPA ID PULL | FHPL Token generation failed');
|
||||
log_message('error', 'FHPL - TPA ID Pull | FHPL Token generation failed');
|
||||
if($function_calling_type == "job"){
|
||||
return ['status' => false, 'message' => 'FHPL Token generation failed'];
|
||||
}else{
|
||||
@ -430,12 +441,12 @@ class FhplApiController extends BaseController
|
||||
"Range" => $range
|
||||
];
|
||||
|
||||
log_message('error', "TPA ID PULL | API parems " . json_encode([$url, 'POST', $headers, $body]));
|
||||
log_message('error', "FHPL - TPA ID Pull | API parems " . json_encode([$url, 'POST', $headers, $body]));
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body);
|
||||
|
||||
if (($response['status'] ?? false) !== true) {
|
||||
log_message('error', 'FHPL API FAILED | response: ' . json_encode($response));
|
||||
log_message('error', 'FHPL - TPA ID Pull API FAILED | response: ' . json_encode($response));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -467,7 +478,7 @@ class FhplApiController extends BaseController
|
||||
log_message('error', "Failed to update file table status.");
|
||||
}
|
||||
|
||||
log_message('error', 'TPA ID PULL API FAILED | API failed: Empty menber data for this pull request');
|
||||
log_message('error', 'FHPL - TPA ID Pull API FAILED | API failed: Empty menber data for this pull request');
|
||||
|
||||
if($function_calling_type == "job"){
|
||||
return ['status' => false, 'message' => 'API call failed', 'data' => 'Empty menber data for this pull request'];
|
||||
@ -524,9 +535,9 @@ class FhplApiController extends BaseController
|
||||
|
||||
if ($this->db->affectedRows() > 0) {
|
||||
$updated++;
|
||||
log_message('error', "✅ Updated tpa_id={$m['TPA_TPADETAIL_ID']} for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
|
||||
log_message('error', "FHPL - TPA ID Pull Updated tpa_id={$m['TPA_TPADETAIL_ID']} for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
|
||||
} else {
|
||||
log_message('error', "⚠️ No update (already set or not matched) for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
|
||||
log_message('error', "FHPL - TPA ID Pull No update (already set or not matched) for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -546,7 +557,7 @@ class FhplApiController extends BaseController
|
||||
|
||||
log_message(
|
||||
'error',
|
||||
"❌ No match for Nhance = " . json_encode($nhanceSideData)
|
||||
"FHPL - TPA ID Pull No match for Nhance = " . json_encode($nhanceSideData)
|
||||
);
|
||||
}
|
||||
|
||||
@ -568,7 +579,7 @@ class FhplApiController extends BaseController
|
||||
|
||||
$totalCount = count($allMembers);
|
||||
|
||||
log_message('error', "TPA ID PULL SUCCESS | completed. Total fetched={$totalCount}, updated={$updated}");
|
||||
log_message('error', "FHPL - TPA ID Pull SUCCESS | completed. Total fetched={$totalCount}, updated={$updated}");
|
||||
|
||||
if($function_calling_type == "job"){
|
||||
return [
|
||||
@ -742,6 +753,7 @@ class FhplApiController extends BaseController
|
||||
$response = call_third_party_api($url,'POST',$headers,$body);
|
||||
|
||||
if(!empty($response['data'])){
|
||||
log_message('error', 'FHPL - Sync TPA Claims | Exception thrown while calling GetTPA_ClaimsDetails API: ' . json_encode($errorData));
|
||||
$finalResult = array_merge($finalResult,$response['data']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ class HealthIndiaApiController extends BaseController
|
||||
{
|
||||
helper('api');
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA | Started for claimId: ' . $claimId);
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push | Started for claimId: ' . $claimId);
|
||||
|
||||
$data = $this->db->table('ticket_master tm')
|
||||
->select('
|
||||
@ -117,12 +117,12 @@ class HealthIndiaApiController extends BaseController
|
||||
// dd($data);
|
||||
|
||||
if (!$data) {
|
||||
log_message('error', "TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: {$claimId} - Claim not found");
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - Claim not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($data['filePath'] == null) {
|
||||
log_message('error', "TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: {$claimId} - File Missing");
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - File Missing");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ class HealthIndiaApiController extends BaseController
|
||||
$pdfPath = WRITEPATH . 'uploads/claim_files/' . $filename;
|
||||
|
||||
if (!file_exists($pdfPath)) {
|
||||
log_message('error', "TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: {$claimId} - PDF not found on server at path: {$pdfPath}");
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - PDF not found on server at path: {$pdfPath}");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ class HealthIndiaApiController extends BaseController
|
||||
// Generate Health India Token
|
||||
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
|
||||
if (empty($tokenResponse['data']['result'][0]['access_token'])) {
|
||||
log_message('error', "TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: {$claimId} - Token generation failed");
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - Token generation failed");
|
||||
return;
|
||||
}
|
||||
$token = $tokenResponse['data']['result'][0]['access_token'];
|
||||
@ -201,16 +201,14 @@ class HealthIndiaApiController extends BaseController
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA | claimId: ' . $claimId . ' | URL: ' . $url );
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push | claimId: ' . $claimId . ' | URL: ' . $url );
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body);
|
||||
|
||||
// dd($response);
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA RESPONSE | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
|
||||
if ($response['status'] != true) {
|
||||
log_message('error', 'TPA CLAIM PUSH FAILED HEALTH_INDIA | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push FAILED | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
$this->db->table('ticket_master')
|
||||
->where('id', $claimId)
|
||||
->update(['tpa_push_response' => json_encode($response)]);
|
||||
@ -230,9 +228,9 @@ class HealthIndiaApiController extends BaseController
|
||||
'updated_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH SUCCESS HEALTH_INDIA | claimId: ' . $claimId . ' | CCN: ' . $ccn . ' | CCN_EXT: ' . $ccnExt);
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push SUCCESS | claimId: ' . $claimId . ' | CCN: ' . $ccn . ' | CCN_EXT: ' . $ccnExt);
|
||||
} else {
|
||||
log_message('error', 'TPA CLAIM PUSH HEALTH_INDIA API SUCCESS BUT CCN EMPTY | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push API SUCCESS BUT CCN EMPTY | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -243,7 +241,7 @@ class HealthIndiaApiController extends BaseController
|
||||
{
|
||||
helper('api');
|
||||
|
||||
log_message('error', 'CLAIM STATUS HEALTH_INDIA | Started for claimId: ' . $claimId);
|
||||
log_message('error', 'HEALTH_INDIA - Claim Status | Started for claimId: ' . $claimId);
|
||||
|
||||
$ticket = $this->db->table('ticket_master tm')
|
||||
->select("tm.id, tm.tpa_claim_id as ccn, cp.policy_no, cp.policy_start_date, cp.policy_end_date, tm.emp_code")
|
||||
@ -252,7 +250,7 @@ class HealthIndiaApiController extends BaseController
|
||||
->get()->getRowArray();
|
||||
|
||||
if (!$ticket) {
|
||||
log_message('error', 'CLAIM STATUS FAILED HEALTH_INDIA | claimId: ' . $claimId . ' - Invalid claim');
|
||||
log_message('error', 'HEALTH_INDIA - Claim Status FAILED | claimId: ' . $claimId . ' - Invalid claim');
|
||||
return ['status' => false, 'message' => 'Invalid claim'];
|
||||
}
|
||||
|
||||
@ -260,7 +258,7 @@ class HealthIndiaApiController extends BaseController
|
||||
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
|
||||
|
||||
if (empty($tokenResponse['data']['result'][0]['access_token'])) {
|
||||
log_message('error', 'CLAIM STATUS FAILED HEALTH_INDIA | claimId: ' . $claimId . ' - Token generation failed');
|
||||
log_message('error', 'HEALTH_INDIA - Claim Status FAILED | claimId: ' . $claimId . ' - Token generation failed');
|
||||
return ['status' => false, 'message' => 'Token generation failed'];
|
||||
}
|
||||
|
||||
@ -280,49 +278,59 @@ class HealthIndiaApiController extends BaseController
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
log_message('error', 'CLAIM STATUS HEALTH_INDIA | claimId: ' . $claimId . ' | Request: ' . json_encode($body));
|
||||
log_message('error', 'HEALTH_INDIA - Claim Status | claimId: ' . $claimId . ' | Request: ' . json_encode($body));
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body);
|
||||
|
||||
// dd($response);
|
||||
|
||||
log_message('error', 'CLAIM STATUS HEALTH_INDIA | claimId: ' . $claimId . ' | Response: ' . json_encode($response));
|
||||
|
||||
if (empty($response['data']['result'][0])) {
|
||||
log_message('error', 'CLAIM STATUS FAILED HEALTH_INDIA | claimId: ' . $claimId . ' | Empty response data');
|
||||
log_message('error', 'HEALTH_INDIA - Claim Status FAILED | claimId: ' . $claimId . ' | Empty response data');
|
||||
return ['status' => false, 'message' => 'API call failed.', 'data' => $response];
|
||||
}
|
||||
|
||||
// Extract claim status
|
||||
$claimData = $response['data']['result'][0];
|
||||
$status = $claimData['claiM_STATUS'] ?? null;
|
||||
$tpa_claim_no = $claimData['tpA_CLAIM_NO'] ?? '';
|
||||
$currentStatus = $claimData['claiM_STATUS'] ?? '';
|
||||
$tpa_claim_type = $claimData['typE_OF_CLAIM'] ?? '';
|
||||
$tpa_ailments = $claimData['ailment'] ?? '';
|
||||
|
||||
// Status mapping based on API documentation
|
||||
$map = [
|
||||
$validStatuses = [
|
||||
"In-Progress" => 5,
|
||||
"Under Process" => 5,
|
||||
"Pending for Bill Entry" => 5,
|
||||
"Query" => 4,
|
||||
"Paid" => 11,
|
||||
"Rejected" => 8,
|
||||
"Approved" => 8,
|
||||
"Outstanding" => 5,
|
||||
"Required Information" => 4,
|
||||
"Intimated and File NOT received" => 4,
|
||||
];
|
||||
|
||||
if ($status != null && isset($map[$status])) {
|
||||
$this->db->table('ticket_master')
|
||||
->where('id', $claimId)
|
||||
->update([
|
||||
'claim_status_id' => $map[$status],
|
||||
'tpa_claim_status' => $status
|
||||
]);
|
||||
log_message('error', "CLAIM STATUS SUCCESS HEALTH_INDIA | Updated claimId: {$claimId} with status: {$status}");
|
||||
} else {
|
||||
log_message('error', "CLAIM STATUS HEALTH_INDIA | claimId: {$claimId} | Unknown status: {$status}");
|
||||
$updateArray = [
|
||||
'tpa_claim_status' => $currentStatus,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
if (isset($validStatuses[$currentStatus])) {
|
||||
$updateArray['claim_status_id'] = $validStatuses[$currentStatus];
|
||||
}
|
||||
if (!empty($tpa_claim_type)) {
|
||||
$updateArray['tpa_claim_type'] = $tpa_claim_type;
|
||||
}
|
||||
if (!empty($tpa_ailments)) {
|
||||
$updateArray['tpa_ailments'] = $tpa_ailments;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->db->table('ticket_master')->where('id',$claimId)->update($updateArray);
|
||||
|
||||
log_message('error', "HEALTH_INDIA - Claim Status SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||
|
||||
return [
|
||||
'status' => true,
|
||||
'message' => 'Claim status updated.',
|
||||
'updated_status' => $status,
|
||||
'updated_status' => $currentStatus,
|
||||
'api_response' => $response
|
||||
];
|
||||
}
|
||||
@ -331,7 +339,7 @@ class HealthIndiaApiController extends BaseController
|
||||
{
|
||||
helper('api');
|
||||
|
||||
log_message('error', 'CLAIM STATUS UPDATE BULK HEALTH_INDIA | Started');
|
||||
log_message('error', 'HEALTH_INDIA - Claim Status UPDATE BULK | Started');
|
||||
|
||||
$tickets = $this->db->table('ticket_master tm')
|
||||
->select("tm.id, tm.tpa_claim_id, cp.policy_no")
|
||||
@ -347,7 +355,7 @@ class HealthIndiaApiController extends BaseController
|
||||
$count++;
|
||||
}
|
||||
|
||||
log_message('error', 'CLAIM STATUS UPDATE BULK HEALTH_INDIA | Completed | Updated: ' . $count);
|
||||
log_message('error', 'HEALTH_INDIA - Claim Status UPDATE BULK | Completed | Updated: ' . $count);
|
||||
|
||||
return $this->response->setJSON(['status' => true, 'updated' => $count]);
|
||||
}
|
||||
@ -356,12 +364,12 @@ class HealthIndiaApiController extends BaseController
|
||||
{
|
||||
helper('api');
|
||||
|
||||
log_message('error', "ECARD REQUEST HEALTH_INDIA | Started | employeeId: {$employeeId} | policyNo: {$policyNo} | memberId: {$memberId}");
|
||||
log_message('error', "HEALTH_INDIA - Ecard Request | Started | employeeId: {$employeeId} | policyNo: {$policyNo} | memberId: {$memberId}");
|
||||
|
||||
// Generate Health India Token
|
||||
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
|
||||
if (empty($tokenResponse['data']['result'][0]['access_token'])) {
|
||||
log_message('error', "ECARD REQUEST FAILED HEALTH_INDIA | employeeId: {$employeeId} | policyNo: {$policyNo} | Message: Token generation failed");
|
||||
log_message('error', "HEALTH_INDIA - Ecard Request | employeeId: {$employeeId} | policyNo: {$policyNo} | Message: Token generation failed");
|
||||
return null;
|
||||
}
|
||||
$token = $tokenResponse['data']['result'][0]['access_token'];
|
||||
@ -380,19 +388,19 @@ class HealthIndiaApiController extends BaseController
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
log_message('error', 'ECARD REQUEST HEALTH_INDIA | Request: ' . json_encode($body));
|
||||
log_message('error', 'HEALTH_INDIA - Ecard Request | Request: ' . json_encode($body));
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body);
|
||||
|
||||
log_message('error', 'ECARD REQUEST HEALTH_INDIA | Response: ' . json_encode($response));
|
||||
log_message('error', 'HEALTH_INDIA - Ecard Request | Response: ' . json_encode($response));
|
||||
|
||||
if (($response['status'] ?? false) !== true) {
|
||||
log_message('error', 'ECARD REQUEST FAILED HEALTH_INDIA | response: ' . json_encode($response));
|
||||
log_message('error', 'HEALTH_INDIA - Ecard Request | response: ' . json_encode($response));
|
||||
return null;
|
||||
}
|
||||
|
||||
if (empty($response['data']['result'][0])) {
|
||||
log_message('error', 'ECARD REQUEST FAILED HEALTH_INDIA | Empty data | response: ' . json_encode($response));
|
||||
log_message('error', 'HEALTH_INDIA - Ecard Request | Empty data | response: ' . json_encode($response));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -402,12 +410,12 @@ class HealthIndiaApiController extends BaseController
|
||||
$ecardUrl = $apiData['membeR_ECARD'] ?? '';
|
||||
|
||||
if (!empty($ecardUrl)) {
|
||||
log_message('error', "ECARD REQUEST SUCCESS HEALTH_INDIA | employeeId: {$employeeId} | policyNo: {$policyNo} | memberId: {$memberId} | ecardUrl: {$ecardUrl}");
|
||||
log_message('error', "HEALTH_INDIA - Ecard Request | employeeId: {$employeeId} | policyNo: {$policyNo} | memberId: {$memberId} | ecardUrl: {$ecardUrl}");
|
||||
return $ecardUrl;
|
||||
}
|
||||
}
|
||||
|
||||
log_message('error', 'ECARD REQUEST FAILED HEALTH_INDIA | response: ' . json_encode($response));
|
||||
log_message('error', 'HEALTH_INDIA - Ecard Request | response: ' . json_encode($response));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -424,7 +432,7 @@ class HealthIndiaApiController extends BaseController
|
||||
|
||||
|
||||
if (empty($policyNo)) {
|
||||
log_message('error', 'TPA ID PULL HEALTH_INDIA | policy_no missing in request');
|
||||
log_message('error', 'HEALTH_INDIA - TPA ID Pull | policy_no missing in request');
|
||||
if ($function_calling_type == "job") {
|
||||
return ['status' => false, 'message' => 'policy_no required'];
|
||||
} else {
|
||||
@ -433,7 +441,7 @@ class HealthIndiaApiController extends BaseController
|
||||
}
|
||||
|
||||
if (empty($client_policy_id)) {
|
||||
log_message('error', 'TPA ID PULL HEALTH_INDIA | client_policy_id missing in request');
|
||||
log_message('error', 'HEALTH_INDIA - TPA ID Pull | client_policy_id missing in request');
|
||||
if ($function_calling_type == "job") {
|
||||
return ['status' => false, 'message' => 'client_policy_id required'];
|
||||
} else {
|
||||
@ -441,7 +449,7 @@ class HealthIndiaApiController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
log_message('error', "TPA ID PULL HEALTH_INDIA | called for policy_no: {$policyNo}, client_policy_id: {$client_policy_id}");
|
||||
log_message('error', "HEALTH_INDIA - TPA ID Pull | called for policy_no: {$policyNo}, client_policy_id: {$client_policy_id}");
|
||||
|
||||
// Fetch file download dates
|
||||
$batchFiles = $this->db->table('batch_files f')
|
||||
@ -455,7 +463,7 @@ class HealthIndiaApiController extends BaseController
|
||||
|
||||
|
||||
if (empty($batchFiles)) {
|
||||
log_message('error', 'TPA ID PULL FAILED HEALTH_INDIA | batchFiles is empty for this tpa id pull request');
|
||||
log_message('error', 'HEALTH_INDIA - TPA ID Pull FAILED | batchFiles is empty for this tpa id pull request');
|
||||
if ($function_calling_type == "job") {
|
||||
return ['status' => false, 'message' => 'batchFiles not found'];
|
||||
} else {
|
||||
@ -466,7 +474,7 @@ class HealthIndiaApiController extends BaseController
|
||||
// Generate Health India Token
|
||||
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
|
||||
if (empty($tokenResponse['data']['result'][0]['access_token'])) {
|
||||
log_message('error', 'TPA ID PULL HEALTH_INDIA | Token generation failed');
|
||||
log_message('error', 'HEALTH_INDIA - TPA ID Pull | Token generation failed');
|
||||
if ($function_calling_type == "job") {
|
||||
return ['status' => false, 'message' => 'Token generation failed'];
|
||||
} else {
|
||||
@ -487,16 +495,16 @@ class HealthIndiaApiController extends BaseController
|
||||
"policY_NUMBER" => $policyNo
|
||||
];
|
||||
|
||||
log_message('error', "TPA ID PULL HEALTH_INDIA | API params: " . json_encode(['url' => $url, 'method' => 'POST', 'body' => $body]));
|
||||
log_message('error', "HEALTH_INDIA - TPA ID Pull | API params: " . json_encode(['url' => $url, 'method' => 'POST', 'body' => $body]));
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body);
|
||||
|
||||
// dd($response);
|
||||
|
||||
log_message('error', "TPA ID PULL HEALTH_INDIA | API Response Received ");
|
||||
log_message('error', "HEALTH_INDIA - TPA ID Pull | API Response Received ");
|
||||
|
||||
if (($response['status'] ?? false) !== true) {
|
||||
log_message('error', 'HEALTH_INDIA API FAILED | response: ' . json_encode($response));
|
||||
log_message('error', 'HEALTH_INDIA - TPA ID Pull API FAILED | response: ' . json_encode($response));
|
||||
|
||||
// update file table status after the tpa id failed to update
|
||||
if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
|
||||
@ -519,7 +527,7 @@ class HealthIndiaApiController extends BaseController
|
||||
!is_array($response['data']['result']) ||
|
||||
count($response['data']['result']) === 0
|
||||
) {
|
||||
log_message('error', 'TPA ID PULL API FAILED HEALTH_INDIA | Empty member data for this pull request');
|
||||
log_message('error', 'HEALTH_INDIA - TPA ID Pull API FAILED | Empty member data for this pull request');
|
||||
|
||||
// update file table status after the tpa id failed to update
|
||||
if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
|
||||
@ -544,7 +552,7 @@ class HealthIndiaApiController extends BaseController
|
||||
$filePath = WRITEPATH . 'tmp/' . time() . '_' . $requestData['file_id'] . '.json';
|
||||
file_put_contents($filePath, $json);
|
||||
|
||||
log_message('error', "TPA ID PULL HEALTH_INDIA | Saved JSON to: {$filePath}");
|
||||
log_message('error', "HEALTH_INDIA - TPA ID Pull | Saved JSON to: {$filePath}");
|
||||
|
||||
// Call a job for dump JSON data to DB
|
||||
$job_details = new Jobs();
|
||||
@ -556,7 +564,7 @@ class HealthIndiaApiController extends BaseController
|
||||
]
|
||||
]);
|
||||
|
||||
log_message('error', "TPA ID PULL HEALTH_INDIA | Job added for saving API data");
|
||||
log_message('error', "HEALTH_INDIA - TPA ID Pull | Job added for saving API data");
|
||||
|
||||
// ================= MATCHING LOGIC =================
|
||||
|
||||
@ -610,9 +618,9 @@ class HealthIndiaApiController extends BaseController
|
||||
|
||||
if ($this->db->affectedRows() > 0) {
|
||||
$updated++;
|
||||
log_message('error', "✅ HEALTH_INDIA | Updated tpa_id={$m['memberId']} for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
|
||||
log_message('error', "HEALTH_INDIA - TPA ID Pull | Updated tpa_id={$m['memberId']} for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
|
||||
} else {
|
||||
log_message('error', "⚠️ HEALTH_INDIA | No update (already set or not matched) for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
|
||||
log_message('error', "HEALTH_INDIA - TPA ID Pull | No update (already set or not matched) for emp_policy_id={$policy['emp_policy_id']} policy={$policyNo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -628,13 +636,13 @@ class HealthIndiaApiController extends BaseController
|
||||
];
|
||||
$batch_file_success = 'partially success';
|
||||
|
||||
log_message('error', "❌ HEALTH_INDIA | No match for Nhance = " . json_encode($nhanceSideData));
|
||||
log_message('error', "HEALTH_INDIA - TPA ID Pull | No match for Nhance = " . json_encode($nhanceSideData));
|
||||
}
|
||||
}
|
||||
|
||||
// Send e-card
|
||||
if (!empty($employee_policy_ids)) {
|
||||
log_message('error', "HEALTH_INDIA | sendMailForDownloadingECard JOB PUSHED.");
|
||||
log_message('error', "HEALTH_INDIA - TPA ID Pull | sendMailForDownloadingECard JOB PUSHED.");
|
||||
Jobs::addJob([
|
||||
'job_name' => 'sendMailForDownloadingECard',
|
||||
'payload' => [
|
||||
@ -655,7 +663,7 @@ class HealthIndiaApiController extends BaseController
|
||||
|
||||
$totalCount = count($allMembers);
|
||||
|
||||
log_message('error', "TPA ID PULL SUCCESS HEALTH_INDIA | completed. Total fetched={$totalCount}, updated={$updated}");
|
||||
log_message('error', "HEALTH_INDIA - TPA ID Pull SUCCESS | completed. Total fetched={$totalCount}, updated={$updated}");
|
||||
|
||||
if ($function_calling_type == "job") {
|
||||
return [
|
||||
@ -707,13 +715,13 @@ class HealthIndiaApiController extends BaseController
|
||||
{
|
||||
helper('api');
|
||||
|
||||
log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Started');
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims | Started');
|
||||
|
||||
// Generate Health India Token
|
||||
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
|
||||
|
||||
if (empty($tokenResponse['data']['result'][0]['access_token'])) {
|
||||
log_message('error', 'SYNC CLAIMS FAILED HEALTH_INDIA | Token generation failed');
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims FAILED | Token generation failed');
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Token generation failed']);
|
||||
}
|
||||
|
||||
@ -737,17 +745,17 @@ class HealthIndiaApiController extends BaseController
|
||||
"policY_NUMBER" => $policy['policy_no']
|
||||
];
|
||||
|
||||
log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Fetching for policy: ' . $policy['policy_no']);
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims | Fetching for policy: ' . $policy['policy_no']);
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body);
|
||||
|
||||
if (!empty($response['data']['result'])) {
|
||||
$finalResult = array_merge($finalResult, $response['data']['result']);
|
||||
log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Fetched ' . count($response['data']['result']) . ' claims for policy: ' . $policy['policy_no']);
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims | Fetched ' . count($response['data']['result']) . ' claims for policy: ' . $policy['policy_no']);
|
||||
}
|
||||
}
|
||||
|
||||
log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Total claims fetched: ' . count($finalResult));
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims | Total claims fetched: ' . count($finalResult));
|
||||
|
||||
// Insert / update ticket_master
|
||||
$insertedCount = 0;
|
||||
@ -786,13 +794,13 @@ class HealthIndiaApiController extends BaseController
|
||||
'created_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
$insertedCount++;
|
||||
log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Inserted claim: ' . ($row['CLAIM_NUMBER'] ?? 'N/A'));
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims | Inserted claim: ' . ($row['CLAIM_NUMBER'] ?? 'N/A'));
|
||||
} else {
|
||||
log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Skipped existing claim: ' . ($row['CLAIM_NUMBER'] ?? 'N/A'));
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims | Skipped existing claim: ' . ($row['CLAIM_NUMBER'] ?? 'N/A'));
|
||||
}
|
||||
}
|
||||
|
||||
log_message('error', 'SYNC CLAIMS HEALTH_INDIA | Completed | Total: ' . count($finalResult) . ' | Inserted: ' . $insertedCount);
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims | Completed | Total: ' . count($finalResult) . ' | Inserted: ' . $insertedCount);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => true,
|
||||
|
||||
@ -670,4 +670,123 @@ class SalesController extends BaseController
|
||||
// For development/testing, you can return a default value
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// ==================== Dashboard ====================
|
||||
|
||||
public function branchLevelDashboard()
|
||||
{
|
||||
// Hardcoded branch ID as requested
|
||||
$branchId = 1;
|
||||
|
||||
try {
|
||||
// 1. Lead Statistics
|
||||
$stats = $this->leadModel->getLeadStats(); // Using existing model method
|
||||
|
||||
// 2. Activity Statistics
|
||||
$activityStats = [
|
||||
'total' => $this->activityModel->countAllResults(),
|
||||
'completed' => $this->activityModel->where('status', 'completed')->countAllResults(),
|
||||
'pending' => $this->activityModel->where('status', 'pending')->countAllResults(),
|
||||
];
|
||||
|
||||
// 3. Team Performance (Aggregating activity counts per user)
|
||||
$db = \Config\Database::connect();
|
||||
$teamPerformance = $db->table('user_profiles as u')
|
||||
->select('u.first_name, u.last_name, u.profile as role,
|
||||
(SELECT COUNT(*) FROM sales_activities WHERE assigned_to = u.id) as total_acts,
|
||||
(SELECT COUNT(*) FROM sales_activities WHERE assigned_to = u.id AND status = "completed") as done_acts')
|
||||
->where('u.nhance_branch_id', $branchId)
|
||||
->where('u.is_active', 1)
|
||||
->get()->getResultArray();
|
||||
|
||||
// 4. Recent Activities (Joining for Lead Names)
|
||||
$recentActivities = $this->activityModel->select('sales_activities.*, sales_actual_leads.company_name')
|
||||
->join('sales_actual_leads', 'sales_actual_leads.lead_id = sales_activities.lead_id')
|
||||
->orderBy('sales_activities.scheduled_date', 'DESC')
|
||||
->limit(6)
|
||||
->findAll();
|
||||
|
||||
// 5. All Leads Overview
|
||||
$leadsOverview = $this->leadModel->select('sales_actual_leads.*, user_profiles.first_name, user_profiles.last_name')
|
||||
->join('user_profiles', 'user_profiles.id = sales_actual_leads.assigned_to', 'left')
|
||||
->findAll();
|
||||
|
||||
$data = [
|
||||
'total_leads' => $stats['total'],
|
||||
'total_activities' => $activityStats['total'],
|
||||
'completed_acts' => $activityStats['completed'],
|
||||
'pipeline_value' => '15.0L', // Hardcoded placeholder from PDF [cite: 14]
|
||||
'team' => $teamPerformance,
|
||||
'recent_acts' => $recentActivities,
|
||||
'leads_overview' => $leadsOverview
|
||||
];
|
||||
|
||||
// dd($data);
|
||||
|
||||
$this->loadLayout('sales/branch_level_dashboard_view', $data);
|
||||
|
||||
// return view('sales/dashboard_view', $data);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->failServerError($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function salesManagerLevelDashboard()
|
||||
{
|
||||
$userId = 1;
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
try {
|
||||
$target = $db->table('sales_target')
|
||||
->where('user_id', $userId)
|
||||
->where('fy_year', '2025-2026')
|
||||
->get()->getRowArray();
|
||||
|
||||
$targetAmount = $target['target_amount'] ?? 2500000.00;
|
||||
$achievedAmount = 600000.00;
|
||||
$remainingAmount = $targetAmount - $achievedAmount;
|
||||
$achievementPercent = ($targetAmount > 0) ? round(($achievedAmount / $targetAmount) * 100) : 0;
|
||||
|
||||
$activitySummary = [
|
||||
'total' => $this->activityModel->where('assigned_to', $userId)->countAllResults(),
|
||||
'pending' => $this->activityModel->where(['assigned_to' => $userId, 'status' => 'pending'])->countAllResults(),
|
||||
'completed' => $this->activityModel->where(['assigned_to' => $userId, 'status' => 'completed'])->countAllResults(),
|
||||
];
|
||||
|
||||
$myLeadsCount = $this->leadModel->where('assigned_to', $userId)->countAllResults();
|
||||
|
||||
$upcomingActivities = $this->activityModel->select('sales_activities.*, sales_actual_leads.company_name')
|
||||
->join('sales_actual_leads', 'sales_actual_leads.lead_id = sales_activities.lead_id')
|
||||
->where(['sales_activities.assigned_to' => $userId, 'sales_activities.status' => 'pending'])
|
||||
->orderBy('scheduled_date', 'ASC')
|
||||
->limit(3)
|
||||
->findAll();
|
||||
|
||||
$recentLeads = $this->leadModel->where('assigned_to', $userId)
|
||||
->orderBy('created_at', 'DESC')
|
||||
->limit(5)
|
||||
->findAll();
|
||||
|
||||
$data = [
|
||||
'target' => $targetAmount,
|
||||
'achieved' => $achievedAmount,
|
||||
'remaining' => $remainingAmount,
|
||||
'percent' => $achievementPercent,
|
||||
'acts' => $activitySummary,
|
||||
'lead_count' => $myLeadsCount,
|
||||
'upcoming' => $upcomingActivities,
|
||||
'recent_leads' => $recentLeads,
|
||||
'user_name' => session()->get('first_name') ?? 'John Doe'
|
||||
];
|
||||
|
||||
// return view('sales/my_dashboard_view', $data);
|
||||
$this->loadLayout('sales/sales_manager_level_dashboard', $data);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->failServerError($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -29,7 +29,7 @@ class VidalApiController extends BaseController
|
||||
$apiUrl = getenv('VIDAL_API_BASE_URL').'/files/upload-url';
|
||||
$subscriptionKey = getenv('VIDAL_API_SUBSCRIPTION_KEY');
|
||||
|
||||
log_message('error', "TPA CLAIM PUSH | Starting file upload process for filename: $filename | Path: $filePath");
|
||||
log_message('error', "VIDAL - Claim Push | Starting file upload process for filename: $filename | Path: $filePath");
|
||||
|
||||
// Step 1: Get signed URL from Vidal API
|
||||
// $filePath = '/opt/lampp/htdocs/nhance/writable/uploads/claim_files/1760013019_73d94af7b96ddc2e3d51.png';
|
||||
@ -39,7 +39,7 @@ class VidalApiController extends BaseController
|
||||
"Ocp-Apim-Subscription-Key: $subscriptionKey"
|
||||
];
|
||||
|
||||
log_message('error', "TPA CLAIM PUSH | Requesting signed URL from Vidal API: $apiUrl | Payload: $payload");
|
||||
log_message('error', "VIDAL - Claim Push | Requesting signed URL from Vidal API: $apiUrl | Payload: $payload");
|
||||
|
||||
$ch = curl_init($apiUrl);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@ -49,7 +49,7 @@ class VidalApiController extends BaseController
|
||||
|
||||
$response = curl_exec($ch);
|
||||
if (curl_errno($ch)) {
|
||||
log_message('error', "Curl error while requesting signed URL: " . curl_error($ch));
|
||||
log_message('error', "VIDAL - Claim Push Curl error while requesting signed URL: " . curl_error($ch));
|
||||
return ["status" => false, "message" => curl_error($ch)];
|
||||
}
|
||||
curl_close($ch);
|
||||
@ -57,14 +57,14 @@ class VidalApiController extends BaseController
|
||||
$responseData = json_decode($response, true);
|
||||
|
||||
if (!isset($responseData['data']['signedUrl']) || !isset($responseData['data']['fileId'])) {
|
||||
log_message('error', "TPA CLAIM PUSH | Invalid signed URL response received: " . json_encode($responseData));
|
||||
log_message('error', "VIDAL - Claim Push | Invalid signed URL response received: " . json_encode($responseData));
|
||||
return ["status" => false, "message" => "Invalid signed URL response", "response" => $responseData];
|
||||
}
|
||||
|
||||
$signedUrl = $responseData['data']['signedUrl'];
|
||||
$fileId = $responseData['data']['fileId'];
|
||||
|
||||
log_message('error', "Received signed URL & fileId. fileId: $fileId");
|
||||
log_message('error', "VIDAL - Claim Push | Received signed URL & fileId. fileId: $fileId");
|
||||
|
||||
// Step 2: Upload file to signed URL using PUT (Azure Blob)
|
||||
$fileSize = filesize($filePath);
|
||||
@ -89,12 +89,12 @@ class VidalApiController extends BaseController
|
||||
curl_close($ch2);
|
||||
|
||||
if ($curlErr) {
|
||||
log_message('error', "TPA CLAIM PUSH | Curl error during file upload: $curlErr");
|
||||
log_message('error', "VIDAL - Claim Push | Curl error during file upload: $curlErr");
|
||||
return ["status" => false, "message" => "File upload failed", "data" => $curlErr];
|
||||
}
|
||||
|
||||
if ($httpCode !== 200 && $httpCode !== 201) {
|
||||
log_message('error', "TPA CLAIM PUSH | File upload failed with HTTP Code: $httpCode | Response: $uploadResponse");
|
||||
log_message('error', "VIDAL - Claim Push | File upload failed with HTTP Code: $httpCode | Response: $uploadResponse");
|
||||
return [
|
||||
"status" => false,
|
||||
"message" => "File upload failed",
|
||||
@ -154,7 +154,7 @@ class VidalApiController extends BaseController
|
||||
->getRowArray(); // single record
|
||||
|
||||
if (count($data) && $data['filePath'] == null) {
|
||||
log_message('error', "TPA CLAIM PUSH | Submit claim failed - Claim or File Missing");
|
||||
log_message('error', "VIDAL - Claim Push | Submit claim failed - Claim or File Missing");
|
||||
return $this->response->setJSON(['status' => false,'message' => 'Claim or File Missing', ]);
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ class VidalApiController extends BaseController
|
||||
|
||||
$upload = $this->uploadFileToVidal($filePath,$filename);
|
||||
if ($upload['status'] !== true) {
|
||||
log_message('error', "TPA CLAIM PUSH | Submit claim failed - File upload failed");
|
||||
log_message('error', "VIDAL - Claim Push | Submit claim failed - File upload failed");
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'File upload failed',
|
||||
@ -212,7 +212,7 @@ class VidalApiController extends BaseController
|
||||
];
|
||||
// dd($body);
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||
log_message('error', 'VIDAL - Claim Push | claimId: '.$claimId.' | payload: '.json_encode($body));
|
||||
|
||||
// $body = [
|
||||
// 'policyNo' => "351500/D0534/PP/20-20/PC",
|
||||
@ -244,7 +244,7 @@ class VidalApiController extends BaseController
|
||||
$response = call_third_party_api($url, $method, $headers, $body);
|
||||
|
||||
if($response['status'] != true){
|
||||
log_message('error', 'TPA CLAIM PUSH FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
log_message('error', 'VIDAL - Claim Push FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_push_response' => json_encode($response) ]);
|
||||
@ -260,7 +260,7 @@ class VidalApiController extends BaseController
|
||||
|
||||
if(!empty($claimNO) && !empty($claimInwardNO)){
|
||||
|
||||
log_message('error', 'TPA CLAIM PUSH SUCCESS | claimId: '.$claimId.' | claimNO: '.$claimNO.' | claimInwardNO: '.$claimInwardNO);
|
||||
log_message('error', 'VIDAL - Claim Push SUCCESS | claimId: '.$claimId.' | claimNO: '.$claimNO.' | claimInwardNO: '.$claimInwardNO);
|
||||
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
@ -269,11 +269,11 @@ class VidalApiController extends BaseController
|
||||
return;
|
||||
|
||||
} else {
|
||||
log_message('error', 'TPA CLAIM PUSH API SUCCESS BUT claimNO,claimInwardNO EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
log_message('error', 'VIDAL - Claim Push API SUCCESS BUT claimNO,claimInwardNO EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
log_message('error', 'TPA CLAIM PUSH API FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
log_message('error', 'VIDAL - Claim Push API FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -412,7 +412,7 @@ class VidalApiController extends BaseController
|
||||
return ['status' => 'success','data' => $decryptedData["redirectUrl"]];
|
||||
}
|
||||
|
||||
public function ClaimDetail($claimId = 234) //234
|
||||
public function ClaimDetail($claimId = null) //234
|
||||
{
|
||||
helper('api');
|
||||
|
||||
@ -454,39 +454,31 @@ class VidalApiController extends BaseController
|
||||
$body = [
|
||||
'empNO' => "",
|
||||
'tpaCardID' => "",
|
||||
'claimID' => "CHE-0226-CL-0013404", //$ticket['claimID'],
|
||||
'claimID' => $ticket['claimID'],
|
||||
'emailID' => "",
|
||||
'mobileNO' => "",
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
$body = [
|
||||
'empNO' => "",
|
||||
'tpaCardID' => "",
|
||||
'claimID' => "CHE-0226-CL-0013893", //$ticket['claimID'],
|
||||
'emailID' => "",
|
||||
'mobileNO' => "",
|
||||
];
|
||||
|
||||
$response = call_third_party_api($url, $method, $headers, $body);
|
||||
|
||||
dd($response);
|
||||
|
||||
if ($response['status'] != true || empty($response['data']['data']['claims'][0])) {
|
||||
log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
|
||||
log_message('error', 'VIDAL - Claim Status FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
|
||||
|
||||
return ['status' => false, 'message' => 'API call failed.','data' => $response];
|
||||
}
|
||||
|
||||
// Extract claim status
|
||||
$claimData = $response['data']['data']['claims'][0];
|
||||
$tpa_claim_no = $claimData['claimNumber'] ?? '';
|
||||
$currentStatus = $claimData['status'] ?? '';
|
||||
$tpa_claim_type = $claimData['claimType'] ?? '';
|
||||
|
||||
|
||||
// VALID STATUS LIST
|
||||
$validStatuses = [
|
||||
|
||||
"In-Progress" => 5,
|
||||
"Required Information" => 4,
|
||||
"Paid" => 11,
|
||||
@ -494,20 +486,25 @@ class VidalApiController extends BaseController
|
||||
"Approved" => 8,
|
||||
];
|
||||
|
||||
|
||||
// Maping tpa claim status with local claim Status
|
||||
if (isset($validStatuses[$currentStatus]))
|
||||
{
|
||||
$updateArray = ['claim_status_id' => $validStatuses[$currentStatus] , 'tpa_claim_status' => $currentStatus , 'updated_at' => date('Y-m-d H:i:s')];
|
||||
}else{
|
||||
$updateArray = ['tpa_claim_status' => $currentStatus , 'updated_at' => date('Y-m-d H:i:s')];
|
||||
$updateArray = [
|
||||
'tpa_claim_status' => $currentStatus,
|
||||
'tpa_claim_id' => $tpa_claim_no,
|
||||
// 'claim_number' => $tpa_claim_no, // already updated
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
if (isset($validStatuses[$currentStatus])) {
|
||||
$updateArray['claim_status_id'] = $validStatuses[$currentStatus];
|
||||
}
|
||||
if (!empty($tpa_claim_type)) {
|
||||
$updateArray['tpa_claim_type'] = $tpa_claim_type;
|
||||
}
|
||||
|
||||
|
||||
// UPDATE ticket_master
|
||||
$this->db->table('ticket_master')->where('id', $claimId)->update($updateArray);
|
||||
|
||||
// LOG UPDATE
|
||||
log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||
log_message('error', "VIDAL - Claim Status SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||
|
||||
return ['status' => true,'message' => 'Claim status updated.','updated_status' => $currentStatus,'api_response' => $response];
|
||||
}
|
||||
@ -548,7 +545,7 @@ class VidalApiController extends BaseController
|
||||
// dd($TicketData);
|
||||
|
||||
if (!$TicketData) {
|
||||
log_message('error', "Claims not found to update status");
|
||||
log_message('error', "VIDAL - Claim Status | Claims not found to update status");
|
||||
return $this->response->setJSON(['status' => false,'message' => 'Claims not found' ]);
|
||||
}
|
||||
|
||||
@ -578,18 +575,19 @@ class VidalApiController extends BaseController
|
||||
$response = call_third_party_api($url, $method, $headers, $body);
|
||||
|
||||
if ($response['status'] != true || empty($response['data']['data']['claims'][0])) {
|
||||
log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
|
||||
log_message('error', 'VIDAL - Claim Status FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
|
||||
$error_data[$claimId][['status' => false,'message' => 'API call failed.','data' => $response]];
|
||||
}
|
||||
|
||||
// Extract claim status
|
||||
$claimData = $response['data']['data']['claims'][0];
|
||||
$tpa_claim_no = $claimData['claimNumber'] ?? '';
|
||||
$currentStatus = $claimData['status'] ?? '';
|
||||
$tpa_claim_type = $claimData['claimType'] ?? '';
|
||||
|
||||
|
||||
// VALID STATUS LIST
|
||||
$validStatuses = [
|
||||
|
||||
"In-Progress" => 5,
|
||||
"Required Information" => 4,
|
||||
"Paid" => 11,
|
||||
@ -597,20 +595,24 @@ class VidalApiController extends BaseController
|
||||
"Approved" => 8,
|
||||
];
|
||||
|
||||
|
||||
// Maping tpa claim status with local claim Status
|
||||
if (isset($validStatuses[$currentStatus]))
|
||||
{
|
||||
$updateArray = ['claim_status_id' => $validStatuses[$currentStatus] , 'tpa_claim_status' => $currentStatus , 'updated_at' => date('Y-m-d H:i:s')];
|
||||
}else{
|
||||
$updateArray = ['tpa_claim_status' => $currentStatus , 'updated_at' => date('Y-m-d H:i:s')];
|
||||
$updateArray = [
|
||||
'tpa_claim_status' => $currentStatus,
|
||||
'tpa_claim_id' => $tpa_claim_no,
|
||||
// 'claim_number' => $tpa_claim_no, // already updated
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
if (isset($validStatuses[$currentStatus])) {
|
||||
$updateArray['claim_status_id'] = $validStatuses[$currentStatus];
|
||||
}
|
||||
if (!empty($tpa_claim_type)) {
|
||||
$updateArray['tpa_claim_type'] = $tpa_claim_type;
|
||||
}
|
||||
|
||||
// UPDATE ticket_master
|
||||
$this->db->table('ticket_master')->where('id', $claimId)->update($updateArray);
|
||||
|
||||
// LOG UPDATE
|
||||
log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||
log_message('error', "VIDAL - Claim Status SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
|
||||
|
||||
$status_updated_count ++;
|
||||
|
||||
@ -662,17 +664,17 @@ class VidalApiController extends BaseController
|
||||
// dd($response);
|
||||
|
||||
if($response['status'] != true){
|
||||
log_message('error', 'Ecard Request FAILED | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | response: '.json_encode($response));
|
||||
log_message('error', 'VIDAL - Ecard Request FAILED | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | response: '.json_encode($response));
|
||||
return null;
|
||||
}
|
||||
|
||||
$ecardUrl = $response['data']['data']['dependents'][0]['ecardLink'] ?? null;
|
||||
|
||||
if(!empty($ecardUrl)){
|
||||
log_message('error', 'Ecard Request PUSH SUCCESS | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | ecardUrl: '.$ecardUrl);
|
||||
log_message('error', 'VIDAL - Ecard Request PUSH SUCCESS | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | ecardUrl: '.$ecardUrl);
|
||||
return $ecardUrl;
|
||||
} else {
|
||||
log_message('error', 'Ecard Request SUCCESS BUT ecardUrl EMPTY | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | response: '.json_encode($response));
|
||||
log_message('error', 'VIDAL - Ecard Request SUCCESS BUT ecardUrl EMPTY | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | response: '.json_encode($response));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -700,7 +702,7 @@ class VidalApiController extends BaseController
|
||||
$client_policy_id = $requestData['client_policy_id'] ?? null;
|
||||
|
||||
if (empty($policyNo)) {
|
||||
log_message('error', 'TPA ID PULL | policy_no missing in request');
|
||||
log_message('error', 'VIDAL - TPA ID Pull | policy_no missing in request');
|
||||
if($function_calling_type == "job"){
|
||||
return ['status' => false, 'message' => 'policy_no required'];
|
||||
}else{
|
||||
@ -709,7 +711,7 @@ class VidalApiController extends BaseController
|
||||
}
|
||||
|
||||
if (empty($client_policy_id)) {
|
||||
log_message('error', 'TPA ID PULL | client_policy_id missing in request');
|
||||
log_message('error', 'VIDAL - TPA ID Pull | client_policy_id missing in request');
|
||||
if($function_calling_type == "job"){
|
||||
return ['status' => false, 'message' => 'client_policy_id required'];
|
||||
}else{
|
||||
@ -717,7 +719,7 @@ class VidalApiController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
log_message('error', "TPA ID PULL | called for policy_no: {$policyNo} , client_policy_id: {$client_policy_id}");
|
||||
log_message('error', "VIDAL - TPA ID Pull | called for policy_no: {$policyNo} , client_policy_id: {$client_policy_id}");
|
||||
|
||||
// Fetch file download dates
|
||||
$batchFiles = $this->db->table('batch_files f')
|
||||
@ -731,7 +733,7 @@ class VidalApiController extends BaseController
|
||||
// dd($batchFiles);
|
||||
|
||||
if (empty($batchFiles)) {
|
||||
log_message('error', 'TPA ID PULL FAILED | batchFiles is empty for this tpa id pull request');
|
||||
log_message('error', 'VIDAL - TPA ID Pull FAILED | batchFiles is empty for this tpa id pull request');
|
||||
if($function_calling_type == "job"){
|
||||
return ['status' => false, 'message' => 'batchFiles not found'];
|
||||
}else{
|
||||
@ -757,7 +759,7 @@ class VidalApiController extends BaseController
|
||||
|
||||
// $body = [ 'empNO' => "Mem 1" ];
|
||||
|
||||
log_message('error', "TPA ID PULL | API parems " . json_encode([$url, $method, $headers, $body]));
|
||||
log_message('error', "VIDAL - TPA ID Pull | API parems " . json_encode([$url, $method, $headers, $body]));
|
||||
|
||||
$response = call_third_party_api($url, $method, $headers, $body);
|
||||
|
||||
@ -767,12 +769,12 @@ class VidalApiController extends BaseController
|
||||
if (isset($requestData['file_id']) && !empty($requestData['file_id'])) {
|
||||
$file_model = new BatchFileModel();
|
||||
$file_model->where('id', $requestData['file_id'])->set('status', 'failed-8')->update();
|
||||
log_message('error', "Files table status updated for the file id : {$requestData['file_id']}");
|
||||
log_message('error', "VIDAL - TPA ID Pull | Files table status updated for the file id : {$requestData['file_id']}");
|
||||
} else {
|
||||
log_message('error', "Failed to update file table status.");
|
||||
log_message('error', "VIDAL - TPA ID Pull | Failed to update file table status.");
|
||||
}
|
||||
|
||||
log_message('error', 'TPA ID PULL API FAILED | API failed: ' . json_encode($response));
|
||||
log_message('error', 'VIDAL - TPA ID Pull API FAILED | API failed: ' . json_encode($response));
|
||||
|
||||
if($function_calling_type == "job"){
|
||||
return ['status' => false, 'message' => 'API call failed', 'data' => $response];
|
||||
@ -784,12 +786,12 @@ class VidalApiController extends BaseController
|
||||
$data = $response['data']['data'] ?? [];
|
||||
|
||||
if (!isset($data['dependents'])) {
|
||||
log_message('error', "TPA ID PULL FAILED |: 'benefDetails' missing in API response: " . json_encode($data));
|
||||
log_message('error', "VIDAL - TPA ID Pull FAILED |: 'benefDetails' missing in API response: " . json_encode($data));
|
||||
break;
|
||||
}
|
||||
|
||||
$fetchedCount = count($data['dependents']);
|
||||
log_message('error', "Fetched {$fetchedCount} records ");
|
||||
log_message('error', "VIDAL - TPA ID Pull | Fetched {$fetchedCount} records ");
|
||||
$allBenef = array_merge($allBenef, $data['dependents']);
|
||||
|
||||
}
|
||||
@ -856,9 +858,9 @@ class VidalApiController extends BaseController
|
||||
|
||||
if ($this->db->affectedRows() > 0) {
|
||||
$updated++;
|
||||
log_message('error', "✅ Updated tpa_id={$row['enrollmentId']} for emp_code={$row['empNo']} policy={$row['policyNumber']}");
|
||||
log_message('error', "VIDAL - TPA ID Pull | Updated tpa_id={$row['enrollmentId']} for emp_code={$row['empNo']} policy={$row['policyNumber']}");
|
||||
} else {
|
||||
log_message('error', "⚠️ No update (already set or not matched) for emp_code={$row['empNo']} policy={$row['policyNumber']}");
|
||||
log_message('error', "VIDAL - TPA ID Pull | No update (already set or not matched) for emp_code={$row['empNo']} policy={$row['policyNumber']}");
|
||||
}
|
||||
|
||||
}
|
||||
@ -879,7 +881,7 @@ class VidalApiController extends BaseController
|
||||
|
||||
log_message(
|
||||
'error',
|
||||
"❌ No match for Nhance = " . json_encode($nhanceSideData)
|
||||
"VIDAL - TPA ID Pull | No match for Nhance = " . json_encode($nhanceSideData)
|
||||
);
|
||||
}
|
||||
|
||||
@ -904,7 +906,7 @@ class VidalApiController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
log_message('error', "TPA ID PULL SUCCESS | completed. Total fetched={$totalCount}, updated={$updated}");
|
||||
log_message('error', "VIDAL - TPA ID Pull SUCCESS | completed. Total fetched={$totalCount}, updated={$updated}");
|
||||
|
||||
if($function_calling_type == "job"){
|
||||
return [
|
||||
|
||||
177
app/Views/sales/branch_level_dashboard_view.php
Normal file
177
app/Views/sales/branch_level_dashboard_view.php
Normal file
@ -0,0 +1,177 @@
|
||||
<style>
|
||||
.dash-container { padding: 25px; background: #f8f9fa; font-family: 'Segoe UI', sans-serif; }
|
||||
.top-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
|
||||
|
||||
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 30px; }
|
||||
.card { background: white; padding: 25px; border-radius: 12px; border: 1px solid #edf2f7; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
|
||||
.stat-val { font-size: 28px; font-weight: 700; color: #1a202c; }
|
||||
.stat-label { color: #718096; font-size: 14px; margin-top: 4px; font-weight: 500; }
|
||||
.stat-change { font-size: 11px; margin-top: 8px; font-weight: 600; }
|
||||
.text-success { color: #48bb78; }
|
||||
|
||||
.main-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 30px; }
|
||||
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
|
||||
|
||||
.team-member { display: flex; align-items: center; padding: 15px 0; border-bottom: 1px solid #f1f5f9; }
|
||||
.member-img { width: 40px; height: 40px; border-radius: 50%; background: #ff6b35; color: white; margin-right: 12px; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 16px; }
|
||||
.act-stats { text-align: right; }
|
||||
.act-stats .total { font-weight: 700; font-size: 13px; color: #1a202c; }
|
||||
.act-stats .done { font-size: 11px; color: #38a169; font-weight: 600; margin-top: 2px; }
|
||||
|
||||
.breakdown-card { margin-top: 20px; }
|
||||
.breakdown-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 13px; }
|
||||
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }
|
||||
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th { text-align: left; padding: 12px; color: #718096; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid #edf2f7; }
|
||||
td { padding: 15px 12px; border-bottom: 1px solid #f1f5f9; font-size: 14px; vertical-align: middle; }
|
||||
|
||||
.status-pill { padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; display: inline-block; }
|
||||
.status-completed { background: #f0fff4; color: #38a169; }
|
||||
.status-pending { background: #fffaf0; color: #dd6b20; }
|
||||
</style>
|
||||
|
||||
<div class="dash-container">
|
||||
<div class="top-header">
|
||||
<div>
|
||||
<h2 style="font-weight: 800; color: #1a202c; font-size: 24px;">Dashboard</h2>
|
||||
<p style="color: #718096; font-size: 14px; margin-top: 4px;">Overview of your branch</p>
|
||||
</div>
|
||||
<div style="position: relative;">
|
||||
<input type="text" placeholder="Search leads, activities....." style="background:white; padding:12px 20px; border-radius:10px; border:1px solid #e2e8f0; width: 350px; font-size: 13px;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stat-cards">
|
||||
<div class="card">
|
||||
<div class="stat-val">4</div>
|
||||
<div class="stat-label">Total Leads</div>
|
||||
<div class="stat-change text-success">↑ 12% this month</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="stat-val">6</div>
|
||||
<div class="stat-label">Total Activities</div>
|
||||
<div class="stat-change text-success">↑ 5% this month</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="stat-val">1</div>
|
||||
<div class="stat-label">Completed Activities</div>
|
||||
<div class="stat-change text-success">↑ 15% this month</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="stat-val">₹15.0L</div>
|
||||
<div class="stat-label">Pipeline Value</div>
|
||||
<div class="stat-change text-success">↑ 18% this month</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-grid">
|
||||
<div class="card">
|
||||
<div class="table-header">
|
||||
<h3 style="font-size: 16px; font-weight: 700;">Recent Activities - All Team</h3>
|
||||
<span style="color: #718096; font-size: 12px; font-weight: 600;">6 activities</span>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Company</th>
|
||||
<th>Activity & Assigned</th>
|
||||
<th>Date</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Venba Infotech</strong></td>
|
||||
<td>
|
||||
<div style="color: #ff6b35; font-weight: 700; font-size: 11px;">CALL</div>
|
||||
<div style="font-size: 12px; color: #718096;">John Doe</div>
|
||||
</td>
|
||||
<td style="color: #4a5568; font-weight: 500;">20 Feb 2026</td>
|
||||
<td><span class="status-pill status-completed">Completed</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Acme Corporation</strong></td>
|
||||
<td>
|
||||
<div style="color: #ff6b35; font-weight: 700; font-size: 11px;">EMAIL</div>
|
||||
<div style="font-size: 12px; color: #718096;">John Doe</div>
|
||||
</td>
|
||||
<td style="color: #4a5568; font-weight: 500;">20 Feb 2026</td>
|
||||
<td><span class="status-pill status-pending">Pending</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="card">
|
||||
<h3 style="font-size: 16px; font-weight: 700; margin-bottom: 15px;">Sales Team Performance</h3>
|
||||
<div class="team-member">
|
||||
<div class="member-img" style="background: #ff6b35;">V</div>
|
||||
<div style="flex: 1;">
|
||||
<div style="font-weight: 700; font-size: 14px;">Venkat 3.0</div>
|
||||
<div style="font-size: 11px; color: #718096;">Sales Manager</div>
|
||||
</div>
|
||||
<div class="act-stats">
|
||||
<div class="total">6 acts</div>
|
||||
<div class="done">1 done</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="team-member">
|
||||
<div class="member-img" style="background: #4a5568;">P</div>
|
||||
<div style="flex: 1;">
|
||||
<div style="font-weight: 700; font-size: 14px;">Pavi_the_Staff V</div>
|
||||
<div style="font-size: 11px; color: #718096;">Sales Staff</div>
|
||||
</div>
|
||||
<div class="act-stats">
|
||||
<div class="total">0 acts</div>
|
||||
<div class="done">0 done</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card breakdown-card">
|
||||
<h3 style="font-size: 15px; font-weight: 700; margin-bottom: 20px;">Activity Breakdown</h3>
|
||||
<div class="breakdown-item"><span><span class="dot" style="background: #ff6b35;"></span> Call</span><strong>42%</strong></div>
|
||||
<div class="breakdown-item"><span><span class="dot" style="background: #48bb78;"></span> Email</span><strong>25%</strong></div>
|
||||
<div class="breakdown-item"><span><span class="dot" style="background: #4299e1;"></span> Meeting</span><strong>18%</strong></div>
|
||||
<div class="breakdown-item"><span><span class="dot" style="background: #ecc94b;"></span> Visit</span><strong>10%</strong></div>
|
||||
<div class="breakdown-item"><span><span class="dot" style="background: #9f7aea;"></span> Demo</span><strong>5%</strong></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="table-header">
|
||||
<h3 style="font-size: 16px; font-weight: 700;">All Leads Overview</h3>
|
||||
<span style="color: #718096; font-size: 12px; font-weight: 600;">Click a lead to see details</span>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Company</th>
|
||||
<th>Status</th>
|
||||
<th>Assigned To</th>
|
||||
<th>Activities</th>
|
||||
<th>Opportunities</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>Venba Infotech</strong></td>
|
||||
<td><span style="background: #edf2f7; color: #4a5568; font-size: 10px; padding: 3px 10px; border-radius: 12px; font-weight: 700; text-transform: uppercase;">New</span></td>
|
||||
<td style="color: #4a5568;">John Doe</td>
|
||||
<td><div style="text-align: center; font-weight: 700;">1</div></td>
|
||||
<td><div style="text-align: center; font-weight: 700;">1</div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Acme Corporation</strong></td>
|
||||
<td><span style="background: #fff3e0; color: #f57c00; font-size: 10px; padding: 3px 10px; border-radius: 12px; font-weight: 700; text-transform: uppercase;">Potential</span></td>
|
||||
<td style="color: #4a5568;">John Doe</td>
|
||||
<td><div style="text-align: center; font-weight: 700;">1</div></td>
|
||||
<td><div style="text-align: center; font-weight: 700;">0</div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
93
app/Views/sales/sales_manager_level_dashboard.php
Normal file
93
app/Views/sales/sales_manager_level_dashboard.php
Normal file
@ -0,0 +1,93 @@
|
||||
<style>
|
||||
.my-dash { padding: 25px; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #fff; }
|
||||
.target-card { background: #1e252b; color: white; padding: 30px; border-radius: 15px; position: relative; margin-bottom: 30px; }
|
||||
.target-amount { font-size: 32px; font-weight: bold; margin: 10px 0; }
|
||||
.progress-container { background: #333; height: 8px; border-radius: 4px; margin: 20px 0; overflow: hidden; position: relative; }
|
||||
.progress-bar { background: #ff6b35; height: 100%; border-radius: 4px; }
|
||||
|
||||
.stats-row { display: flex; gap: 15px; margin-top: 25px; }
|
||||
.stat-box { background: rgba(255,255,255,0.05); padding: 15px; border-radius: 10px; flex: 1; text-align: left; border: 1px solid rgba(255,255,255,0.1); }
|
||||
.stat-box .num { font-size: 20px; font-weight: bold; display: block; margin-bottom: 2px; }
|
||||
.stat-box .lbl { font-size: 11px; color: #999; }
|
||||
|
||||
.chart-circle { position: absolute; right: 40px; top: 35px; width: 75px; height: 75px; border: 6px solid #333; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 18px; border-top-color: #ff6b35; }
|
||||
|
||||
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; }
|
||||
.list-card { border: 1px solid #f0f0f0; border-radius: 12px; padding: 25px; background: #fff; }
|
||||
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid #f9f9f9; }
|
||||
.badge-done { background: #00c853; color: white; padding: 5px 15px; border-radius: 8px; font-size: 11px; font-weight: 600; cursor: pointer; border: none; }
|
||||
|
||||
.lead-initial { width: 35px; height: 35px; background: #f0f0f0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; color: #ff6b35; }
|
||||
.status-pill { font-size: 10px; padding: 2px 10px; border-radius: 12px; font-weight: 600; }
|
||||
</style>
|
||||
|
||||
<div class="my-dash">
|
||||
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:25px;">
|
||||
<div>
|
||||
<h1 style="font-size:22px; margin:0; font-weight: 700;">My Dashboard</h1>
|
||||
<p style="color:#666; font-size:13px; margin-top: 4px;">Welcome back, <?= $user_name ?></p>
|
||||
</div>
|
||||
<div style="position: relative;">
|
||||
<input type="text" placeholder="Search leads, activities..." style="background:#f5f5f5; padding:10px 20px; border-radius:8px; border:none; width: 250px; font-size: 13px;">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="target-card">
|
||||
<div style="font-size:11px; color:#999; letter-spacing: 1px; font-weight: 600;">YEARLY TARGET 2025</div>
|
||||
<div class="target-amount">₹<?= number_format($target / 100000, 1) ?>L</div>
|
||||
<div style="font-size:12px; color:#777;">Apr 2025 - Mar 2026</div>
|
||||
|
||||
<div class="chart-circle">
|
||||
<span style="color:#ff6b35"><?= $percent ?>%</span>
|
||||
</div>
|
||||
|
||||
<div class="progress-container">
|
||||
<div class="progress-bar" style="width: <?= $percent ?>%"></div>
|
||||
</div>
|
||||
<div style="display:flex; justify-content:space-between; font-size:12px; color: #999;">
|
||||
<span>Achieved <strong style="color:white">₹<?= number_format($achieved / 100000, 1) ?>L</strong></span>
|
||||
<span>Remaining <strong style="color:white">₹<?= number_format($remaining / 100000, 1) ?>L</strong></span>
|
||||
</div>
|
||||
|
||||
<div class="stats-row">
|
||||
<div class="stat-box"><span class="num"><?= $acts['total'] ?></span><span class="lbl">My Activities</span></div>
|
||||
<div class="stat-box"><span class="num"><?= $acts['pending'] ?></span><span class="lbl">Pending</span></div>
|
||||
<div class="stat-box"><span class="num"><?= $acts['completed'] ?></span><span class="lbl">Completed</span></div>
|
||||
<div class="stat-box"><span class="num"><?= $lead_count ?></span><span class="lbl">My Leads</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-grid">
|
||||
<div class="list-card">
|
||||
<div style="display:flex; justify-content:space-between; margin-bottom:15px; align-items: center;">
|
||||
<h3 style="font-size:16px; font-weight: 700; margin: 0;">My Upcoming Activities</h3>
|
||||
<span style="color:#ff6b35; font-size:12px; font-weight: 600;"><?= $acts['pending'] ?> pending</span>
|
||||
</div>
|
||||
<?php foreach($upcoming as $u): ?>
|
||||
<div class="list-item">
|
||||
<div>
|
||||
<div style="font-weight:600; font-size:14px; color: #333;"><?= $u['company_name'] ?></div>
|
||||
<div style="font-size:11px; color:#999; margin-top: 3px;"><?= strtoupper($u['activity_type'] ?? 'EMAIL') ?> - <?= date('d Mar Y', strtotime($u['scheduled_date'])) ?></div>
|
||||
</div>
|
||||
<button class="badge-done">✓ Done</button>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="list-card">
|
||||
<h3 style="font-size:16px; font-weight: 700; margin-bottom:20px;">My Recent Leads</h3>
|
||||
<?php foreach($recent_leads as $rl): ?>
|
||||
<div class="list-item">
|
||||
<div style="display:flex; gap:12px; align-items:center;">
|
||||
<div class="lead-initial"><?= substr($rl['company_name'], 0, 1) ?></div>
|
||||
<div>
|
||||
<div style="font-weight:600; font-size:14px; color: #333;"><?= $rl['company_name'] ?></div>
|
||||
<div style="font-size:11px; color:#999; margin-top: 2px;"><?= $rl['email'] ?></div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="status-pill" style="background: #e3f2fd; color: #1976d2;"><?= $rl['status'] ?></span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user