FIX_API : RV

This commit is contained in:
VENKATESHWARAN 2025-09-09 18:48:34 +05:30
parent 27074708b5
commit 5a2a98623b
7 changed files with 151 additions and 25 deletions

View File

@ -61,6 +61,7 @@ $routes->get('download-kyc-docs/(:segment)', 'ClientController::downloadKYCDocum
$routes->get('claim-form-download/(:any)', 'TicketController::downloadClaimForm/$1');
$routes->match (['get','post'],"claims-feedback-form/(:any)/(:any)", "TicketController::viewClaimFeedbackForm/$1/$2");
$routes->match (['get','post'],"claims-feedback-form/(:any)", "TicketController::viewClaimFeedbackForm/$1");
$routes->get('downloadClaimFile/(:any)', 'TicketController::downloadClaimFile/$1');

View File

@ -2088,6 +2088,7 @@ class EmpDataServiceController extends BaseController
'base_premium' => $base_bremium_and_gst['base_premium'] ?? null,
'gst' => $base_bremium_and_gst['gst'] ?? null,
'policy_issue_date' => $policy_issue_date ?? null,
'created_by' => $file['created_by'] ?? null,
]]);
// $this->cashDepositCalculationForInception($depositeData);
@ -2523,6 +2524,7 @@ class EmpDataServiceController extends BaseController
'emp_count' => $emp_count ?? null,
'action_type' => $file['event_type'] ?? null,
'policy_issue_date' => $policy_issue_date ?? null,
'created_by' => $file['created_by'] ?? null,
]]);
@ -3185,6 +3187,7 @@ class EmpDataServiceController extends BaseController
'base_premium' => $base_bremium_and_gst['base_premium'] ?? null,
'gst' => $base_bremium_and_gst['gst'] ?? null,
'policy_issue_date' => $policy_issue_date ?? null,
'created_by' => $file['created_by'] ?? null,
]]);
}
@ -3695,6 +3698,7 @@ class EmpDataServiceController extends BaseController
'base_premium' => $base_bremium_and_gst['base_premium'] ?? null,
'gst' => $base_bremium_and_gst['gst'] ?? null,
'policy_issue_date' => $policy_issue_date ?? null,
'created_by' => $file['created_by'] ?? null,
]]);
}
@ -4989,7 +4993,7 @@ class EmpDataServiceController extends BaseController
'policy_no' => $policy_data['policy_no'] ?? null,
'cd_ac_no' => $policy_data['cd_ac_no'] ?? null,
'cd_ac_pk' => $policy_data['cd_ac_pk'] ?? null,
'policy_issue_date' => $policy_data['policy_issue_date'] ?? null,
'policy_issue_date' => $params['policy_issue_date'] ?? null,
'policy_start_date' => $policy_data['policy_start_date'] ?? null,
'policy_end_date' => $policy_data['policy_end_date'] ?? null,
'data_received_date' => $policy_data['data_received_date'] ?? null,
@ -5000,7 +5004,7 @@ class EmpDataServiceController extends BaseController
'co_share' => $policy_data['co_share'] ?? 0,
'pre_payable_by' => $policy_data['pre_payable_by'] ?? 1,
'renewal_date' => $policy_data['policy_end_date'] ?? null,
'month' => date('Y-m-01', strtotime($policy_data['policy_issue_date'] ?? "")) ?? null,
'month' => date('Y-m-01', strtotime($params['policy_issue_date'] ?? "")) ?? null,
'ct_type' => 1,
'is_cd_reduce_from_bds' => 0,
'client_type_id' => 0,
@ -5015,6 +5019,7 @@ class EmpDataServiceController extends BaseController
'source_client_policy_id' => $lead_data['source_policy_id'] ?? null,
'tsi' => generate_tsi_code($lead_data['lead_type'] ?? 1) ?? null,
'installment' => $lead_data['no_of_installment'] ?? null,
'created_by' => $params['created_by'] ?? null,
];
$this->myLogger->logme("error", "Constructed policy transaction data: " . json_encode($policyTransactionData));

View File

