Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
670a8be9db
@ -131,5 +131,10 @@ HEALTH_INDIA_PASSWORD =
|
||||
|
||||
HEALTH_INDIA_PRIMARY_KEY_CONSTANT =
|
||||
|
||||
#For sending mail for leads RFQ/QCR
|
||||
LEAD_INSURER_FROM_MAIL_ID =
|
||||
LEAD_CLIENT_FROM_MAIL_ID =
|
||||
|
||||
# BDS Daily Report Emails Configuration
|
||||
bds.dailyReportEmails =
|
||||
|
||||
|
||||
51
app/Config/RfqConfig.php
Normal file
51
app/Config/RfqConfig.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class RfqConfig extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Google Drive parent folder IDs for RFQ and QCR sheets.
|
||||
*/
|
||||
public string $rfqParentFolderId = '1MnYh5PTPDlc9mYMGsjmTv02y8EZ-BQf1';
|
||||
public string $qcrParentFolderId = '1MnYh5PTPDlc9mYMGsjmTv02y8EZ-BQf1';
|
||||
|
||||
/**
|
||||
* Default permissions for created sheets.
|
||||
* Copied from GoogleSheetController::$config.
|
||||
*/
|
||||
public array $permissions = [
|
||||
'editors' => [
|
||||
'vitvelz@gmail.com',
|
||||
'velz1990@gmail.com',
|
||||
'venkateshraman786@gmail.com',
|
||||
],
|
||||
'viewers' => [],
|
||||
];
|
||||
|
||||
/**
|
||||
* Default protections for RFQ sheets.
|
||||
* Copied from GoogleSheetController::$config.
|
||||
*/
|
||||
public array $protections = [
|
||||
[
|
||||
'range' => 'RFQ Page!B12:C12',
|
||||
'users' => [
|
||||
'velz1990@gmail.com',
|
||||
'vitvelz@gmail.com',
|
||||
'firebase-adminsdk-mcdfe@nhance-ee8d1.iam.gserviceaccount.com',
|
||||
],
|
||||
'groups' => [],
|
||||
],
|
||||
[
|
||||
'range' => 'Claims Page!A1',
|
||||
'users' => [
|
||||
'velz1990@gmail.com',
|
||||
'venkateshraman786@gmail.com',
|
||||
'firebase-adminsdk-mcdfe@nhance-ee8d1.iam.gserviceaccount.com',
|
||||
],
|
||||
'groups' => [],
|
||||
],
|
||||
];
|
||||
}
|
||||
@ -510,6 +510,8 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->match(['get', 'post'],"list", "LeadsController::viewLeadsList");
|
||||
$routes->post("create", "LeadsController::createLead");
|
||||
$routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1");
|
||||
$routes->get("createRfqSheet", "LeadsController::createRfqSheet");
|
||||
$routes->get("mailTemplate", "LeadsController::getLeadMailTemplate");
|
||||
$routes->get("sendMail", "LeadsController::sendMailWithAttachement");
|
||||
$routes->post("sendMail", "LeadsController::sendMailWithAttachement");
|
||||
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
||||
@ -523,6 +525,10 @@ $routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("createQCR", "LeadsController::createQCR");
|
||||
$routes->get("list/(:any)", "LeadsController::viewRFQ/$1");
|
||||
$routes->get("nonEB","LeadsController::rfqNonEB");
|
||||
// Non-EB dedicated RFQ/QCR endpoints (do not alter existing ones)
|
||||
$routes->get("nonEB/rfq/(:any)","LeadsController::viewNonEbRFQFromList/$1");
|
||||
$routes->get("nonEB/qcr/(:any)","LeadsController::viewNonEbQCRFromList/$1");
|
||||
$routes->get("placementData/(:num)", "LeadsController::getPlacementData/$1");
|
||||
});
|
||||
|
||||
|
||||
@ -552,9 +558,18 @@ $routes->cli("cli/sendCroneRemainderMail", "DashboardController::sendCroneRemain
|
||||
$routes->cli('cli/update-emp-policy-status', 'ClientController::updateEmpAndPolicyStatus');
|
||||
$routes->cli('cli/insurerRFQRemainder', 'LeadsController::remainderForQcr');
|
||||
$routes->cli('cli/sendMailWithAutoQuery','TicketController::sendMailWithAutoQuery');
|
||||
|
||||
// Claim Status Update every 2 hours
|
||||
$routes->cli('cli/MediAssit-ClaimStatusUpdate','MediAssistApiController::ClaimStatusUpdate');
|
||||
$routes->cli('cli/Vidal-ClaimStatusUpdate','VidalApiController::ClaimStatusUpdate');
|
||||
$routes->cli('cli/Fhpl-ClaimStatusUpdate','FhplApiController::ClaimStatusUpdate');
|
||||
$routes->cli('cli/HealthIndia-ClaimStatusUpdate','HealthIndiaApiController::ClaimStatusUpdate');
|
||||
|
||||
// Sync TPA Claims to Nhance
|
||||
$routes->cli('cli/MediAssit-syncTpaClaimToNhance','MediAssistApiController::syncTpaClaimToNhance');
|
||||
$routes->cli('cli/Fhpl-syncTpaClaimToNhance','FhplApiController::syncFhplClaimsToNhance');
|
||||
$routes->cli('cli/HealthIndia-syncTpaClaimToNhance','HealthIndiaApiController::syncHealthIndiaClaimsToNhance');
|
||||
|
||||
$routes->cli('cli/thzReminderCrone','ThzController::getOpenTicketsOlderThan24HoursAndAssignNextLevel');
|
||||
|
||||
|
||||
@ -771,6 +786,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('fetchVehiclePolicy/(:any)','TicketController::fetchVehiclePolicy/$1');
|
||||
$routes->post('saveIRDocsJson',"TicketController::saveIRDocsJson");
|
||||
$routes->get('getTpaClaimStatus',"ApiServiceController::getClaimStatus");
|
||||
$routes->post('manualTpaClaimPush',"ApiServiceController::manualTpaClaimPush");
|
||||
});
|
||||
|
||||
$routes->group("/claim_mis", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
@ -82,6 +82,8 @@ class ApiServiceController extends BaseController
|
||||
{
|
||||
try{
|
||||
|
||||
|
||||
|
||||
if(empty($params) && $this->response){
|
||||
|
||||
$payload = $this->request->getJSON(true);
|
||||
@ -105,6 +107,9 @@ class ApiServiceController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
|
||||
log_message('error', 'Ecard Request started | client_policy_id: '.$client_policy_id.' | policyNo: '.$policy_no.' | emp_code: '.$emp_code.' | type: '.$type);
|
||||
|
||||
// $employee_policy = $this->employeePolicyModel
|
||||
// ->select('employees.*, employee_polices.tpa_id , employee_polices.rand_string , employee_polices.uhid as uhid , client_policy.tpa_id as tpa_primary_id ')
|
||||
// ->join('employees', 'employee_polices.employee_id = employees.id', 'left')
|
||||
@ -126,11 +131,15 @@ class ApiServiceController extends BaseController
|
||||
->whereIn('employees.emp_status', ['active', 'expired'])
|
||||
->findAll();
|
||||
|
||||
log_message('error', 'Ecard Request - Employee data fetched | count: '.count($employee_policy).' | type: '.$type);
|
||||
|
||||
if(count($employee_policy) > 0)
|
||||
{
|
||||
if($employee_policy[0]['tpa_id'] != null)
|
||||
{
|
||||
|
||||
log_message('error', 'Ecard Request - tpa_id found | tpa_id: '.$employee_policy[0]['tpa_id'].' | type: '.$type);
|
||||
|
||||
if($employee_policy[0]['tpa_primary_id'] == $this->medi_assist_primary_key)//Medi assist
|
||||
{
|
||||
|
||||
@ -176,11 +185,11 @@ class ApiServiceController extends BaseController
|
||||
$data['message'] = "E-card not generated";
|
||||
}
|
||||
|
||||
} else {
|
||||
$data['eCardDownload'] = null;
|
||||
$data['message'] = "E-card not generated";
|
||||
log_message('error', 'TPA number is null');
|
||||
}
|
||||
} else {
|
||||
$data['eCardDownload'] = null;
|
||||
$data['message'] = "E-card not generated";
|
||||
log_message('error', 'TPA number is null');
|
||||
}
|
||||
}else{
|
||||
$data['eCardDownload'] = null;
|
||||
$data['message'] = "E-card not generated";
|
||||
@ -476,6 +485,35 @@ class ApiServiceController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Manual TPA Claim Push - accepts claim_id via POST and delegates to pushClaims().
|
||||
* Returns the response from pushClaims() as the API response.
|
||||
*/
|
||||
public function manualTpaClaimPush()
|
||||
{
|
||||
$claimId = $this->request->getPost('claim_id');
|
||||
|
||||
if (empty($claimId)) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'claim_id is required'
|
||||
]);
|
||||
}
|
||||
|
||||
$result = $this->pushClaims($claimId);
|
||||
|
||||
if ($result !== null && is_array($result)) {
|
||||
return $this->response->setJSON([
|
||||
'status' => $result['status'] ?? false,
|
||||
'message' => $result['message'] ?? ($result['status'] ? 'Claim pushed successfully' : 'Claim push failed')
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
'message' => 'Claim push failed or TPA has no API service enabled for this ticket.'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// public function getWellnessUrl()
|
||||
|
||||
@ -99,7 +99,7 @@ class FhplApiController extends BaseController
|
||||
|
||||
if (count($data) && $data['filePath'] == null) {
|
||||
log_message('error', "FHPL - Claim Push FAILED | claimId: '.$claimId.' - Claim or File Missing");
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | Claim or File Missing'];
|
||||
}
|
||||
|
||||
// Build absolute file path
|
||||
@ -108,7 +108,7 @@ class FhplApiController extends BaseController
|
||||
|
||||
if (!file_exists($pdfPath)) {
|
||||
log_message('error', "FHPL - Claim Push FAILED | claimId: '.$claimId.' - PDF not found on server");
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | PDF not found on server'];
|
||||
}
|
||||
|
||||
// Convert PDF to Base64
|
||||
@ -118,7 +118,7 @@ class FhplApiController extends BaseController
|
||||
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
|
||||
if (empty($tokenResponse['data']['access_token'])) {
|
||||
log_message('error', "FHPL - Claim Push FAILED | claimId: '.$claimId.' - FHPL Token generation failed");
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | FHPL Token generation failed'];
|
||||
}
|
||||
$token = $tokenResponse['data']['access_token'];
|
||||
|
||||
@ -163,7 +163,7 @@ class FhplApiController extends BaseController
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_push_response' => json_encode($response) ]);
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | API call failed'];
|
||||
}
|
||||
|
||||
|
||||
@ -185,14 +185,14 @@ class FhplApiController extends BaseController
|
||||
]);
|
||||
|
||||
log_message('error', 'FHPL - Claim Push SUCCESS | claimId: '.$claimId.' | claimNO: '.$fhplClaimNo);
|
||||
|
||||
return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response];
|
||||
}else {
|
||||
log_message('error', 'FHPL - Claim Push API SUCCESS BUT claimsInfo EMPTY | response: '.json_encode($response));
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push API SUCCESS BUT claimsInfo EMPTY'];
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push API SUCCESS BUT claimsInfo EMPTY'];
|
||||
// return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
@ -288,7 +288,10 @@ class FhplApiController extends BaseController
|
||||
$tickets = $this->db->table('ticket_master tm')
|
||||
->select("tm.id,tm.tpa_claim_id,cp.policy_no")
|
||||
->join('client_policy cp','tm.client_policy_id=cp.id')
|
||||
->where('tm.tpa_claim_id IS NOT NULL')
|
||||
->where('tm.tpa_claim_push_reference_no IS NOT NULL')
|
||||
->whereNotIn('tm.claim_status_id', [8, 11, 12, 13, 66, 22, 24, 47, 49, 32, 34, 53, 55, 42, 44, 58, 60])
|
||||
->where('tm.is_active', 1)
|
||||
->where('cp.tpa_id', $this->fhplTpaId)
|
||||
->get()->getResultArray();
|
||||
|
||||
$count=0;
|
||||
@ -714,7 +717,7 @@ class FhplApiController extends BaseController
|
||||
// ];
|
||||
// }
|
||||
|
||||
public function syncFhplClaimsToNhance()
|
||||
public function syncFhplClaimsToNhanceOld()
|
||||
{
|
||||
helper('api');
|
||||
|
||||
@ -790,6 +793,201 @@ class FhplApiController extends BaseController
|
||||
return ['status'=>true,'total'=>count($finalResult)];
|
||||
}
|
||||
|
||||
public function syncFhplClaimsToNhance()
|
||||
{
|
||||
helper('api');
|
||||
|
||||
try {
|
||||
|
||||
// Generate FHPL Token
|
||||
$tokenResponse = json_decode($this->generateAuthToken()->getBody(), true);
|
||||
|
||||
if (empty($tokenResponse['data']['access_token'])) {
|
||||
return $this->response->setJSON(['status' => false,'message' => 'FHPL Token generation failed']);
|
||||
}
|
||||
|
||||
$token = $tokenResponse['data']['access_token'];
|
||||
|
||||
$url = getenv('FHPL_BASE_URL')."/api/GetTPA_ClaimsDetails";
|
||||
|
||||
$headers = [
|
||||
"Authorization: Bearer ".$token,
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
$policies = $this->db->table('client_policy')
|
||||
->where('tpa_id',$this->fhplTpaId)
|
||||
->get()->getResultArray();
|
||||
|
||||
$finalResult=[];
|
||||
foreach($policies as $policy){
|
||||
|
||||
$body = [
|
||||
"UserName" => getenv('FHPL_USER_NAME'),
|
||||
"Password" => getenv('FHPL_PASSWORD'),
|
||||
"PolicyNumber" => $policy['policy_no'],
|
||||
"Fromdate" => $policy['policy_start_date'],
|
||||
"Todate" => $policy['policy_end_date']
|
||||
];
|
||||
|
||||
$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($response));
|
||||
$finalResult = array_merge($finalResult,$response['data']);
|
||||
}
|
||||
}
|
||||
|
||||
$insertedCount = 0;
|
||||
|
||||
// Insert into ticket_master with mandatory columns (reference: MediAssist syncTpaClaimToNhance)
|
||||
foreach($finalResult as $row){
|
||||
|
||||
$status = $row['CLAIM_STATUS'] ?? null;
|
||||
|
||||
$map = [
|
||||
"Under Process"=>5,
|
||||
"Paid"=>11,
|
||||
"Rejected"=>8,
|
||||
"Approved"=>8
|
||||
];
|
||||
|
||||
$claimStatus = $map[$status] ?? 61;
|
||||
|
||||
// Derive relationship (default to self)
|
||||
$relationship = map_relationship(trim($row['RELATION'] ?? 'self'));
|
||||
|
||||
// Fetch client policy details
|
||||
$clientpolicy = $this->db->table('client_policy cp')
|
||||
->select("
|
||||
cp.id as client_policy_id,
|
||||
cp.client_id ,
|
||||
cp.insurer_id ,
|
||||
cp.tpa_id ,
|
||||
client_rm.id as acm_id
|
||||
")
|
||||
->join('client_rm', 'client_rm.client_id = cp.client_id AND client_rm.level = 3', 'left')
|
||||
->where('cp.policy_no', $row['POLICY_NO'] ?? null)
|
||||
->orderBy('client_rm.id','DESC')
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if (!$clientpolicy) {
|
||||
log_message(
|
||||
'error',
|
||||
'FHPL - Sync TPA Claims | Client policy not found for policy_no: ' . ($row['POLICY_NO'] ?? 'N/A')
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Fetch employee / insured details
|
||||
$employee = $this->db->table('employees e')
|
||||
->select("
|
||||
e.id as emp_id,
|
||||
e.emp_code ,
|
||||
e.name as emp_name,
|
||||
e2.id as insured_emp_id,
|
||||
e2.name as insured_emp_name,
|
||||
ep.tpa_id as tpa_no
|
||||
")
|
||||
->join(
|
||||
'employees e2',
|
||||
"e2.emp_code = e.emp_code AND e2.relationship = ".$this->db->escape($relationship),
|
||||
'left'
|
||||
)
|
||||
->join( 'employee_polices ep', "ep.employee_id = e2.id ", 'left' )
|
||||
->where('e.emp_code', $row['EMPLOYEE_NO'] ?? null)
|
||||
->where('e.client_id', $clientpolicy['client_id'] ?? null)
|
||||
->where('e.relationship', 'self')
|
||||
->where('e.is_active', 1)
|
||||
->where('e2.is_active', 1)
|
||||
->where('ep.is_active', 1)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if (!$employee) {
|
||||
log_message(
|
||||
'error',
|
||||
'FHPL - Sync TPA Claims | Employee data not found for emp_code: ' . ($row['EMPLOYEE_NO'] ?? 'N/A') .
|
||||
' | policy_no: ' . ($row['POLICY_NO'] ?? 'N/A') .
|
||||
' | relationship: ' . $relationship
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
$claimData = [
|
||||
// Core
|
||||
'ticket_type_id' => 1,
|
||||
'claim_status_id' => $claimStatus,
|
||||
'policy_no' => $row['POLICY_NO'] ?? null,
|
||||
'claim_number' => $row['CLAIM_ID'] ?? null,
|
||||
'tpa_claim_id' => $row['CLAIM_ID'] ?? null,
|
||||
|
||||
// local primary ids
|
||||
'tpa_id' => $clientpolicy['tpa_id'] ?? $this->fhplTpaId,
|
||||
'insurer_id' => $clientpolicy['insurer_id'] ?? null,
|
||||
'client_policy_id' => $clientpolicy['client_policy_id'] ?? null,
|
||||
'client_id' => $clientpolicy['client_id'] ?? null,
|
||||
'acm_id' => $clientpolicy['acm_id'] ?? null,
|
||||
|
||||
// Employee / Insured
|
||||
'emp_id' => $employee['emp_id'] ?? null,
|
||||
'insured_emp_id' => $employee['insured_emp_id'] ?? null,
|
||||
'tpa_no' => $employee['tpa_no'] ?? null,
|
||||
'emp_code' => $row['EMPLOYEE_NO'] ?? null,
|
||||
'emp_name' => $employee['emp_name'] ?? null,
|
||||
'insured_name' => $row['insured_emp_name'] ?? null,
|
||||
'relationship' => $relationship,
|
||||
|
||||
// Claim info
|
||||
'claim_type' => 1,
|
||||
'mode_of_intimation' => 5,
|
||||
'claim_amount' => $row['CLAIM_AMOUNT'] ?? null,
|
||||
|
||||
// Dates
|
||||
'doa' => change_date_format($row['DATE_OF_ADMISSION'] ?? '', null, 'Y-m-d') ?? null,
|
||||
'dod' => change_date_format($row['DATE_OF_DISCHARGE'] ?? '', null, 'Y-m-d') ?? null,
|
||||
|
||||
// Hospital
|
||||
'hospital_name' => $row['HOSPITAL_NAME'] ?? null,
|
||||
'hospital_state' => $row['HOSPITAL_STATE'] ?? null,
|
||||
'hospital_city' => $row['HOSPITAL_CITY'] ?? null,
|
||||
'hospital_address' => $row['Hospital Address'] ?? null,
|
||||
'hospital_pincode' => $row['Hospital Pincode'] ?? null,
|
||||
|
||||
'registration_date' => $row['CLAIM_REGISTERED_DATE'] ?? null,
|
||||
|
||||
// Others
|
||||
'tpa_claim_type' => $row['CLAIM_TYPE'] ?? null,
|
||||
'tpa_ailments' => $row['AILMENT'] ?? null,
|
||||
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
$this->db->table('ticket_master')->insert($claimData);
|
||||
|
||||
$insertedCount++;
|
||||
}
|
||||
|
||||
log_message('error', 'FHPL - Sync TPA Claims | Fetched Data | Inserted Data: ' . count($finalResult) . ' | Inserted: ' . $insertedCount);
|
||||
return ['status'=>true,'total'=>count($finalResult), 'inserted'=>$insertedCount];
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
$errorData = [
|
||||
'message' => $th->getMessage(),
|
||||
'file' => $th->getFile(),
|
||||
'line' => $th->getLine(),
|
||||
'code' => $th->getCode(),
|
||||
'trace' => $th->getTraceAsString(),
|
||||
'trace_array' => $th->getTrace(), // full array version (optional)
|
||||
'function' => $th->getTrace()[0]['function'] ?? null,
|
||||
'class' => $th->getTrace()[0]['class'] ?? null,
|
||||
];
|
||||
log_message('error', 'FHPL - Sync TPA Claims | Exception thrown: ' . json_encode($errorData));
|
||||
return ['status'=>false,'message'=>$th->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
public function saveFhplAPIData($array)
|
||||
{
|
||||
$file_id = $array['file_id'];
|
||||
|
||||
@ -123,12 +123,12 @@ class HealthIndiaApiController extends BaseController
|
||||
|
||||
if (!$data) {
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - Claim not found");
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | Claim not found'];
|
||||
}
|
||||
|
||||
if ($data['filePath'] == null) {
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - File Missing");
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | File Missing'];
|
||||
}
|
||||
|
||||
// Build absolute file path
|
||||
@ -137,7 +137,7 @@ class HealthIndiaApiController extends BaseController
|
||||
|
||||
if (!file_exists($pdfPath)) {
|
||||
log_message('error', "HEALTH_INDIA - Claim Push FAILED | claimId: {$claimId} - PDF not found on server at path: {$pdfPath}");
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | PDF not found on server'];
|
||||
}
|
||||
|
||||
// Convert PDF to Base64
|
||||
@ -217,7 +217,7 @@ class HealthIndiaApiController extends BaseController
|
||||
$this->db->table('ticket_master')
|
||||
->where('id', $claimId)
|
||||
->update(['tpa_push_response' => json_encode($response)]);
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | API call failed'];
|
||||
}
|
||||
|
||||
if ($response['status'] === true && !empty($response['data']['result'][0]['ccn'])) {
|
||||
@ -234,12 +234,13 @@ class HealthIndiaApiController extends BaseController
|
||||
]);
|
||||
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push SUCCESS | claimId: ' . $claimId . ' | CCN: ' . $ccn . ' | CCN_EXT: ' . $ccnExt);
|
||||
return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response];
|
||||
} else {
|
||||
log_message('error', 'HEALTH_INDIA - Claim Push API SUCCESS BUT CCN EMPTY | claimId: ' . $claimId . ' | response: ' . json_encode($response));
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push API SUCCESS BUT CCN EMPTY'];
|
||||
}
|
||||
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push API SUCCESS BUT CCN EMPTY'];
|
||||
}
|
||||
|
||||
public function ClaimDetail($claimId = null)
|
||||
@ -355,7 +356,9 @@ class HealthIndiaApiController extends BaseController
|
||||
$tickets = $this->db->table('ticket_master tm')
|
||||
->select("tm.id, tm.tpa_claim_id, cp.policy_no")
|
||||
->join('client_policy cp', 'tm.client_policy_id=cp.id')
|
||||
->where('tm.tpa_claim_id IS NOT NULL')
|
||||
->where('tm.tpa_claim_push_reference_no IS NOT NULL')
|
||||
->whereNotIn('tm.claim_status_id', [8, 11, 12, 13, 66, 22, 24, 47, 49, 32, 34, 53, 55, 42, 44, 58, 60])
|
||||
->where('tm.is_active', 1)
|
||||
->where('cp.tpa_id', $this->healthIndiaTpaId)
|
||||
->get()->getResultArray();
|
||||
|
||||
@ -722,7 +725,7 @@ class HealthIndiaApiController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function syncHealthIndiaClaimsToNhance()
|
||||
public function syncHealthIndiaClaimsToNhanceOld()
|
||||
{
|
||||
helper('api');
|
||||
|
||||
@ -820,6 +823,217 @@ class HealthIndiaApiController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
public function syncHealthIndiaClaimsToNhance()
|
||||
{
|
||||
helper('api');
|
||||
|
||||
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', 'HEALTH_INDIA - Sync TPA Claims FAILED | Token generation failed');
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Token generation failed']);
|
||||
}
|
||||
|
||||
$token = $tokenResponse['data']['result'][0]['access_token'];
|
||||
|
||||
$url = getenv('HEALTH_INDIA_BASE_URL') . "/ClaimsMIS/GetClaimsMIS";
|
||||
|
||||
$headers = [
|
||||
"Authorization: Bearer " . $token,
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
$policies = $this->db->table('client_policy')
|
||||
->where('tpa_id', $this->healthIndiaTpaId)
|
||||
->get()->getResultArray();
|
||||
|
||||
$finalResult = [];
|
||||
|
||||
foreach ($policies as $policy) {
|
||||
$body = [
|
||||
"policY_NUMBER" => $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', 'HEALTH_INDIA - Sync TPA Claims | Fetched ' . count($response['data']['result']) . ' claims for policy: ' . $policy['policy_no']);
|
||||
}
|
||||
}
|
||||
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims | Total claims fetched: ' . count($finalResult));
|
||||
|
||||
$insertedCount = 0;
|
||||
|
||||
foreach ($finalResult as $row) {
|
||||
$status = $row['Claim_Status'] ?? 'Under Process';
|
||||
|
||||
$map = [
|
||||
"Under Process" => 5,
|
||||
"Pending for Bill Entry" => 5,
|
||||
"Paid" => 11,
|
||||
"Rejected" => 8,
|
||||
"Approved" => 8,
|
||||
"Outstanding" => 5,
|
||||
];
|
||||
|
||||
$claimStatus = $map[$status] ?? 1;
|
||||
|
||||
// Check if claim already exists
|
||||
$existing = $this->db->table('ticket_master')
|
||||
->where('tpa_claim_id', $row['CLAIM_NUMBER'])
|
||||
->get()->getRowArray();
|
||||
|
||||
if ($existing) {
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims | Skipped existing claim: ' . ($row['CLAIM_NUMBER'] ?? 'N/A'));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Derive relationship (default to self)
|
||||
$relationship = 'self';
|
||||
$rawRelation = $row['RELATION_NAME'] ?? null;
|
||||
if (!empty($rawRelation)) {
|
||||
if ($rawRelation === 'Employee') {
|
||||
$relationship = 'self';
|
||||
} elseif (strtoupper($rawRelation) === 'WIFE') {
|
||||
$relationship = 'spouse';
|
||||
} else {
|
||||
$relationship = strtolower($rawRelation);
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch client policy details
|
||||
$clientpolicy = $this->db->table('client_policy cp')
|
||||
->select("
|
||||
cp.id as client_policy_id,
|
||||
cp.client_id,
|
||||
cp.insurer_id,
|
||||
cp.tpa_id,
|
||||
client_rm.id as acm_id
|
||||
")
|
||||
->join('client_rm', 'client_rm.client_id = cp.client_id AND client_rm.level = 3', 'left')
|
||||
->where('cp.policy_no', $row['Policy_No'] ?? null)
|
||||
->orderBy('client_rm.id', 'DESC')
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if (!$clientpolicy) {
|
||||
log_message(
|
||||
'error',
|
||||
'HEALTH_INDIA - Sync TPA Claims | Client policy not found for policy_no: ' . ($row['Policy_No'] ?? 'N/A')
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Fetch employee / insured details
|
||||
$employee = $this->db->table('employees e')
|
||||
->select("
|
||||
e.id as emp_id,
|
||||
e.emp_code,
|
||||
e.name as emp_name,
|
||||
e2.id as insured_emp_id,
|
||||
e2.name as insured_emp_name,
|
||||
ep.tpa_id as tpa_no,
|
||||
e.mobile as emp_mobile,
|
||||
e.email_corporate as emp_mail
|
||||
")
|
||||
->join(
|
||||
'employees e2',
|
||||
"e2.emp_code = e.emp_code AND e2.relationship = " . $this->db->escape($relationship),
|
||||
'left'
|
||||
)
|
||||
->join('employee_polices ep', "ep.employee_id = e2.id ", 'left')
|
||||
->where('e.emp_code', $row['Employee_Code'] ?? null)
|
||||
->where('e.client_id', $clientpolicy['client_id'] ?? null)
|
||||
->where('e.relationship', 'self')
|
||||
->where('e.is_active', 1)
|
||||
->where('e2.is_active', 1)
|
||||
->where('ep.is_active', 1)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if (!$employee) {
|
||||
log_message(
|
||||
'error',
|
||||
'HEALTH_INDIA - Sync TPA Claims | Employee data not found for emp_code: ' . ($row['Employee_Code'] ?? 'N/A') .
|
||||
' | policy_no: ' . ($row['Policy_No'] ?? 'N/A') .
|
||||
' | relationship: ' . $relationship
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
$claimData = [
|
||||
// Core
|
||||
'ticket_type_id' => 1,
|
||||
'claim_status_id' => $claimStatus,
|
||||
'policy_no' => $row['Policy_No'] ?? null,
|
||||
'claim_number' => $row['CLAIM_NUMBER'] ?? null,
|
||||
'tpa_claim_id' => $row['CLAIM_NUMBER'] ?? null,
|
||||
|
||||
// Local primary/foreign keys
|
||||
'tpa_id' => $clientpolicy['tpa_id'] ?? $this->healthIndiaTpaId,
|
||||
'insurer_id' => $clientpolicy['insurer_id'] ?? null,
|
||||
'client_policy_id' => $clientpolicy['client_policy_id'] ?? null,
|
||||
'client_id' => $clientpolicy['client_id'] ?? null,
|
||||
'acm_id' => $clientpolicy['acm_id'] ?? null,
|
||||
|
||||
// Employee / Insured
|
||||
'emp_id' => $employee['emp_id'] ?? null,
|
||||
'insured_emp_id' => $employee['insured_emp_id'] ?? null,
|
||||
'tpa_no' => $employee['tpa_no'] ?? null,
|
||||
'emp_code' => $row['Employee_Code'] ?? null,
|
||||
'emp_name' => $employee['emp_name'] ?? null,
|
||||
'insured_name' => $employee['insured_emp_name'] ?? ($row['PATIENT_NAME'] ?? null),
|
||||
'relationship' => $relationship,
|
||||
'emp_mobile' => $employee['emp_mobile'] ?? null,
|
||||
'emp_mail' => $employee['emp_mail'] ?? null,
|
||||
|
||||
// Claim info
|
||||
'claim_type' => 1,
|
||||
'mode_of_intimation' => 5,
|
||||
'claim_amount' => $row['INTIMATED_AMOUNT'] ?? 0,
|
||||
|
||||
// Dates
|
||||
'doa' => !empty($row['DATEOF_ADMISSION']) ? date('Y-m-d', strtotime($row['DATEOF_ADMISSION'])) : null,
|
||||
'dod' => !empty($row['DATEOF_DISCHARGE']) ? date('Y-m-d', strtotime($row['DATEOF_DISCHARGE'])) : null,
|
||||
|
||||
// Hospital
|
||||
'hospital_name' => $row['HOSPITAL_NAME'] ?? null,
|
||||
'hospital_address' => $row['Hospital_address'] ?? null,
|
||||
'hospital_pincode' => $row['HOSPITAL_Pincode'] ?? null,
|
||||
'hospital_state' => $row['HOSPITAL_STATE'] ?? null,
|
||||
'hospital_city' => $row['HOSPITAL_CITY'] ?? null,
|
||||
|
||||
// TPA extras
|
||||
'tpa_claim_status' => $status,
|
||||
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
$this->db->table('ticket_master')->insert($claimData);
|
||||
$insertedCount++;
|
||||
|
||||
log_message(
|
||||
'error',
|
||||
'HEALTH_INDIA - Sync TPA Claims | Inserted claim: ' . ($row['CLAIM_NUMBER'] ?? 'N/A')
|
||||
);
|
||||
}
|
||||
|
||||
log_message('error', 'HEALTH_INDIA - Sync TPA Claims | Completed | Total: ' . count($finalResult) . ' | Inserted: ' . $insertedCount);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => true,
|
||||
'total' => count($finalResult),
|
||||
'inserted' => $insertedCount
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveHealthIndiaAPIData($array)
|
||||
{
|
||||
$file_id = $array['file_id'];
|
||||
|
||||
@ -121,10 +121,10 @@ class ICICILombardController extends AdminController
|
||||
$body = [
|
||||
"PolicyNumber" => "4016/PPN/A/O/53185987/00/000",
|
||||
"CDBGAccountNumber" => "CD-MUM-0026",
|
||||
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440022",
|
||||
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440023",
|
||||
"MemberDetails" => [
|
||||
[
|
||||
"MemberEmpId" => "EMPID3625565",
|
||||
"MemberEmpId" => "EMPID3625566",
|
||||
"DOJ" => "21-MAR-2019",
|
||||
"InsuredName" => "sanjeev",
|
||||
"DOB" => "7-JUL-1993",
|
||||
@ -136,7 +136,7 @@ class ICICILombardController extends AdminController
|
||||
"FlagStatus" => "A"
|
||||
],
|
||||
[
|
||||
"MemberEmpId" => "EMPID3625565",
|
||||
"MemberEmpId" => "EMPID3625566",
|
||||
"DOJ" => "21-MAR-2019",
|
||||
"InsuredName" => "bhavya",
|
||||
"DOB" => "8-AUG-1970",
|
||||
@ -195,6 +195,7 @@ class ICICILombardController extends AdminController
|
||||
|
||||
//fetch token
|
||||
$tokenResponse = $this->generateAuthToken('esbgpauhid');
|
||||
// dd($tokenResponse);
|
||||
if (!$tokenResponse || empty($tokenResponse['data']['access_token'])) {
|
||||
return $this->response->setJSON([
|
||||
'status' => false,
|
||||
@ -213,13 +214,15 @@ class ICICILombardController extends AdminController
|
||||
];
|
||||
|
||||
$body = [
|
||||
"PolicyNumber" => "4016/PPN/A/O/53185987/00/000",
|
||||
"PolicyNumber" => "4016/PPN/A/O/53185987/00/001",
|
||||
"IMID" => "201580517901",
|
||||
"CorrelationId" => "550e8400-e29b-41d4-a716-446655440022"
|
||||
];
|
||||
|
||||
$response = call_third_party_api($url, 'POST', $headers, $body, true);
|
||||
|
||||
// dd($response);
|
||||
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -141,7 +141,7 @@ class MediAssistApiController extends BaseController
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_push_response' => json_encode($response) ]);
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED', 'response' => $response];
|
||||
}
|
||||
|
||||
// return $this->response->setJSON($response);
|
||||
@ -156,11 +156,11 @@ class MediAssistApiController extends BaseController
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_claim_push_reference_no' => $claimRef ]);
|
||||
|
||||
return;
|
||||
return ['status' => true, 'message' => 'Claim Push SUCCESS', 'response' => $response];
|
||||
|
||||
} else {
|
||||
log_message('error','MEDI_ASSIST - Claim Push API Failed | claimReferenceNo EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push API Failed', 'response' => $response];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -317,8 +317,8 @@ class PolicyTransactionController extends BaseController
|
||||
'col_cell_name' => 'Q',
|
||||
'col_name' => 'Base Premium',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => '',
|
||||
'format' => null,
|
||||
'data_type' => 'positive_number',
|
||||
'format' => 'positive_number',
|
||||
'allowed_values' => null,
|
||||
'custom' => null,
|
||||
'params' => null
|
||||
@ -329,8 +329,8 @@ class PolicyTransactionController extends BaseController
|
||||
'col_cell_name' => 'R',
|
||||
'col_name' => 'Non commission permium Amount',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => '',
|
||||
'format' => null,
|
||||
'data_type' => 'positive_number',
|
||||
'format' => 'positive_number',
|
||||
'allowed_values' => null,
|
||||
'custom' => null,
|
||||
'params' => null
|
||||
@ -341,8 +341,8 @@ class PolicyTransactionController extends BaseController
|
||||
'col_cell_name' => 'S',
|
||||
'col_name' => 'TP Premium',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => '',
|
||||
'format' => null,
|
||||
'data_type' => 'positive_number',
|
||||
'format' => 'positive_number',
|
||||
'allowed_values' => null,
|
||||
'custom' => null,
|
||||
'params' => null
|
||||
@ -353,8 +353,8 @@ class PolicyTransactionController extends BaseController
|
||||
'col_cell_name' => 'T',
|
||||
'col_name' => 'IGST',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => '',
|
||||
'format' => null,
|
||||
'data_type' => 'positive_number',
|
||||
'format' => 'positive_number',
|
||||
'allowed_values' => null,
|
||||
'custom' => 'check_gst_percentage',
|
||||
'params' => ['row']
|
||||
@ -365,8 +365,8 @@ class PolicyTransactionController extends BaseController
|
||||
'col_cell_name' => 'U',
|
||||
'col_name' => 'CGST',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => '',
|
||||
'format' => null,
|
||||
'data_type' => 'positive_number',
|
||||
'format' => 'positive_number',
|
||||
'allowed_values' => null,
|
||||
'custom' => 'check_gst_percentage',
|
||||
'params' => ['row']
|
||||
@ -377,8 +377,8 @@ class PolicyTransactionController extends BaseController
|
||||
'col_cell_name' => 'V',
|
||||
'col_name' => 'SGST',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => '',
|
||||
'format' => null,
|
||||
'data_type' => 'positive_number',
|
||||
'format' => 'positive_number',
|
||||
'allowed_values' => null,
|
||||
'custom' => 'check_gst_percentage',
|
||||
'params' => ['row']
|
||||
@ -390,8 +390,8 @@ class PolicyTransactionController extends BaseController
|
||||
'col_cell_name' => 'W',
|
||||
'col_name' => 'Stamp Duty',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => '',
|
||||
'format' => null,
|
||||
'data_type' => 'positive_number',
|
||||
'format' => 'positive_number',
|
||||
'allowed_values' => null,
|
||||
'custom' => null,
|
||||
'params' => null
|
||||
@ -414,8 +414,8 @@ class PolicyTransactionController extends BaseController
|
||||
'col_cell_name' => 'X',
|
||||
'col_name' => 'Agreed Amount',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => '',
|
||||
'format' => null,
|
||||
'data_type' => 'positive_number',
|
||||
'format' => 'positive_number',
|
||||
'allowed_values' => null,
|
||||
'custom' => null,
|
||||
'params' => null
|
||||
@ -426,8 +426,8 @@ class PolicyTransactionController extends BaseController
|
||||
'col_cell_name' => 'Y',
|
||||
'col_name' => 'Agreed BP Percentage',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => '',
|
||||
'format' => null,
|
||||
'data_type' => 'positive_number',
|
||||
'format' => 'positive_number',
|
||||
'allowed_values' => null,
|
||||
'custom' => null,
|
||||
'params' => null
|
||||
@ -438,8 +438,8 @@ class PolicyTransactionController extends BaseController
|
||||
'col_cell_name' => 'Z',
|
||||
'col_name' => 'Agreed TP Percentage',
|
||||
'is_mandatory' => false,
|
||||
'data_type' => '',
|
||||
'format' => null,
|
||||
'data_type' => 'positive_number',
|
||||
'format' => 'positive_number',
|
||||
'allowed_values' => null,
|
||||
'custom' => null,
|
||||
'params' => null
|
||||
|
||||
@ -959,6 +959,8 @@ class TicketController extends BaseController
|
||||
// Redirect or show a 404 to prevent "Undefined array key" errors
|
||||
return redirect()->to(base_url('ticket/list'))->with('error', 'Ticket not found');
|
||||
}
|
||||
|
||||
$ticket_data['is_tpa_api_service_enabled'] = $this->ticketMasterModel->isTpaApiServiceEnabled($ticket_id);
|
||||
|
||||
$ticket_data = $this->formatDateForClaim($ticket_data, 'd/m/Y');
|
||||
|
||||
|
||||
@ -164,7 +164,7 @@ class VidalApiController extends BaseController
|
||||
|
||||
if (count($data) && $data['filePath'] == null) {
|
||||
log_message('error', "VIDAL - Claim Push | Submit claim failed - Claim or File Missing");
|
||||
return $this->response->setJSON(['status' => false,'message' => 'Claim or File Missing', ]);
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | Claim or File Missing'];
|
||||
}
|
||||
|
||||
$filePath = $data['filePath'] ?? '';
|
||||
@ -271,7 +271,7 @@ class VidalApiController extends BaseController
|
||||
$this->db->table('ticket_master')
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_push_response' => json_encode($response) ]);
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push FAILED | API call failed'];
|
||||
}
|
||||
|
||||
// return $this->response->setJSON($response);
|
||||
@ -289,16 +289,17 @@ class VidalApiController extends BaseController
|
||||
->where('id',$claimId)
|
||||
->update([ 'tpa_claim_push_reference_no' => $claimInwardNO , 'tpa_claim_id' => $claimNO , 'claim_number' => $claimNO ]);
|
||||
|
||||
return;
|
||||
return ['status' => true, 'message' => 'Claim Push SUCCESS'];
|
||||
|
||||
} else {
|
||||
log_message('error', 'VIDAL - Claim Push API SUCCESS BUT claimNO,claimInwardNO EMPTY | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push API SUCCESS BUT claimNO,claimInwardNO EMPTY'];
|
||||
}
|
||||
}else{
|
||||
log_message('error', 'VIDAL - Claim Push API FAILED | claimId: '.$claimId.' | response: '.json_encode($response));
|
||||
return;
|
||||
return ['status' => false, 'message' => 'Claim Push API FAILED'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getWellnessSSORedirectUrl($email = 'test@getvisitapp.com')
|
||||
|
||||
@ -3023,6 +3023,9 @@ if (!function_exists('validate_excel_value')) {
|
||||
case 'vehicle':
|
||||
return validate_indian_vehicle_number($value);
|
||||
|
||||
case 'positive_number':
|
||||
return validate_positive_number_value($value);
|
||||
|
||||
default:
|
||||
return [
|
||||
'status' => true,
|
||||
@ -3066,6 +3069,24 @@ if (!function_exists('validate_mobile_value')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('validate_positive_number_value')) {
|
||||
function validate_positive_number_value($value)
|
||||
{
|
||||
if ($value === "" || $value === null) {
|
||||
return ['status' => true, 'error' => null];
|
||||
}
|
||||
|
||||
if (is_numeric($value) && $value >= 0) {
|
||||
return ['status' => true, 'error' => null];
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => false,
|
||||
'error' => "Value must be a positive number"
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('validate_email_value')) {
|
||||
function validate_email_value($value)
|
||||
{
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
<?php namespace App\Libraries;
|
||||
<?php
|
||||
namespace App\Libraries;
|
||||
|
||||
use Google_Client;
|
||||
use Google_Service_Sheets;
|
||||
use Google_Service_Drive;
|
||||
use Google_Service_Sheets_ValueRange;
|
||||
use Google_Service_Sheets;
|
||||
use Google_Service_Sheets_BatchUpdateSpreadsheetRequest;
|
||||
use Google_Service_Sheets_ValueRange;
|
||||
|
||||
class GoogleSheetLib
|
||||
{
|
||||
@ -12,7 +13,6 @@ class GoogleSheetLib
|
||||
protected Google_Service_Sheets $sheets;
|
||||
protected Google_Service_Drive $drive;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = new Google_Client();
|
||||
@ -28,7 +28,7 @@ class GoogleSheetLib
|
||||
// Required scopes
|
||||
$this->client->addScope([
|
||||
Google_Service_Drive::DRIVE,
|
||||
Google_Service_Sheets::SPREADSHEETS
|
||||
Google_Service_Sheets::SPREADSHEETS,
|
||||
]);
|
||||
|
||||
// Init services
|
||||
@ -53,7 +53,7 @@ class GoogleSheetLib
|
||||
public function write(string $spreadsheetId, array $values, string $range = 'Sheet1')
|
||||
{
|
||||
$body = new Google_Service_Sheets_ValueRange([
|
||||
'values' => $values
|
||||
'values' => $values,
|
||||
]);
|
||||
|
||||
$this->sheets
|
||||
@ -81,7 +81,6 @@ class GoogleSheetLib
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
|
||||
/* ================= COPY TEMPLATE ================= */
|
||||
|
||||
public function copyTemplate(string $templateId, string $name, string $folderId): string
|
||||
@ -92,10 +91,10 @@ class GoogleSheetLib
|
||||
'name' => $name,
|
||||
'parents' => [$folderId],
|
||||
|
||||
]),[
|
||||
'supportsAllDrives' => true,
|
||||
'fields' => 'id, name, parents'
|
||||
]
|
||||
]), [
|
||||
'supportsAllDrives' => true,
|
||||
'fields' => 'id, name, parents',
|
||||
]
|
||||
);
|
||||
|
||||
return $file->id;
|
||||
@ -116,7 +115,7 @@ class GoogleSheetLib
|
||||
|
||||
private function createPermission(string $fileId, string $email, string $role)
|
||||
{
|
||||
$type = str_starts_with($email, 'group:') ? 'group' : 'user';
|
||||
$type = str_starts_with($email, 'group:') ? 'group' : 'user';
|
||||
$email = str_replace('group:', '', $email);
|
||||
|
||||
$this->drive->permissions->create(
|
||||
@ -124,9 +123,9 @@ class GoogleSheetLib
|
||||
new \Google_Service_Drive_Permission([
|
||||
'type' => $type,
|
||||
'role' => $role,
|
||||
'emailAddress' => $email
|
||||
'emailAddress' => $email,
|
||||
]),
|
||||
['sendNotificationEmail' => false,'supportsAllDrives' => true]
|
||||
['sendNotificationEmail' => false, 'supportsAllDrives' => true]
|
||||
);
|
||||
}
|
||||
|
||||
@ -135,7 +134,7 @@ class GoogleSheetLib
|
||||
public function applyProtectionsold(string $spreadsheetId, array $ranges)
|
||||
{
|
||||
$spreadsheet = $this->sheets->spreadsheets->get($spreadsheetId);
|
||||
$sheetId = $spreadsheet->getSheets()[0]->getProperties()->getSheetId();
|
||||
$sheetId = $spreadsheet->getSheets()[0]->getProperties()->getSheetId();
|
||||
|
||||
$requests = [];
|
||||
|
||||
@ -145,96 +144,95 @@ class GoogleSheetLib
|
||||
$requests[] = [
|
||||
'addProtectedRange' => [
|
||||
'protectedRange' => [
|
||||
'range' => [
|
||||
'sheetId' => $sheetId
|
||||
'range' => [
|
||||
'sheetId' => $sheetId,
|
||||
],
|
||||
'warningOnly' => false
|
||||
]
|
||||
]
|
||||
'warningOnly' => false,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$this->sheets->spreadsheets->batchUpdate(
|
||||
$spreadsheetId,
|
||||
new Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
|
||||
'requests' => $requests
|
||||
'requests' => $requests,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function applyProtections(string $spreadsheetId, array $protections)
|
||||
{
|
||||
// Fetch spreadsheet metadata
|
||||
$spreadsheet = $this->sheets->spreadsheets->get(
|
||||
$spreadsheetId,
|
||||
['fields' => 'sheets(properties(sheetId,title,gridProperties))']
|
||||
);
|
||||
|
||||
// Map sheet names
|
||||
$sheetMap = [];
|
||||
foreach ($spreadsheet->getSheets() as $sheet) {
|
||||
$props = $sheet->getProperties();
|
||||
$sheetMap[$props->getTitle()] = [
|
||||
'sheetId' => $props->getSheetId(),
|
||||
'rowCount' => $props->getGridProperties()->getRowCount(),
|
||||
'colCount' => $props->getGridProperties()->getColumnCount(),
|
||||
];
|
||||
}
|
||||
|
||||
$requests = [];
|
||||
|
||||
foreach ($protections as $protection) {
|
||||
|
||||
$rangeStr = $protection['range'];
|
||||
|
||||
if (!str_contains($rangeStr, '!')) {
|
||||
throw new \Exception("Invalid range format: {$rangeStr}");
|
||||
}
|
||||
|
||||
[$sheetName, $a1] = explode('!', $rangeStr, 2);
|
||||
|
||||
if (!isset($sheetMap[$sheetName])) {
|
||||
throw new \Exception("Sheet not found: {$sheetName}");
|
||||
}
|
||||
|
||||
$sheetMeta = $sheetMap[$sheetName];
|
||||
|
||||
$gridRange = $this->convertA1ToGridRange(
|
||||
$a1,
|
||||
$sheetMeta['sheetId'],
|
||||
$sheetMeta['rowCount'],
|
||||
$sheetMeta['colCount']
|
||||
{
|
||||
// Fetch spreadsheet metadata
|
||||
$spreadsheet = $this->sheets->spreadsheets->get(
|
||||
$spreadsheetId,
|
||||
['fields' => 'sheets(properties(sheetId,title,gridProperties))']
|
||||
);
|
||||
|
||||
$protectedRange = [
|
||||
'range' => $gridRange,
|
||||
'description' => 'RFQ Protected Area',
|
||||
'warningOnly' => false,
|
||||
'editors' => [
|
||||
'users' => $protection['users'] ?? [],
|
||||
'groups' => $protection['groups'] ?? []
|
||||
]
|
||||
];
|
||||
// Map sheet names
|
||||
$sheetMap = [];
|
||||
foreach ($spreadsheet->getSheets() as $sheet) {
|
||||
$props = $sheet->getProperties();
|
||||
$sheetMap[$props->getTitle()] = [
|
||||
'sheetId' => $props->getSheetId(),
|
||||
'rowCount' => $props->getGridProperties()->getRowCount(),
|
||||
'colCount' => $props->getGridProperties()->getColumnCount(),
|
||||
];
|
||||
}
|
||||
|
||||
$requests[] = [
|
||||
'addProtectedRange' => [
|
||||
'protectedRange' => $protectedRange
|
||||
]
|
||||
];
|
||||
$requests = [];
|
||||
|
||||
foreach ($protections as $protection) {
|
||||
|
||||
$rangeStr = $protection['range'];
|
||||
|
||||
if (! str_contains($rangeStr, '!')) {
|
||||
throw new \Exception("Invalid range format: {$rangeStr}");
|
||||
}
|
||||
|
||||
[$sheetName, $a1] = explode('!', $rangeStr, 2);
|
||||
|
||||
if (! isset($sheetMap[$sheetName])) {
|
||||
throw new \Exception("Sheet not found: {$sheetName}");
|
||||
}
|
||||
|
||||
$sheetMeta = $sheetMap[$sheetName];
|
||||
|
||||
$gridRange = $this->convertA1ToGridRange(
|
||||
$a1,
|
||||
$sheetMeta['sheetId'],
|
||||
$sheetMeta['rowCount'],
|
||||
$sheetMeta['colCount']
|
||||
);
|
||||
|
||||
$protectedRange = [
|
||||
'range' => $gridRange,
|
||||
'description' => 'RFQ Protected Area',
|
||||
'warningOnly' => false,
|
||||
'editors' => [
|
||||
'users' => $protection['users'] ?? [],
|
||||
'groups' => $protection['groups'] ?? [],
|
||||
],
|
||||
];
|
||||
|
||||
$requests[] = [
|
||||
'addProtectedRange' => [
|
||||
'protectedRange' => $protectedRange,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
if (! empty($requests)) {
|
||||
$batch = new \Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
|
||||
'requests' => $requests,
|
||||
]);
|
||||
|
||||
$this->sheets->spreadsheets->batchUpdate($spreadsheetId, $batch);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!empty($requests)) {
|
||||
$batch = new \Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
|
||||
'requests' => $requests
|
||||
]);
|
||||
|
||||
$this->sheets->spreadsheets->batchUpdate($spreadsheetId, $batch);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ================= URL ================= */
|
||||
|
||||
public function sheetUrl(string $sheetId): string
|
||||
@ -242,43 +240,41 @@ class GoogleSheetLib
|
||||
return "https://docs.google.com/spreadsheets/d/{$sheetId}/edit";
|
||||
}
|
||||
|
||||
private function convertA1ToGridRange($a1, $sheetId, $maxRows, $maxCols)
|
||||
{
|
||||
if (preg_match('/^([A-Z]+)(\d+)(?::([A-Z]+)(\d+))?$/i', $a1, $m)) {
|
||||
|
||||
private function convertA1ToGridRange($a1, $sheetId, $maxRows, $maxCols)
|
||||
{
|
||||
if (preg_match('/^([A-Z]+)(\d+)(?::([A-Z]+)(\d+))?$/i', $a1, $m)) {
|
||||
$startCol = $this->colToIndex($m[1]);
|
||||
$startRow = intval($m[2]) - 1;
|
||||
|
||||
$startCol = $this->colToIndex($m[1]);
|
||||
$startRow = intval($m[2]) - 1;
|
||||
if (! empty($m[3])) {
|
||||
$endCol = $this->colToIndex($m[3]) + 1;
|
||||
$endRow = intval($m[4]);
|
||||
} else {
|
||||
$endCol = $startCol + 1;
|
||||
$endRow = $startRow + 1;
|
||||
}
|
||||
|
||||
if (!empty($m[3])) {
|
||||
$endCol = $this->colToIndex($m[3]) + 1;
|
||||
$endRow = intval($m[4]);
|
||||
} else {
|
||||
$endCol = $startCol + 1;
|
||||
$endRow = $startRow + 1;
|
||||
return [
|
||||
'sheetId' => $sheetId,
|
||||
'startRowIndex' => $startRow,
|
||||
'endRowIndex' => $endRow,
|
||||
'startColumnIndex' => $startCol,
|
||||
'endColumnIndex' => $endCol,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'sheetId' => $sheetId,
|
||||
'startRowIndex' => $startRow,
|
||||
'endRowIndex' => $endRow,
|
||||
'startColumnIndex' => $startCol,
|
||||
'endColumnIndex' => $endCol
|
||||
];
|
||||
throw new \Exception("Unsupported A1 format: {$a1}");
|
||||
}
|
||||
|
||||
throw new \Exception("Unsupported A1 format: {$a1}");
|
||||
}
|
||||
|
||||
private function colToIndex($letters)
|
||||
{
|
||||
$letters = strtoupper($letters);
|
||||
$index = 0;
|
||||
for ($i = 0; $i < strlen($letters); $i++) {
|
||||
$index = $index * 26 + (ord($letters[$i]) - 64);
|
||||
private function colToIndex($letters)
|
||||
{
|
||||
$letters = strtoupper($letters);
|
||||
$index = 0;
|
||||
for ($i = 0; $i < strlen($letters); $i++) {
|
||||
$index = $index * 26 + (ord($letters[$i]) - 64);
|
||||
}
|
||||
return $index - 1;
|
||||
}
|
||||
return $index - 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class LeadsModel extends Model
|
||||
{
|
||||
protected $table = 'leads';
|
||||
protected $primaryKey = 'id';
|
||||
protected $table = 'leads';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'actual_lead_id',
|
||||
@ -100,7 +99,7 @@ class LeadsModel extends Model
|
||||
'no_of_installment',
|
||||
'is_policy_created',
|
||||
'claim_history',
|
||||
|
||||
|
||||
'total_lives_at_incept',
|
||||
'premium_at_incept',
|
||||
|
||||
@ -109,20 +108,19 @@ class LeadsModel extends Model
|
||||
'quote_received_insurer',
|
||||
'acm_id',
|
||||
'policy_with_correction',
|
||||
'agreed_percentage',
|
||||
'agreed_percentage', 'misc',
|
||||
];
|
||||
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
@ -161,7 +159,7 @@ class LeadsModel extends Model
|
||||
FROM rfq
|
||||
WHERE type = 2
|
||||
AND is_active = 1 and lead_id = leads.id
|
||||
) AS qcr_count,
|
||||
) AS qcr_count,
|
||||
|
||||
(
|
||||
SELECT COUNT(*) AS rfq_count
|
||||
@ -177,7 +175,7 @@ class LeadsModel extends Model
|
||||
->join('lead_files', 'leads.id = lead_files.lead_id AND lead_files.type = 2 AND lead_files.is_active = 1', 'left')
|
||||
->where('leads.is_active', 1);
|
||||
|
||||
if (!empty($where)) {
|
||||
if (! empty($where)) {
|
||||
$data->where($where);
|
||||
}
|
||||
|
||||
@ -186,7 +184,7 @@ class LeadsModel extends Model
|
||||
|
||||
public function getLeadForInsertClientList($type = null, $client_id = null)
|
||||
{
|
||||
$query = $this->db->table('leads')
|
||||
$query = $this->db->table('leads')
|
||||
->select('leads.*, user_profiles.first_name as user_name')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id')
|
||||
->where('leads.is_active', 1)
|
||||
@ -195,8 +193,6 @@ class LeadsModel extends Model
|
||||
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)")
|
||||
->where("(leads.is_policy_created = '' OR leads.is_policy_created IS NULL)");
|
||||
|
||||
|
||||
|
||||
if ($type) {
|
||||
$query->where('leads.lead_type', $type);
|
||||
}
|
||||
@ -243,8 +239,8 @@ class LeadsModel extends Model
|
||||
// $builder->select($select);
|
||||
|
||||
// // Auditing subquery
|
||||
// $subquery = "(SELECT pk, MAX(created_at) AS last_claim_status_change
|
||||
// FROM auditing_history
|
||||
// $subquery = "(SELECT pk, MAX(created_at) AS last_claim_status_change
|
||||
// FROM auditing_history
|
||||
// WHERE table_name = 'leads' AND field_name = 'status'
|
||||
// GROUP BY pk)";
|
||||
|
||||
@ -282,7 +278,7 @@ class LeadsModel extends Model
|
||||
// // if (!str_ends_with($key, '_ids') && $key != "won") {
|
||||
// // $total += (int) $value;
|
||||
// // }
|
||||
|
||||
|
||||
// if (!str_ends_with($key, '_ids')) {
|
||||
// $total += (int) $value;
|
||||
// }
|
||||
@ -292,12 +288,10 @@ class LeadsModel extends Model
|
||||
// $lead_data[0]['total'] = $total;
|
||||
// $lead_data[0]['policy_with_correction'] = $policy_with_correction_count;
|
||||
|
||||
|
||||
// // dd($lead_data[0]);
|
||||
// return $lead_data[0];
|
||||
// }
|
||||
|
||||
|
||||
public function getDashData()
|
||||
{
|
||||
// Get all unique statuses
|
||||
@ -322,7 +316,7 @@ class LeadsModel extends Model
|
||||
$selectParts = [];
|
||||
foreach ($statuses as $row) {
|
||||
$status = $row['status'];
|
||||
$alias = strtolower(str_replace(' ', '_', $status));
|
||||
$alias = strtolower(str_replace(' ', '_', $status));
|
||||
|
||||
$selectParts[] = "SUM(CASE WHEN status = '{$status}' THEN 1 ELSE 0 END) AS `{$alias}`";
|
||||
$selectParts[] = "GROUP_CONCAT(CASE WHEN status = '{$status}' THEN id END) AS `{$alias}_ids`";
|
||||
@ -340,19 +334,17 @@ class LeadsModel extends Model
|
||||
// Calculate total
|
||||
$total = 0;
|
||||
foreach ($lead_data as $key => $val) {
|
||||
if (!str_ends_with($key, '_ids')) {
|
||||
if (! str_ends_with($key, '_ids')) {
|
||||
$total += (int) $val;
|
||||
}
|
||||
}
|
||||
|
||||
$lead_data['total'] = $total;
|
||||
$lead_data['policy_with_correction'] = $policy_with_correction_data['count'] ?? 0;
|
||||
$lead_data['total'] = $total;
|
||||
$lead_data['policy_with_correction'] = $policy_with_correction_data['count'] ?? 0;
|
||||
$lead_data['policy_with_correction_ids'] = $policy_with_correction_data['ids'] ?? null;
|
||||
|
||||
// dd($lead_data);
|
||||
return $lead_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class PolicyTypeModel extends Model
|
||||
{
|
||||
protected $table = 'policy_type';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
protected $table = 'policy_type';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
"id",
|
||||
"policy_type",
|
||||
"bap",
|
||||
@ -22,6 +21,6 @@ class PolicyTypeModel extends Model
|
||||
"etp",
|
||||
"iep",
|
||||
"itp",
|
||||
"question_json",'itep','etep', 'policy_category',
|
||||
"question_json", 'itep', 'etep', 'policy_category', 'misc',
|
||||
];
|
||||
}
|
||||
|
||||
@ -1218,6 +1218,21 @@ class TicketMasterModel extends Model
|
||||
|
||||
}
|
||||
|
||||
public function isTpaApiServiceEnabled($ticket_id)
|
||||
{
|
||||
$result = $this->db->table('ticket_master tm')
|
||||
->select('tas.*')
|
||||
->join('client_policy cp', 'tm.client_policy_id = cp.id')
|
||||
->join('tpa_api_services tas', 'cp.tpa_id = tas.tpa_id')
|
||||
->where('tm.id', $ticket_id)
|
||||
->where('tm.is_active', 1)
|
||||
->where('cp.is_active', 1)
|
||||
->where('tas.is_active', 1)
|
||||
->get()->getRowArray();
|
||||
|
||||
return count($result ?? []) > 0 ? true : false; // true if any API service is enabled, false if no API service is enabled
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------
|
||||
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>Google Sheet Editor</h3>
|
||||
<h3>Edit RFQ </h3>
|
||||
|
||||
<button onclick="save()">💾 Save</button>
|
||||
<button onclick="download()">⬇ Download</button>
|
||||
@ -44,9 +44,9 @@ function createRfq() {
|
||||
<table id="sheet"></table>
|
||||
|
||||
<script>
|
||||
alert('first');
|
||||
// alert('first');
|
||||
const sheetId = "<?= esc($sheetId) ?>";
|
||||
alert('second');
|
||||
// alert('second');
|
||||
/* ---------- LOAD ---------- */
|
||||
fetch('<?php echo base_url() ?>' + `sheet/${sheetId}/fetch`)
|
||||
.then(r => r.json())
|
||||
@ -54,7 +54,7 @@ fetch('<?php echo base_url() ?>' + `sheet/${sheetId}/fetch`)
|
||||
.then(render);
|
||||
|
||||
function render(data) {
|
||||
alert('data');
|
||||
// alert('data');
|
||||
console.log('data');
|
||||
console.log(data);
|
||||
const table = document.getElementById('sheet');
|
||||
|
||||
@ -121,7 +121,7 @@
|
||||
|
||||
<!-- Sweet Alert CDN -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap-multiselect@1.1.0/dist/js/bootstrap-multiselect.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-multiselect/0.9.13/css/bootstrap-multiselect.css" />
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js"></script>
|
||||
@ -146,7 +146,7 @@
|
||||
|
||||
|
||||
<script src="https://cdn.datatables.net/plug-ins/2.0.8/sorting/scientific.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.8.0/jszip.min.js"></script>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -51,6 +51,17 @@
|
||||
|
||||
<div class="col-auto d-flex align-items-center">
|
||||
|
||||
|
||||
<?php if (
|
||||
$ticket_data['is_tpa_api_service_enabled'] == true &&
|
||||
empty($ticket_data['tpa_claim_push_reference_no']) &&
|
||||
empty($ticket_data['claim_number'])
|
||||
) : ?>
|
||||
<a href="#" class="btn btn-success mr-2" onclick="manualTpaClaimPush(); return false;">
|
||||
Manual TPA Claim Push
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(isset($ticket_data['tpa_claim_push_reference_no']) && !empty($ticket_data['tpa_claim_push_reference_no'])) : ?>
|
||||
<a href="#" class="btn btn-success mr-2" onclick="fetchTpaClaimStatus()">
|
||||
Fetch Claim Status
|
||||
@ -390,6 +401,57 @@
|
||||
});
|
||||
}
|
||||
|
||||
function manualTpaClaimPush() {
|
||||
let ticket_master_id = $('#ticket_master_id').val();
|
||||
if (!ticket_master_id) {
|
||||
toastr.warning('Claim ID not found. Please ensure the form is loaded.', 'Warning');
|
||||
return;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Manual TPA Claim Push',
|
||||
text: 'Do you want to push this claim to the TPA now?',
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#00999E',
|
||||
cancelButtonColor: '#6c757d',
|
||||
confirmButtonText: 'Yes, push claim',
|
||||
cancelButtonText: 'Cancel'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
let requestData = { claim_id: ticket_master_id };
|
||||
let url = '<?= base_url('ticket/manualTpaClaimPush') ?>';
|
||||
|
||||
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.log('Manual TPA claim push response:', response);
|
||||
if (response.status) {
|
||||
toastr.success(response.message || 'Claim pushed to TPA successfully', 'Success');
|
||||
window.location.reload(true);
|
||||
} else {
|
||||
toastr.warning(response.message || 'Claim push failed', 'Warning');
|
||||
}
|
||||
}, function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.error('Error pushing claim:', error);
|
||||
console.error(xhr.responseText);
|
||||
let msg = 'An error occurred while pushing the claim to TPA.';
|
||||
if (xhr.responseJSON && xhr.responseJSON.message) {
|
||||
msg = xhr.responseJSON.message;
|
||||
} else if (xhr.status === 404) {
|
||||
msg = 'Manual TPA Claim Push endpoint is not configured. Please contact support.';
|
||||
}
|
||||
toastr.error(msg, 'Error');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function fetchTpaClaimStatus(){
|
||||
|
||||
let ticket_master_id = $('#ticket_master_id').val();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user