module keuangan

pull/1/head
Aji Kamaludin 5 years ago
parent fa65af44b5
commit b00f58bb46
No known key found for this signature in database
GPG Key ID: 23E2BDC458317AF8

@ -0,0 +1,25 @@
<?php
namespace App\Exports;
use App\Models\Keuangan;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
class KeuanganExport implements FromView
{
/**
* @return \Illuminate\Support\Collection
*/
public function collection()
{
return Keuangan::all();
}
public function view(): View
{
return view('keuangan.export', [
'keuangan' => $this->collection()
]);
}
}

@ -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(){

@ -0,0 +1,68 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Keuangan;
use App\Exports\KeuanganExport;
use Maatwebsite\Excel\Facades\Excel;
class KeuanganController extends Controller
{
public function index()
{
$keuangan = Keuangan::orderBy('created_at','desc')->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');
}
}

@ -10,6 +10,46 @@
</h1>
</div>
<div class="row">
<div class="col-6 col-sm-3 col-lg-3">
<div class="card">
<div class="card-body p-3 text-center">
<div class="h1 m-0">IDR {{ format_idr($total_uang) }}</div>
<div class="text-muted mb-4">Total Uang</div>
</div>
</div>
</div>
<div class="col-6 col-sm-3 col-lg-3">
<div class="card">
<div class="card-body p-3 text-center">
<div class="h1 m-0">IDR {{ format_idr($total_uang_tabungan) }}</div>
<div class="text-muted mb-4">Total Uang Tabungan</div>
</div>
</div>
</div>
<div class="col-6 col-sm-3 col-lg-3">
<div class="card">
<div class="card-body p-3 text-center">
<div class="h1 m-0">IDR {{ format_idr($total_uang_spp) }}</div>
<div class="text-muted mb-4">Total Uang SPP</div>
</div>
</div>
</div>
<div class="col-6 col-sm-3 col-lg-3">
<div class="card">
<div class="card-body p-3 text-center">
<div class="h1 m-0">IDR {{ format_idr($total_uang_keluar) }}</div>
<div class="text-muted mb-4">Total Uang Keluar</div>
</div>
</div>
</div>
<div class="col-6 col-sm-3 col-lg-3">
<div class="card">
<div class="card-body p-3 text-center">
<div class="h1 m-0">IDR {{ format_idr($total_uang_masuk) }}</div>
<div class="text-muted mb-4">Total Uang Masuk</div>
</div>
</div>
</div>
<div class="col-12">
<div class="card">
<div class="card-header">

@ -0,0 +1,20 @@
<table>
<thead>
<tr>
<th><b>Tanggal</b></th>
<th><b>KD</b></th>
<th><b>Jumlah</b></th>
<th><b>Keterangan</b></th>
</tr>
</thead>
<tbody>
@foreach($keuangan as $item)
<tr>
<td>{{ $item->created_at->format('d-m-Y') }}</td>
<td>{{ ($item->tipe == 'in') ? 'Pemasukan' : 'Pengeluaran' }}</td>
<td>{{ $item->jumlah }}</td>
<td>{{ $item->keterangan }}</td>
</tr>
@endforeach
</tbody>
</table>

@ -0,0 +1,134 @@
@extends('layouts.app')
@section('page-name','Keuangan')
@section('content')
<div class="page-header">
<h1 class="page-title">
@yield('page-name')
</h1>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Transaksi</h3>
</div>
@if(session()->has('msg'))
<div class="card-alert alert alert-{{ session()->get('type') }}" id="message" style="border-radius: 0px !important">
@if(session()->get('type') == 'success')
<i class="fe fe-check mr-2" aria-hidden="true"></i>
@else
<i class="fe fe-alert-triangle mr-2" aria-hidden="true"></i>
@endif
{{ session()->get('msg') }}
</div>
@endif
<div class="card-body">
<form action="{{ route('keuangan.store') }}" method="post">
@if($errors->any())
<div class="alert alert-danger">
@foreach($errors->all() as $error)
{{ $error }}<br>
@endforeach
</div>
@endif
<div class="row">
<div class="col-12">
@csrf
<div class="form-group">
<label class="form-label">Keperluan</label>
<div class="selectgroup w-100">
<label class="selectgroup-item">
<input type="radio" name="keperluan" value="in" class="selectgroup-input">
<span class="selectgroup-button">Catat Pemasukan</span>
</label>
<label class="selectgroup-item">
<input type="radio" name="keperluan" value="out" class="selectgroup-input">
<span class="selectgroup-button">Catat Pengeluaran</span>
</label>
</div>
</div>
<div class="form-group" style="display:none" id="form-jumlah">
<label class="form-label">Jumlah</label>
<input type="number" name="jumlah" id="jumlah" class="form-control" min='100'>
</div>
<div class="form-group" style="display:none" id="form-keterangan">
<label class="form-label">Keterangan</label>
<textarea name="keterangan" id="keterangan" rows="3" class="form-control"></textarea>
</div>
</div>
</div>
<div class="d-flex">
<button id="submit" class="btn btn-primary ml-auto" style="display:none">Simpan</button>
</div>
</form>
</div>
</div>
</div>
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Mutasi Keuangan</h3>
<div class="card-options">
<a href="{{ route('keuangan.export') }}" class="btn btn-primary btn-sm ml-2" download="true">Export</a>
</div>
</div>
<div class="table-responsive">
<table class="table card-table table-hover table-vcenter text-wrap">
<thead>
<tr>
<th class="w-1">No.</th>
<th>Tanggal</th>
<th>KD</th>
<th>Keterangan</th>
<th>Jumlah</th>
</tr>
</thead>
<tbody>
@foreach ($keuangan as $index => $item)
<tr>
<td><span class="text-muted">{{ $index+1 }}</span></td>
<td>{{ $item->created_at->format('d-m-Y') }}</td>
<td>
@if($item->tipe == 'in')
Uang Masuk
@elseif($item->tipe == 'out')
Uang Keluar
@endif
</td>
<td style="max-width:150px;">{{ $item->keterangan }}</td>
<td>IDR. {{ format_idr($item->jumlah) }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="card-footer">
<div class="d-flex">
<div class="ml-auto mb-0">
{{ $keuangan->links() }}
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@section('js')
<script>
require(['jquery'], function ($) {
$(document).ready(function () {
var keperluan = 'in';
//keperluan
$('.selectgroup-input').change(function(){
keperluan = this.value
$('#form-jumlah').show()
$('#form-keterangan').show()
$('#submit').show()
})
});
});
</script>
@endsection

@ -4,8 +4,8 @@
<div class="col-lg order-lg-first">
<ul class="nav nav-tabs border-0 flex-column flex-lg-row">
<li class="nav-item">
<a href="{{ route('web.index') }}" class="nav-link {{ set_active(['web.index'], 'active') }}">
<i class="fe fe-home"></i> Home
<a href="{{ route('web.index') }}" class="nav-link {{ set_active(['web.*'], 'active') }}">
<i class="fe fe-home"></i> Dashboard
</a>
</li>
<li class="nav-item">
@ -19,7 +19,7 @@
</a>
</li>
<li class="nav-item">
<a href="#!" class="nav-link">
<a href="{{ route('keuangan.index') }}" class="nav-link {{ set_active(['keuangan.*'], 'active') }}">
<i class="fe fe-repeat"></i> Keuangan
</a>
</li>

@ -77,10 +77,10 @@
</td>
<td class="text-center">
<a class="icon" href="{{ route('siswa.show', $item->id) }}" title="lihat detail">
<i class="fe fe-eye"></i>
<i class="fe fe-eye"></i>
</a>
<a class="icon" href="{{ route('siswa.edit', $item->id) }}" title="edit item">
<i class="fe fe-edit"></i>
<i class="fe fe-edit"></i>
</a>
<a class="icon btn-delete" href="#!" data-id="{{ $item->id }}" title="delete item">
<i class="fe fe-trash"></i>

@ -94,7 +94,7 @@
<th>KD</th>
<th>Keterangan</th>
<th>Jumlah</th>
<th></th>
{{-- <th></th> --}}
</tr>
</thead>
<tbody>
@ -116,14 +116,14 @@
</td>
<td style="max-width:150px;">{{ $item->keperluan }}</td>
<td>IDR. {{ format_idr($item->jumlah) }}</td>
<td class="text-center">
{{-- <td class="text-center"> --}}
{{-- <a class="icon btn-delete" href="#!" data-id="{{ $item->id }}" title="delete item">
<i class="fe fe-trash"></i>
</a> --}}
<form action="{{ route('tabungan.destroy', $item->id) }}" method="POST" id="form-{{ $item->id }}">
{{-- <form action="{{ route('tabungan.destroy', $item->id) }}" method="POST" id="form-{{ $item->id }}">
@csrf
</form>
</td>
</form> --}}
{{-- </td> --}}
</tr>
@endforeach
</tbody>

@ -66,7 +66,11 @@ Route::middleware(['auth:web'])->group(function(){
Route::get('tabungan', 'TabunganController@index')->name('tabungan.index');
Route::post('menabung', 'TabunganController@menabung')->name('tabungan.store');
Route::get('export-mutasi', 'TabunganController@export')->name('tabungan.export');
Route::post('del-tabungan','TabunganController@destroy')->name('tabungan.destroy');
//Keuangan
Route::get('keuangan', 'KeuanganController@index')->name('keuangan.index');
Route::post('keuangan', 'KeuanganController@store')->name('keuangan.store');
Route::get('export-keuangan', 'KeuanganController@export')->name('keuangan.export');
});

Loading…
Cancel
Save