Udpate Dus Detail

This commit is contained in:
Daeng Deni Mardaeni 2023-06-14 16:20:32 +07:00
parent ab17d08d23
commit 57439c7e9a
28 changed files with 643 additions and 153 deletions

View File

@ -33,7 +33,13 @@
}
})
->addIndexColumn()
->addColumn('checkbox', function ($item) {
return '<div class="form-check form-check-sm form-check-custom form-check-solid">
<input class="form-check-input" name="checkbox[]" type="checkbox" value="' . $item->id . '" />
</div>';
})
->addColumn('action', 'cetaklabel::app.cardboard._action')
->rawColumns(['checkbox', 'action'])
->setRowId('id');
}
@ -61,7 +67,7 @@
->autoWidth(true)
->orderBy(1)
->parameters([
'scrollX' => true,
'scrollX' => false,
'drawCallback' => 'function() { KTMenu.createInstances(); }',
])
->addTableClass('align-middle table-row-dashed fs-6 gy-5');
@ -74,6 +80,7 @@
: array
{
return [
Column::make('checkbox')->title('')->orderable(false)->searchable(false)->exportable(false)->printable(false)->width(10),
Column::make('DT_RowIndex')->title('No')->orderable(false)->searchable(false),
Column::make('kode'),
Column::make('directorat.name')->title('Direktorat'),

View File

@ -0,0 +1,115 @@
<?php
namespace Modules\Cetaklabel\DataTables;
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
use Illuminate\Support\Facades\URL;
use Modules\Cetaklabel\Entities\Cardboard;
use Modules\Cetaklabel\Entities\CardboardDetail;
use Yajra\DataTables\EloquentDataTable;
use Yajra\DataTables\Html\Builder as HtmlBuilder;
use Yajra\DataTables\Html\Column;
use Yajra\DataTables\Services\DataTable;
class CardboardDetailDataTable extends DataTable
{
/**
* Build the DataTable class.
*
* @param QueryBuilder $query Results from query() method.
*/
public function dataTable(QueryBuilder $query)
: EloquentDataTable
{
$current_url = URL::current();
$url = explode('/', $current_url);
$query = $query->with(['cardboard', 'document'])->where('cardboard_id', $url[4]);
return (new EloquentDataTable($query))
->filter(function ($query) {
if (request()->has('search')) {
$search = request()->get('search');
}
})
->addIndexColumn()
->addColumn('directorat', function ($model) {
return $model->document->directorat->kode . ' - ' . $model->document->directorat->name;
})
->addColumn('sub_directorat', function ($model) {
return $model->document->sub_directorat->kode . ' - ' . $model->document->sub_directorat->name;
})
->addColumn('job', function ($model) {
return $model->document->job->kode . ' - ' . $model->document->job->name;
})
->addColumn('sub_job', function ($model) {
return $model->document->sub_job->kode . ' - ' . $model->document->sub_job->name;
})
->addColumn('sub_sub_job', function ($model) {
return $model->document->sub_sub_job->kode . ' - ' . $model->document->sub_sub_job->name;
})
->addColumn('action', 'cetaklabel::app.cardboard-detail._action')
->setRowId('id');
}
/**
* Get the query source of dataTable.
*/
public function query(CardboardDetail $model)
: QueryBuilder
{
return $model->newQuery();
}
/**
* Optional method if you want to use the html builder.
*/
public function html()
: HtmlBuilder
{
return $this->builder()
->setTableId('cardboard-detail-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('cardboard_id')->title('Cardboard ID'),
Column::make('document.kode_odner')->title('Kode Odner'),
Column::make('directorat')->title('Direktorat'),
Column::make('sub_directorat')->title('Sub Direktorat'),
Column::make('job')->title('Jenis Pekerjaan'),
Column::make('sub_job')->title('Sub Jenis Pekerjaan'),
Column::make('sub_sub_job')->title('Sub Sub Jenis Pekerjaan'),
Column::computed('action')
->exportable(false)
->printable(false)
->width(60)
->addClass('text-center'),
];
}
/**
* Get the filename for export.
*/
protected function filename()
: string
{
return 'Cardboard_' . date('YmdHis');
}
}

View File

@ -3,8 +3,6 @@
namespace Modules\Cetaklabel\DataTables;
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Route;
use Modules\Cetaklabel\Entities\Document;
use Yajra\DataTables\EloquentDataTable;
use Yajra\DataTables\Html\Builder as HtmlBuilder;

View File

@ -3,8 +3,6 @@
namespace Modules\Cetaklabel\DataTables;
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Route;
use Modules\Cetaklabel\Entities\Document;
use Modules\Cetaklabel\Entities\DocumentDetail;
use Yajra\DataTables\EloquentDataTable;

View File

@ -5,7 +5,6 @@
use Illuminate\Support\Facades\Schema;
use Modules\Cetaklabel\Entities\Directorat;
use Modules\Cetaklabel\Entities\Job;
use Modules\Cetaklabel\Entities\SpecialCode;
use Modules\Cetaklabel\Entities\SubDirectorat;
use Modules\Cetaklabel\Entities\SubJob;
use Modules\Cetaklabel\Entities\SubSubJob;

View File

@ -8,8 +8,10 @@
protected $table = 'cardboard_details';
protected $fillable = [
'id',
'cardboard_id',
'document_id'
'document_id',
'status',
];
public function cardboard()

View File

@ -50,7 +50,8 @@
return $this->belongsTo(SpecialCode::class);
}
public function approved(){
public function approved()
{
return $this->belongsTo(User::class, 'approved_by');
}

View File

@ -92,12 +92,13 @@
*
* @param \Modules\Cetaklabel\Entities\Cardboard $cardboard
*/
public function show(Cardboard $cardboard)
public function show(CardboardDataTable $dataTable, Request $request)
{
if (is_null($this->user) || !$this->user->can('document.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any document data !');
}
abort(404);
return $dataTable->render('cetaklabel::app.cardboard-detail.index');
}
/**

View File

@ -0,0 +1,158 @@
<?php
namespace Modules\Cetaklabel\Http\Controllers;
use App\Http\Controllers\Controller;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Modules\Cetaklabel\DataTables\CardboardDataTable;
use Modules\Cetaklabel\DataTables\CardboardDetailDataTable;
use Modules\Cetaklabel\Entities\CardboardDetail;
class CardboardDetailController extends Controller
{
public $user;
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->user = Auth::guard('web')->user();
return $next($request);
});
}
/**
* Display a listing of the Cardboards.
*
* @param \App\DataTables\CardboardDetailDataTable $dataTable
*
* @return mixed
*/
public function index(CardboardDetailDataTable $dataTable)
{
if (is_null($this->user) || !$this->user->can('document.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any document data !');
}
return $dataTable->render('cetaklabel::app.cardboard-detail.index');
}
/**
* Store a newly created Cardboard in storage.
*
* @return mixed
*/
public function store(Request $request)
{
if (is_null($this->user) || !$this->user->can('document.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any document data !');
}
// Validate the request...
$validated = $request->validated();
// Store the Cardboard...
if ($validated) {
try {
CardboardDetail::create($validated);
echo json_encode(['status' => 'success', 'message' => 'Cardboard created successfully.']);
} catch (Exception $e) {
echo json_encode(['status' => 'error', 'message' => 'Cardboard created failed.']);
}
return;
}
echo json_encode(['status' => 'error', 'message' => 'Cardboard created failed.']);
}
/**
* Show the form for creating a new Cardboard.
*/
public function create()
{
if (is_null($this->user) || !$this->user->can('document.create')) {
abort(403, 'Sorry !! You are Unauthorized to create any document data !');
}
abort(404);
}
/**
* Display the specified Cardboard.
*
* @param \Modules\Cetaklabel\Entities\CardboardDetail $cardboard_detail
*/
public function show(CardboardDetailDataTable $dataTable)
{
if (is_null($this->user) || !$this->user->can('document.read')) {
abort(403, 'Sorry !! You are Unauthorized to view any document data !');
}
return $dataTable->render('cetaklabel::app.cardboard-detail.index');
}
/**
* Show the form for editing the specified Cardboard.
*
* @param $id
*/
public function edit($id)
{
if (is_null($this->user) || !$this->user->can('document.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any document data !');
}
$cardboard = CardboardDetail::find($id);
echo json_encode($cardboard);
}
/**
* Update the specified Cardboard in storage.
*
* @param \Modules\Cetaklabel\Entities\CardboardDetail $cardboard_detail
*
* @return mixed
*/
public function update(Request $request, CardboardDetail $cardboard_detail)
{
if (is_null($this->user) || !$this->user->can('document.update')) {
abort(403, 'Sorry !! You are Unauthorized to update any document data !');
}
// Validate the request...
$validated = $request->validated();
// Update the Cardboard...
if ($validated) {
try {
$cardboard_detail->update($validated);
echo json_encode(['status' => 'success', 'message' => 'Cardboard updated successfully.']);
} catch (Exception $e) {
echo json_encode(['status' => 'error', 'message' => 'Cardboard updated failed.']);
}
return;
}
echo json_encode(['status' => 'error', 'message' => 'Cardboard updated failed.']);
}
/**
* Remove the specified Cardboard from storage.
*
* @param \Modules\Cetaklabel\Entities\CardboardDetail $cardboard_detail
*
* @return void
*/
public function destroy(CardboardDetail $cardboard_detail)
{
if (is_null($this->user) || !$this->user->can('document.delete')) {
abort(403, 'Sorry !! You are Unauthorized to delete any document data !');
}
$cardboard_detail->delete();
echo json_encode(['status' => 'success', 'message' => 'Cardboard deleted successfully.']);
}
}

View File

@ -9,26 +9,20 @@
use Haruncpi\LaravelIdGenerator\IdGenerator;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\View;
use Modules\Cetaklabel\DataTables\DocumentDataTable;
use Modules\Cetaklabel\Entities\Directorat;
use Modules\Cetaklabel\Entities\Document;
use Modules\Cetaklabel\Entities\DocumentDetail;
use Modules\Cetaklabel\Entities\DocumentType;
use Modules\Cetaklabel\Entities\Job;
use Modules\Cetaklabel\Entities\SpecialCode;
use Modules\Cetaklabel\Entities\SubDirectorat;
use Modules\Cetaklabel\Entities\SubJob;
use Modules\Cetaklabel\Entities\SubSubJob;
use Modules\Cetaklabel\Http\Requests\Document\StoreDocumentRequest;
use Modules\Cetaklabel\Http\Requests\Document\UpdateDocumentRequest;
use Response;
// Reference the Dompdf namespace
use Dompdf\Dompdf;
// Reference the Options namespace
use Dompdf\Options;
// Reference the Font Metrics namespace
use Dompdf\FontMetrics;
class DocumentController extends Controller

View File

@ -6,9 +6,6 @@
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Modules\Cetaklabel\Entities\Document;
use Modules\Cetaklabel\Entities\DocumentDetail;
class SettingsController extends Controller
{

View File

@ -21,7 +21,8 @@
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
public function authorize()
: bool
{
return true;
}
@ -31,7 +32,8 @@
*
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
*/
public function rules(): array
public function rules()
: array
{
return [
'kode' => 'required|string',
@ -52,7 +54,8 @@
/**
* Configure the validator instance.
*/
public function withValidator(Validator $validator): void
public function withValidator(Validator $validator)
: void
{
$validator->after(function (Validator $validator) {
if ($validator->errors()->any()) {
@ -66,7 +69,8 @@
});
}
protected function failedValidation(Validator|\Illuminate\Contracts\Validation\Validator $validator): JsonResponse
protected function failedValidation(Validator|\Illuminate\Contracts\Validation\Validator $validator)
: JsonResponse
{
$errors = (new ValidationException($validator))->errors();
@ -77,7 +81,8 @@
], JsonResponse::HTTP_UNPROCESSABLE_ENTITY));
}
protected function prepareForValidation(): void
protected function prepareForValidation()
: void
{
$directorat = Directorat::find($this->directorat_id);
@ -126,7 +131,6 @@
}
}
$this->merge([
@ -138,7 +142,8 @@
]);
}
private function sumHalaman($prefix,$id, $dus = 1){
private function sumHalaman($prefix, $id, $dus = 1)
{
$document = Document::where(['kode_odner' => substr($prefix, 0, 8), 'sequence_odner' => $id, 'sequence_dus' => $dus])->first();
if ($document == null) {

View File

@ -0,0 +1,14 @@
@php
$route = explode('.', Route::currentRouteName());
@endphp
<div class="d-flex flex-row flex-center">
<a href="{{ route($route[0].'.edit',['cardboard_detail' => $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,98 @@
<!--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', '.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});
LaravelDataTables["{{$route[0]}}-table"].ajax.reload();
}
});
}
})
})
})
</script>
@endpush
@section('styles')
<style>
.dataTables_filter {
display: none;
}
</style>
@endsection

