From 79e32e20476e09e5e95ad338bbfaeec0d81f577c Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Fri, 21 Jul 2023 16:37:19 +0700 Subject: [PATCH] update from dell --- DataTables/ApprovalDataTable.php | 119 ++++++++++++ ...23_07_06_130223_create_approvals_table.php | 44 +++++ Entities/Approval.php | 25 +++ Http/Controllers/ApprovalController.php | 90 +++++++++ Http/Controllers/ReportController.php | 120 ++++++++++++ .../views/app/approval/_action.blade.php | 45 +++++ Resources/views/app/approval/_form.blade.php | 70 +++++++ .../views/app/approval/_status.blade.php | 17 ++ Resources/views/app/approval/_table.blade.php | 175 ++++++++++++++++++ Resources/views/app/approval/index.blade.php | 143 ++++++++++++++ Resources/views/app/report/_form.blade.php | 106 +++++++++++ Resources/views/app/report/index.blade.php | 27 +++ 12 files changed, 981 insertions(+) create mode 100644 DataTables/ApprovalDataTable.php create mode 100644 Database/Migrations/2023_07_06_130223_create_approvals_table.php create mode 100644 Entities/Approval.php create mode 100644 Http/Controllers/ApprovalController.php create mode 100644 Http/Controllers/ReportController.php create mode 100644 Resources/views/app/approval/_action.blade.php create mode 100644 Resources/views/app/approval/_form.blade.php create mode 100644 Resources/views/app/approval/_status.blade.php create mode 100644 Resources/views/app/approval/_table.blade.php create mode 100644 Resources/views/app/approval/index.blade.php create mode 100644 Resources/views/app/report/_form.blade.php create mode 100644 Resources/views/app/report/index.blade.php diff --git a/DataTables/ApprovalDataTable.php b/DataTables/ApprovalDataTable.php new file mode 100644 index 0000000..7bec4a1 --- /dev/null +++ b/DataTables/ApprovalDataTable.php @@ -0,0 +1,119 @@ +filter(function ($query) { + if (request()->has('search')) { + $search = request()->get('search'); + } + }) + ->addIndexColumn() + ->addColumn('craeted_at', function ($model) { + return $model->created_at !== null ? Carbon::parse($model->created_at)->format('d F Y H:i:s') : '-'; + }) + ->addColumn('created_by', function ($model) { + return $model->created_by ? $model->creator->name : '-'; + }) + ->addColumn('approved_at', function ($model) { + return $model->approved_at !== null ? Carbon::parse($model->approved_at)->format('d F Y H:i:s') : '-'; + }) + ->addColumn('approved_by', function ($model) { + return $model->approved_by ? User::find($model->approved_by)->name : '-'; + }) + ->addColumn('status', function ($model) { + return $this->render('cetaklabel::app.approval._status', compact('model')); + }) + ->addColumn('action', function ($model) { + return $this->render('cetaklabel::app.approval._action', compact('model')); + }) + ->rawColumns(['status', 'action']) + ->setRowId('id'); + } + + /** + * Get the query source of dataTable. + */ + public function query(Approval $model) + : QueryBuilder + { + return $model->newQuery(); + } + + /** + * Optional method if you want to use the html builder. + */ + public function html() + : HtmlBuilder + { + return $this->builder() + ->setTableId('approval-table') + ->columns($this->getColumns()) + ->minifiedAjax() + ->stateSave(false) + ->responsive() + ->autoWidth(true) + ->orderBy(1) + ->parameters([ + 'scrollX' => false, + '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('method'), + Column::make('menu'), + Column::make('description'), + Column::make('craeted_at')->className('none'), + Column::make('created_by')->className('none'), + Column::make('approved_at')->className('none'), + Column::make('approved_by')->className('none'), + Column::computed('status') + ->exportable(false) + ->printable(false) + ->width(60) + ->addClass('text-center'), + Column::computed('action') + ->exportable(false) + ->printable(false) + ->width(250) + ->addClass('text-center'), + ]; + } + + /** + * Get the filename for export. + */ + protected function filename() + : string + { + return 'Approval_' . date('YmdHis'); + } + } diff --git a/Database/Migrations/2023_07_06_130223_create_approvals_table.php b/Database/Migrations/2023_07_06_130223_create_approvals_table.php new file mode 100644 index 0000000..0376d84 --- /dev/null +++ b/Database/Migrations/2023_07_06_130223_create_approvals_table.php @@ -0,0 +1,44 @@ +id(); + $table->string("method", 50); + $table->string('model', 50); + $table->json('new_request')->nullable(); + $table->json('old_request')->nullable(); + $table->string("description", 255)->nullable(); + $table->string('status', 1)->default(0)->nullable(); + $table->timestamps(); + $table->timestamp('approved_at')->nullable(); + $table->softDeletes(); + + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + $table->unsignedBigInteger('approved_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('approvals'); + } +}; diff --git a/Entities/Approval.php b/Entities/Approval.php new file mode 100644 index 0000000..eac7aef --- /dev/null +++ b/Entities/Approval.php @@ -0,0 +1,25 @@ +belongsTo(User::class, 'created_by'); + } + } diff --git a/Http/Controllers/ApprovalController.php b/Http/Controllers/ApprovalController.php new file mode 100644 index 0000000..d9b1c79 --- /dev/null +++ b/Http/Controllers/ApprovalController.php @@ -0,0 +1,90 @@ +middleware(function ($request, $next) { + $this->user = Auth::guard('web')->user(); + return $next($request); + }); + } + + /** + * Display a listing of the resource. + * @return Renderable + */ + public function index(ApprovalDataTable $dataTable) + { + return $dataTable->render('cetaklabel::app.approval.index'); + } + + /** + * Show the form for creating a new resource. + * @return Renderable + */ + public function create() + { + return view('cetaklabel::create'); + } + + /** + * Store a newly created resource in storage. + * @param Request $request + * @return Renderable + */ + public function store(Request $request) + { + // + } + + /** + * Show the specified resource. + * @param int $id + * @return Renderable + */ + public function show($id) + { + return view('cetaklabel::show'); + } + + /** + * Show the form for editing the specified resource. + * @param int $id + * @return Renderable + */ + public function edit($id) + { + return view('cetaklabel::edit'); + } + + /** + * Update the specified resource in storage. + * @param Request $request + * @param int $id + * @return Renderable + */ + public function update(Request $request, $id) + { + // + } + + /** + * Remove the specified resource from storage. + * @param int $id + * @return Renderable + */ + public function destroy($id) + { + // + } +} diff --git a/Http/Controllers/ReportController.php b/Http/Controllers/ReportController.php new file mode 100644 index 0000000..6103da6 --- /dev/null +++ b/Http/Controllers/ReportController.php @@ -0,0 +1,120 @@ +middleware(function ($request, $next) { + $this->user = Auth::guard('web')->user(); + return $next($request); + }); + } + + public function _index(CardboardDataTable $datatable){ + addVendor('chained-select'); + $directorats = Directorat::all(); + + return $datatable->render('cetaklabel::app.cardboard.index', compact('directorats')); + } + + /** + * Display a listing of the resource. + * + * @return Renderable + */ + public function index() + { + addVendor('chained-select'); + if (Auth::user()->hasRole(['ad', 'administrator'])) { + + $directorat = Directorat::all(); + return view('cetaklabel::app.report.index', compact('directorat')); + } else if (Auth::user()->hasRole(['dd'])) { + $sub_directorat = SubDirectorat::all(); + return view('cetaklabel::app.report.index', compact('sub_directorat')); + } + + return view('cetaklabel::app.report.index'); + } + + /** + * Show the form for creating a new resource. + * + * @return Renderable + */ + public function create() + { + return view('cetaklabel::create'); + } + + /** + * Store a newly created resource in storage. + * + * @param Request $request + * + * @return Renderable + */ + public function store(Request $request) + { + // + } + + /** + * Show the specified resource. + * + * @param int $id + * + * @return Renderable + */ + public function show($id) + { + return view('cetaklabel::show'); + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * + * @return Renderable + */ + public function edit($id) + { + return view('cetaklabel::edit'); + } + + /** + * Update the specified resource in storage. + * + * @param Request $request + * @param int $id + * + * @return Renderable + */ + public function update(Request $request, $id) + { + // + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * + * @return Renderable + */ + public function destroy($id) + { + // + } + } diff --git a/Resources/views/app/approval/_action.blade.php b/Resources/views/app/approval/_action.blade.php new file mode 100644 index 0000000..30d503f --- /dev/null +++ b/Resources/views/app/approval/_action.blade.php @@ -0,0 +1,45 @@ +@php + $route = explode('.', Route::currentRouteName()); +@endphp +@if( Auth::user()->hasRole('ad') || Auth::user()->hasRole('administrator')) +
+ + {!! getIcon("pencil", "fs-1 text-info","duotune") !!} + + + {!! Form::open(['method' => 'DELETE','route' => [$route[0].'.destroy', $model->id],'class'=>'']) !!} + {{ Form::button(getIcon("trash", "fs-1 text-danger","duotune"), ['type' => 'submit', 'class' => 'delete btn btn-icon btn-bg-light btn-active-light-danger btn-sm'] ) }} + {!! Form::close() !!} +
+@endif + +@if(Auth::user()->hasRole('dd')) + @if($model->status == 0) + {!! Form::open(['method' => 'PUT','route' => [$route[0].'.update', $model->id],'class'=>'d-inline-block']) !!} + + + + + + {!! Form::close() !!} + + {!! Form::open(['method' => 'PUT','route' => [$route[0].'.update', $model->id],'class'=>'d-inline-block']) !!} + + + + + + {!! Form::close() !!} + @endif +@endif diff --git a/Resources/views/app/approval/_form.blade.php b/Resources/views/app/approval/_form.blade.php new file mode 100644 index 0000000..05a0f80 --- /dev/null +++ b/Resources/views/app/approval/_form.blade.php @@ -0,0 +1,70 @@ +@php + $route = explode('.', Route::currentRouteName()); +@endphp + + + + diff --git a/Resources/views/app/approval/_status.blade.php b/Resources/views/app/approval/_status.blade.php new file mode 100644 index 0000000..87e5b32 --- /dev/null +++ b/Resources/views/app/approval/_status.blade.php @@ -0,0 +1,17 @@ +{{-- +New +New +New +New +New +New +New--}} + + +@if($model->status == 0) + Waiting Approval +@elseif($model->status == 1) + Approved +@elseif($model->status == 3) + Rejected +@endif diff --git a/Resources/views/app/approval/_table.blade.php b/Resources/views/app/approval/_table.blade.php new file mode 100644 index 0000000..60a77c5 --- /dev/null +++ b/Resources/views/app/approval/_table.blade.php @@ -0,0 +1,175 @@ + +{{ $dataTable->table() }} + + +{{-- Inject Scripts --}} +@section('scripts') + {{ $dataTable->scripts() }} +@endsection + +@push('customscript') + @php + $route = explode('.', Route::currentRouteName()); + @endphp + + +@endpush + +@section('styles') + +@endsection diff --git a/Resources/views/app/approval/index.blade.php b/Resources/views/app/approval/index.blade.php new file mode 100644 index 0000000..216e406 --- /dev/null +++ b/Resources/views/app/approval/index.blade.php @@ -0,0 +1,143 @@ + + +
+ +
+
+
+ + + + + + + + + +
+ + +
+ + +
+ +
+ + + + + + + +
+ + +
+
+
+ @include('cetaklabel::app.approval._table') + @include('cetaklabel::app.approval._form') +
+ +
+ + @push('customscript') + + @endpush +
diff --git a/Resources/views/app/report/_form.blade.php b/Resources/views/app/report/_form.blade.php new file mode 100644 index 0000000..d67e914 --- /dev/null +++ b/Resources/views/app/report/_form.blade.php @@ -0,0 +1,106 @@ +@php + $route = explode('.', Route::currentRouteName()); +@endphp + +
+
+ @csrf + +
+ @if(Auth::user()->hasRole(['ad','administrator'])) + +
+ + + + +
+ + + +
+ + + + +
+ + @endif + + @if(Auth::user()->hasRole(['dd'])) + +
+ + + + +
+ + @endif + + +
+ + + + +
+ + + +
+ + + +
+  s.d.  +
+
+ +
+ + +
+ + +
+ +
+
+ + diff --git a/Resources/views/app/report/index.blade.php b/Resources/views/app/report/index.blade.php new file mode 100644 index 0000000..4ea366c --- /dev/null +++ b/Resources/views/app/report/index.blade.php @@ -0,0 +1,27 @@ + + +
+ +
+

+ Setting Parameter +

+
+
+ @include('cetaklabel::app.report._form') +
+ +
+ + + @push('customscript') + + @endpush +