update tgl 25

This commit is contained in:
whywdd 2025-02-25 03:58:17 +07:00
parent 6703fcf78d
commit 02c22275e7
12 changed files with 198 additions and 73 deletions

View File

@ -9,8 +9,12 @@ class GajiController extends Controller
{ {
public function index() public function index()
{ {
// Ambil semua data gaji dari database // Ambil hanya data yang memiliki nilai gaji dan tidak null
$gajiKaryawan = GajiModel::all(); // Anda bisa menambahkan filter atau pagination jika diperlukan $gajiKaryawan = GajiModel::whereNotNull('gaji')
return view('Gaji', compact('gajiKaryawan')); // Kirim data ke view ->where('gaji', '>', 0)
->select('nama_karyawan', 'gaji') // Ambil kolom nama_karyawan dan gaji
->get();
return view('Gaji', compact('gajiKaryawan'));
} }
} }

View File

@ -35,9 +35,8 @@ public function store(Request $request)
'kode' => $kode, 'kode' => $kode,
'kategori' => $validated['kategori'], 'kategori' => $validated['kategori'],
'nama_karyawan' => $validated['nama_karyawan'], 'nama_karyawan' => $validated['nama_karyawan'],
'keterangan' => null, 'uang_masuk' => null,
'uang_masuk' => 0, 'uang_keluar' => null,
'uang_keluar' => 0,
'gaji' => $gaji, 'gaji' => $gaji,
]); ]);

View File

@ -3,11 +3,19 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Models\LaporanModel;
class LaporanController extends Controller class LaporanController extends Controller
{ {
public function index() public function index()
{ {
return view('Laporan'); // This will return the home view $laporan = LaporanModel::orderBy('Tanggal', 'desc')->get();
$totalUangMasuk = LaporanModel::sum('uang_masuk');
$totalUangKeluar = LaporanModel::sum('uang_keluar');
$totalGaji = LaporanModel::sum('gaji');
$totalKredit = $totalUangKeluar + $totalGaji;
$saldo = $totalUangMasuk - $totalKredit;
return view('Laporan', compact('laporan', 'totalUangMasuk', 'totalUangKeluar', 'totalGaji', 'totalKredit', 'saldo'));
} }
} }

View File

@ -35,9 +35,9 @@ public function store(Request $request)
'kode' => $kode, 'kode' => $kode,
'kategori' => $validated['kategori'], 'kategori' => $validated['kategori'],
'keterangan' => $validated['keterangan'], 'keterangan' => $validated['keterangan'],
'uang_masuk' => 0, 'uang_masuk' => null,
'uang_keluar' => $uang_keluar, 'uang_keluar' => $uang_keluar,
'gaji' => 0, 'gaji' => null,
]); ]);
return redirect()->back()->with('success', 'Data berhasil disimpan!'); return redirect()->back()->with('success', 'Data berhasil disimpan!');

View File

@ -29,15 +29,15 @@ public function store(Request $request)
// Tentukan kode berdasarkan kategori // Tentukan kode berdasarkan kategori
$kode = $this->generateKode($validated['kategori']); $kode = $this->generateKode($validated['kategori']);
// Simpan data // Simpan data dengan nilai null untuk uang_keluar dan gaji
UangMasukModel::create([ UangMasukModel::create([
'Tanggal' => $validated['Tanggal'], 'Tanggal' => $validated['Tanggal'],
'kode' => $kode, 'kode' => $kode,
'kategori' => $validated['kategori'], 'kategori' => $validated['kategori'],
'keterangan' => $validated['keterangan'], 'keterangan' => $validated['keterangan'],
'uang_masuk' => $uang_masuk, 'uang_masuk' => $uang_masuk,
'uang_keluar' => 0, 'uang_keluar' => null, // Mengizinkan null
'gaji' => 0, 'gaji' => null, // Mengizinkan null
]); ]);
return redirect()->back()->with('success', 'Data berhasil disimpan!'); return redirect()->back()->with('success', 'Data berhasil disimpan!');

View File

@ -27,6 +27,7 @@ class GajiModel extends Model
'kode', 'kode',
'kategori', 'kategori',
'keterangan', 'keterangan',
'nama_karyawan',
'uang_masuk', 'uang_masuk',
'uang_keluar', 'uang_keluar',
'gaji' 'gaji'

View File

