feat(daftar-pustaka) : tambah daftar pustaka dan categori pustaka, lihat detail, tambah, edit
This commit is contained in:
152
app/Http/Controllers/CategoryDaftarPustakaController.php
Normal file
152
app/Http/Controllers/CategoryDaftarPustakaController.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\CategoryDaftarPustaka;
|
||||
use Modules\Lpj\Http\Requests\CategoryDaftarPustakaRequest;
|
||||
|
||||
class CategoryDaftarPustakaController extends Controller
|
||||
{
|
||||
public $user;
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::category-daftar-pustaka.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('lpj::category-daftar-pustaka.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(CategoryDaftarPustakaRequest $request)
|
||||
{
|
||||
$validated = $request->validated();
|
||||
if ($validated) {
|
||||
try {
|
||||
CategoryDaftarPustaka::create($validated);
|
||||
return redirect()->route('category-daftar-pustaka.index')->with('success', 'Data Berhasil Disimpan');
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->route('category-daftar-pustaka.index')->with('error', $th->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$category = CategoryDaftarPustaka::where('id', $id)->first();
|
||||
return view('lpj::category-daftar-pustaka.show', compact('category'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('lpj::category-daftar-pustaka.create', ['category' => CategoryDaftarPustaka::where('id', $id)->first()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(CategoryDaftarPustakaRequest $request, $id)
|
||||
{
|
||||
$validated = $request->validated();
|
||||
if ($validated) {
|
||||
try {
|
||||
CategoryDaftarPustaka::where('id', $id)->update($validated);
|
||||
return redirect()->route('category-daftar-pustaka.index')->with('success', 'Data Berhasil Disimpan');
|
||||
} catch (\Throwable $th) {
|
||||
return redirect()->route('category-daftar-pustaka.index')->with('error', $th->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
CategoryDaftarPustaka::where('id', $id)->delete();
|
||||
return response()->json(['success' => true, 'message' => 'Data Berhasil Dihapus']);
|
||||
} catch (\Throwable $th) {
|
||||
return response()->json(['success' => false, 'message' => $th->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('jenis_aset.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = CategoryDaftarPustaka::query();
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = 0 + 1;
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
}
|
||||
129
app/Http/Controllers/DaftarPustakaController.php
Normal file
129
app/Http/Controllers/DaftarPustakaController.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Models\CategoryDaftarPustaka;
|
||||
use Modules\Lpj\Services\DaftarPustakaService;
|
||||
use Modules\Lpj\Http\Requests\DaftarPustakaRequest;
|
||||
|
||||
class DaftarPustakaController extends Controller
|
||||
{
|
||||
private $daftarPustaka;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->daftarPustaka = app(DaftarPustakaService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$categories = CategoryDaftarPustaka::all();
|
||||
$daftar_pustaka = $this->daftarPustaka->getAllDaftarPustaka($request);
|
||||
|
||||
return view('lpj::daftar-pustaka.index', [
|
||||
'categories' => $categories,
|
||||
'daftar_pustaka' => $daftar_pustaka,
|
||||
'page' => $daftar_pustaka->currentPage(),
|
||||
'pageCount' => $daftar_pustaka->lastPage(),
|
||||
'limit' => $daftar_pustaka->perPage(),
|
||||
'total' => $daftar_pustaka->total(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$categories = CategoryDaftarPustaka::all();
|
||||
// dd($categories);
|
||||
return view('lpj::daftar-pustaka.create', compact('categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(DaftarPustakaRequest $request)
|
||||
{
|
||||
|
||||
$validate = $request->validated();
|
||||
// dd($validate);
|
||||
$file = $request->file('attachment');
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
$this->daftarPustaka->storeDaftarPustaka($validate, $file);
|
||||
return redirect()
|
||||
->route('daftar-pustaka.index')
|
||||
->with('success', 'Daftar Pustaka created successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('daftar-pustaka.create')
|
||||
->with('error', 'Failed to create daftar pustaka');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$daftarPustaka = $this->daftarPustaka->getDaftarPustakaById($id);
|
||||
$categories = CategoryDaftarPustaka::all();
|
||||
|
||||
return view('lpj::daftar-pustaka.show', compact('daftarPustaka', 'categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$daftarPustaka = $this->daftarPustaka->getDaftarPustakaById($id);
|
||||
$categories = CategoryDaftarPustaka::all();
|
||||
return view('lpj::daftar-pustaka.create', compact('daftarPustaka', 'categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(DaftarPustakaRequest $request, $id)
|
||||
{
|
||||
$validate = $request->validated();
|
||||
if ($validate) {
|
||||
try {
|
||||
// Save to database
|
||||
$file = $request->file('attachment');
|
||||
$this->daftarPustaka->updateDaftarPustaka($validate, $file, $id);
|
||||
return redirect()
|
||||
->route('daftar-pustaka.index')
|
||||
->with('success', 'Daftar Pustaka updated successfully');
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('daftar-pustaka.create')
|
||||
->with('error', 'Failed to update daftar pustaka');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
try {
|
||||
$this->daftarPustaka->deleteDaftarPustaka($id);
|
||||
return response()->json(['success' => true, 'message' => 'Daftar Pustaka deleted successfully']);
|
||||
} catch (Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Failed to delete daftar pustaka']);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/CategoryDaftarPustakaRequest.php
Normal file
33
app/Http/Requests/CategoryDaftarPustakaRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CategoryDaftarPustakaRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|max:255',
|
||||
];
|
||||
|
||||
if ($this->method() == 'PUT') {
|
||||
$rules['code'] = 'required|max:50|unique:category_daftar_pustaka,code,' . $this->id;
|
||||
} else {
|
||||
$rules['code'] = 'required|max:50|unique:category_daftar_pustaka,code';
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
38
app/Http/Requests/DaftarPustakaRequest.php
Normal file
38
app/Http/Requests/DaftarPustakaRequest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DaftarPustakaRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
||||
$rules = [
|
||||
'judul' => 'required|max:255',
|
||||
'category_id' => 'required',
|
||||
'deskripsi' => 'nullable',
|
||||
];
|
||||
|
||||
if ($this->method() == 'PUT') {
|
||||
$rules['attachment'] = 'nullable|mimes:pdf,jpg,jpeg,png,gif';
|
||||
} else {
|
||||
$rules['attachment'] = 'required|mimes:pdf,jpg,jpeg,png,gif';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
27
app/Models/CategoryDaftarPustaka.php
Normal file
27
app/Models/CategoryDaftarPustaka.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\CategoryDaftarPustakaFactory;
|
||||
|
||||
class CategoryDaftarPustaka extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'category_daftar_pustaka';
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'name',
|
||||
'code',
|
||||
];
|
||||
|
||||
public function daftarPustaka(){
|
||||
return $this->hasMany(DaftarPustaka::class);
|
||||
}
|
||||
|
||||
}
|
||||
29
app/Models/DaftarPustaka.php
Normal file
29
app/Models/DaftarPustaka.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Lpj\Database\Factories\DaftarPustakaFactory;
|
||||
|
||||
class DaftarPustaka extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'daftar_pustaka';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'category_id',
|
||||
'judul',
|
||||
'attachment',
|
||||
'deskripsi',
|
||||
];
|
||||
|
||||
public function category(){
|
||||
return $this->belongsTo(CategoryDaftarPustaka::class);
|
||||
}
|
||||
}
|
||||
94
app/Services/DaftarPustakaService.php
Normal file
94
app/Services/DaftarPustakaService.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Services;
|
||||
|
||||
use Modules\Lpj\Models\DaftarPustaka;
|
||||
|
||||
class DaftarPustakaService
|
||||
{
|
||||
public function storeDaftarPustaka(array $data, $file)
|
||||
{
|
||||
if ($file) {
|
||||
$data['attachment'] = $this->handleUpload($file);
|
||||
}
|
||||
return DaftarPustaka::create($data);
|
||||
}
|
||||
|
||||
public function updateDaftarPustaka($data, $file, $id)
|
||||
{
|
||||
// Ambil data inputan yang diperlukan saja
|
||||
|
||||
$daftarPustaka = DaftarPustaka::findOrFail($id);
|
||||
|
||||
// Jika ada file baru yang diupload
|
||||
if ($file) {
|
||||
// (Opsional) Hapus file lama
|
||||
if ($daftarPustaka->attachment && file_exists(public_path($daftarPustaka->attachment))) {
|
||||
unlink(public_path($daftarPustaka->attachment));
|
||||
}
|
||||
|
||||
// Upload file baru
|
||||
$data['attachment'] = $this->handleUpload($file);
|
||||
}
|
||||
|
||||
// Update data
|
||||
$daftarPustaka->update($data);
|
||||
|
||||
return $daftarPustaka;
|
||||
}
|
||||
|
||||
|
||||
public function deleteDaftarPustaka($id)
|
||||
{
|
||||
return DaftarPustaka::where('id', $id)->delete();
|
||||
}
|
||||
|
||||
public function getDaftarPustakaById($id)
|
||||
{
|
||||
return DaftarPustaka::where('id', $id)->first();
|
||||
}
|
||||
|
||||
// get all with pagination
|
||||
public function getAllDaftarPustaka($request)
|
||||
{
|
||||
$query = DaftarPustaka::query();
|
||||
|
||||
// Filter pencarian
|
||||
if (!empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->orWhere('judul', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// Filter kategori
|
||||
if (!empty($request->get('category'))) {
|
||||
$category = explode(',', $request->input('category'));
|
||||
$query->whereIn('category_id', $category);
|
||||
}
|
||||
|
||||
// Default pagination
|
||||
$page = (int) $request->get('page', 1);
|
||||
$size = (int) $request->get('size', 10);
|
||||
|
||||
return $query->paginate($size, ['*'], 'page', $page);
|
||||
}
|
||||
|
||||
|
||||
private function handleUpload($file)
|
||||
{
|
||||
$today = now();
|
||||
$folderPath = 'daftar_pustaka/' . $today->format('Y/m/d');
|
||||
|
||||
if (!file_exists(public_path($folderPath))) {
|
||||
mkdir(public_path($folderPath), 0755, true);
|
||||
}
|
||||
|
||||
$fileName = $file->getClientOriginalName();
|
||||
$file->move(public_path($folderPath), $fileName);
|
||||
|
||||
return $folderPath . '/' . $fileName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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('category_daftar_pustaka', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('code')->unique()->index();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
$table->timestamp('authorized_at')->nullable();
|
||||
$table->char('authorized_status', 1)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||
$table->unsignedBigInteger('authorized_by')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('category_daftar_pustaka');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?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('daftar_pustaka', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('judul');
|
||||
$table->string('attachment')->nullable();
|
||||
$table->text('deskripsi');
|
||||
$table->unsignedBigInteger('category_id');
|
||||
$table->foreign('category_id')->references('id')->on('category_daftar_pustaka');
|
||||
$table->timestamps();
|
||||
$table->timestamp('authorized_at')->nullable();
|
||||
$table->char('authorized_status', 1)->nullable();
|
||||
$table->softDeletes();
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
$table->unsignedBigInteger('updated_by')->nullable();
|
||||
$table->unsignedBigInteger('deleted_by')->nullable();
|
||||
$table->unsignedBigInteger('authorized_by')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('daftar_pustaka');
|
||||
}
|
||||
};
|
||||
28
module.json
28
module.json
@@ -607,6 +607,23 @@
|
||||
"EO Appraisal",
|
||||
"senior-officer"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Daftar Pustaka",
|
||||
"path": "daftar-pustaka",
|
||||
"icon": "ki-filled ki-filter-tablet text-lg text-primary",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": [
|
||||
"administrator",
|
||||
"pemohon-ao",
|
||||
"pemohon-eo",
|
||||
"admin",
|
||||
"DD Appraisal",
|
||||
"EO Appraisal",
|
||||
"senior-officer"
|
||||
]
|
||||
}
|
||||
],
|
||||
"master": [
|
||||
@@ -1149,6 +1166,17 @@
|
||||
"administrator",
|
||||
"admin"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Kategori Daftar Pustaka",
|
||||
"path": "category-daftar-pustaka",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": [
|
||||
"administrator",
|
||||
"admin"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
64
resources/views/category-daftar-pustaka/create.blade.php
Normal file
64
resources/views/category-daftar-pustaka/create.blade.php
Normal file
@@ -0,0 +1,64 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{-- {{ Breadcrumbs::render(request()->route()->getName()) }} --}}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
|
||||
<form
|
||||
action="{{ isset($category->id) ? route('category-daftar-pustaka.update', $category->id) : route('category-daftar-pustaka.store') }}"
|
||||
method="POST">
|
||||
@csrf
|
||||
@if (isset($category->id))
|
||||
@method('PUT')
|
||||
<input type="text" name="id" value="{{ $category->id }}" hidden class="hidden">
|
||||
@endif
|
||||
<div class="card border border-agi-100 pb-2.5">
|
||||
<div class="card-header bg-agi-50" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
Tambah
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('category-daftar-pustaka.index') }}" class="btn btn-xs btn-info"><i
|
||||
class="ki-filled ki-exit-left"></i> Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Code
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('code') border-danger bg-danger-light @enderror" type="text"
|
||||
name="code" value="{{ $category->code ?? old('code') }}"
|
||||
{{ isset($category->id) ? 'readonly' : '' }}>
|
||||
@error('code')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Name
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input input-file @error('name') border-danger bg-danger-light @enderror"
|
||||
type="text" name="name" value="{{ $category->name ?? old('name') }}">
|
||||
@error('name')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
147
resources/views/category-daftar-pustaka/index.blade.php
Normal file
147
resources/views/category-daftar-pustaka/index.blade.php
Normal file
@@ -0,0 +1,147 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{-- {{ Breadcrumbs::render('basicdata.jenis-aset') }} --}}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="card border border-agi-100 card-grid min-w-full" data-datatable="false" data-datatable-page-size="10" data-datatable-state-save="false" id="category-daftar-pustaka-table" data-api-url="{{ route('category-daftar-pustaka.datatables') }}">
|
||||
<div class="card-header bg-agi-50 py-5 flex-wrap">
|
||||
<h3 class="card-title">
|
||||
Daftar Kategori Daftar Pustaka
|
||||
</h3>
|
||||
<div class="flex flex-wrap gap-2 lg:gap-5">
|
||||
<div class="flex">
|
||||
<label class="input input-sm"> <i class="ki-filled ki-magnifier"> </i>
|
||||
<input placeholder="Search Kategori Daftar Pustaka" id="search" type="text" value="">
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2.5">
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<a class="btn btn-sm btn-light" href=""> Export to Excel </a>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('category-daftar-pustaka.create') }}"> Tambah Kategori </a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="scrollable-x-auto">
|
||||
<table class="table table-auto table-border align-middle text-gray-700 font-medium text-sm" data-datatable-table="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-14">
|
||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
||||
</th>
|
||||
<th class="min-w-[250px]" data-datatable-column="code">
|
||||
<span class="sort"> <span class="sort-label"> Code </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[250px]" data-datatable-column="name">
|
||||
<span class="sort"> <span class="sort-label"> Name </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer justify-center md:justify-between flex-col md:flex-row gap-3 text-gray-600 text-2sm font-medium">
|
||||
<div class="flex items-center gap-2">
|
||||
Show
|
||||
<select class="select select-sm w-16" data-datatable-size="true" name="perpage"> </select> per page
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<span data-datatable-info="true"> </span>
|
||||
<div class="pagination" data-datatable-pagination="true">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
function deleteData(data) {
|
||||
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) {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax(`category-daftar-pustaka/${data}`, {
|
||||
type: 'DELETE'
|
||||
}).then((response) => {
|
||||
swal.fire('Deleted!', 'User has been deleted.', 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Error!', 'An error occurred while deleting the file.', 'error');
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<script type="module">
|
||||
const element = document.querySelector('#category-daftar-pustaka-table ');
|
||||
const searchInput = document.getElementById('search');
|
||||
|
||||
const apiUrl = element.getAttribute('data-api-url');
|
||||
const dataTableOptions = {
|
||||
apiEndpoint: apiUrl,
|
||||
pageSize: 5,
|
||||
columns: {
|
||||
select: {
|
||||
render: (item, data, context) => {
|
||||
const checkbox = document.createElement('input');
|
||||
checkbox.className = 'checkbox checkbox-sm';
|
||||
checkbox.type = 'checkbox';
|
||||
checkbox.value = data.id.toString();
|
||||
checkbox.setAttribute('data-datatable-row-check', 'true');
|
||||
return checkbox.outerHTML.trim();
|
||||
},
|
||||
},
|
||||
code: {
|
||||
title: 'Code',
|
||||
},
|
||||
name: {
|
||||
title: 'Name',
|
||||
},
|
||||
actions: {
|
||||
title: 'Status',
|
||||
render: (item, data) => {
|
||||
return `<div class="flex flex-nowrap justify-center">
|
||||
<a class="btn btn-sm btn-icon btn-clear btn-info" href="category-daftar-pustaka/${data.id}/edit">
|
||||
<i class="ki-outline ki-notepad-edit"></i>
|
||||
</a>
|
||||
<a onclick="deleteData(${data.id})" class="delete btn btn-sm btn-icon btn-clear btn-danger">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</a>
|
||||
</div>`;
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
// Custom search functionality
|
||||
searchInput.addEventListener('input', function () {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
113
resources/views/daftar-pustaka/create.blade.php
Normal file
113
resources/views/daftar-pustaka/create.blade.php
Normal file
@@ -0,0 +1,113 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{-- {{ Breadcrumbs::render(request()->route()->getName()) }} --}}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
<form
|
||||
action="{{ isset($daftarPustaka->id) ? route('daftar-pustaka.update', $daftarPustaka->id) : route('daftar-pustaka.store') }}"
|
||||
method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@if (isset($daftarPustaka->id))
|
||||
<input type="hidden" name="id" value="{{ $daftarPustaka->id }}">
|
||||
@method('PUT')
|
||||
@endif
|
||||
|
||||
<div class="card border border-agi-100 pb-2.5">
|
||||
<div class="card-header bg-agi-50" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
{{ isset($daftarPustaka->id) ? 'Edit' : 'Tambah' }} Daftar Pustaka
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('daftar-pustaka.index') }}" class="btn btn-xs btn-info"><i
|
||||
class="ki-filled ki-exit-left"></i> Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Judul
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('judul') border-danger bg-danger-light @enderror" type="text"
|
||||
name="judul" value="{{ $daftarPustaka->judul ?? old('judul') }}">
|
||||
@error('judul')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Upload File
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('attachment') border-danger bg-danger-light @enderror" type="file"
|
||||
name="attachment">
|
||||
@error('attachment')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@if (isset($daftarPustaka->attachment))
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
File
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
{{-- ambil nama file pathnya hilangkan --}}
|
||||
<a href="{{ asset($daftarPustaka->attachment) }}" class="badge badge-outline badge-md badge-info">{{ basename($daftarPustaka->attachment) }}
|
||||
<i class="ki-filled ki-cloud-download"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Kategori
|
||||
</label>
|
||||
|
||||
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select class="select tomselect w-full" name="category_id">
|
||||
<option value="">Pilih Kategori</option>
|
||||
@if (isset($categories))
|
||||
@foreach ($categories as $item)
|
||||
<option value="{{ $item->id }}"
|
||||
{{ old('category_id', $daftarPustaka->category_id ?? '') == $item->id ? 'selected' : '' }}>
|
||||
{{ $item->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@error('category_id')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Deskripsi
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<textarea name="deskripsi" class="textarea" id="" cols="30" rows="10">{{ $daftarPustaka->deskripsi ?? old('deskripsi') }}</textarea>
|
||||
@error('deskripsi')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{ isset($daftarPustaka->id) ? 'Update' : 'Simpan' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
307
resources/views/daftar-pustaka/index.blade.php
Normal file
307
resources/views/daftar-pustaka/index.blade.php
Normal file
@@ -0,0 +1,307 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{-- {{ Breadcrumbs::render('basicdata.ijin_usaha') }} --}}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="flex flex-col items-stretch gap-7">
|
||||
<div class="flex items-center gap-3 w-full">
|
||||
<div class="input w-full">
|
||||
<i class="ki-filled ki-magnifier">
|
||||
</i>
|
||||
<input id="search" placeholder="Search Daftar Pustaka, Judul" type="text">
|
||||
<span class="badge badge-outline -me-1.5">
|
||||
⌘ K
|
||||
</span>
|
||||
</div>
|
||||
<!--Filter-->
|
||||
<a class="btn btn-info" id="search_filter" onclick="filterSearch()">
|
||||
<i class="ki-filled ki-filter">
|
||||
</i>
|
||||
Filter
|
||||
</a>
|
||||
<a class="btn btn-light" id="reset_filter" onclick="resetFilter()">
|
||||
<i class="ki-filled ki-arrow-circle-left"></i>
|
||||
Reset Filter
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-5 justify-between mt-3">
|
||||
<h3 class="text-sm text-mono font-medium">
|
||||
page {{ $page }} of {{ $pageCount }} — {{ $limit }} items per page, total
|
||||
{{ $total }} items.
|
||||
</h3>
|
||||
<div class="flex gap-2.5">
|
||||
<select id="category_id" name="category_id" class="select tomselect w-[300px]" multiple>
|
||||
<option value="" selected disabled>Filter by Category</option>
|
||||
@foreach ($categories as $item)
|
||||
<option value="{{ $item->id }}">{{ $item->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<div class="flex toggle-group" data-kt-tabs="true" data-kt-tabs-initialized="true">
|
||||
<a class="btn btn-icon active selected" data-kt-tab-toggle="#daftar_pustaka_grid" onclick="showGrid()"
|
||||
href="javascript:void(0)">
|
||||
<i class="ki-filled ki-category"></i>
|
||||
</a>
|
||||
<a class="btn btn-icon" data-kt-tab-toggle="#daftar_pustaka_list" onclick="showList()"
|
||||
href="javascript:void(0)">
|
||||
<i class="ki-filled ki-row-horizontal"></i>
|
||||
</a>
|
||||
@if (auth()->user()->hasRole(['administrator', 'admin']))
|
||||
<a href="{{ route('daftar-pustaka.create') }}" class="btn btn-primary">
|
||||
<i class="ki-filled ki-plus"></i>
|
||||
Tambah
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4 " id="daftar_pustaka_grid">
|
||||
@if (isset($daftar_pustaka))
|
||||
@foreach ($daftar_pustaka as $item)
|
||||
<div class="card border shadow-none ">
|
||||
<a class="show-pustaka h-[300px] w-full block" href="{{ route('daftar-pustaka.show', $item->id) }}"
|
||||
data-url="{{ $item->attachment }}">
|
||||
<div class="p-4 h-full w-full flex items-center justify-center overflow-hidden">
|
||||
<div class="preview-content h-full w-full"></div>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div class="card-body">
|
||||
<a href="{{ route('daftar-pustaka.show', $item->id) }}">
|
||||
|
||||
<h3 class="text-md font-medium text-gray-900 hover:text-primary cursor-pointer">
|
||||
{{ $item->judul }}</h3>
|
||||
<p class="text-2sm text-gray-700">
|
||||
{{-- batasi panjang deskripsi 50 --}}
|
||||
{{ substr($item->deskripsi, 0, 50) }}
|
||||
</p>
|
||||
</a>
|
||||
<div class="flex justify-between items-center gap-2.5 mt-2">
|
||||
<p class="badge rounded-full badge-sm badge-outline badge-success text-xs text-gray-700">
|
||||
# {{ $item->category->name }}</p>
|
||||
|
||||
@auth
|
||||
@if (auth()->user()->hasRole(['administrator', 'admin']))
|
||||
<div>
|
||||
<a class="btn btn-sm btn-danger" onclick="deleteData({{ $item->id }})">
|
||||
<i class="ki-filled ki-trash">
|
||||
</i>
|
||||
Hapus
|
||||
</a>
|
||||
<a class="btn btn-sm btn-info"
|
||||
href="{{ route('daftar-pustaka.edit', $item->id) }}">
|
||||
<i class="ki-filled ki-pencil">
|
||||
</i>
|
||||
Edit
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
@endauth
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 gap-4 hidden" id="daftar_pustaka_list">
|
||||
@if (isset($daftar_pustaka))
|
||||
@foreach ($daftar_pustaka as $item)
|
||||
<div class="card">
|
||||
<div class="card-body flex items-center flex-wrap justify-between p-2 pe-5 gap-4.5">
|
||||
<div class="flex items-center gap-3.5">
|
||||
<div
|
||||
class="kt-card flex items-center justify-center bg-accent/50 h-[70px] w-[90px] shadow-none">
|
||||
<a class="show-pustaka h-[90px] w-full block"
|
||||
href="{{ route('daftar-pustaka.show', $item->id) }}"
|
||||
data-url="{{ $item->attachment }}">
|
||||
<div class="p-4 h-full w-full flex items-center justify-center overflow-hidden">
|
||||
<div class="preview-content h-full w-full"></div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 cursor-pointer">
|
||||
<a href="{{ route('daftar-pustaka.show', $item->id) }}">
|
||||
<div class="flex items-center mt-1">
|
||||
<a class="hover:text-primary text-sm font-medium text-mono leading-5.5">
|
||||
{{ $item->judul }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="flex items-center flex-wrap gap-3">
|
||||
<span class="kt-badge kt-badge-warning kt-badge-sm rounded-full gap-1">
|
||||
<span class="text-xs font-medium text-foreground">
|
||||
{{ substr($item->deskripsi, 0, 50) }}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-1.5">
|
||||
<p class="badge rounded-full badge-sm badge-outline badge-success text-xs text-gray-700">
|
||||
# {{ $item->category->name }}</p>
|
||||
@auth
|
||||
@if (auth()->user()->hasRole(['administrator', 'admin']))
|
||||
<div>
|
||||
<a class="btn btn-sm btn-danger" onclick="deleteData({{ $item->id }})">
|
||||
<i class="ki-filled ki-trash">
|
||||
</i>
|
||||
Hapus
|
||||
</a>
|
||||
<a class="btn btn-sm btn-info"
|
||||
href="{{ route('daftar-pustaka.edit', $item->id) }}">
|
||||
<i class="ki-filled ki-pencil">
|
||||
</i>
|
||||
Edit
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
@endauth
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
|
||||
|
||||
<div class="pagination flex gap-2 justify-center mt-5">
|
||||
@if ($daftar_pustaka->onFirstPage())
|
||||
<span class="btn disabled"><i class="ki-filled ki-black-left"></i></span>
|
||||
@else
|
||||
<a href="{{ $daftar_pustaka->previousPageUrl() }}" class="btn">
|
||||
<i class="ki-filled ki-black-left"></i>
|
||||
</a>
|
||||
@endif
|
||||
|
||||
@foreach ($daftar_pustaka->getUrlRange(1, $daftar_pustaka->lastPage()) as $page => $url)
|
||||
<a href="{{ $url }}" class="btn {{ $page == $daftar_pustaka->currentPage() ? 'active' : '' }}">
|
||||
{{ $page }}
|
||||
</a>
|
||||
@endforeach
|
||||
|
||||
@if ($daftar_pustaka->hasMorePages())
|
||||
<a href="{{ $daftar_pustaka->nextPageUrl() }}" class="btn">
|
||||
<i class="ki-filled ki-black-right"></i>
|
||||
</a>
|
||||
@else
|
||||
<span class="btn disabled"><i class="ki-filled ki-black-right"></i></span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="{{ asset('vendor/pdfobject.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
function deleteData(data) {
|
||||
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) {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax(`daftar-pustaka/${data}`, {
|
||||
type: 'DELETE'
|
||||
}).then((response) => {
|
||||
swal.fire('Deleted!', 'User has been deleted.', 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Error!', 'An error occurred while deleting the file.', 'error');
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.show-pustaka').forEach(function(element) {
|
||||
const url = element.getAttribute('data-url');
|
||||
const previewContent = element.querySelector('.preview-content');
|
||||
|
||||
if (!previewContent || !url) return;
|
||||
|
||||
const fileExtension = url.split('.').pop().toLowerCase();
|
||||
|
||||
if (fileExtension === 'pdf') {
|
||||
PDFObject.embed(url, previewContent, {
|
||||
height: "100%",
|
||||
width: "100%"
|
||||
});
|
||||
} else if (['jpg', 'jpeg', 'png', 'gif'].includes(fileExtension)) {
|
||||
previewContent.innerHTML = `
|
||||
<img src="${url}" alt="Preview"
|
||||
class="w-full h-full object-cover rounded" />
|
||||
`;
|
||||
} else {
|
||||
previewContent.innerHTML = '<p class="text-center">Unsupported file type</p>';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function showGrid() {
|
||||
document.getElementById("daftar_pustaka_grid").classList.remove("hidden");
|
||||
document.getElementById("daftar_pustaka_grid").classList.add("active");
|
||||
|
||||
document.getElementById("daftar_pustaka_list").classList.add("hidden");
|
||||
document.getElementById("daftar_pustaka_list").classList.remove("active");
|
||||
|
||||
// Update button active class
|
||||
document.querySelectorAll(".toggle-group a").forEach(btn => btn.classList.remove("selected", "active"));
|
||||
event.currentTarget.classList.add("selected", "active");
|
||||
}
|
||||
|
||||
function showList() {
|
||||
document.getElementById("daftar_pustaka_list").classList.remove("hidden");
|
||||
document.getElementById("daftar_pustaka_list").classList.add("active");
|
||||
|
||||
document.getElementById("daftar_pustaka_grid").classList.add("hidden");
|
||||
document.getElementById("daftar_pustaka_grid").classList.remove("active");
|
||||
|
||||
// Update button active class
|
||||
document.querySelectorAll(".toggle-group a").forEach(btn => btn.classList.remove("selected", "active"));
|
||||
event.currentTarget.classList.add("selected", "active");
|
||||
}
|
||||
|
||||
function filterSearch() {
|
||||
const search = document.getElementById('search')?.value || '';
|
||||
|
||||
const select = document.getElementById('category_id');
|
||||
const selectedCategories = Array.from(select.selectedOptions).map(option => option.value);
|
||||
|
||||
const categoryParam = selectedCategories.join(',');
|
||||
|
||||
const url = "{{ route('daftar-pustaka.index') }}?search=" + encodeURIComponent(search) + "&category=" +
|
||||
encodeURIComponent(categoryParam);
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
|
||||
function resetFilter() {
|
||||
const url = "{{ route('daftar-pustaka.index') }}";
|
||||
window.location.href = url;
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
71
resources/views/daftar-pustaka/show.blade.php
Normal file
71
resources/views/daftar-pustaka/show.blade.php
Normal file
@@ -0,0 +1,71 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{-- {{ Breadcrumbs::render(request()->route()->getName()) }} --}}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
|
||||
<form
|
||||
action="{{ isset($daftarPustaka->id) ? route('daftar-pustaka.update', $daftarPustaka->id) : route('daftar-pustaka.store') }}"
|
||||
method="POST">
|
||||
@csrf
|
||||
<div class="card border border-agi-100 pb-2.5">
|
||||
<div class="card-header bg-agi-50" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
{{ $daftarPustaka->judul ?? '' }}
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('daftar-pustaka.index') }}" class="btn btn-xs btn-info"><i
|
||||
class="ki-filled ki-exit-left"></i> Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
<div
|
||||
class=" min-w-3xl w-[1280px] h-[768px]">
|
||||
<div class="p-4 h-full flex flex-col">
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<button type="button" id="downloadBtn" class="btn btn-primary btn-sm">
|
||||
<i class="ki-duotone ki-cloud-download me-1"><span class="path1"></span><span
|
||||
class="path2"></span></i>
|
||||
Download File
|
||||
</button>
|
||||
</div>
|
||||
<div id="previewContent" class="flex-grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border border-t">
|
||||
</div>
|
||||
<div>
|
||||
{{ $daftarPustaka->deskripsi ?? '' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="{{ asset('vendor/pdfobject.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
let url = @json($daftarPustaka->attachment);
|
||||
console.log(url);
|
||||
|
||||
const fileExtension = url.split('.').pop().toLowerCase();
|
||||
const previewContent = document.getElementById('previewContent');
|
||||
|
||||
if (['pdf'].includes(fileExtension)) {
|
||||
PDFObject.embed(url, "#previewContent");
|
||||
} else if (['jpg', 'jpeg', 'png', 'gif'].includes(fileExtension)) {
|
||||
previewContent.innerHTML =
|
||||
`<img src="${url}" alt="Preview" class="max-w-full max-h-full object-contain">`;
|
||||
} else {
|
||||
previewContent.innerHTML = '<p class="text-center">Unsupported file type</p>';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@@ -50,6 +50,9 @@ use Modules\Lpj\Http\Controllers\LaporanMonitoringSoController;
|
||||
use Modules\Lpj\Http\Controllers\LaporanDebitureController;
|
||||
use Modules\Lpj\Http\Controllers\LaporanUserController;
|
||||
use Modules\Lpj\Http\Controllers\LaporanSLAPenilaiController;
|
||||
use Modules\Lpj\Http\Controllers\DaftarPustakaController;
|
||||
use Modules\Lpj\Http\Controllers\CategoryDaftarPustakaController;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -766,6 +769,16 @@ Route::middleware(['auth'])->group(function () {
|
||||
Route::get('datatables', [LaporanSLAPenilaiController::class, 'dataForDatatableSLaPenilai'])->name('datatables');
|
||||
});
|
||||
|
||||
// daftar pustaka
|
||||
Route::resource('daftar-pustaka', DaftarPustakaController::class);
|
||||
|
||||
// category daftar pustaka
|
||||
Route::prefix('category-daftar-pustaka')->name('category-daftar-pustaka.')->group(function () {
|
||||
Route::get('datatables', [CategoryDaftarPustakaController::class, 'dataForDatatables'])->name('datatables');
|
||||
});
|
||||
|
||||
Route::resource('category-daftar-pustaka', CategoryDaftarPustakaController::class);
|
||||
|
||||
});
|
||||
|
||||
require __DIR__ . '/registrasi.php';
|
||||
|
||||
Reference in New Issue
Block a user