FEAT_CLAIM_MIS_UPLOAD
This commit is contained in:
parent
d949359ea3
commit
bfe4c59f78
@ -736,6 +736,12 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('getTpaClaimStatus',"ApiServiceController::getClaimStatus");
|
||||
});
|
||||
|
||||
$routes->group("/claim_mis", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('list','TicketController::claimMisFileList');
|
||||
$routes->get('download','TicketController::downloadClaimMisFile');
|
||||
$routes->post('upload','TicketController::uploadClaimMisFile');
|
||||
});
|
||||
|
||||
$routes->group("clientApi",["filter" => "AuthClientApi"], function ($routes){
|
||||
|
||||
$routes->post("getPolicyMaster","ClientAPIController::sendPolicyMaster");
|
||||
|
||||
@ -1984,6 +1984,7 @@ class MasterController extends AdminController
|
||||
'rules' => WRITEPATH . 'uploads/commission/rules',
|
||||
'claim_sample_forms' => ROOTPATH . 'public/claim_sample_forms/',
|
||||
'bds_dump_excel' => WRITEPATH . 'uploads/bds_dump_excel/',
|
||||
'claims_mis' => WRITEPATH . 'uploads/claims_mis/',
|
||||
];
|
||||
|
||||
foreach ($folders as $folderName => $folderPath) {
|
||||
|
||||
@ -24,6 +24,7 @@ use App\Models\ClaimFilesModel;
|
||||
use App\Models\ClaimDumpFileModel;
|
||||
use App\Models\VehicleModel;
|
||||
use App\Models\PartnerPolicyModel;
|
||||
use App\Models\ClaimMisFileModel;
|
||||
|
||||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
@ -67,6 +68,7 @@ class TicketController extends BaseController
|
||||
protected $claimDumpFileModel;
|
||||
protected $vehicleModel;
|
||||
protected $partnerPolicyModel;
|
||||
protected $claimmisFileModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -398,6 +400,7 @@ class TicketController extends BaseController
|
||||
$this->claimDumpFileModel = new ClaimDumpFileModel();
|
||||
$this->vehicleModel = new VehicleModel();
|
||||
$this->partnerPolicyModel = new PartnerPolicyModel();
|
||||
$this->claimmisFileModel = new ClaimMisFileModel();
|
||||
}
|
||||
|
||||
public function ticketList()
|
||||
@ -2980,4 +2983,83 @@ class TicketController extends BaseController
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'IR docs saved successfully', 'data' => $required_docs], 200);
|
||||
|
||||
}
|
||||
|
||||
public function claimMisFileList()
|
||||
{
|
||||
$data['page_name'] = "Cliam MIS Files";
|
||||
$data['claim_mis_file_list'] = $this->claimmisFileModel
|
||||
->select('claims_mis_files.*, user_profiles.first_name as user_name')
|
||||
->join('user_profiles', 'claims_mis_files.created_by = user_profiles.id')
|
||||
->where('claims_mis_files.is_active', 1)
|
||||
->orderBy('claims_mis_files.id', 'desc')
|
||||
->findAll();
|
||||
$data['tpa_list'] = $this->TPAModel->where('is_active', 1)->findAll();
|
||||
|
||||
return $this->loadLayout('claim_mis_file_list', $data);
|
||||
}
|
||||
|
||||
public function uploadClaimMisFile()
|
||||
{
|
||||
$file = $this->request->getFile('file');
|
||||
$data = $this->request->getPost();
|
||||
|
||||
if(isset($data['from_date']) && !empty($data['from_date'])){
|
||||
$data['from_date'] = change_date_format($data['from_date'], 'd/m/Y', 'Y-m-d');
|
||||
}
|
||||
|
||||
if(isset($data['to_date']) && !empty($data['to_date'])){
|
||||
$data['to_date'] = change_date_format($data['to_date'], 'd/m/Y', 'Y-m-d');
|
||||
}
|
||||
|
||||
$file_path = WRITEPATH.'uploads/claims_mis';
|
||||
$file_name = file_Upload_for_lead($file, $file_path);
|
||||
|
||||
if(!empty($file_name)){
|
||||
$data['file_name'] = $file_name;
|
||||
}
|
||||
|
||||
$response = $this->claimmisFileModel->insert($data);
|
||||
|
||||
if($response){
|
||||
return $this->respond(['status'=>true, 'code'=>200, 'message'=>'MIS file uploaded successfully'], 200);
|
||||
}else{
|
||||
return $this->respond(['status'=>true, 'code'=>500, 'message'=>'Failed to upload'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
public function downloadClaimMisFile()
|
||||
{
|
||||
try {
|
||||
|
||||
$file_id = $this->request->getGet('id');
|
||||
|
||||
// Find record
|
||||
$record = $this->claimmisFileModel->where('id', $file_id)->first();
|
||||
// dd($record);
|
||||
|
||||
if (!$record) {
|
||||
$data['message'] = 'File record not found';
|
||||
return view('errors/404', $data);
|
||||
}
|
||||
|
||||
$uploadPath = WRITEPATH . 'uploads/claims_mis/';
|
||||
$filePath = $uploadPath . $record['file_name'];
|
||||
// dd($filePath);
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
$data['message'] = 'The Physical File Not Found';
|
||||
return view('errors/404', $data);
|
||||
}
|
||||
|
||||
// Force file download
|
||||
return $this->response->download($filePath, null)->setFileName($record['file_name']);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// return $this->failServerError($e->getMessage());
|
||||
$this->myLogger->logme('error', 'Error occoured in downloadClaimMisFile : ' . $e->getMessage());
|
||||
$data['message'] = 'File record not found';
|
||||
return view('errors/404', $data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
57
app/Models/ClaimMisFileModel.php
Normal file
57
app/Models/ClaimMisFileModel.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ClaimMisFileModel extends Model
|
||||
{
|
||||
protected $table = 'claims_mis_files';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'client_id',
|
||||
'tpa_id',
|
||||
'client_policy_id',
|
||||
'from_date',
|
||||
'to_date',
|
||||
'file_name',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'is_active'
|
||||
];
|
||||
|
||||
|
||||
// Callbacks
|
||||
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)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
388
app/Views/claim_mis_file_list.php
Normal file
388
app/Views/claim_mis_file_list.php
Normal file
@ -0,0 +1,388 @@
|
||||
<style>
|
||||
|
||||
.reload:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
.addbtnStyle{
|
||||
margin-left: 20px !important;
|
||||
}
|
||||
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.dataTables_length label {height: 21px !important;}
|
||||
|
||||
.readonly-select { background-color: #f3f3f3 !important; cursor: not-allowed; pointer-events: none; }
|
||||
</style>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table data-custom-table-css="table" class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="tickets-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="font-weight-medium">S.No </th>
|
||||
<th class="font-weight-medium">File name</th>
|
||||
<th class="font-weight-medium">User/Time</th>
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="font-12">
|
||||
<?php
|
||||
if (isset($claim_mis_file_list)) {
|
||||
foreach ($claim_mis_file_list as $key => $file) {
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td class="text-center"><b><?php echo ($key + 1) ?></b></td>
|
||||
<td class="text-center"><?php echo $file['file_name'] ?></td>
|
||||
<td><?php echo change_date_format($file['created_at'],'Y-m-d H:i:s', 'd M Y h:i a') . ' by <strong>' . $file['user_name'] . '</strong>' ?>
|
||||
<td>
|
||||
<div class="btn-group dropdown">
|
||||
<a href="javascript: void(0);" class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown" aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a target="_blank" class="dropdown-item" href="<?= base_url("claim_mis/download?id=") . $file['id']; ?>"><i class="mdi mdi-download mr-2 text-muted font-18 vertical-middle"></i>Download</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- end col -->
|
||||
|
||||
<!-- Center modal content for upload file-->
|
||||
<div class="modal fade" id="claim-mis-file-upload-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Cliam MIS File upload</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="parsley-examples" id="claim-mis-upload-form" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Client<span id="tpa_danger" class="text-danger">*</span></label>
|
||||
<select name="client_id" class="form-control" id="client_id" required>
|
||||
<option value="">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Policy <span id="tpa_danger" class="text-danger">*</span></label>
|
||||
<select name="client_policy_id" class="form-control" id="client_policy_id" required>
|
||||
<option value="">Select</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="tpa">TPA<span id="tpa_danger" class="text-danger">*</span></label>
|
||||
<select class="form-control readonly-select" id="tpa_id" name="tpa_id" required>
|
||||
<option value="">Select TPA</option>
|
||||
<?php foreach ($tpa_list as $value) { ?>
|
||||
<option value="<?= $value['id'] ?>"><?= $value['short_name'] ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label>From Date<span id="tpa_danger" class="text-danger">*</span></label>
|
||||
<input class="form-control" type="text" name="from_date" id="from_date" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>To Date<span id="tpa_danger" class="text-danger">*</span></label>
|
||||
<input class="form-control" type="text" name="to_date" id="to_date" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="file_upload">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label>Upload file</label>
|
||||
<input type="file" name="file" id="file" accept=".pdf,.xls,.xlsx,application/pdf,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3" style="margin-top: 40px;margin-left: 170px;">
|
||||
<button id="claim_mis_form_submit_button" type="submit" class="btn btn-primary waves-effect waves-light justify-content-end">Upload</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
|
||||
let policyListByClient = null;
|
||||
let client_list = null;
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
getClientAndBranchAndPolicy();
|
||||
|
||||
$('#client_id').select2();
|
||||
$('#client_policy_id').select2();
|
||||
|
||||
var from_date = flatpickr("#from_date", {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
var to_date = flatpickr("#to_date", {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
// AJAX Form Submit Function
|
||||
$('#claim-mis-upload-form').on('submit', function(e) {
|
||||
e.preventDefault(); // Prevent default form submission
|
||||
|
||||
// Get form data
|
||||
var formData = new FormData(this);
|
||||
var fileInput = $('#file')[0];
|
||||
|
||||
// Validate file type
|
||||
var allowedTypes = [
|
||||
'application/pdf',
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/vnd.oasis.opendocument.spreadsheet'
|
||||
];
|
||||
|
||||
if (!fileInput.files || !fileInput.files.length) {
|
||||
toastr.warning('Please select a file', 'WARNING');
|
||||
return false;
|
||||
}
|
||||
|
||||
var selectedFile = fileInput.files[0];
|
||||
|
||||
// Some browsers return empty type → fallback to extension
|
||||
var allowedExtensions = ['pdf', 'xls', 'xlsx', 'ods'];
|
||||
var fileExtension = selectedFile.name.split('.').pop().toLowerCase();
|
||||
|
||||
if (
|
||||
(!allowedTypes.includes(selectedFile.type)) &&
|
||||
(!allowedExtensions.includes(fileExtension))
|
||||
) {
|
||||
toastr.warning(
|
||||
'Please upload a valid file (PDF / Excel: .pdf, .xls, .xlsx, .ods)',
|
||||
'WARNING'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//form submit url;
|
||||
let url = `<?php echo base_url('claim_mis/upload'); ?>`;
|
||||
|
||||
// Show loading state
|
||||
var submitButton = $('#claim_mis_form_submit_button');
|
||||
var originalText = submitButton.text();
|
||||
submitButton.prop('disabled', true).text('Uploading...');
|
||||
|
||||
// AJAX request
|
||||
$.ajax({
|
||||
url: url, // Your route URL
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false, // CRITICAL: Don't process the data
|
||||
contentType: false, // CRITICAL: Don't set content-type header
|
||||
cache: false,
|
||||
success: function(response) {
|
||||
|
||||
// Handle successful response
|
||||
console.log('Upload successful:', response);
|
||||
|
||||
if (response.status == true) {
|
||||
toastr.success(response.message, "SUCCESS");
|
||||
} else {
|
||||
toastr.error(response.message, "ERROR");
|
||||
}
|
||||
|
||||
// Reset form
|
||||
$('#claim-mis-upload-form')[0].reset();
|
||||
$('.close').click();
|
||||
window.location.reload();
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response
|
||||
console.error('Upload failed:', error);
|
||||
console.error('Upload failed:', error);
|
||||
},
|
||||
complete: function() {
|
||||
// Reset button state
|
||||
submitButton.prop('disabled', false).text(originalText);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#client_id').on('change', function(){
|
||||
|
||||
let client_id = $(this).val();
|
||||
|
||||
if(policyListByClient != '') {
|
||||
console.log(policyListByClient[client_id]);
|
||||
let data = policyListByClient[client_id];
|
||||
appendPolicies(data);
|
||||
}
|
||||
})
|
||||
|
||||
$('#client_policy_id').on('change', function(){
|
||||
let tpa_id = $(this).find(':selected').data('tpaid');
|
||||
console.log('tpa_id', tpa_id);
|
||||
|
||||
if(tpa_id){
|
||||
$('#tpa_id').val(tpa_id);
|
||||
}else{
|
||||
$('#tpa_id').val('');
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
// Datatable document ready
|
||||
$(document).ready(function() {
|
||||
|
||||
var ticketsTable = $('#tickets-table');
|
||||
|
||||
if (ticketsTable.length) {
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
// dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||
// "<'row'<'col-sm-12'tr>>" +
|
||||
// "<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
|
||||
dom: "<'row'<'col-sm-7'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
|
||||
"<'row'<'col-sm-12'tr>>" +
|
||||
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
|
||||
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
|
||||
buttons: [
|
||||
{
|
||||
text: 'Add',
|
||||
className: 'buttons-html5 addbtnStyle',
|
||||
action: function (e, dt, node, config) {
|
||||
openDumpUploadModal();
|
||||
}
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: `
|
||||
<div class="datatable-search-wrapper" style="position:relative; display:inline-block;">
|
||||
_INPUT_
|
||||
<i class="mdi mdi-magnify datatable-search-icon"
|
||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666;"></i>
|
||||
<i class="mdi mdi-close-circle datatable-clear-icon"
|
||||
style="position:absolute; right:10px; top:50%; transform:translateY(-50%); color:#666; display:none;"></i>
|
||||
</div>`,
|
||||
searchPlaceholder: "Search",
|
||||
emptyTable: '<div class="text-center text-muted">No Data found</div>'
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 15, // Set default number of rows per page (optional)
|
||||
});
|
||||
} else {
|
||||
console.error("Table not found.");
|
||||
}
|
||||
});
|
||||
|
||||
function openDumpUploadModal() {
|
||||
var myModal = new bootstrap.Modal(document.getElementById('claim-mis-file-upload-modal'));
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
function getClientAndBranchAndPolicy() {
|
||||
$.ajax({
|
||||
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
console.log('getClientAndBranchAndPolicy', res);
|
||||
|
||||
if (res.status == true) {
|
||||
policyListByClient = res.policyListByClient;
|
||||
client_list = res.client_data;
|
||||
appendClients(res.client_data);
|
||||
} else {
|
||||
console.log('No data found');
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function appendClients(data) {
|
||||
|
||||
$('#client_id').empty();
|
||||
|
||||
$('#client_id').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select Client'
|
||||
}));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
|
||||
if (item.client_policy_count > 0) {
|
||||
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.client_name
|
||||
});
|
||||
$('#client_id').append(option);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function appendPolicies(data) {
|
||||
|
||||
|
||||
$('#client_policy_id').empty();
|
||||
$('#client_policy_id').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select Policy',
|
||||
}));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.policy_type + '-' + item.policy_no,
|
||||
'data-tpaid': item.id,
|
||||
});
|
||||
|
||||
$('#client_policy_id').append(option);
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -1863,6 +1863,9 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/ticket/claim-upload') ?>">Claim Dump Upload</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/claim_mis/list') ?>">Claim MIS Upload</a>
|
||||
</li>
|
||||
<!-- <li>
|
||||
<a href="<?= base_url('/ticketList?return_type=web') ?>">Ticket List</a>
|
||||
</li> -->
|
||||
|
||||
Loading…
Reference in New Issue
Block a user