refactor: menambahkan relasi user biography dan where barbershop dan menambahkan kolom penginput di view serta menyesuaikan order di datatable
This commit is contained in:
parent
167f5a111a
commit
38a9441ca8
@ -20,7 +20,7 @@ public function index(): View
|
||||
{
|
||||
return view('pages.admin.finance.expenses', [
|
||||
'pageTitle' => 'Pengeluaran',
|
||||
'expenses' => Expense::latest()->get(),
|
||||
'expenses' => Expense::with(['user', 'user.biography'])->barbershop()->latest()->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ public function index(Request $request): View|JsonResponse
|
||||
|
||||
return DataTables::eloquent($attendances)
|
||||
->addIndexColumn()
|
||||
->editColumn('date', function ($item) {
|
||||
->editColumn('created_at', function ($item) {
|
||||
return formatDateIndo($item->created_at);
|
||||
})
|
||||
->addColumn('working_time', function ($item) {
|
||||
|
||||
@ -20,7 +20,7 @@ public function index(): View
|
||||
{
|
||||
return view('pages.admin.manage.inventory', [
|
||||
'pageTitle' => 'Barang',
|
||||
'inventory' => Inventory::latest()->get(),
|
||||
'inventory' => Inventory::with(['user', 'user.biography'])->barbershop()->latest()->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ public function index(): View
|
||||
{
|
||||
return view('pages.admin.manage.transaction.index', [
|
||||
'pageTitle' => 'Transaksi',
|
||||
'transactions' => Transaction::latest()->get(),
|
||||
'transactions' => Transaction::with(['user', 'user.biography'])->barbershop()->latest()->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ public function index(): View
|
||||
{
|
||||
return view('pages.admin.master.customers', [
|
||||
'pageTitle' => 'Pelanggan',
|
||||
'customers' => Customer::latest()->get(),
|
||||
'customers' => Customer::with(['user', 'user.biography'])->barbershop()->latest()->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ window.columns = [
|
||||
orderable: false,
|
||||
searchable: false
|
||||
},
|
||||
{ data: 'date' },
|
||||
{ data: 'created_at' },
|
||||
{ data: 'check_in' },
|
||||
{ data: 'check_in_image' },
|
||||
{ data: 'check_out' },
|
||||
@ -15,7 +15,7 @@ window.columns = [
|
||||
function updateWorkingTime() {
|
||||
const today = moment().format('YYYY-MM-DD');
|
||||
|
||||
$('table tbody tr').each(function() {
|
||||
$('table tbody tr').each(function () {
|
||||
const dateCell = $(this).find('td:nth-child(2)');
|
||||
const checkOutCell = $(this).find('td:nth-child(5)');
|
||||
const workingTimeCell = $(this).find('td:nth-child(7)');
|
||||
@ -23,7 +23,6 @@ function updateWorkingTime() {
|
||||
const rowDate = moment(dateCell.text(), 'ddd, DD MMM YYYY').format('YYYY-MM-DD');
|
||||
const checkOutText = checkOutCell.text().trim();
|
||||
|
||||
// Cek apakah baris adalah hari ini dan check_out masih '-'
|
||||
if (rowDate === today && checkOutText === '-') {
|
||||
const checkInCell = $(this).find('td:nth-child(3)');
|
||||
const checkInTime = checkInCell.text().trim();
|
||||
@ -53,17 +52,12 @@ function updateWorkingTime() {
|
||||
});
|
||||
}
|
||||
|
||||
// Panggil fungsi updateWorkingTime setiap detik
|
||||
$(document).ready(function() {
|
||||
// Pastikan moment.js sudah diinclude
|
||||
$(document).ready(function () {
|
||||
if (typeof moment !== 'undefined') {
|
||||
// Set moment locale ke Indonesia
|
||||
moment.locale('id');
|
||||
|
||||
// Update pertama kali saat halaman dimuat
|
||||
updateWorkingTime();
|
||||
|
||||
// Set interval untuk update setiap detik
|
||||
setInterval(updateWorkingTime, 1000);
|
||||
} else {
|
||||
console.error('moment.js library tidak ditemukan');
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
(function ($) {
|
||||
function getColumnIndex(columns, columnName) {
|
||||
return columns.findIndex(column => column.data === columnName);
|
||||
}
|
||||
|
||||
const createdAtIndex = getColumnIndex(columns, 'created_at');
|
||||
$('#datatable').DataTable({
|
||||
serverSide: true,
|
||||
processing: true,
|
||||
@ -20,5 +25,6 @@
|
||||
[10, 25, 50, 100],
|
||||
[10, 25, 50, 100]
|
||||
],
|
||||
order: createdAtIndex !== -1 ? [[createdAtIndex, "desc"]] : [],
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
@ -22,6 +22,7 @@ class="btn btn-primary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Penginput</th>
|
||||
<th>Nama</th>
|
||||
<th>Jumlah</th>
|
||||
<th>Tanggal</th>
|
||||
@ -32,6 +33,7 @@ class="btn btn-primary">
|
||||
@foreach ($cashes as $cash)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $cash->user->biography->full_name ?? '-deleted-' }}</td>
|
||||
<td>{{ $cash->name }}</td>
|
||||
<td>{{ formatToRupiah($cash->amount) ?? '-' }}</td>
|
||||
<td>{{ formatDateIndo($cash->created_at) }}</td>
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Penginput</th>
|
||||
<th>Nama</th>
|
||||
<th>Jumlah</th>
|
||||
<th>Bukti</th>
|
||||
@ -33,6 +34,7 @@
|
||||
@foreach ($expenses as $expense)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $expense->user->biography->full_name ?? '-deleted-' }}</td>
|
||||
<td>{{ $expense->name }}</td>
|
||||
<td>{{ formatToRupiah($expense->amount) ?? '-' }}</td>
|
||||
<td>
|
||||
|
||||
@ -67,7 +67,7 @@
|
||||
<div class="col-lg-6 position-relative">
|
||||
<label class="form-label" for="shaving_result">Hasil Mencukur</label>
|
||||
<input name="shaving_result" class="form-control @error('shaving_result') is-invalid @enderror"
|
||||
id="shaving_result" type="text" placeholder="Silahkan Pilih Pegawai"
|
||||
id="shaving_result" type="text" placeholder="Silakan Pilih Pegawai"
|
||||
value="{{ old('shaving_result') }}" readonly>
|
||||
@error('shaving_result')
|
||||
<div class="invalid-feedback">
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
<div class="col-lg-6 position-relative">
|
||||
<label class="form-label" for="shaving_result">Hasil Mencukur</label>
|
||||
<input name="shaving_result" class="form-control @error('shabing_result') is-invalid @enderror"
|
||||
id="shaving_result" type="text" placeholder="Silahkan Pilih Pegawai"
|
||||
id="shaving_result" type="text" placeholder="Silakan Pilih Pegawai"
|
||||
value="{{ old('shaving_result', formatToRupiah($payroll->shaving_result)) }}" readonly>
|
||||
@error('shaving_result')
|
||||
<div class="invalid-feedback">
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Penginput</th>
|
||||
<th>Nama</th>
|
||||
<th>Kuantitas</th>
|
||||
<th>Harga</th>
|
||||
@ -36,6 +37,7 @@
|
||||
@foreach ($inventory as $item)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $item->user->biography->full_name ?? '-deleted-' }}</td>
|
||||
<td>{{ $item->name }}</td>
|
||||
<td>{{ $item->quantity }}</td>
|
||||
<td>{{ formatToRupiah($item->price) }}</td>
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Penginput</th>
|
||||
<th>Pelanggan</th>
|
||||
<th>Layanan</th>
|
||||
<th>Harga</th>
|
||||
@ -33,6 +34,7 @@
|
||||
@foreach ($transactions as $transaction)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $transaction->user->biography->full_name ?? '-deleted-' }}</td>
|
||||
<td>{{ $transaction->customer->name }}</td>
|
||||
<td>{{ $transaction->service->name }}</td>
|
||||
<td>{{ formatToRupiah($transaction->price) }}</td>
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Penginput</th>
|
||||
<th>Nama</th>
|
||||
<th>Kontak</th>
|
||||
<th>Tanggal</th>
|
||||
@ -32,6 +33,7 @@
|
||||
@foreach ($customers as $customer)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $customer->user->biography->full_name ?? 'deleted-' }}</td>
|
||||
<td>{{ $customer->name }}</td>
|
||||
<td>{{ $customer->contact_number ?? '-' }}</td>
|
||||
<td>{{ formatDateIndo($customer->created_at) }}</td>
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Penginput</th>
|
||||
<th>Nama</th>
|
||||
<th>Harga</th>
|
||||
<th>Deskripsi</th>
|
||||
@ -29,6 +30,7 @@
|
||||
@foreach ($services as $service)
|
||||
<tr>
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $service->user->biography->full_name ?? '-deleted-' }}</td>
|
||||
<td>{{ $service->name }}</td>
|
||||
<td>{{ formatToRupiah($service->price) }}</td>
|
||||
<td>{{ $service->description }}</td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user