@ -0,0 +1,49 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LaporanModel extends Model
{
use HasFactory;
// Nama tabel yang digunakan
protected $table = 'laporan_transaksis'; // Ganti dengan nama tabel yang sesuai
// Primary key
protected $primaryKey = 'id';
// Menentukan apakah primary key adalah auto-increment
public $incrementing = true;
// Tipe data primary key
protected $keyType = 'int';
// Kolom yang dapat diisi
protected $fillable = [
'Tanggal',
'kode',
'kategori',
'keterangan',
'nama_karyawan',
'uang_masuk',
'uang_keluar',
'gaji'
];
// Timestamps
public $timestamps = true;
// Jika Anda ingin mengubah nama kolom timestamps
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
protected $casts = [
'Tanggal' => 'date',
'uang_masuk' => 'decimal:2',
'uang_keluar' => 'decimal:2',
'gaji' => 'decimal:2',
];
}

View File

@ -1,11 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Laporan_transaksi extends Model
{
use HasFactory;
}

View File

@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateNullableFieldsInLaporanTransaksis extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('laporan_transaksis', function (Blueprint $table) {
// Ubah kolom-kolom menjadi nullable
$table->string('keterangan')->nullable()->change();
$table->string('nama_karyawan')->nullable()->change();
$table->decimal('uang_masuk', 10, 2)->default(0)->change();
$table->decimal('uang_keluar', 10, 2)->default(0)->change();
$table->decimal('gaji', 10, 2)->default(0)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('laporan_transaksis', function (Blueprint $table) {
// Kembalikan kolom-kolom menjadi tidak nullable
$table->string('keterangan')->nullable(false)->change();
$table->string('nama_karyawan')->nullable(false)->change();
$table->decimal('uang_masuk', 10, 2)->nullable(false)->change();
$table->decimal('uang_keluar', 10, 2)->nullable(false)->change();
$table->decimal('gaji', 10, 2)->nullable(false)->change();
});
}
}

View File

