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