diff --git a/app/DataTables/DocumentDataTable.php b/app/DataTables/DocumentDataTable.php new file mode 100644 index 0000000..d26aa2a --- /dev/null +++ b/app/DataTables/DocumentDataTable.php @@ -0,0 +1,128 @@ +filter(function ($query) { + if (request()->has('search')) { + $search = request()->get('search'); + $query->where('kode', 'like', "%" . $search['value'] . "%"); + } + }) + ->addColumn('kode_directorat',function($model){ + return $model->directorat->kode; + }) + ->addColumn('name_directorat',function($model){ + return $model->directorat->name; + }) + ->addColumn('kode_sub_directorat',function($model){ + return $model->sub_directorat->kode; + }) + ->addColumn('name_sub_directorat',function($model){ + return $model->sub_directorat->name; + }) + ->addColumn('kode_pekerjaan',function($model){ + return $model->job->kode; + }) + ->addColumn('name_pekerjaan',function($model){ + return $model->job->name; + }) + ->addColumn('kode_sub_pekerjaan',function($model){ + return $model->sub_job->kode; + }) + ->addColumn('name_sub_pekerjaan',function($model){ + return $model->sub_job->name; + }) + ->addColumn('kode_sub_sub_pekerjaan',function($model){ + return $model->sub_sub_job->kode; + }) + ->addColumn('name_sub_sub_pekerjaan',function($model){ + return $model->sub_sub_job->name; + }) + ->addIndexColumn() + ->addColumn('action', 'pages.app.document._action') + ->setRowId('id'); + } + + /** + * Get the query source of dataTable. + */ + public function query(Document $model): QueryBuilder + { + return $model->newQuery(); + } + + /** + * Optional method if you want to use the html builder. + */ + public function html(): HtmlBuilder + { + return $this->builder() + ->setTableId('document-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('kode_directorat')->title('Kode Direktorat'), + Column::make('name_directorat')->title('Nama Direktorat'), + Column::make('kode_sub_directorat')->title('Kode Sub Direktorat'), + Column::make('name_sub_directorat')->title('Nama Sub Direktorat'), + Column::make('kode_pekerjaan')->title('Kode Pekerjaan'), + Column::make('name_pekerjaan')->title('Nama Pekerjaan'), + Column::make('kode_sub_pekerjaan')->title('Kode Sub Pekerjaan'), + Column::make('name_sub_pekerjaan')->title('Nama Sub Pekerjaan'), + Column::make('kode_sub_sub_pekerjaan')->title('Kode Sub Sub Pekerjaan'), + Column::make('name_sub_sub_pekerjaan')->title('Nama Sub Sub Pekerjaan'), + Column::make('status'), + Column::computed('action') + ->exportable(false) + ->printable(false) + ->width(60) + ->addClass('text-center'), + ]; + } + + /** + * Get the filename for export. + */ + protected function filename(): string + { + return 'Document_' . date('YmdHis'); + } +} diff --git a/app/DataTables/DocumentTypeDataTable.php b/app/DataTables/DocumentTypeDataTable.php index 8d1c679..f4b9d41 100644 --- a/app/DataTables/DocumentTypeDataTable.php +++ b/app/DataTables/DocumentTypeDataTable.php @@ -30,7 +30,7 @@ class DocumentTypeDataTable extends DataTable } }) ->addIndexColumn() - ->addColumn('action', 'pages.masters.document-type._action') + ->addColumn('action', 'pages.app.document-type._action') ->setRowId('id'); } diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php new file mode 100644 index 0000000..15667ed --- /dev/null +++ b/app/Http/Controllers/DocumentController.php @@ -0,0 +1,179 @@ +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(DocumentDataTable $dataTable) + { + /*if (is_null($this->user) || !$this->user->can('app.read')) { + abort(403, 'Sorry !! You are Unauthorized to view any master data !'); + }*/ + + return $dataTable->render('pages.app.document.index'); + } + + /** + * Show the form for creating a new resource. + */ + public function create() + { + /*if (is_null($this->user) || !$this->user->can('app.create')) { + abort(403, 'Sorry !! You are Unauthorized to create any master data !'); + }*/ + addVendor('chained-select'); + + $directorat = Directorat::all(); + $special_code = SpecialCode::all(); + $document_type = DocumentType::all(); + return view('pages.app.document.create', compact('directorat', 'special_code', 'document_type')); + } + + /** + * Store a newly created resource in storage. + */ + public function store(StoreDocumentRequest $request) + { + /*if (is_null($this->user) || !$this->user->can('app.create')) { + abort(403, 'Sorry !! You are Unauthorized to create any master data !'); + }*/ + + + // Validate the request... + $validated = $request->validated(); + + // Store the Document... + if ($validated) { + $validated['sequence'] = 1; + try { + $created = Document::create($validated); + + if ($created) { + $detail = [ + 'document_id' => $created->id, + 'document_type_id' => $request->document_type_id, + 'tanggal_upload' => date('Y-m-d'), + 'tanggal_dokumen' => $request->tanggal_dokumen, + 'nomor_dokumen' => $request->nomor_dokumen, + 'perihal' => $request->perihal, + 'kode_cabang' => $request->kode_cabang, + 'jumlah_halaman' => $request->jumlah_halaman, + 'custom_field_1' => $request->custom_field_1, + 'custom_field_2' => $request->custom_field_2, + 'custom_field_3' => $request->custom_field_3, + 'custom_field_4' => $request->custom_field_4, + + 'nama_nasabah' => $request->nama_nasabah, + 'no_rekening' => $request->no_rekening, + 'no_cif' => $request->no_cif, + 'group' => $request->group, + ]; + + + DocumentDetail::create($detail); + } + + return redirect()->route('document.index')->with('success', 'Document created successfully.'); + } catch (Exception $e) { + return redirect()->route('document.index')->with('error', 'Document created failed.'); + } + } + + return false; + } + + /** + * Display the specified resource. + */ + public function show(Document $documents) + { + + } + + /** + * Show the form for editing the specified resource. + */ + public function edit($id) + { + $document = Document::find($id); + $directorat = Directorat::all(); + $sub_directorat = SubDirectorat::where('directorat_id', $document->directorat_id)->get(); + $job = Job::where('sub_directorat_id', $document->sub_directorat_id)->get(); + $sub_job = SubJob::where('job_id', $document->job_id)->get(); + $sub_sub_job = SubSubJob::where('sub_job_id', $document->sub_job_id)->get(); + $special_code = SpecialCode::all(); + $document_type = DocumentType::all(); + + return view('pages.app.document.edit', compact('document', 'directorat', 'sub_directorat', 'job', 'sub_job', 'sub_sub_job', 'special_code', 'document_type')); + + } + + /** + * Update the specified resource in storage. + */ + public function update(UpdateDocumentRequest $request, Document $documents) + { + /*if (is_null($this->user) || !$this->user->can('app.update')) { + abort(403, 'Sorry !! You are Unauthorized to update any master data !'); + }*/ + + // Validate the request... + $validated = $request->validated(); + + // Update the Document... + if ($validated) { + try { + $document = Document::find($request->id); + $update = $document->update($validated); + + + return redirect()->route('document.index')->with('success', 'Document updated successfully.'); + } catch (Exception $e) { + return redirect()->route('document.index')->with('error', 'Document updated failed.'); + } + } + + return false; + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Request $request) + { + $documents = Document::find($request->document); + $documents->delete(); + echo json_encode(['status' => 'success', 'message' => 'Document deleted successfully.']); + } + } diff --git a/app/Http/Controllers/SubSubjobController.php b/app/Http/Controllers/SubSubjobController.php index a97fee9..5d6c12a 100644 --- a/app/Http/Controllers/SubSubjobController.php +++ b/app/Http/Controllers/SubSubjobController.php @@ -25,12 +25,17 @@ class SubSubJobController extends Controller /** * Display a listing of the resource. */ - public function index(SubSubJobDataTable $dataTable) + public function index(SubSubJobDataTable $dataTable, Request $request) { /*if (is_null($this->user) || !$this->user->can('masters.read')) { abort(403, 'Sorry !! You are Unauthorized to view any master data !'); }*/ + if(isset($request->sub_job_id) && !empty($request->sub_job_id)) { + $this->show($request); + return; + } + addVendor('chained-select'); $directorat = Directorat::all(); @@ -75,7 +80,18 @@ class SubSubJobController extends Controller */ public function show(Request $request) { + $subSubJob = SubSubJob::where('sub_job_id', $request->sub_job_id)->get(); + $data = []; + foreach ($subSubJob as $row) { + $result = [ + $row->id => $row->name, + ]; + + $data[] = $result; + } + + echo json_encode($data); } /** diff --git a/app/Http/Requests/StoreDocumentRequest.php b/app/Http/Requests/StoreDocumentRequest.php new file mode 100644 index 0000000..af99453 --- /dev/null +++ b/app/Http/Requests/StoreDocumentRequest.php @@ -0,0 +1,60 @@ + + */ + public function rules() + : array + { + return [ + 'kode' => 'required|string|unique:documents,kode', + 'directorat_id' => 'required|integer|exists:directorats,id', + 'sub_directorat_id' => 'required|integer|exists:sub_directorats,id', + 'job_id' => 'required|integer|exists:jobs,id', + 'sub_job_id' => 'required|integer|exists:sub_jobs,id', + 'sub_sub_job_id' => 'required|integer|exists:sub_sub_jobs,id', + 'special_code_id' => 'nullable|integer|exists:special_codes,id', + 'no_urut' => 'nullable|integer|min:1|max:999', + 'sequence' => 'nullable|integer|min:1|max:999', + 'status' => 'nullable|integer', + 'keterangan' => 'nullable|string|max:255', + 'jenis_dokumen' => 'nullable|string|max:255', + ]; + } + + /** + * 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('document.index')->with('error', 'Document created failed.'); + } + }); + } + } diff --git a/app/Http/Requests/UpdateDocumentRequest.php b/app/Http/Requests/UpdateDocumentRequest.php new file mode 100644 index 0000000..89c477f --- /dev/null +++ b/app/Http/Requests/UpdateDocumentRequest.php @@ -0,0 +1,60 @@ + + */ + public function rules() + : array + { + return [ + 'kode' => 'required|string|unique:documents,kode,' . $this->id, + 'directorat_id' => 'required|integer|exists:directorats,id', + 'sub_directorat_id' => 'required|integer|exists:sub_directorats,id', + 'job_id' => 'required|integer|exists:jobs,id', + 'sub_job_id' => 'required|integer|exists:sub_jobs,id', + 'sub_sub_job_id' => 'required|integer|exists:sub_sub_jobs,id', + 'special_code_id' => 'nullable|integer|exists:special_codes,id', + 'no_urut' => 'nullable|integer|min:1|max:999', + 'sequence' => 'nullable|integer|min:1|max:999', + 'status' => 'nullable|integer', + 'keterangan' => 'nullable|string|max:255', + 'jenis_dokumen' => 'nullable|string|max:255', + ]; + } + + /** + * 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('document.index')->with('error', 'Document updated failed.'); + } + }); + } + } diff --git a/app/Models/Document.php b/app/Models/Document.php index cf6090a..a1fc9dc 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -21,7 +21,9 @@ class Document extends Model 'sub_sub_job_id', 'special_code_id', 'no_urut', - 'kode' + 'kode', + 'sequence', + 'jenis_dokumen' ]; public function getActivitylogOptions(): LogOptions diff --git a/app/Models/DocumentDetail.php b/app/Models/DocumentDetail.php index 4c55f3c..e059e25 100644 --- a/app/Models/DocumentDetail.php +++ b/app/Models/DocumentDetail.php @@ -16,15 +16,16 @@ class DocumentDetail extends Model protected $fillable = [ 'document_id', 'document_type_id', - 'type', + 'nama_nasabah', 'no_rekening', 'no_cif', 'group', + 'group', 'tanggal_upload', - 'tanggal_document', - 'no_document', + 'tanggal_dokumen', + 'nomor_dokumen', 'perihal', 'kode_cabang', 'jumlah_halaman', diff --git a/composer.json b/composer.json index fa85860..8b98480 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,9 @@ "license": "MIT", "require": { "php": "^8.0.2", + "anlutro/l4-settings": "^1.3", "guzzlehttp/guzzle": "^7.2", + "haruncpi/laravel-id-generator": "^1.1", "jackiedo/log-reader": "2.*", "laracasts/flash": "^3.2", "laravel/framework": "^10.0", diff --git a/composer.lock b/composer.lock index cf3c2fb..6fa51d8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,71 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9e90063b659e638d19ae81dade0a7fc4", + "content-hash": "0e87e4f9bda92e486cd97bf407e9f234", "packages": [ + { + "name": "anlutro/l4-settings", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/anlutro/laravel-settings.git", + "reference": "8f3c602b6eb440fb4211d2aa028f879a779f037f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/anlutro/laravel-settings/zipball/8f3c602b6eb440fb4211d2aa028f879a779f037f", + "reference": "8f3c602b6eb440fb4211d2aa028f879a779f037f", + "shasum": "" + }, + "require": { + "illuminate/cache": "^4.2|^5|^6|^7|^8|^9|^10", + "illuminate/support": "^4.2|^5|^6|^7|^8|^9|^10" + }, + "require-dev": { + "laravel/framework": ">=5.7", + "mockery/mockery": "^1.2", + "phpunit/phpunit": "^8.0" + }, + "suggest": { + "illuminate/database": "Save settings to a database table.", + "illuminate/filesystem": "Save settings to a JSON file." + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Setting": "anlutro\\LaravelSettings\\Facade" + }, + "providers": [ + "anlutro\\LaravelSettings\\ServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "anlutro\\LaravelSettings\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Lutro", + "email": "anlutro@gmail.com" + } + ], + "description": "Persistent settings in Laravel.", + "support": { + "issues": "https://github.com/anlutro/laravel-settings/issues", + "source": "https://github.com/anlutro/laravel-settings/tree/v1.3.1" + }, + "time": "2023-03-27T09:47:32+00:00" + }, { "name": "brick/math", "version": "0.11.0", @@ -1041,6 +1104,53 @@ ], "time": "2021-10-07T12:57:01+00:00" }, + { + "name": "haruncpi/laravel-id-generator", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/haruncpi/laravel-id-generator.git", + "reference": "b227dc2391ea45e9d070f19d35dc0a5f7a8f4185" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/haruncpi/laravel-id-generator/zipball/b227dc2391ea45e9d070f19d35dc0a5f7a8f4185", + "reference": "b227dc2391ea45e9d070f19d35dc0a5f7a8f4185", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Haruncpi\\LaravelIdGenerator\\IdGeneratorServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Haruncpi\\LaravelIdGenerator\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "cc-by-4.0" + ], + "authors": [ + { + "name": "Md.Harun-Ur-Rashid", + "email": "harun.cox@gmail.com" + } + ], + "description": "Easy way to generate custom ID in laravel framework", + "support": { + "issues": "https://github.com/haruncpi/laravel-id-generator/issues", + "source": "https://github.com/haruncpi/laravel-id-generator/tree/v1.1.0" + }, + "time": "2021-10-01T06:16:03+00:00" + }, { "name": "jackiedo/log-reader", "version": "2.3.0", diff --git a/database/migrations/2023_04_17_135901_create_documents_table.php b/database/migrations/2023_04_17_135901_create_documents_table.php index f649507..77d6316 100644 --- a/database/migrations/2023_04_17_135901_create_documents_table.php +++ b/database/migrations/2023_04_17_135901_create_documents_table.php @@ -24,11 +24,13 @@ return new class extends Migration $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->foreignIdFor(SpecialCode::class)->nullable()->constrained()->onDelete('cascade'); + $table->string('no_urut',3)->nullable(); + $table->string('sequence',100)->nullable(); $table->string('kode', 15); $table->string('status')->nullable(); $table->string('keterangan')->nullable(); + $table->enum('jenis_dokumen',['nasabah','non nasabah'])->nullable(); $table->timestamps(); $table->softDeletes(); 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 index 6864e0d..1f57db8 100644 --- a/database/migrations/2023_04_17_135930_create_document_details_table.php +++ b/database/migrations/2023_04_17_135930_create_document_details_table.php @@ -16,7 +16,6 @@ return new class extends Migration $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(); @@ -24,7 +23,7 @@ return new class extends Migration $table->date('tanggal_upload')->nullable(); $table->date('tanggal_dokumen')->nullable(); - $table->string('no_dokumen')->nullable(); + $table->string('nomor_dokumen')->nullable(); $table->string('perihal')->nullable(); $table->string('kode_cabang')->nullable(); $table->string('jumlah_halaman')->nullable(); diff --git a/resources/views/layout/partials/sidebar-layout/_toolbar.blade.php b/resources/views/layout/partials/sidebar-layout/_toolbar.blade.php index 49d08aa..83c0990 100644 --- a/resources/views/layout/partials/sidebar-layout/_toolbar.blade.php +++ b/resources/views/layout/partials/sidebar-layout/_toolbar.blade.php @@ -8,6 +8,14 @@ @endphp @if(isset($route[1]) && $route[1] == 'index') + @if($route[0]=='document') +
+ + Add {{ str_replace('-',' ',$route[0]) }} + +
+ + @else
@@ -15,6 +23,7 @@
+ @endif @elseif(isset($route[2]) && $route[2] == 'index' && $route[0] == 'user') @if($route[1]!=='users') @@ -25,6 +34,7 @@ @else +
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 8ffe1ab..b021eb0 100644 --- a/resources/views/layout/partials/sidebar-layout/sidebar/_menu.blade.php +++ b/resources/views/layout/partials/sidebar-layout/sidebar/_menu.blade.php @@ -197,7 +197,7 @@