update history corporate
This commit is contained in:
@@ -17,10 +17,6 @@ class AuditTrailController extends Controller {
|
||||
*/
|
||||
public function index(Request $request, $id)
|
||||
{
|
||||
$exlusionId = null;
|
||||
if ($request->model == 'App\Models\ExclusionRules'){
|
||||
$exlusionId = ExclusionRules::where('exclusion_id', $id)->get();
|
||||
}
|
||||
$audittrails = AuditTrail::query()
|
||||
->where('model', '=', $request->model)
|
||||
->where('model_id', '=', $id)
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Helpers\Helper;
|
||||
use App\Models\Corporate;
|
||||
use App\Models\CorporateService;
|
||||
use App\Models\Exclusion;
|
||||
use App\Models\ExclusionImport;
|
||||
use App\Models\Icd;
|
||||
use App\Models\ImportLog;
|
||||
use App\Services\ImportService;
|
||||
@@ -216,7 +217,13 @@ class DiagnosisExclusionController extends Controller
|
||||
$import->reader->close();
|
||||
Storage::delete('temp/' . $file_name);
|
||||
$import->writer->close();
|
||||
ExclusionImport::updateOrCreate([
|
||||
'corporate_id' => $corporate_id
|
||||
],[
|
||||
'file_name' => $file_name,
|
||||
'file_path' => 'temp/result-' . $file_name,
|
||||
|
||||
]);
|
||||
return [
|
||||
// 'total_successed_row' => $imported_plan_data,
|
||||
// 'total_failed_row' => count($failed_plan_data),
|
||||
|
||||
24
app/Models/ExclusionImport.php
Normal file
24
app/Models/ExclusionImport.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Altek\Accountant\Contracts\Recordable;
|
||||
|
||||
class ExclusionImport extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'corporate_id',
|
||||
'file_name',
|
||||
'file_path',
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Models\CorporatePlan;
|
||||
use App\Models\CorporateBenefit;
|
||||
use App\Models\Member;
|
||||
use App\Models\ExclusionRules;
|
||||
use App\Models\ExclusionImport;
|
||||
use App\Models\Icd;
|
||||
use App\Models\IcdTemplate;
|
||||
use App\Models\AuditTrail;
|
||||
@@ -108,6 +109,15 @@ class AppServiceProvider extends ServiceProvider
|
||||
$this->logAuditTrailExclusion($model, 'deleted');
|
||||
});
|
||||
|
||||
ExclusionImport::updated(function ($model) {
|
||||
|
||||
$this->logAuditTrailExclusion($model, 'updated');
|
||||
});
|
||||
|
||||
ExclusionImport::deleted(function ($model) {
|
||||
$this->logAuditTrailExclusion($model, 'deleted');
|
||||
});
|
||||
|
||||
// ICD or exlusion
|
||||
Icd::updated(function ($model) {
|
||||
$this->logAuditTrail($model, 'updated');
|
||||
@@ -149,7 +159,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
// Membuat jejak audit baru
|
||||
$auditTrail = new AuditTrail([
|
||||
'model' => get_class($model),
|
||||
'model_id' => $model->exclusion_id,
|
||||
'model_id' => $model->corporate_id,
|
||||
'action' => $action,
|
||||
'old_values' => json_encode($model->getOriginal()),
|
||||
'new_values' => json_encode($model->getAttributes()),
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('exclusion_imports', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('corporate_id');
|
||||
$table->string('file_name');
|
||||
$table->string('file_path');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('exclusion_imports');
|
||||
}
|
||||
};
|
||||
@@ -98,8 +98,8 @@ export default function CustomizedAccordions() {
|
||||
|
||||
useEffect(() => {
|
||||
setCorporate(configuredCorporateContext.currentCorporate);
|
||||
const model = 'App\\Models\\ExclusionRules';
|
||||
const url = `/audittrail/${id}?model=${model}`;
|
||||
const model = 'App\\Models\\ExclusionImport';
|
||||
const url = `/audittrail/${corporate_id}?model=${model}`;
|
||||
axios.get(url)
|
||||
.then((res) => {
|
||||
setCurrentCorporate(res.data);
|
||||
@@ -153,7 +153,7 @@ export default function CustomizedAccordions() {
|
||||
<TableBody>
|
||||
{Object.entries(item.old_values).map(([key, value]) => {
|
||||
let renderedValue;
|
||||
if (key === 'deleted_by' || key === 'created_by' || key === 'updated_by') {
|
||||
if (key === 'deleted_by' || key === 'created_by' || key === 'updated_by' || key === 'file_path') {
|
||||
return null; // Melewati iterasi saat key adalah 'deleted_by'
|
||||
}
|
||||
switch (key) {
|
||||
|
||||
@@ -520,9 +520,9 @@ export default function List(props: any) {
|
||||
>
|
||||
Delete
|
||||
</Button> */}
|
||||
<Link to={`/corporate/${corporate_id}/diagnosis-exclusions/${row.id}/history`}>
|
||||
{/* <Link to={`/corporate/${corporate_id}/diagnosis-exclusions/${row.id}/history`}>
|
||||
<HistoryIcon />
|
||||
</Link>
|
||||
</Link> */}
|
||||
</Stack>
|
||||
|
||||
</TableCell>
|
||||
@@ -895,6 +895,11 @@ export default function List(props: any) {
|
||||
<TableCell style={headStyle} align="left">
|
||||
Action
|
||||
</TableCell>
|
||||
<TableCell style={headStyle} align="left">
|
||||
<Link to={`/corporate/${corporate_id}/diagnosis-exclusions/history`}>
|
||||
<HistoryIcon />
|
||||
</Link>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
{dataTableIsLoading ? (
|
||||
|
||||
@@ -166,7 +166,7 @@ export default function Router() {
|
||||
element: <DiagnosisExclusions />,
|
||||
},
|
||||
{
|
||||
path: ':corporate_id/diagnosis-exclusions/:id/history',
|
||||
path: ':corporate_id/diagnosis-exclusions/history',
|
||||
element: <DiagnosisExclusionsHistory />,
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user