View File

@ -0,0 +1,91 @@
<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 Cardboard">
</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.cardboard-detail._table')
</div>
<!--end::Card body-->
</div>
<!--end::Card-->
</x-default-layout>

View File

@ -2,6 +2,12 @@
$route = explode('.', Route::currentRouteName());
@endphp
<div class="d-flex flex-row flex-center">
<a href="{{ route('cardboard-detail.show',['cardboard_detail' => $model->id]) }}"
class="btn btn-icon btn-bg-light btn-active-light-primary btn-sm me-1">
{!! getIcon("cube-3", "fs-1 text-warning","duotune") !!}
</a>
<a href="{{ route($route[0].'.edit',['cardboard' => $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") !!}

View File

@ -15,7 +15,11 @@
}
@media print {
.pagebreak { page-break-before: always; } /* page-break-after works, as well */
.pagebreak {
page-break-before: always;
}
/* page-break-after works, as well */
}

View File

@ -12,6 +12,7 @@
*/
use Modules\Cetaklabel\Http\Controllers\CardboardController;
use Modules\Cetaklabel\Http\Controllers\CardboardDetailController;
use Modules\Cetaklabel\Http\Controllers\DirectoratController;
use Modules\Cetaklabel\Http\Controllers\DocumentController;
use Modules\Cetaklabel\Http\Controllers\DocumentTypeController;
@ -38,6 +39,7 @@
Route::resource('document', DocumentController::class);
Route::resource('cardboard', CardboardController::class);
Route::resource('cardboard-detail', CardboardDetailController::class);
Route::get('document-download/{id}', [DocumentController::class, 'download'])->name('document.download');
Route::get('document-label/{id}', [DocumentController::class, 'label'])->name('document.label');
Route::get('document-odner/{id}', [DocumentController::class, 'odner'])->name('document.odner');