CHANGE_COMMISSION
This commit is contained in:
parent
9741f6e82a
commit
0648ca425f
@ -35,7 +35,7 @@ class RuleImportController extends AdminController
|
||||
$data['departments'] = $this->departments;
|
||||
$data['insurers'] = $this->insurerModel->where('is_active', 1)->findAll();
|
||||
$data['commission_file_list'] = $this->commissionFilesModel
|
||||
->select('commission_files.*, insurers.name as insurer_name, user_profiles.first_name as created_user_name')
|
||||
->select('commission_files.*, insurers.short_name as insurer_name, user_profiles.first_name as created_user_name')
|
||||
->join('insurers', 'commission_files.insurer_id = insurers.id')
|
||||
->join('user_profiles', 'commission_files.created_by = user_profiles.id')
|
||||
->where('commission_files.is_active', 1)
|
||||
@ -98,6 +98,7 @@ class RuleImportController extends AdminController
|
||||
// ---------------------------------------------------------
|
||||
// 2. Read POST fields
|
||||
// ---------------------------------------------------------
|
||||
// print_r($this->request->getPost()); die;
|
||||
$insurerId = $this->request->getPost('insurer_id');
|
||||
$department = $this->request->getPost('department');
|
||||
$commissionMonth = $this->request->getPost('commission_month');
|
||||
@ -108,6 +109,9 @@ class RuleImportController extends AdminController
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Missing required fields: insurer_id, department, commission_month'], 200);
|
||||
}
|
||||
|
||||
$commissionMonth = $commissionMonth . '-01';
|
||||
$commissionMonth = change_date_format($commissionMonth, 'Y-M-d', 'Y-m-d');
|
||||
|
||||
// Optional / default fields
|
||||
$postedFileName = $this->request->getPost('file_name') ?: $file->getClientName();
|
||||
$fileStatus = $this->request->getPost('file_status') ?: 'pending';
|
||||
@ -271,7 +275,7 @@ class RuleImportController extends AdminController
|
||||
|
||||
// Update DB: status, rules_count, updated_by
|
||||
$this->commissionFilesModel->update($insertId, [
|
||||
'file_status' => 'pending',
|
||||
'file_status' => 'success',
|
||||
'rules_count' => $rulesCount,
|
||||
'updated_by' => (int)$createdBy,
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
@ -354,7 +358,7 @@ class RuleImportController extends AdminController
|
||||
try {
|
||||
$this->commissionFilesModel->update($insertId, [
|
||||
'file_status' => 'failed',
|
||||
'updated_by' => isset($createdBy) ? (int)$createdBy : null,
|
||||
'updated_by' => get_session_userid(),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'notes' => 'Upload exception: ' . $ex->getMessage(),
|
||||
]);
|
||||
|
||||
@ -29,6 +29,39 @@ class CommissionFilesModel extends Model
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Validation rules (optional)
|
||||
// protected $validationRules = [
|
||||
// 'file_name' => 'required|min_length[1]|max_length[100]',
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
<style>
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
.table td,
|
||||
.table th {
|
||||
padding: 3px 8px !important;
|
||||
vertical-align: middle;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
@ -36,6 +38,11 @@
|
||||
min-height: 40px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.reload:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style>
|
||||
@ -143,10 +150,10 @@
|
||||
<th><div class="column-header">S.No.</div></th>
|
||||
<th><div class="column-header">File Name</div></th>
|
||||
<th><div class="column-header">Insurer</div></th>
|
||||
<th><div class="column-header">Commission Month</div></th>
|
||||
<th><div class="column-header">Commission <br> Month</div></th>
|
||||
<th><div class="column-header">Department</div></th>
|
||||
<th><div class="column-header">Rules Count</div></th>
|
||||
<th><div class="column-header">File<br>status</div></th>
|
||||
<th><div class="column-header">Rules <br> Count</div></th>
|
||||
<th><div class="column-header">status</div></th>
|
||||
<th><div class="column-header">User/Time</div></th>
|
||||
<th><div class="column-header">Action</div></th>
|
||||
</tr>
|
||||
@ -156,7 +163,9 @@
|
||||
<?php foreach ($commission_file_list as $index => $row) { ?>
|
||||
<tr>
|
||||
<td class="text-center"><?= $index+1 ?></td>
|
||||
<td><?php echo $row['file_name'] ?> </td>
|
||||
<td style="overflow: hidden;" class="reload truncate" data-toggle="tooltip" data-placement="top" title="<?php echo $row['file_name'] ?>">
|
||||
<?php echo $row['file_name'] ?>
|
||||
</td>
|
||||
<td><?php echo $row['insurer_name'] ?> </td>
|
||||
<td><?php echo change_date_format($row['commission_month'], 'Y-m-d', 'M-Y'); ?></td>
|
||||
<td><?php echo ucfirst($row['department']) ?> </td>
|
||||
@ -345,6 +354,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
//datatable
|
||||
$(document).ready(function() {
|
||||
table = $('#tickets-table').DataTable({
|
||||
scrollX: true,
|
||||
@ -363,20 +373,26 @@
|
||||
extend: 'collection',
|
||||
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
|
||||
className: 'btn app-btn-secondary ',
|
||||
buttons: [{
|
||||
extend: 'csv',
|
||||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||||
title: 'Client-List',
|
||||
// title: function() {
|
||||
// return $('#toggleButtons').is(':checked')
|
||||
// ? 'GC-Client-List'
|
||||
// : 'RC-Client-List';
|
||||
// },
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
}]
|
||||
buttons: [
|
||||
{
|
||||
extend: 'csv',
|
||||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||||
title: 'List',
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
},
|
||||
{
|
||||
extend: 'excel',
|
||||
title: 'List',
|
||||
text: '<i class="mdi mdi-file-excel " ></i><span class=" btn-custom"> EXCEL </span>',
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
language: {
|
||||
@ -405,6 +421,7 @@
|
||||
`);
|
||||
})
|
||||
|
||||
// others
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#insurer_id').select2();
|
||||
@ -415,15 +432,6 @@
|
||||
minViewMode: 'months',
|
||||
autoclose: true
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#file_upload').on('hidden.bs.modal', function () {
|
||||
console.log("Modal closed");
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// Add custom filter function to DataTables
|
||||
$.fn.dataTable.ext.search.push(function(settings, data, dataIndex) {
|
||||
@ -448,16 +456,7 @@
|
||||
table.draw();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
function showFileUploadModal(input) {
|
||||
var myModal = new bootstrap.Modal(document.getElementById('file_upload'));
|
||||
myModal.show();
|
||||
// $(input).val('');
|
||||
}
|
||||
|
||||
// form submit
|
||||
$('#commission_upload_form').submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
@ -517,12 +516,19 @@
|
||||
$('.close').click()
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(10).fadeOut('slow');
|
||||
// window.location.reload(true);
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// open the file upload modal
|
||||
function showFileUploadModal(input) {
|
||||
var myModal = new bootstrap.Modal(document.getElementById('file_upload'));
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
// remove the file entry
|
||||
function deleteCommissionData(id) {
|
||||
|
||||
Swal.fire({
|
||||
|
||||
@ -2026,7 +2026,7 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/commission/list') ?>">
|
||||
<i class="ri-book-open-line"></i>
|
||||
<span> commission</span>
|
||||
<span> Commission</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user