Add Module Special Code

This commit is contained in:
daeng.deni@dharma.or.id 2023-04-17 22:17:11 +07:00
parent a3dd7e93de
commit 38b2178451
20 changed files with 1000 additions and 1 deletions

View File

@ -0,0 +1,89 @@
<?php
namespace App\DataTables;
use App\Models\SpecialCode;
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
use Yajra\DataTables\EloquentDataTable;
use Yajra\DataTables\Html\Builder as HtmlBuilder;
use Yajra\DataTables\Html\Button;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Html\Editor\Editor;
use Yajra\DataTables\Html\Editor\Fields;
use Yajra\DataTables\Services\DataTable;
class SpecialCodeDataTable extends DataTable
{
/**
* Build the DataTable class.
*
* @param QueryBuilder $query Results from query() method.
*/
public function dataTable(QueryBuilder $query): EloquentDataTable
{
return (new EloquentDataTable($query))
->filter(function ($query) {
if (request()->has('search')) {
$search = request()->get('search');
$query->where('kode', 'like', "%" . $search['value'] . "%")
->orWhere('name', 'like', "%" . $search['value'] . "%");
}
})
->addIndexColumn()
->addColumn('action', 'pages.masters.special-code._action')
->setRowId('id');
}
/**
* Get the query source of dataTable.
*/
public function query(SpecialCode $model): QueryBuilder
{
return $model->newQuery();
}
/**
* Optional method if you want to use the html builder.
*/
public function html(): HtmlBuilder
{
return $this->builder()
->setTableId('special-code-table')
->columns($this->getColumns())
->minifiedAjax()
->stateSave(false)
->responsive()
->autoWidth(true)
->orderBy(1)
->parameters([
'scrollX' => true,
'drawCallback' => 'function() { KTMenu.createInstances(); }',
])
->addTableClass('align-middle table-row-dashed fs-6 gy-5');
}
/**
* Get the dataTable columns definition.
*/
public function getColumns(): array
{
return [
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
Column::make('kode'),
Column::make('name'),
Column::computed('action')
->exportable(false)
->printable(false)
->width(60)
->addClass('text-center'),
];
}
/**
* Get the filename for export.
*/
protected function filename(): string
{
return 'Special_Code_' . date('YmdHis');
}
}

View File

