update from dell
This commit is contained in:
parent
34b544503e
commit
79e32e2047
119
DataTables/ApprovalDataTable.php
Normal file
119
DataTables/ApprovalDataTable.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Cetaklabel\DataTables;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
|
||||
use Modules\Cetaklabel\Entities\Approval;
|
||||
use Modules\Usermanager\Entities\User;
|
||||
use Yajra\DataTables\EloquentDataTable;
|
||||
use Yajra\DataTables\Html\Builder as HtmlBuilder;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use Yajra\DataTables\Services\DataTable;
|
||||
|
||||
class ApprovalDataTable 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');
|
||||
}
|
||||
})
|
||||
->addIndexColumn()
|
||||
->addColumn('craeted_at', function ($model) {
|
||||
return $model->created_at !== null ? Carbon::parse($model->created_at)->format('d F Y H:i:s') : '-';
|
||||
})
|
||||
->addColumn('created_by', function ($model) {
|
||||
return $model->created_by ? $model->creator->name : '-';
|
||||
})
|
||||
->addColumn('approved_at', function ($model) {
|
||||
return $model->approved_at !== null ? Carbon::parse($model->approved_at)->format('d F Y H:i:s') : '-';
|
||||
})
|
||||
->addColumn('approved_by', function ($model) {
|
||||
return $model->approved_by ? User::find($model->approved_by)->name : '-';
|
||||
})
|
||||
->addColumn('status', function ($model) {
|
||||
return $this->render('cetaklabel::app.approval._status', compact('model'));
|
||||
})
|
||||
->addColumn('action', function ($model) {
|
||||
return $this->render('cetaklabel::app.approval._action', compact('model'));
|
||||
})
|
||||
->rawColumns(['status', 'action'])
|
||||
->setRowId('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the query source of dataTable.
|
||||
*/
|
||||
public function query(Approval $model)
|
||||
: QueryBuilder
|
||||
{
|
||||
return $model->newQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional method if you want to use the html builder.
|
||||
*/
|
||||
public function html()
|
||||
: HtmlBuilder
|
||||
{
|
||||
return $this->builder()
|
||||
->setTableId('approval-table')
|
||||
->columns($this->getColumns())
|
||||
->minifiedAjax()
|
||||
->stateSave(false)
|
||||
->responsive()
|
||||
->autoWidth(true)
|
||||
->orderBy(1)
|
||||
->parameters([
|
||||
'scrollX' => false,
|
||||
'drawCallback' => 'function() { KTMenu.createInstances(); }',
|
||||
])
|
||||
->addTableClass('align-middle table-row-dashed fs-6 gy-5');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dataTable columns definition.
|
||||
*/
|
||||
public function getColumns()
|
||||
: array
|
||||
{
|
||||
return [
|
||||
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
|
||||
Column::make('method'),
|
||||
Column::make('menu'),
|
||||
Column::make('description'),
|
||||
Column::make('craeted_at')->className('none'),
|
||||
Column::make('created_by')->className('none'),
|
||||
Column::make('approved_at')->className('none'),
|
||||
Column::make('approved_by')->className('none'),
|
||||
Column::computed('status')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(60)
|
||||
->addClass('text-center'),
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(250)
|
||||
->addClass('text-center'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename for export.
|
||||
*/
|
||||
protected function filename()
|
||||
: string
|
||||
{
|
||||
return 'Approval_' . date('YmdHis');
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('approvals', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string("method", 50);
|
||||
$table->string('model', 50);
|
||||
$table->json('new_request')->nullable();
|
||||
$table->json('old_request')->nullable();
|
||||
$table->string("description", 255)->nullable();
|
||||
$table->string('status', 1)->default(0)->nullable();
|
||||
$table->timestamps();
|
||||
$table->timestamp('approved_at')->nullable();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||
$table->unsignedBigInteger('approved_by')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('approvals');
|
||||
}
|
||||
};
|
25
Entities/Approval.php
Normal file
25
Entities/Approval.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Cetaklabel\Entities;
|
||||
|
||||
class Approval extends BaseModel
|
||||
{
|
||||
protected $fillable = [
|
||||
'method',
|
||||
'model',
|
||||
'new_request',
|
||||
'old_request',
|
||||
'description',
|
||||
'status',
|
||||
'approved_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
'approved_by',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
}
|
90
Http/Controllers/ApprovalController.php
Normal file
90
Http/Controllers/ApprovalController.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Cetaklabel\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\Cetaklabel\DataTables\ApprovalDataTable;
|
||||
use Modules\Cetaklabel\Entities\Approval;
|
||||
|
||||
class ApprovalController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->user = Auth::guard('web')->user();
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index(ApprovalDataTable $dataTable)
|
||||
{
|
||||
return $dataTable->render('cetaklabel::app.approval.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('cetaklabel::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('cetaklabel::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('cetaklabel::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
120
Http/Controllers/ReportController.php
Normal file
120
Http/Controllers/ReportController.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Cetaklabel\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Modules\Cetaklabel\DataTables\CardboardDataTable;
|
||||
use Modules\Cetaklabel\Entities\Directorat;
|
||||
use Modules\Cetaklabel\Entities\SubDirectorat;
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->user = Auth::guard('web')->user();
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
public function _index(CardboardDataTable $datatable){
|
||||
addVendor('chained-select');
|
||||
$directorats = Directorat::all();
|
||||
|
||||
return $datatable->render('cetaklabel::app.cardboard.index', compact('directorats'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
addVendor('chained-select');
|
||||
if (Auth::user()->hasRole(['ad', 'administrator'])) {
|
||||
|
||||
$directorat = Directorat::all();
|
||||
return view('cetaklabel::app.report.index', compact('directorat'));
|
||||
} else if (Auth::user()->hasRole(['dd'])) {
|
||||
$sub_directorat = SubDirectorat::all();
|
||||
return view('cetaklabel::app.report.index', compact('sub_directorat'));
|
||||
}
|
||||
|
||||
return view('cetaklabel::app.report.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('cetaklabel::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
return view('cetaklabel::show');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('cetaklabel::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
45
Resources/views/app/approval/_action.blade.php
Normal file
45
Resources/views/app/approval/_action.blade.php
Normal file
@ -0,0 +1,45 @@
|
||||
@php
|
||||
$route = explode('.', Route::currentRouteName());
|
||||
@endphp
|
||||
@if( Auth::user()->hasRole('ad') || Auth::user()->hasRole('administrator'))
|
||||
<div class="d-flex flex-row flex-center">
|
||||
<a href="{{ route($route[0].'.edit',[str_replace('-','_',$route[0]) => $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>
|
||||
@endif
|
||||
|
||||
@if(Auth::user()->hasRole('dd'))
|
||||
@if($model->status == 0)
|
||||
{!! Form::open(['method' => 'PUT','route' => [$route[0].'.update', $model->id],'class'=>'d-inline-block']) !!}
|
||||
<input type="hidden" value="{{$model->kode}}" name="kode">
|
||||
<input type="hidden" value="{{$model->name}}" name="name">
|
||||
<input type="hidden" value="1" name="status">
|
||||
<input type="hidden" value="1" name="approval">
|
||||
<button type="submit" value="1" class="kt_approve_form btn btn-light-success btn-active-success btn-sm " style="--bs-btn-padding-y: .25rem !important; --bs-btn-padding-x: .5rem !important; --bs-btn-font-size: .75rem !important;">
|
||||
<i class="ki-duotone ki-double-check">
|
||||
<i class="path1"></i>
|
||||
<i class="path2"></i>
|
||||
</i> Approve
|
||||
</button>
|
||||
{!! Form::close() !!}
|
||||
|
||||
{!! Form::open(['method' => 'PUT','route' => [$route[0].'.update', $model->id],'class'=>'d-inline-block']) !!}
|
||||
<input type="hidden" value="{{$model->kode}}" name="kode">
|
||||
<input type="hidden" value="{{$model->name}}" name="name">
|
||||
<input type="hidden" value="3" name="status">
|
||||
<input type="hidden" value="1" name="approval">
|
||||
<button type="submit" value="1" class="kt_reject_form btn btn-light-danger btn-active-danger btn-sm" style="--bs-btn-padding-y: .25rem !important; --bs-btn-padding-x: .5rem !important; --bs-btn-font-size: .75rem !important;">
|
||||
<i class="ki-duotone ki-cross">
|
||||
<i class="path1"></i>
|
||||
<i class="path2"></i>
|
||||
</i> Reject
|
||||
</button>
|
||||
{!! Form::close() !!}
|
||||
@endif
|
||||
@endif
|
70
Resources/views/app/approval/_form.blade.php
Normal file
70
Resources/views/app/approval/_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_approval" 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">Create {{ 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="approval_id" name="id"/>
|
||||
<input type="text" id="approval_kode" minlength="2" maxlength="2" pattern="[0-9]{2,2}" class="form-control form-control-solid" placeholder="Enter Kode Approval" 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="approval_name" maxlength="50" class="form-control form-control-solid" placeholder="Enter Approval 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-->
|
17
Resources/views/app/approval/_status.blade.php
Normal file
17
Resources/views/app/approval/_status.blade.php
Normal file
@ -0,0 +1,17 @@
|
||||
{{--
|
||||
<span class="badge badge-light-primary">New</span>
|
||||
<span class="badge badge-light-secondary">New</span>
|
||||
<span class="badge badge-light-success">New</span>
|
||||
<span class="badge badge-light-info">New</span>
|
||||
<span class="badge badge-light-warning">New</span>
|
||||
<span class="badge badge-light-danger">New</span>
|
||||
<span class="badge badge-light-dark">New</span>--}}
|
||||
|
||||
|
||||
@if($model->status == 0)
|
||||
<span class="badge badge-light-primary">Waiting Approval</span>
|
||||
@elseif($model->status == 1)
|
||||
<span class="badge badge-light-success">Approved</span>
|
||||
@elseif($model->status == 3)
|
||||
<span class="badge badge-light-danger">Rejected</span>
|
||||
@endif
|
175
Resources/views/app/approval/_table.blade.php
Normal file
175
Resources/views/app/approval/_table.blade.php
Normal file
@ -0,0 +1,175 @@
|
||||
<!--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();
|
||||
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($route[0])}} has been deleted.', 'Success!', {timeOut: 5000});
|
||||
Swal.fire({
|
||||
title: 'Success!',
|
||||
text: "Data berhasil di hapus, menunggu Approval",
|
||||
icon: 'success',
|
||||
confirmButtonText: 'Ok'
|
||||
});
|
||||
LaravelDataTables["{{$route[0]}}-table"].ajax.reload();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@section('styles')
|
||||
<style>
|
||||
.dataTables_filter {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@endsection
|
143
Resources/views/app/approval/index.blade.php
Normal file
143
Resources/views/app/approval/index.blade.php
Normal file
@ -0,0 +1,143 @@
|
||||
<x-default-layout>
|
||||
<!--begin::Card-->
|
||||
<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 Approval">
|
||||
</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('cetaklabel::app.approval._table')
|
||||
@include('cetaklabel::app.approval._form')
|
||||
</div>
|
||||
<!--end::Card body-->
|
||||
</div>
|
||||
<!--end::Card-->
|
||||
@push('customscript')
|
||||
<script>
|
||||
$(function () {
|
||||
$(".form_approval").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(),
|
||||
success: function (data) {
|
||||
var _data = JSON.parse(data);
|
||||
toastr.success(_data.message);
|
||||
|
||||
var _message = _data.message;
|
||||
var message = 'Data Berhasil Di Simpan, Menunggu Approval';
|
||||
if(_message.includes("updated")){
|
||||
message = 'Data Berhasil Di Update, Menunggu Approval';
|
||||
}
|
||||
Swal.fire({
|
||||
title: 'Success!',
|
||||
text: message,
|
||||
icon: 'success',
|
||||
confirmButtonText: 'Ok'
|
||||
});
|
||||
|
||||
form[0].reset();
|
||||
LaravelDataTables["approval-table"].ajax.reload();
|
||||
$('#kt_modal_approval').modal('hide');
|
||||
},
|
||||
error: function (data, textStatus, errorThrown) {
|
||||
var errors = data.responseJSON.errors;
|
||||
$.each(errors, function (key, value) {
|
||||
toastr.error(value);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#kt_modal_approval').on('hidden.bs.modal', function (e) {
|
||||
$(".form_approval")[0].reset();
|
||||
$(".form_approval").attr('action', "{{ route('approval.store') }}");
|
||||
$(".form_approval").find('input[name="_method"]').remove();
|
||||
$("#title_form").html("Create Approval");
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
</x-default-layout>
|
106
Resources/views/app/report/_form.blade.php
Normal file
106
Resources/views/app/report/_form.blade.php
Normal file
@ -0,0 +1,106 @@
|
||||
@php
|
||||
$route = explode('.', Route::currentRouteName());
|
||||
@endphp
|
||||
<!--begin:Form-->
|
||||
<div class="d-flex flex-center w-50">
|
||||
<form class="form_{{$route[0]}}" method="POST" action="{{ route($route[0].'.store') }}">
|
||||
@csrf
|
||||
|
||||
<div class="row gx-5 mb-5">
|
||||
@if(Auth::user()->hasRole(['ad','administrator']))
|
||||
<!--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" for="directorat_id">
|
||||
<span class="required">Directorat</span>
|
||||
<span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span>
|
||||
</label>
|
||||
<!--end::Label-->
|
||||
<select class="form-select" name="directorat_id" id="directorat_id">
|
||||
<option>Select Directorat</option>
|
||||
@foreach($directorat as $item)
|
||||
<option value="{{$item->id}}">{{$item->name}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</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" for="sub_directorat_id">
|
||||
<span class="required">Sub Directorat</span>
|
||||
<span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span>
|
||||
</label>
|
||||
<!--end::Label-->
|
||||
<select class="form-select" name="sub_directorat_id" id="sub_directorat_id">
|
||||
<option>Select Sub Directorat</option>
|
||||
</select>
|
||||
</div>
|
||||
<!--end::Input group-->
|
||||
@endif
|
||||
|
||||
@if(Auth::user()->hasRole(['dd']))
|
||||
<!--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" for="directorat_id">
|
||||
<span class="required">Sub Directorat</span>
|
||||
<span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span>
|
||||
</label>
|
||||
<!--end::Label-->
|
||||
<select class="form-select" name="directorat_id" id="directorat_id">
|
||||
<option>Select Sub Directorat</option>
|
||||
@foreach($sub_directorat as $item)
|
||||
<option value="{{$item->id}}">{{$item->name}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<!--end::Input group-->
|
||||
@endif
|
||||
|
||||
<!--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" for="sub_directorat_id">
|
||||
<span class="required">Jenis Laporan</span>
|
||||
<span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span>
|
||||
</label>
|
||||
<!--end::Label-->
|
||||
<select class="form-select" name="sub_directorat_id" id="sub_directorat_id">
|
||||
<option value="dus">Laporan Dus</option>
|
||||
<option value="odner">Laporan Odner</option>
|
||||
<option value="document">Laporan Document</option>
|
||||
</select>
|
||||
</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" for="sub_directorat_id">
|
||||
<span class="required">Periode</span>
|
||||
<span class="ms-1" data-bs-toggle="tooltip" title="Specify a target name for future usage and reference"></span>
|
||||
</label>
|
||||
<!--end::Label-->
|
||||
<div class="d-flex flex-row mb-8 fv-row">
|
||||
<input type="date" id="tanggalawal"
|
||||
class="form-control form-control-solid border border-gray-300 ps-15 ml-10"
|
||||
placeholder="Tanggal Awal"> <span class="mt-3">s.d.</span> <input type="date" id="tanggalakhir"
|
||||
class="form-control form-control-solid border border-gray-300 ps-15 ml-10"
|
||||
placeholder="Tanggal Awal">
|
||||
</div>
|
||||
</div>
|
||||
<!--end::Input group-->
|
||||
</div>
|
||||
|
||||
<!--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>
|
||||
</div>
|
||||
<!--end:Form-->
|
||||
|
27
Resources/views/app/report/index.blade.php
Normal file
27
Resources/views/app/report/index.blade.php
Normal file
@ -0,0 +1,27 @@
|
||||
<x-default-layout>
|
||||
<!--begin::Card-->
|
||||
<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">
|
||||
Setting Parameter
|
||||
</h3>
|
||||
</div>
|
||||
<div class="card-body pt-6 d-flex flex-center">
|
||||
@include('cetaklabel::app.report._form')
|
||||
</div>
|
||||
<!--end::Card body-->
|
||||
</div>
|
||||
<!--end::Card-->
|
||||
|
||||
@push('customscript')
|
||||
<script>
|
||||
$(function () {
|
||||
$("#sub_directorat_id").remoteChained({
|
||||
parents: "#directorat_id",
|
||||
url: "/sub-directorat"
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
</x-default-layout>
|
Loading…
Reference in New Issue
Block a user