diff --git a/app/Exports/BranchExport.php b/app/Exports/BranchExport.php
new file mode 100644
index 0000000..fdf70d1
--- /dev/null
+++ b/app/Exports/BranchExport.php
@@ -0,0 +1,49 @@
+id,
+ $row->code,
+ $row->name,
+ $row->created_at
+ ];
+ }
+
+ public function headings()
+ : array
+ {
+ return [
+ 'ID',
+ 'Code',
+ 'Name',
+ 'Created At'
+ ];
+ }
+
+ public function columnFormats()
+ : array
+ {
+ return [
+ 'A' => NumberFormat::FORMAT_NUMBER,
+ 'D' => NumberFormat::FORMAT_DATE_DATETIME
+ ];
+ }
+ }
diff --git a/app/Exports/CurrencyExport.php b/app/Exports/CurrencyExport.php
new file mode 100644
index 0000000..3492a67
--- /dev/null
+++ b/app/Exports/CurrencyExport.php
@@ -0,0 +1,54 @@
+id,
+ $row->code,
+ $row->name,
+ $row->decimal_places,
+ $row->updated_at,
+ $row->deleted_at,
+ $row->created_at
+ ];
+ }
+
+ public function headings()
+ : array
+ {
+ return [
+ 'ID',
+ 'Code',
+ 'Name',
+ 'Decimal Places',
+ 'Created At'
+ ];
+ }
+
+ public function columnFormats()
+ : array
+ {
+ return [
+ 'A' => NumberFormat::FORMAT_NUMBER,
+ 'B' => NumberFormat::FORMAT_NUMBER,
+ 'E' => NumberFormat::FORMAT_DATE_DATETIME
+ ];
+ }
+ }
diff --git a/app/Http/Controllers/BranchController.php b/app/Http/Controllers/BranchController.php
new file mode 100644
index 0000000..49af366
--- /dev/null
+++ b/app/Http/Controllers/BranchController.php
@@ -0,0 +1,150 @@
+validated();
+
+ if ($validate) {
+ try {
+ // Save to database
+ Branch::create($validate);
+ return redirect()
+ ->route('basicdata.branch.index')
+ ->with('success', 'Branch created successfully');
+ } catch (Exception $e) {
+ return redirect()
+ ->route('basicdata.branch.create')
+ ->with('error', 'Failed to create branch');
+ }
+ }
+ }
+
+ public function create()
+ {
+ return view('basicdata::branch.create');
+ }
+
+ public function edit($id)
+ {
+ $branch = Branch::find($id);
+ return view('basicdata::branch.create', compact('branch'));
+ }
+
+ public function update(BranchRequest $request, $id)
+ {
+ $validate = $request->validated();
+
+ if ($validate) {
+ try {
+ // Update in database
+ $branch = Branch::find($id);
+ $branch->update($validate);
+ return redirect()
+ ->route('basicdata.branch.index')
+ ->with('success', 'Branch updated successfully');
+ } catch (Exception $e) {
+ return redirect()
+ ->route('basicdata.branch.edit', $id)
+ ->with('error', 'Failed to update branch');
+ }
+ }
+ }
+
+ public function destroy($id)
+ {
+ try {
+ // Delete from database
+ $branch = Branch::find($id);
+ $branch->delete();
+
+ echo json_encode(['success' => true, 'message' => 'Branch deleted successfully']);
+ } catch (Exception $e) {
+ echo json_encode(['success' => false, 'message' => 'Failed to delete branch']);
+ }
+ }
+
+ public function dataForDatatables(Request $request)
+ {
+ if (is_null($this->user) || !$this->user->can('branch.view')) {
+ //abort(403, 'Sorry! You are not allowed to view users.');
+ }
+
+ // Retrieve data from the database
+ $query = Branch::query();
+
+ // Apply search filter if provided
+ if ($request->has('search') && !empty($request->get('search'))) {
+ $search = $request->get('search');
+ $query->where(function ($q) use ($search) {
+ $q->where('code', 'LIKE', "%$search%");
+ $q->orWhere('name', 'LIKE', "%$search%");
+ });
+ }
+
+ // Apply sorting if provided
+ if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
+ $order = $request->get('sortOrder');
+ $column = $request->get('sortField');
+ $query->orderBy($column, $order);
+ }
+
+ // Get the total count of records
+ $totalRecords = $query->count();
+
+ // Apply pagination if provided
+ if ($request->has('page') && $request->has('size')) {
+ $page = $request->get('page');
+ $size = $request->get('size');
+ $offset = ($page - 1) * $size; // Calculate the offset
+
+ $query->skip($offset)->take($size);
+ }
+
+ // Get the filtered count of records
+ $filteredRecords = $query->count();
+
+ // Get the data for the current page
+ $data = $query->get();
+
+ // Calculate the page count
+ $pageCount = ceil($totalRecords / $request->get('size'));
+
+ // Calculate the current page number
+ $currentPage = 0 + 1;
+
+ // Return the response data as a JSON object
+ return response()->json([
+ 'draw' => $request->get('draw'),
+ 'recordsTotal' => $totalRecords,
+ 'recordsFiltered' => $filteredRecords,
+ 'pageCount' => $pageCount,
+ 'page' => $currentPage,
+ 'totalCount' => $totalRecords,
+ 'data' => $data,
+ ]);
+ }
+
+ public function export()
+ {
+ return Excel::download(new BranchExport, 'branch.xlsx');
+ }
+ }
diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php
new file mode 100644
index 0000000..f93b258
--- /dev/null
+++ b/app/Http/Controllers/CurrencyController.php
@@ -0,0 +1,150 @@
+validated();
+
+ if ($validate) {
+ try {
+ // Save to database
+ Currency::create($validate);
+ return redirect()
+ ->route('basicdata.currency.index')
+ ->with('success', 'Currency created successfully');
+ } catch (Exception $e) {
+ return redirect()
+ ->route('basicdata.currency.create')
+ ->with('error', 'Failed to create currency');
+ }
+ }
+ }
+
+ public function create()
+ {
+ return view('basicdata::currency.create');
+ }
+
+ public function edit($id)
+ {
+ $currency = Currency::find($id);
+ return view('basicdata::currency.create', compact('currency'));
+ }
+
+ public function update(CurrencyRequest $request, $id)
+ {
+ $validate = $request->validated();
+
+ if ($validate) {
+ try {
+ // Update in database
+ $currency = Currency::find($id);
+ $currency->update($validate);
+ return redirect()
+ ->route('basicdata.currency.index')
+ ->with('success', 'Currency updated successfully');
+ } catch (Exception $e) {
+ return redirect()
+ ->route('basicdata.currency.edit', $id)
+ ->with('error', 'Failed to update currency');
+ }
+ }
+ }
+
+ public function destroy($id)
+ {
+ try {
+ // Delete from database
+ $currency = Currency::find($id);
+ $currency->delete();
+
+ echo json_encode(['success' => true, 'message' => 'Currency deleted successfully']);
+ } catch (Exception $e) {
+ echo json_encode(['success' => false, 'message' => 'Failed to delete currency']);
+ }
+ }
+
+ public function dataForDatatables(Request $request)
+ {
+ if (is_null($this->user) || !$this->user->can('currency.view')) {
+ //abort(403, 'Sorry! You are not allowed to view users.');
+ }
+
+ // Retrieve data from the database
+ $query = Currency::query();
+
+ // Apply search filter if provided
+ if ($request->has('search') && !empty($request->get('search'))) {
+ $search = $request->get('search');
+ $query->where(function ($q) use ($search) {
+ $q->where('code', 'LIKE', "%$search%");
+ $q->orWhere('name', 'LIKE', "%$search%");
+ });
+ }
+
+ // Apply sorting if provided
+ if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
+ $order = $request->get('sortOrder');
+ $column = $request->get('sortField');
+ $query->orderBy($column, $order);
+ }
+
+ // Get the total count of records
+ $totalRecords = $query->count();
+
+ // Apply pagination if provided
+ if ($request->has('page') && $request->has('size')) {
+ $page = $request->get('page');
+ $size = $request->get('size');
+ $offset = ($page - 1) * $size; // Calculate the offset
+
+ $query->skip($offset)->take($size);
+ }
+
+ // Get the filtered count of records
+ $filteredRecords = $query->count();
+
+ // Get the data for the current page
+ $data = $query->get();
+
+ // Calculate the page count
+ $pageCount = ceil($totalRecords / $request->get('size'));
+
+ // Calculate the current page number
+ $currentPage = 0 + 1;
+
+ // Return the response data as a JSON object
+ return response()->json([
+ 'draw' => $request->get('draw'),
+ 'recordsTotal' => $totalRecords,
+ 'recordsFiltered' => $filteredRecords,
+ 'pageCount' => $pageCount,
+ 'page' => $currentPage,
+ 'totalCount' => $totalRecords,
+ 'data' => $data,
+ ]);
+ }
+
+ public function export()
+ {
+ return Excel::download(new CurrencyExport, 'currency.xlsx');
+ }
+ }
diff --git a/app/Http/Requests/BranchRequest.php b/app/Http/Requests/BranchRequest.php
new file mode 100644
index 0000000..7cea8ee
--- /dev/null
+++ b/app/Http/Requests/BranchRequest.php
@@ -0,0 +1,40 @@
+ 'required|string|max:255',
+ 'status' => 'nullable|boolean',
+ 'authorized_at' => 'nullable|datetime',
+ 'authorized_status' => 'nullable|string|max:1',
+ 'authorized_by' => 'nullable|exists:users,id',
+ ];
+
+ if ($this->method() == 'PUT') {
+ $rules['code'] = 'required|string|max:3|unique:branches,code,' . $this->id;
+ } else {
+ $rules['code'] = 'required|string|max:3|unique:branches,code';
+ }
+
+ return $rules;
+ }
+
+ /**
+ * Determine if the user is authorized to make this request.
+ */
+ public function authorize()
+ : bool
+ {
+ return true;
+ }
+ }
diff --git a/app/Http/Requests/CurrencyRequest.php b/app/Http/Requests/CurrencyRequest.php
new file mode 100644
index 0000000..28236d3
--- /dev/null
+++ b/app/Http/Requests/CurrencyRequest.php
@@ -0,0 +1,41 @@
+ 'required|string|max:255',
+ 'decimal_places' => 'nullable|integer|between:0,3',
+ 'status' => 'nullable|boolean',
+ 'authorized_at' => 'nullable|datetime',
+ 'authorized_status' => 'nullable|string|max:1',
+ 'authorized_by' => 'nullable|exists:users,id',
+ ];
+
+ if ($this->method() == 'PUT') {
+ $rules['code'] = 'required|string|max:3|unique:currencies,code,' . $this->id;
+ } else {
+ $rules['code'] = 'required|string|max:3|unique:currencies,code';
+ }
+
+ return $rules;
+ }
+
+ /**
+ * Determine if the user is authorized to make this request.
+ */
+ public function authorize()
+ : bool
+ {
+ return true;
+ }
+ }
diff --git a/app/Models/Branch.php b/app/Models/Branch.php
new file mode 100644
index 0000000..6f0a771
--- /dev/null
+++ b/app/Models/Branch.php
@@ -0,0 +1,10 @@
+id();
+ $table->string('code', 9)->unique();
+ $table->string('name');
+ $table->boolean('status')->default(true)->nullable();
+ $table->timestamps();
+ $table->timestamp('authorized_at')->nullable();
+ $table->char('authorized_status', 1)->nullable();
+ $table->softDeletes();
+
+ $table->unsignedBigInteger('created_by')->nullable();
+ $table->unsignedBigInteger('updated_by')->nullable();
+ $table->unsignedBigInteger('deleted_by')->nullable();
+ $table->unsignedBigInteger('authorized_by')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down()
+ : void
+ {
+ Schema::dropIfExists('branches');
+ }
+ };
diff --git a/database/migrations/2024_08_12_024448_create_currencies_table.php b/database/migrations/2024_08_12_024448_create_currencies_table.php
new file mode 100644
index 0000000..ec92b59
--- /dev/null
+++ b/database/migrations/2024_08_12_024448_create_currencies_table.php
@@ -0,0 +1,40 @@
+id();
+ $table->string('code', 3)->unique();
+ $table->string('name');
+ $table->integer('decimal_places')->default(2);
+ $table->boolean('status')->default(true)->nullable();
+ $table->timestamps();
+ $table->timestamp('authorized_at')->nullable();
+ $table->char('authorized_status', 1)->nullable();
+ $table->softDeletes();
+
+ $table->unsignedBigInteger('created_by')->nullable();
+ $table->unsignedBigInteger('updated_by')->nullable();
+ $table->unsignedBigInteger('deleted_by')->nullable();
+ $table->unsignedBigInteger('authorized_by')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down()
+ : void
+ {
+ Schema::dropIfExists('currencies');
+ }
+ };
diff --git a/module.json b/module.json
index efea2b3..45ac5c9 100644
--- a/module.json
+++ b/module.json
@@ -11,7 +11,49 @@
"files": [],
"menu": {
"main": [],
- "master": [],
+ "master": [
+ {
+ "title": "Basic Data",
+ "path": "basicdata",
+ "icon": "ki-filled ki-category text-lg",
+ "classes": "",
+ "attributes": [],
+ "permission": "",
+ "roles": [
+ "administrator",
+ "pemohon-ao",
+ "pemohon-eo",
+ "admin",
+ "surveyor"
+ ],
+ "sub": [
+ {
+ "title": "Cabang",
+ "path": "basicdata.branch",
+ "classes": "",
+ "attributes": [],
+ "permission": "",
+ "roles": [
+ "administrator",
+ "pemohon-ao",
+ "pemohon-eo"
+ ]
+ },
+ {
+ "title": "Mata Uang",
+ "path": "basicdata.currency",
+ "classes": "",
+ "attributes": [],
+ "permission": "",
+ "roles": [
+ "administrator",
+ "pemohon-ao",
+ "pemohon-eo"
+ ]
+ }
+ ]
+ }
+ ],
"system": []
}
}
diff --git a/resources/views/branch/create.blade.php b/resources/views/branch/create.blade.php
new file mode 100644
index 0000000..f9cb3b7
--- /dev/null
+++ b/resources/views/branch/create.blade.php
@@ -0,0 +1,58 @@
+@extends('layouts.main')
+
+@section('breadcrumbs')
+ {{ Breadcrumbs::render(request()->route()->getName()) }}
+@endsection
+
+@section('content')
+
+ @if(isset($branch->id))
+
+
+@endsection
diff --git a/resources/views/branch/index.blade.php b/resources/views/branch/index.blade.php
new file mode 100644
index 0000000..ff5a9e5
--- /dev/null
+++ b/resources/views/branch/index.blade.php
@@ -0,0 +1,147 @@
+@extends('layouts.main')
+
+@section('breadcrumbs')
+ {{ Breadcrumbs::render('basicdata.branch') }}
+@endsection
+
+@section('content')
+
+@endsection
+
+@push('scripts')
+
+
+@endpush
+
diff --git a/resources/views/currency/create.blade.php b/resources/views/currency/create.blade.php
new file mode 100644
index 0000000..c8b8f03
--- /dev/null
+++ b/resources/views/currency/create.blade.php
@@ -0,0 +1,69 @@
+@extends('layouts.main')
+
+@section('breadcrumbs')
+ {{ Breadcrumbs::render(request()->route()->getName()) }}
+@endsection
+
+@section('content')
+
+ @if(isset($currency->id))
+
+
+@endsection
diff --git a/resources/views/currency/index.blade.php b/resources/views/currency/index.blade.php
new file mode 100644
index 0000000..b7be97f
--- /dev/null
+++ b/resources/views/currency/index.blade.php
@@ -0,0 +1,154 @@
+@extends('layouts.main')
+
+@section('breadcrumbs')
+ {{ Breadcrumbs::render('basicdata.currency') }}
+@endsection
+
+@section('content')
+
+@endsection
+
+@push('scripts')
+
+
+@endpush
+
diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php
new file mode 100644
index 0000000..f983f70
--- /dev/null
+++ b/routes/breadcrumbs.php
@@ -0,0 +1,39 @@
+push('Basic Data');
+});
+
+
+Breadcrumbs::for('basicdata.currency', function (BreadcrumbTrail $trail) {
+ $trail->parent('basicdata');
+ $trail->push('Mata Uang', route('basicdata.currency.index'));
+});
+
+Breadcrumbs::for('basicdata.currency.create', function (BreadcrumbTrail $trail) {
+ $trail->parent('basicdata.currency');
+ $trail->push('Tambah Mata Uang', route('basicdata.currency.create'));
+});
+
+Breadcrumbs::for('basicdata.currency.edit', function (BreadcrumbTrail $trail) {
+ $trail->parent('basicdata.currency');
+ $trail->push('Edit Mata Uang');
+});
+
+Breadcrumbs::for('basicdata.branch', function (BreadcrumbTrail $trail) {
+ $trail->parent('basicdata');
+ $trail->push('Cabang', route('basicdata.branch.index'));
+});
+
+Breadcrumbs::for('basicdata.branch.create', function (BreadcrumbTrail $trail) {
+ $trail->parent('basicdata.branch');
+ $trail->push('Tambah Cabang', route('basicdata.branch.create'));
+});
+
+Breadcrumbs::for('basicdata.branch.edit', function (BreadcrumbTrail $trail) {
+ $trail->parent('basicdata.branch');
+ $trail->push('Edit Cabang');
+});
diff --git a/routes/web.php b/routes/web.php
index ec6a846..859cc51 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,19 +1,44 @@
names('basicdata');
-});
+ Route::middleware(['auth'])->group(function () {
+ Route::name('basicdata.')->prefix('basic-data')->group(function () {
+ Route::name('currency.')->prefix('mata-uang')->group(function () {
+ Route::get('restore/{id}', [CurrencyController::class, 'restore'])->name('restore');
+ Route::get('datatables', [CurrencyController::class, 'dataForDatatables'])->name('datatables');
+ Route::get('export', [CurrencyController::class, 'export'])->name('export');
+ });
+
+ Route::name('branch.')->prefix('cabang')->group(function () {
+ Route::get('restore/{id}', [BranchController::class, 'restore'])->name('restore');
+ Route::get('datatables', [BranchController::class, 'dataForDatatables'])->name('datatables');
+ Route::get('export', [BranchController::class, 'export'])->name('export');
+ });
+
+ Route::resource('cabang', BranchController::class, [
+ 'names' => [
+ 'index' => 'branch.index',
+ 'show' => 'branch.show',
+ 'create' => 'branch.create',
+ 'store' => 'branch.store',
+ 'edit' => 'branch.edit',
+ 'update' => 'branch.update',
+ 'destroy' => 'branch.destroy',
+ ],
+ ]);
+ });
+ });