FIX_LIVE_ISSUES_AND_OTHERS

This commit is contained in:
VENKATESHWARAN 2026-03-25 17:05:23 +05:30
parent 0039fe72a1
commit 8929175f98
11 changed files with 305 additions and 15 deletions

View File

@ -24,6 +24,7 @@ class Acl
'#^/downloadFileTableFile#' => ['public' => true],
'#^/swagger#' => ['roles' => [ADMIN_ROLE_ID]],
'#^/getEmployeeActiveOrInactivePolicy#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],
'#^/test/chartbrewDashboardDemo#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],
'#^/bulkEcardDownloadAsZip#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],
'#^/sheet#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],
'#^/sendextraparam#' => ['roles' => [ADMIN_ROLE_ID, HEAD_ROLE_ID]],

View File

@ -882,6 +882,7 @@ $routes->group('test', function($routes) {
$routes->get('logo_renaming','TestingController::logo_renaming');
$routes->get('testingquerys','TestingController::testingquerys');
$routes->get('thzReminderCrone','ThzController::getOpenTicketsOlderThan24HoursAndAssignNextLevel');
$routes->get('chartbrewDashboardDemo','TestingController::chartbrewDashboardDemo');
// $routes->get('createDefaultMailTempalteInDB','TestingController::createDefaultMailTempalteInCrossDB');
// $routes->get('createDefaultMailTempalteInSameDB','TestingController::createDefaultMailTempalteInSameDB');
});

View File