@ -0,0 +1,118 @@
<?php
namespace App\Http\Controllers;
use App\DataTables\SpecialCodeDataTable;
use App\Http\Requests\StoreSpecialCodeRequest;
use App\Http\Requests\UpdateSpecialCodeRequest;
use App\Models\SpecialCode;
use Illuminate\Http\Request;
use Spatie\Activitylog\Facades\CauserResolver;
class SpecialCodeController extends Controller
{
public $user;
public function __construct()
{
$this->middleware(function ($request, $next) {
//$this->user = Auth::guard('web')->user();
return $next($request);
});
//CauserResolver::setCauser($this->user);
}
/**
* Display a listing of the resource.
*/
public function index(SpecialCodeDataTable $dataTable)
{
/*if (is_null($this->user) || !$this->user->can('masters.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any master data !');
}*/
return $dataTable->render('pages.masters.special-code.index');
}
/**
* Show the form for creating a new resource.
*/
public function create(){}
/**
* Store a newly created resource in storage.
*/
public function store(StoreSpecialCodeRequest $request)
{
/*if (is_null($this->user) || !$this->user->can('masters.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Store the Special Code...
if($validated){
try{
SpecialCode::create($validated);
echo json_encode(['status' => 'success', 'message' => 'Special Code created successfully.']);
}catch(\Exception $e){
echo json_encode(['status' => 'error', 'message' => 'Special Code created failed.']);
}
}
return false;
}
/**
* Display the specified resource.
*/
public function show(SpecialCode $special_code)
{
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id){
$special_code = SpecialCode::find($id);
echo json_encode($special_code);
}
/**
* Update the specified resource in storage.
*/
public function update(UpdateSpecialCodeRequest $request, SpecialCode $special_code)
{
/*if (is_null($this->user) || !$this->user->can('masters.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any master data !');
}*/
// Validate the request...
$validated = $request->validated();
// Update the Directorat...
if($validated){
try{
$special_code->update($validated);
echo json_encode(['status' => 'success', 'message' => 'Special Code updated successfully.']);
}catch(\Exception $e){
echo json_encode(['status' => 'error', 'message' => 'Special Code updated failed.']);
}
}
return false;
}
/**
* Remove the specified resource from storage.
*/
public function destroy(SpecialCode $special_code){
$special_code->delete();
echo json_encode(['status' => 'success', 'message' => 'Special Code deleted successfully.']);
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
class StoreSpecialCodeRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
*/
public function rules(): array
{
return [
'kode' => 'required|string|max:2|min:2|unique:special_codes,kode',
'name' => 'required|string|max:50'
];
}
/**
* Configure the validator instance.
*/
public function withValidator(Validator $validator): void
{
$validator->after(function (Validator $validator) {
if($validator->errors()->any()) {
$error = json_decode($validator->errors()->toJson(), true);
foreach ($error as $key => $value) {
flash( $value[0]);
}
return redirect()->route('special-code.index')->with('error', 'Special Code created failed.');
}
});
}
}

View File

@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
class UpdateSpecialCodeRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
*/
public function rules(): array
{
return [
'kode' => 'required|string|max:2|min:2|unique:special_codes,kode,'.$this->id,
'name' => 'required|string|max:50'
];
}
/**
* Configure the validator instance.
*/
public function withValidator(Validator $validator): void
{
$validator->after(function (Validator $validator) {
if($validator->errors()->any()) {
$error = json_decode($validator->errors()->toJson(), true);
foreach ($error as $key => $value) {
flash( $value[0]);
}
return redirect()->route('special_code.index')->with('error', 'Special Code updated failed.');
}
});
}
}

67
app/Models/Document.php Normal file
View File

@ -0,0 +1,67 @@
<?php
namespace App\Models;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Wildside\Userstamps\Userstamps;
class Document extends Model
{
use LogsActivity, HasFactory, SoftDeletes, Userstamps;
protected $fillable = [
'directorat_id',
'sub_directorat_id',
'job_id',
'sub_job_id',
'sub_sub_job_id',
'special_code_id',
'no_urut',
'kode'
];
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()->logAll()
->useLogName('master data');
}
public function directorat()
{
return $this->belongsTo(Directorat::class);
}
public function sub_directorat()
{
return $this->belongsTo(SubDirectorat::class);
}
public function job()
{
return $this->belongsTo(Job::class);
}
public function sub_job()
{
return $this->belongsTo(SubJob::class);
}
public function sub_sub_job()
{
return $this->belongsTo(SubSubJob::class);
}
public function special_code()
{
return $this->belongsTo(SpecialCode::class);
}
public function document_details()
{
return $this->hasMany(DocumentDetail::class);
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Models;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Wildside\Userstamps\Userstamps;
class DocumentDetail extends Model
{
use LogsActivity, HasFactory, SoftDeletes, Userstamps;
protected $fillable = [
'document_id',
'document_type_id',
'type',
'nama_nasabah',
'no_rekening',
'no_cif',
'group',
'tanggal_upload',
'tanggal_document',
'no_document',
'perihal',
'kode_cabang',
'jumlah_halaman',
'custom_field_1',
'custom_field_2',
'custom_field_3',
'custom_field_4'
];
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()->logAll()
->useLogName('master data');
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Wildside\Userstamps\Userstamps;
class DocumentType extends Model
{
use LogsActivity, HasFactory, SoftDeletes, Userstamps;
protected $fillable = [
'kode',
'name'
];
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()->logAll()
->useLogName('master data');
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Spatie\Activitylog\LogOptions;
use Spatie\Activitylog\Traits\LogsActivity;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Wildside\Userstamps\Userstamps;
class SpecialCode extends Model
{
use LogsActivity, HasFactory, SoftDeletes, Userstamps;
protected $fillable = [
'kode',
'name'
];
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()->logAll()
->useLogName('master data');
}
}

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('document_types', function (Blueprint $table) {
$table->id();
$table->string('kode', 2);
$table->string('name');
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('special_codes');
}
};

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('special_codes', function (Blueprint $table) {
$table->id();
$table->string('kode', 2);
$table->string('name');
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('special_codes');
}
};

View File

@ -0,0 +1,50 @@
<?php
use App\Models\Directorat;
use App\Models\Job;
use App\Models\SpecialCode;
use App\Models\SubDirectorat;
use App\Models\SubJob;
use App\Models\SubSubJob;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('documents', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(Directorat::class)->constrained()->onDelete('cascade');
$table->foreignIdFor(SubDirectorat::class)->constrained()->onDelete('cascade');
$table->foreignIdFor(Job::class)->constrained()->onDelete('cascade');
$table->foreignIdFor(SubJob::class)->constrained()->onDelete('cascade');
$table->foreignIdFor(SubSubJob::class)->constrained()->onDelete('cascade');
$table->foreignIdFor(SpecialCode::class)->constrained()->onDelete('cascade');
$table->string('no_urut',3);
$table->string('kode', 15);
$table->string('status')->nullable();
$table->string('keterangan')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('documents');
}
};

View File

@ -0,0 +1,55 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('document_details', function (Blueprint $table) {
$table->id();
$table->foreignId('document_id')->constrained('documents')->onDelete('cascade');
$table->foreignId('document_type_id')->nullable()->constrained('document_types')->onDelete('cascade');
$table->enum('type', ['nasabah', 'non_nasabah']);
$table->string('nama_nasabah')->nullable();
$table->string('no_rekening')->nullable();
$table->string('no_cif')->nullable();
$table->string('group')->nullable();
$table->date('tanggal_upload')->nullable();
$table->date('tanggal_dokumen')->nullable();
$table->string('no_dokumen')->nullable();
$table->string('perihal')->nullable();
$table->string('kode_cabang')->nullable();
$table->string('jumlah_halaman')->nullable();
$table->string('custom_field_1')->nullable();
$table->string('custom_field_2')->nullable();
$table->string('custom_field_3')->nullable();
$table->string('custom_field_4')->nullable();
$table->string('status')->nullable();
$table->string('keterangan')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
$table->unsignedBigInteger('deleted_by')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('document_details');
}
};

View File

@ -4,6 +4,7 @@ namespace Database\Seeders;
use App\Models\Directorat;
use App\Models\Job;
use App\Models\SpecialCode;
use App\Models\SubDirectorat;
use App\Models\SubJob;
use App\Models\SubSubJob;
@ -53,5 +54,15 @@ class LabelSeeder extends Seeder
'sub_directorat_id' => $subdirektorat->id,
'directorat_id' => $direktorat->id,
]);
$SpecialCode = SpecialCode::create([
'kode' => '00',
'name' => 'Archive'
]);
$SpecialCode = SpecialCode::create([
'kode' => '98',
'name' => 'Softcopy'
]);
}
}

