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
+
+
+