diff --git a/DataTables/CardboardDetailDataTable.php b/DataTables/CardboardDetailDataTable.php index 06d0815..a692530 100644 --- a/DataTables/CardboardDetailDataTable.php +++ b/DataTables/CardboardDetailDataTable.php @@ -4,7 +4,6 @@ use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Illuminate\Support\Facades\URL; - use Modules\Cetaklabel\Entities\Cardboard; use Modules\Cetaklabel\Entities\CardboardDetail; use Yajra\DataTables\EloquentDataTable; use Yajra\DataTables\Html\Builder as HtmlBuilder; diff --git a/DataTables/DirectoratDataTable.php b/DataTables/DirectoratDataTable.php index b1ad03b..7fd38c4 100644 --- a/DataTables/DirectoratDataTable.php +++ b/DataTables/DirectoratDataTable.php @@ -2,8 +2,11 @@ namespace Modules\Cetaklabel\DataTables; + use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder as QueryBuilder; + use Illuminate\Support\Facades\Auth; use Modules\Cetaklabel\Entities\Directorat; + use Modules\Usermanager\Entities\User; use Yajra\DataTables\EloquentDataTable; use Yajra\DataTables\Html\Builder as HtmlBuilder; use Yajra\DataTables\Html\Column; @@ -23,11 +26,27 @@ ->filter(function ($query) { if (request()->has('search')) { $search = request()->get('search'); + + if(Auth::user()->hasRole('otorisator')) { + $query->whereIn('status', [0, 4, 6, 9]); + } $query->where('kode', 'like', "%" . $search['value'] . "%") ->orWhere('name', 'like', "%" . $search['value'] . "%"); } }) ->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', 'cetaklabel::masters.directorat._status') ->addColumn('action', 'cetaklabel::masters.directorat._action') ->rawColumns(['status', 'action']) @@ -74,6 +93,10 @@ Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false), Column::make('kode'), Column::make('name'), + 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) diff --git a/DataTables/DocumentTypeDataTable.php b/DataTables/DocumentTypeDataTable.php index 5985af5..a432c9d 100644 --- a/DataTables/DocumentTypeDataTable.php +++ b/DataTables/DocumentTypeDataTable.php @@ -2,8 +2,10 @@ namespace Modules\Cetaklabel\DataTables; + use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Modules\Cetaklabel\Entities\DocumentType; + use Modules\Usermanager\Entities\User; use Yajra\DataTables\EloquentDataTable; use Yajra\DataTables\Html\Builder as HtmlBuilder; use Yajra\DataTables\Html\Column; @@ -28,7 +30,21 @@ } }) ->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', 'cetaklabel::masters.document-type._status') ->addColumn('action', 'cetaklabel::masters.document-type._action') + ->rawColumns(['status', 'action']) ->setRowId('id'); } @@ -72,11 +88,20 @@ Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false), Column::make('kode'), Column::make('name'), - Column::computed('action') + Column::make('craeted_at')->className('none'), + Column::make('created_by')->className('none'), + Column::make('approved_at')->className('none'), + Column::make('approved_by')->title('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'), ]; } diff --git a/DataTables/JobDataTable.php b/DataTables/JobDataTable.php index cfadfea..79dc251 100644 --- a/DataTables/JobDataTable.php +++ b/DataTables/JobDataTable.php @@ -2,8 +2,10 @@ namespace Modules\Cetaklabel\DataTables; + use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Modules\Cetaklabel\Entities\Job; + use Modules\Usermanager\Entities\User; use Yajra\DataTables\EloquentDataTable; use Yajra\DataTables\Html\Builder as HtmlBuilder; use Yajra\DataTables\Html\Column; @@ -36,7 +38,21 @@ ->addColumn('sub_directorat', function ($job) { return $job->sub_directorat->name; }) + ->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', 'cetaklabel::masters.directorat._status') ->addColumn('action', 'cetaklabel::masters.job._action') + ->rawColumns(['status', 'action']) ->setRowId('id'); } @@ -82,11 +98,20 @@ Column::make('sub_directorat'), Column::make('kode'), Column::make('name'), - Column::computed('action') + 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'), ]; } diff --git a/DataTables/SpecialCodeDataTable.php b/DataTables/SpecialCodeDataTable.php index 93a738b..1ded387 100644 --- a/DataTables/SpecialCodeDataTable.php +++ b/DataTables/SpecialCodeDataTable.php @@ -2,8 +2,10 @@ namespace Modules\Cetaklabel\DataTables; + use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Modules\Cetaklabel\Entities\SpecialCode; + use Modules\Usermanager\Entities\User; use Yajra\DataTables\EloquentDataTable; use Yajra\DataTables\Html\Builder as HtmlBuilder; use Yajra\DataTables\Html\Column; @@ -28,7 +30,21 @@ } }) ->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', 'cetaklabel::masters.directorat._status') ->addColumn('action', 'cetaklabel::masters.special-code._action') + ->rawColumns(['status', 'action']) ->setRowId('id'); } @@ -73,11 +89,20 @@ Column::make('kode'), Column::make('name'), Column::make('description'), - Column::computed('action') + Column::make('craeted_at')->className('none'), + Column::make('created_by')->className('none'), + Column::make('approved_at')->className('none'), + Column::make('approved_by')->title('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'), ]; } diff --git a/DataTables/SubDirectoratDataTable.php b/DataTables/SubDirectoratDataTable.php index fe62cdf..d67b68a 100644 --- a/DataTables/SubDirectoratDataTable.php +++ b/DataTables/SubDirectoratDataTable.php @@ -2,8 +2,10 @@ namespace Modules\Cetaklabel\DataTables; + use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Modules\Cetaklabel\Entities\SubDirectorat; + use Modules\Usermanager\Entities\User; use Yajra\DataTables\EloquentDataTable; use Yajra\DataTables\Html\Builder as HtmlBuilder; use Yajra\DataTables\Html\Column; @@ -32,7 +34,21 @@ ->addColumn('directorat', function ($subDirectorat) { return $subDirectorat->directorat->name; }) + ->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', 'cetaklabel::masters.directorat._status') ->addColumn('action', 'cetaklabel::masters.sub-directorat._action') + ->rawColumns(['status', 'action']) ->setRowId('id'); } @@ -77,11 +93,20 @@ Column::make('directorat'), Column::make('kode'), Column::make('name'), - Column::computed('action') + Column::make('craeted_at')->className('none'), + Column::make('created_by')->className('none'), + Column::make('approved_at')->className('none'), + Column::make('approved_by')->title('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'), ]; } diff --git a/DataTables/SubJobDataTable.php b/DataTables/SubJobDataTable.php index fc15f68..0f79edd 100644 --- a/DataTables/SubJobDataTable.php +++ b/DataTables/SubJobDataTable.php @@ -2,8 +2,10 @@ namespace Modules\Cetaklabel\DataTables; + use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Modules\Cetaklabel\Entities\SubJob; + use Modules\Usermanager\Entities\User; use Yajra\DataTables\EloquentDataTable; use Yajra\DataTables\Html\Builder as HtmlBuilder; use Yajra\DataTables\Html\Column; @@ -40,7 +42,21 @@ ->addColumn('job', function ($subJob) { return $subJob->job->name; }) + ->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', 'cetaklabel::masters.directorat._status') ->addColumn('action', 'cetaklabel::masters.sub-job._action') + ->rawColumns(['status', 'action']) ->setRowId('id'); } @@ -87,11 +103,20 @@ Column::make('job'), Column::make('kode'), Column::make('name'), - Column::computed('action') + Column::make('craeted_at')->className('none'), + Column::make('created_by')->className('none'), + Column::make('approved_at')->className('none'), + Column::make('approved_by')->title('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'), ]; } diff --git a/DataTables/SubSubJobDataTable.php b/DataTables/SubSubJobDataTable.php index 4331e94..d40c7ce 100644 --- a/DataTables/SubSubJobDataTable.php +++ b/DataTables/SubSubJobDataTable.php @@ -2,8 +2,10 @@ namespace Modules\Cetaklabel\DataTables; + use Carbon\Carbon; use Illuminate\Database\Eloquent\Builder as QueryBuilder; use Modules\Cetaklabel\Entities\SubSubJob; + use Modules\Usermanager\Entities\User; use Yajra\DataTables\EloquentDataTable; use Yajra\DataTables\Html\Builder as HtmlBuilder; use Yajra\DataTables\Html\Column; @@ -44,7 +46,21 @@ ->addColumn('sub_job', function ($subJob) { return $subJob->sub_job->name; }) + ->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', 'cetaklabel::masters.directorat._status') ->addColumn('action', 'cetaklabel::masters.sub-sub-job._action') + ->rawColumns(['status', 'action']) ->setRowId('id'); } @@ -92,11 +108,20 @@ Column::make('sub_job'), Column::make('kode'), Column::make('name'), - Column::computed('action') + Column::make('craeted_at')->className('none'), + Column::make('created_by')->className('none'), + Column::make('approved_at')->className('none'), + Column::make('approved_by')->title('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'), ]; } diff --git a/Entities/DocumentType.php b/Entities/DocumentType.php index 3402ad2..517c179 100644 --- a/Entities/DocumentType.php +++ b/Entities/DocumentType.php @@ -4,10 +4,7 @@ class DocumentType extends BaseModel { - protected $fillable = [ - 'kode', - 'name' - ]; + protected $fillable = ['kode', 'name', 'status', 'approved_by', 'approved_at']; public function document_detail() { diff --git a/Entities/Job.php b/Entities/Job.php index 89efa3a..2feafa2 100644 --- a/Entities/Job.php +++ b/Entities/Job.php @@ -5,12 +5,7 @@ class Job extends BaseModel { - protected $fillable = [ - 'directorat_id', - 'sub_directorat_id', - 'kode', - 'name' - ]; + protected $fillable = ['directorat_id', 'sub_directorat_id', 'kode', 'name', 'status', 'approved_by', 'approved_at']; public function directorat() diff --git a/Entities/SpecialCode.php b/Entities/SpecialCode.php index 599e526..37ff58b 100644 --- a/Entities/SpecialCode.php +++ b/Entities/SpecialCode.php @@ -7,8 +7,7 @@ protected $fillable = [ 'kode', 'name', - 'description' - ]; + 'description', 'status','approved_by','approved_at']; public function document() { diff --git a/Entities/SubDirectorat.php b/Entities/SubDirectorat.php index b3808aa..26241bf 100644 --- a/Entities/SubDirectorat.php +++ b/Entities/SubDirectorat.php @@ -7,8 +7,7 @@ protected $fillable = [ 'directorat_id', 'kode', - 'name' - ]; + 'name', 'status','approved_by','approved_at']; public function directorat() { diff --git a/Entities/SubJob.php b/Entities/SubJob.php index ea9c644..d4ddb7f 100644 --- a/Entities/SubJob.php +++ b/Entities/SubJob.php @@ -9,8 +9,7 @@ 'sub_directorat_id', 'job_id', 'kode', - 'name' - ]; + 'name', 'status','approved_by','approved_at']; public function directorat() diff --git a/Entities/SubSubJob.php b/Entities/SubSubJob.php index edc94a6..0fc48cd 100644 --- a/Entities/SubSubJob.php +++ b/Entities/SubSubJob.php @@ -10,8 +10,7 @@ 'job_id', 'sub_job_id', 'kode', - 'name' - ]; + 'name', 'status','approved_by','approved_at']; public function directorat() diff --git a/Http/Requests/Directorat/UpdateDirectoratRequest.php b/Http/Requests/Directorat/UpdateDirectoratRequest.php index be0ad8e..a20f350 100644 --- a/Http/Requests/Directorat/UpdateDirectoratRequest.php +++ b/Http/Requests/Directorat/UpdateDirectoratRequest.php @@ -68,11 +68,13 @@ protected function prepareForValidation() { - if (isset($this->approval) && $this->approval == 1) { - $this->merge([ - 'approved_at' => now(), - 'approved_by' => auth()->user()->id, - ]); + if(isset($this->status) && $this->status == 1) { + if (isset($this->approval) && $this->approval == 1) { + $this->merge([ + 'approved_at' => now(), + 'approved_by' => auth()->user()->id, + ]); + } } } } diff --git a/Http/Requests/DocumentType/UpdateDocumentTypeRequest.php b/Http/Requests/DocumentType/UpdateDocumentTypeRequest.php index 4b2b671..fb88945 100644 --- a/Http/Requests/DocumentType/UpdateDocumentTypeRequest.php +++ b/Http/Requests/DocumentType/UpdateDocumentTypeRequest.php @@ -28,8 +28,11 @@ : array { return [ - 'kode' => 'required|string|max:2|min:2|unique:document_types,kode,' . $this->document_type->id, - 'name' => 'required|string|max:50' + 'kode' => 'required|string|max:2|min:2|unique:document_types,kode,' . $this->document_type->id, + 'name' => 'required|string|max:50', + 'status' => 'nullable|integer', + 'approved_at' => 'nullable|date', + 'approved_by' => 'nullable|integer', ]; } @@ -62,4 +65,16 @@ 'messages' => 'Document Type updated failed.' ], JsonResponse::HTTP_UNPROCESSABLE_ENTITY)); } + + protected function prepareForValidation() + { + if(isset($this->status) && $this->status == 1) { + if (isset($this->approval) && $this->approval == 1) { + $this->merge([ + 'approved_at' => now(), + 'approved_by' => auth()->user()->id, + ]); + } + } + } } diff --git a/Http/Requests/Job/UpdateJobRequest.php b/Http/Requests/Job/UpdateJobRequest.php index 878d369..7afdf8e 100644 --- a/Http/Requests/Job/UpdateJobRequest.php +++ b/Http/Requests/Job/UpdateJobRequest.php @@ -31,7 +31,10 @@ 'directorat_id' => 'required|exists:directorats,id', 'sub_directorat_id' => 'required|exists:sub_directorats,id', 'kode' => 'required|string|max:2|min:2|unique:jobs,kode,' . $this->job->id, - 'name' => 'required|string|max:50' + 'name' => 'required|string|max:50', + 'status' => 'nullable|integer', + 'approved_at' => 'nullable|date', + 'approved_by' => 'nullable|integer', ]; } @@ -64,4 +67,16 @@ 'messages' => 'Job updated failed.' ], JsonResponse::HTTP_UNPROCESSABLE_ENTITY)); } + + protected function prepareForValidation() + { + if(isset($this->status) && $this->status == 1) { + if (isset($this->approval) && $this->approval == 1) { + $this->merge([ + 'approved_at' => now(), + 'approved_by' => auth()->user()->id, + ]); + } + } + } } diff --git a/Http/Requests/SpecialCode/UpdateSpecialCodeRequest.php b/Http/Requests/SpecialCode/UpdateSpecialCodeRequest.php index 81ae40e..353f6ec 100644 --- a/Http/Requests/SpecialCode/UpdateSpecialCodeRequest.php +++ b/Http/Requests/SpecialCode/UpdateSpecialCodeRequest.php @@ -30,7 +30,10 @@ return [ 'kode' => 'required|string|max:2|min:2|unique:special_codes,kode,' . $this->special_code->id, 'name' => 'required|string|max:50', - 'description' => 'nullable|string|max:255' + 'description' => 'nullable|string|max:255', + 'status' => 'nullable|integer', + 'approved_at' => 'nullable|date', + 'approved_by' => 'nullable|integer' ]; } @@ -63,4 +66,16 @@ 'messages' => 'Special Code updated failed.' ], JsonResponse::HTTP_UNPROCESSABLE_ENTITY)); } + + protected function prepareForValidation() + { + if(isset($this->status) && $this->status == 1) { + if (isset($this->approval) && $this->approval == 1) { + $this->merge([ + 'approved_at' => now(), + 'approved_by' => auth()->user()->id, + ]); + } + } + } } diff --git a/Http/Requests/SubDirectorat/UpdateSubDirectoratRequest.php b/Http/Requests/SubDirectorat/UpdateSubDirectoratRequest.php index 8a687f4..807e999 100644 --- a/Http/Requests/SubDirectorat/UpdateSubDirectoratRequest.php +++ b/Http/Requests/SubDirectorat/UpdateSubDirectoratRequest.php @@ -30,7 +30,10 @@ return [ 'directorat_id' => 'required|exists:directorats,id', 'kode' => 'required|string|max:2|min:2|unique:sub_directorats,kode,' . $this->sub_directorat->id, - 'name' => 'required|string|max:50' + 'name' => 'required|string|max:50', + 'status' => 'nullable|integer', + 'approved_at' => 'nullable|date', + 'approved_by' => 'nullable|integer' ]; } @@ -63,4 +66,16 @@ 'messages' => 'Sub Directorat updated failed.' ], JsonResponse::HTTP_UNPROCESSABLE_ENTITY)); } + + protected function prepareForValidation() + { + if(isset($this->status) && $this->status == 1) { + if (isset($this->approval) && $this->approval == 1) { + $this->merge([ + 'approved_at' => now(), + 'approved_by' => auth()->user()->id, + ]); + } + } + } } diff --git a/Http/Requests/SubJob/UpdateSubJobRequest.php b/Http/Requests/SubJob/UpdateSubJobRequest.php index 29e2374..dae24dc 100644 --- a/Http/Requests/SubJob/UpdateSubJobRequest.php +++ b/Http/Requests/SubJob/UpdateSubJobRequest.php @@ -32,7 +32,10 @@ 'sub_directorat_id' => 'required|exists:sub_directorats,id', 'job_id' => 'required|exists:jobs,id', 'kode' => 'required|string|max:2|min:2|unique:sub_jobs,kode,' . $this->sub_job->id, - 'name' => 'required|string|max:50' + 'name' => 'required|string|max:50', + 'status' => 'nullable|integer', + 'approved_at' => 'nullable|date', + 'approved_by' => 'nullable|integer' ]; } @@ -65,4 +68,16 @@ 'messages' => 'Sub Job updated failed.' ], JsonResponse::HTTP_UNPROCESSABLE_ENTITY)); } + + protected function prepareForValidation() + { + if(isset($this->status) && $this->status == 1) { + if (isset($this->approval) && $this->approval == 1) { + $this->merge([ + 'approved_at' => now(), + 'approved_by' => auth()->user()->id, + ]); + } + } + } } diff --git a/Http/Requests/SubSubJob/UpdateSubSubJobRequest.php b/Http/Requests/SubSubJob/UpdateSubSubJobRequest.php index 5f54214..e8dce6e 100644 --- a/Http/Requests/SubSubJob/UpdateSubSubJobRequest.php +++ b/Http/Requests/SubSubJob/UpdateSubSubJobRequest.php @@ -34,7 +34,10 @@ 'job_id' => 'required|exists:jobs,id', 'sub_job_id' => 'required|exists:sub_jobs,id', 'kode' => 'required|string|max:2|min:2|unique:sub_sub_jobs,kode,' . $this->sub_sub_job->id, - 'name' => 'required|string|max:50' + 'name' => 'required|string|max:50', + 'status' => 'nullable|integer', + 'approved_at' => 'nullable|date', + 'approved_by' => 'nullable|integer', ]; } @@ -67,4 +70,16 @@ 'messages' => 'Sub Sub Job updated failed.' ], JsonResponse::HTTP_UNPROCESSABLE_ENTITY)); } + + protected function prepareForValidation() + { + if(isset($this->status) && $this->status == 1) { + if (isset($this->approval) && $this->approval == 1) { + $this->merge([ + 'approved_at' => now(), + 'approved_by' => auth()->user()->id, + ]); + } + } + } } diff --git a/Resources/views/masters/directorat/_action.blade.php b/Resources/views/masters/directorat/_action.blade.php index 526458e..54321ae 100644 --- a/Resources/views/masters/directorat/_action.blade.php +++ b/Resources/views/masters/directorat/_action.blade.php @@ -3,7 +3,7 @@ @endphp @if( Auth::user()->hasRole('operator') || Auth::user()->hasRole('administrator'))
- {!! getIcon("pencil", "fs-1 text-info","duotune") !!} @@ -16,7 +16,6 @@ @if(Auth::user()->hasRole('otorisator')) @if($model->status == 0) - {!! Form::open(['method' => 'PUT','route' => [$route[0].'.update', $model->id],'class'=>'d-inline-block']) !!} diff --git a/Resources/views/masters/directorat/_status.blade.php b/Resources/views/masters/directorat/_status.blade.php index 6c9d948..87e5b32 100644 --- a/Resources/views/masters/directorat/_status.blade.php +++ b/Resources/views/masters/directorat/_status.blade.php @@ -12,4 +12,6 @@ Waiting Approval @elseif($model->status == 1) Approved +@elseif($model->status == 3) + Rejected @endif diff --git a/Resources/views/masters/document-type/_action.blade.php b/Resources/views/masters/document-type/_action.blade.php index 8b4035b..bc06d55 100644 --- a/Resources/views/masters/document-type/_action.blade.php +++ b/Resources/views/masters/document-type/_action.blade.php @@ -1,13 +1,45 @@ @php $route = explode('.', Route::currentRouteName()); @endphp -
- - {!! getIcon("pencil", "fs-1 text-info","duotune") !!} - +@if( Auth::user()->hasRole('operator')) +
+ + {!! 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() !!} -
+ {!! 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('otorisator')) + @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/masters/document-type/_status.blade.php b/Resources/views/masters/document-type/_status.blade.php new file mode 100644 index 0000000..87e5b32 --- /dev/null +++ b/Resources/views/masters/document-type/_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/masters/document-type/_table.blade.php b/Resources/views/masters/document-type/_table.blade.php index 0de5740..a7fa98c 100644 --- a/Resources/views/masters/document-type/_table.blade.php +++ b/Resources/views/masters/document-type/_table.blade.php @@ -100,6 +100,60 @@ } }); + } + }) + }); + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_approve_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Approve This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Approve it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }); + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_reject_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Reject This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Reject it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + } }) }) diff --git a/Resources/views/masters/job/_action.blade.php b/Resources/views/masters/job/_action.blade.php index 62ff4f3..7e825f1 100644 --- a/Resources/views/masters/job/_action.blade.php +++ b/Resources/views/masters/job/_action.blade.php @@ -1,13 +1,49 @@ @php $route = explode('.', Route::currentRouteName()); @endphp -
- - {!! getIcon("pencil", "fs-1 text-info","duotune") !!} - +@if( Auth::user()->hasRole('operator')) +
+ + {!! 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() !!} -
+ {!! 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('otorisator')) + @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/masters/job/_status.blade.php b/Resources/views/masters/job/_status.blade.php new file mode 100644 index 0000000..87e5b32 --- /dev/null +++ b/Resources/views/masters/job/_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/masters/job/_table.blade.php b/Resources/views/masters/job/_table.blade.php index a1623e0..1e83b9b 100644 --- a/Resources/views/masters/job/_table.blade.php +++ b/Resources/views/masters/job/_table.blade.php @@ -104,6 +104,60 @@ } }) }) + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_approve_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Approve This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Approve it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }); + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_reject_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Reject This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Reject it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }) + }) @endpush diff --git a/Resources/views/masters/special-code/_action.blade.php b/Resources/views/masters/special-code/_action.blade.php index 226de56..bc06d55 100644 --- a/Resources/views/masters/special-code/_action.blade.php +++ b/Resources/views/masters/special-code/_action.blade.php @@ -1,13 +1,45 @@ @php $route = explode('.', Route::currentRouteName()); @endphp -
- - {!! getIcon("pencil", "fs-1 text-info","duotune") !!} - +@if( Auth::user()->hasRole('operator')) +
+ + {!! 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() !!} -
+ {!! 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('otorisator')) + @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/masters/special-code/_status.blade.php b/Resources/views/masters/special-code/_status.blade.php new file mode 100644 index 0000000..87e5b32 --- /dev/null +++ b/Resources/views/masters/special-code/_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/masters/special-code/_table.blade.php b/Resources/views/masters/special-code/_table.blade.php index 2a55bac..ed5a51a 100644 --- a/Resources/views/masters/special-code/_table.blade.php +++ b/Resources/views/masters/special-code/_table.blade.php @@ -104,6 +104,60 @@ } }) }) + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_approve_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Approve This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Approve it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }); + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_reject_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Reject This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Reject it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }) }) @endpush diff --git a/Resources/views/masters/sub-directorat/_action.blade.php b/Resources/views/masters/sub-directorat/_action.blade.php index 51064cf..87581a8 100644 --- a/Resources/views/masters/sub-directorat/_action.blade.php +++ b/Resources/views/masters/sub-directorat/_action.blade.php @@ -1,13 +1,47 @@ @php $route = explode('.', Route::currentRouteName()); @endphp -
- - {!! getIcon("pencil", "fs-1 text-info","duotune") !!} - +@if( Auth::user()->hasRole('operator')) +
+ + {!! 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() !!} -
+ {!! 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('otorisator')) + @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/masters/sub-directorat/_status.blade.php b/Resources/views/masters/sub-directorat/_status.blade.php new file mode 100644 index 0000000..87e5b32 --- /dev/null +++ b/Resources/views/masters/sub-directorat/_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/masters/sub-directorat/_table.blade.php b/Resources/views/masters/sub-directorat/_table.blade.php index b63a967..2dfc76e 100644 --- a/Resources/views/masters/sub-directorat/_table.blade.php +++ b/Resources/views/masters/sub-directorat/_table.blade.php @@ -104,6 +104,60 @@ } }) }) + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_approve_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Approve This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Approve it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }); + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_reject_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Reject This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Reject it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }) }) @endpush diff --git a/Resources/views/masters/sub-job/_action.blade.php b/Resources/views/masters/sub-job/_action.blade.php index 8eee214..ca645c7 100644 --- a/Resources/views/masters/sub-job/_action.blade.php +++ b/Resources/views/masters/sub-job/_action.blade.php @@ -1,13 +1,51 @@ @php $route = explode('.', Route::currentRouteName()); @endphp -
- - {!! getIcon("pencil", "fs-1 text-info","duotune") !!} - +@if( Auth::user()->hasRole('operator')) +
+ + {!! 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() !!} -
+ {!! 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('otorisator')) + @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/masters/sub-job/_status.blade.php b/Resources/views/masters/sub-job/_status.blade.php new file mode 100644 index 0000000..87e5b32 --- /dev/null +++ b/Resources/views/masters/sub-job/_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/masters/sub-job/_table.blade.php b/Resources/views/masters/sub-job/_table.blade.php index a427b0f..779a0a3 100644 --- a/Resources/views/masters/sub-job/_table.blade.php +++ b/Resources/views/masters/sub-job/_table.blade.php @@ -105,6 +105,60 @@ } }) }) + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_approve_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Approve This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Approve it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }); + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_reject_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Reject This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Reject it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }) }) @endpush diff --git a/Resources/views/masters/sub-sub-job/_action.blade.php b/Resources/views/masters/sub-sub-job/_action.blade.php index 214f9a2..d4fbd69 100644 --- a/Resources/views/masters/sub-sub-job/_action.blade.php +++ b/Resources/views/masters/sub-sub-job/_action.blade.php @@ -1,13 +1,53 @@ @php $route = explode('.', Route::currentRouteName()); @endphp -
- - {!! getIcon("pencil", "fs-1 text-info","duotune") !!} - +@if( Auth::user()->hasRole('operator')) +
+ + {!! 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() !!} -
+ {!! 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('otorisator')) + @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/masters/sub-sub-job/_status.blade.php b/Resources/views/masters/sub-sub-job/_status.blade.php new file mode 100644 index 0000000..87e5b32 --- /dev/null +++ b/Resources/views/masters/sub-sub-job/_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/masters/sub-sub-job/_table.blade.php b/Resources/views/masters/sub-sub-job/_table.blade.php index fe89e4c..f48d11e 100644 --- a/Resources/views/masters/sub-sub-job/_table.blade.php +++ b/Resources/views/masters/sub-sub-job/_table.blade.php @@ -106,6 +106,60 @@ } }) }) + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_approve_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Approve This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Approve it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }); + + LaravelDataTables["{{$route[0]}}-table"].on('click', '.kt_reject_form', function (event) { + var form = $(this).closest("form"); + event.preventDefault(); + Swal.fire({ + title: 'Are you sure?', + text: "Reject This Data!", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Yes, Reject it!' + }).then((result) => { + if (result.isConfirmed) { + $.ajax({ + type: "POST", + url: form.attr('action'), + data: form.serialize(), // serializes the form's elements. + success: function (data) { + toastr.success('{{ucfirst($route[0])}} has been deleted.', 'Success!', {timeOut: 5000}); + LaravelDataTables["{{$route[0]}}-table"].ajax.reload(); + } + }); + + } + }) + }) }) @endpush