update
parent
9b3e9f6096
commit
d10cc7ca74
|
|
@ -14,6 +14,7 @@ use App\Models\Master\Template;
|
|||
use App\Models\Master\TabelData;
|
||||
use App\Models\Master\TabelDataKolom;
|
||||
use App\Models\Dataset;
|
||||
use App\Models\DatasetCatatan;
|
||||
use App\Models\TxDataset;
|
||||
use App\Repositories\Eloquent\DatasetRepository;
|
||||
use DB;
|
||||
|
|
@ -92,9 +93,9 @@ class DatasetController extends Controller
|
|||
public function grid(Request $request)
|
||||
{
|
||||
if((session('group_id') == 1) || (session('group_alias') == 'admin')){
|
||||
$data = Dataset::with(['tabelData'])->where('status',1)->orderBy('DatasetId','DESC')->get();
|
||||
$data = Dataset::with(['tabelData'])->orderBy('DatasetId','DESC')->get();
|
||||
}else{
|
||||
$data = Dataset::with(['tabelData'])->where('status',1)->orderBy('DatasetId','DESC')->whereIn('instansi_id',[auth()->user()->ms_instansi_id])->get();
|
||||
$data = Dataset::with(['tabelData'])->orderBy('DatasetId','DESC')->whereIn('instansi_id',[session('instansi_id')])->get();
|
||||
}
|
||||
// $data = User::with(['group'])->orderBy('id','DESC')->get();
|
||||
$_data = [];
|
||||
|
|
@ -107,25 +108,27 @@ class DatasetController extends Controller
|
|||
|
||||
if((permission('is_create', $this->route.'.*','module',false)) || (permission('is_update', $this->route.'.*','module',false))){
|
||||
$action .= '<div class="flex flex-col gap-1 justify-center text-center items-center">';
|
||||
if($row->created_by == auth()->user()->id){
|
||||
if(($row->created_by == auth()->user()->id) || ($row->status == 2)){
|
||||
$action .= '<a href="'.url('opendata/dataset/update/'.encode_id($row->DatasetId)).'" title="Ubah Data" class="p-2 w-full rounded text-white bg-blue-600">Edit</a>';
|
||||
}
|
||||
$action .= '<a href="'.url('opendata/dataset/view/'.encode_id($row->DatasetId)).'" title="Lihat Data" class="p-2 w-full rounded text-white bg-slate-600">Detail</a>';
|
||||
if((session('group_id') == 1) || (session('group_alias') == 'admin')){
|
||||
// $action .= '<a href="#" data-href="'.url('management/user/forcelogin/'.encode_id($row->id)).'" title="Force Login" class="forcelogin btn btn-sm btn-block bg-success"><i class="ri-user-2-line text-white"></i></a>';
|
||||
if($row->status == 1){
|
||||
$action .= '<a href="#" data-href="'.url('opendata/dataset/delete/'.encode_id($row->DatasetId)).'" title="Hapus Data" class="remove_data p-2 w-full rounded bg-red-600 text-white">Hapus</a>';
|
||||
// $action .= '<a href="#" data-href="'.url('opendata/dataset/delete/'.encode_id($row->DatasetId)).'" title="Hapus Data" class="remove_data p-2 w-full rounded bg-red-600 text-white">Tolak Verifikasi</a>';
|
||||
}else{
|
||||
$action .= '<a href="#" data-href="'.url('opendata/dataset/aktif/'.encode_id($row->DatasetId)).'" title="Aktifkan Data" class="aktif_data p-2 w-full rounded bg-emerald-600 text-white">Restore Data</a>';
|
||||
// $action .= '<a href="#" data-href="'.url('opendata/dataset/aktif/'.encode_id($row->DatasetId)).'" title="Aktifkan Data" class="aktif_data p-2 w-full rounded bg-emerald-600 text-white">Verifikasi</a>';
|
||||
}
|
||||
}
|
||||
$action .= '</div>';
|
||||
}
|
||||
$status = '';
|
||||
if($row->status == 1){
|
||||
$status = '<small class="p-1 w-full bg-success text-white rounded" title="Aktif"><i class="ri-check-line"></i></small>';
|
||||
}else{
|
||||
$status = '<small class="p-1 w-full bg-danger text-white rounded" title="Tidak Aktif"><i class="ri-close-line"></i></small>';
|
||||
$status = '<small class="p-1 w-full bg-emerald-500 text-white rounded" title="Valid">Valid</small>';
|
||||
}elseif($row->status == 0){
|
||||
$status = '<small class="p-1 w-full bg-yellow-500 text-white rounded" title="Tidak Valid">Menunggu Verifikasi</small>';
|
||||
}elseif($row->status == 2){
|
||||
$status = '<small class="p-1 w-full bg-red-500 text-white rounded" title="Tidak Valid">Verifikasi Ditolak</small>';
|
||||
}
|
||||
|
||||
$_data[] = [
|
||||
|
|
@ -187,6 +190,7 @@ class DatasetController extends Controller
|
|||
$dataset->data = null;
|
||||
$dataset->file = null;
|
||||
$dataset->deskripsi = $request->deskripsi;
|
||||
$dataset->status = 0;
|
||||
$dataset->created_by = auth()->user()->id;
|
||||
$dataset->save();
|
||||
}
|
||||
|
|
@ -292,6 +296,7 @@ class DatasetController extends Controller
|
|||
$data['item'] = Dataset::find($keyId);
|
||||
|
||||
$template = TabelData::find($data['item']->ms_tabel_data_id);
|
||||
$data['catatan'] = DatasetCatatan::where('dataset_id',$keyId)->orderBy('created_at','ASC')->get();
|
||||
$data['tabel'] = TabelDataKolom::where('ms_tabel_data_id',$template->MsTabelDataId)->orderBy('order','ASC')->get();
|
||||
// $filename = pathinfo($tabelData->template_url, PATHINFO_FILENAME);
|
||||
// $data['modelClass'] = "App\\Models\\Dataset\\Dataset" . ucfirst($filename);
|
||||
|
|
@ -325,6 +330,27 @@ class DatasetController extends Controller
|
|||
|
||||
return response()->json(['success' => true,'message' => 'Berhasil update data','type' => 'success']);
|
||||
}
|
||||
public function verifikasi(Request $request,$id)
|
||||
{
|
||||
$keyId = decode_id($id);
|
||||
$dataset = Dataset::find($keyId);
|
||||
$dataset->status = $request->verifikasi;
|
||||
$dataset->save();
|
||||
|
||||
if($request->catatan){
|
||||
$cat = new DatasetCatatan;
|
||||
$cat->dataset_id = $keyId;
|
||||
$cat->type = 'dataset';
|
||||
$cat->catatan = $request->catatan;
|
||||
$cat->status = 1;
|
||||
$cat->save();
|
||||
}
|
||||
|
||||
return redirect()->back()->with([
|
||||
'message' => 'Berhasil update data',
|
||||
'type' => 'success',
|
||||
]);
|
||||
}
|
||||
|
||||
function generateTemplate($id){
|
||||
$keyId = decode_id($id);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DatasetCatatan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'dataset_catatan';
|
||||
protected $primaryKey = 'DatasetCatatanId';
|
||||
protected $guarded = [];
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('dataset_catatan', function (Blueprint $table) {
|
||||
$table->id('DatasetCatatanId');
|
||||
$table->integer('dataset_id');
|
||||
$table->string('type')->nullable(); //dataset, dataset tambahan
|
||||
$table->text('catatan')->nullable();
|
||||
$table->integer('status')->default(0);
|
||||
$table->timestampsTz();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('dataset_catatan');
|
||||
}
|
||||
};
|
||||
|
|
@ -115,7 +115,6 @@
|
|||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Pagination -->
|
||||
|
|
|
|||
|
|
@ -100,9 +100,39 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{{-- {!! $modelClass::legend() !!} --}}
|
||||
</div>
|
||||
@if(@$item->status == 0)
|
||||
<hr class="mt-3">
|
||||
<h5 class="text-xl font-bold mt-3">Form Verifikasi Dataset</h5>
|
||||
<form action="{{ url('opendata/dataset/verifikasi/'.encode_id($item->DatasetId)) }}" method="POST">
|
||||
{{ csrf_field() }}
|
||||
<div class="mt-2">
|
||||
<select name="verifikasi" class="w-full p-2 bg-white border" id="">
|
||||
<option value="1">Verifikasi</option>
|
||||
<option value="2">Tolak Verifikasi</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<textarea name="catatan" class="w-full p-2 bg-white border" id="" cols="30" rows="10" placeholder="Masukan Catatan"></textarea>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<button class="p-2 bg-blue-500 rounded text-white">Simpan</button>
|
||||
</div>
|
||||
</form>
|
||||
@endif
|
||||
@if($item->status == '2')
|
||||
<hr class="mt-3">
|
||||
<h5 class="text-xl font-bold my-3">Catatan Verifikasi Dataset</h5>
|
||||
@foreach ($catatan as $valCatatan)
|
||||
<div class="flex flex-col gap-3 bg-gray-100 p-2 mb-2 rounded">
|
||||
<div class="text-[10px]">{{$valCatatan->created_at}}</div>
|
||||
<div class="text-sm">{{$valCatatan->catatan}}</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ Route::name('opendata.')->prefix('opendata')->group(function () {
|
|||
Route::get('view/{id?}',[DatasetController::class,'view'])->name('view');
|
||||
Route::get('delete/{id?}',[DatasetController::class,'delete'])->name('delete');
|
||||
Route::get('aktif/{id?}',[DatasetController::class,'aktif'])->name('aktif');
|
||||
Route::post('verifikasi/{id?}',[DatasetController::class,'verifikasi'])->name('verifikasi');
|
||||
Route::get('generateTemplate/{id?}',[DatasetController::class,'generateTemplate'])->name('generateTemplate');
|
||||
// Route::get('download/{id?}',[DatasetController::class,'download'])->name('download');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue