Compare commits
4 Commits
fix/revisi
...
feature/um
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fb8aeceaa | ||
|
|
ecc243d1cc | ||
|
|
8c236c460d | ||
|
|
41ddbaef24 |
@@ -53,7 +53,7 @@ class AdvertisementController extends Controller
|
|||||||
$advertisement->village_name = $village ? $village->village_name : null;
|
$advertisement->village_name = $village ? $village->village_name : null;
|
||||||
|
|
||||||
$district = DB::table('districts')->where('district_code', $advertisement->district_code)->first();
|
$district = DB::table('districts')->where('district_code', $advertisement->district_code)->first();
|
||||||
$advertisement->district_name = $district ? $district->district_name : null;
|
$advertisement->district_name = $district ? $district->district_name : null;
|
||||||
return $advertisement;
|
return $advertisement;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -75,10 +75,10 @@ class AdvertisementController extends Controller
|
|||||||
{
|
{
|
||||||
$data = $request->validated();
|
$data = $request->validated();
|
||||||
|
|
||||||
// Cari village_code berdasarkan village_name
|
|
||||||
$village_code = DB::table('villages')->where('village_name', $data['village_name'])->value('village_code');
|
|
||||||
// Cari district_code berdasarkan district_name
|
// Cari district_code berdasarkan district_name
|
||||||
$district_code = DB::table('districts')->where('district_name', $data['district_name'])->value('district_code');
|
$district_code = DB::table('districts')->where('district_name', $data['district_name'])->value('district_code');
|
||||||
|
// Cari village_code berdasarkan village_name
|
||||||
|
$village_code = DB::table('villages')->where('village_name', $data['village_name'])->where('district_code', $district_code)->value('village_code');
|
||||||
|
|
||||||
// Tambahkan village_code dan district_code ke data
|
// Tambahkan village_code dan district_code ke data
|
||||||
$data['village_code'] = $village_code;
|
$data['village_code'] = $village_code;
|
||||||
@@ -142,10 +142,10 @@ class AdvertisementController extends Controller
|
|||||||
{
|
{
|
||||||
$data = $request->validated();
|
$data = $request->validated();
|
||||||
|
|
||||||
// Cari village_code berdasarkan village_name
|
|
||||||
$village_code = DB::table('villages')->where('village_name', $data['village_name'])->value('village_code');
|
|
||||||
// Cari district_code berdasarkan district_name
|
// Cari district_code berdasarkan district_name
|
||||||
$district_code = DB::table('districts')->where('district_name', $data['district_name'])->value('district_code');
|
$district_code = DB::table('districts')->where('district_name', $data['district_name'])->value('district_code');
|
||||||
|
// Cari village_code berdasarkan village_name
|
||||||
|
$village_code = DB::table('villages')->where('village_name', $data['village_name'])->where('district_code', $district_code)->value('village_code');
|
||||||
|
|
||||||
// Tambahkan village_code dan district_code ke data
|
// Tambahkan village_code dan district_code ke data
|
||||||
$data['village_code'] = $village_code;
|
$data['village_code'] = $village_code;
|
||||||
@@ -196,4 +196,17 @@ class AdvertisementController extends Controller
|
|||||||
|
|
||||||
return response()->json($results);
|
return response()->json($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function downloadExcelAdvertisement()
|
||||||
|
{
|
||||||
|
$filePath = storage_path('app/public/templateFile/template_reklame.xlsx');
|
||||||
|
|
||||||
|
// Cek apakah file ada
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
return response()-> json(['message' => 'File tidak ditemukan!'], Response::HTTP_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return file to download
|
||||||
|
return response()->download($filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
117
app/Http/Controllers/Api/TourismController.php
Normal file
117
app/Http/Controllers/Api/TourismController.php
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\Tourism;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\TourismRequest;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Resources\TourismResource;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use App\Imports\TourismImport;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class TourismController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
info($request);
|
||||||
|
$perPage = $request->input('per_page', 15);
|
||||||
|
$search = $request->input('search', '');
|
||||||
|
|
||||||
|
$query = Tourism::query();
|
||||||
|
$tourisms = $query->paginate($perPage);
|
||||||
|
|
||||||
|
$tourisms->getCollection()->transform(function ($tourisms) {
|
||||||
|
$village = DB::table('villages')->where('village_code', $tourisms->village_code)->first();
|
||||||
|
$tourisms->village_name = $village ? $village->village_name : null;
|
||||||
|
|
||||||
|
$district = DB::table('districts')->where('district_code', $tourisms->district_code)->first();
|
||||||
|
$tourisms->district_name = $district ? $district->district_name : null;
|
||||||
|
|
||||||
|
$business_type = DB::table('business_type')->where('id', $tourisms->business_type_id)->first();
|
||||||
|
$tourisms->business_type = $business_type ? $business_type->business_type : null;
|
||||||
|
return $tourisms;
|
||||||
|
});
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'data' => TourismResource::collection($tourisms),
|
||||||
|
'meta' => [
|
||||||
|
'total' => $tourisms->total(),
|
||||||
|
'per_page' => $tourisms->perPage(),
|
||||||
|
'current_page' => $tourisms->currentPage(),
|
||||||
|
'last_page' => $tourisms->lastPage(),
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(TourismRequest $request): Tourism
|
||||||
|
{
|
||||||
|
return Tourism::create($request->validated());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import advertisements from Excel or CSV
|
||||||
|
*/
|
||||||
|
public function importFromFile(Request $request)
|
||||||
|
{
|
||||||
|
//Validasi file
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'file' => 'required|mimes:xlsx, xls|max:10240'
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'File validation failed.',
|
||||||
|
'errors' => $validator->errors()
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$file = $request->file('file');
|
||||||
|
Excel::import(new TourismImport, $file);
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'File uploaded and imported successfully!'
|
||||||
|
], 200);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Error during file import.',
|
||||||
|
'error' => $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Tourism $tourism): Tourism
|
||||||
|
{
|
||||||
|
return $tourism;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(TourismRequest $request, Tourism $tourism): Tourism
|
||||||
|
{
|
||||||
|
$tourism->update($request->validated());
|
||||||
|
|
||||||
|
return $tourism;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Tourism $tourism): Response
|
||||||
|
{
|
||||||
|
$tourism->delete();
|
||||||
|
|
||||||
|
return response()->noContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
189
app/Http/Controllers/Api/UmkmController.php
Normal file
189
app/Http/Controllers/Api/UmkmController.php
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Models\Umkm;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Requests\UmkmRequest;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Resources\UmkmResource;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use App\Imports\UmkmImport;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class UmkmController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
info($request);
|
||||||
|
$perPage = $request->input('per_page', 15);
|
||||||
|
$search = $request->input('search', '');
|
||||||
|
|
||||||
|
$query = Umkm::query();
|
||||||
|
|
||||||
|
$umkm = $query->paginate($perPage);
|
||||||
|
|
||||||
|
$umkm->getCollection()->transform(function ($umkm) {
|
||||||
|
$village = DB::table('villages')->where('village_code', $umkm->village_code)->first();
|
||||||
|
$umkm->village_name = $village ? $village->village_name : null;
|
||||||
|
|
||||||
|
$district = DB::table('districts')->where('district_code', $umkm->district_code)->first();
|
||||||
|
$umkm->district_name = $district ? $district->district_name : null;
|
||||||
|
|
||||||
|
$business_scale = DB::table('business_scale')->where('id', $umkm->business_scale_id)->first();
|
||||||
|
$umkm->business_scale = $business_scale ? $business_scale->business_scale : null;
|
||||||
|
|
||||||
|
$permit_status = DB::table('permit_status')->where('id', $umkm->permit_status_id)->first();
|
||||||
|
$umkm->permit_status = $permit_status ? $permit_status->permit_status : null;
|
||||||
|
|
||||||
|
$business_form = DB::table('business_form')->where('id', $umkm->business_form_id)->first();
|
||||||
|
$umkm->business_form = $business_form ? $business_form->business_form : null;
|
||||||
|
return $umkm;
|
||||||
|
});
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'data' => UmkmResource::collection($umkm),
|
||||||
|
'meta' => [
|
||||||
|
'total' => $umkm->total(),
|
||||||
|
'per_page' => $umkm->perPage(),
|
||||||
|
'current_page' => $umkm->currentPage(),
|
||||||
|
'last_page' => $umkm->lastPage(),
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(UmkmRequest $request): Umkm
|
||||||
|
{
|
||||||
|
info($request);
|
||||||
|
$data = $request->validated();
|
||||||
|
|
||||||
|
// Cari kode berdasarkan nama
|
||||||
|
$district_code = DB::table('districts')->where('district_name', $data['district_name'])->value('district_code');
|
||||||
|
$village_code = DB::table('villages')->where('village_name', $data['village_name'])->where('district_code', $district_code)->value('village_code');
|
||||||
|
$business_scale_id = DB::table('business_scale')->where('id', $data['business_scale'])->value('id');
|
||||||
|
$permit_status_id = DB::table('permit_status')->where('id', $data['permit_status'])->value('id');
|
||||||
|
$business_form_id = DB::table('business_form')->where('id', $data['business_form'])->value('id');
|
||||||
|
|
||||||
|
info($business_scale_id);
|
||||||
|
|
||||||
|
// Update data dengan kode yang ditemukan
|
||||||
|
$data['village_code'] = $village_code;
|
||||||
|
$data['district_code'] = $district_code;
|
||||||
|
$data['land_area'] = (double) $request['land_area'];
|
||||||
|
$data['business_scale_id'] = (int) $business_scale_id;
|
||||||
|
$data['permit_status_id'] = (int) $permit_status_id;
|
||||||
|
$data['business_form_id'] = (int) $business_form_id;
|
||||||
|
|
||||||
|
info($data);
|
||||||
|
|
||||||
|
// Simpan ke database
|
||||||
|
return Umkm::create($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import advertisements from Excel or CSV.
|
||||||
|
*/
|
||||||
|
public function importFromFile(Request $request)
|
||||||
|
{
|
||||||
|
// Validasi file
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'file' => 'required|mimes:xlsx, xls|max:10240',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'File validation failed.',
|
||||||
|
'errors' => $validator->errors()
|
||||||
|
], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Ambil file dari request
|
||||||
|
$file = $request->file('file');
|
||||||
|
|
||||||
|
// Menggunakan Laravel Excel untuk mengimpor file
|
||||||
|
Excel::import(new UmkmImport, $file);
|
||||||
|
|
||||||
|
// Jika sukses, kembalikan response sukses
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'File uploaded and imported successfully!'
|
||||||
|
], 200);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Error during file import.',
|
||||||
|
'error' => $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Umkm $umkm): Umkm
|
||||||
|
{
|
||||||
|
return $umkm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(UmkmRequest $request, Umkm $umkm): Umkm
|
||||||
|
{
|
||||||
|
info($request);
|
||||||
|
$data = $request->validated();
|
||||||
|
|
||||||
|
|
||||||
|
// Cari district_code berdasarkan district_name
|
||||||
|
$district_code = DB::table('districts')->where('district_name', $data['district_name'])->value('district_code');
|
||||||
|
// Cari village_code berdasarkan village_name
|
||||||
|
$village_code = DB::table('villages')->where('village_name', $data['village_name'])->where('district_code', $district_code)->value('village_code');
|
||||||
|
$business_scale_id = DB::table('business_scale')->where('id', $data['business_scale_id'])->value('id');
|
||||||
|
$permit_status_id = DB::table('permit_status')->where('id', $data['permit_status_id'])->value('id');
|
||||||
|
$business_form_id = DB::table('business_form')->where('id', $data['business_form_id'])->value('id');
|
||||||
|
|
||||||
|
|
||||||
|
// Tambahkan village_code dan district_code ke data
|
||||||
|
$data['village_code'] = $village_code;
|
||||||
|
$data['district_code'] = $district_code;
|
||||||
|
$data['land_area'] = (double) $request['land_area'];
|
||||||
|
$data['business_scale_id'] = (int) $business_scale_id;
|
||||||
|
$data['permit_status_id'] = (int) $permit_status_id;
|
||||||
|
$data['business_form_id'] = (int) $business_form_id;
|
||||||
|
|
||||||
|
// Log data setelah transformasi
|
||||||
|
info($data);
|
||||||
|
|
||||||
|
$umkm->update($data);
|
||||||
|
|
||||||
|
return $umkm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Umkm $umkm): Response
|
||||||
|
{
|
||||||
|
$umkm->delete();
|
||||||
|
|
||||||
|
return response()->noContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downloadExcelUmkm()
|
||||||
|
{
|
||||||
|
$filePath = storage_path('app/public/templateFile/template_umkm.xlsx');
|
||||||
|
|
||||||
|
// Cek apakah file ada
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
return response()-> json(['message' => 'File tidak ditemukan!'], Response::HTTP_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return file to download
|
||||||
|
return response()->download($filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
118
app/Http/Controllers/Data/TourismController.php
Normal file
118
app/Http/Controllers/Data/TourismController.php
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Data;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Tourism;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class TourismController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('data.tourisms.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show the form for creating a new rsource.
|
||||||
|
*/
|
||||||
|
public function bulkCreate()
|
||||||
|
{
|
||||||
|
return view('data.tourisms.form-upload');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show th form for creating a new resource
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$title = 'Pariwisata';
|
||||||
|
$subtitle = 'Create Data';
|
||||||
|
|
||||||
|
// Mengambil data untuk dropdown
|
||||||
|
$dropdownOptions = [
|
||||||
|
'village_name' => DB::table('villages')->orderBy('village_name')->pluck('village_name', 'village_code'),
|
||||||
|
'district_name' => DB::table('districts')->orderBy('district_name')->pluck('district_name', 'district_code'),
|
||||||
|
'business_type_id' => DB::table('business_type')->orderBy('business_type')->pluck('business_type', 'id'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$fields = $this->getFields();
|
||||||
|
$fieldTypes = $this->getFieldTypes();
|
||||||
|
|
||||||
|
$apiUrl = url('/api/tourisms');
|
||||||
|
|
||||||
|
return view('data.tourisms.form', compact('title', 'subtitle', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$title = 'Pariwisata';
|
||||||
|
$subtitle = 'Create Data';
|
||||||
|
|
||||||
|
$modelInstance = Tourism::find($id);
|
||||||
|
// Pastikan model ditemukan
|
||||||
|
if (!$modelInstance) {
|
||||||
|
return redirect()->route('tourisms.index') ->with('error', 'Pariwisata tidak ditemukan');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mengambil dan memetakan village_name dan district_name
|
||||||
|
$village = DB::table('villages')->where('village_code', $modelInstance->village_code)->first();
|
||||||
|
$modelInstance->village_name = $village ? $village->village_name : null;
|
||||||
|
|
||||||
|
$district = DB::table('districts')->where('district_code', $modelInstance->district_code)->first();
|
||||||
|
$modelInstance->district_name = $district ? $district->district_name : null;
|
||||||
|
|
||||||
|
$business_type = DB::table('business_type')->where('id', $modelInstance->business_type_id)->first();
|
||||||
|
$modelInstance->business_scale_id = $business_type ? $business_type->id : null;
|
||||||
|
|
||||||
|
$dropdownOptions = [
|
||||||
|
'village_name' => DB::table('villages')->orderBy('village_name')->pluck('village_name', 'village_code'),
|
||||||
|
'district_name' => DB::table('districts')->orderBy('district_name')->pluck('district_name', 'district_code'),
|
||||||
|
'business_type_id' => DB::table('business_type')->orderBy('business_type')->pluck('business_type', 'id'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$fields = $this->getFields();
|
||||||
|
$fieldTypes = $this->getFieldTypes();
|
||||||
|
|
||||||
|
$apiUrl = url('/api/tourisms');
|
||||||
|
|
||||||
|
return view('data.tourisms.form', compact('title', 'subtitle', 'modelInstance', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getFields()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"business_name" => "Nama Usaha",
|
||||||
|
"project_name" => "Nama Project",
|
||||||
|
"business_address" => "Alamat Usaha",
|
||||||
|
"district_name" => "Kecamatan",
|
||||||
|
"village_name" => "Desa",
|
||||||
|
"land_area" => "Luas Tanah",
|
||||||
|
"investment_amount" => "Jumlah Investasi",
|
||||||
|
"number_of_employee" => "TKI",
|
||||||
|
"business_type_id" => "Jenis Usaha",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getFieldTypes()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"business_name" => "text",
|
||||||
|
"project_name" => "text",
|
||||||
|
"business_address" => "textarea",
|
||||||
|
"district_name" => "combobox",
|
||||||
|
"village_name" => "combobox",
|
||||||
|
"land_area" => "text",
|
||||||
|
"investment_amount" => "text",
|
||||||
|
"number_of_employee" => "text",
|
||||||
|
"business_type_id" => "select",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
149
app/Http/Controllers/Data/UmkmController.php
Normal file
149
app/Http/Controllers/Data/UmkmController.php
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Data;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Umkm;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class UmkmController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('data.umkm.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function bulkCreate()
|
||||||
|
{
|
||||||
|
return view('data.umkm.form-upload');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
$title = 'UMKM';
|
||||||
|
$subtitle = 'Create Data';
|
||||||
|
|
||||||
|
// Mengambil data untuk dropdown
|
||||||
|
$dropdownOptions = [
|
||||||
|
'village_name' => DB::table('villages')->orderBy('village_name')->pluck('village_name', 'village_code'),
|
||||||
|
'district_name' => DB::table('districts')->orderBy('district_name')->pluck('district_name', 'district_code'),
|
||||||
|
'business_scale_id' => DB::table('business_scale')->orderBy('business_scale')->pluck('business_scale', 'id'),
|
||||||
|
'permit_status_id' => DB::table('permit_status')->orderBy('permit_status')->pluck('permit_status', 'id'),
|
||||||
|
'business_form_id' => DB::table('business_form')->orderBy('business_form')->pluck('business_form', 'id')
|
||||||
|
];
|
||||||
|
|
||||||
|
$fields = $this->getFields();
|
||||||
|
$fieldTypes = $this->getFieldTypes();
|
||||||
|
|
||||||
|
$apiUrl = url('/api/umkm');
|
||||||
|
|
||||||
|
return view('data.umkm.form', compact('title', 'subtitle', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$title = 'UMKM';
|
||||||
|
$subtitle = 'Update Data';
|
||||||
|
$modelInstance = Umkm::find($id);
|
||||||
|
// Pastikan model ditemukan
|
||||||
|
if (!$modelInstance) {
|
||||||
|
return redirect()->route('umkm.index')->with('error', 'Umkm not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mengambil dan memetakan village_name dan district_name
|
||||||
|
$village = DB::table('villages')->where('village_code', $modelInstance->village_code)->first();
|
||||||
|
$modelInstance->village_name = $village ? $village->village_name : null;
|
||||||
|
|
||||||
|
$district = DB::table('districts')->where('district_code', $modelInstance->district_code)->first();
|
||||||
|
$modelInstance->district_name = $district ? $district->district_name : null;
|
||||||
|
|
||||||
|
$business_scale = DB::table('business_scale')->where('id', $modelInstance->business_scale_id)->first();
|
||||||
|
$modelInstance->business_scale_id = $business_scale ? $business_scale->id : null;
|
||||||
|
|
||||||
|
$permit_status = DB::table('permit_status')->where('id', $modelInstance->permit_status_id)->first();
|
||||||
|
$modelInstance->permit_status_id = $permit_status ? $permit_status->id : null;
|
||||||
|
|
||||||
|
$business_form = DB::table('business_form')->where('id', $modelInstance->business_form_id)->first();
|
||||||
|
$modelInstance->business_form_id = $business_form ? $business_form->id : null;
|
||||||
|
|
||||||
|
// dd($modelInstance['business_form_id']);
|
||||||
|
// Mengambil data untuk dropdown
|
||||||
|
$dropdownOptions = [
|
||||||
|
'village_name' => DB::table('villages')->orderBy('village_name')->pluck('village_name', 'village_code'),
|
||||||
|
'district_name' => DB::table('districts')->orderBy('district_name')->pluck('district_name', 'district_code'),
|
||||||
|
'business_scale_id' => DB::table('business_scale')->orderBy('business_scale')->pluck('business_scale', 'id'),
|
||||||
|
'permit_status_id' => DB::table('permit_status')->orderBy('permit_status')->pluck('permit_status', 'id'),
|
||||||
|
'business_form_id' => DB::table('business_form')->orderBy('business_form')->pluck('business_form', 'id')
|
||||||
|
];
|
||||||
|
|
||||||
|
info("AdvertisementController@edit diakses dengan Model Instance: $modelInstance");
|
||||||
|
$fields = $this->getFields();
|
||||||
|
$fieldTypes = $this->getFieldTypes();
|
||||||
|
|
||||||
|
$apiUrl = url('/api/umkm');
|
||||||
|
|
||||||
|
// dd($modelInstance->business_form_id, $dropdownOptions['business_form']);
|
||||||
|
return view('data.umkm.form', compact('title', 'subtitle', 'modelInstance', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getFields()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"business_name" => "Nama Usaha",
|
||||||
|
"business_address" => "Alamat Usaha",
|
||||||
|
"business_desc" => "Deskripsi Usaha",
|
||||||
|
"business_contact" => "Kontak Usaha",
|
||||||
|
"business_id_number" => "NIB",
|
||||||
|
"business_scale_id" => "Skala Usaha",
|
||||||
|
"owner_id" => "NIK",
|
||||||
|
"owner_name" => "Nama Pemilik",
|
||||||
|
"owner_address" => "Alamat Pemilik",
|
||||||
|
"owner_contact" => "Kontak Pemilik",
|
||||||
|
"business_type" => "Jenis Usaha",
|
||||||
|
"district_name" => "Kecamatan",
|
||||||
|
"village_name" => "Desa",
|
||||||
|
"number_of_employee" => "Jumlah Karyawan",
|
||||||
|
"land_area" => "Luas Tanah",
|
||||||
|
"permit_status_id" => "Ijin Status",
|
||||||
|
"business_form_id" => "Bisnis Form",
|
||||||
|
"revenue" => "Omset"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getFieldTypes()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
"business_name" => "text",
|
||||||
|
"business_address" => "text",
|
||||||
|
"business_desc" => "textarea",
|
||||||
|
"business_contact" => "text",
|
||||||
|
"business_id_number" => "text",
|
||||||
|
"business_scale_id" => "select",
|
||||||
|
"owner_id" => "text",
|
||||||
|
"owner_name" => "text",
|
||||||
|
"owner_address" => "text",
|
||||||
|
"owner_contact" => "text",
|
||||||
|
"business_type" => "text",
|
||||||
|
"district_name" => "combobox",
|
||||||
|
"village_name" => "combobox",
|
||||||
|
"number_of_employee" => "text",
|
||||||
|
"land_area" => "text",
|
||||||
|
"permit_status_id" => "select",
|
||||||
|
"business_form_id" => "select",
|
||||||
|
"revenue" => "text"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
21
app/Http/Controllers/Report/ReportTourismController.php
Normal file
21
app/Http/Controllers/Report/ReportTourismController.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Report;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\BusinessTypeCount;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class ReportTourismController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listring of the resource
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$businessTypeCounts = BusinessTypeCount::all();
|
||||||
|
info($businessTypeCounts);
|
||||||
|
return view('report.tourisms.index', compact('businessTypeCounts'));
|
||||||
|
}
|
||||||
|
}
|
||||||
41
app/Http/Requests/TourismRequest.php
Normal file
41
app/Http/Requests/TourismRequest.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class TourismRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'jenis_proyek' => 'string',
|
||||||
|
'nib' => 'string',
|
||||||
|
'business_name' => 'required|string',
|
||||||
|
'status_penanaman_modal' => 'string',
|
||||||
|
'business_form' => 'string',
|
||||||
|
'uraian_resiko_proyek' => 'string',
|
||||||
|
'project_name' => 'required|string',
|
||||||
|
'business_address' => 'required|string',
|
||||||
|
'district_code' => 'required|string',
|
||||||
|
'village_code' => 'required|string',
|
||||||
|
'land_area' => 'required|string',
|
||||||
|
'investment_amount' => 'required|string',
|
||||||
|
'number_of_employee' => 'required|string',
|
||||||
|
'business_type_id' => 'required|string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
106
app/Http/Requests/UmkmRequest.php
Normal file
106
app/Http/Requests/UmkmRequest.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UmkmRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'business_name' => 'required|string',
|
||||||
|
'business_address' => 'required|string',
|
||||||
|
'business_desc' => 'required|string',
|
||||||
|
'business_contact' => 'required|string',
|
||||||
|
'business_id_number' => 'string',
|
||||||
|
'business_scale_id' => 'required',
|
||||||
|
'owner_id' => 'required|string',
|
||||||
|
'owner_name' => 'required|string',
|
||||||
|
'owner_address' => 'required|string',
|
||||||
|
'owner_contact' => 'required|string',
|
||||||
|
'business_type' => 'required|string',
|
||||||
|
'business_form_id' => 'required|string',
|
||||||
|
'revenue' => 'required|numeric|between:0,999999999999999999.99',
|
||||||
|
'village_name' => 'required|string',
|
||||||
|
'district_name' => 'required',
|
||||||
|
'number_of_employee' => 'required',
|
||||||
|
'permit_status_id' => 'required',
|
||||||
|
'land_area' => 'required|integer|between:0,99999999999',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation messages for the request.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function messages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'business_name.required' => 'Nama usaha wajib diisi.',
|
||||||
|
'business_name.string' => 'Nama usaha harus berupa teks.',
|
||||||
|
|
||||||
|
'business_address.required' => 'Alamat usaha wajib diisi.',
|
||||||
|
'business_address.string' => 'Alamat usaha harus berupa teks.',
|
||||||
|
|
||||||
|
'business_desc.required' => 'Deskripsi usaha wajib diisi.',
|
||||||
|
'business_desc.string' => 'Deskripsi usaha harus berupa teks.',
|
||||||
|
|
||||||
|
'business_contact.required' => 'Kontak usaha wajib diisi.',
|
||||||
|
'business_contact.string' => 'Kontak usaha harus berupa teks.',
|
||||||
|
|
||||||
|
'business_id_number.string' => 'Nomor ID usaha harus berupa teks.',
|
||||||
|
|
||||||
|
'business_scale.required' => 'Skala usaha wajib diisi.',
|
||||||
|
|
||||||
|
'owner_id.required' => 'ID pemilik wajib diisi.',
|
||||||
|
'owner_id.string' => 'ID pemilik harus berupa teks.',
|
||||||
|
|
||||||
|
'owner_name.required' => 'Nama pemilik wajib diisi.',
|
||||||
|
'owner_name.string' => 'Nama pemilik harus berupa teks.',
|
||||||
|
|
||||||
|
'owner_address.required' => 'Alamat pemilik wajib diisi.',
|
||||||
|
'owner_address.string' => 'Alamat pemilik harus berupa teks.',
|
||||||
|
|
||||||
|
'owner_contact.required' => 'Kontak pemilik wajib diisi.',
|
||||||
|
'owner_contact.string' => 'Kontak pemilik harus berupa teks.',
|
||||||
|
|
||||||
|
'business_type.required' => 'Jenis usaha wajib diisi.',
|
||||||
|
'business_type.string' => 'Jenis usaha harus berupa teks.',
|
||||||
|
|
||||||
|
'business_form.required' => 'Bentuk usaha wajib diisi.',
|
||||||
|
'business_form.string' => 'Bentuk usaha harus berupa teks.',
|
||||||
|
|
||||||
|
'revenue.required' => 'Omset wajib diisi.',
|
||||||
|
'revenue.numeric' => 'Omset harus berupa angka yang valid.',
|
||||||
|
'revenue.between' => 'Omset harus berada di antara 0 dan 9.999.999.999,99.',
|
||||||
|
|
||||||
|
'village_name.required' => 'Nama desa wajib diisi.',
|
||||||
|
'village_name.string' => 'Nama desa harus berupa teks.',
|
||||||
|
|
||||||
|
'district_name.required' => 'Nama distrik wajib diisi.',
|
||||||
|
|
||||||
|
'number_of_employee.required' => 'Jumlah karyawan wajib diisi.',
|
||||||
|
|
||||||
|
'permit_status.required' => 'Status izin wajib diisi.',
|
||||||
|
|
||||||
|
'land_area.required' => 'Luas lahan wajib diisi.',
|
||||||
|
'land_area.integer' => 'Luas lahan harus berupa angka bulat.',
|
||||||
|
'land_area.between' => 'Luas lahan harus berada di antara 0 dan 99.999.999.999.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Http/Resources/TourismResource.php
Normal file
19
app/Http/Resources/TourismResource.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class TourismResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return parent::toArray($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Http/Resources/UmkmResource.php
Normal file
19
app/Http/Resources/UmkmResource.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class UmkmResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return parent::toArray($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@ class AdvertisementImport implements ToCollection
|
|||||||
$districtCode = $districts[$districtName] ?? null;
|
$districtCode = $districts[$districtName] ?? null;
|
||||||
|
|
||||||
$listTrueVillage = DB::table('villages')
|
$listTrueVillage = DB::table('villages')
|
||||||
->where('district_code', $districtCode) // Perbaikan pada where()
|
->where('district_code', $districtCode)
|
||||||
->get()
|
->get()
|
||||||
->mapWithKeys(function ($item) {
|
->mapWithKeys(function ($item) {
|
||||||
return [strtolower(trim($item->village_name)) => [
|
return [strtolower(trim($item->village_name)) => [
|
||||||
|
|||||||
96
app/Imports/TourismImport.php
Normal file
96
app/Imports/TourismImport.php
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Imports;
|
||||||
|
|
||||||
|
use App\Models\Tourism;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
class TourismImport implements ToCollection
|
||||||
|
{
|
||||||
|
protected static $processed = false;
|
||||||
|
/**
|
||||||
|
* Process each row in the file.
|
||||||
|
*/
|
||||||
|
public function collection(Collection $rows)
|
||||||
|
{
|
||||||
|
if (self::$processed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self::$processed = true;
|
||||||
|
|
||||||
|
if ($rows->isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ambil data districts dengan normalisasi nama
|
||||||
|
$districts = DB::table('districts')
|
||||||
|
->get()
|
||||||
|
->mapWithKeys(function ($item) {
|
||||||
|
return [strtolower(trim($item->district_name)) => $item->district_code];
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
// Cari header secara otomatis
|
||||||
|
$header = $rows->first();
|
||||||
|
$headerIndex = collect($header)->search(fn($value) => !empty($value));
|
||||||
|
|
||||||
|
// Pastikan header ditemukan
|
||||||
|
if ($headerIndex === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
info($rows);
|
||||||
|
|
||||||
|
foreach ($rows->skip(1) as $row) {
|
||||||
|
// Normalisasi nama kecamatan dan desa
|
||||||
|
$districtName = strtolower(trim(str_replace('Kecamatan', '', $row[13])));
|
||||||
|
$villageName = strtolower(trim($row[14]));
|
||||||
|
|
||||||
|
// Cari distric_code dari table districts
|
||||||
|
$districtCode = $districts[$districtName] ?? null;
|
||||||
|
|
||||||
|
$listTrueVillage = DB::table('villages')
|
||||||
|
->where('district_code', $districtCode)
|
||||||
|
->get()
|
||||||
|
->mapWithKeys(function ($item) {
|
||||||
|
return [strtolower(trim($item->village_name)) => [
|
||||||
|
'village_code' => $item->village_code,
|
||||||
|
'district_code' => $item->district_code
|
||||||
|
]];
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
// ambill village code yang village_name sama dengan $villageName
|
||||||
|
$villageCode = $listTrueVillage[$villageName]['village_code'] ?? '000000';
|
||||||
|
|
||||||
|
$dataToInsert[] = [
|
||||||
|
'project_id' => $row[1],
|
||||||
|
'jenis_proyek' => $row[2],
|
||||||
|
'nib' => $row[3],
|
||||||
|
'business_name' => $row[4],
|
||||||
|
'terbit_oss' => DateTime::createFromFormat('d/m/Y', $row[5])->format('Y-m-d'),
|
||||||
|
'status_penanaman_modal' => $row[6],
|
||||||
|
'business_form' => $row[7],
|
||||||
|
'uraian_resiko_proyek' => $row[8],
|
||||||
|
'project_name' => $row[9],
|
||||||
|
'business_type_id' => $row[10],
|
||||||
|
'business_scale_id' => (int) $row[11],
|
||||||
|
'business_address' => $row[12],
|
||||||
|
'district_code' => $districtCode,
|
||||||
|
'village_code' => $villageCode,
|
||||||
|
'land_area' => $row[15],
|
||||||
|
'investment_amount' => (string) $row[16],
|
||||||
|
'number_of_employee' => (string) $row[17],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($dataToInsert)) {
|
||||||
|
Tourism::insert($dataToInsert);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
98
app/Imports/UmkmImport.php
Normal file
98
app/Imports/UmkmImport.php
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Imports;
|
||||||
|
|
||||||
|
use App\Models\Umkm;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class UmkmImport implements ToCollection
|
||||||
|
{
|
||||||
|
|
||||||
|
protected static $processed = false;
|
||||||
|
/**
|
||||||
|
* Process each row in the file.
|
||||||
|
*/
|
||||||
|
public function collection(Collection $rows)
|
||||||
|
{
|
||||||
|
if (self::$processed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self::$processed = true;
|
||||||
|
|
||||||
|
if ($rows->isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ambil data districts dengan normalisasi nama
|
||||||
|
$districts = DB::table('districts')
|
||||||
|
->get()
|
||||||
|
->mapWithKeys(function ($item) {
|
||||||
|
return [strtolower(trim($item->district_name)) => $item->district_code];
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
// Cari header secara otomatis
|
||||||
|
$header = $rows->first();
|
||||||
|
$headerIndex = collect($header)->search(fn($value) => !empty($value));
|
||||||
|
|
||||||
|
// Pastikan header ditemukan
|
||||||
|
if ($headerIndex === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
info($rows);
|
||||||
|
|
||||||
|
foreach ($rows->skip(1) as $row) {
|
||||||
|
// Normalisasi nama kecamatan dan desa
|
||||||
|
$districtName = strtolower(trim(str_replace('Kecamatan', '', $row[14])));
|
||||||
|
$villageName = strtolower(trim($row[13]));
|
||||||
|
|
||||||
|
// Cari distric_code dari table districts
|
||||||
|
$districtCode = $districts[$districtName] ?? null;
|
||||||
|
|
||||||
|
$listTrueVillage = DB::table('villages')
|
||||||
|
->where('district_code', $districtCode)
|
||||||
|
->get()
|
||||||
|
->mapWithKeys(function ($item) {
|
||||||
|
return [strtolower(trim($item->village_name)) => [
|
||||||
|
'village_code' => $item->village_code,
|
||||||
|
'district_code' => $item->district_code
|
||||||
|
]];
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
// ambil village code yang village_name sama dengan $villageName
|
||||||
|
$villageCode = $listTrueVillage[$villageName]['village_code'] ?? '0000';
|
||||||
|
|
||||||
|
$dataToInsert[] = [
|
||||||
|
'business_name' => $row[0],
|
||||||
|
'business_address' => $row[1],
|
||||||
|
'business_desc' => $row[2],
|
||||||
|
'business_contact' => $row[3],
|
||||||
|
'business_id_number' => $row[4],
|
||||||
|
'business_scale_id' => $row[5],
|
||||||
|
'owner_id' => $row[6],
|
||||||
|
'owner_name' => $row[7],
|
||||||
|
'owner_address' => $row[8],
|
||||||
|
'owner_contact' => $row[9],
|
||||||
|
'business_type' => $row[10],
|
||||||
|
'business_form_id' => $row[11],
|
||||||
|
'revenue' => $row[12],
|
||||||
|
'village_code' => $villageCode,
|
||||||
|
'district_code' => $districtCode,
|
||||||
|
'number_of_employee' => $row[15],
|
||||||
|
'land_area' => $row[16],
|
||||||
|
'permit_status_id' => $row[17],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
info($dataToInsert);
|
||||||
|
if (!empty($dataToInsert)) {
|
||||||
|
Umkm::insert($dataToInsert);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
app/Models/BusinessTypeCount.php
Normal file
14
app/Models/BusinessTypeCount.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class BusinessTypeCount extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'business_type_counts';
|
||||||
|
protected $primaryKey = null;
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
protected $fillable = ['business_type', 'count'];
|
||||||
|
}
|
||||||
47
app/Models/Tourism.php
Normal file
47
app/Models/Tourism.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Tourism
|
||||||
|
*
|
||||||
|
* @property $id
|
||||||
|
* @property $project_id
|
||||||
|
* @property $jenis_proyek
|
||||||
|
* @property $nib
|
||||||
|
* @property $created_at
|
||||||
|
* @property $updated_at
|
||||||
|
* @property $business_name
|
||||||
|
* @property $terbit_oss
|
||||||
|
* @property $status_penanaman_modal
|
||||||
|
* @property $business_form
|
||||||
|
* @property $uraian_resiko_proyek
|
||||||
|
* @property $project_name
|
||||||
|
* @property $business_scale_id
|
||||||
|
* @property $business_address
|
||||||
|
* @property $district_code
|
||||||
|
* @property $village_code
|
||||||
|
* @property $land_area
|
||||||
|
* @property $investment_amount
|
||||||
|
* @property $number_of_employee
|
||||||
|
* @property $business_type_id
|
||||||
|
*
|
||||||
|
* @package App
|
||||||
|
* @mixin \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
class Tourism extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $perPage = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $fillable = ['project_id', 'jenis_proyek', 'nib', 'business_name', 'terbit_oss', 'status_penanaman_modal', 'business_form', 'uraian_resiko_proyek', 'project_name', 'business_scale_id', 'business_address', 'district_code', 'village_code', 'land_area', 'investment_amount', 'number_of_employee', 'business_type_id'];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
48
app/Models/Umkm.php
Normal file
48
app/Models/Umkm.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Umkm
|
||||||
|
*
|
||||||
|
* @property $id
|
||||||
|
* @property $created_at
|
||||||
|
* @property $updated_at
|
||||||
|
* @property $business_name
|
||||||
|
* @property $business_address
|
||||||
|
* @property $business_desc
|
||||||
|
* @property $business_contact
|
||||||
|
* @property $business_id_number
|
||||||
|
* @property $business_scale_id
|
||||||
|
* @property $owner_id
|
||||||
|
* @property $owner_name
|
||||||
|
* @property $owner_address
|
||||||
|
* @property $owner_contact
|
||||||
|
* @property $business_type
|
||||||
|
* @property $business_form_id
|
||||||
|
* @property $revenue
|
||||||
|
* @property $village_code
|
||||||
|
* @property $distric_code
|
||||||
|
* @property $number_of_employee
|
||||||
|
* @property $land_area
|
||||||
|
* @property $permit_status_id
|
||||||
|
*
|
||||||
|
* @package App
|
||||||
|
* @mixin \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
class Umkm extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $perPage = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $fillable = ['business_name', 'business_address', 'business_desc', 'business_contact', 'business_id_number', 'business_scale_id', 'owner_id', 'owner_name', 'owner_address', 'owner_contact', 'business_type', 'business_form_id', 'revenue', 'village_code', 'district_code', 'number_of_employee', 'land_area', 'permit_status_id'];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
46
database/migrations/2025_02_12_083512_create_table_umkm.php
Normal file
46
database/migrations/2025_02_12_083512_create_table_umkm.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?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('umkm', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
|
||||||
|
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
|
||||||
|
$table->string('business_name');
|
||||||
|
$table->string('business_address');
|
||||||
|
$table->string('business_desc');
|
||||||
|
$table->string('business_contact');
|
||||||
|
$table->string('business_id_number')->nullable();
|
||||||
|
$table->integer('business_scale_id');
|
||||||
|
$table->string('owner_id');
|
||||||
|
$table->string('owner_name');
|
||||||
|
$table->string('owner_address');
|
||||||
|
$table->string('owner_contact');
|
||||||
|
$table->string('business_type');
|
||||||
|
$table->string('business_form');
|
||||||
|
$table->decimal('revenue');
|
||||||
|
$table->string('village_code');
|
||||||
|
$table->integer('distric_code');
|
||||||
|
$table->integer('number_of_employee');
|
||||||
|
$table->float('land_area')->nullable();
|
||||||
|
$table->integer('permit_status_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('umkm');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?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('business_scale', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
|
||||||
|
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
|
||||||
|
$table->string('business_scale');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('business_scale');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?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('permit_status', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
|
||||||
|
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
|
||||||
|
$table->string('permit_status');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('permit_status');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?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::table('umkm', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('business_form');
|
||||||
|
$table->integer('business_form_id')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('umkm', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('business_form_id');
|
||||||
|
$table->string('business_form')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?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('business_form', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
|
||||||
|
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
|
||||||
|
$table->string('business_form');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('business_form');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?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::table('umkm', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('distric_code', 'district_code');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('umkm', function (Blueprint $table) {
|
||||||
|
$table->renameColumn('district_code', 'distric_code');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?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::table('umkm', function (Blueprint $table) {
|
||||||
|
Schema::rename('umkm', 'umkms');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('umkm', function (Blueprint $table) {
|
||||||
|
Schema::rename('umkm', 'umkms');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?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::table('umkms', function (Blueprint $table) {
|
||||||
|
// Mengubah kolom 'revenue' menjadi decimal(20, 2)
|
||||||
|
$table->decimal('revenue', 20, 2)->change();
|
||||||
|
|
||||||
|
// Mengubah kolom 'land_area' menjadi decimal(20, 2)
|
||||||
|
$table->integer('land_area')->nullable()->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('umkm', function (Blueprint $table) {
|
||||||
|
// Mengembalikan kolom 'revenue' ke decimal default (jika ada)
|
||||||
|
$table->decimal('revenue')->change();
|
||||||
|
|
||||||
|
// Mengembalikan kolom 'land_area' ke tipe sebelumnya (float atau lainnya)
|
||||||
|
$table->float('land_area')->nullable()->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?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('tourism', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
|
||||||
|
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
|
||||||
|
$table->string('business_name');
|
||||||
|
$table->string('project_name');
|
||||||
|
$table->string('business_address');
|
||||||
|
$table->string('village_code');
|
||||||
|
$table->string('land_area');
|
||||||
|
$table->string('investment_amount');
|
||||||
|
$table->string('number_of_employee');
|
||||||
|
$table->string('business_type_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('tourism');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?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('business_type', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
|
||||||
|
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
|
||||||
|
$table->string('business_type');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('business_type');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?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::table('tourism', function (Blueprint $table) {
|
||||||
|
$table->string('district_code')->after('business_address');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('tourism', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('district_code');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?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::rename('tourism', 'tourisms');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::rename('tourisms', 'tourism');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?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::table('tourisms', function (Blueprint $table) {
|
||||||
|
$table->integer('project_id')->nullable()->after('id');
|
||||||
|
$table->string('jenis_proyek')->nullable()->after('project_id');
|
||||||
|
$table->string('nib')->nullable()->after('jenis_proyek');
|
||||||
|
$table->integer('business_scale_id')->nullable()->after('project_name');
|
||||||
|
$table->date('terbit_oss')->nullable()->after('business_name');
|
||||||
|
$table->string('status_penanaman_modal')->nullable()->after('terbit_oss');
|
||||||
|
$table->string('business_form')->nullable()->after('status_penanaman_modal');
|
||||||
|
$table->string('uraian_resiko_proyek')->nullable()->after('business_form');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('tourisms', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['project_id', 'jenis_proyek', 'nib', 'business_scale_id', 'terbit_oss',
|
||||||
|
'status_penanaman_modal', 'business_form', 'uraian_resiko_proyek']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?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::table('tourisms', function (Blueprint $table) {
|
||||||
|
$table->string('project_id')->change();
|
||||||
|
$table->integer('district_code')->change();
|
||||||
|
$table->integer('business_type_id')->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('tourisms', function (Blueprint $table) {
|
||||||
|
$table->integer('project_id')->change();
|
||||||
|
$table->string('district_code')->change();
|
||||||
|
$table->string('business_type_id')->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
26
database/seeders/BusinessFormSeeder.php
Normal file
26
database/seeders/BusinessFormSeeder.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class BusinessFormSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
DB::table('business_form')->insert([
|
||||||
|
['business_form' => 'Perseorangan'],
|
||||||
|
['business_form' => 'Persekutuan'],
|
||||||
|
['business_form' => 'Koperasi'],
|
||||||
|
['business_form' => 'CV'],
|
||||||
|
['business_form' => 'PT'],
|
||||||
|
['business_form' => 'PTTB'],
|
||||||
|
['business_form' => 'Perseroan'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
database/seeders/BusinessScaleSeeder.php
Normal file
22
database/seeders/BusinessScaleSeeder.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class BusinessScaleSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
DB::table('business_scale')->insert([
|
||||||
|
['business_scale' => 'Micro'],
|
||||||
|
['business_scale' => 'Kecil'],
|
||||||
|
['business_scale' => 'Menengah'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
database/seeders/BusinessTypeSeeder.php
Normal file
28
database/seeders/BusinessTypeSeeder.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class BusinessTypeSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
DB::table('business_type')->insert([
|
||||||
|
['business_type' => 'Villas'],
|
||||||
|
['business_type' => 'Hotels'],
|
||||||
|
['business_type' => 'Restaurants / Food Stores'],
|
||||||
|
['business_type' => 'Cafes'],
|
||||||
|
['business_type' => 'Adventure / Outdoor Activities'],
|
||||||
|
['business_type' => 'Event Organizers'],
|
||||||
|
['business_type' => 'Travel & Tours'],
|
||||||
|
['business_type' => 'Miscellaneous'],
|
||||||
|
['business_type' => 'Others'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
database/seeders/PermitStatusSeeder.php
Normal file
22
database/seeders/PermitStatusSeeder.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class PermitStatusSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
DB::table('permit_status')->insert([
|
||||||
|
['permit_status' => 'Not Registered'],
|
||||||
|
['permit_status' => 'Registered'],
|
||||||
|
['permit_status' => 'Application Process'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
5
database/view_query/business_type_counts.sql
Normal file
5
database/view_query/business_type_counts.sql
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
CREATE VIEW business_type_counts AS
|
||||||
|
SELECT b.business_type, COUNT(t.id) AS count
|
||||||
|
FROM tourisms t
|
||||||
|
JOIN business_type b ON t.business_type_id = b.id
|
||||||
|
GROUP BY b.business_type;
|
||||||
13
package-lock.json
generated
13
package-lock.json
generated
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "Darkone-Laravel",
|
"name": "sibedas-pbg-web",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
"node-waves": "^0.7.6",
|
"node-waves": "^0.7.6",
|
||||||
"quill": "^1.3.7",
|
"quill": "^1.3.7",
|
||||||
"simplebar": "^5.3.9",
|
"simplebar": "^5.3.9",
|
||||||
|
"sweetalert2": "^11.16.0",
|
||||||
"wnumb": "^1.2.0"
|
"wnumb": "^1.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -2507,6 +2508,16 @@
|
|||||||
"node": ">= 0.8.0"
|
"node": ">= 0.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/sweetalert2": {
|
||||||
|
"version": "11.16.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.16.0.tgz",
|
||||||
|
"integrity": "sha512-4CGgNMpQHcwV+Gov0j4u3lDc/5lyl04NBsa1vW0Se9cqsrQoUimD6/Z5UyZiRP4kMbwQGyb7wsp0x3ytybti6w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "individual",
|
||||||
|
"url": "https://github.com/sponsors/limonte"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tailwindcss": {
|
"node_modules/tailwindcss": {
|
||||||
"version": "3.4.15",
|
"version": "3.4.15",
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.15.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.15.tgz",
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
"node-waves": "^0.7.6",
|
"node-waves": "^0.7.6",
|
||||||
"quill": "^1.3.7",
|
"quill": "^1.3.7",
|
||||||
"simplebar": "^5.3.9",
|
"simplebar": "^5.3.9",
|
||||||
|
"sweetalert2": "^11.16.0",
|
||||||
"wnumb": "^1.2.0"
|
"wnumb": "^1.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Dropzone } from "dropzone";
|
import { Dropzone } from "dropzone";
|
||||||
|
import GlobalConfig from "../../global-config.js";
|
||||||
|
|
||||||
Dropzone.autoDiscover = false;
|
Dropzone.autoDiscover = false;
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ console.log(dropzonePreviewNode);
|
|||||||
((previewTemplate = dropzonePreviewNode.parentNode.innerHTML),
|
((previewTemplate = dropzonePreviewNode.parentNode.innerHTML),
|
||||||
dropzonePreviewNode.parentNode.removeChild(dropzonePreviewNode),
|
dropzonePreviewNode.parentNode.removeChild(dropzonePreviewNode),
|
||||||
(dropzone = new Dropzone(".dropzone", {
|
(dropzone = new Dropzone(".dropzone", {
|
||||||
url: "http://localhost:8000/api/advertisements/import",
|
url: `${GlobalConfig.apiHost}/api/advertisements/import`,
|
||||||
// url: "https://httpbin.org/post",
|
// url: "https://httpbin.org/post",
|
||||||
method: "post",
|
method: "post",
|
||||||
acceptedFiles: ".xls,.xlsx", // Use acceptedFiles for better validation
|
acceptedFiles: ".xls,.xlsx", // Use acceptedFiles for better validation
|
||||||
@@ -85,6 +86,40 @@ dropzone.on("complete", function(file) {
|
|||||||
dropzone.removeFile(file);
|
dropzone.removeFile(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add event listener to donwload file template
|
||||||
|
document.getElementById('downloadtempadvertisement').addEventListener('click', function() {
|
||||||
|
var url = `${GlobalConfig.apiHost}/api/download-template-advertisement`;
|
||||||
|
fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${document
|
||||||
|
.querySelector('meta[name="api-token"]')
|
||||||
|
.getAttribute("content")}`
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
return response.blob();
|
||||||
|
} else {
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((blob) => {
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.style.display = 'none';
|
||||||
|
a.href = url;
|
||||||
|
a.download = 'template_reklame.xlsx';
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Gagal mendownload file:", error);
|
||||||
|
showToast('bxs-error-alt', 'red', "Template file is not already exist.");
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Function to show toast
|
// Function to show toast
|
||||||
function showToast(iconClass, iconColor, message) {
|
function showToast(iconClass, iconColor, message) {
|
||||||
const toastElement = document.getElementById('toastUploadAdvertisement');
|
const toastElement = document.getElementById('toastUploadAdvertisement');
|
||||||
|
|||||||
79
resources/js/data/tourisms/data-tourisms.js
Normal file
79
resources/js/data/tourisms/data-tourisms.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import { Grid } from "gridjs/dist/gridjs.umd.js";
|
||||||
|
import gridjs from "gridjs/dist/gridjs.umd.js";
|
||||||
|
import "gridjs/dist/gridjs.umd.js";
|
||||||
|
import GlobalConfig from "../../global-config.js";
|
||||||
|
import GeneralTable from "../../table-generator.js";
|
||||||
|
|
||||||
|
|
||||||
|
const dataTourismsColumns = [
|
||||||
|
"Proyek ID",
|
||||||
|
"Jenis Proyek",
|
||||||
|
"NIB",
|
||||||
|
"Nama Perusahaan",
|
||||||
|
"Terbit OSS",
|
||||||
|
"Status Penanaman Modal",
|
||||||
|
"Bentuk Bisnis",
|
||||||
|
"Uraian Resiko Proyek",
|
||||||
|
"Nama Proyek",
|
||||||
|
"Alamat Usaha",
|
||||||
|
"Kecamatan",
|
||||||
|
"Desa",
|
||||||
|
"Luas Tanah",
|
||||||
|
"Jumlah Investasi",
|
||||||
|
"TKI",
|
||||||
|
"Tipe Usaha",
|
||||||
|
{
|
||||||
|
name: "Actions",
|
||||||
|
widht: "120px",
|
||||||
|
formatter: function(cell, row) {
|
||||||
|
const id = row.cells[16].data;
|
||||||
|
const model = "data/tourisms";
|
||||||
|
return gridjs.html(`
|
||||||
|
<div class="d-flex justify-items-end gap-10">
|
||||||
|
<button class="btn btn-warning me-2 btn-edit"
|
||||||
|
data-id="${id}"
|
||||||
|
data-model="${model}">
|
||||||
|
<i class='bx bx-edit' ></i></button>
|
||||||
|
<button class="btn btn-red btn-delete"
|
||||||
|
data-id="${id}">
|
||||||
|
<i class='bx bxs-trash' ></i></button>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const table = new GeneralTable(
|
||||||
|
"tourisms-data-table",
|
||||||
|
`${GlobalConfig.apiHost}/api/tourisms`,
|
||||||
|
`${GlobalConfig.apiHost}`,
|
||||||
|
dataTourismsColumns
|
||||||
|
);
|
||||||
|
|
||||||
|
table.processData = function (data) {
|
||||||
|
return data.data.map((item) => {
|
||||||
|
return [
|
||||||
|
item.project_id,
|
||||||
|
item.jenis_project,
|
||||||
|
item.nib,
|
||||||
|
item.business_name,
|
||||||
|
item.terbit_oss,
|
||||||
|
item.status_penanaman_modal,
|
||||||
|
item.business_form,
|
||||||
|
item.uraian_resiko_project,
|
||||||
|
item.project_name,
|
||||||
|
item.business_address,
|
||||||
|
item.district_name,
|
||||||
|
item.village_name,
|
||||||
|
item.land_area,
|
||||||
|
item.investment_amount,
|
||||||
|
item.number_of_employee,
|
||||||
|
item.business_type,
|
||||||
|
item.id,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
table.init();
|
||||||
|
})
|
||||||
149
resources/js/data/tourisms/form-upload.js
Normal file
149
resources/js/data/tourisms/form-upload.js
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
import { Dropzone } from "dropzone";
|
||||||
|
import GlobalConfig from "../../global-config.js";
|
||||||
|
|
||||||
|
Dropzone.autoDiscover = false;
|
||||||
|
|
||||||
|
var previewTemplate,
|
||||||
|
dropzone,
|
||||||
|
dropzonePreviewNode = document.querySelector("#dropzone-preview-list");
|
||||||
|
console.log(previewTemplate);
|
||||||
|
console.log(dropzone);
|
||||||
|
console.log(dropzonePreviewNode);
|
||||||
|
|
||||||
|
(dropzonePreviewNode.id = ""),
|
||||||
|
dropzonePreviewNode &&
|
||||||
|
((previewTemplate = dropzonePreviewNode.parentNode.innerHTML),
|
||||||
|
dropzonePreviewNode.parentNode.removeChild(dropzonePreviewNode),
|
||||||
|
(dropzone = new Dropzone(".dropzone", {
|
||||||
|
url: `${GlobalConfig.apiHost}/api/tourisms/import`,
|
||||||
|
// url: "https://httpbin.org/post",
|
||||||
|
method: "post",
|
||||||
|
acceptedFiles: ".xls,.xlsx", // Use acceptedFiles for better validation
|
||||||
|
previewTemplate: previewTemplate,
|
||||||
|
previewsContainer: "#dropzone-preview",
|
||||||
|
autoProcessQueue: false, // Disable auto post
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${document
|
||||||
|
.querySelector('meta[name="api-token"]')
|
||||||
|
.getAttribute("content")}`
|
||||||
|
},
|
||||||
|
init: function() {
|
||||||
|
// Listen for the success event
|
||||||
|
this.on("success", function(file, response) {
|
||||||
|
console.log("File successfully uploaded:", file);
|
||||||
|
console.log("API Response:", response);
|
||||||
|
|
||||||
|
// Show success toast
|
||||||
|
showToast('bxs-check-square', 'green', response.message);
|
||||||
|
document.getElementById("submit-upload").innerHTML = "Upload Files";
|
||||||
|
// Tunggu sebentar lalu reload halaman
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = "/data/tourisms";
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
// Listen for the error event
|
||||||
|
this.on("error", function(file, errorMessage) {
|
||||||
|
console.error("Error uploading file:", file);
|
||||||
|
console.error("Error message:", errorMessage);
|
||||||
|
// Handle the error response
|
||||||
|
|
||||||
|
// Show error toast
|
||||||
|
showToast('bxs-error-alt', 'red', errorMessage.message);
|
||||||
|
document.getElementById("submit-upload").innerHTML = "Upload Files";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})));
|
||||||
|
|
||||||
|
// Add event listener to control the submission manually
|
||||||
|
document.querySelector("#submit-upload").addEventListener("click", function() {
|
||||||
|
console.log("Ini adalah value dropzone", dropzone.files[0]);
|
||||||
|
const formData = new FormData()
|
||||||
|
console.log("Dropzonefiles",dropzone.files);
|
||||||
|
|
||||||
|
this.innerHTML = '<span class="spinner-border spinner-border-sm me-1" role="status" aria-hidden="true"></span>Loading...';
|
||||||
|
|
||||||
|
// Pastikan ada file dalam queue sebelum memprosesnya
|
||||||
|
if (dropzone.files.length > 0) {
|
||||||
|
formData.append('file', dropzone.files[0])
|
||||||
|
console.log("ini adalah form data on submit", ...formData);
|
||||||
|
dropzone.processQueue(); // Ini akan manual memicu upload
|
||||||
|
} else {
|
||||||
|
// Show error toast when no file is selected
|
||||||
|
showToast('bxs-error-alt', 'red', "Please add a file first.");
|
||||||
|
document.getElementById("submit-upload").innerHTML = "Upload Files";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Optional: Listen for the 'addedfile' event to log or control file add behavior
|
||||||
|
dropzone.on("addedfile", function (file) {
|
||||||
|
console.log("File ditambahkan:", file);
|
||||||
|
console.log("Nama File:", file.name);
|
||||||
|
console.log("Tipe File:", file.type);
|
||||||
|
console.log("Ukuran File:", (file.size / 1024).toFixed(2) + " KB");
|
||||||
|
});
|
||||||
|
|
||||||
|
dropzone.on("complete", function(file) {
|
||||||
|
dropzone.removeFile(file);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add event listener to download file template
|
||||||
|
document.getElementById('downloadtemptourisms').addEventListener('click', function() {
|
||||||
|
var url = `${GlobalConfig.apiHost}/api/download-template-umkm`;
|
||||||
|
fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${document
|
||||||
|
.querySelector('meta[name="api-token"]')
|
||||||
|
.getAttribute("content")}`
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
return response.blob(); // Jika respons OK, konversi menjadi blob
|
||||||
|
} else {
|
||||||
|
return response.json(); // Jika respons gagal, konversi menjadi JSON untuk menangani pesan error
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((blob) => {
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.style.display = 'none';
|
||||||
|
a.href = url;
|
||||||
|
a.download = 'template_tourisms.xlsx';
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Gagal mendownload file:", error);
|
||||||
|
showToast('bxs-error-alt', 'red', "Template file is not already exist.");
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Function to show toast
|
||||||
|
function showToast(iconClass, iconColor, message) {
|
||||||
|
const toastElement = document.getElementById('toastUploadUmkm');
|
||||||
|
const toastBody = toastElement.querySelector('.toast-body');
|
||||||
|
const toastHeader = toastElement.querySelector('.toast-header');
|
||||||
|
|
||||||
|
// Remove existing icon (if any) before adding the new one
|
||||||
|
const existingIcon = toastHeader.querySelector('.bx');
|
||||||
|
if (existingIcon) {
|
||||||
|
toastHeader.querySelector('.auth-logo').removeChild(existingIcon); // Remove the existing icon
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the new icon to the toast header
|
||||||
|
const icon = document.createElement('i');
|
||||||
|
icon.classList.add('bx', iconClass);
|
||||||
|
icon.style.fontSize = '25px';
|
||||||
|
icon.style.color = iconColor;
|
||||||
|
toastHeader.querySelector('.auth-logo').appendChild(icon);
|
||||||
|
|
||||||
|
// Set the toast message
|
||||||
|
toastBody.textContent = message;
|
||||||
|
|
||||||
|
// Show the toast
|
||||||
|
const toast = new bootstrap.Toast(toastElement); // Inisialisasi Bootstrap Toast
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
|
||||||
81
resources/js/data/umkm/data-umkm.js
Normal file
81
resources/js/data/umkm/data-umkm.js
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import gridjs from "gridjs/dist/gridjs.umd.js";
|
||||||
|
import "gridjs/dist/gridjs.umd.js";
|
||||||
|
import GlobalConfig from "../../global-config.js";
|
||||||
|
import GeneralTable from "../../table-generator.js";
|
||||||
|
|
||||||
|
const dataUMKMColumns = [
|
||||||
|
"Nama Usaha",
|
||||||
|
"Alamat Usaha",
|
||||||
|
"Deskripsi Usaha",
|
||||||
|
"Kontak Usaha",
|
||||||
|
"NIB",
|
||||||
|
"Skala Usaha",
|
||||||
|
"NIK",
|
||||||
|
"Nama Pemilik",
|
||||||
|
"Alamat Pemilik",
|
||||||
|
"Kontak Pemilik",
|
||||||
|
"Jenis Usaha",
|
||||||
|
"Bentuk Usaha",
|
||||||
|
"Revenue",
|
||||||
|
"Desa",
|
||||||
|
"Kecamatan",
|
||||||
|
"Jumlah Karyawan",
|
||||||
|
"Luas Tanah",
|
||||||
|
"Ijin Status",
|
||||||
|
{
|
||||||
|
name: "Actions",
|
||||||
|
widht: "120px",
|
||||||
|
formatter: function(cell, row) {
|
||||||
|
const id = row.cells[18].data;
|
||||||
|
const model = "data/umkm";
|
||||||
|
return gridjs.html(`
|
||||||
|
<div class="d-flex justify-items-end gap-10">
|
||||||
|
<button class="btn btn-warning me-2 btn-edit"
|
||||||
|
data-id="${id}"
|
||||||
|
data-model="${model}">
|
||||||
|
<i class='bx bx-edit' ></i></button>
|
||||||
|
<button class="btn btn-red btn-delete"
|
||||||
|
data-id="${id}">
|
||||||
|
<i class='bx bxs-trash' ></i></button>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const table = new GeneralTable(
|
||||||
|
"umkm-data-table",
|
||||||
|
`${GlobalConfig.apiHost}/api/umkm`,
|
||||||
|
`${GlobalConfig.apiHost}`,
|
||||||
|
dataUMKMColumns
|
||||||
|
);
|
||||||
|
|
||||||
|
table.processData = function (data) {
|
||||||
|
return data.data.map((item) => {
|
||||||
|
return [
|
||||||
|
item.business_name,
|
||||||
|
item.business_address,
|
||||||
|
item.business_desc,
|
||||||
|
item.business_contact,
|
||||||
|
item.business_id_number,
|
||||||
|
item.business_scale,
|
||||||
|
item.owner_id,
|
||||||
|
item.owner_name,
|
||||||
|
item.owner_address,
|
||||||
|
item.owner_contact,
|
||||||
|
item.business_type,
|
||||||
|
item.business_form,
|
||||||
|
item.revenue,
|
||||||
|
item.village_name,
|
||||||
|
item.district_name,
|
||||||
|
item.number_of_employee,
|
||||||
|
item.land_area,
|
||||||
|
item.permit_status,
|
||||||
|
item.id,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
table.init();
|
||||||
|
});
|
||||||
185
resources/js/data/umkm/form-create-update.js
Normal file
185
resources/js/data/umkm/form-create-update.js
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
import GlobalConfig from "../../global-config";
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
const saveButton = document.querySelector(".modal-footer .btn-primary");
|
||||||
|
const modalButton = document.querySelector(".btn-modal");
|
||||||
|
const form = document.querySelector("form#create-update-form");
|
||||||
|
var authLogo = document.querySelector(".auth-logo");
|
||||||
|
|
||||||
|
if (!saveButton || !form) return;
|
||||||
|
|
||||||
|
saveButton.addEventListener("click", function () {
|
||||||
|
// Disable tombol dan tampilkan spinner
|
||||||
|
modalButton.disabled = true;
|
||||||
|
modalButton.innerHTML = `
|
||||||
|
<span class="spinner-border spinner-border-sm me-1" role="status" aria-hidden="true"></span>
|
||||||
|
Loading...
|
||||||
|
`;
|
||||||
|
const isEdit = saveButton.classList.contains("btn-edit");
|
||||||
|
const formData = new FormData(form)
|
||||||
|
const toast = document.getElementById('toastEditUpdate');
|
||||||
|
const toastBody = toast.querySelector('.toast-body');
|
||||||
|
const toastHeader = toast.querySelector('.toast-header small');
|
||||||
|
|
||||||
|
const data = {};
|
||||||
|
|
||||||
|
// Mengonversi FormData ke dalam JSON
|
||||||
|
formData.forEach((value, key) => {
|
||||||
|
data[key] = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Log semua data dalam FormData
|
||||||
|
for (let pair of formData.entries()) {
|
||||||
|
console.log(pair[0] + ": " + pair[1]);
|
||||||
|
}
|
||||||
|
const url = form.getAttribute("action");
|
||||||
|
console.log("Ini adalah url dari form action", url);
|
||||||
|
|
||||||
|
const method = isEdit ? "PUT" : "POST";
|
||||||
|
|
||||||
|
fetch(url, {
|
||||||
|
method: method,
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${document
|
||||||
|
.querySelector('meta[name="api-token"]')
|
||||||
|
.getAttribute("content")}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log("Response data:", data);
|
||||||
|
if (!data.errors) {
|
||||||
|
// Remove existing icon (if any) before adding the new one
|
||||||
|
if (authLogo) {
|
||||||
|
// Hapus ikon yang sudah ada jika ada
|
||||||
|
const existingIcon = authLogo.querySelector('.bx');
|
||||||
|
if (existingIcon) {
|
||||||
|
authLogo.removeChild(existingIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buat ikon baru
|
||||||
|
const icon = document.createElement('i');
|
||||||
|
icon.classList.add('bx', 'bxs-check-square');
|
||||||
|
icon.style.fontSize = '25px';
|
||||||
|
icon.style.color = 'green'; // Pastikan 'green' dalam bentuk string
|
||||||
|
|
||||||
|
// Tambahkan ikon ke dalam auth-logo
|
||||||
|
authLogo.appendChild(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set success message for the toast
|
||||||
|
toastBody.textContent = isEdit ? "Data updated successfully!" : "Data created successfully!";
|
||||||
|
toast.classList.add('show'); // Show the toast
|
||||||
|
setTimeout(() => {
|
||||||
|
toast.classList.remove('show'); // Hide the toast after 3 seconds
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = '/data/umkm';
|
||||||
|
}, 3000);
|
||||||
|
} else {
|
||||||
|
if (authLogo) {
|
||||||
|
// Hapus ikon yang sudah ada jika ada
|
||||||
|
const existingIcon = authLogo.querySelector('.bx');
|
||||||
|
if (existingIcon) {
|
||||||
|
authLogo.removeChild(existingIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buat ikon baru
|
||||||
|
const icon = document.createElement('i');
|
||||||
|
icon.classList.add('bx', 'bxs-error-alt');
|
||||||
|
icon.style.fontSize = '25px';
|
||||||
|
icon.style.color = 'red'; // Pastikan 'green' dalam bentuk string
|
||||||
|
|
||||||
|
// Tambahkan ikon ke dalam auth-logo
|
||||||
|
authLogo.appendChild(icon);
|
||||||
|
}
|
||||||
|
// Set error message for the toast
|
||||||
|
toastBody.textContent = "Error: " + (data.message || "Something went wrong");
|
||||||
|
toast.classList.add('show'); // Show the toast
|
||||||
|
|
||||||
|
// Enable button and reset its text on error
|
||||||
|
modalButton.disabled = false;
|
||||||
|
modalButton.innerHTML = isEdit ? "Update" : "Create";
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
toast.classList.remove('show'); // Hide the toast after 3 seconds
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error("Error:", error);
|
||||||
|
if (authLogo) {
|
||||||
|
// Hapus ikon yang sudah ada jika ada
|
||||||
|
const existingIcon = authLogo.querySelector('.bx');
|
||||||
|
if (existingIcon) {
|
||||||
|
authLogo.removeChild(existingIcon);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buat ikon baru
|
||||||
|
const icon = document.createElement('i');
|
||||||
|
icon.classList.add('bx', 'bxs-error-alt');
|
||||||
|
icon.style.fontSize = '25px';
|
||||||
|
icon.style.color = 'red'; // Pastikan 'green' dalam bentuk string
|
||||||
|
|
||||||
|
// Tambahkan ikon ke dalam auth-logo
|
||||||
|
authLogo.appendChild(icon);
|
||||||
|
}
|
||||||
|
// Set error message for the toast
|
||||||
|
toastBody.textContent = "An error occurred while processing your request.";
|
||||||
|
toast.classList.add('show'); // Show the toast
|
||||||
|
|
||||||
|
// Enable button and reset its text on error
|
||||||
|
modalButton.disabled = false;
|
||||||
|
modalButton.innerHTML = isEdit ? "Update" : "Create";
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
toast.classList.remove('show'); // Hide the toast after 3 seconds
|
||||||
|
}, 3000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fungsi fetchOptions untuk autocomplete server-side
|
||||||
|
window.fetchOptions = function (field) {
|
||||||
|
let inputValue = document.getElementById(field).value;
|
||||||
|
console.log("Query Value:", inputValue); // Debugging log
|
||||||
|
if (inputValue.length < 2) return;
|
||||||
|
let districtValue = document.getElementById("district_name").value; // Ambil kecamatan terpilih
|
||||||
|
|
||||||
|
let url = `${GlobalConfig.apiHost}/api/combobox/search-options?query=${encodeURIComponent(inputValue)}&field=${field}`;
|
||||||
|
|
||||||
|
// Jika field desa, tambahkan kecamatan sebagai filter
|
||||||
|
if (field === "village_name") {
|
||||||
|
url += `&district=${encodeURIComponent(districtValue)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${document
|
||||||
|
.querySelector('meta[name="api-token"]')
|
||||||
|
.getAttribute("content")}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
let dataList = document.getElementById(field + "Options");
|
||||||
|
dataList.innerHTML = "";
|
||||||
|
|
||||||
|
data.forEach(item => {
|
||||||
|
let option = document.createElement("option");
|
||||||
|
option.value = item.name;
|
||||||
|
option.dataset.code = item.code;
|
||||||
|
dataList.appendChild(option);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => console.error("Error fetching options:", error));
|
||||||
|
};
|
||||||
|
|
||||||
|
document.querySelector('.btn-back').addEventListener('click', function() {
|
||||||
|
window.history.back();
|
||||||
|
});
|
||||||
|
});
|
||||||
149
resources/js/data/umkm/form-upload.js
Normal file
149
resources/js/data/umkm/form-upload.js
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
import { Dropzone } from "dropzone";
|
||||||
|
import GlobalConfig from "../../global-config.js";
|
||||||
|
|
||||||
|
Dropzone.autoDiscover = false;
|
||||||
|
|
||||||
|
var previewTemplate,
|
||||||
|
dropzone,
|
||||||
|
dropzonePreviewNode = document.querySelector("#dropzone-preview-list");
|
||||||
|
console.log(previewTemplate);
|
||||||
|
console.log(dropzone);
|
||||||
|
console.log(dropzonePreviewNode);
|
||||||
|
|
||||||
|
(dropzonePreviewNode.id = ""),
|
||||||
|
dropzonePreviewNode &&
|
||||||
|
((previewTemplate = dropzonePreviewNode.parentNode.innerHTML),
|
||||||
|
dropzonePreviewNode.parentNode.removeChild(dropzonePreviewNode),
|
||||||
|
(dropzone = new Dropzone(".dropzone", {
|
||||||
|
url: `${GlobalConfig.apiHost}/api/umkm/import`,
|
||||||
|
// url: "https://httpbin.org/post",
|
||||||
|
method: "post",
|
||||||
|
acceptedFiles: ".xls,.xlsx", // Use acceptedFiles for better validation
|
||||||
|
previewTemplate: previewTemplate,
|
||||||
|
previewsContainer: "#dropzone-preview",
|
||||||
|
autoProcessQueue: false, // Disable auto post
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${document
|
||||||
|
.querySelector('meta[name="api-token"]')
|
||||||
|
.getAttribute("content")}`
|
||||||
|
},
|
||||||
|
init: function() {
|
||||||
|
// Listen for the success event
|
||||||
|
this.on("success", function(file, response) {
|
||||||
|
console.log("File successfully uploaded:", file);
|
||||||
|
console.log("API Response:", response);
|
||||||
|
|
||||||
|
// Show success toast
|
||||||
|
showToast('bxs-check-square', 'green', response.message);
|
||||||
|
document.getElementById("submit-upload").innerHTML = "Upload Files";
|
||||||
|
// Tunggu sebentar lalu reload halaman
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = "/data/umkm";
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
// Listen for the error event
|
||||||
|
this.on("error", function(file, errorMessage) {
|
||||||
|
console.error("Error uploading file:", file);
|
||||||
|
console.error("Error message:", errorMessage);
|
||||||
|
// Handle the error response
|
||||||
|
|
||||||
|
// Show error toast
|
||||||
|
showToast('bxs-error-alt', 'red', errorMessage.message);
|
||||||
|
document.getElementById("submit-upload").innerHTML = "Upload Files";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})));
|
||||||
|
|
||||||
|
// Add event listener to control the submission manually
|
||||||
|
document.querySelector("#submit-upload").addEventListener("click", function() {
|
||||||
|
console.log("Ini adalah value dropzone", dropzone.files[0]);
|
||||||
|
const formData = new FormData()
|
||||||
|
console.log("Dropzonefiles",dropzone.files);
|
||||||
|
|
||||||
|
this.innerHTML = '<span class="spinner-border spinner-border-sm me-1" role="status" aria-hidden="true"></span>Loading...';
|
||||||
|
|
||||||
|
// Pastikan ada file dalam queue sebelum memprosesnya
|
||||||
|
if (dropzone.files.length > 0) {
|
||||||
|
formData.append('file', dropzone.files[0])
|
||||||
|
console.log("ini adalah form data on submit", ...formData);
|
||||||
|
dropzone.processQueue(); // Ini akan manual memicu upload
|
||||||
|
} else {
|
||||||
|
// Show error toast when no file is selected
|
||||||
|
showToast('bxs-error-alt', 'red', "Please add a file first.");
|
||||||
|
document.getElementById("submit-upload").innerHTML = "Upload Files";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Optional: Listen for the 'addedfile' event to log or control file add behavior
|
||||||
|
dropzone.on("addedfile", function (file) {
|
||||||
|
console.log("File ditambahkan:", file);
|
||||||
|
console.log("Nama File:", file.name);
|
||||||
|
console.log("Tipe File:", file.type);
|
||||||
|
console.log("Ukuran File:", (file.size / 1024).toFixed(2) + " KB");
|
||||||
|
});
|
||||||
|
|
||||||
|
dropzone.on("complete", function(file) {
|
||||||
|
dropzone.removeFile(file);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add event listener to download file template
|
||||||
|
document.getElementById('downloadtempumkm').addEventListener('click', function() {
|
||||||
|
var url = `${GlobalConfig.apiHost}/api/download-template-umkm`;
|
||||||
|
fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${document
|
||||||
|
.querySelector('meta[name="api-token"]')
|
||||||
|
.getAttribute("content")}`
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
return response.blob(); // Jika respons OK, konversi menjadi blob
|
||||||
|
} else {
|
||||||
|
return response.json(); // Jika respons gagal, konversi menjadi JSON untuk menangani pesan error
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((blob) => {
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.style.display = 'none';
|
||||||
|
a.href = url;
|
||||||
|
a.download = 'template_umkm.xlsx';
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Gagal mendownload file:", error);
|
||||||
|
showToast('bxs-error-alt', 'red', "Template file is not already exist.");
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Function to show toast
|
||||||
|
function showToast(iconClass, iconColor, message) {
|
||||||
|
const toastElement = document.getElementById('toastUploadUmkm');
|
||||||
|
const toastBody = toastElement.querySelector('.toast-body');
|
||||||
|
const toastHeader = toastElement.querySelector('.toast-header');
|
||||||
|
|
||||||
|
// Remove existing icon (if any) before adding the new one
|
||||||
|
const existingIcon = toastHeader.querySelector('.bx');
|
||||||
|
if (existingIcon) {
|
||||||
|
toastHeader.querySelector('.auth-logo').removeChild(existingIcon); // Remove the existing icon
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the new icon to the toast header
|
||||||
|
const icon = document.createElement('i');
|
||||||
|
icon.classList.add('bx', iconClass);
|
||||||
|
icon.style.fontSize = '25px';
|
||||||
|
icon.style.color = iconColor;
|
||||||
|
toastHeader.querySelector('.auth-logo').appendChild(icon);
|
||||||
|
|
||||||
|
// Set the toast message
|
||||||
|
toastBody.textContent = message;
|
||||||
|
|
||||||
|
// Show the toast
|
||||||
|
const toast = new bootstrap.Toast(toastElement); // Inisialisasi Bootstrap Toast
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
|
||||||
16
resources/js/report/tourisms/index.js
Normal file
16
resources/js/report/tourisms/index.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import gridjs from "gridjs/dist/gridjs.umd.js";
|
||||||
|
import "gridjs/dist/gridjs.umd.js";
|
||||||
|
|
||||||
|
// Mengambil data dari input dengan id="business_type_counts"
|
||||||
|
const businessTypeCountsElement = document.getElementById("business_type_counts");
|
||||||
|
console.log(businessTypeCountsElement);
|
||||||
|
const businessTypeCounts = JSON.parse(businessTypeCountsElement.value); // Cek apakah data sudah terbawa dengan benar
|
||||||
|
|
||||||
|
// Membuat Grid.js instance
|
||||||
|
new gridjs.Grid({
|
||||||
|
columns: ["Jenis Bisnis Pariwisata", "Jumlah Total"], // Nama kolom
|
||||||
|
data: businessTypeCounts.map(item => [item.business_type, item.count]), // Mengubah data untuk Grid.js
|
||||||
|
search: true, // Menambahkan fitur pencarian
|
||||||
|
pagination: true, // Menambahkan fitur pagination
|
||||||
|
sort: true, // Menambahkan fitur sorting
|
||||||
|
}).render(document.getElementById("tourisms-report-data-table"));
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Grid } from "gridjs/dist/gridjs.umd.js";
|
import { Grid } from "gridjs/dist/gridjs.umd.js";
|
||||||
import "gridjs/dist/gridjs.umd.js";
|
import "gridjs/dist/gridjs.umd.js";
|
||||||
|
import Swal from "sweetalert2";
|
||||||
|
|
||||||
class GeneralTable {
|
class GeneralTable {
|
||||||
constructor(tableId, apiUrl, baseUrl, columns, options = {}) {
|
constructor(tableId, apiUrl, baseUrl, columns, options = {}) {
|
||||||
@@ -94,9 +95,29 @@ class GeneralTable {
|
|||||||
handleDelete(event) {
|
handleDelete(event) {
|
||||||
const id = event.target.getAttribute('data-id');
|
const id = event.target.getAttribute('data-id');
|
||||||
console.log(id);
|
console.log(id);
|
||||||
if (confirm("Are you sure you want to delete this item?")) {
|
// if (confirm("Are you sure you want to delete this item?")) {
|
||||||
this.deleteRecord(id);
|
// this.deleteRecord(id);
|
||||||
}
|
// }
|
||||||
|
Swal.fire({
|
||||||
|
title: "Are you sure?",
|
||||||
|
text: "You won't be able to revert this!",
|
||||||
|
icon: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: "#d33",
|
||||||
|
cancelButtonColor: "#3085d6",
|
||||||
|
confirmButtonText: "Yes, delete it!"
|
||||||
|
}).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
this.deleteRecord(id);
|
||||||
|
Swal.fire({
|
||||||
|
title: "Deleted!",
|
||||||
|
text: "Your record has been deleted.",
|
||||||
|
icon: "success",
|
||||||
|
showConfirmButton: false, // Menghilangkan tombol OK
|
||||||
|
timer: 2000 // Menutup otomatis dalam 2 detik (opsional)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteRecord(id) {
|
async deleteRecord(id) {
|
||||||
@@ -110,23 +131,30 @@ class GeneralTable {
|
|||||||
.getAttribute("content")}`,
|
.getAttribute("content")}`,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
// headers: {
|
|
||||||
// 'Authorization': `Bearer ${document.querySelector('meta[name="api-token"]').getAttribute("content")}`,
|
|
||||||
// 'Content-Type': 'application/json',
|
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
if (response.status === 204) { // Jika status code 204, berarti berhasil
|
if (response.status === 204) {
|
||||||
alert('Data deleted successfully!');
|
|
||||||
location.reload();
|
location.reload();
|
||||||
} else {
|
} else {
|
||||||
const data = await response.json(); // Jika ada data di response body
|
const data = await response.json();
|
||||||
alert('Failed to delete data: ' + (data.message || 'Unknown error.'));
|
showErrorAlert(`Failed to delete record: ${data.message || "Unknown error"}`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting data:', error);
|
console.error('Error deleting data:', error);
|
||||||
alert('Error deleting data.');
|
showErrorAlert("Error deleting data. Please try again.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fungsi untuk menampilkan alert
|
||||||
|
function showErrorAlert(message) {
|
||||||
|
const alertContainer = document.getElementById("alert-container");
|
||||||
|
|
||||||
|
alertContainer.innerHTML = `
|
||||||
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||||
|
${message}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
export default GeneralTable;
|
export default GeneralTable;
|
||||||
@@ -8,14 +8,10 @@
|
|||||||
<div class="col-xl-12">
|
<div class="col-xl-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h5 class="card-title">Upload Data Reklame</h5>
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
<p class="card-subtitle">
|
<h5 class="card-title">Upload Data Reklame</h5>
|
||||||
Please upload a file with the extension <strong>.xls or .xlsx</strong> with a maximum size of <strong>10 MB</strong>.
|
<button id="downloadtempadvertisement" class="btn btn-secondary">Download Template</button>
|
||||||
<br>
|
</div>
|
||||||
For <strong>.xls</strong> and <strong>.xlsx</strong> files, ensure that the data is contained within a <strong>single sheet</strong> with the following columns:
|
|
||||||
<strong>No, Nama Wajib Pajak, NPWPD, Jenis Reklame, Isi Reklame, Alamat Wajib Pajak, Lokasi Reklame, Desa,
|
|
||||||
Kecamatan, Panajang, Lebar, Sudut Pandang, Muka, Luas, Sudut, Kontak.</strong>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -31,6 +27,10 @@
|
|||||||
<div class="dz-message needsclick">
|
<div class="dz-message needsclick">
|
||||||
<i class="h1 bx bx-cloud-upload"></i>
|
<i class="h1 bx bx-cloud-upload"></i>
|
||||||
<h3>Drop files here or click to upload.</h3>
|
<h3>Drop files here or click to upload.</h3>
|
||||||
|
<p class="card-subtitle">
|
||||||
|
Please upload a file with the extension <strong>.xls or .xlsx</strong> with a maximum size of <strong>10 MB</strong>.
|
||||||
|
<br>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
<div class="toast-body">
|
<div class="toast-body">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
|||||||
91
resources/views/data/tourisms/form-upload.blade.php
Normal file
91
resources/views/data/tourisms/form-upload.blade.php
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
@extends('layouts.vertical', ['subtitle' => 'File Upload'])
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
@include('layouts.partials/page-title', ['title' => 'Form', 'subtitle' => 'File Uploads'])
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
|
<h5 class="card-title mb-0">Upload Data Pariwisata</h5>
|
||||||
|
<button id="downloadtemptourisms" class="btn btn-secondary">Download Template</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
|
||||||
|
<div class="dropzone">
|
||||||
|
<form action="" method="post" enctype="multipart/form-data">
|
||||||
|
<div class="fallback">
|
||||||
|
<input id="file-dropzone"type="file" name="file" multiple/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="dz-message needsclick">
|
||||||
|
<i class="h1 bx bx-cloud-upload"></i>
|
||||||
|
<h3>Drop files here or click to upload.</h3>
|
||||||
|
<p class="card-subtitle">
|
||||||
|
Please upload a file with the extension <strong>.xls or .xlsx</strong> with a maximum size of <strong>10 MB</strong>.
|
||||||
|
<br>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="list-unstyled mb-0" id="dropzone-preview">
|
||||||
|
<li class="mt-2" id="dropzone-preview-list">
|
||||||
|
<!-- This is used as the file preview template -->
|
||||||
|
<div class="border rounded">
|
||||||
|
<div class="d-flex align-items-center p-2">
|
||||||
|
<div class="flex-shrink-0 me-3">
|
||||||
|
<div class="avatar-sm bg-light rounded">
|
||||||
|
<img data-dz-thumbnail class="img-fluid rounded d-block" src="#"
|
||||||
|
alt="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<div class="pt-1">
|
||||||
|
<h5 class="fs-14 mb-1" data-dz-name>
|
||||||
|
</h5>
|
||||||
|
<p class="fs-13 text-muted mb-0" data-dz-size></p>
|
||||||
|
<strong class="error text-danger" data-dz-errormessage></strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex-shrink-0 ms-3">
|
||||||
|
<button data-dz-remove class="btn btn-sm btn-danger">Delete</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<!-- end dropzon-preview -->
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-end">
|
||||||
|
<button id="submit-upload" class="btn btn-primary">Upload Files</button>
|
||||||
|
</div>
|
||||||
|
</div> <!-- end card body -->
|
||||||
|
</div> <!-- end card -->
|
||||||
|
</div> <!-- end col -->
|
||||||
|
</div> <!-- end row -->
|
||||||
|
|
||||||
|
<div class="toast-container position-fixed end-0 top-0 p-3">
|
||||||
|
<div id="toastUploadUmkm" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||||
|
<div class="toast-header">
|
||||||
|
<div class="auth-logo me-auto">
|
||||||
|
</div>
|
||||||
|
<small class="text-muted"></small>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="toast"
|
||||||
|
aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="toast-body">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
@vite(['resources/js/data/tourisms/form-upload.js'])
|
||||||
|
@endsection
|
||||||
127
resources/views/data/tourisms/form.blade.php
Normal file
127
resources/views/data/tourisms/form.blade.php
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
@extends('layouts.vertical', ['subtitle' => $subtitle]) <!-- Menggunakan subtitle dari controller -->
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
@include('layouts.partials/page-title', ['title' => $title, 'subtitle' => $subtitle]) <!-- Menggunakan title dan subtitle dari controller -->
|
||||||
|
|
||||||
|
<div class="row d-flex justify-content-center">
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
{{ session('error') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<ul>
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="col-lg-12 col-md-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<button class="btn btn-danger float-end btn-back">
|
||||||
|
<i class='bx bx-arrow-back'></i>
|
||||||
|
Back
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<form id="create-update-form" action="{{ isset($modelInstance) && $modelInstance->id ? $apiUrl . '/' . $modelInstance->id : $apiUrl }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
@if(isset($modelInstance))
|
||||||
|
@method('PUT')
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
@foreach($fields as $field => $label)
|
||||||
|
<div class="col-md-6 form-group mb-3">
|
||||||
|
<label for="{{ $field }}">{{ $label }}</label>
|
||||||
|
@php
|
||||||
|
$fieldType = $fieldTypes[$field] ?? 'text'; // Default text jika tidak ditemukan tipe
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
@if($fieldType == 'textarea')
|
||||||
|
<textarea id="{{ $field }}" name="{{ $field }}" class="form-control">{{ old($field, isset($modelInstance) ? $modelInstance->{$field} : '') }}</textarea>
|
||||||
|
@elseif($fieldType == 'select' && isset($dropdownOptions[$field]))
|
||||||
|
<select id="{{ $field }}" name="{{ $field }}" class="form-control">
|
||||||
|
@foreach($dropdownOptions[$field] as $code => $name)
|
||||||
|
@php
|
||||||
|
// $selectedValue = old($field, $modelInstance->{$field});
|
||||||
|
$selectedValue = old($field, $modelInstance->$field ?? '');
|
||||||
|
$isSelected = strval($selectedValue) === strval($code);
|
||||||
|
@endphp
|
||||||
|
<option value="{{ $code }}" class="{{ $isSelected ? 'selected' : '' }}" {{ $isSelected ? 'selected' : '' }}>
|
||||||
|
{{ $name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@elseif($fieldType == 'combobox' && isset($dropdownOptions[$field]))
|
||||||
|
<input class="form-control" list="{{ $field }}Options" id="{{ $field }}" name="{{ $field }}"
|
||||||
|
value="{{ old($field, isset($modelInstance) ? $modelInstance->{$field} : '') }}" placeholder="Type to search..." oninput="fetchOptions('{{ $field }}')">
|
||||||
|
<datalist id="{{ $field }}Options"></datalist>
|
||||||
|
@else
|
||||||
|
<input type="{{ $fieldType }}" id="{{ $field }}" name="{{ $field }}" class="form-control" value="{{ old($field, isset($modelInstance) ? $modelInstance->{$field} : '') }}">
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-end">
|
||||||
|
<button type="button" class="btn {{ isset($modelInstance) ? 'btn-warning' : 'btn-success' }} width-lg btn-modal" data-bs-toggle="modal" data-bs-target="#confirmationModalCenter">
|
||||||
|
{{ isset($modelInstance) ? 'Update' : 'Create' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Modal -->
|
||||||
|
<div class="modal fade" id="confirmationModalCenter" tabindex="-1"
|
||||||
|
aria-labelledby="confirmationModalCenterTitle" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="confirmationModalCenterTitle">
|
||||||
|
{{ isset($modelInstance) ? 'Update Confirmation' : 'Create Confirmation' }}
|
||||||
|
</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal"
|
||||||
|
aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>{{ isset($modelInstance) ? 'Are you sure you want to save the data changes?' : 'Are you sure you want to create new data based on the form contents?' }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary"
|
||||||
|
data-bs-dismiss="modal">Close</button>
|
||||||
|
<button type="button" class="btn btn-primary {{ isset($modelInstance) ? 'btn-edit' : 'btn-create' }}" data-bs-dismiss="modal">Save changes</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="toast-container position-fixed end-0 top-0 p-3">
|
||||||
|
<div id="toastEditUpdate" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||||
|
<div class="toast-header">
|
||||||
|
<div class="auth-logo me-auto">
|
||||||
|
</div>
|
||||||
|
<small class="text-muted"></small>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="toast"
|
||||||
|
aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="toast-body">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
@vite(['resources/js/data/umkm/form-create-update.js'])
|
||||||
|
@endsection
|
||||||
38
resources/views/data/tourisms/index.blade.php
Normal file
38
resources/views/data/tourisms/index.blade.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
@extends('layouts.vertical', ['subtitle' => 'Pariwisata'])
|
||||||
|
|
||||||
|
@section('css')
|
||||||
|
@vite(['node_modules/gridjs/dist/theme/mermaid.min.css'])
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'Pariwisata'])
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h5 class="card-title">Daftar Pariwisata</h5>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="d-flex justify-content-end gap-10 pb-3">
|
||||||
|
<button class="btn btn-success me-2 width-lg btn-create" data-model="data/tourisms">
|
||||||
|
<i class='bx bxs-file-plus'></i>
|
||||||
|
Create</button>
|
||||||
|
<button class="btn btn-primary width-lg btn-bulk-create" data-model="data/tourisms">
|
||||||
|
<i class='bx bx-upload' ></i>
|
||||||
|
Bulk Create
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div id="tourisms-data-table"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- <div id="alert-container"></div> --}}
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
@vite(['resources/js/data/tourisms/data-tourisms.js'])
|
||||||
|
@endsection
|
||||||
91
resources/views/data/umkm/form-upload.blade.php
Normal file
91
resources/views/data/umkm/form-upload.blade.php
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
@extends('layouts.vertical', ['subtitle' => 'File Upload'])
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
@include('layouts.partials/page-title', ['title' => 'Form', 'subtitle' => 'File Uploads'])
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
|
<h5 class="card-title mb-0">Upload Data Umkm</h5>
|
||||||
|
<button id="downloadtempumkm" class="btn btn-secondary">Download Template</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
|
||||||
|
<div class="dropzone">
|
||||||
|
<form action="" method="post" enctype="multipart/form-data">
|
||||||
|
<div class="fallback">
|
||||||
|
<input id="file-dropzone"type="file" name="file" multiple/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="dz-message needsclick">
|
||||||
|
<i class="h1 bx bx-cloud-upload"></i>
|
||||||
|
<h3>Drop files here or click to upload.</h3>
|
||||||
|
<p class="card-subtitle">
|
||||||
|
Please upload a file with the extension <strong>.xls or .xlsx</strong> with a maximum size of <strong>10 MB</strong>.
|
||||||
|
<br>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="list-unstyled mb-0" id="dropzone-preview">
|
||||||
|
<li class="mt-2" id="dropzone-preview-list">
|
||||||
|
<!-- This is used as the file preview template -->
|
||||||
|
<div class="border rounded">
|
||||||
|
<div class="d-flex align-items-center p-2">
|
||||||
|
<div class="flex-shrink-0 me-3">
|
||||||
|
<div class="avatar-sm bg-light rounded">
|
||||||
|
<img data-dz-thumbnail class="img-fluid rounded d-block" src="#"
|
||||||
|
alt="" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<div class="pt-1">
|
||||||
|
<h5 class="fs-14 mb-1" data-dz-name>
|
||||||
|
</h5>
|
||||||
|
<p class="fs-13 text-muted mb-0" data-dz-size></p>
|
||||||
|
<strong class="error text-danger" data-dz-errormessage></strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex-shrink-0 ms-3">
|
||||||
|
<button data-dz-remove class="btn btn-sm btn-danger">Delete</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<!-- end dropzon-preview -->
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-end">
|
||||||
|
<button id="submit-upload" class="btn btn-primary">Upload Files</button>
|
||||||
|
</div>
|
||||||
|
</div> <!-- end card body -->
|
||||||
|
</div> <!-- end card -->
|
||||||
|
</div> <!-- end col -->
|
||||||
|
</div> <!-- end row -->
|
||||||
|
|
||||||
|
<div class="toast-container position-fixed end-0 top-0 p-3">
|
||||||
|
<div id="toastUploadUmkm" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||||
|
<div class="toast-header">
|
||||||
|
<div class="auth-logo me-auto">
|
||||||
|
</div>
|
||||||
|
<small class="text-muted"></small>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="toast"
|
||||||
|
aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="toast-body">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
@vite(['resources/js/data/umkm/form-upload.js'])
|
||||||
|
@endsection
|
||||||
127
resources/views/data/umkm/form.blade.php
Normal file
127
resources/views/data/umkm/form.blade.php
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
@extends('layouts.vertical', ['subtitle' => $subtitle]) <!-- Menggunakan subtitle dari controller -->
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
@include('layouts.partials/page-title', ['title' => $title, 'subtitle' => $subtitle]) <!-- Menggunakan title dan subtitle dari controller -->
|
||||||
|
|
||||||
|
<div class="row d-flex justify-content-center">
|
||||||
|
@if (session('error'))
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
{{ session('error') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<ul>
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="col-lg-12 col-md-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<button class="btn btn-danger float-end btn-back">
|
||||||
|
<i class='bx bx-arrow-back'></i>
|
||||||
|
Back
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<form id="create-update-form" action="{{ isset($modelInstance) && $modelInstance->id ? $apiUrl . '/' . $modelInstance->id : $apiUrl }}" method="POST">
|
||||||
|
@csrf
|
||||||
|
@if(isset($modelInstance))
|
||||||
|
@method('PUT')
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
@foreach($fields as $field => $label)
|
||||||
|
<div class="col-md-6 form-group mb-3">
|
||||||
|
<label for="{{ $field }}">{{ $label }}</label>
|
||||||
|
@php
|
||||||
|
$fieldType = $fieldTypes[$field] ?? 'text'; // Default text jika tidak ditemukan tipe
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
@if($fieldType == 'textarea')
|
||||||
|
<textarea id="{{ $field }}" name="{{ $field }}" class="form-control">{{ old($field, isset($modelInstance) ? $modelInstance->{$field} : '') }}</textarea>
|
||||||
|
@elseif($fieldType == 'select' && isset($dropdownOptions[$field]))
|
||||||
|
<select id="{{ $field }}" name="{{ $field }}" class="form-control">
|
||||||
|
@foreach($dropdownOptions[$field] as $code => $name)
|
||||||
|
@php
|
||||||
|
// $selectedValue = old($field, $modelInstance->{$field});
|
||||||
|
$selectedValue = old($field, $modelInstance->$field ?? '');
|
||||||
|
$isSelected = strval($selectedValue) === strval($code);
|
||||||
|
@endphp
|
||||||
|
<option value="{{ $code }}" class="{{ $isSelected ? 'selected' : '' }}" {{ $isSelected ? 'selected' : '' }}>
|
||||||
|
{{ $name }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@elseif($fieldType == 'combobox' && isset($dropdownOptions[$field]))
|
||||||
|
<input class="form-control" list="{{ $field }}Options" id="{{ $field }}" name="{{ $field }}"
|
||||||
|
value="{{ old($field, isset($modelInstance) ? $modelInstance->{$field} : '') }}" placeholder="Type to search..." oninput="fetchOptions('{{ $field }}')">
|
||||||
|
<datalist id="{{ $field }}Options"></datalist>
|
||||||
|
@else
|
||||||
|
<input type="{{ $fieldType }}" id="{{ $field }}" name="{{ $field }}" class="form-control" value="{{ old($field, isset($modelInstance) ? $modelInstance->{$field} : '') }}">
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex justify-content-end">
|
||||||
|
<button type="button" class="btn {{ isset($modelInstance) ? 'btn-warning' : 'btn-success' }} width-lg btn-modal" data-bs-toggle="modal" data-bs-target="#confirmationModalCenter">
|
||||||
|
{{ isset($modelInstance) ? 'Update' : 'Create' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Modal -->
|
||||||
|
<div class="modal fade" id="confirmationModalCenter" tabindex="-1"
|
||||||
|
aria-labelledby="confirmationModalCenterTitle" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="confirmationModalCenterTitle">
|
||||||
|
{{ isset($modelInstance) ? 'Update Confirmation' : 'Create Confirmation' }}
|
||||||
|
</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal"
|
||||||
|
aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>{{ isset($modelInstance) ? 'Are you sure you want to save the data changes?' : 'Are you sure you want to create new data based on the form contents?' }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary"
|
||||||
|
data-bs-dismiss="modal">Close</button>
|
||||||
|
<button type="button" class="btn btn-primary {{ isset($modelInstance) ? 'btn-edit' : 'btn-create' }}" data-bs-dismiss="modal">Save changes</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="toast-container position-fixed end-0 top-0 p-3">
|
||||||
|
<div id="toastEditUpdate" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||||
|
<div class="toast-header">
|
||||||
|
<div class="auth-logo me-auto">
|
||||||
|
</div>
|
||||||
|
<small class="text-muted"></small>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="toast"
|
||||||
|
aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="toast-body">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
@vite(['resources/js/data/umkm/form-create-update.js'])
|
||||||
|
@endsection
|
||||||
38
resources/views/data/umkm/index.blade.php
Normal file
38
resources/views/data/umkm/index.blade.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
@extends('layouts.vertical', ['subtitle' => 'UMKM'])
|
||||||
|
|
||||||
|
@section('css')
|
||||||
|
@vite(['node_modules/gridjs/dist/theme/mermaid.min.css'])
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'UMKM'])
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h5 class="card-title">Daftar UMKM</h5>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="d-flex justify-content-end gap-10 pb-3">
|
||||||
|
<button class="btn btn-success me-2 width-lg btn-create" data-model="data/umkm">
|
||||||
|
<i class='bx bxs-file-plus'></i>
|
||||||
|
Create</button>
|
||||||
|
<button class="btn btn-primary width-lg btn-bulk-create" data-model="data/umkm">
|
||||||
|
<i class='bx bx-upload' ></i>
|
||||||
|
Bulk Create
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div id="umkm-data-table"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="alert-container"></div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
@vite(['resources/js/data/umkm/data-umkm.js'])
|
||||||
|
@endsection
|
||||||
@@ -94,6 +94,28 @@
|
|||||||
<li class="sub-nav-item">
|
<li class="sub-nav-item">
|
||||||
<a class="sub-nav-link" href="{{ route ('advertisements.index') }}">Reklame</a>
|
<a class="sub-nav-link" href="{{ route ('advertisements.index') }}">Reklame</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="sub-nav-item">
|
||||||
|
<a class="sub-nav-link" href="{{ route ('umkm.index') }}">UMKM</a>
|
||||||
|
</li>
|
||||||
|
<li class="sub-nav-item">
|
||||||
|
<a class="sub-nav-link" href="{{ route ('tourisms.index') }}">Pariwisata</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link menu-arrow" href="#report" data-bs-toggle="collapse" role="button"
|
||||||
|
aria-expanded="false" aria-controls="report">
|
||||||
|
<span class="nav-icon">
|
||||||
|
<iconify-icon icon="mingcute:task-line"></iconify-icon>
|
||||||
|
</span>
|
||||||
|
<span class="nav-text">Laporan</span>
|
||||||
|
</a>
|
||||||
|
<div class="collapse" id="report">
|
||||||
|
<ul class="nav sub-navbar-nav">
|
||||||
|
<li class="sub-nav-item">
|
||||||
|
<a class="sub-nav-link" href="{{ route ('tourisms.index') }}">Pariwisata</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
28
resources/views/report/tourisms/index.blade.php
Normal file
28
resources/views/report/tourisms/index.blade.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
@extends('layouts.vertical', ['subtitle' => 'Report Pariwisata'])
|
||||||
|
|
||||||
|
@section('css')
|
||||||
|
@vite(['node_modules/gridjs/dist/theme/mermaid.min.css'])
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
@include('layouts.partials/page-title', ['title' => 'Report', 'subtitle' => 'Report Pariwisata'])
|
||||||
|
|
||||||
|
<input id="business_type_counts" type="hidden" value="{{ json_encode($businessTypeCounts) }}">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h5 class="card-title">Laporan Pariwisata</h5>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="row">
|
||||||
|
<div>
|
||||||
|
<div id="tourisms-report-data-table"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
@vite(['resources/js/report/tourisms/index.js'])
|
||||||
|
@endsection
|
||||||
@@ -8,6 +8,8 @@ use App\Http\Controllers\Api\ScrapingController;
|
|||||||
use App\Http\Controllers\Api\UsersController;
|
use App\Http\Controllers\Api\UsersController;
|
||||||
use App\Http\Controllers\Settings\SyncronizeController;
|
use App\Http\Controllers\Settings\SyncronizeController;
|
||||||
use App\Http\Controllers\Api\AdvertisementController;
|
use App\Http\Controllers\Api\AdvertisementController;
|
||||||
|
use App\Http\Controllers\Api\UmkmController;
|
||||||
|
use App\Http\Controllers\Api\TourismController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::post('/login', [UsersController::class, 'login'])->name('api.user.login');
|
Route::post('/login', [UsersController::class, 'login'])->name('api.user.login');
|
||||||
@@ -45,10 +47,20 @@ Route::group(['middleware' => 'auth:sanctum'], function (){
|
|||||||
Route::apiResource('advertisements', AdvertisementController::class);
|
Route::apiResource('advertisements', AdvertisementController::class);
|
||||||
Route::get('/combobox/search-options', [AdvertisementController::class, 'searchOptionsInAdvertisements']);
|
Route::get('/combobox/search-options', [AdvertisementController::class, 'searchOptionsInAdvertisements']);
|
||||||
Route::post('/advertisements/import', [AdvertisementController::class, 'importFromFile']);
|
Route::post('/advertisements/import', [AdvertisementController::class, 'importFromFile']);
|
||||||
|
Route::get('/download-template-advertisement', [AdvertisementController::class, 'downloadExcelAdvertisement']);
|
||||||
|
|
||||||
|
// umkm
|
||||||
|
Route::apiResource('umkm', UmkmController::class);
|
||||||
|
Route::post('/umkm/import', [UmkmController::class, 'importFromFile']);
|
||||||
|
Route::get('/download-template-umkm', [UmkmController::class, 'downloadExcelUmkm']);
|
||||||
|
|
||||||
|
//tourism
|
||||||
|
Route::apiResource('tourisms', TourismController::class);
|
||||||
|
Route::post('/tourisms/import', [TourismController::class, 'importFromFile']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Route::get('/sync-task', [SyncronizeController::class, 'syncPbgTask'])->name('api.task');
|
Route::get('/sync-task', [SyncronizeController::class, 'syncPbgTask'])->name('api.task');
|
||||||
Route::get('/get-user-token', [SyncronizeController::class, 'getUserToken'])->name('api.task.token');
|
Route::get('/get-user-token', [SyncronizeController::class, 'getUserToken'])->name('api.task.token');
|
||||||
Route::get('/get-index-integration-retribution/{uuid}', [SyncronizeController::class, 'syncIndexIntegration'])->name('api.task.inntegration');
|
Route::get('/get-index-integration-retribution/{uuid}', [SyncronizeController::class, 'syncIndexIntegration'])->name('api.task.inntegration');
|
||||||
Route::get('/sync-task-submit/{uuid}', [SyncronizeController::class, 'syncTaskDetailSubmit'])->name('api.task.submit');
|
Route::get('/sync-task-submit/{uuid}', [SyncronizeController::class, 'syncTaskDetailSubmit'])->name('api.task.submit');
|
||||||
@@ -7,6 +7,9 @@ use App\Http\Controllers\RequestAssignment\PbgTaskController;
|
|||||||
use App\Http\Controllers\Settings\SettingsController;
|
use App\Http\Controllers\Settings\SettingsController;
|
||||||
use App\Http\Controllers\Settings\SyncronizeController;
|
use App\Http\Controllers\Settings\SyncronizeController;
|
||||||
use App\Http\Controllers\Data\AdvertisementController;
|
use App\Http\Controllers\Data\AdvertisementController;
|
||||||
|
use App\Http\Controllers\Data\UmkmController;
|
||||||
|
use App\Http\Controllers\Data\TourismController;
|
||||||
|
use App\Http\Controllers\Report\ReportTourismController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
require __DIR__ . '/auth.php';
|
require __DIR__ . '/auth.php';
|
||||||
@@ -49,5 +52,24 @@ Route::group(['middleware' => 'auth'], function(){
|
|||||||
// Rute khusus untuk create dan bulk-create
|
// Rute khusus untuk create dan bulk-create
|
||||||
Route::get('/advertisements/create', [AdvertisementController::class, 'create'])->name('advertisements.create');
|
Route::get('/advertisements/create', [AdvertisementController::class, 'create'])->name('advertisements.create');
|
||||||
Route::get('/advertisements/bulk-create', [AdvertisementController::class, 'bulkCreate'])->name('advertisements.bulk-create');
|
Route::get('/advertisements/bulk-create', [AdvertisementController::class, 'bulkCreate'])->name('advertisements.bulk-create');
|
||||||
|
|
||||||
|
// Resource route, kecuali create karena dibuat terpisah
|
||||||
|
Route::resource('/umkm', UmkmController::class)->except(['create', 'show']);
|
||||||
|
|
||||||
|
// Rute khusus untuk create dan bulk-create
|
||||||
|
Route::get('/umkm/create', [UmkmController::class, 'create'])->name('umkm.create');
|
||||||
|
Route::get('/umkm/bulk-create', [UmkmController::class, 'bulkCreate'])->name('umkm.bulk-create');
|
||||||
|
|
||||||
|
// Resource route, kecuali create karena dibuat terpisah
|
||||||
|
Route::resource('/tourisms', TourismController::class)->except(['create', 'show']);
|
||||||
|
// Rute khusus untuk create dan bulk-create
|
||||||
|
Route::get('/tourisms/create', [TourismController::class, 'create'])->name('tourisms.create');
|
||||||
|
Route::get('/tourisms/bulk-create', [TourismController::class, 'bulkCreate'])->name('tourisms.bulk-create');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Report
|
||||||
|
Route::group(['prefix' => '/report'], function(){
|
||||||
|
// Resource route, kecuali create karena dibuat terpisah
|
||||||
|
Route::resource('/tourisms', ReportTourismController::class);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user