Membuat tampilan menu master ijin usaha

This commit is contained in:
2024-09-18 11:06:17 +07:00
parent b2b7559ed0
commit 2041b38980
16 changed files with 943 additions and 20 deletions

View File

@@ -0,0 +1,166 @@
<?php
namespace Modules\Lpj\Http\Controllers;
use App\Http\Controllers\Controller;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\Lpj\Http\Requests\IjinUsahaRequest;
use Modules\Lpj\Models\IjinUsaha;
class IjinUsahaController extends Controller
{
public $user;
/**
* Display a listing of the resource.
*/
public function index()
{
return view('lpj::Ijin_usaha.index');
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('lpj::Ijin_usaha.create');
}
/**
* Store a newly created resource in storage.
*/
public function store(IjinUsahaRequest $request)
{
$validate = $request->validated();
if ($validate) {
try {
IjinUsaha::create($validate);
return redirect()
->route('basicdata.ijin_usaha.index')
->with('success', 'Ijin Usaha created successfully');
} catch (Exception $e) {
return redirect()
->route('basicdata.ijin_usaha.create')
->with('error', 'Failed to create ijin Usaha');
}
}
}
/**
* Show the specified resource.
*/
public function show($id)
{
// return view('lpj::show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
$ijin_usaha = IjinUsaha::find($id);
return view('lpj::Ijin_usaha.create', compact('ijin_usaha'));
}
/**
* Update the specified resource in storage.
*/
public function update(IjinUsahaRequest $request, $id)
{
$validate = $request->validated();
if ($validate) {
try {
// Update in database
$ijin_usaha = IjinUsaha::find($id);
$ijin_usaha->update($validate);
return redirect()
->route('basicdata.ijin_usaha.index')
->with('success', 'Ijin Usaha updated successfully');
} catch (Exception $e) {
return redirect()
->route('basicdata.ijin_usaha.edit', $id)
->with('error', 'Failed to update ijin$ijin_usaha');
}
}
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$ijin_usaha = IjinUsaha::find($id);
$ijin_usaha->delete();
echo json_encode(['success' => true, 'message' => 'Ijin Usaha deleted successfully']);
} catch (Exception $e) {
echo json_encode(['success' => false, 'message' => 'Failed to delete Ijin Usaha']);
}
}
public function dataForDatatables(Request $request)
{
if (is_null($this->user) || !$this->user->can('Ijin_usaha.view')) {
//abort(403, 'Sorry! You are not allowed to view users.');
}
// Retrieve data from the database
$query = IjinUsaha::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('nama_ijin_usaha', '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,
]);
}
}

View File

@@ -0,0 +1,135 @@
<?php
namespace Modules\Lpj\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\Lpj\Models\KJPP;
class KJPPController extends Controller
{
public $user;
/**
* Display a listing of the resource.
*/
public function index()
{
return view('lpj::kjpp.index');
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('lpj::create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
//
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('lpj::show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
return view('lpj::edit');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
//
}
public function dataForDatatables(Request $request)
{
if (is_null($this->user) || !$this->user->can('kjpp.view')) {
//abort(403, 'Sorry! You are not allowed to view users.');
}
// Retrieve data from the database
$query = KJPP::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('nomor', 'LIKE', "%$search%");
$q->orWhere('nama_kjpp', '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,
]);
}
public function export()
{
// return Excel::download(new CurrencyExport, 'currency.xlsx');
}
}

View File

@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\Lpj\Models\Penawaran;
class TenderController extends Controller
{
@@ -17,36 +18,42 @@ class TenderController extends Controller
return view('lpj::penawaran/index');
}
public function proses_penawaran_index()
{
return view('lpj::proses_penawaran/index');
}
public function penawaran_ulang_index()
{
return view('lpj::penawaran_ulang/index');
}
/**
* Show the form for creating a new resource.
*/
public function create()
public function penawaran_create()
{
return view('lpj::create');
return view('lpj::penawaran/create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
public function penawaran_store(Request $request): RedirectResponse
{
//
// $validated = $request->validate([
// 'nama_kjpp_sebelumnya' => 'required|string',
// 'biaya_kjpp_sebelumnya' => 'required|numeric',
// 'tgl_penilaian_sebelumnya' => 'required|date',
// 'nama_kjpp_1' => 'required|exists:kjpps,id',
// 'nama_kjpp_2' => 'required|exists:kjpps,id',
// 'nama_kjpp_3' => 'required|exists:kjpps,id',
// 'data_jaminan_legalitas' => 'required|string',
// 'tujuan_penilaian' => 'required|in:Penjaminan Hutang,Lelang,Revaluasi Aset',
// 'jenis_laporan' => 'required|in:Short report,Full report',
// 'batas_waktu' => 'required|date',
// 'catatan' => 'nullable|string'
// ]);
// Penawaran::create($validated);
// return redirect()->back()->with('success', 'Data berhasil disimpan!');
}
/**
* Show the specified resource.
*/
public function show($id)
public function penawaran_show($id)
{
return view('lpj::show');
}
@@ -74,4 +81,14 @@ class TenderController extends Controller
{
//
}
public function proses_penawaran_index()
{
return view('lpj::proses_penawaran/index');
}
public function penawaran_ulang_index()
{
return view('lpj::penawaran_ulang/index');
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Modules\Lpj\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class IjinUsahaRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
$rules = [
'nama_ijin_usaha' => 'required|string|not_regex:/^\d+$/|max:255'
];
return $rules;
}
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
public function messages(): array
{
return [
'nama_ijin_usaha.required' => 'Nama Ijin Usaha harus diisi!',
'nama_ijin_usaha.not_regex' => 'Nama Ijin Usaha harus berupa huruf!',
'nama_ijin_usaha.max' => 'Nama Ijin Usaha maksimal 255 huruf!'
];
}
}

24
app/Models/IjinUsaha.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
namespace Modules\Lpj\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Modules\Lpj\Database\Factories\IjinUsahaFactory;
class IjinUsaha extends Model
{
use HasFactory;
protected $table = 'ijin_usaha';
/**
* The attributes that are mass assignable.
*/
protected $fillable = ['nama_ijin_usaha'];
// protected static function newFactory(): IjinUsahaFactory
// {
// //return IjinUsahaFactory::new();
// }
}

32
app/Models/KJPP.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
namespace Modules\Lpj\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Modules\Lpj\Database\Factories\KJPPFactory;
class KJPP extends Model
{
use HasFactory;
// Define the table if not using default table naming
protected $table = 'kjpp';
/**
* The attributes that are mass assignable.
*/
protected $guarded = ['id'];
// If you're using JSON columns, you may want to cast them properly
protected $casts = [
'jenis_usaha' => 'array',
'pengalaman' => 'array',
'kerjasama_sejak' => 'date', // For date fields
];
// protected static function newFactory(): KJPPFactory
// {
// //return KJPPFactory::new();
// }
}