diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index f659dfb9..a6a324f8 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -786,7 +786,7 @@ $routes->get('FhplGetBenefDetails','FhplApiController::FhplGetBenefDetails');
$routes->get('EcardRequest','HealthIndiaApiController::EcardRequest');
$routes->get('HospitalNetwork','MediAssistApiController::HospitalNetwork');
$routes->get('VidalGetBenefDetails','VidalApiController::VidalGetBenefDetails');
-$routes->get('ClaimDetail','HealthIndiaApiController::ClaimDetail');
+$routes->get('ClaimDetail','VidalApiController::ClaimDetail');
$routes->get('SubmitClaim','HealthIndiaApiController::SubmitClaim');
$routes->get('IntimateClaim','MediAssistApiController::IntimateClaim');
$routes->get('IRSubmission','MediAssistApiController::IRSubmission');
@@ -895,6 +895,8 @@ $routes->group('logs', function($routes) {
$routes->group('sales', function($routes) {
// ==================== LEAD ROUTES ====================
+
+ $routes->get('/', 'SalesController::index');
// Get all leads with filters
$routes->get('leads', 'SalesController::getLeads');
diff --git a/app/Controllers/LogController.php b/app/Controllers/LogController.php
index 99652ff3..980ed5f5 100644
--- a/app/Controllers/LogController.php
+++ b/app/Controllers/LogController.php
@@ -1,259 +1,146 @@
logPath = WRITEPATH . 'logs/';
- $this->session = session();
}
- /**
- * Display list of all log files
- */
public function index()
{
-
- $logFiles = $this->getLogFiles();
-
$data = [
- 'title' => 'Log Files',
- 'logFiles' => $logFiles
+ 'title' => 'Log Files',
+ 'logFiles' => $this->getLogFiles()
];
-
- return $this->loadLayout('logs/index', $data);
-
- // return view('logs/index', $data);
+ return view('logs/index', $data);
+ }
+
+ public function view($filename = null)
+ {
+ if (!$filename) return redirect()->to('/logs');
+
+ $filename = basename($filename);
+ $filePath = $this->logPath . $filename;
+
+ if (!file_exists($filePath)) return redirect()->to('/logs');
+
+ $db = \Config\Database::connect();
+
+ // 1. Fetch TPA List for the first row of tabs
+ $tpaConfigs = $db->table('tpa_log_config')->get()->getResultArray();
+
+ // 2. Dynamically get Action buttons from table columns
+ $allColumns = $db->getFieldNames('tpa_log_config');
+ $dynamicKeys = [];
+ foreach ($allColumns as $column) {
+ if ($column !== 'tpa_name') {
+ // Formatting: 'claim_push_key' -> 'Claim Push'
+ $label = str_replace(['_key', '_'], ['', ' '], $column);
+ $dynamicKeys[$column] = ucwords($label);
+ }
+ }
+
+ $selectedTpa = $this->request->getGet('tpa');
+ $selectedKey = $this->request->getGet('key');
+ $searchTerm = $this->request->getGet('search');
+
+ // Parse logs with current filters
+ $logEntries = $this->parseLogFileOptimized($filePath, $tpaConfigs, $selectedTpa, $selectedKey, $searchTerm);
+
+ // Date Pagination
+ $prevFile = $nextFile = null;
+ if (preg_match('/log-(\d{4}-\d{2}-\d{2})\.log/', $filename, $match)) {
+ $currentDate = $match[1];
+ $prevD = date('Y-m-d', strtotime('-1 day', strtotime($currentDate)));
+ $nextD = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
+ if (file_exists($this->logPath . "log-$prevD.log")) $prevFile = "log-$prevD.log";
+ if (file_exists($this->logPath . "log-$nextD.log")) $nextFile = "log-$nextD.log";
+ }
+
+ $data = [
+ 'title' => 'TPA Logs: ' . $filename,
+ 'filename' => $filename,
+ 'logEntries' => $logEntries,
+ 'tpaConfigs' => $tpaConfigs,
+ 'dynamicKeys' => $dynamicKeys, // Dynamic Buttons
+ 'selectedTpa' => $selectedTpa,
+ 'selectedKey' => $selectedKey,
+ 'searchTerm' => $searchTerm,
+ 'prevFile' => $prevFile,
+ 'nextFile' => $nextFile
+ ];
+
+ return view('logs/view', $data);
+ }
+
+ private function parseLogFileOptimized($path, $configs, $tpaName, $keyType, $searchTerm)
+ {
+ $entries = [];
+ $handle = fopen($path, 'r');
+ if (!$handle) return [];
+
+ $filters = [];
+ if ($tpaName) {
+ $filters[] = $tpaName;
+ if ($keyType) {
+ foreach ($configs as $conf) {
+ if ($conf['tpa_name'] === $tpaName && isset($conf[$keyType])) {
+ $filters[] = $conf[$keyType];
+ }
+ }
+ }
+ }
+ if ($searchTerm) $filters[] = $searchTerm;
+
+ $currentEntry = null;
+ while (($line = fgets($handle)) !== false) {
+ if (preg_match('/^(\w+)\s*-\s*(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s*-->\s*(.*)$/', $line, $matches)) {
+ if ($currentEntry && $this->matchesFilters($currentEntry['message'], $filters)) {
+ $entries[] = $currentEntry;
+ }
+ $currentEntry = ['level' => $matches[1], 'date' => $matches[2], 'message' => $matches[3]];
+ } elseif ($currentEntry !== null && trim($line) !== '') {
+ $currentEntry['message'] .= "\n" . $line;
+ }
+ }
+ if ($currentEntry && $this->matchesFilters($currentEntry['message'], $filters)) $entries[] = $currentEntry;
+
+ fclose($handle);
+ return array_reverse($entries);
+ }
+
+ private function matchesFilters($message, $filters)
+ {
+ if (empty($filters)) return false;
+ foreach ($filters as $f) {
+ if (stripos($message, $f) === false) return false;
+ }
+ return true;
}
- /**
- * Get all log files sorted by date (latest first)
- */
private function getLogFiles()
{
$files = [];
-
- if (!is_dir($this->logPath)) {
- return $files;
- }
-
+ if (!is_dir($this->logPath)) return $files;
$iterator = new \DirectoryIterator($this->logPath);
-
foreach ($iterator as $fileInfo) {
if ($fileInfo->isFile() && $fileInfo->getExtension() === 'log') {
$files[] = [
'name' => $fileInfo->getFilename(),
- 'path' => $fileInfo->getPathname(),
- 'size' => $this->formatBytes($fileInfo->getSize()),
- 'modified' => $fileInfo->getMTime(),
- 'modified_date' => date('Y-m-d H:i:s', $fileInfo->getMTime())
+ 'size' => round($fileInfo->getSize() / 1024, 2) . ' KB',
+ 'modified_date' => date('Y-m-d H:i:s', $fileInfo->getMTime()),
+ 'ts' => $fileInfo->getMTime()
];
}
}
-
- // Sort by modified time (latest first)
- usort($files, function($a, $b) {
- return $b['modified'] - $a['modified'];
- });
-
+ usort($files, fn($a, $b) => $b['ts'] - $a['ts']);
return $files;
}
-
- /**
- * View specific log file content
- */
- public function view($filename = null)
- {
-
-
-
- if (!$filename) {
- return redirect()->to('/logs')->with('error', 'No log file specified');
- }
-
- // Security: prevent directory traversal
- $filename = basename($filename);
- $filePath = $this->logPath . $filename;
-
- if (!file_exists($filePath)) {
- return redirect()->to('/logs')->with('error', 'Log file not found');
- }
-
- // ✅ extract date from filename: log-YYYY-MM-DD.log
- if (preg_match('/log-(\d{4}-\d{2}-\d{2})\.log/', $filename, $match)) {
- $currentDate = $match[1];
-
- $prevDate = date('Y-m-d', strtotime('-1 day', strtotime($currentDate)));
- $nextDate = date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
-
- $prevFile = "log-$prevDate.log";
- $nextFile = "log-$nextDate.log";
-
- $prevExists = file_exists($this->logPath . $prevFile);
- $nextExists = file_exists($this->logPath . $nextFile);
- }
-
- // Read log file content
- $content = file_get_contents($filePath);
- $logEntries = $this->parseLogFile($content);
-
- $data = [
- 'title' => 'View Log: ' . $filename,
- 'filename' => $filename,
- 'logEntries' => $logEntries,
- 'prevFile' => $prevExists ? $prevFile : null,
- 'nextFile' => $nextExists ? $nextFile : null,
- 'fileSize' => $this->formatBytes(filesize($filePath)),
- 'lastModified' => date('Y-m-d H:i:s', filemtime($filePath))
- ];
-
- // print_r( $data); die;
-
- return $this->loadLayout('logs/view', $data);
- // return view('logs/view', $data);
- }
-
- /**
- * Parse log file into structured array
- */
-
- private function parseLogFile($content)
- {
- $entries = [];
- $lines = explode("\n", $content);
-
- $currentEntry = null;
-
- // Messages to filter out
- $skipPatterns = [
- '/Session: Class initialized using/',
- '/Session class already loaded/',
- ];
-
- foreach ($lines as $line) {
- // Match CI4 log format: LEVEL - date --> message
- if (preg_match('/^(\w+)\s*-\s*(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s*-->\s*(.*)$/', $line, $matches)) {
-
- // Save previous entry if exists (before checking skip)
- if ($currentEntry !== null) {
- $entries[] = $currentEntry;
- $currentEntry = null;
- }
-
- // Check if this message should be skipped
- $shouldSkip = false;
- foreach ($skipPatterns as $pattern) {
- if (preg_match($pattern, $matches[3])) {
- $shouldSkip = true;
- break;
- }
- }
-
- if ($shouldSkip) {
- continue;
- }
-
- // Start new entry
- $currentEntry = [
- 'level' => $matches[1],
- 'date' => $matches[2],
- 'message' => $matches[3]
- ];
- } elseif ($currentEntry !== null && trim($line) !== '') {
- // Continuation of previous message
- $currentEntry['message'] .= "\n" . $line;
- }
- }
-
- // Add last entry
- if ($currentEntry !== null) {
- $entries[] = $currentEntry;
- }
-
- return array_reverse($entries); // Latest first
- }
-
- /**
- * Download log file
- */
- public function download($filename = null)
- {
- if (!$filename) {
- return redirect()->to('/logs')->with('error', 'No log file specified');
- }
-
- $filename = basename($filename);
- $filePath = $this->logPath . $filename;
-
- if (!file_exists($filePath)) {
- return redirect()->to('/logs')->with('error', 'Log file not found');
- }
-
- return $this->response->download($filePath, null);
- }
-
- /**
- * Delete log file
- */
- public function delete($filename = null)
- {
- if (!$filename) {
- return redirect()->to('/logs')->with('error', 'No log file specified');
- }
-
- $filename = basename($filename);
- $filePath = $this->logPath . $filename;
-
- if (!file_exists($filePath)) {
- return redirect()->to('/logs')->with('error', 'Log file not found');
- }
-
- if (unlink($filePath)) {
- return redirect()->to('/logs')->with('success', 'Log file deleted successfully');
- } else {
- return redirect()->to('/logs')->with('error', 'Failed to delete log file');
- }
- }
-
- /**
- * Format bytes to human readable format
- */
- private function formatBytes($bytes, $precision = 2)
- {
- $units = ['B', 'KB', 'MB', 'GB', 'TB'];
-
- $bytes = max($bytes, 0);
- $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
- $pow = min($pow, count($units) - 1);
-
- $bytes /= pow(1024, $pow);
-
- return round($bytes, $precision) . ' ' . $units[$pow];
- }
-
- /**
- * Clear all log files
- */
- public function clearAll()
- {
- $logFiles = $this->getLogFiles();
- $deleted = 0;
-
- foreach ($logFiles as $file) {
- if (unlink($file['path'])) {
- $deleted++;
- }
- }
-
- return redirect()->to('/logs')->with('success', $deleted . ' log file(s) deleted successfully');
- }
}
\ No newline at end of file
diff --git a/app/Controllers/MediAssistApiController.php b/app/Controllers/MediAssistApiController.php
index 0452c797..1d0b3769 100644
--- a/app/Controllers/MediAssistApiController.php
+++ b/app/Controllers/MediAssistApiController.php
@@ -130,14 +130,14 @@ class MediAssistApiController extends BaseController
// ]
// ];
- log_message('error', 'TPA CLAIM PUSH | claimId: '.$claimId.' | payload: '.json_encode($body));
+ log_message('error','MEDI_ASSIST - Claim Push | claimId: '.$claimId.' | payload: '.json_encode($body));
$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','MEDI_ASSIST - Claim Push FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
$this->db->table('ticket_master')
->where('id',$claimId)
->update([ 'tpa_push_response' => json_encode($response) ]);
@@ -150,7 +150,7 @@ class MediAssistApiController extends BaseController
if(!empty($claimRef)){
- log_message('error', 'TPA CLAIM PUSH SUCCESS | claimId: '.$claimId.' | claimReferenceNo: '.$claimRef);
+ log_message('error','MEDI_ASSIST - Claim Push SUCCESS | claimId: '.$claimId.' | claimReferenceNo: '.$claimRef);
$this->db->table('ticket_master')
->where('id',$claimId)
@@ -159,7 +159,7 @@ class MediAssistApiController extends BaseController
return;
} else {
- log_message('error', 'TPA CLAIM PUSH API SUCCESS BUT claimReferenceNo EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
+ log_message('error','MEDI_ASSIST - Claim Push API Failed | claimReferenceNo EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
return;
}
@@ -193,17 +193,17 @@ class MediAssistApiController extends BaseController
$response = call_third_party_api($url, $method, $headers, $body);
if($response['status'] != true){
- log_message('error', 'Ecard Request FAILED | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | response: '.json_encode($response));
+ log_message('error','MEDI_ASSIST - Ecard Request FAILED | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | response: '.json_encode($response));
return null;
}
$ecardUrl = $response['data']['ecardUrl'] ?? null;
if(!empty($ecardUrl)){
- log_message('error', 'Ecard Request PUSH SUCCESS | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | ecardUrl: '.$ecardUrl);
+ log_message('error','MEDI_ASSIST - 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','MEDI_ASSIST - Ecard Request SUCCESS BUT ecardUrl EMPTY | employeeId: '.$employeeId.' | policyNo: '.$policyNo.' | response: '.json_encode($response));
return null;
}
@@ -242,7 +242,7 @@ class MediAssistApiController 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','MEDI_ASSIST - TPA ID Pull | policy_no missing in request');
if($function_calling_type == "job"){
return ['status' => false, 'message' => 'policy_no required'];
}else{
@@ -251,7 +251,7 @@ class MediAssistApiController extends BaseController
}
if (empty($client_policy_id)) {
- log_message('error', 'TPA ID PULL | client_policy_id missing in request');
+ log_message('error','MEDI_ASSIST - TPA ID Pull | client_policy_id missing in request');
if($function_calling_type == "job"){
return ['status' => false, 'message' => 'client_policy_id required'];
}else{
@@ -259,7 +259,7 @@ class MediAssistApiController extends BaseController
}
}
- log_message('error', "TPA ID PULL | called for policy_no: {$policyNo} , client_policy_id: {$client_policy_id}");
+ log_message('error',"MEDI_ASSIST - TPA ID Pull | called for policy_no: {$policyNo} , client_policy_id: {$client_policy_id}");
$employeePolicyModel = new EmployeePolicyModel();
$employeePolicyData = $employeePolicyModel
@@ -278,7 +278,7 @@ class MediAssistApiController extends BaseController
->findAll();
if (empty($employeePolicyData)) {
- log_message('error', 'TPA ID PULL FAILED | employeePolicyData is empty (tpa_id IS NULL from nhance) for this tpa id pull request');
+ log_message('error','MEDI_ASSIST - TPA ID Pull FAILED | employeePolicyData is empty (tpa_id IS NULL from nhance) for this TPA ID Pull request');
if($function_calling_type == "job"){
return ['status' => false, 'message' => 'employeePolicyData not found'];
}else{
@@ -301,8 +301,8 @@ class MediAssistApiController extends BaseController
"employeeId" => ""
];
- log_message('error', "TPA ID PULL | API Request (startIndex={$startIndex}): " . json_encode($body));
- log_message('error', "TPA ID PULL | API parems " . json_encode([$url, $method, $headers, $body]));
+ log_message('error',"MEDI_ASSIST - TPA ID Pull | API Request (startIndex={$startIndex}): " . json_encode($body));
+ log_message('error',"MEDI_ASSIST - TPA ID Pull | API parems " . json_encode([$url, $method, $headers, $body]));
$response = call_third_party_api($url, $method, $headers, $body);
@@ -312,12 +312,12 @@ class MediAssistApiController 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',"MEDI_ASSIST - Files table status updated for the file id : {$requestData['file_id']}");
} else {
- log_message('error', "Failed to update file table status.");
+ log_message('error',"MEDI_ASSIST - Failed to update file table status.");
}
- log_message('error', 'TPA ID PULL API FAILED | API failed: ' . json_encode($response));
+ log_message('error','MEDI_ASSIST - TPA ID Pull API FAILED | API failed: ' . json_encode($response));
if($function_calling_type == "job"){
return ['status' => false, 'message' => 'API call failed', 'data' => $response];
@@ -329,7 +329,7 @@ class MediAssistApiController extends BaseController
$data = $response['data'] ?? [];
if (!isset($data['benefDetails'])) {
- log_message('error', "TPA ID PULL FAILED |: 'benefDetails' missing in API response: " . json_encode($data));
+ log_message('error',"MEDI_ASSIST - TPA ID Pull FAILED |: 'benefDetails' missing in API response: " . json_encode($data));
break;
}
@@ -337,7 +337,7 @@ class MediAssistApiController extends BaseController
$totalCount = $count;
$fetchedCount = count($data['benefDetails']);
- log_message('error', "Fetched {$fetchedCount} records (startIndex={$startIndex}) of total {$count}");
+ log_message('error',"MEDI_ASSIST - Fetched {$fetchedCount} records (startIndex={$startIndex}) of total {$count}");
$allBenef = array_merge($allBenef, $data['benefDetails']);
@@ -376,7 +376,7 @@ class MediAssistApiController extends BaseController
$hasMatchForThisPolicy = true;
- // log_message('error', "✅ Match found: emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
+ // log_message('error',"MEDI_ASSIST - ✅ Match found: emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
$sql = "UPDATE employee_polices
SET tpa_id = ?
@@ -390,9 +390,9 @@ class MediAssistApiController extends BaseController
if ($this->db->affectedRows() > 0) {
$updated++;
- log_message('error', "✅ Updated tpa_id={$row['benefMediAssistID']} for emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
+ log_message('error',"MEDI_ASSIST - ✅ Updated tpa_id={$row['benefMediAssistID']} for emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
} else {
- log_message('error', "⚠️ No update (already set or not matched) for emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
+ log_message('error',"MEDI_ASSIST - ⚠️ No update (already set or not matched) for emp_code={$row['priBenefEmpCode']} policy={$row['polNo']}");
}
}
@@ -423,7 +423,7 @@ class MediAssistApiController extends BaseController
// send e-card
if(!empty($employee_policy_ids)){
- log_message('error', "sendMailForDownloadingECard JOB PUSHED.");
+ log_message('error',"MEDI_ASSIST - sendMailForDownloadingECard JOB PUSHED.");
Jobs::addJob(['job_name' => 'sendMailForDownloadingECard', 'payload' => ['ids' => $employee_policy_ids, 'client_policy_id' => $client_policy_id]]);
}
@@ -432,13 +432,13 @@ class MediAssistApiController extends BaseController
$file_model = new BatchFileModel();
$file_model->where('id', $requestData['file_id'])->set('status', $batch_file_success)->update();
- log_message('error', "Files table status updated for the file id : {$requestData['file_id']}");
+ log_message('error',"MEDI_ASSIST - Files table status updated for the file id : {$requestData['file_id']}");
} else {
- log_message('error', "Failed to update file table status.");
+ log_message('error',"MEDI_ASSIST - Failed to update file table status.");
}
- log_message('error', "TPA ID PULL SUCCESS | completed. Total fetched={$totalCount}, updated={$updated}");
+ log_message('error',"MEDI_ASSIST - TPA ID Pull SUCCESS | completed. Total fetched={$totalCount}, updated={$updated}");
if($function_calling_type == "job"){
return [
@@ -462,9 +462,9 @@ class MediAssistApiController 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',"MEDI_ASSIST - Files table status updated for the file id : {$requestData['file_id']}");
} else {
- log_message('error', "Failed to update file table status.");
+ log_message('error',"MEDI_ASSIST - Failed to update file table status.");
}
$errorData = [
@@ -478,7 +478,7 @@ class MediAssistApiController extends BaseController
'class' => $th->getTrace()[0]['class'] ?? null,
];
- log_message('error', 'Exception thrown while calling GetBenefDetails API: ' . json_encode($errorData));
+ log_message('error','MEDI_ASSIST - Exception thrown while calling GetBenefDetails API: ' . json_encode($errorData));
if($function_calling_type == "job"){
return ['status' => false, 'message' => 'API call failed', 'data' => $errorData];
}else{
@@ -564,15 +564,17 @@ class MediAssistApiController extends BaseController
if ($response['status'] != true || empty($response['data']['claimsData'][0])) {
- log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
+ log_message('error','MEDI_ASSIST - Claim Status FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
return ['status' => false,'message' => 'API call failed.','data' => $response ];
}
- // Extract claim status
+ // Extract Claim Status
$claimData = $response['data']['claimsData'][0];
$currentStatus = $claimData['claim_Current_Status'] ?? '';
$tpa_claim_no = $claimData['tpA_CLAIM_NO'] ?? '';
+ $tpa_claim_type = $claimData['typE_OF_CLAIM'] ?? '';
+ $tpa_ailments = ($claimData['ailment'] ?? '') . ' - ' . ($claimData['ailmenT_DESC'] ?? '');
// VALID STATUS LIST
$validStatuses = [
@@ -613,27 +615,35 @@ class MediAssistApiController extends BaseController
"DENIAL REVIEW AWAITED" => 66,
];
-
- // Maping tpa claim status with local claim Status
- if (isset($validStatuses[$currentStatus]))
- {
- $updateArray = ['claim_status_id' => $validStatuses[$currentStatus] , 'tpa_claim_status' => $currentStatus , 'tpa_claim_id' => $tpa_claim_no, 'claim_number' => $tpa_claim_no, 'updated_at' => date('Y-m-d H:i:s')];
- }else{
- $updateArray = ['tpa_claim_status' => $currentStatus , 'tpa_claim_id' => $tpa_claim_no, 'claim_number' => $tpa_claim_no , '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,
+ '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;
+ }
+
// 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',"MEDI_ASSIST - Claim Status SUCCESS | Updated ticket ID $claimId with Claim Status: $currentStatus");
- return ['status' => true,'message' => 'Claim status updated.','updated_status' => $currentStatus,'api_response' => $response];
+ return ['status' => true,'message' => 'Claim Status updated.','updated_status' => $currentStatus,'api_response' => $response];
}
public function IRSubmission($claimId = null) // 585 this id for test
{
- log_message('error', "IRSubmission INIT for ticket_id={$claimId}");
+ log_message('error',"MEDI_ASSIST - IR Submission | INIT for ticket_id={$claimId}");
// 1. FETCH TICKET DETAILS
$ticket = $this->db->table('ticket_master tm')
@@ -654,7 +664,7 @@ class MediAssistApiController extends BaseController
->getRowArray();
if (!$ticket || empty($ticket['ClaimID'])) {
- log_message('error', "IRSubmission FAILED → ClaimID NOT FOUND for ticket_id={$claimId}");
+ log_message('error',"MEDI_ASSIST - IR Submission FAILED → ClaimID NOT FOUND for ticket_id={$claimId}");
return [
'status' => false,
@@ -683,17 +693,17 @@ class MediAssistApiController extends BaseController
$downloadUrl = base_url('fileDownload?file_path=') . $fileDir;
} else {
$downloadUrl = "";
- log_message('error', "File NOT FOUND on server → {$fileDir}");
+ log_message('error',"MEDI_ASSIST - IR Submission File NOT FOUND on server → {$fileDir}");
}
- log_message('error', "IRSubmission Attachment Ready: {$filename} | URL={$downloadUrl}");
+ log_message('error',"MEDI_ASSIST - IR Submission Attachment Ready: {$filename} | URL={$downloadUrl}");
$Attachments[] = [
"AttachmentName" => $filename,
"AttachmentPath" => $downloadUrl
];
} else {
- log_message('error', "IRSubmission Missing File URL → file_id={$file['id']}");
+ log_message('error',"MEDI_ASSIST - IR Submission Missing File URL → file_id={$file['id']}");
}
}
}
@@ -704,7 +714,7 @@ class MediAssistApiController extends BaseController
"Attachments" => $Attachments
];
- log_message('error', "IRSubmission Request Body => " . json_encode($body));
+ log_message('error',"MEDI_ASSIST - IR Submission Request Body => " . json_encode($body));
// 4. SEND API CALL
helper('api');
@@ -720,13 +730,13 @@ class MediAssistApiController extends BaseController
$response = call_third_party_api($url, $method, $headers, $body);
- log_message('error', "IRSubmission API Response => " . json_encode($response));
+ log_message('error',"MEDI_ASSIST - IR Submission API Response => " . json_encode($response));
// 5. HANDLE RESPONSE
if (!$response['status']) {
log_message(
'error',
- "IRSubmission FAILED for ClaimID={$ticket['ClaimID']} → Response=" . json_encode($response)
+ "MEDI_ASSIST - IR Submission FAILED for ClaimID={$ticket['ClaimID']} → Response=" . json_encode($response)
);
return [
@@ -736,7 +746,7 @@ class MediAssistApiController extends BaseController
];
}
- log_message('error', "IRSubmission SUCCESS → ClaimID={$ticket['ClaimID']}");
+ log_message('error',"MEDI_ASSIST - IR Submission SUCCESS → ClaimID={$ticket['ClaimID']}");
return [
'status' => true,
@@ -750,7 +760,7 @@ class MediAssistApiController extends BaseController
$file_id = $array['file_id'];
$json = file_get_contents($array['json_file_path']);
$records = json_decode($json, true);
- // log_message('error','saveMediAssitAPIData' . json_encode($array));//die();
+ // log_message('error','MEDI_ASSIST - saveMediAssitAPIData' . json_encode($array));//die();
$file_model = new BatchFileModel();
$file_info = $file_model->where('id', $file_id)->find();
// dd($file_info);
@@ -787,7 +797,7 @@ class MediAssistApiController extends BaseController
'created_by' => $file_info[0]['created_by'] ?? null,
];
}
- // log_message('error','COUNT' . count($mappedRows));
+ // log_message('error','MEDI_ASSIST - COUNT' . count($mappedRows));
// print_rr($mappedRows);//die();
$result = $tpaApiDataModel->insertBatchWithChunkLog($mappedRows,500,('FILE_ID_'.$file_id));
// unlink($file_array['json_file_path']); // delete temp json file
@@ -829,7 +839,7 @@ class MediAssistApiController extends BaseController
// dd($TicketData);
if (!$TicketData) {
- log_message('error', "Claims not found to update status");
+ log_message('error',"MEDI_ASSIST - Claims not found to update Claim Status");
return $this->response->setJSON(['status' => false,'message' => 'Claims not found' ]);
}
@@ -871,14 +881,16 @@ class MediAssistApiController extends BaseController
$response = call_third_party_api($url, $method, $headers, $body);
if ($response['status'] != true || empty($response['data']['claimsData'][0])) {
- log_message('error', 'CLAIM STATUS FAILED | for ticket ID: ' . $claimId.' | response: '.json_encode($response));
+ log_message('error','MEDI_ASSIST - 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
+ // Extract Claim Status
$claimData = $response['data']['claimsData'][0];
$currentStatus = $claimData['claim_Current_Status'] ?? '';
$tpa_claim_no = $claimData['tpA_CLAIM_NO'] ?? '';
+ $tpa_claim_type = $claimData['typE_OF_CLAIM'] ?? '';
+ $tpa_ailments = ($claimData['ailment'] ?? '') . ' - ' . ($claimData['ailmenT_DESC'] ?? '');
// VALID STATUS LIST
$validStatuses = [
@@ -920,12 +932,20 @@ class MediAssistApiController extends BaseController
"DENIAL REVIEW AWAITED" => 66,
];
- // Maping tpa claim status with local claim Status
- if (isset($validStatuses[$currentStatus]))
- {
- $updateArray = ['claim_status_id' => $validStatuses[$currentStatus] , 'tpa_claim_status' => $currentStatus , 'tpa_claim_id' => $tpa_claim_no , 'claim_number' => $tpa_claim_no , 'updated_at' => date('Y-m-d H:i:s')];
- }else{
- $updateArray = ['tpa_claim_status' => $currentStatus , 'tpa_claim_id' => $tpa_claim_no , 'claim_number' => $tpa_claim_no, '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,
+ '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;
}
// UPDATE ticket_master
@@ -933,13 +953,13 @@ class MediAssistApiController extends BaseController
$status_updated_count ++;
// LOG UPDATE
- log_message('error', "CLAIM STATUS SUCCESS | Updated ticket ID $claimId with claim status: $currentStatus");
+ log_message('error',"MEDI_ASSIST - Claim Status SUCCESS | Updated ticket ID $claimId with Claim Status: $currentStatus");
}
return $this->response->setJSON([
'status' => true,
- 'message' => 'Claim status updated.',
+ 'message' => 'Claim Status updated.',
'updated_status' => $currentStatus,
'api_response' => $response,
'count' => $status_updated_count,
@@ -1002,7 +1022,7 @@ class MediAssistApiController extends BaseController
->getResultArray();
if (empty($policies)) {
- log_message('error', 'No policies found for claim sync');
+ log_message('error','MEDI_ASSIST - Sync TPA Claims | No policies found for claim sync');
return $this->response->setJSON([
'status' => false,
'message' => 'Policies not found'
@@ -1067,7 +1087,7 @@ class MediAssistApiController extends BaseController
if (empty($response['status']) || empty($response['data']['claimsData'])) {
- log_message('error','CLAIM STATUS FAILED | ' .'policyNo: ' . $policy['policyNo'] .' | ' . $chunkStart->format('Y-m-d') .' to ' . $chunkEnd->format('Y-m-d') .' | response: ' . json_encode($response) );
+ log_message('error','MEDI_ASSIST - Sync TPA Claims | ' .'policyNo: ' . $policy['policyNo'] .' | ' . $chunkStart->format('Y-m-d') .' to ' . $chunkEnd->format('Y-m-d') .' | response: ' . json_encode($response) );
$errorData[] = [
'policy_no' => $policy['policyNo'],
@@ -1153,7 +1173,7 @@ class MediAssistApiController extends BaseController
$claimStatusId = $validStatuses[$currentStatus] ?? null;
if (!$claimStatusId) {
- log_message('error', 'Unknown claim status: '.$currentStatus);
+ log_message('error','MEDI_ASSIST - Sync TPA Claims | Unknown Claim Status: '.$currentStatus);
continue;
}
@@ -1243,13 +1263,18 @@ class MediAssistApiController extends BaseController
// Payment
'utr_details' => $value['banK_CHEQUE_NO'] ?? null,
'settle_letter' => $value['settlement_LetterLink'] ?? null,
+
+ //others
+ 'tpa_claim_type' => $value['typE_OF_CLAIM'],
+ 'tpa_ailments' => ($value['ailment'] ?? '') . ' - ' . ($value['ailmenT_DESC'] ?? ''),
+
];
$this->db->table('ticket_master')->insert($claimData);
log_message(
'error',
- 'New claim created | Policy: '.$claimData['policy_no'].' | Claim: '.$claimData['claim_number']
+ 'MEDI_ASSIST - Sync TPA Claims | New claim created | Policy: '.$claimData['policy_no'].' | Claim: '.$claimData['claim_number']
);
}
@@ -1259,7 +1284,7 @@ class MediAssistApiController extends BaseController
return $this->response->setJSON([
'status' => true,
- 'message' => 'TPA claim status sync completed',
+ 'message' => 'TPA Claim Status sync completed',
'total_records' => count($finalResult),
'result' => $finalResult,
'errors' => $errorData
diff --git a/app/Controllers/SalesController.php b/app/Controllers/SalesController.php
index 33a422f6..751186ad 100644
--- a/app/Controllers/SalesController.php
+++ b/app/Controllers/SalesController.php
@@ -1,6 +1,6 @@
noteModel = new SalesLeadNoteModel();
}
+ public function index() {
+ $db = \Config\Database::connect();
+ // Fetch users for the assignment dropdowns
+ $data['users'] = $db->table('user_profiles')
+ ->select('id, first_name, last_name')
+ ->where('is_active', 1)
+ ->get()->getResultArray();
+
+ $this->loadLayout('sales/tracker_view', $data);
+ }
+
+ public function completeActivity($id) {
+ try {
+ $data = $this->request->getJSON(true);
+ $data['updated_by'] = $this->getUserId();
+
+ // 1. Mark current activity as completed
+ $this->activityModel->completeActivity((int)$id, [
+ 'completion_notes' => $data['completion_notes'],
+ 'updated_by' => $data['updated_by']
+ ]);
+
+ // 2. Handle follow-up if requested
+ if (!empty($data['schedule_followup']) && $data['schedule_followup'] === 'yes') {
+ $activity = $this->activityModel->find($id);
+ $this->activityModel->insert([
+ 'lead_id' => $activity['lead_id'],
+ 'activity_type' => $data['followup_type'],
+ 'notes' => $data['followup_notes'],
+ 'scheduled_date' => $data['followup_schedule'],
+ 'assigned_to' => $activity['assigned_to'],
+ 'status' => 'pending',
+ 'created_by' => $this->getUserId()
+ ]);
+ }
+
+ return $this->respond(['status' => 'success', 'message' => 'Activity updated']);
+ } catch (\Exception $e) {
+ return $this->failServerError($e->getMessage());
+ }
+ }
+
+
+ /**
+ * Corrected createLead to handle assigned_to as ID
+ */
+ public function createLead()
+ {
+ try {
+ $data = $this->request->getJSON(true);
+ $data['created_by'] = $this->getUserId();
+
+ // Ensure assigned_to is a valid integer from user_profiles
+ if (empty($data['assigned_to'])) {
+ return $this->fail('Please assign this lead to a user.');
+ }
+
+ if (!$this->leadModel->insert($data)) {
+ return $this->fail($this->leadModel->errors());
+ }
+
+ return $this->respondCreated(['status' => 'success', 'id' => $this->leadModel->getInsertID()]);
+ } catch (\Exception $e) {
+ return $this->failServerError($e->getMessage());
+ }
+ }
+
// ==================== LEAD APIs ====================
/**
@@ -81,46 +148,6 @@ class SalesController extends BaseController
}
}
- /**
- * Create new lead
- * POST /api/sales/leads
- */
- public function createLead()
- {
- try {
- $data = $this->request->getJSON(true);
-
- // Set created_by and updated_by from authenticated user
- $data['created_by'] = $this->getUserId();
- $data['updated_by'] = $this->getUserId();
-
- if (!$this->leadModel->insert($data)) {
- return $this->fail($this->leadModel->errors(), ResponseInterface::HTTP_BAD_REQUEST);
- }
-
- $leadId = $this->leadModel->getInsertID();
-
- // Insert contact persons if provided
- if (!empty($data['contact_persons'])) {
- foreach ($data['contact_persons'] as $contact) {
- $contact['lead_id'] = $leadId;
- $contact['created_by'] = $this->getUserId();
- $this->contactModel->insert($contact);
- }
- }
-
- $lead = $this->leadModel->getLeadComplete($leadId);
-
- return $this->respondCreated([
- 'status' => 'success',
- 'message' => 'Lead created successfully',
- 'data' => $lead
- ]);
- } catch (\Exception $e) {
- return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
- }
- }
-
/**
* Update lead
* PUT /api/sales/leads/{id}
@@ -467,55 +494,6 @@ class SalesController extends BaseController
}
}
- /**
- * Complete activity
- * POST /api/sales/activities/{id}/complete
- */
- public function completeActivity($id)
- {
- try {
- $activity = $this->activityModel->find((int)$id);
-
- if (!$activity) {
- return $this->failNotFound('Activity not found');
- }
-
- if ($activity['status'] === 'completed') {
- return $this->fail('Activity is already completed', ResponseInterface::HTTP_BAD_REQUEST);
- }
-
- $data = $this->request->getJSON(true);
- $data['updated_by'] = $this->getUserId();
-
- $this->activityModel->completeActivity((int)$id, $data);
-
- // Create follow-up activity if requested
- if (!empty($data['create_followup']) && $data['create_followup'] === true) {
- $followupData = [
- 'lead_id' => $activity['lead_id'],
- 'activity_type' => $data['followup_type'] ?? 'Call',
- 'notes' => $data['followup_notes'] ?? '',
- 'scheduled_date' => $data['followup_date'] ?? null,
- 'assigned_to' => $activity['assigned_to'],
- 'parent_activity_id' => $id,
- 'created_by' => $this->getUserId(),
- 'updated_by' => $this->getUserId(),
- ];
-
- $this->activityModel->insert($followupData);
- }
-
- $updatedActivity = $this->activityModel->find((int)$id);
-
- return $this->respond([
- 'status' => 'success',
- 'message' => 'Activity completed successfully',
- 'data' => $updatedActivity
- ]);
- } catch (\Exception $e) {
- return $this->fail($e->getMessage(), ResponseInterface::HTTP_INTERNAL_SERVER_ERROR);
- }
- }
/**
* Delete activity
diff --git a/app/Controllers/VidalApiController.php b/app/Controllers/VidalApiController.php
index c5274eff..62a9da4a 100644
--- a/app/Controllers/VidalApiController.php
+++ b/app/Controllers/VidalApiController.php
@@ -412,7 +412,7 @@ class VidalApiController extends BaseController
return ['status' => 'success','data' => $decryptedData["redirectUrl"]];
}
- public function ClaimDetail($claimId = null) //234
+ public function ClaimDetail($claimId = 234) //234
{
helper('api');
@@ -454,16 +454,24 @@ class VidalApiController extends BaseController
$body = [
'empNO' => "",
'tpaCardID' => "",
- 'claimID' => $ticket['claimID'],
+ 'claimID' => "CHE-0226-CL-0013404", //$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);
+ 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));
diff --git a/app/Models/SalesActivityModel.php b/app/Models/SalesActivityModel.php
index dc70086c..80b8aef6 100644
--- a/app/Models/SalesActivityModel.php
+++ b/app/Models/SalesActivityModel.php
@@ -60,52 +60,52 @@ class SalesActivityModel extends Model
protected $skipValidation = false;
/**
- * Get activities by lead with user details
+ * Get sales_activities by lead with user details
*/
public function getActivitiesByLead($leadId, $status = null)
{
- $builder = $this->select('activities.*, user_profiles.username as assigned_to_name')
- ->join('user_profiles', 'user_profiles.id = activities.assigned_to', 'left')
- ->where('activities.lead_id', $leadId);
+ $builder = $this->select('sales_activities.*, user_profiles.first_name as assigned_to_name')
+ ->join('user_profiles', 'user_profiles.id = sales_activities.assigned_to', 'left')
+ ->where('sales_activities.lead_id', $leadId);
if ($status) {
- $builder->where('activities.status', $status);
+ $builder->where('sales_activities.status', $status);
}
- return $builder->orderBy('activities.scheduled_date', 'DESC')->findAll();
+ return $builder->orderBy('sales_activities.scheduled_date', 'DESC')->findAll();
}
/**
- * Get all activities with filters
+ * Get all sales_activities with filters
*/
public function getActivitiesWithFilters($filters = [], $limit = 10, $offset = 0)
{
- $builder = $this->select('activities.*, actual_leads.company_name, user_profiles.username as assigned_to_name')
- ->join('actual_leads', 'actual_leads.lead_id = activities.lead_id', 'left')
- ->join('user_profiles', 'user_profiles.id = activities.assigned_to', 'left');
+ $builder = $this->select('sales_activities.*, actual_leads.company_name, user_profiles.first_name as assigned_to_name')
+ ->join('actual_leads', 'actual_leads.lead_id = sales_activities.lead_id', 'left')
+ ->join('user_profiles', 'user_profiles.id = sales_activities.assigned_to', 'left');
if (!empty($filters['status'])) {
- $builder->where('activities.status', $filters['status']);
+ $builder->where('sales_activities.status', $filters['status']);
}
if (!empty($filters['activity_type'])) {
- $builder->where('activities.activity_type', $filters['activity_type']);
+ $builder->where('sales_activities.activity_type', $filters['activity_type']);
}
if (!empty($filters['assigned_to'])) {
- $builder->where('activities.assigned_to', $filters['assigned_to']);
+ $builder->where('sales_activities.assigned_to', $filters['assigned_to']);
}
if (!empty($filters['date_from'])) {
- $builder->where('activities.scheduled_date >=', $filters['date_from']);
+ $builder->where('sales_activities.scheduled_date >=', $filters['date_from']);
}
if (!empty($filters['date_to'])) {
- $builder->where('activities.scheduled_date <=', $filters['date_to']);
+ $builder->where('sales_activities.scheduled_date <=', $filters['date_to']);
}
return [
- 'data' => $builder->orderBy('activities.scheduled_date', 'DESC')
+ 'data' => $builder->orderBy('sales_activities.scheduled_date', 'DESC')
->limit($limit, $offset)->findAll(),
'total' => $builder->countAllResults(false)
];
@@ -125,7 +125,7 @@ class SalesActivityModel extends Model
}
/**
- * Get pending activities count by user
+ * Get pending sales_activities count by user
*/
public function getPendingActivitiesCount($userId)
{
@@ -136,18 +136,18 @@ class SalesActivityModel extends Model
}
/**
- * Get upcoming activities for a user
+ * Get upcoming sales_activities for a user
*/
public function getUpcomingActivities($userId, $days = 7, $limit = 10)
{
$endDate = date('Y-m-d H:i:s', strtotime("+{$days} days"));
- return $this->select('activities.*, actual_leads.company_name')
- ->join('actual_leads', 'actual_leads.lead_id = activities.lead_id', 'left')
- ->where('activities.assigned_to', $userId)
- ->where('activities.status', 'pending')
- ->where('activities.scheduled_date <=', $endDate)
- ->orderBy('activities.scheduled_date', 'ASC')
+ return $this->select('sales_activities.*, actual_leads.company_name')
+ ->join('actual_leads', 'actual_leads.lead_id = sales_activities.lead_id', 'left')
+ ->where('sales_activities.assigned_to', $userId)
+ ->where('sales_activities.status', 'pending')
+ ->where('sales_activities.scheduled_date <=', $endDate)
+ ->orderBy('sales_activities.scheduled_date', 'ASC')
->limit($limit)
->findAll();
}
@@ -157,10 +157,10 @@ class SalesActivityModel extends Model
*/
public function getActivityTimeline($leadId)
{
- return $this->select('activities.*, user_profiles.username as assigned_to_name')
- ->join('user_profiles', 'user_profiles.id = activities.assigned_to', 'left')
- ->where('activities.lead_id', $leadId)
- ->orderBy('activities.scheduled_date', 'DESC')
+ return $this->select('sales_activities.*, user_profiles.first_name as assigned_to_name')
+ ->join('user_profiles', 'user_profiles.id = sales_activities.assigned_to', 'left')
+ ->where('sales_activities.lead_id', $leadId)
+ ->orderBy('sales_activities.scheduled_date', 'DESC')
->findAll();
}
}
\ No newline at end of file
diff --git a/app/Models/SalesActualLeadModel.php b/app/Models/SalesActualLeadModel.php
index 6b8aee8f..25603740 100644
--- a/app/Models/SalesActualLeadModel.php
+++ b/app/Models/SalesActualLeadModel.php
@@ -6,7 +6,7 @@ use CodeIgniter\Model;
/**
* Lead Model
- * Handles all operations related to actual_leads table
+ * Handles all operations related to sales_actual_leads table
*/
class SalesActualLeadModel extends Model
{
@@ -63,9 +63,9 @@ class SalesActualLeadModel extends Model
*/
public function getLeadWithUser($leadId)
{
- return $this->select('actual_leads.*, user_profiles.username as assigned_to_name, user_profiles.email as assigned_to_email')
- ->join('user_profiles', 'user_profiles.id = actual_leads.assigned_to', 'left')
- ->where('actual_leads.lead_id', $leadId)
+ return $this->select('sales_actual_leads.*, user_profiles.first_name as assigned_to_name, user_profiles.email as assigned_to_email')
+ ->join('user_profiles', 'user_profiles.id = sales_actual_leads.assigned_to', 'left')
+ ->where('sales_actual_leads.lead_id', $leadId)
->first();
}
@@ -74,22 +74,22 @@ class SalesActualLeadModel extends Model
*/
public function getLeadsWithFilters($filters = [], $limit = 10, $offset = 0)
{
- $builder = $this->select('actual_leads.*, user_profiles.username as assigned_to_name')
- ->join('user_profiles', 'user_profiles.id = actual_leads.assigned_to', 'left');
+ $builder = $this->select('sales_actual_leads.*, user_profiles.first_name as assigned_to_name')
+ ->join('user_profiles', 'user_profiles.id = sales_actual_leads.assigned_to', 'left');
if (!empty($filters['status'])) {
- $builder->where('actual_leads.status', $filters['status']);
+ $builder->where('sales_actual_leads.status', $filters['status']);
}
if (!empty($filters['assigned_to'])) {
- $builder->where('actual_leads.assigned_to', $filters['assigned_to']);
+ $builder->where('sales_actual_leads.assigned_to', $filters['assigned_to']);
}
if (!empty($filters['search'])) {
$builder->groupStart()
- ->like('actual_leads.company_name', $filters['search'])
- ->orLike('actual_leads.email', $filters['search'])
- ->orLike('actual_leads.phone', $filters['search'])
+ ->like('sales_actual_leads.company_name', $filters['search'])
+ ->orLike('sales_actual_leads.email', $filters['search'])
+ ->orLike('sales_actual_leads.phone', $filters['search'])
->groupEnd();
}
diff --git a/app/Models/SalesLeadNoteModel.php b/app/Models/SalesLeadNoteModel.php
index c8d9654f..60e612a4 100644
--- a/app/Models/SalesLeadNoteModel.php
+++ b/app/Models/SalesLeadNoteModel.php
@@ -53,10 +53,10 @@ class SalesLeadNoteModel extends Model
*/
public function getNotesByLead($leadId)
{
- return $this->select('lead_notes.*, user_profiles.username')
- ->join('user_profiles', 'user_profiles.id = lead_notes.user_id', 'left')
- ->where('lead_notes.lead_id', $leadId)
- ->orderBy('lead_notes.created_at', 'DESC')
+ return $this->select('sales_lead_notes.*, user_profiles.first_name')
+ ->join('user_profiles', 'user_profiles.id = sales_lead_notes.created_by', 'left')
+ ->where('sales_lead_notes.lead_id', $leadId)
+ ->orderBy('sales_lead_notes.created_at', 'DESC')
->findAll();
}
@@ -65,10 +65,10 @@ class SalesLeadNoteModel extends Model
*/
public function getNotesByUser($userId, $limit = 20, $offset = 0)
{
- return $this->select('lead_notes.*, actual_leads.company_name')
- ->join('actual_leads', 'actual_leads.lead_id = lead_notes.lead_id', 'left')
- ->where('lead_notes.user_id', $userId)
- ->orderBy('lead_notes.created_at', 'DESC')
+ return $this->select('sales_lead_notes.*, actual_leads.company_name')
+ ->join('actual_leads', 'actual_leads.lead_id = sales_lead_notes.lead_id', 'left')
+ ->where('sales_lead_notes.created_by', $userId)
+ ->orderBy('sales_lead_notes.created_at', 'DESC')
->limit($limit, $offset)
->findAll();
}
diff --git a/app/Models/TpaConfigModel.php b/app/Models/TpaConfigModel.php
new file mode 100644
index 00000000..10ddc35a
--- /dev/null
+++ b/app/Models/TpaConfigModel.php
@@ -0,0 +1,12 @@
+
\ No newline at end of file
diff --git a/app/Views/logs/view.php b/app/Views/logs/view.php
index de031e03..1e7b7cfb 100644
--- a/app/Views/logs/view.php
+++ b/app/Views/logs/view.php
@@ -2,482 +2,126 @@
-
= esc($title) ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- = count(array_filter($logEntries, fn($e) => stripos($e['message'], 'TPA CLAIM PUSH SUCCESS') !== false)) ?>
-
-
Claim success
-
-
-
- = count(array_filter($logEntries, fn($e) => stripos($e['message'], 'TPA CLAIM PUSH FAILED') !== false)) ?>
-
-
Claim failed
-
-
-
- = count(array_filter($logEntries, fn($e) => stripos($e['message'], 'TPA ID PULL SUCCESS') !== false)) ?>
-
-
Tpa no pull success
-
-
-
- = count(array_filter($logEntries, fn($e) => stripos($e['message'], 'TPA ID PULL FAILED') !== false)) ?>
-
-
Tpa no pull Failed
-
-
-
- = count(array_filter($logEntries, fn($e) => stripos($e['message'], 'CLAIM STATUS SUCCESS') !== false)) ?>
-
-
Claim status fetch success
-
-
-
- = count(array_filter($logEntries, fn($e) => stripos($e['message'], 'CLAIM STATUS FAILED') !== false)) ?>
-
-
Claim status fetch failed
-
-
-
- = count(array_filter($logEntries, fn($e) => stripos($e['message'], 'Ecard Request PUSH SUCCESS') !== false)) ?>
-
-
Ecard Request
-
-
-
-
-
-
-
-
-
- Filter:
-
-
-
-
-
-
-
-
-
-
-
-
-
No Log Entries Found
-
This log file is empty or couldn't be parsed.
-
-
-
-
-
-
-
-
= esc($entry['message']) ?>
-
-
-
-
+
+
-
+
+
+
+
+
No Logs Found
+
Try adjusting your TPA filters or search term.
+
+
+
+
+
+
+ = esc($entry['level']) ?>
+ = esc($entry['date']) ?>
+
+
= esc($entry['message']) ?>
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/sales/tracker_view.php b/app/Views/sales/tracker_view.php
new file mode 100644
index 00000000..b317712c
--- /dev/null
+++ b/app/Views/sales/tracker_view.php
@@ -0,0 +1,356 @@
+
+
+
+
+
+
+
+
+
+
All
+
New
+
Potential
+
Prospects
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Activity Timeline
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file