diff --git a/app/Exports/IjinUsahaExport.php b/app/Exports/IjinUsahaExport.php new file mode 100644 index 0000000..a7d02e4 --- /dev/null +++ b/app/Exports/IjinUsahaExport.php @@ -0,0 +1,47 @@ +id, + $row->code, + $row->name, + $row->created_at + ]; + } + + public function headings(): array + { + return [ + 'ID', + 'Code', + 'Name', + 'Created At' + ]; + } + + public function columnFormats(): array + { + return [ + 'A' => NumberFormat::FORMAT_NUMBER, + 'B' => NumberFormat::FORMAT_NUMBER, + 'E' => NumberFormat::FORMAT_DATE_DATETIME + ]; + } +} diff --git a/app/Exports/KJPPExport.php b/app/Exports/KJPPExport.php new file mode 100644 index 0000000..f8026c0 --- /dev/null +++ b/app/Exports/KJPPExport.php @@ -0,0 +1,49 @@ +id, + $row->code, + $row->name, + $row->jenis_kantor, + $row->created_at + ]; + } + + public function headings(): array + { + return [ + 'ID', + 'Code', + 'Name', + 'Jenis Kantor / Cabang', + 'Created At' + ]; + } + + public function columnFormats(): array + { + return [ + 'A' => NumberFormat::FORMAT_NUMBER, + 'B' => NumberFormat::FORMAT_NUMBER, + 'E' => NumberFormat::FORMAT_DATE_DATETIME + ]; + } +} diff --git a/app/Http/Controllers/IjinUsahaController.php b/app/Http/Controllers/IjinUsahaController.php new file mode 100644 index 0000000..360d223 --- /dev/null +++ b/app/Http/Controllers/IjinUsahaController.php @@ -0,0 +1,174 @@ +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('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, + ]); + } + + public function export() + { + return Excel::download(new IjinUsahaExport, 'ijin_usaha.xlsx'); + } +} diff --git a/app/Http/Controllers/KJPPController.php b/app/Http/Controllers/KJPPController.php new file mode 100644 index 0000000..8be9d4d --- /dev/null +++ b/app/Http/Controllers/KJPPController.php @@ -0,0 +1,166 @@ +validated(); + + + if ($validate) { + $file = $request->file('attachment'); + $filename = $file ? time() . '.' . $file->getClientOriginalExtension() : 'default.pdf'; + + if ($file) { + $file->storeAs('uploads_pdf', $filename, 'public'); + } else { + Storage::copy('/home/bagi/Downloads/default.pdf', 'public/uploads_pdf/' . $filename); + } + + dd($validate); + KJPP::create($validate); + return redirect() + ->route('basicdata.kjpp.index') + ->with('success', 'Ijin Usaha created successfully'); + } + } + + /** + * 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(KJPP $request, $id) + { + // + } + + /** + * 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('code', 'LIKE', "%$search%"); + $q->orWhere('name', 'LIKE', "%$search%"); + $q->orWhere('jenis_kantor', '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 KJPPExport, 'currency.xlsx'); + } +} diff --git a/app/Http/Controllers/TenderController.php b/app/Http/Controllers/TenderController.php new file mode 100644 index 0000000..d23fd30 --- /dev/null +++ b/app/Http/Controllers/TenderController.php @@ -0,0 +1,94 @@ +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 penawaran_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 proses_penawaran_index() + { + return view('lpj::proses_penawaran/index'); + } + + public function penawaran_ulang_index() + { + return view('lpj::penawaran_ulang/index'); + } +} diff --git a/app/Http/Requests/IjinUsahaRequest.php b/app/Http/Requests/IjinUsahaRequest.php new file mode 100644 index 0000000..6f5cd80 --- /dev/null +++ b/app/Http/Requests/IjinUsahaRequest.php @@ -0,0 +1,46 @@ + 'required|string|not_regex:/^\d+$/|max:255' + ]; + + if ($this->method() == 'PUT') { + $rules['code'] = 'required|max:50|unique:ijin_usaha,code,' . $this->id; + } else { + $rules['code'] = 'required|max:50|unique:ijin_usaha,code'; + } + + return $rules; + } + + /** + * Determine if the user is authorized to make this request. + */ + public function authorize(): bool + { + return true; + } + + public function messages(): array + { + return [ + 'code.required' => 'Kode Ijin Usaha harus diisi!', + 'code.max' => 'Kode Ijin Usaha maksimal 255 huruf!', + 'code.unique' => 'Kode Ijin Usaha tidak boleh sama!', + 'name.required' => 'Nama Ijin Usaha harus diisi!', + 'name.not_regex' => 'Nama Ijin Usaha harus berupa huruf!', + 'name.max' => 'Nama Ijin Usaha maksimal 255 huruf!' + ]; + } +} diff --git a/app/Http/Requests/KJPPRequest.php b/app/Http/Requests/KJPPRequest.php new file mode 100644 index 0000000..b5f4622 --- /dev/null +++ b/app/Http/Requests/KJPPRequest.php @@ -0,0 +1,122 @@ + 'required|string|not_regex:/^\d+$/|max:255', + 'jenis_kantor' => 'required', + 'nomor_ijin_usaha' => 'required', + 'province_code' => 'required', + 'city_code' => 'required', + 'district_code' => 'required', + 'village_code' => 'required', + 'address' => 'required', + 'postal_code' => 'required|numeric', + 'nomor_telepon_kantor' => 'required|numeric|digits_between:8,15', + 'email_kantor' => 'required|email', + 'nama_pimpinan' => 'required|string|not_regex:/^\d+$/|max:255', + 'nomor_hp_pimpinan' => 'required|numeric|digits_between:10,15', + 'nama_pic_reviewer' => 'required|string|not_regex:/^\d+$/|max:255', + 'nomor_hp_pic_reviewer' => 'required|numeric|digits_between:10,15', + 'nama_pic_admin' => 'required|string|not_regex:/^\d+$/|max:255', + 'nomor_hp_pic_admin' => 'required|numeric|digits_between:10,15', + 'nama_pic_marketing' => 'required|string|not_regex:/^\d+$/|max:255', + 'nomor_hp_pic_marketing' => 'required|numeric|digits_between:10,15', + 'ijin_usaha.*' => 'nullable', + 'jenis_jaminan.*' => 'nullable', + 'attachment' => 'nullable|mimes:pdf|max:1024' + ]; + + if ($this->method() == 'PUT') { + $rules['code'] = 'required|max:50|unique:kjpp,code,' . $this->id; + } else { + $rules['code'] = 'required|max:50|unique:kjpp,code'; + } + + return $rules; + } + + /** + * Determine if the user is authorized to make this request. + */ + public function authorize(): bool + { + return true; + } + + public function prepareForValidation(): void + { + if ($this->method() == 'POST') { + $this->merge([ + 'code' => IdGenerator::generate( + ['table' => 'ijin_usaha', 'length' => 5, 'prefix' => 'IU', 'field' => 'code'], + ['table' => 'jenis_jaminan', 'length' => 5, 'prefix' => 'JJ', 'field' => 'code'], + ) + ]); + } + + $this->merge([ + 'ijin_usaha_id' => json_encode($this->ijin_usaha_id), + 'jenis_aset_id' => json_encode($this->jenis_aset_id) + ]); + } + + public function messages(): array + { + return [ + 'code.required' => 'Kode KJPP Wajib diisi!', + 'code.max' => 'Kode KJPP maksimal 255 huruf!', + 'code.unique' => 'Kode KJPP tidak boleh sama!', + 'name.required' => 'Nama KJPP Wajib diisi!', + 'name.not_regex' => 'Nama KJPP harus berupa huruf!', + 'name.max' => 'Nama KJPP maksimal 255 huruf!', + 'jenis_kantor.required' => 'Jenis Kantor Wajib diisi!', + 'nomor_ijin_usaha.required' => 'Nomor Ijin Usaha Wajib diisi!', + 'nomor_ijin_usaha.max' => 'Nomor Ijin Usaha maksimal 255 huruf!', + 'province_code.required' => 'Provinsi Wajib diisi!', + 'city_code.required' => 'Kota / Kabupaten Wajib diisi!', + 'district_code.required' => 'Kecamatan Wajib diisi!', + 'village_code.required' => 'Kelurahan Wajib diisi!', + 'postal_code.required' => 'Kode Pos Wajib diisi!', + 'postal_code.numeric' => 'Kode Pos harus berupa angka!', + 'address.required' => 'Alamat Kantor Wajib diisi!', + 'nomor_telepon_kantor.required' => 'Nomor Telepon Kantor Wajib diisi!', + 'nomor_telepon_kantor.numeric' => 'Nomor Telepon Kantor harus berupa angka!', + 'nomor_telepon_kantor.digits_between' => 'Nomor Telepon Kantor minimum 8 digit dan maksimum 15 digit!', + 'email_kantor.required' => 'Email Kantor Wajib diisi!', + 'email_kantor.email' => 'Email Kantor tidak valid!', + 'nama_pimpinan.required' => 'Nama Pimpinan Wajib diisi!', + 'nama_pimpinan.not_regex' => 'Nama Pimpinan harus berupa huruf!', + 'nomor_hp_pimpinan.required' => 'Nomor HP Pimpinan Wajib diisi!', + 'nomor_hp_pimpinan.numeric' => 'Nomor HP Pimpinan harus berupa angka!', + 'nomor_hp_pimpinan.digits_between' => 'Nomor HP Pimpinan minimum 10 digit dan maksimum 15 digit!', + 'nama_pic_reviewer.required' => 'Nama PIC Reviewer Wajib diisi!', + 'nama_pic_reviewer.not_regex' => 'Nama PIC Reviewer harus berupa huruf!', + 'nomor_hp_pic_reviewer.required' => 'Nomor HP PIC Reviewer Wajib diisi!', + 'nomor_hp_pic_reviewer.numeric' => 'Nomor HP PIC Reviewer harus berupa angka!', + 'nomor_hp_pic_reviewer.digits_between' => 'Nomor HP PIC Reviewer minimum 10 digit dan maksimum 15 digit!', + 'nama_pic_admin.required' => 'Nama PIC Admin Wajib diisi!', + 'nama_pic_admin.not_regex' => 'Nama PIC Admin harus berupa huruf!', + 'nomor_hp_pic_admin.required' => 'Nomor HP PIC Admin Wajib diisi!', + 'nomor_hp_pic_admin.numeric' => 'Nomor HP PIC Admin harus berupa angka!', + 'nomor_hp_pic_admin.digits_between' => 'Nomor HP PIC Admin minimum 10 digit dan maksimum 15 digit!', + 'nama_pic_marketing.required' => 'Nama PIC Marketing Wajib diisi!', + 'nama_pic_marketing.not_regex' => 'Nama PIC Marketing harus berupa huruf!', + 'nomor_hp_pic_marketing.required' => 'Nomor HP PIC Marketing Wajib diisi!', + 'nomor_hp_pic_marketing.numeric' => 'Nomor HP PIC Marketing harus berupa angka!', + 'nomor_hp_pic_marketing.digits_between' => 'Nomor HP PIC Marketing minimum 10 digit dan maksimum 15 digit!', + 'attachment.mimes' => 'Attachment harus berformat pdf!', + 'attachment.max' => 'Attachment berukuran maksimum 1 MB!', + ]; + } +} diff --git a/app/Models/Branch.php b/app/Models/Branch.php index 836cca5..4ca5bd9 100644 --- a/app/Models/Branch.php +++ b/app/Models/Branch.php @@ -1,16 +1,21 @@ hasMany(Debiture::class, 'branch_id', 'id'); - } + return $this->hasMany(Debiture::class, 'branch_id', 'id'); } + + public function kjpp() + { + return $this->belongsTo(KJPP::class); + } +} diff --git a/app/Models/IjinUsaha.php b/app/Models/IjinUsaha.php new file mode 100644 index 0000000..522a183 --- /dev/null +++ b/app/Models/IjinUsaha.php @@ -0,0 +1,24 @@ +belongsTo(KJPP::class); + } +} diff --git a/app/Models/JenisAset.php b/app/Models/JenisAset.php index 4a3edf8..6d18441 100644 --- a/app/Models/JenisAset.php +++ b/app/Models/JenisAset.php @@ -1,11 +1,11 @@ belongsTo(KJPP::class); } +} diff --git a/app/Models/KJPP.php b/app/Models/KJPP.php new file mode 100644 index 0000000..e535941 --- /dev/null +++ b/app/Models/KJPP.php @@ -0,0 +1,62 @@ +hasOne(Branch::class, 'jenis_kantor'); + } + + // relasi ke jenis aset + public function jenis_aset() + { + return $this->hasMany(JenisJaminan::class, 'jenis_aset_id'); + } + + // relasi ke ijin usaha + public function ijin_usaha() + { + return $this->hasMany(IjinUsaha::class, 'ijin_usaha_id'); + } +} diff --git a/database/migrations/2024_09_18_014746_create_ijin_usaha_table.php b/database/migrations/2024_09_18_014746_create_ijin_usaha_table.php new file mode 100644 index 0000000..af9e74f --- /dev/null +++ b/database/migrations/2024_09_18_014746_create_ijin_usaha_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('code')->unique()->index(); + $table->string('name'); + $table->boolean('status')->default(true)->nullable(); + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('ijin_usaha'); + } +}; diff --git a/database/migrations/2024_09_18_084905_create_kjpp_table.php b/database/migrations/2024_09_18_084905_create_kjpp_table.php new file mode 100644 index 0000000..387af1f --- /dev/null +++ b/database/migrations/2024_09_18_084905_create_kjpp_table.php @@ -0,0 +1,57 @@ +id(); + $table->string('code'); + $table->string('name'); + $table->string('jenis_kantor'); + $table->string('nomor_ijin_usaha'); + $table->string('province_code'); + $table->string('city_code'); + $table->string('district_code'); + $table->string('village_code'); + $table->string('address'); + $table->string('postal_code'); + $table->string('nomor_telepon_kantor'); + $table->string('email_kantor'); + $table->string('nama_pimpinan'); + $table->string('nomor_hp_pimpinan'); + $table->string('nama_pic_reviewer'); + $table->string('nomor_hp_pic_reviewer'); + $table->string('nama_pic_admin'); + $table->string('nomor_hp_pic_admin'); + $table->string('nama_pic_marketing'); + $table->string('nomor_hp_pic_marketing'); + $table->string('ijin_usaha_id')->nullable(); + $table->string('jenis_aset_id')->nullable(); + $table->string('attachment')->nullable(); + $table->boolean('status')->default(true)->nullable(); + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + $table->softDeletes(); + + $table->unsignedBigInteger('deleted_by')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('kjpp'); + } +}; diff --git a/module.json b/module.json index ac61330..9141313 100644 --- a/module.json +++ b/module.json @@ -19,8 +19,44 @@ "attributes": [], "permission": "", "roles": [ - "Administrator" - + "administrator" + ] + }, + { + "title": "Tender", + "path": "tender", + "icon": "ki-filled ki-category text-lg", + "classes": "", + "attributes": [], + "permission": "", + "roles": [ + "administrator" + ], + "sub": [ + { + "title": "Data Penawaran", + "path": "tender.penawaran", + "classes": "", + "attributes": [], + "permission": "", + "roles": [] + }, + { + "title": "Data Proses Penawaran", + "path": "tender.proses_penawaran", + "classes": "", + "attributes": [], + "permission": "", + "roles": [] + }, + { + "title": "Data Penawaran Ulang", + "path": "tender.penawaran_ulang", + "classes": "", + "attributes": [], + "permission": "", + "roles": [] + } ] }, { @@ -31,7 +67,7 @@ "attributes": [], "permission": "", "roles": [ - "Administrator" + "administrator" ] }, { @@ -42,7 +78,7 @@ "attributes": [], "permission": "", "roles": [ - "Administrator" + "administrator" ] }, { @@ -98,7 +134,7 @@ "attributes": [], "permission": "", "roles": [ - "Administrator" + "administrator" ] } ], @@ -233,8 +269,23 @@ "attributes": [], "permission": "", "roles": [] + }, + { + "title": "KJPP", + "path": "basicdata.kjpp", + "classes": "", + "attributes": [], + "permission": "", + "roles": [] + }, + { + "title": "Ijin Usaha", + "path": "basicdata.ijin_usaha", + "classes": "", + "attributes": [], + "permission": "", + "roles": [] } - ] } ], diff --git a/resources/views/Ijin_usaha/create.blade.php b/resources/views/Ijin_usaha/create.blade.php new file mode 100644 index 0000000..507268d --- /dev/null +++ b/resources/views/Ijin_usaha/create.blade.php @@ -0,0 +1,77 @@ +@extends('layouts.main') + +@section('breadcrumbs') + {{ Breadcrumbs::render(request()->route()->getName()) }} +@endsection + +@section('content') +
| + + | ++ Kode Ijin Usaha + + | ++ Nama Ijin Usaha + + | +Action | +
|---|