update modeule directorat
This commit is contained in:
parent
8fe5096964
commit
7aa17c2d3c
@ -26,15 +26,15 @@ class DirectoratDataTable extends DataTable
|
||||
if (request()->has('search')) {
|
||||
$search = request()->get('search');
|
||||
$query->where('kode', 'like', "%" . $search['value'] . "%")
|
||||
->orWhere('nama', 'like', "%" . $search['value'] . "%");
|
||||
->orWhere('name', 'like', "%" . $search['value'] . "%");
|
||||
}
|
||||
})
|
||||
->addIndexColumn()
|
||||
->addColumn('kode', function ($model) {
|
||||
return $model->kode;
|
||||
})
|
||||
->addColumn('nama', function ($model) {
|
||||
return $model->nama;
|
||||
->addColumn('name', function ($model) {
|
||||
return $model->name;
|
||||
})
|
||||
->addColumn('action', 'pages.masters.directorat._action')
|
||||
->setRowId('id');
|
||||
@ -57,15 +57,10 @@ class DirectoratDataTable extends DataTable
|
||||
->setTableId('directorat-table')
|
||||
->columns($this->getColumns())
|
||||
->minifiedAjax()
|
||||
->stateSave(false)
|
||||
->responsive()
|
||||
->autoWidth(true)
|
||||
->orderBy(1)
|
||||
->selectStyleSingle()
|
||||
->buttons([
|
||||
Button::make('excel'),
|
||||
Button::make('csv'),
|
||||
Button::make('pdf'),
|
||||
Button::make('print'),
|
||||
Button::make('reload')
|
||||
])
|
||||
->parameters([
|
||||
'scrollX' => true,
|
||||
'drawCallback' => 'function() { KTMenu.createInstances(); }',
|
||||
@ -81,7 +76,7 @@ class DirectoratDataTable extends DataTable
|
||||
return [
|
||||
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
|
||||
Column::make('kode'),
|
||||
Column::make('nama'),
|
||||
Column::make('name'),
|
||||
Column::make('created_at'),
|
||||
Column::make('updated_at'),
|
||||
Column::computed('action')
|
||||
|
@ -35,13 +35,7 @@ class DirectoratController extends Controller
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
/*if (is_null($this->user) || !$this->user->can('masters.create')) {
|
||||
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
|
||||
}*/
|
||||
return view('pages.masters.directorat.create');
|
||||
}
|
||||
public function create(){}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
@ -52,6 +46,7 @@ class DirectoratController extends Controller
|
||||
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
|
||||
}*/
|
||||
|
||||
|
||||
// Validate the request...
|
||||
$validated = $request->validated();
|
||||
|
||||
@ -59,9 +54,11 @@ class DirectoratController extends Controller
|
||||
if($validated){
|
||||
try{
|
||||
Directorat::create($validated);
|
||||
return redirect()->route('directorat.index')->with('success', 'Directorat created successfully.');
|
||||
//return redirect()->route('directorat.index')->with('success', 'Directorat created successfully.');
|
||||
echo json_encode(['status' => 'success', 'message' => 'Directorat created successfully.']);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->route('directorat.index')->with('error', 'Directorat created failed.');
|
||||
//return redirect()->route('directorat.index')->with('error', 'Directorat created failed.');
|
||||
echo json_encode(['status' => 'error', 'message' => 'Directorat created failed.']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,10 +76,9 @@ class DirectoratController extends Controller
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
public function edit($id){
|
||||
$directorat = Directorat::find($id);
|
||||
return view('pages.masters.directorat.edit', compact('directorat'));
|
||||
echo json_encode($directorat);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,9 +97,11 @@ class DirectoratController extends Controller
|
||||
if($validated){
|
||||
try{
|
||||
$directorat->update($validated);
|
||||
return redirect()->route('directorat.index')->with('success', 'Directorat updated successfully.');
|
||||
//return redirect()->route('directorat.index')->with('success', 'Directorat updated successfully.');
|
||||
echo json_encode(['status' => 'success', 'message' => 'Directorat updated successfully.']);
|
||||
}catch(\Exception $e){
|
||||
return redirect()->route('directorat.index')->with('error', 'Directorat updated failed.');
|
||||
//return redirect()->route('directorat.index')->with('error', 'Directorat updated failed.');
|
||||
echo json_encode(['status' => 'error', 'message' => 'Directorat updated failed.']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class StoreDirectoratRequest extends FormRequest
|
||||
{
|
||||
@ -11,7 +12,7 @@ class StoreDirectoratRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -22,7 +23,25 @@ class StoreDirectoratRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'kode' => 'required|string|max:2|min:2|unique:directorats,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('directorat.index')->with('error', 'Directorat created failed.');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
class UpdateDirectoratRequest extends FormRequest
|
||||
{
|
||||
@ -11,7 +12,7 @@ class UpdateDirectoratRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -22,7 +23,25 @@ class UpdateDirectoratRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'kode' => 'required|string|max:2|min:2|unique:directorats,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('directorat.index')->with('error', 'Directorat updated failed.');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ class Directorat extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'kode',
|
||||
'nama'
|
||||
'name'
|
||||
];
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
|
@ -7,9 +7,11 @@
|
||||
"require": {
|
||||
"php": "^8.0.2",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"laracasts/flash": "^3.2",
|
||||
"laravel/framework": "^10.0",
|
||||
"laravel/sanctum": "^3.0",
|
||||
"laravel/tinker": "^2.7",
|
||||
"laravelcollective/html": "^6.4",
|
||||
"spatie/laravel-activitylog": "^4.7",
|
||||
"yajra/laravel-datatables": "^10.0",
|
||||
"yajra/laravel-datatables-oracle": "^10.3.1"
|
||||
|
131
composer.lock
generated
131
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "13056cf887653c387f2ff134ce499ad0",
|
||||
"content-hash": "b9f7e562d6d509796b8064720f017880",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
@ -1041,6 +1041,63 @@
|
||||
],
|
||||
"time": "2021-10-07T12:57:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laracasts/flash",
|
||||
"version": "3.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laracasts/flash.git",
|
||||
"reference": "6330bc3c027d3c03188b41c58133016f8226b8fb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laracasts/flash/zipball/6330bc3c027d3c03188b41c58133016f8226b8fb",
|
||||
"reference": "6330bc3c027d3c03188b41c58133016f8226b8fb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/support": "~5.0|^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "dev-master",
|
||||
"phpunit/phpunit": "^6.1|^9.5.10"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Laracasts\\Flash\\FlashServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Flash": "Laracasts\\Flash\\Flash"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Laracasts/Flash/functions.php"
|
||||
],
|
||||
"psr-0": {
|
||||
"Laracasts\\Flash": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeffrey Way",
|
||||
"email": "jeffrey@laracasts.com"
|
||||
}
|
||||
],
|
||||
"description": "Easy flash notifications",
|
||||
"support": {
|
||||
"source": "https://github.com/laracasts/flash/tree/3.2.2"
|
||||
},
|
||||
"time": "2023-01-30T20:31:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v10.7.1",
|
||||
@ -1434,6 +1491,78 @@
|
||||
},
|
||||
"time": "2023-02-15T16:40:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravelcollective/html",
|
||||
"version": "v6.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/LaravelCollective/html.git",
|
||||
"reference": "ac74f580459a5120079b8def0404e5d312a09504"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/LaravelCollective/html/zipball/ac74f580459a5120079b8def0404e5d312a09504",
|
||||
"reference": "ac74f580459a5120079b8def0404e5d312a09504",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/http": "^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||
"illuminate/routing": "^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||
"illuminate/session": "^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||
"illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||
"illuminate/view": "^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||
"php": ">=7.2.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/database": "^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||
"mockery/mockery": "~1.0",
|
||||
"phpunit/phpunit": "~8.5|^9.5.10"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "6.x-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Collective\\Html\\HtmlServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Form": "Collective\\Html\\FormFacade",
|
||||
"Html": "Collective\\Html\\HtmlFacade"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Collective\\Html\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Adam Engebretson",
|
||||
"email": "adam@laravelcollective.com"
|
||||
},
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "HTML and Form Builders for the Laravel Framework",
|
||||
"homepage": "https://laravelcollective.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/LaravelCollective/html/issues",
|
||||
"source": "https://github.com/LaravelCollective/html"
|
||||
},
|
||||
"time": "2023-02-13T18:15:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/commonmark",
|
||||
"version": "2.4.0",
|
||||
|
@ -181,7 +181,6 @@ return [
|
||||
Illuminate\Translation\TranslationServiceProvider::class,
|
||||
Illuminate\Validation\ValidationServiceProvider::class,
|
||||
Illuminate\View\ViewServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Package Service Providers...
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ return new class extends Migration
|
||||
Schema::create('directorats', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('kode',2);
|
||||
$table->string('nama',50);
|
||||
$table->string('name',50);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
@ -13,9 +13,9 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('sub_directorats', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('directorate_id');
|
||||
$table->foreignId('directorat_id');
|
||||
$table->string('kode',2);
|
||||
$table->string('nama',50);
|
||||
$table->string('name',50);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
@ -13,9 +13,9 @@ return new class extends Migration
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('sub_directorate_id');
|
||||
$table->foreignId('sub_directorat_id');
|
||||
$table->string('kode',2);
|
||||
$table->string('nama',50);
|
||||
$table->string('name',50);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
@ -15,7 +15,7 @@ return new class extends Migration
|
||||
$table->id();
|
||||
$table->foreignId('job_id');
|
||||
$table->string('kode',2);
|
||||
$table->string('nama',50);
|
||||
$table->string('name',50);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
|
@ -70,6 +70,22 @@
|
||||
<!--end::Javascript-->
|
||||
@yield('scripts')
|
||||
@stack('customscript')
|
||||
|
||||
<script>
|
||||
@if(Session::has('success'))
|
||||
toastr.success("{{ Session::get('success') }}");
|
||||
@endif
|
||||
|
||||
@if(Session::has('error'))
|
||||
toastr.error("{{ Session::get('error') }}");
|
||||
@endif
|
||||
|
||||
@if($errors->any())
|
||||
@foreach($errors->all() as $error)
|
||||
toastr.error("{{ $error }}");
|
||||
@endforeach
|
||||
@endif
|
||||
</script>
|
||||
</body>
|
||||
<!--end::Body-->
|
||||
|
||||
|
@ -1,13 +1,17 @@
|
||||
<!--begin::Page title-->
|
||||
<div class="page-title d-flex flex-column justify-content-center flex-wrap me-3">
|
||||
@php
|
||||
$route = explode('.',Route::currentRouteName());
|
||||
@endphp
|
||||
|
||||
<!--begin::Title-->
|
||||
<h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0">Multipurpose</h1>
|
||||
<h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0 text-capitalize">List {{ $route[0] }}</h1>
|
||||
<!--end::Title-->
|
||||
<!--begin::Breadcrumb-->
|
||||
<ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1">
|
||||
<!--begin::Item-->
|
||||
<li class="breadcrumb-item text-muted">
|
||||
<a href="/" class="text-muted text-hover-primary">Home</a>
|
||||
<a href="{{ route('dashboard') }}" class="text-muted text-hover-primary">Home</a>
|
||||
</li>
|
||||
<!--end::Item-->
|
||||
<!--begin::Item-->
|
||||
@ -16,7 +20,7 @@
|
||||
</li>
|
||||
<!--end::Item-->
|
||||
<!--begin::Item-->
|
||||
<li class="breadcrumb-item text-muted">Dashboards</li>
|
||||
<li class="breadcrumb-item text-muted text-capitalize">{{ $route[0] }}</li>
|
||||
<!--end::Item-->
|
||||
</ul>
|
||||
<!--end::Breadcrumb-->
|
||||
|
@ -3,16 +3,19 @@
|
||||
<!--begin::Toolbar container-->
|
||||
<div id="kt_app_toolbar_container" class="app-container container-fluid d-flex flex-stack">
|
||||
@include(config('settings.KT_THEME_LAYOUT_DIR').'/partials/sidebar-layout/_page-title')
|
||||
<!--begin::Actions-->
|
||||
<div class="d-flex align-items-center gap-2 gap-lg-3">
|
||||
<!--begin::Secondary button-->
|
||||
<a href="#" class="btn btn-sm fw-bold bg-body btn-color-gray-700 btn-active-color-primary" data-bs-toggle="modal" data-bs-target="#kt_modal_create_app">Rollover</a>
|
||||
<!--end::Secondary button-->
|
||||
@php
|
||||
$route = explode('.',Route::currentRouteName());
|
||||
@endphp
|
||||
|
||||
@if($route[1] == 'index')
|
||||
<!--begin::Actions-->
|
||||
<div class="d-flex align-items-center gap-2 gap-lg-3">
|
||||
<!--begin::Primary button-->
|
||||
<a href="#" class="btn btn-sm fw-bold btn-primary" data-bs-toggle="modal" data-bs-target="#kt_modal_new_target">Add Target</a>
|
||||
<a href="{{ route($route[0].'.create') }}" class="btn btn-sm fw-bold btn-primary text-capitalize" data-bs-toggle="modal" data-bs-target="#kt_modal_{{ $route[0] }}">Add {{ $route[0] }}</a>
|
||||
<!--end::Primary button-->
|
||||
</div>
|
||||
<!--end::Actions-->
|
||||
@endif
|
||||
</div>
|
||||
<!--end::Toolbar container-->
|
||||
</div>
|
||||
|
@ -0,0 +1,13 @@
|
||||
@php
|
||||
$route = explode('.', Route::currentRouteName());
|
||||
@endphp
|
||||
<div class="d-flex flex-row flex-center">
|
||||
<a href="{{ route($route[0].'.edit',['directorat' => $model->id]) }}"
|
||||
class="kt_edit_form btn btn-icon btn-bg-light btn-active-light-primary btn-sm me-1">
|
||||
{!! getIcon("pencil", "fs-1 text-info","duotune") !!}
|
||||
</a>
|
||||
|
||||
{!! 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() !!}
|
||||
</div>
|
70
resources/views/pages/masters/directorat/_form.blade.php
Normal file
70
resources/views/pages/masters/directorat/_form.blade.php
Normal file
@ -0,0 +1,70 @@
|
||||
@php
|
||||
$route = explode('.', Route::currentRouteName());
|
||||
@endphp
|
||||
|
||||
<!--begin::Modal - New Target-->
|
||||
<div class="modal fade" id="kt_modal_directorat" tabindex="-1" aria-hidden="true">
|
||||
<!--begin::Modal dialog-->
|
||||
<div class="modal-dialog modal-dialog-centered mw-650px">
|
||||
<!--begin::Modal content-->
|
||||
<div class="modal-content rounded">
|
||||
<!--begin::Modal header-->
|
||||
<div class="modal-header pb-0 border-0 justify-content-end">
|
||||
<!--begin::Close-->
|
||||
<div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal">{!! getIcon('cross', 'fs-1') !!}</div>
|
||||
<!--end::Close-->
|
||||
</div>
|
||||
<!--begin::Modal header-->
|
||||
<!--begin::Modal body-->
|
||||
<div class="modal-body scroll-y px-10 px-lg-15 pt-0 pb-15">
|
||||
<!--begin:Form-->
|
||||
<form class="form_{{$route[0]}}" method="POST" action="{{ route($route[0].'.store') }}">
|
||||
@csrf
|
||||
<!--begin::Heading-->
|
||||
<div class="mb-13 text-center">
|
||||
<!--begin::Title-->
|
||||
<h1 class="mb-3 text-capitalize" id="title_form">{{$route[0]}}</h1>
|
||||
<!--end::Title-->
|
||||
</div>
|
||||
<!--end::Heading-->
|
||||
<!--begin::Input group-->
|
||||
<div class="d-flex flex-column mb-8 fv-row">
|
||||
<!--begin::Label-->
|
||||
<label class="d-flex align-items-center fs-6 fw-semibold mb-2">
|
||||
<span class="required">Kode</span>
|
||||
<span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span>
|
||||
</label>
|
||||
<!--end::Label-->
|
||||
<input type="hidden" id="directorat_id" name="id" />
|
||||
<input type="text" id="directorat_kode" minlength="2" maxlength="2" pattern="[0-9]{2,2}" class="form-control form-control-solid" placeholder="Enter Kode Directorat" name="kode" />
|
||||
</div>
|
||||
<!--end::Input group-->
|
||||
|
||||
<!--begin::Input group-->
|
||||
<div class="d-flex flex-column mb-8 fv-row">
|
||||
<!--begin::Label-->
|
||||
<label class="d-flex align-items-center fs-6 fw-semibold mb-2">
|
||||
<span class="required">Name</span>
|
||||
<span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span>
|
||||
</label>
|
||||
<!--end::Label-->
|
||||
<input type="text" id="directorat_name" maxlength="50" class="form-control form-control-solid" placeholder="Enter Directorat Name" name="name" />
|
||||
</div>
|
||||
<!--end::Input group-->
|
||||
|
||||
<!--begin::Actions-->
|
||||
<div class="text-center">
|
||||
<button type="reset" data-bs-dismiss="modal" class="btn btn-light me-3">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
<!--end::Actions-->
|
||||
</form>
|
||||
<!--end:Form-->
|
||||
</div>
|
||||
<!--end::Modal body-->
|
||||
</div>
|
||||
<!--end::Modal content-->
|
||||
</div>
|
||||
<!--end::Modal dialog-->
|
||||
</div>
|
||||
<!--end::Modal - New Target-->
|
@ -8,23 +8,38 @@
|
||||
@endsection
|
||||
|
||||
@push('customscript')
|
||||
<script src="https://cdn.datatables.net/buttons/1.0.3/js/dataTables.buttons.min.js"></script>
|
||||
@php
|
||||
$route = explode('.', Route::currentRouteName());
|
||||
@endphp
|
||||
|
||||
<script>
|
||||
$("#searchbox").on("keyup search input paste cut", function () {
|
||||
LaravelDataTables["directorat-table"].search(this.value).draw();
|
||||
LaravelDataTables["{{$route[0]}}-table"].search(this.value).draw();
|
||||
});
|
||||
|
||||
$(function () {
|
||||
const documentTitle = 'Transaction Report';
|
||||
var buttons = new $.fn.dataTable.Buttons(LaravelDataTables["directorat-table"], {
|
||||
const documentTitle = '{{ ucfirst($route[0]) }} Report';
|
||||
var buttons = new $.fn.dataTable.Buttons(LaravelDataTables["{{$route[0]}}-table"], {
|
||||
buttons: [
|
||||
{
|
||||
extend: 'excel',
|
||||
extend: 'copyHtml5',
|
||||
title: documentTitle
|
||||
},
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
title: documentTitle
|
||||
},
|
||||
{
|
||||
extend: 'csvHtml5',
|
||||
title: documentTitle
|
||||
},
|
||||
{
|
||||
extend: 'pdfHtml5',
|
||||
title: documentTitle,
|
||||
title: documentTitle
|
||||
},
|
||||
{
|
||||
extend: 'print',
|
||||
title: documentTitle
|
||||
}
|
||||
]
|
||||
}).container().appendTo($('#kt_datatable_example_buttons'));
|
||||
@ -34,7 +49,7 @@
|
||||
exportButtons.forEach(exportButton => {
|
||||
exportButton.addEventListener('click', e => {
|
||||
e.preventDefault();
|
||||
|
||||
console.log(e.target.getAttribute('data-kt-export'));
|
||||
// Get clicked export value
|
||||
const exportValue = e.target.getAttribute('data-kt-export');
|
||||
const target = document.querySelector('.dt-buttons .buttons-' + exportValue);
|
||||
@ -44,7 +59,24 @@
|
||||
});
|
||||
});
|
||||
|
||||
LaravelDataTables["directorat-table"].on('click', '.delete', function (event) {
|
||||
LaravelDataTables["{{$route[0]}}-table"].on('click','.kt_edit_form',function(event){
|
||||
event.preventDefault();
|
||||
$.ajax({
|
||||
url: $(this).attr('href'),
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
$('#title_form').text('Edit {{ ucfirst($route[0]) }}');
|
||||
$('#{{$route[0]}}_id').val(response.id);
|
||||
$('#{{$route[0]}}_name').val(response.name);
|
||||
$('#{{$route[0]}}_kode').val(response.kode);
|
||||
$('.form_{{$route[0]}}').attr('action', '{{ URL::to('/'.$route[0].'/') }}/' + response.id).append('<input type="hidden" name="_method" value="PUT">');
|
||||
$('#kt_modal_{{$route[0]}}').modal('show');
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
LaravelDataTables["{{$route[0]}}-table"].on('click', '.delete', function (event) {
|
||||
var form = $(this).closest("form");
|
||||
event.preventDefault();
|
||||
Swal.fire({
|
||||
@ -57,12 +89,17 @@
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
form.submit();
|
||||
Swal.fire(
|
||||
'Deleted!',
|
||||
'Directorat has been deleted.',
|
||||
'success'
|
||||
)
|
||||
$.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();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -71,7 +108,6 @@
|
||||
@endpush
|
||||
|
||||
@section('styles')
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.0.3/css/buttons.dataTables.min.css">
|
||||
<style>
|
||||
.dataTables_filter {
|
||||
display: none;
|
||||
|
@ -3,47 +3,129 @@
|
||||
<div class="card card-xxl-stretch mb-5 mb-xl-8">
|
||||
<!--begin::Card body-->
|
||||
<div class="card-header border-0 pt-5">
|
||||
<h3 class="card-title align-items-start flex-column">
|
||||
<div class="card-title align-items-start flex-column">
|
||||
<div class="d-flex align-items-center position-relative my-1">
|
||||
<!--begin::Svg Icon | path: icons/duotune/general/gen021.svg-->
|
||||
<span class="svg-icon svg-icon-1 position-absolute ms-6">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
||||
<rect opacity="0.5" x="17.0365" y="15.1223" width="8.15546" height="2" rx="1" transform="rotate(45 17.0365 15.1223)" fill="currentColor"></rect>
|
||||
<path d="M11 19C6.55556 19 3 15.4444 3 11C3 6.55556 6.55556 3 11 3C15.4444 3 19 6.55556 19 11C19 15.4444 15.4444 19 11 19ZM11 5C7.53333 5 5 7.53333 5 11C5 14.4667 7.53333 17 11 17C14.4667 17 17 14.4667 17 11C17 7.53333 14.4667 5 11 5Z" fill="currentColor"></path>
|
||||
<rect opacity="0.5" x="17.0365" y="15.1223" width="8.15546" height="2" rx="1"
|
||||
transform="rotate(45 17.0365 15.1223)" fill="currentColor"></rect>
|
||||
<path
|
||||
d="M11 19C6.55556 19 3 15.4444 3 11C3 6.55556 6.55556 3 11 3C15.4444 3 19 6.55556 19 11C19 15.4444 15.4444 19 11 19ZM11 5C7.53333 5 5 7.53333 5 11C5 14.4667 7.53333 17 11 17C14.4667 17 17 14.4667 17 11C17 7.53333 14.4667 5 11 5Z"
|
||||
fill="currentColor"></path>
|
||||
</svg>
|
||||
</span>
|
||||
<!--end::Svg Icon-->
|
||||
<input type="text" id="searchbox" class="form-control form-control-solid border border-gray-300 w-250px ps-15" placeholder="Search Directorat">
|
||||
<input type="text" id="searchbox"
|
||||
class="form-control form-control-solid border border-gray-300 w-250px ps-15"
|
||||
placeholder="Search Directorat">
|
||||
</div>
|
||||
|
||||
</h3>
|
||||
<!--begin::Export buttons-->
|
||||
<div id="kt_datatable_example_1_export" class="d-none"></div>
|
||||
<!--end::Export buttons-->
|
||||
|
||||
<div class="card-toolbar" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-trigger="hover"
|
||||
title=""
|
||||
data-bs-original-title="Click to add a role">
|
||||
<!--begin::Export buttons-->
|
||||
<div id="kt_datatable_example_1_export" class="d-none"></div>
|
||||
<!--end::Export buttons-->
|
||||
|
||||
<a href="{{ route('directorat.create') }}" class="btn btn-sm btn-light-primary">
|
||||
<!--begin::Svg Icon | path: /var/www/preview.keenthemes.com/kt-products/metronic/releases/2022-07-14-092914/core/html/src/media/icons/duotune/arrows/arr013.svg-->
|
||||
<span class="svg-icon svg-icon-muted svg-icon-2hx">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path opacity="0.3" d="M11 13H7C6.4 13 6 12.6 6 12C6 11.4 6.4 11 7 11H11V13ZM17 11H13V13H17C17.6 13 18 12.6 18 12C18 11.4 17.6 11 17 11Z" fill="currentColor"/>
|
||||
<path d="M22 12C22 17.5 17.5 22 12 22C6.5 22 2 17.5 2 12C2 6.5 6.5 2 12 2C17.5 2 22 6.5 22 12ZM17 11H13V7C13 6.4 12.6 6 12 6C11.4 6 11 6.4 11 7V11H7C6.4 11 6 11.4 6 12C6 12.6 6.4 13 7 13H11V17C11 17.6 11.4 18 12 18C12.6 18 13 17.6 13 17V13H17C17.6 13 18 12.6 18 12C18 11.4 17.6 11 17 11Z" fill="currentColor"/>
|
||||
</svg>
|
||||
</span>
|
||||
<!--end::Svg Icon-->
|
||||
New Directorat
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="card-toolbar">
|
||||
|
||||
<!--begin::Export dropdown-->
|
||||
<button type="button" class="btn btn-light-primary" data-kt-menu-trigger="click"
|
||||
data-kt-menu-placement="bottom-end">
|
||||
<i class="ki-duotone ki-exit-down fs-2"><span class="path1"></span><span class="path2"></span></i>
|
||||
Export Report
|
||||
</button>
|
||||
<!--begin::Menu-->
|
||||
<div id="kt_datatable_example_export_menu"
|
||||
class="menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-gray-600 menu-state-bg-light-primary fw-semibold fs-7 w-200px py-4"
|
||||
data-kt-menu="true">
|
||||
<!--begin::Menu item-->
|
||||
<div class="menu-item px-3">
|
||||
<a href="#" class="menu-link px-3" data-kt-export="copy">
|
||||
Copy to clipboard
|
||||
</a>
|
||||
</div>
|
||||
<!--end::Menu item-->
|
||||
<!--begin::Menu item-->
|
||||
<div class="menu-item px-3">
|
||||
<a href="#" class="menu-link px-3" data-kt-export="excel">
|
||||
Export as Excel
|
||||
</a>
|
||||
</div>
|
||||
<!--end::Menu item-->
|
||||
<!--begin::Menu item-->
|
||||
<div class="menu-item px-3">
|
||||
<a href="#" class="menu-link px-3" data-kt-export="csv">
|
||||
Export as CSV
|
||||
</a>
|
||||
</div>
|
||||
<!--end::Menu item-->
|
||||
<!--begin::Menu item-->
|
||||
<div class="menu-item px-3">
|
||||
<a href="#" class="menu-link px-3" data-kt-export="pdf">
|
||||
Export as PDF
|
||||
</a>
|
||||
</div>
|
||||
<!--end::Menu item-->
|
||||
<!--begin::Menu item-->
|
||||
<div class="menu-item px-3">
|
||||
<a href="#" class="menu-link px-3" data-kt-export="print">
|
||||
Print
|
||||
</a>
|
||||
</div>
|
||||
<!--end::Menu item-->
|
||||
</div>
|
||||
|
||||
<!--begin::Hide default export buttons-->
|
||||
<div id="kt_datatable_example_buttons" class="d-none"></div>
|
||||
<!--end::Hide default export buttons-->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body pt-6">
|
||||
@include('pages.masters.directorat._table')
|
||||
@include('pages.masters.directorat._form')
|
||||
</div>
|
||||
<!--end::Card body-->
|
||||
</div>
|
||||
<!--end::Card-->
|
||||
@push('customscript')
|
||||
<script>
|
||||
$(function () {
|
||||
$(".form_directorat").submit(function (e) {
|
||||
e.preventDefault(); // avoid to execute the actual submit of the form.
|
||||
|
||||
var form = $(this);
|
||||
var actionUrl = form.attr('action');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: actionUrl,
|
||||
data: form.serialize(), // serializes the form's elements.
|
||||
success: function (data) {
|
||||
var _data = JSON.parse(data);
|
||||
toastr.success(_data.message);
|
||||
form[0].reset();
|
||||
LaravelDataTables["directorat-table"].ajax.reload();
|
||||
$('#kt_modal_directorat').modal('hide');
|
||||
|
||||
},
|
||||
error: function (data, textStatus, errorThrown) {
|
||||
var errors = data.responseJSON.errors;
|
||||
$.each(errors, function (key, value) {
|
||||
toastr.error(value);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#kt_modal_directorat').on('hidden.bs.modal', function (e) {
|
||||
$(".form_directorat")[0].reset();
|
||||
$(".form_directorat").attr('action', "{{ route('directorat.store') }}");
|
||||
$(".form_directorat").find('input[name="_method"]').remove();
|
||||
$("#title_form").html("Create Directorat");
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
</x-default-layout>
|
||||
|
Loading…
Reference in New Issue
Block a user