View File

@ -216,7 +216,7 @@
<!--end:Menu item-->
<!--begin:Menu item-->
<div data-kt-menu-trigger="click" class="menu-item menu-accordion {{ $route[0] == 'directorat' || $route[0] == 'sub-directorat' || $route[0] == 'job' || $route[0] == 'sub-job' || $route[0] == 'sub-sub-job' ? 'show' : '' }}">
<div data-kt-menu-trigger="click" class="menu-item menu-accordion {{ $route[0] == 'directorat' || $route[0] == 'sub-directorat' || $route[0] == 'job' || $route[0] == 'sub-job' || $route[0] == 'sub-sub-job' || $route[0] == 'special-code' ? 'show' : '' }}">
<!--begin:Menu link-->
<span class="menu-link">
<span class="menu-icon">{!! getIcon('abstract-28', 'fs-2','duotone') !!}</span>
@ -286,6 +286,19 @@
<!--end:Menu link-->
</div>
<!--end:Menu item-->
<!--begin:Menu item-->
<div class="menu-item">
<!--begin:Menu link-->
<a class="menu-link {{ $route[0] == 'special-code' ? 'active' : '' }}" href="{{ route('special-code.index') }}">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">Kode Khusus</span>
</a>
<!--end:Menu link-->
</div>
<!--end:Menu item-->
</div>
<!--end:Menu sub-->
</div>

View File

@ -0,0 +1,13 @@
@php
$route = explode('.', Route::currentRouteName());
@endphp
<div class="d-flex flex-row flex-center">
<a href="{{ route($route[0].'.edit',['special_code' => $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>

View File