@ -232,7 +232,13 @@ class ApiServiceController extends BaseController
$policy_id = $this->request->getPost('client_policy_id') ?? null;
$fileModel = new BatchFileModel();
$filesData = $fileModel->where('is_active', 1)->where('event_type', 'api')->where('status', 'inprogress')->countAllResults();
$filesData = $fileModel
->join('client_policy', 'client_policy.id = batch_files.client_policy_id')
->where('client_policy.tpa_id', $tpa_id)
->where('batch_files.is_active', 1)
->where('batch_files.event_type', 'api')
->where('batch_files.status', 'inprogress')
->countAllResults();
if($filesData > 0){
log_message('error', "TPA GetBenefDetails job is already in process.");

View File

@ -6380,12 +6380,13 @@ class ClientController extends AdminController
$client_type = $this->request->getGet('client_type') ?? null;
// Check in Policy Transaction (BDS)
$bds_count = $this->policyTransactionModel
$bds_data = $this->policyTransactionModel
->where('is_active', 1)
->where('action_type', 'inception')
->where('TRIM(policy_no)', $policy_no)
->where('policy_no IS NOT NULL AND policy_no <> ""')
->countAllResults();
->orderBy('id', 'desc')
->first() ?? [];
// Check in Enrollment (client_policy)
$client_policy_data = $this->clientPolicyModel
@ -6395,14 +6396,15 @@ class ClientController extends AdminController
->first();
// Decide message + count
if ($bds_count > 0) {
if (count($bds_data) > 0) {
return $this->respond([
'status' => true,
'message' => "This policy number is already linked to another policy in the BDS",
'code' => 409,
'data' => $bds_count,
'data' => $bds_data['id'],
'received_data' => $received_data,
'pt_id' => $bds_data['id'],
'client_policy_id' => $client_policy_data['id'] ?? null
], 200);
@ -6421,8 +6423,9 @@ class ClientController extends AdminController
return $this->respond([
'status' => false,
'message' => 'No Data Found',
'message' => 'Policy number not found in BDS or Enrollment, so proceed to add a new policy.',
'code' => 404,
'is_dublicate' => false,
'received_data' => $received_data,
'client_policy_id' => null
], 200);

View File

@ -549,6 +549,8 @@ class PolicyTransactionController extends BaseController
public function viewInception()
{
$bds_edit_pt_id = $this->request->getGet('pt_id') ?? null;
$view = $this->request->getGet('view') ?? null;
$data['tab_name'] = 'Policies';
$data['page_name'] = 'Policies';
@ -618,7 +620,7 @@ class PolicyTransactionController extends BaseController
$issuer = empty($issuer) ? 0 : $issuer;
$status = empty($status) ? 0 : $status; // Corrected from `$issuer`
if(empty($bds_edit_pt_id)){
if(empty($bds_edit_pt_id) && empty($view)){
if ($this->request->is('get')) {
// Fetch inception data list

View File

@ -1322,7 +1322,7 @@ class TestingController extends BaseController
* If env values are not present, sensible dummy defaults are used so that
* the function can still be exercised.
*/
public function testMediAssistWellness()
public function testMediAssistWellnessOld()
{
// Configuration prefer environment variables, fall back to demo values
@ -1374,4 +1374,169 @@ class TestingController extends BaseController
],
], 200);
}
public function chartbrewDashboardDemo()
{
// 1. Configuration - Use a Chartbrew-specific Secret Key from .env
$chartbrew_base_url = "https://analytics.nhanceindia.in/report/my-first-dashboard-oHbWNWH0";
$chartbrew_secret = getenv('METABASE_SECRET_KEY'); // Ensure this is set in your .env
// 2. Get dynamic parameters (matching your screenshot's naming convention)
$policy_id = $this->request->getGet('client_policy_id') ?? 4687;
// 3. Define the Payload
// Note: 'sub' (Subject) should usually be the user ID or a unique identifier
// depending on Chartbrew's specific JWT requirements.
$payload = [
"sub" => [
"type" => "Project",
"id" => 4, // Integer type usually preferred
"sharePolicyId" => 4
],
"iat" => time(),
"exp" => time() + (10 * 60), // 10 minute expiration
];
// 4. Encode the JWT
// Make sure you have 'use Firebase\JWT\JWT;' at the top of your controller
$token = JWT::encode($payload, $chartbrew_secret, 'HS256');
// 5. Construct the URL
// We use http_build_query to ensure special characters are handled correctly
$params = [
'token' => $token,
'theme' => 'light',
'client_policy_id' => $policy_id
];
$url = $chartbrew_base_url . '?' . http_build_query($params);
// 6. Optional API response
if ($this->request->getGet('api') == 1) {
return $this->response->setJSON([
'status' => 'success',
'data' => [
'chartbrewUrl' => $url,
'policy_id' => $policy_id
]
]);
}
// 7. Return the View
return view('chartbrew_dashboard_view', [
'iframe_url' => $url,
'policy_id' => $policy_id
]);
}
public function testMediAssistWellness()
{
// Config
$keyString = env('MEDIASSIST_WELLNESS_KEY');
$ivString = env('MEDIASSIST_WELLNESS_IV');
$loginUrlTemplate = env('MEDIASSIST_WELLNESS_LOGIN_URL');
$partnerCorpId = '15963';
$cipher_algorithm = 'AES-256-CBC';
// Payload (MATCH EXACT CASE from doc)
$payload = [
'Id' => '15022',
'expiryTime' => (string)(time() + 600), // string format safer
'CPartnerId' => $partnerCorpId,
];
$plainJson = json_encode($payload, JSON_UNESCAPED_SLASHES);
// ✅ IMPORTANT: Ensure correct key + IV length (ASCII based)
$key = substr(str_pad($keyString, 32, '0'), 0, 32); // 32 bytes
$iv = substr(str_pad($ivString, 16, '0'), 0, 16); // 16 bytes
// Encrypt
$cipherTextRaw = openssl_encrypt(
$plainJson,
$cipher_algorithm,
$key,
OPENSSL_RAW_DATA,
$iv
);
if ($cipherTextRaw === false) {
return $this->respond([
'status' => false,
'message' => 'Encryption failed.',
], 500);
}
// ✅ Use ONLY Base64 (NO urlencode unless explicitly required)
$encryptedSSO = base64_encode($cipherTextRaw);
// Build URL
$loginUrl = str_replace(
['{0}', '{1}'],
[$partnerCorpId, $encryptedSSO],
$loginUrlTemplate
);
return $this->respond([
'status' => true,
'data' => [
'loginUrl' => $loginUrl,
'encryptedSSO' => $encryptedSSO,
'plainPayload' => $payload,
'decryptMediAssistWellness' => $this->decryptMediAssistWellness($encryptedSSO),
],
], 200);
}
public function decryptMediAssistWellness($encryptedSSO)
{
// Config
$keyString = env('MEDIASSIST_WELLNESS_KEY');
$ivString = env('MEDIASSIST_WELLNESS_IV');
$cipher_algorithm = 'AES-256-CBC';
// Ensure same key + IV format used in encryption
$key = substr(str_pad($keyString, 32, '0'), 0, 32); // 32 bytes
$iv = substr(str_pad($ivString, 16, '0'), 0, 16); // 16 bytes
// Decode Base64
$cipherTextRaw = base64_decode($encryptedSSO, true);
if ($cipherTextRaw === false) {
return [
'status' => false,
'message' => 'Invalid Base64 string.',
];
}
// Decrypt
$decrypted = openssl_decrypt(
$cipherTextRaw,
$cipher_algorithm,
$key,
OPENSSL_RAW_DATA,
$iv
);
if ($decrypted === false) {
return [
'status' => false,
'message' => 'Decryption failed.',
];
}
// Convert JSON to array
$data = json_decode($decrypted, true);
return [
'status' => true,
'data' => [
'decryptedRaw' => $decrypted,
'decoded' => $data
],
];
}
}

View File

@ -574,7 +574,9 @@ class TicketController extends BaseController
->join("({$subquery->getCompiledSelect()}) tat_category", 'tm.id = tat_category.ticket_id', 'left')
->where('tm.is_active', 1)
->whereNotIn('claim_status_id', [11, 12, 13, 22, 24, 32, 34, 42, 44, 47, 53, 58, 65])
->orderBy('tm.id', 'DESC');
->orderBy('tm.id', 'DESC')
->limit(100);
$data = $query->get()->getResultArray();

View File

@ -1112,7 +1112,7 @@
// Default to Last 30 Days if No Filters Are Applied
if (empty($client_id) && empty($insurer_id) && empty($policy_type_id) && empty($date_type) && empty($issuer) && empty($where)) {
$fromDate = date('Y-m-d', strtotime('-90 days'));
$fromDate = date('Y-m-d', strtotime('-30 days'));
$toDate = date('Y-m-d 23:59:59');
$builder->where('policy_transaction.created_at >=', $fromDate)

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<iframe src="<?= $iframe_url ?>" allowTransparency="true" width="1200" height="600" frameborder="0" style="background-color: #ffffff"></iframe>
</body>
</html>

View File

@ -2080,7 +2080,10 @@ body[data-sidebar-size="condensed"] .footer {
<?php if (in_array(get_role_id(), [1, 5]) || (in_array(MANAGEMENT_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(BUSINESS_TEAM_ID, user_team()) || in_array(POS_TEAM_ID, user_team()))) { ?>
<li>
<a href="<?= base_url('/policy_tranction/inception/list') ?>">Policy</a>
<a href="<?= base_url('/policy_tranction/inception/list?view=1') ?>">Policy Add</a>
</li>
<li>
<a href="<?= base_url('/policy_tranction/inception/list') ?>">Policy List</a>
</li>
<!-- <li>
<a href="<?= base_url('/policy_tranction/inception/list2') ?>">Policy 2</a>

View File

@ -395,6 +395,27 @@ table.dataTable tbody td {
</div>
</div>
</div>
<div class="modal fade" id="policyNoAddModal" tabindex="-1" role="dialog" aria-labelledby="policyNoAddModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="policyNoAddModalLabel">Add policy</h5>
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">x</button>
</div>
<div class="modal-body">
<label for="modal_policy_no">Policy number</label>
<input type="text" class="form-control" id="modal_policy_no" name="modal_policy_no" autocomplete="off" placeholder="Enter policy number">
<small class="text-danger d-block mt-1" id="policy_no_add_modal_feedback"></small>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" onclick="hidePolicyNoAddModal()">Cancel</button>
<button type="button" class="btn btn-outline-primary" onclick="runInceptionAddFlowFromList()">Proceed to Add</button>
<button type="button" class="btn btn-primary" id="policyNoModalCheck">Check</button>
</div>
</div>
</div>
</div>
<script>
/* Modified by Gemini Code Assist */
function openPolicyFilterNav() {
@ -547,6 +568,7 @@ $(document).ready(function(){
getClientAndBranchAndPolicy()
addHTMLInput();
addHTMLInputForVehicleFileUpload()
getAddPage();
<?php if (session()->has('create_failed')) : ?>
toastr.error('<?= session()->getFlashdata('create_failed') ?>', 'Failed');
@ -577,9 +599,87 @@ $(document).ready(function(){
$('#ppteam').select2();
})
function openPolicyNoAddModal() {
var myModal = new bootstrap.Modal(document.getElementById('policyNoAddModal'));
myModal.show();
}
function runInceptionAddFlowFromList() {
hide_list_show_add();
addInsurerColumn();
addHTMLInput(null, 'policy_docs_div');
$('#policy_docs').show();
$('.close').click();
}
function validatePolicyNoForAdd() {
var pn = ($('#modal_policy_no').val() || '').trim();
$('#policy_no_add_modal_feedback').text('');
if (!pn) {
$('#policy_no_add_modal_feedback').text('Please enter a policy number.');
return;
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: '<?= base_url('/util/get_client_policy_data_using_policy_no') ?>',
type: 'GET',
data: { policy_no: pn },
dataType: 'json',
success: function (res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
var msg = (res && res.message) ? String(res.message) : 'Unable to validate policy number.';
if ("pt_id" in res) {
console.log("PT ID exists:", res.pt_id);
getPolicyTransactionDataForEdit(res.pt_id);
$('.close').click();
} else if("is_dublicate" in res){
runInceptionAddFlowFromList();
toastr.success(msg,'SUCCESS');
} else {
toastr.warning(msg,'WARNING');
}
},
error: function () {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
function getAddPage(){
const params = new URLSearchParams(window.location.search);
const view = params.get('view') ?? 0;
if(view == 1){
runInceptionAddFlowFromList();
}
}
// Datatable document ready
$(document).ready(function() {
$('#policyNoModalCheck').on('click', function () {
validatePolicyNoForAdd();
});
$('#policyNoModalProceedAdd').on('click', function () {
proceedToAddFromPolicyNoModal();
});
$(document).on('keydown', '#modal_policy_no', function (e) {
if (e.key === 'Enter') {
e.preventDefault();
validatePolicyNoForAdd();
}
});
var ticketsTable = $('#tickets-table');
if (ticketsTable.length) {
@ -605,10 +705,7 @@ $(document).ready(function() {
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
className: 'btn app-btn-primary mr-2',
action: function (e, dt, node, config) {
hide_list_show_add();
addInsurerColumn();
addHTMLInput(null, 'policy_docs_div');
$('#policy_docs').show()
openPolicyNoAddModal();
}
},
{