@ -12,30 +12,29 @@
<!-- Filter Keterangan --> <!-- Filter Keterangan -->
<div class="flex flex-wrap gap-4 px-6 py-4 border-b border-gray-200"> <div class="flex flex-wrap gap-4 px-6 py-4 border-b border-gray-200">
<div class="flex items-center"> <div class="flex items-center">
<label class="mr-2 text-sm font-medium text-gray-600">Keterangan:</label> <label class="mr-2 text-sm font-medium text-gray-600">Nama Karyawan:</label>
<input type="text" id="filterKeterangan" placeholder="Masukkan keterangan" class="border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" onkeyup="filterTable()"> <input type="text" id="filterKeterangan" placeholder="Masukkan nama karyawan" class="border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500" onkeyup="filterTable()">
<button class="bg-blue-500 text-white px-4 py-2 rounded-md hover:bg-blue-600 transition-colors"> <button class="bg-blue-500 text-white px-4 py-2 rounded-md hover:bg-blue-600 transition-colors ml-2">
<i class="fas fa-search mr-2"></i>Filter <i class="fas fa-search mr-2"></i>Filter
</button> </button>
</div> </div>
</div> </div>
<div class="bg-white rounded-lg shadow-lg p-6"> <div class="overflow-x-auto">
<!-- Tabel Keterangan Gaji Karyawan -->
<table id="gajiTable" class="min-w-full bg-white border border-gray-300"> <table id="gajiTable" class="min-w-full bg-white border border-gray-300">
<thead> <thead>
<tr> <tr class="bg-gray-50">
<th class="py-2 px-4 border-b text-left">No</th> <th class="py-2 px-4 border-b text-left">No</th>
<th class="py-2 px-4 border-b text-left">Keterangan</th> <th class="py-2 px-4 border-b text-left">Nama Karyawan</th>
<th class="py-2 px-4 border-b text-left">Nominal</th> <th class="py-2 px-4 border-b text-left">Nominal Gaji</th>
<th class="py-2 px-4 border-b text-left">Aksi</th> <th class="py-2 px-4 border-b text-center">Aksi</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach($gajiKaryawan as $index => $gaji) @forelse($gajiKaryawan as $index => $gaji)
<tr> <tr>
<td class="py-2 px-4 border-b">{{ $index + 1 }}</td> <td class="py-2 px-4 border-b">{{ $index + 1 }}</td>
<td class="py-2 px-4 border-b">{{ $gaji->keterangan }}</td> <td class="py-2 px-4 border-b">{{ $gaji->nama_karyawan }}</td>
<td class="py-2 px-4 border-b">Rp {{ number_format($gaji->gaji, 0, ',', '.') }}</td> <td class="py-2 px-4 border-b">Rp {{ number_format($gaji->gaji, 0, ',', '.') }}</td>
<td class="py-3 px-4 text-center"> <td class="py-3 px-4 text-center">
<div class="flex justify-center space-x-2"> <div class="flex justify-center space-x-2">
@ -48,7 +47,13 @@
</div> </div>
</td> </td>
</tr> </tr>
@endforeach @empty
<tr>
<td colspan="4" class="py-4 px-4 text-center text-gray-500">
Tidak ada data gaji karyawan
</td>
</tr>
@endforelse
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -24,18 +24,25 @@
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6"> <div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
<div class="bg-white p-4 rounded-lg shadow"> <div class="bg-white p-4 rounded-lg shadow">
<h3 class="text-gray-500 text-sm">Total Pendapatan</h3> <h3 class="text-gray-500 text-sm">Total Pendapatan</h3>
<p class="text-2xl font-bold text-green-600">Rp 5.000.000</p> <p class="text-2xl font-bold text-green-600">Rp {{ number_format($totalUangMasuk, 0, ',', '.') }}</p>
<p class="text-sm text-gray-400">+15% dari bulan lalu</p> <p class="text-sm text-gray-400">Data realtime keuangan</p>
</div> </div>
<div class="bg-white p-4 rounded-lg shadow"> <div class="bg-white p-4 rounded-lg shadow">
<h3 class="text-gray-500 text-sm">Total Pengeluaran</h3> <h3 class="text-gray-500 text-sm">Total Pengeluaran</h3>
<p class="text-2xl font-bold text-red-600">Rp 3.200.000</p> <p class="text-2xl font-bold text-red-600">Rp {{ number_format($totalKredit, 0, ',', '.') }}</p>
<p class="text-sm text-gray-400">-5% dari bulan lalu</p> <p class="text-sm text-gray-400">Data realtime keuangan</p>
</div> </div>
<div class="bg-white p-4 rounded-lg shadow"> <div class="bg-white p-4 rounded-lg shadow">
<h3 class="text-gray-500 text-sm">Laba Bersih</h3> <h3 class="text-gray-500 text-sm">Laba Bersih</h3>
<p class="text-2xl font-bold text-blue-600">Rp 1.800.000</p> <p class="text-2xl font-bold text-blue-600">Rp {{ number_format($saldo, 0, ',', '.') }}</p>
<p class="text-sm text-gray-400">+25% dari bulan lalu</p>
@if(isset($persentasePeningkatan))
<p class="text-sm {{ $persentasePeningkatan >= 0 ? 'text-green-500' : 'text-red-500' }}">
{{ $persentasePeningkatan >= 0 ? '+' : '' }}{{ number_format($persentasePeningkatan, 0) }}% dari bulan lalu
</p>
@else
<p class="text-sm text-gray-400">Data realtime keuangan</p>
@endif
</div> </div>
<div class="bg-white p-4 rounded-lg shadow"> <div class="bg-white p-4 rounded-lg shadow">
<h3 class="text-gray-500 text-sm">Saldo Kas</h3> <h3 class="text-gray-500 text-sm">Saldo Kas</h3>
@ -99,37 +106,61 @@
</tr> </tr>
</thead> </thead>
<tbody id="tableBody"> <tbody id="tableBody">
<!-- Example data with more accounting details --> <!-- Looping data dari database -->
<tr class="border-b border-gray-200 hover:bg-gray-50"> @php
<td class="py-3 px-4">1</td> $no = 1;
<td class="py-3 px-4">2024-02-20</td> $runningSaldo = 0;
<td class="py-3 px-4">411</td> @endphp
<td class="py-3 px-4">Penjualan</td>
<td class="py-3 px-4">Pendapatan dari penjualan produk A</td> @foreach($laporan as $item)
<td class="py-3 px-4 text-right text-green-600">Rp 5.000.000</td> @php
<td class="py-3 px-4 text-right text-red-600">-</td> $debit = $item->uang_masuk;
<td class="py-3 px-4 text-right font-medium">Rp 5.000.000</td> $kredit = $item->uang_keluar + $item->gaji;
<td class="py-3 px-4 text-center"> $runningSaldo += $debit - $kredit;
<div class="flex justify-center space-x-2"> @endphp
<button class="text-blue-600 hover:text-blue-800" title="Edit"> <tr class="border-b border-gray-200 hover:bg-gray-50">
<i class="fas fa-edit"></i> <td class="py-3 px-4">{{ $no++ }}</td>
</button> <td class="py-3 px-4">{{ $item->Tanggal->format('Y-m-d') }}</td>
<button class="text-green-600 hover:text-green-800" title="Detail"> <td class="py-3 px-4">{{ $item->kode }}</td>
<i class="fas fa-eye"></i> <td class="py-3 px-4">{{ $item->kategori }}</td>
</button> <td class="py-3 px-4">{{ $item->keterangan }}</td>
<button class="text-red-600 hover:text-red-800" title="Hapus"> <td class="py-3 px-4 text-right text-green-600">
<i class="fas fa-trash"></i> @if($debit > 0)
</button> Rp {{ number_format($debit, 0, ',', '.') }}
</div> @else
</td> -
</tr> @endif
</td>
<td class="py-3 px-4 text-right text-red-600">
@if($kredit > 0)
Rp {{ number_format($kredit, 0, ',', '.') }}
@else
-
@endif
</td>
<td class="py-3 px-4 text-right font-medium">Rp {{ number_format($runningSaldo, 0, ',', '.') }}</td>
<td class="py-3 px-4 text-center">
<div class="flex justify-center space-x-2">
<button class="text-blue-600 hover:text-blue-800" title="Edit">
<i class="fas fa-edit"></i>
</button>
<button class="text-green-600 hover:text-green-800" title="Detail">
<i class="fas fa-eye"></i>
</button>
<button class="text-red-600 hover:text-red-800" title="Hapus">
<i class="fas fa-trash"></i>
</button>
</div>
</td>
</tr>
@endforeach
</tbody> </tbody>
<tfoot> <tfoot>
<tr class="bg-gray-50 font-bold"> <tr class="bg-gray-50 font-bold">
<td colspan="5" class="py-3 px-4 text-right">Total:</td> <td colspan="5" class="py-3 px-4 text-right">Total:</td>
<td class="py-3 px-4 text-right text-green-600">Rp 5.000.000</td> <td class="py-3 px-4 text-right text-green-600">Rp {{ number_format($totalUangMasuk, 0, ',', '.') }}</td>
<td class="py-3 px-4 text-right text-red-600">Rp 0</td> <td class="py-3 px-4 text-right text-red-600">Rp {{ number_format($totalKredit, 0, ',', '.') }}</td>
<td class="py-3 px-4 text-right">Rp 5.000.000</td> <td class="py-3 px-4 text-right">Rp {{ number_format($saldo, 0, ',', '.') }}</td>
<td></td> <td></td>
</tr> </tr>
</tfoot> </tfoot>
@ -149,10 +180,7 @@
<i class="fas fa-print mr-2"></i>Print <i class="fas fa-print mr-2"></i>Print
</button> </button>
</div> </div>
<button class="btn bg-blue-500 text-white hover:bg-blue-600">
<i class="fas fa-plus mr-2"></i>Tambah Transaksi
</button>
</div>
<!-- Pagination (same as before) --> <!-- Pagination (same as before) -->
<!-- Modal (same as before) --> <!-- Modal (same as before) -->

View File

@ -32,7 +32,7 @@
Route::get('/uang-keluar', [UangKeluarController::class, 'index'])->name('uang-keluar.index'); Route::get('/uang-keluar', [UangKeluarController::class, 'index'])->name('uang-keluar.index');
Route::post('/uang-keluar', [UangKeluarController::class, 'store'])->name('uangkeluar.store'); Route::post('/uang-keluar', [UangKeluarController::class, 'store'])->name('uangkeluar.store');
Route::get('/input-gaji', [InputGajiController::class, 'index'])->name('input-gaji.index'); Route::get('/input-gaji', [InputGajiController::class, 'index'])->name('input-gaji.index');
Route::post('/input-gaji', [InputGajiController::class, 'store'])->name('input-gaji.store'); // Route::post('/input-gaji', [InputGajiController::class, 'store'])->name('input-gaji.store');
//untuk Uang Gaji //untuk Uang Gaji
Route::get('/gaji', [GajiController::class, 'index'])->name('gaji.index'); Route::get('/gaji', [GajiController::class, 'index'])->name('gaji.index');