diff --git a/app/DataTables/SpecialCodeDataTable.php b/app/DataTables/SpecialCodeDataTable.php new file mode 100644 index 0000000..65056c6 --- /dev/null +++ b/app/DataTables/SpecialCodeDataTable.php @@ -0,0 +1,89 @@ +filter(function ($query) { + if (request()->has('search')) { + $search = request()->get('search'); + $query->where('kode', 'like', "%" . $search['value'] . "%") + ->orWhere('name', 'like', "%" . $search['value'] . "%"); + } + }) + ->addIndexColumn() + ->addColumn('action', 'pages.masters.special-code._action') + ->setRowId('id'); + } + + /** + * Get the query source of dataTable. + */ + public function query(SpecialCode $model): QueryBuilder + { + return $model->newQuery(); + } + + /** + * Optional method if you want to use the html builder. + */ + public function html(): HtmlBuilder + { + return $this->builder() + ->setTableId('special-code-table') + ->columns($this->getColumns()) + ->minifiedAjax() + ->stateSave(false) + ->responsive() + ->autoWidth(true) + ->orderBy(1) + ->parameters([ + 'scrollX' => true, + 'drawCallback' => 'function() { KTMenu.createInstances(); }', + ]) + ->addTableClass('align-middle table-row-dashed fs-6 gy-5'); + } + + /** + * Get the dataTable columns definition. + */ + public function getColumns(): array + { + return [ + Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false), + Column::make('kode'), + Column::make('name'), + Column::computed('action') + ->exportable(false) + ->printable(false) + ->width(60) + ->addClass('text-center'), + ]; + } + + /** + * Get the filename for export. + */ + protected function filename(): string + { + return 'Special_Code_' . date('YmdHis'); + } +} diff --git a/app/Http/Controllers/SpecialCodeController.php b/app/Http/Controllers/SpecialCodeController.php new file mode 100644 index 0000000..33c0ada --- /dev/null +++ b/app/Http/Controllers/SpecialCodeController.php @@ -0,0 +1,118 @@ +middleware(function ($request, $next) { + //$this->user = Auth::guard('web')->user(); + return $next($request); + }); + + //CauserResolver::setCauser($this->user); + } + + /** + * Display a listing of the resource. + */ + public function index(SpecialCodeDataTable $dataTable) + { + /*if (is_null($this->user) || !$this->user->can('masters.read')) { + abort(403, 'Sorry !! You are Unauthorized to view any master data !'); + }*/ + + return $dataTable->render('pages.masters.special-code.index'); + } + + /** + * Show the form for creating a new resource. + */ + public function create(){} + + /** + * Store a newly created resource in storage. + */ + public function store(StoreSpecialCodeRequest $request) + { + /*if (is_null($this->user) || !$this->user->can('masters.create')) { + abort(403, 'Sorry !! You are Unauthorized to create any master data !'); + }*/ + + + // Validate the request... + $validated = $request->validated(); + + // Store the Special Code... + if($validated){ + try{ + SpecialCode::create($validated); + echo json_encode(['status' => 'success', 'message' => 'Special Code created successfully.']); + }catch(\Exception $e){ + echo json_encode(['status' => 'error', 'message' => 'Special Code created failed.']); + } + } + + return false; + } + + /** + * Display the specified resource. + */ + public function show(SpecialCode $special_code) + { + + } + + /** + * Show the form for editing the specified resource. + */ + public function edit($id){ + $special_code = SpecialCode::find($id); + echo json_encode($special_code); + } + + /** + * Update the specified resource in storage. + */ + public function update(UpdateSpecialCodeRequest $request, SpecialCode $special_code) + { + /*if (is_null($this->user) || !$this->user->can('masters.update')) { + abort(403, 'Sorry !! You are Unauthorized to update any master data !'); + }*/ + + // Validate the request... + $validated = $request->validated(); + + // Update the Directorat... + if($validated){ + try{ + $special_code->update($validated); + + echo json_encode(['status' => 'success', 'message' => 'Special Code updated successfully.']); + }catch(\Exception $e){ + echo json_encode(['status' => 'error', 'message' => 'Special Code updated failed.']); + } + } + + return false; + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(SpecialCode $special_code){ + $special_code->delete(); + echo json_encode(['status' => 'success', 'message' => 'Special Code deleted successfully.']); + } +} diff --git a/app/Http/Controllers/SubjobController.php b/app/Http/Controllers/SubJobController.php similarity index 100% rename from app/Http/Controllers/SubjobController.php rename to app/Http/Controllers/SubJobController.php diff --git a/app/Http/Requests/StoreSpecialCodeRequest.php b/app/Http/Requests/StoreSpecialCodeRequest.php new file mode 100644 index 0000000..79794fe --- /dev/null +++ b/app/Http/Requests/StoreSpecialCodeRequest.php @@ -0,0 +1,47 @@ + + */ + public function rules(): array + { + return [ + 'kode' => 'required|string|max:2|min:2|unique:special_codes,kode', + 'name' => 'required|string|max:50' + ]; + } + + /** + * Configure the validator instance. + */ + public function withValidator(Validator $validator): void + { + $validator->after(function (Validator $validator) { + if($validator->errors()->any()) { + $error = json_decode($validator->errors()->toJson(), true); + foreach ($error as $key => $value) { + flash( $value[0]); + } + + return redirect()->route('special-code.index')->with('error', 'Special Code created failed.'); + } + }); + } +} diff --git a/app/Http/Requests/UpdateSpecialCodeRequest.php b/app/Http/Requests/UpdateSpecialCodeRequest.php new file mode 100644 index 0000000..5cb8e6f --- /dev/null +++ b/app/Http/Requests/UpdateSpecialCodeRequest.php @@ -0,0 +1,47 @@ + + */ + public function rules(): array + { + return [ + 'kode' => 'required|string|max:2|min:2|unique:special_codes,kode,'.$this->id, + 'name' => 'required|string|max:50' + ]; + } + + /** + * Configure the validator instance. + */ + public function withValidator(Validator $validator): void + { + $validator->after(function (Validator $validator) { + if($validator->errors()->any()) { + $error = json_decode($validator->errors()->toJson(), true); + foreach ($error as $key => $value) { + flash( $value[0]); + } + + return redirect()->route('special_code.index')->with('error', 'Special Code updated failed.'); + } + }); + } +} diff --git a/app/Models/Document.php b/app/Models/Document.php new file mode 100644 index 0000000..cf6090a --- /dev/null +++ b/app/Models/Document.php @@ -0,0 +1,67 @@ +logAll() + ->useLogName('master data'); + } + + public function directorat() + { + return $this->belongsTo(Directorat::class); + } + + public function sub_directorat() + { + return $this->belongsTo(SubDirectorat::class); + } + + public function job() + { + return $this->belongsTo(Job::class); + } + + public function sub_job() + { + return $this->belongsTo(SubJob::class); + } + + public function sub_sub_job() + { + return $this->belongsTo(SubSubJob::class); + } + + public function special_code() + { + return $this->belongsTo(SpecialCode::class); + } + + public function document_details() + { + return $this->hasMany(DocumentDetail::class); + } +} diff --git a/app/Models/DocumentDetail.php b/app/Models/DocumentDetail.php new file mode 100644 index 0000000..4c55f3c --- /dev/null +++ b/app/Models/DocumentDetail.php @@ -0,0 +1,43 @@ +logAll() + ->useLogName('master data'); + } +} diff --git a/app/Models/DocumentType.php b/app/Models/DocumentType.php new file mode 100644 index 0000000..bacfacc --- /dev/null +++ b/app/Models/DocumentType.php @@ -0,0 +1,26 @@ +logAll() + ->useLogName('master data'); + } +} diff --git a/app/Models/SpecialCode.php b/app/Models/SpecialCode.php new file mode 100644 index 0000000..26f9598 --- /dev/null +++ b/app/Models/SpecialCode.php @@ -0,0 +1,26 @@ +logAll() + ->useLogName('master data'); + } +} diff --git a/database/migrations/2023_04_17_130450_create_document_types_table.php b/database/migrations/2023_04_17_130450_create_document_types_table.php new file mode 100644 index 0000000..d81cfa5 --- /dev/null +++ b/database/migrations/2023_04_17_130450_create_document_types_table.php @@ -0,0 +1,34 @@ +id(); + $table->string('kode', 2); + $table->string('name'); + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('special_codes'); + } +}; diff --git a/database/migrations/2023_04_17_130450_create_special_codes_table.php b/database/migrations/2023_04_17_130450_create_special_codes_table.php new file mode 100644 index 0000000..6f33529 --- /dev/null +++ b/database/migrations/2023_04_17_130450_create_special_codes_table.php @@ -0,0 +1,34 @@ +id(); + $table->string('kode', 2); + $table->string('name'); + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('special_codes'); + } +}; diff --git a/database/migrations/2023_04_17_135901_create_documents_table.php b/database/migrations/2023_04_17_135901_create_documents_table.php new file mode 100644 index 0000000..f649507 --- /dev/null +++ b/database/migrations/2023_04_17_135901_create_documents_table.php @@ -0,0 +1,50 @@ +id(); + $table->foreignIdFor(Directorat::class)->constrained()->onDelete('cascade'); + $table->foreignIdFor(SubDirectorat::class)->constrained()->onDelete('cascade'); + $table->foreignIdFor(Job::class)->constrained()->onDelete('cascade'); + $table->foreignIdFor(SubJob::class)->constrained()->onDelete('cascade'); + $table->foreignIdFor(SubSubJob::class)->constrained()->onDelete('cascade'); + $table->foreignIdFor(SpecialCode::class)->constrained()->onDelete('cascade'); + $table->string('no_urut',3); + $table->string('kode', 15); + $table->string('status')->nullable(); + $table->string('keterangan')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('documents'); + } +}; diff --git a/database/migrations/2023_04_17_135930_create_document_details_table.php b/database/migrations/2023_04_17_135930_create_document_details_table.php new file mode 100644 index 0000000..6864e0d --- /dev/null +++ b/database/migrations/2023_04_17_135930_create_document_details_table.php @@ -0,0 +1,55 @@ +id(); + $table->foreignId('document_id')->constrained('documents')->onDelete('cascade'); + $table->foreignId('document_type_id')->nullable()->constrained('document_types')->onDelete('cascade'); + + $table->enum('type', ['nasabah', 'non_nasabah']); + $table->string('nama_nasabah')->nullable(); + $table->string('no_rekening')->nullable(); + $table->string('no_cif')->nullable(); + $table->string('group')->nullable(); + + $table->date('tanggal_upload')->nullable(); + $table->date('tanggal_dokumen')->nullable(); + $table->string('no_dokumen')->nullable(); + $table->string('perihal')->nullable(); + $table->string('kode_cabang')->nullable(); + $table->string('jumlah_halaman')->nullable(); + $table->string('custom_field_1')->nullable(); + $table->string('custom_field_2')->nullable(); + $table->string('custom_field_3')->nullable(); + $table->string('custom_field_4')->nullable(); + $table->string('status')->nullable(); + $table->string('keterangan')->nullable(); + + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('document_details'); + } +}; diff --git a/database/seeders/LabelSeeder.php b/database/seeders/LabelSeeder.php index c6d3fc2..c4a5a3c 100644 --- a/database/seeders/LabelSeeder.php +++ b/database/seeders/LabelSeeder.php @@ -4,6 +4,7 @@ namespace Database\Seeders; use App\Models\Directorat; use App\Models\Job; +use App\Models\SpecialCode; use App\Models\SubDirectorat; use App\Models\SubJob; use App\Models\SubSubJob; @@ -53,5 +54,15 @@ class LabelSeeder extends Seeder 'sub_directorat_id' => $subdirektorat->id, 'directorat_id' => $direktorat->id, ]); + + $SpecialCode = SpecialCode::create([ + 'kode' => '00', + 'name' => 'Archive' + ]); + + $SpecialCode = SpecialCode::create([ + 'kode' => '98', + 'name' => 'Softcopy' + ]); } } diff --git a/resources/views/layout/partials/sidebar-layout/sidebar/_menu.blade.php b/resources/views/layout/partials/sidebar-layout/sidebar/_menu.blade.php index 1a63660..f0bc4e7 100644 --- a/resources/views/layout/partials/sidebar-layout/sidebar/_menu.blade.php +++ b/resources/views/layout/partials/sidebar-layout/sidebar/_menu.blade.php @@ -216,7 +216,7 @@ -
diff --git a/resources/views/pages/masters/special-code/_action.blade.php b/resources/views/pages/masters/special-code/_action.blade.php new file mode 100644 index 0000000..57031f0 --- /dev/null +++ b/resources/views/pages/masters/special-code/_action.blade.php @@ -0,0 +1,13 @@ +@php + $route = explode('.', Route::currentRouteName()); +@endphp +