create update tourisms

This commit is contained in:
arifal
2025-02-18 02:45:39 +07:00
parent aff31e08ef
commit 1dd971fb73
16 changed files with 3233 additions and 2982 deletions

View File

@@ -199,7 +199,7 @@ class AdvertisementController extends Controller
public function downloadExcelAdvertisement() public function downloadExcelAdvertisement()
{ {
$filePath = storage_path('app/public/templateFile/template_reklame.xlsx'); $filePath = storage_path('app/public/templates/template_reklame.xlsx');
// Cek apakah file ada // Cek apakah file ada
if (!file_exists($filePath)) { if (!file_exists($filePath)) {

View File

@@ -56,7 +56,14 @@ class TourismController extends Controller
*/ */
public function store(TourismRequest $request): Tourism public function store(TourismRequest $request): Tourism
{ {
return Tourism::create($request->validated()); info($request);
$data = $request->validated();
$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');
$data['district_code'] = $district_code;
$data['village_code'] = $village_code;
return Tourism::create($data);
} }
/** /**

View File

@@ -176,7 +176,7 @@ class UmkmController extends Controller
public function downloadExcelUmkm() public function downloadExcelUmkm()
{ {
$filePath = storage_path('app/public/templateFile/template_umkm.xlsx'); $filePath = storage_path('app/public/templates/template_umkm.xlsx');
// Cek apakah file ada // Cek apakah file ada
if (!file_exists($filePath)) { if (!file_exists($filePath)) {

View File

@@ -38,6 +38,7 @@ class TourismController extends Controller
'village_name' => DB::table('villages')->orderBy('village_name')->pluck('village_name', 'village_code'), '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'), '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'), 'business_type_id' => DB::table('business_type')->orderBy('business_type')->pluck('business_type', 'id'),
'business_scale_id' => DB::table('business_scale')->orderBy('business_scale')->pluck('business_scale', 'id'),
]; ];
$fields = $this->getFields(); $fields = $this->getFields();
@@ -90,6 +91,7 @@ class TourismController extends Controller
{ {
return [ return [
"business_name" => "Nama Usaha", "business_name" => "Nama Usaha",
"business_form" => "Bentuk Usaha",
"project_name" => "Nama Project", "project_name" => "Nama Project",
"business_address" => "Alamat Usaha", "business_address" => "Alamat Usaha",
"district_name" => "Kecamatan", "district_name" => "Kecamatan",
@@ -98,6 +100,13 @@ class TourismController extends Controller
"investment_amount" => "Jumlah Investasi", "investment_amount" => "Jumlah Investasi",
"number_of_employee" => "TKI", "number_of_employee" => "TKI",
"business_type_id" => "Jenis Usaha", "business_type_id" => "Jenis Usaha",
"project_id" => "Priject ID",
"nib" => "NIB",
"jenis_proyek" => "Jenis Proyek",
"status_penanaman_modal" => "Status Penanaman Modal",
"uraian_resiko_proyek" => "Uraian Resiko Proyek",
"business_scale_id" => "Skala Bisnis/Usaha",
"terbit_oss" => "Terbit OSS",
]; ];
} }
@@ -105,6 +114,7 @@ class TourismController extends Controller
{ {
return [ return [
"business_name" => "text", "business_name" => "text",
"business_form" => "text",
"project_name" => "text", "project_name" => "text",
"business_address" => "textarea", "business_address" => "textarea",
"district_name" => "combobox", "district_name" => "combobox",
@@ -113,6 +123,13 @@ class TourismController extends Controller
"investment_amount" => "text", "investment_amount" => "text",
"number_of_employee" => "text", "number_of_employee" => "text",
"business_type_id" => "select", "business_type_id" => "select",
"project_id" => "text",
"nib" => "text",
"jenis_proyek" => "text",
"status_penanaman_modal" => "text",
"uraian_resiko_proyek" => "text",
"business_scale_id" => "select",
"terbit_oss" => "date"
]; ];
} }
} }

View File

@@ -22,20 +22,23 @@ class TourismRequest extends FormRequest
public function rules(): array public function rules(): array
{ {
return [ return [
'jenis_proyek' => 'string', 'jenis_proyek' => 'required|string',
'nib' => 'string', 'nib' => 'string',
'business_name' => 'required|string', 'business_name' => 'required|string',
'status_penanaman_modal' => 'string', 'status_penanaman_modal' => 'string',
'business_form' => 'string', 'business_form' => 'string',
'uraian_resiko_proyek' => 'string', 'uraian_resiko_proyek' => 'string',
'project_name' => 'required|string', 'project_name' => 'required|string',
'project_id' => 'required|string',
'business_address' => 'required|string', 'business_address' => 'required|string',
'district_code' => 'required|string', 'district_name' => 'required|string',
'village_code' => 'required|string', 'village_name' => 'required|string',
'land_area' => 'required|string', 'land_area' => 'required|string',
'investment_amount' => 'required|string', 'investment_amount' => 'required|string',
'number_of_employee' => 'required|string', 'number_of_employee' => 'required|string',
'business_type_id' => 'required|string', 'business_type_id' => 'required|string',
'terbit_oss' => 'required|date',
'business_scale_id' => 'required',
]; ];
} }
} }

View File

@@ -67,6 +67,13 @@ class UsersRoleMenuSeeder extends Seeder
"icon" => "mingcute:task-line", "icon" => "mingcute:task-line",
"parent_id" => null, "parent_id" => null,
"sort_order" => 5, "sort_order" => 5,
],
[
"name" => "Laporan",
"url" => "/laporan",
"icon" => "mingcute:task-line",
"parent_id" => null,
"sort_order" => 6,
] ]
]; ];
@@ -84,6 +91,7 @@ class UsersRoleMenuSeeder extends Seeder
$settings = Menu::where('name', 'Settings')->first(); $settings = Menu::where('name', 'Settings')->first();
$dataSettings = Menu::where('name', 'Data Settings')->first(); $dataSettings = Menu::where('name', 'Data Settings')->first();
$data = Menu::where('name', 'Data')->first(); $data = Menu::where('name', 'Data')->first();
$laporan = Menu::where('name', 'Laporan')->first();
// create children menu // create children menu
$children_menus = [ $children_menus = [
@@ -155,7 +163,28 @@ class UsersRoleMenuSeeder extends Seeder
"url" => "business-industries.index", "url" => "business-industries.index",
"icon" => null, "icon" => null,
"parent_id" => $data->id, "parent_id" => $data->id,
"sort_order" => 2, "sort_order" => 3,
],
[
"name" => "UMKM",
"url" => "umkm.index",
"icon" => null,
"parent_id" => $data->id,
"sort_order" => 4,
],
[
"name" => "Pariwisata",
"url" => "tourisms.index",
"icon" => null,
"parent_id" => $data->id,
"sort_order" => 5,
],
[
"name" => "Lap Pariwisata",
"url" => "tourisms.index",
"icon" => null,
"parent_id" => $laporan->id,
"sort_order" => 1,
], ],
]; ];
@@ -173,6 +202,9 @@ class UsersRoleMenuSeeder extends Seeder
$setting_pbg = Menu::where('name', 'PBG')->first(); $setting_pbg = Menu::where('name', 'PBG')->first();
$reklame = Menu::where('name', 'Reklame')->first(); $reklame = Menu::where('name', 'Reklame')->first();
$businessIndustries = Menu::where('name', 'Usaha atau Industri')->first(); $businessIndustries = Menu::where('name', 'Usaha atau Industri')->first();
$pariwisata = Menu::where('name', 'Pariwisata')->first();
$laporan_pariwisata = Menu::where('name', 'Lap Pariwisata')->first();
$umkm = Menu::where('name', 'UMKM')->first();
// Superadmin gets all menus // Superadmin gets all menus
$superadmin->menus()->sync([ $superadmin->menus()->sync([
@@ -182,6 +214,7 @@ class UsersRoleMenuSeeder extends Seeder
$settings->id => ["allow_show" => true, "allow_create" => false, "allow_update" => false, "allow_destroy" => false], $settings->id => ["allow_show" => true, "allow_create" => false, "allow_update" => false, "allow_destroy" => false],
$dataSettings->id => ["allow_show" => true, "allow_create" => false, "allow_update" => false, "allow_destroy" => false], $dataSettings->id => ["allow_show" => true, "allow_create" => false, "allow_update" => false, "allow_destroy" => false],
$data->id => ["allow_show" => true, "allow_create" => false, "allow_update" => false, "allow_destroy" => false], $data->id => ["allow_show" => true, "allow_create" => false, "allow_update" => false, "allow_destroy" => false],
$laporan->id => ["allow_show" => true, "allow_create" => false, "allow_update" => false, "allow_destroy" => false],
// children // children
$dashboard_pimpinan->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true], $dashboard_pimpinan->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
$dashboard_pbg->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true], $dashboard_pbg->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
@@ -193,6 +226,9 @@ class UsersRoleMenuSeeder extends Seeder
$setting_pbg->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true], $setting_pbg->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
$reklame->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true], $reklame->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
$businessIndustries->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true], $businessIndustries->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
$pariwisata->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
$laporan_pariwisata->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
$umkm->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
]); ]);
// Admin gets limited menus // Admin gets limited menus

63
package-lock.json generated
View File

@@ -6,6 +6,7 @@
"": { "": {
"dependencies": { "dependencies": {
"apexcharts": "^3.44.2", "apexcharts": "^3.44.2",
"big.js": "^6.2.2",
"bootstrap": "^5.3.3", "bootstrap": "^5.3.3",
"countup.js": "^2.3.2", "countup.js": "^2.3.2",
"dropzone": "^5.9.0", "dropzone": "^5.9.0",
@@ -60,22 +61,6 @@
"node": ">=12" "node": ">=12"
} }
}, },
"node_modules/@esbuild/win32-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz",
"integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@iconify/types": { "node_modules/@iconify/types": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz",
@@ -262,26 +247,6 @@
"url": "https://opencollective.com/parcel" "url": "https://opencollective.com/parcel"
} }
}, },
"node_modules/@parcel/watcher-win32-x64": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.0.tgz",
"integrity": "sha512-lPrxve92zEHdgeff3aiu4gDOIt4u7sJYha6wbdEZDCDUhtjTsOMiaJzG5lMY4GkWH8p0fMmO2Ppq5G5XXG+DQw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@pkgjs/parseargs": { "node_modules/@pkgjs/parseargs": {
"version": "0.11.0", "version": "0.11.0",
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
@@ -328,19 +293,6 @@
"linux" "linux"
] ]
}, },
"node_modules/@rollup/rollup-win32-x64-msvc": {
"version": "4.28.0",
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.28.0.tgz",
"integrity": "sha512-Bvno2/aZT6usSa7lRDL2+hMjVAGjuqaymF1ApZm31JXzniR/hvr14jpU+/z4X6Gt5BPlzosscyJZGUvguXIqeQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
]
},
"node_modules/@types/estree": { "node_modules/@types/estree": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",
@@ -478,6 +430,19 @@
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true "dev": true
}, },
"node_modules/big.js": {
"version": "6.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-6.2.2.tgz",
"integrity": "sha512-y/ie+Faknx7sZA5MfGA2xKlu0GDv8RWrXGsmlteyJQ2lvoKv9GBK/fpRMc2qlSoBAgNxrixICFCBefIq8WCQpQ==",
"license": "MIT",
"engines": {
"node": "*"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/bigjs"
}
},
"node_modules/binary-extensions": { "node_modules/binary-extensions": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",

View File

@@ -17,6 +17,7 @@
}, },
"dependencies": { "dependencies": {
"apexcharts": "^3.44.2", "apexcharts": "^3.44.2",
"big.js": "^6.2.2",
"bootstrap": "^5.3.3", "bootstrap": "^5.3.3",
"countup.js": "^2.3.2", "countup.js": "^2.3.2",
"dropzone": "^5.9.0", "dropzone": "^5.9.0",

View File

@@ -95,6 +95,33 @@
"__commonjsHelpers-C4iS2aBk.js" "__commonjsHelpers-C4iS2aBk.js"
] ]
}, },
"resources/js/business-industries/create.js": {
"file": "assets/create-CiRhiWZV.js",
"name": "create",
"src": "resources/js/business-industries/create.js",
"isEntry": true,
"imports": [
"_dropzone-B5tMhgFp.js",
"_global-config-9uDKFQ8j.js"
]
},
"resources/js/business-industries/index.js": {
"file": "assets/index-BIXijOG8.js",
"name": "index",
"src": "resources/js/business-industries/index.js",
"isEntry": true,
"imports": [
"_gridjs.umd-BiCNXlqL.js",
"_global-config-9uDKFQ8j.js",
"__commonjsHelpers-C4iS2aBk.js"
]
},
"resources/js/business-industries/update.js": {
"file": "assets/update-C8VOvIbF.js",
"name": "update",
"src": "resources/js/business-industries/update.js",
"isEntry": true
},
"resources/js/config.js": { "resources/js/config.js": {
"file": "assets/config-DqV4EBmE.js", "file": "assets/config-DqV4EBmE.js",
"name": "config", "name": "config",
@@ -120,7 +147,7 @@
"isEntry": true "isEntry": true
}, },
"resources/js/data-settings/index.js": { "resources/js/data-settings/index.js": {
"file": "assets/index-BOfsbw53.js", "file": "assets/index-C4raIbBK.js",
"name": "index", "name": "index",
"src": "resources/js/data-settings/index.js", "src": "resources/js/data-settings/index.js",
"isEntry": true, "isEntry": true,
@@ -137,7 +164,7 @@
"isEntry": true "isEntry": true
}, },
"resources/js/data/advertisements/data-advertisements.js": { "resources/js/data/advertisements/data-advertisements.js": {
"file": "assets/data-advertisements-C_ZfB4RA.js", "file": "assets/data-advertisements-oslZaKHh.js",
"name": "data-advertisements", "name": "data-advertisements",
"src": "resources/js/data/advertisements/data-advertisements.js", "src": "resources/js/data/advertisements/data-advertisements.js",
"isEntry": true, "isEntry": true,
@@ -157,16 +184,17 @@
] ]
}, },
"resources/js/data/advertisements/form-upload.js": { "resources/js/data/advertisements/form-upload.js": {
"file": "assets/form-upload-Ci7Kyzc7.js", "file": "assets/form-upload-tA9zPESO.js",
"name": "form-upload", "name": "form-upload",
"src": "resources/js/data/advertisements/form-upload.js", "src": "resources/js/data/advertisements/form-upload.js",
"isEntry": true, "isEntry": true,
"imports": [ "imports": [
"_dropzone-B5tMhgFp.js" "_dropzone-B5tMhgFp.js",
"_global-config-9uDKFQ8j.js"
] ]
}, },
"resources/js/master/users/create.js": { "resources/js/master/users/create.js": {
"file": "assets/create-RO4xgm-f.js", "file": "assets/create-BfiYISiN.js",
"name": "create", "name": "create",
"src": "resources/js/master/users/create.js", "src": "resources/js/master/users/create.js",
"isEntry": true "isEntry": true
@@ -401,7 +429,7 @@
"isEntry": true "isEntry": true
}, },
"resources/scss/style.scss": { "resources/scss/style.scss": {
"file": "assets/style-H92i7DXd.css", "file": "assets/style-vmU-kDl3.css",
"src": "resources/scss/style.scss", "src": "resources/scss/style.scss",
"isEntry": true "isEntry": true
} }

Binary file not shown.

Binary file not shown.

View File

@@ -4,7 +4,6 @@ import "gridjs/dist/gridjs.umd.js";
import GlobalConfig from "../../global-config.js"; import GlobalConfig from "../../global-config.js";
import GeneralTable from "../../table-generator.js"; import GeneralTable from "../../table-generator.js";
const dataTourismsColumns = [ const dataTourismsColumns = [
"Proyek ID", "Proyek ID",
"Jenis Proyek", "Jenis Proyek",
@@ -39,8 +38,8 @@ const dataTourismsColumns = [
<i class='bx bxs-trash' ></i></button> <i class='bx bxs-trash' ></i></button>
</div> </div>
`); `);
} },
} },
]; ];
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
@@ -55,13 +54,13 @@ document.addEventListener("DOMContentLoaded", () => {
return data.data.map((item) => { return data.data.map((item) => {
return [ return [
item.project_id, item.project_id,
item.jenis_project, item.jenis_proyek,
item.nib, item.nib,
item.business_name, item.business_name,
item.terbit_oss, item.terbit_oss,
item.status_penanaman_modal, item.status_penanaman_modal,
item.business_form, item.business_form,
item.uraian_resiko_project, item.uraian_resiko_proyek,
item.project_name, item.project_name,
item.business_address, item.business_address,
item.district_name, item.district_name,
@@ -76,4 +75,4 @@ document.addEventListener("DOMContentLoaded", () => {
}; };
table.init(); table.init();
}) });

View File

@@ -0,0 +1,193 @@
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/tourisms";
}, 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();
});
});

View File

@@ -63,6 +63,8 @@
<input class="form-control" list="{{ $field }}Options" id="{{ $field }}" name="{{ $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 }}')"> value="{{ old($field, isset($modelInstance) ? $modelInstance->{$field} : '') }}" placeholder="Type to search..." oninput="fetchOptions('{{ $field }}')">
<datalist id="{{ $field }}Options"></datalist> <datalist id="{{ $field }}Options"></datalist>
@elseif($fieldType == 'date')
<input type="date" id="{{ $field }}" name="{{ $field }}" class="form-control" value="{{ old($field, isset($modelInstance) ? $modelInstance->{$field} : '') }}">
@else @else
<input type="{{ $fieldType }}" id="{{ $field }}" name="{{ $field }}" class="form-control" value="{{ old($field, isset($modelInstance) ? $modelInstance->{$field} : '') }}"> <input type="{{ $fieldType }}" id="{{ $field }}" name="{{ $field }}" class="form-control" value="{{ old($field, isset($modelInstance) ? $modelInstance->{$field} : '') }}">
@endif @endif
@@ -123,5 +125,5 @@
@endsection @endsection
@section('scripts') @section('scripts')
@vite(['resources/js/data/umkm/form-create-update.js']) @vite(['resources/js/data/tourisms/form-create-update.js'])
@endsection @endsection

View File

@@ -77,5 +77,5 @@
@endsection @endsection
@section('scripts') @section('scripts')
@vite(['resources/roles/role_menu.js']) @vite(['resources/js/roles/role_menu.js'])
@endsection @endsection

View File

@@ -85,6 +85,6 @@ Route::group(['middleware' => 'auth'], function(){
// Report // Report
Route::group(['prefix' => '/report'], function(){ Route::group(['prefix' => '/report'], function(){
// Resource route, kecuali create karena dibuat terpisah // Resource route, kecuali create karena dibuat terpisah
Route::resource('/tourisms', ReportTourismController::class); Route::resource('/tourisms-report', ReportTourismController::class);
}); });
}); });