@ -3417,6 +3417,7 @@ class EmployeeRestController extends AdminController
{
$received_data = $this->request->getPost();
$this->myLogger->logme('error', 'API claim initiate Recevied Params :' . json_encode($received_data ?? []));
$get_file_data = $this->request->getFiles('claim_docs');
// print_r($get_file_data); die;
$employee_id = $received_data['emp_id'];
@ -3510,8 +3511,6 @@ class EmployeeRestController extends AdminController
if ($insert_status && !empty($ticket_id)) {
$this->handleCliamFiles($file_data, $ticket_id);
//insert first history
$this->ticketController->putHistoryAfterInsert($fetchData, $ticket_id);
@ -3524,11 +3523,14 @@ class EmployeeRestController extends AdminController
'mail_content' => $fetchData['message'] ?? "New Claim",
];
$ticket_message_id = null;
if (!empty($messagesData['ticket_id'])) {
$TicketMessageModel = new TicketMessageModel();
$TicketMessageModel->insert($messagesData);
$ticket_message_id = $TicketMessageModel->insert($messagesData);
}
$this->handleCliamFiles($file_data, $ticket_id, $ticket_message_id);
$mail_sent_status = ($this->ticketController->sendAutoMailTrigger($ticket_id));
if (gettype($mail_sent_status) == 'array') {
$message = 'Claim Iniated Successfully';
@ -3565,7 +3567,7 @@ class EmployeeRestController extends AdminController
}
}
public function handleCliamFiles($data, $ticket_id)
public function handleCliamFiles($data, $ticket_id, $ticket_message_id)
{
if(!empty($data) && !empty($ticket_id))
{
@ -3578,6 +3580,7 @@ class EmployeeRestController extends AdminController
'doc_name' => $value['file_name'],
'url' => $value['file_path'],
'file_type' => 2,
'ticket_message_id' => $ticket_message_id,
];
$insert_ids[] = $claim_file->insert($data);
@ -3743,7 +3746,28 @@ class EmployeeRestController extends AdminController
}
$ticket_data[$key]['claim_type_value'] = $claimType[$claimPrimaryTypey][$value['claim_type']] ?? null;
$ticket_data[$key]['ticket_policy_type'] = $ticketTypeArray[$value['ticket_type_id']] ?? null;
$ticketMesssageModel = new TicketMessageModel();
$ticket_message_id = $ticketMesssageModel
->where('is_active', 1)
->where('sender', "user")
->where('ticket_id', $ticket_id)
->orderBy('id', "desc")
->first();
$claimFiles = new ClaimFilesModel();
$message["claim_files_data"] = $claimFiles
->select('id as claim_file_id, doc_name as claim_file_name')
->where('is_active', 1)
->where('file_type', 2)
->where('ticket_id', $ticket_id)
->where('ticket_message_id', $ticket_message_id)
->findAll();
foreach ($message["claim_files_data"] as $key => &$value) {
$value['url'] = base_url('downloadClaimFile/') . $value['id'];
}
unset($value);
}
}
@ -3793,6 +3817,11 @@ class EmployeeRestController extends AdminController
], 200);
}
public function getClaimFiles()
{
$ticket_id = $this->request->getGet('ticket_id');
}
// public function getPreEmployeePolicyCount($mobile_no, $clientId = null)
// {
// log_message('error', 'getPreEmployeePolicyCount called with params : ' . json_encode(['mobile_no' => $mobile_no, 'client_id' => $clientId], true));

View File