@ -0,0 +1,71 @@
@php
$route = explode('.', Route::currentRouteName());
@endphp
<!--begin::Modal - New Target-->
<div class="modal fade" id="kt_modal_{{$route[0]}}" 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">{{ str_replace('-',' ',$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="{{$route[0]}}_id" name="id" />
<input type="text" id="{{$route[0]}}_kode" minlength="2" maxlength="2" pattern="[0-9]{2,2}" class="form-control form-control-solid" placeholder="Enter Kode" 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="{{$route[0]}}_name" maxlength="50" class="form-control form-control-solid" placeholder="Enter Special Code 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-->

View File

@ -0,0 +1,117 @@
<!--begin::Table-->
{{ $dataTable->table() }}
<!--end::Table-->
{{-- Inject Scripts --}}
@section('scripts')
{{ $dataTable->scripts() }}
@endsection
@push('customscript')
@php
$route = explode('.', Route::currentRouteName());
@endphp
<script>
$("#searchbox").on("keyup search input paste cut", function () {
LaravelDataTables["{{$route[0]}}-table"].search(this.value).draw();
});
$(function () {
const documentTitle = '{{ ucfirst($route[0]) }} Report';
var buttons = new $.fn.dataTable.Buttons(LaravelDataTables["{{$route[0]}}-table"], {
buttons: [
{
extend: 'copyHtml5',
title: documentTitle
},
{
extend: 'excelHtml5',
title: documentTitle
},
{
extend: 'csvHtml5',
title: documentTitle
},
{
extend: 'pdfHtml5',
title: documentTitle
},
{
extend: 'print',
title: documentTitle
}
]
}).container().appendTo($('#kt_datatable_example_buttons'));
// Hook dropdown menu click event to datatable export buttons
const exportButtons = document.querySelectorAll('#kt_datatable_example_export_menu [data-kt-export]');
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);
// Trigger click event on hidden datatable export buttons
target.click();
});
});
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(str_replace('-',' ',$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();
event.preventDefault();
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete 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(str_replace('-',' ',$route[0]))}} has been deleted.', 'Success!', {timeOut: 5000});
LaravelDataTables["{{$route[0]}}-table"].ajax.reload();
}
});
}
})
})
})
</script>
@endpush
@section('styles')
<style>
.dataTables_filter {
display: none;
}
</style>
@endsection

View File

@ -0,0 +1,136 @@
<x-default-layout>
<!--begin::Card-->
@php
$route = explode('.', Route::currentRouteName());
@endphp
<div class="card card-xxl-stretch mb-5 mb-xl-8">
<!--begin::Card body-->
<div class="card-header border-0 pt-5">
<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>
</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 Special Code">
</div>
<!--begin::Export buttons-->
<div id="kt_datatable_example_1_export" class="d-none"></div>
<!--end::Export buttons-->
</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.special-code._table')
@include('pages.masters.special-code._form')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
@push('customscript')
<script>
$(function () {
$(".form_special-code").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["{{$route[0]}}-table"].ajax.reload();
$('#kt_modal_{{$route[0]}}').modal('hide');
},
error: function (data, textStatus, errorThrown) {
var errors = data.responseJSON.errors;
$.each(errors, function (key, value) {
toastr.error(value);
});
}
});
});
$('#kt_modal_{{$route[0]}}').on('hidden.bs.modal', function (e) {
$(".form_special-code")[0].reset();
$(".form_special-code").attr('action', "{{ route('special-code.store') }}");
$(".form_special-code").find('input[name="_method"]').remove();
$("#title_form").html("Create Special Code");
})
});
</script>
@endpush
</x-default-layout>

View File

@ -5,6 +5,7 @@ use App\Http\Controllers\DirectoratController;
use App\Http\Controllers\JobController;
use App\Http\Controllers\Logs\AuditLogsController;
use App\Http\Controllers\Logs\SystemLogsController;
use App\Http\Controllers\SpecialCodeController;
use App\Http\Controllers\SubDirectoratController;
use App\Http\Controllers\SubJobController;
use App\Http\Controllers\SubSubJobController;
@ -39,6 +40,7 @@ Route::group(['middleware' => ['auth', 'verified']], function () {
Route::resource('job', JobController::class);
Route::resource('sub-job', SubJobController::class);
Route::resource('sub-sub-job', SubSubJobController::class);
Route::resource('special-code', SpecialCodeController::class);
// Users Management
Route::prefix('user')->name('user.')->group(function(){