diff --git a/app/Exports/KeuanganExport.php b/app/Exports/KeuanganExport.php new file mode 100644 index 0000000..eb8c49a --- /dev/null +++ b/app/Exports/KeuanganExport.php @@ -0,0 +1,25 @@ + $this->collection() + ]); + } +} diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 55b3538..f0052b4 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -4,11 +4,23 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; +use App\Models\Keuangan; class HomeController extends Controller { public function index(){ - return view('dashboard.index'); + $total_uang = Keuangan::where('tipe','in')->sum('jumlah') - Keuangan::where('tipe','out')->sum('jumlah'); + $total_uang_tabungan = Keuangan::where('tipe','in')->where('tabungan_id','!=','null')->sum('jumlah') - Keuangan::where('tipe','out')->where('tabungan_id','!=','null')->sum('jumlah'); + $total_uang_spp = Keuangan::where('tipe','in')->where('transaksi_id','!=','null')->sum('jumlah') - Keuangan::where('tipe','out')->where('transaksi_id','!=','null')->sum('jumlah');; + $total_uang_masuk = Keuangan::where('tipe','in')->sum('jumlah'); + $total_uang_keluar = Keuangan::where('tipe','out')->sum('jumlah'); + return view('dashboard.index',[ + 'total_uang' => $total_uang, + 'total_uang_tabungan' => $total_uang_tabungan, + 'total_uang_spp' => $total_uang_spp, + 'total_uang_masuk' => $total_uang_masuk, + 'total_uang_keluar' => $total_uang_keluar, + ]); } public function pengaturan(){ diff --git a/app/Http/Controllers/KeuanganController.php b/app/Http/Controllers/KeuanganController.php new file mode 100644 index 0000000..d746512 --- /dev/null +++ b/app/Http/Controllers/KeuanganController.php @@ -0,0 +1,68 @@ +paginate(10); + return view('keuangan.index', [ + 'keuangan' => $keuangan, + + ]); + } + + public function store(Request $request) + { + $request->validate([ + 'keperluan' => 'required|in:in,out', + 'jumlah' => 'required|numeric', + 'keterangan' => 'nullable', + ]); + + $keuangan = Keuangan::orderBy('created_at','desc')->first(); + if($keuangan != null){ + $simpan = Keuangan::make([ + 'tipe' => $request->keperluan, + 'jumlah' => $request->jumlah, + 'keterangan' => $request->keterangan + ]); + if($request->keperluan == 'in'){ + $simpan->total_kas = $keuangan->total_kas + $request->jumlah; + }else if($request->keperluan == 'out'){ + $simpan->total_kas = $keuangan->total_kas - $request->jumlah; + } + }else{ + $simpan = Keuangan::make([ + 'tipe' => $request->keperluan, + 'jumlah' => $request->jumlah, + 'keterangan' => $request->keterangan + ]); + $simpan->total_kas = $request->jumlah; + } + + if($simpan->save()){ + return redirect()->route('keuangan.index')->with([ + 'type' => 'success', + 'msg' => 'Pencatatan Keuangan dibuat' + ]); + }else{ + return redirect()->route('keuangan.index')->with([ + 'type' => 'danger', + 'msg' => 'Terjadi Kesalahan' + ]); + } + + } + + public function export() + { + return Excel::download(new KeuanganExport, 'mutasi_keuangan-'.now().'.xlsx'); + } +} diff --git a/resources/views/dashboard/index.blade.php b/resources/views/dashboard/index.blade.php index b95c4fc..bd62f3e 100644 --- a/resources/views/dashboard/index.blade.php +++ b/resources/views/dashboard/index.blade.php @@ -10,6 +10,46 @@
+
+
+
+
IDR {{ format_idr($total_uang) }}
+
Total Uang
+
+
+
+
+
+
+
IDR {{ format_idr($total_uang_tabungan) }}
+
Total Uang Tabungan
+
+
+
+
+
+
+
IDR {{ format_idr($total_uang_spp) }}
+
Total Uang SPP
+
+
+
+
+
+
+
IDR {{ format_idr($total_uang_keluar) }}
+
Total Uang Keluar
+
+
+
+
+
+
+
IDR {{ format_idr($total_uang_masuk) }}
+
Total Uang Masuk
+
+
+
diff --git a/resources/views/keuangan/export.blade.php b/resources/views/keuangan/export.blade.php new file mode 100644 index 0000000..7ed46ea --- /dev/null +++ b/resources/views/keuangan/export.blade.php @@ -0,0 +1,20 @@ + + + + + + + + + + + @foreach($keuangan as $item) + + + + + + + @endforeach + +
TanggalKDJumlahKeterangan
{{ $item->created_at->format('d-m-Y') }}{{ ($item->tipe == 'in') ? 'Pemasukan' : 'Pengeluaran' }}{{ $item->jumlah }}{{ $item->keterangan }}
\ No newline at end of file diff --git a/resources/views/keuangan/index.blade.php b/resources/views/keuangan/index.blade.php new file mode 100644 index 0000000..31e08cf --- /dev/null +++ b/resources/views/keuangan/index.blade.php @@ -0,0 +1,134 @@ +@extends('layouts.app') + +@section('page-name','Keuangan') + +@section('content') + +
+
+
+
+

Transaksi

+
+ @if(session()->has('msg')) +
+ @if(session()->get('type') == 'success') + + @else + + @endif + {{ session()->get('msg') }} +
+ @endif +
+
+ @if($errors->any()) +
+ @foreach($errors->all() as $error) + {{ $error }}
+ @endforeach +
+ @endif +
+
+ @csrf +
+ +
+ + +
+
+ + +
+
+
+ +
+
+
+
+
+
+
+
+

Mutasi Keuangan

+
+ Export +
+
+
+ + + + + + + + + + + + @foreach ($keuangan as $index => $item) + + + + + + + + @endforeach + +
No.TanggalKDKeteranganJumlah
{{ $index+1 }}{{ $item->created_at->format('d-m-Y') }} + @if($item->tipe == 'in') + Uang Masuk + @elseif($item->tipe == 'out') + Uang Keluar + @endif + {{ $item->keterangan }}IDR. {{ format_idr($item->jumlah) }}
+
+ +
+
+
+@endsection +@section('js') + +@endsection \ No newline at end of file diff --git a/resources/views/shared/navbar.blade.php b/resources/views/shared/navbar.blade.php index eecafa3..291ed90 100644 --- a/resources/views/shared/navbar.blade.php +++ b/resources/views/shared/navbar.blade.php @@ -4,8 +4,8 @@