MERGE_UAT_S3_ECARD_MIG_SCRIPT_IMPROVED

This commit is contained in:
Ubuntu 2025-12-29 16:50:23 +05:30
commit d3e44f7463
6 changed files with 335 additions and 185 deletions

View File

@ -1502,14 +1502,14 @@ class EmployeeController extends AdminController
} }
// exit(); // exit();
} }
else // else
{ // {
if($mode !== 2) // if($mode !== 2)
{ // {
$data['message'] = 'Inprogress... Comeback later! or Contact support'; // $data['message'] = 'Inprogress... Comeback later! or Contact support';
return view('errors/404', $data); // return view('errors/404', $data);
} // }
} // }
//in else generate PDF and upload it in s3 //in else generate PDF and upload it in s3
// echo 'else'; // echo 'else';
@ -1646,20 +1646,27 @@ class EmployeeController extends AdminController
// echo '<br>PDF generated and uploaded to S3 successfully.<br>'; // echo '<br>PDF generated and uploaded to S3 successfully.<br>';
unlink($temp_local_path); unlink($temp_local_path);
if($s3->exists($s3_key)) //2 => for bulk generate so skip s3 check and generate PDF
{
//get pre signed url & make it download
$s3_url = $s3->getPresignedUrl($s3_key );
$pdf = file_get_contents($s3_url['url']);
if ($mode == 1) {
// Inline view
return $this->response
->setHeader('Content-Type', 'application/pdf')
->setHeader('Content-Disposition', 'inline; filename="' . $s3_key . '"')
->setBody($pdf);
} else if($mode == 0){
// echo 'Force download';//die();
return $this->response
->setHeader('Content-Type', 'application/pdf')
->setHeader('Content-Disposition', 'attachment; filename="' . $s3_key . '"')
->setBody($pdf);
}
// exit(); // exit();
// if ($mode == 1) { }
// // Inline view
// return $this->response
// ->setHeader('Content-Type', 'application/pdf')
// ->setHeader('Content-Disposition', 'inline; filename="' . $filename . '"')
// ->setBody($dompdf->output());
// } else {
// // Force download
// return $this->response
// ->setHeader('Content-Type', 'application/pdf')
// ->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"')
// ->setBody($dompdf->output());
// }
// $this->myLogger->logme('error', 'generateIDCardForEmployee function completed successfully.'); // $this->myLogger->logme('error', 'generateIDCardForEmployee function completed successfully.');
@ -1671,6 +1678,20 @@ class EmployeeController extends AdminController
} }
public function sanitizeFilePart(string $value): string
{
// Trim spaces
$value = trim($value);
// Replace ANY unsafe character (including /) with underscore
$value = preg_replace('/[^A-Za-z0-9._()-]/', '_', $value);
// Collapse multiple underscores
$value = preg_replace('/_+/', '_', $value);
return $value;
}
// -------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------
public function viewECard() public function viewECard()
@ -4021,185 +4042,207 @@ class EmployeeController extends AdminController
public function bulkGenerateEcardAndStoreinS3(array $params = []) public function bulkGenerateEcardAndStoreinS3(array $params = [])
{ {
/** $request = \Config\Services::request();
* --------------------------- $isCli = is_cli();
* 1. Detect mode + collect inputs
* ---------------------------
*/
$client_policy_id = $params['client_policy_id'] ?? null; /* ---------------------------------------------------------
$emp_code = $params['emp_code'] ?? null; * 1. INPUTS (shared for WEB + CLI)
$emp_pk = $params['emp_pk'] ?? null; * --------------------------------------------------------- */
$batch_size = $params['batch_size'] ?? null; $client_policy_id = $params['client_policy_id'] ?? (!$isCli ? $request->getGet('client_policy_id') : null);
$batch_no = $params['batch_no'] ?? null; $emp_code = $params['emp_code'] ?? (!$isCli ? $request->getGet('emp_code') : null);
$execution_mode = $params['execution_mode'] ?? 'sequential';//parallel $emp_pk = $params['emp_pk'] ?? (!$isCli ? $request->getGet('emp_pk') : null);
$total_batches = $params['total_batches'] ?? 0;//parallel
if (is_cli()) { $batch_size = (int) ($params['batch_size'] ?? (!$isCli ? $request->getGet('batch_size') : 100));
$mode = 'CLI'; $batch_size = $batch_size > 0 ? $batch_size : 100;
$batch_no = isset($params['batch_no']) ? (int) $params['batch_no'] : null;
$total_batches = (int) ($params['total_batches'] ?? 0);
$execution_mode = $params['execution_mode'] ?? (!$isCli ? $request->getGet('execution_mode') : 'sequential');
$execution_mode = in_array($execution_mode, ['sequential', 'parallel']) ? $execution_mode : 'sequential';
$is_dry_run = $params['is_dry_run'] ?? (!$isCli ? $request->getGet('is_dry_run') : false);
} elseif (empty($params) && $this->request->getMethod() === 'get') { $log_search_context = 'ECARD_BULK_TO_S3';
$mode = 'WEB'; if($is_dry_run)
$client_policy_id = $this->request->getGet('client_policy_id');
$emp_code = $this->request->getGet('emp_code');
$emp_pk = $this->request->getGet('emp_pk');
$execution_mode = $this->request->getGet('execution_mode') ?? 'sequential';
$batch_size = (int) ($this->request->getGet('batch_size') ?? 100);
if($client_policy_id == null || empty($client_policy_id) || $client_policy_id == '')
{ {
return $this->respond(['status' => false, 'code' => 200, 'message' => 'client_policy_id is necessary'], 200); $log_search_context = 'ECARD_BULK_TO_S3_DRY_RUN';
} }
/**
* --------------------------- // Cursor (KEY FIX: avoids OFFSET issues)
* 2. Calculate total records $last_emp_id = (int) ($params['last_emp_id'] ?? 0);
* ---------------------------
*/ $this->myLogger->logme('error', "$log_search_context"." INIT - ". json_encode([
$total = $this->employeePolicyModel 'cli' => $isCli,
'policy' => $client_policy_id,
'batch_no' => $batch_no,
'last_emp_id' => $last_emp_id,
'mode' => $execution_mode
'is_dry_run' => $is_dry_run
]));
/* ---------------------------------------------------------
* 2. WEB DISPATCHER (QUEUE CREATOR)
* --------------------------------------------------------- */
if (!$isCli && empty($params)) {
if (empty($client_policy_id)) {
return $this->respond(['status' => false, 'message' => 'client_policy_id required'], 200);
}
// COUNT QUERY (same filters as worker)
$countBuilder = $this->employeePolicyModel->builder()
->join('employees', 'employees.id = employee_polices.employee_id') ->join('employees', 'employees.id = employee_polices.employee_id')
->where('employees.emp_status', 'active') ->where([
->where('employees.is_active', '1') 'employees.emp_status' => 'active',
->where("employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id <> ''") 'employees.is_active' => '1',
->where('employee_polices.status', 'active') 'employee_polices.status' => 'active',
->where('employee_polices.is_active', '1') 'employee_polices.is_active' => '1',
->where('employee_polices.client_policy_id', $client_policy_id) 'employee_polices.client_policy_id' => $client_policy_id
->countAllResults(); ])
->where("employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id <> ''");
if ($emp_code) $countBuilder->where('employees.emp_code', $emp_code);
if ($emp_pk) $countBuilder->where('employees.id', $emp_pk);
$total = (int) $countBuilder->countAllResults();
if ($total === 0) {
$this->myLogger->logme('error', "$log_search_context". 'No records found. Queue skipped.');
return $this->respond(['status' => 'NO_RECORDS'], 200);
}
$total_batches = (int) ceil($total / $batch_size); $total_batches = (int) ceil($total / $batch_size);
// echo $total_batches;die();
$this->myLogger->logme('error', "$log_search_context".'Queueing jobs - '. json_encode([
'total' => $total,
'batches' => $total_batches,
'mode' => $execution_mode
]));
$basePayload = [
/**
* ---------------------------
* 3. Push JOB per batch
* ---------------------------
*/
if ($execution_mode === 'parallel') {
for ($batch_no = 1; $batch_no <= $total_batches; $batch_no++) {
Jobs::addJob([
'job_name' => 'bulkGenerateEcardAndStoreinS3',
'payload' => [
'client_policy_id' => $client_policy_id, 'client_policy_id' => $client_policy_id,
'batch_size' => $batch_size,
'total_batches' => $total_batches,
'execution_mode' => $execution_mode,
'emp_code' => $emp_code, 'emp_code' => $emp_code,
'emp_pk' => $emp_pk, 'emp_pk' => $emp_pk,
'batch_size' => $batch_size, 'last_emp_id' => 0,
'batch_no' => $batch_no, 'is_dry_run' => $is_dry_run
'total_batches' => $total_batches, ];
'execution_mode' => 'parallel',
],
]);
}
}
if ($execution_mode === 'sequential') { if ($execution_mode === 'parallel') {
for ($i = 1; $i <= $total_batches; $i++) {
Jobs::addJob([ Jobs::addJob([
'job_name' => 'bulkGenerateEcardAndStoreinS3', 'job_name' => 'bulkGenerateEcardAndStoreinS3',
'payload' => [ 'payload' => array_merge($basePayload, ['batch_no' => $i])
'client_policy_id' => $client_policy_id, ]);
'batch_size' => $batch_size, }
'batch_no' => $batch_no ?? 1, } else {
'total_batches' => $total_batches, Jobs::addJob([
'execution_mode' => 'sequential', 'job_name' => 'bulkGenerateEcardAndStoreinS3',
], 'payload' => array_merge($basePayload, ['batch_no' => 1])
]); ]);
} }
return $this->respond(['status' => true, 'code' => 200, 'message' => 'E-card generation started', return $this->respond([
'status' => 'ECARD_BULK_TO_S3 Job queued',
'total' => $total, 'total' => $total,
'batches' => $total_batches,], 200); 'batches' => $total_batches
// return [ ], 200);
// 'status' => true,
// 'message' => 'E-card generation started',
// 'total' => $total,
// 'batches' => $total_batches,
// ];
} }
//else {
// return true;
// }
/** /* ---------------------------------------------------------
* --------------------------- * 3. CLI WORKER (ACTUAL PROCESSOR)
* 4. Build query (CLI execution) * --------------------------------------------------------- */
* --------------------------- if ($batch_no === null) {
*/ $this->myLogger->logme('error', "$log_search_context".'Worker called without batch_no');
$builder = $this->employeePolicyModel return;
->select(' }
$this->myLogger->logme('error', "$log_search_context"."START Batch {$batch_no}");
$builder = $this->employeePolicyModel->builder();
$builder->select('
employee_polices.client_policy_id, employee_polices.client_policy_id,
employees.emp_code, employees.emp_code,
employees.id as emp_id,
tpa.short_name, tpa.short_name,
employees.client_id, employees.client_id,
employee_polices.rand_string, employee_polices.rand_string
employees.id as emp_id
') ')
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id') ->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('employees', 'employees.id = employee_polices.employee_id') ->join('employees', 'employees.id = employee_polices.employee_id')
->join('tpa', 'tpa.id = client_policy.tpa_id') ->join('tpa', 'tpa.id = client_policy.tpa_id')
->where('employees.emp_status', 'active') ->where([
->where('employees.is_active', '1') 'employees.emp_status' => 'active',
'employees.is_active' => '1',
'employee_polices.status' => 'active',
'employee_polices.is_active' => '1',
'employee_polices.client_policy_id' => $client_policy_id
])
->where("employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id <> ''") ->where("employee_polices.tpa_id IS NOT NULL AND employee_polices.tpa_id <> ''")
->where('employee_polices.status', 'active') ->orderBy('employees.id', 'ASC');
->where('employee_polices.is_active', '1')
->where('employee_polices.client_policy_id', $client_policy_id);
if (!empty($emp_code)) { if ($emp_code) $builder->where('employees.emp_code', $emp_code);
$builder->where('employees.emp_code', $emp_code); if ($emp_pk) $builder->where('employees.id', $emp_pk);
if ($last_emp_id) $builder->where('employees.id >', $last_emp_id);
$rows = $builder->get($batch_size)->getResultArray();
$rowCount = count($rows);
$this->myLogger->logme('error', "$log_search_context"." Batch {$batch_no} fetched {$rowCount} rows");
if ($rowCount === 0) {
$this->myLogger->logme('error', "$log_search_context"." Batch {$batch_no} empty. STOPPING.");
return;
} }
if (!empty($emp_pk)) { foreach ($rows as $row) {
$builder->where('employees.id', $emp_pk); $this->myLogger->logme('error', "$log_search_context".' Processing - '. json_encode([
'emp_id' => $row['emp_id'],
'emp_code' => $row['emp_code'],
'policy' => $row['client_policy_id']
]));
if(!$is_dry_run) //for tesing skip generate ecard and just log only
{
$ecard_gen_res = $this->generateIDCardForEmployee($row['rand_string'],0,2); // 2 means skip S3 check
} }
/** $this->myLogger->logme('error', "$log_search_context".' processed - '. json_encode([
* --------------------------- 'emp_id' => $row['emp_id'],
* 5. Apply batching (only if provided) 'emp_code' => $row['emp_code'],
* --------------------------- 'policy' => $row['client_policy_id'],
*/ // 'ecard_gen_res' => $ecard_gen_res
if (!empty($batch_size) && !empty($batch_no)) { ]));//check
$offset = ($batch_no - 1) * $batch_size;
$builder->limit($batch_size, $offset);
} }
$res = $builder->findAll(); $new_last_emp_id = end($rows)['emp_id'];
/** /* ---------------------------------------------------------
* --------------------------- * 4. SEQUENTIAL RE-QUEUE (SAFE)
* 6. Process batch * --------------------------------------------------------- */
* --------------------------- if ($execution_mode === 'sequential' && $rowCount === $batch_size) {
*/ $this->myLogger->logme('info', "$log_search_context"."Re-queueing next batch - " . json_encode([
foreach ($res as $row) { 'next_batch' => $batch_no + 1,
$ecard_gen_res = $this->generateIDCardForEmployee( 'last_emp_id' => $new_last_emp_id
$row['rand_string'], ]));
0,
2 // skip S3 check, force regenerate
);
// print_rr([
// 'batch' => $batch_no,
// 'emp' => $row['emp_code'],
// 'res' => $ecard_gen_res,
// ]);
// echo date('Y-m-d H:i:s') . PHP_EOL;
}
if ($execution_mode === 'sequential' && $batch_no < $total_batches) {
Jobs::addJob([ Jobs::addJob([
'job_name' => 'bulkGenerateEcardAndStoreinS3', 'job_name' => 'bulkGenerateEcardAndStoreinS3',
'payload' => [ 'payload' => [
'client_policy_id' => $client_policy_id, 'client_policy_id' => $client_policy_id,
'batch_size' => $batch_size, 'batch_size' => $batch_size,
'batch_no' => ($batch_no + 1), 'batch_no' => $batch_no + 1,
'total_batches' => $total_batches,
'execution_mode' => 'sequential', 'execution_mode' => 'sequential',
], 'last_emp_id' => $new_last_emp_id,
'emp_code' => $emp_code,
'emp_pk' => $emp_pk,
'is_dry_run' => $is_dry_run
]
]); ]);
} }
// echo "BATCH {$batch_no} COMPLETED @ " . date('Y-m-d H:i:s') . PHP_EOL; $this->myLogger->logme('error', "$log_search_context". "END Batch {$batch_no}");
return array($batch_no);
} }

View File

@ -2928,6 +2928,11 @@ class EmployeeRestController extends AdminController
$data['ticket_settled_status_id'] = 44; $data['ticket_settled_status_id'] = 44;
$data['claim_subject'] = "Claim GTLI"; $data['claim_subject'] = "Claim GTLI";
$data['sum_insured_label'] = "Sum Assured"; $data['sum_insured_label'] = "Sum Assured";
} else if ($ClientPolicyValue['policy_type_id'] == 72){
$data['ticket_type_id'] = 72;
$data['ticket_settled_status_id'] = 76;
$data['claim_subject'] = "Claim OPD";
$data['sum_insured_label'] = "Sum Insured";
} else { } else {
$policyGroup = 'gmc'; $policyGroup = 'gmc';
$data['ticket_type_id'] = 1; $data['ticket_type_id'] = 1;
@ -3625,7 +3630,7 @@ class EmployeeRestController extends AdminController
WHEN cp.policy_type_id = 1 THEN 2 WHEN cp.policy_type_id = 1 THEN 2
WHEN cp.policy_type_id = 6 THEN 3 WHEN cp.policy_type_id = 6 THEN 3
WHEN cp.policy_type_id = 7 THEN 4 WHEN cp.policy_type_id = 7 THEN 4
ELSE NULL ELSE cp.policy_type_id
END AS ticket_type_id END AS ticket_type_id
from employees emp from employees emp
@ -3653,6 +3658,9 @@ class EmployeeRestController extends AdminController
if ($fetchData['ticket_type_id'] == 1 && !empty($fetchData['tpa_no'])) { if ($fetchData['ticket_type_id'] == 1 && !empty($fetchData['tpa_no'])) {
$results = $claimStatusQuery->findAll(2); $results = $claimStatusQuery->findAll(2);
$fetchData['claim_status_id'] = $results[1]['id'] ?? $results[0]['id']; $fetchData['claim_status_id'] = $results[1]['id'] ?? $results[0]['id'];
} else if ($fetchData['ticket_type_id'] == 72 && !empty($fetchData['tpa_no'])) {
$results = $claimStatusQuery->findAll(2);
$fetchData['claim_status_id'] = $results[1]['id'] ?? $results[0]['id'];
} else { } else {
$fetchData['claim_status_id'] = $claimStatusQuery->first()['id']; $fetchData['claim_status_id'] = $claimStatusQuery->first()['id'];
} }
@ -3918,6 +3926,7 @@ class EmployeeRestController extends AdminController
1 => 2, 1 => 2,
6 => 3, 6 => 3,
7 => 4, 7 => 4,
72 => 72,
]; ];
foreach ($policy_type_ids as $value) { foreach ($policy_type_ids as $value) {

View File

@ -76,7 +76,7 @@ class TicketController extends BaseController
$this->ticketMasterModel = new TicketMasterModel(); $this->ticketMasterModel = new TicketMasterModel();
$this->ticketType = [1 => "Claim-GMC", 2 => "Claim-GPA", 3 => "EDLI", 4 => "GTLI", 8 => "Motor"]; $this->ticketType = [1 => "Claim-GMC", 2 => "Claim-GPA", 3 => "EDLI", 4 => "GTLI", 8 => "Motor", 72 => "OPD"];
$this->priorityType = [ $this->priorityType = [
1 => "Low", 1 => "Low",
2 => "Medium", 2 => "Medium",
@ -287,7 +287,45 @@ class TicketController extends BaseController
13 => ['cancel_remark' => 'Cancel Remark'], 13 => ['cancel_remark' => 'Cancel Remark'],
47 => ['cancel_remark' => 'Cancel Remark'], 47 => ['cancel_remark' => 'Cancel Remark'],
53 => ['cancel_remark' => 'Cancel Remark'], 53 => ['cancel_remark' => 'Cancel Remark'],
58 => ['cancel_remark' => 'Cancel Remark'] 58 => ['cancel_remark' => 'Cancel Remark'],
// OPD claim status
67 => ['non_id_reason' => 'Non ID Reason'],
69 => ['raised_date' => 'Raised Date'],
70 => ['raised_date' => 'Raised Date'],
71 => [
'claim_number' => 'Claim Number',
'registration_date' => 'Registration Date'
],
72 => ['query_received_date' => 'Query Received Date'],
73 => [
'denial_reason' => 'Denial Reason',
'denial_date' => 'Denial Date'
],
74 => [
'approved_amount' => 'Approved Amount',
'approved_date' => 'Approved Date',
'approved_letter' => 'Approved Letter',
'approved_description' => 'Approved Description'
],
75 => ['pay_initiate_date' => 'Payment Initiated Date'],
76 => [
'utr_details' => 'UTR Details',
'settled_date' => 'Settled Date',
'settle_letter' => 'Settle Letter'
],
78 => ['cancel_remark' => 'Cancel Remark'],
79 => [
'return_remark' => 'Return Remark',
'awb_no_courier_name' => 'AWB No Courier Name'
],
]; ];
$this->nonIDReason = [ $this->nonIDReason = [
@ -335,7 +373,12 @@ class TicketController extends BaseController
55 => [], 55 => [],
56 => [], 56 => [],
57 => [], 57 => [],
60 => [] 60 => [],
68 => [],
77 => [],
80 => [],
81 => [],
]; ];
$this->ticketMasterModel = new TicketMasterModel(); $this->ticketMasterModel = new TicketMasterModel();
@ -703,7 +746,8 @@ class TicketController extends BaseController
'priorityType' => $this->priorityType, 'priorityType' => $this->priorityType,
'relationshipType' => $this->relationshipType, 'relationshipType' => $this->relationshipType,
'modeOFIntimate' => $this->modeOFIntimate, 'modeOFIntimate' => $this->modeOFIntimate,
'nonIDReason' => $this->nonIDReason 'nonIDReason' => $this->nonIDReason,
'claim_ticket_type_id' => $ticket_type
]; ];
switch ($ticket_type) { switch ($ticket_type) {
@ -719,6 +763,9 @@ class TicketController extends BaseController
case 8: case 8:
$data['ticket_form'] = 'Motor'; $data['ticket_form'] = 'Motor';
break; break;
case 72:
$data['ticket_form'] = 'OPD';
break;
} }
// Fetch ACM Users // Fetch ACM Users
@ -741,8 +788,9 @@ class TicketController extends BaseController
$claim_status_id = 35; $claim_status_id = 35;
}else if($ticket_type == 8){ }else if($ticket_type == 8){
$claim_status_id = 62; $claim_status_id = 62;
} }else if($ticket_type == 72){
else{ $claim_status_id = 67;
}else{
$claim_status_id = 1; $claim_status_id = 1;
} }
} }
@ -757,7 +805,9 @@ class TicketController extends BaseController
$data['claim_type'] = $this->claimType[2]; $data['claim_type'] = $this->claimType[2];
} }
if($ticket_type == 8){
$data['client_for_motor'] = $this->clientModel->select('id,client_name,phone')->where('client_type', 2)->where('is_active', 1)->findAll(); $data['client_for_motor'] = $this->clientModel->select('id,client_name,phone')->where('client_type', 2)->where('is_active', 1)->findAll();
}
$this->myLogger->logme('error', "Ticket form data fetched successfully for Ticket Type: $ticket_type"); $this->myLogger->logme('error', "Ticket form data fetched successfully for Ticket Type: $ticket_type");
@ -2013,9 +2063,13 @@ class TicketController extends BaseController
} }
} }
if($lastMatchedStatus == 1){ if($lastMatchedStatus == 1 || $lastMatchedStatus == 67){
if(!empty($incoming_form_values['tpa_no'])){ if(!empty($incoming_form_values['tpa_no'])){
if($lastMatchedStatus == 1){
$lastMatchedStatus = 2; $lastMatchedStatus = 2;
}else if($lastMatchedStatus == 67){
$lastMatchedStatus = 68;
}
} }
} }