@ -1246,13 +1246,23 @@ class TicketController extends BaseController
->orderBy('ticket_messages.created_at', 'DESC')
->findAll();
foreach ($dataToSend['messages'] as $message) {
foreach ($dataToSend['messages'] as &$message) {
$mail_content_converted = $this->convertHtmlToText($message['mail_content']);
$message['mail_content'] = $mail_content_converted;
$claimFiles = new ClaimFilesModel();
$message["files_data"] = $claimFiles->where('is_active', 1)
->where('file_type', 2)->where('ticket_id', $ticket_master_id)
->where('ticket_message_id', $message['id'])
->findAll();
}
unset($message);
$dataToSend['emp_name'] = $this->ticketMasterModel->select('emp_name')
->where('id', $ticket_master_id)->where('is_active', 1)
->first()['emp_name'];
// dd($dataToSend);
if ($dataToSend) {
return $dataToSend;
@ -1262,6 +1272,38 @@ class TicketController extends BaseController
}
}
public function downloadClaimFile($claim_file_id = null)
{
// $actionType = $this->request->getGet();
$claimFiles = new ClaimFilesModel();
$file_data = $claimFiles->where('id', $claim_file_id)->first();
$fileName = $file_data['doc_name'];
$filePath = WRITEPATH . '/uploads/claim_files/' . $fileName;
try {
// Check if the file exists
if (file_exists($filePath)) {
// Set the appropriate MIME type
$mimeType = mime_content_type($filePath);
// Send the file to the client for download
return $this->response->download($filePath, null, $mimeType);
} else {
$data['message'] = 'The Physical File Not Found';
echo view('errors/404', $data);
}
} catch (\Exception $e) {
// Handle any exceptions
$errorMessage = $e->getMessage();
$this->myLogger->logme('error', $errorMessage);
// You can return an error response here
echo $errorMessage;
}
}
public function convertHtmlToText($html)
{
if(!empty($html)){

View File

@ -64,42 +64,79 @@ if (!function_exists('file_Upload')) {
}
}
// if (!function_exists('multi_file_Upload')) {
// function multi_file_Upload($fileToUpload, $filepath)
// {
// $uploadedFiles = [];
// // Handle multiple files
// if (is_array($fileToUpload)) {
// foreach ($fileToUpload as $file) {
// if ($file !== null && $file->isValid() && !$file->hasMoved()) {
// $file->move($filepath);
// $fileName = $file->getName(); // safer unique name
// $uploadedFiles[] = [
// 'file_name' => $fileName,
// 'file_path' => $filepath . $fileName
// ];
// }
// }
// }
// // Handle single file
// else {
// if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) {
// $fileToUpload->move($filepath);
// $fileName = $fileToUpload->getName();
// $uploadedFiles[] = [
// 'file_name' => $fileName,
// 'file_path' => $filepath . $fileName
// ];
// }
// }
// return $uploadedFiles; // always return array of files
// }
// }
if (!function_exists('multi_file_Upload')) {
function multi_file_Upload($fileToUpload, $filepath)
{
$uploadedFiles = [];
// Handle multiple files
if (is_array($fileToUpload)) {
foreach ($fileToUpload as $file) {
// Normalize: always work with an array of UploadedFile objects
$files = is_array($fileToUpload) ? $fileToUpload : [$fileToUpload];
foreach ($files as $file) {
// If file is itself an array (multiple under same input name)
if (is_array($file)) {
foreach ($file as $f) {
if ($f !== null && $f->isValid() && !$f->hasMoved()) {
$fileName = $f->getRandomName(); // safer unique name
$f->move($filepath, $fileName);
$uploadedFiles[] = [
'file_name' => $fileName,
'file_path' => $filepath . $fileName
];
}
}
} else {
// Single file
if ($file !== null && $file->isValid() && !$file->hasMoved()) {
$file->move($filepath);
$fileName = $file->getName(); // safer unique name
$fileName = $file->getRandomName();
$file->move($filepath, $fileName);
$uploadedFiles[] = [
'file_name' => $fileName,
'file_path' => $filepath . $fileName
];
}
}
}
// Handle single file
else {
if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) {
$fileToUpload->move($filepath);
$fileName = $fileToUpload->getName();
$uploadedFiles[] = [
'file_name' => $fileName,
'file_path' => $filepath . $fileName
];
}
}
return $uploadedFiles; // always return array of files
return $uploadedFiles; // always return array
}
}
if (!function_exists('file_unlink')) {
function file_unlink($filepath)
{

View File

@ -11,6 +11,7 @@ class ClaimFilesModel extends Model
protected $allowedFields = [
'id',
'ticket_id',
'ticket_message_id',
'file_type',
'doc_name',
'url',

View File

@ -28,6 +28,17 @@
<div id="msg_388" class="form-group">
<p><?= $message['mail_content'] ?></p>
</div>
<div>
<?php if (isset($message['files_data']) && !empty($message['files_data'])) {
foreach ($message['files_data'] as $index => $datas) {
$index = $index + 1;
?>
<p>File <?= $index ?> : <a href="<?= base_url('downloadClaimFile/') . $datas['id'] ?>" target="_blank"><?= $datas['doc_name'] ?></a></p>
<?php } } ?>
</div>
<!-- <div class="form-group mt-5">
<button class="btn btn-dark btn-sm" type="button" onclick="quoteMessage(388);"><i
class="fa fa-quote-left"></i> Quote</button>