View File

@ -38,7 +38,7 @@
<!-- Header Section --> <!-- Header Section -->
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6 d-flex align-items-center"> <div class="col-6 d-flex align-items-center">
<h4 class="mb-0">Claim GMC</h4> <h4 class="mb-0"><?= isset($claim_ticket_type_id) && $claim_ticket_type_id == 72 ? 'Claim OPD' : 'Claim GMC' ?></h4>
</div> </div>
<div class="col-6 text-right"> <div class="col-6 text-right">
<a href="<?= base_url('ticket/list'); ?>" aria-label="Back to ticket list"> <a href="<?= base_url('ticket/list'); ?>" aria-label="Back to ticket list">
@ -49,7 +49,7 @@
<?php } ?> <?php } ?>
<form role="form" class="parsley-examples" method="post" id="ticket_form_data" onsubmit="submitClaimForm(event, this)" enctype="multipart/form-data"> <form role="form" class="parsley-examples" method="post" id="ticket_form_data" onsubmit="submitClaimForm(event, this)" enctype="multipart/form-data">
<input type="hidden" id="ticket_type_id" name="ticket_type_id" value="1"> <input type="hidden" id="ticket_type_id" name="ticket_type_id" value="<?= isset($claim_ticket_type_id) && $claim_ticket_type_id == 72 ? 72 : 1 ?>">
<input type="hidden" id="ticket_master_id" name="ticket_master_id" value="<?= isset($ticket_data['id']) ? $ticket_data['id'] : '' ?>"> <input type="hidden" id="ticket_master_id" name="ticket_master_id" value="<?= isset($ticket_data['id']) ? $ticket_data['id'] : '' ?>">
<input type="hidden" id="is_head_approved" name="is_head_approved" value="<?= isset($ticket_data['is_head_approved']) ? $ticket_data['is_head_approved'] : '' ?>"> <input type="hidden" id="is_head_approved" name="is_head_approved" value="<?= isset($ticket_data['is_head_approved']) ? $ticket_data['is_head_approved'] : '' ?>">
<input type="hidden" id="extra_fields_array_for_validate" name="extra_fields_array_for_validate" value='<?= isset($extra_fields_array_for_validate) && !empty($extra_fields_array_for_validate) ? json_encode($extra_fields_array_for_validate) : "[]" ?>'> <input type="hidden" id="extra_fields_array_for_validate" name="extra_fields_array_for_validate" value='<?= isset($extra_fields_array_for_validate) && !empty($extra_fields_array_for_validate) ? json_encode($extra_fields_array_for_validate) : "[]" ?>'>
@ -681,6 +681,29 @@
showClass = '.payment'; showClass = '.payment';
} }
// OPD
if (value == 69 || value == 70) { // CDA & INFORMATION REQUIRED
showClass = '.cda_ir';
} else if (value == 71) { // UNDER PROCESS - CLAIM NO. UPDATION
showClass = '.up_cnu';
} else if (value == 72) { // UNDER PROCESS - QUERY DOCUMENT RECEIVED
showClass = '.up_qdr';
} else if (value == 73) { // REJECTED
showClass = '.rejected';
} else if (value == 74) { // APPROVED
showClass = '.approved';
} else if (value == 76) { // SETTLED
showClass = '.settled';
} else if (value == 78) { // CANCELLED
showClass = '.canceled';
} else if (value == 79) { // RETURNED
showClass = '.returned';
} else if (value == 67) { // NON ID
showClass = '.non_id';
} else if (value == 75) { // PAYMENT INITIATED
showClass = '.payment';
}
// Show the relevant section and enable required attributes // Show the relevant section and enable required attributes
if (showClass) { if (showClass) {
// $(showClass).show().find('input, textarea').attr('required', true); // $(showClass).show().find('input, textarea').attr('required', true);
@ -708,7 +731,7 @@
console.log('Selected Value:', selectedVal); console.log('Selected Value:', selectedVal);
console.log('Element ID:', elementId); console.log('Element ID:', elementId);
if (selectedVal == 2 || selectedVal == 14) { if (selectedVal == 2 || selectedVal == 14 || selectedVal == 68 || selectedVal == 79) {
$field = $('#non_id_reason') $field = $('#non_id_reason')
$field.prop('required', false); $field.prop('required', false);
} else if (selectedVal == 1) { } else if (selectedVal == 1) {
@ -1134,7 +1157,7 @@
$.each(data, function(index, item) { $.each(data, function(index, item) {
// console.log(item); // console.log(item);
if (ticket_type == 1 && item.policy_type_id != 1) { if ((ticket_type == 1 && item.policy_type_id != 1) || (ticket_type == 72 && item.policy_type_id == 72)) {
$('#emp_client_policy').append($('<option>', { $('#emp_client_policy').append($('<option>', {
value: item.client_policy_value, value: item.client_policy_value,
text: item.client_policy_name, text: item.client_policy_name,

View File

@ -62,7 +62,7 @@
<?php <?php
if (!isset($view_ticket_page)) { if (!isset($view_ticket_page)) {
if ($selected_ticket_type == 1) { if ($selected_ticket_type == 1 || $selected_ticket_type == 72) {
include('ticket_form_gmc.php'); include('ticket_form_gmc.php');
} else if ($selected_ticket_type == 8) { } else if ($selected_ticket_type == 8) {
include('ticket_form_motor.php'); include('ticket_form_motor.php');
@ -714,6 +714,17 @@
$('#emp_client_policy_data_list').append(option).select2(); $('#emp_client_policy_data_list').append(option).select2();
} }
} else if (ticket_type == 72) {
if (item.policy_type == 72) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
});
$('#emp_client_policy_data_list').append(option).select2();
}
} else { } else {
// console.log("inside else condition"); // console.log("inside else condition");
} }
@ -1119,6 +1130,7 @@
function setMemberData(input) { function setMemberData(input) {
var selectedOption = $(input).find(':selected'); var selectedOption = $(input).find(':selected');
var ticket_type_id = $('#ticket_type_id').val();
// Retrieve the data-* attributes // Retrieve the data-* attributes
var empId = selectedOption.data('empid'); var empId = selectedOption.data('empid');
@ -1140,13 +1152,21 @@
if (tpaNo == "") { if (tpaNo == "") {
if(ticket_type_id == 1){
$('#claim_status_id').val(1) $('#claim_status_id').val(1)
}else{
$('#claim_status_id').val(67)
}
$('#non_id_reason').attr('required', true); $('#non_id_reason').attr('required', true);
var $label = $("#non_id_reason_lable_id"); var $label = $("#non_id_reason_lable_id");
$label.text('*'); $label.text('*');
} else { } else {
if(ticket_type_id == 1){
$('#claim_status_id').val(2) $('#claim_status_id').val(2)
}else{
$('#claim_status_id').val(68)
}
$('#non_id_reason').attr('required', false); $('#non_id_reason').attr('required', false);
var $label = $("#non_id_reason_lable_id"); var $label = $("#non_id_reason_lable_id");
$label.text(""); $label.text("");

View File

@ -29,6 +29,7 @@
<option value="3">EDLI</option> <option value="3">EDLI</option>
<option value="4">GTLI</option> <option value="4">GTLI</option>
<option value="8">Motor</option> <option value="8">Motor</option>
<option value="72">OPD</option>
</select> </select>
</div> </div>
</div> </div>