Compare commits
12 Commits
6ebcbc24c0
...
bc02af2a66
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc02af2a66 | ||
|
|
9bbb00c69f | ||
|
|
5ec0e9ff3b | ||
|
|
d2d10ea63a | ||
|
|
a10a1700b0 | ||
|
|
c11962cda1 | ||
|
|
66d6c843c3 | ||
|
|
78965e9728 | ||
|
|
8aa4e83cd8 | ||
|
|
ab217a8d79 | ||
|
|
8df17601ea | ||
|
|
42e04673c6 |
@ -10,16 +10,16 @@ enum CashTransactionType: string
|
||||
|
||||
case DEPOSIT = 'deposit';
|
||||
case EXPENSE = 'expense';
|
||||
case TRANSFER = 'transfer';
|
||||
case WITHDRAWAL = 'withdrawal';
|
||||
case EMPLOYEE_ADVANCE = 'employee_advance';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::DEPOSIT => 'Setoran',
|
||||
self::DEPOSIT => 'Deposit',
|
||||
self::EXPENSE => 'Pengeluaran',
|
||||
self::TRANSFER => 'Transfer',
|
||||
self::WITHDRAWAL => 'Penarikan',
|
||||
self::WITHDRAWAL => 'Withdrawal',
|
||||
self::EMPLOYEE_ADVANCE => 'Kasbon',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,9 +71,8 @@ enum Permission: string
|
||||
case PRODUCTS_UPDATE = 'products.update';
|
||||
case PRODUCTS_DELETE = 'products.delete';
|
||||
case PRODUCTS_TOGGLE_STATUS = 'products.toggle_status';
|
||||
|
||||
// Stocks
|
||||
case STOCKS_VIEW = 'stocks.view';
|
||||
case PRODUCTS_TRANSFER_STOCK = 'products.transfer_stock';
|
||||
case PRODUCTS_VIEW_STOCK_MUTATIONS = 'products.view_stock_mutations';
|
||||
|
||||
// Orders
|
||||
case ORDERS_VIEW = 'orders.view';
|
||||
@ -113,6 +112,7 @@ enum Permission: string
|
||||
case EMPLOYEE_ADVANCES_UPDATE = 'employee_advances.update';
|
||||
case EMPLOYEE_ADVANCES_DELETE = 'employee_advances.delete';
|
||||
case EMPLOYEE_ADVANCES_PAY = 'employee_advances.pay';
|
||||
case EMPLOYEE_ADVANCES_VIEW_PAYMENTS = 'employee_advances.view_payments';
|
||||
case EMPLOYEE_ADVANCES_VERIFY = 'employee_advances.verify';
|
||||
|
||||
// Payroll
|
||||
|
||||
@ -22,19 +22,38 @@ public function index(Request $request): Response
|
||||
{
|
||||
$year = $request->integer('year', now()->year);
|
||||
$month = $request->integer('month', now()->month);
|
||||
|
||||
$hrSettings = app(HRSettings::class);
|
||||
$user = auth()->user();
|
||||
$isAdmin = $user->hasAnyRole(['developer', 'owner', 'direktur']);
|
||||
|
||||
if ($isAdmin) {
|
||||
return Inertia::render('admin/hr/attendance/index', [
|
||||
'attendances' => $this->service->getByMonth($year, $month),
|
||||
'todayAttendance' => null,
|
||||
'currentYear' => $year,
|
||||
'currentMonth' => $month,
|
||||
'monthStats' => $this->service->getMonthStats($year, $month),
|
||||
'hrSettings' => [
|
||||
'scheduled_check_in_time' => $hrSettings->scheduled_check_in_time,
|
||||
'scheduled_check_out_time' => $hrSettings->scheduled_check_out_time,
|
||||
],
|
||||
'isAdmin' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
$employeeId = $user->employee?->id;
|
||||
|
||||
return Inertia::render('admin/hr/attendance/index', [
|
||||
'attendances' => $this->service->getByMonth($year, $month),
|
||||
'attendances' => $this->service->getByMonth($year, $month, $employeeId),
|
||||
'todayAttendance' => $this->service->getToday(),
|
||||
'currentYear' => $year,
|
||||
'currentMonth' => $month,
|
||||
'monthStats' => $this->service->getMonthStats($year, $month),
|
||||
'monthStats' => $this->service->getMonthStats($year, $month, $employeeId),
|
||||
'hrSettings' => [
|
||||
'scheduled_check_in_time' => $hrSettings->scheduled_check_in_time,
|
||||
'scheduled_check_out_time' => $hrSettings->scheduled_check_out_time,
|
||||
],
|
||||
'isAdmin' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,9 @@ public function create(): Response
|
||||
|
||||
return Inertia::render('admin/hr/employee/create', [
|
||||
'roles' => $this->service->canViewAll()
|
||||
? Role::where('name', '!=', 'Developer')->get(['id', 'name'])
|
||||
? Role::where('name', '!=', 'Developer')
|
||||
->when($this->service->shouldHideAdminBahanBaku(), fn ($q) => $q->where('name', '!=', 'admin-bahan-baku'))
|
||||
->get(['id', 'name'])
|
||||
: Role::where('name', '=', $user->roles->first()?->name)->get(['id', 'name']),
|
||||
'canViewAll' => $this->service->canViewAll(),
|
||||
]);
|
||||
@ -57,7 +59,10 @@ public function edit(User $user): Response
|
||||
|
||||
return Inertia::render('admin/hr/employee/edit', [
|
||||
'employee' => $user,
|
||||
'roles' => Role::where('name', '!=', 'Developer')->get(['id', 'name']),
|
||||
'roles' => Role::where('name', '!=', 'Developer')
|
||||
->when($this->service->shouldHideAdminBahanBaku(), fn ($q) => $q->where('name', '!=', 'admin-bahan-baku'))
|
||||
->get(['id', 'name']),
|
||||
'canViewAll' => $this->service->canViewAll(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -30,10 +30,10 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
protected function attendanceDate(): Attribute
|
||||
protected function formattedAttendanceDate(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => $value?->translatedFormat('l, d F Y'),
|
||||
get: fn ($value) => $value ? \Carbon\Carbon::parse($value)->translatedFormat('l, d F Y') : null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -26,14 +26,14 @@ protected function casts(): array
|
||||
protected function formattedAmount(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => 'Rp ' . number_format($this->amount, 0, ',', '.'),
|
||||
get: fn () => 'Rp '.number_format($this->amount, 0, ',', '.'),
|
||||
);
|
||||
}
|
||||
|
||||
protected function formattedPaidAt(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => $this->paid_at?->translatedFormat('l, d F Y'),
|
||||
get: fn () => $this->paid_at?->translatedFormat('l, d F Y'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -34,14 +34,14 @@ protected function casts(): array
|
||||
protected function formattedName(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => ucfirst($this->name),
|
||||
get: fn () => ucfirst($this->name),
|
||||
);
|
||||
}
|
||||
|
||||
protected function formattedStock(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn() => number_format($this->stock, 0, ',', '.'),
|
||||
get: fn () => number_format($this->stock, 0, ',', '.'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\Admin\Finance;
|
||||
|
||||
use App\Enums\CashTransactionType;
|
||||
use App\Enums\EmployeeAdvanceStatus;
|
||||
use App\Models\EmployeeAdvance;
|
||||
use App\Models\EmployeeAdvancePayment;
|
||||
@ -47,7 +48,9 @@ public function create(array $data): EmployeeAdvance
|
||||
$employee = auth()->user()->employee;
|
||||
|
||||
if (! $employee) {
|
||||
throw new \Exception('Anda tidak terdaftar sebagai karyawan.');
|
||||
throw ValidationException::withMessages([
|
||||
'amount' => 'Anda tidak terdaftar sebagai karyawan.',
|
||||
]);
|
||||
}
|
||||
|
||||
$employeeAdvance = EmployeeAdvance::create([
|
||||
@ -73,6 +76,44 @@ public function create(array $data): EmployeeAdvance
|
||||
|
||||
public function update(EmployeeAdvance $employeeAdvance, array $data): EmployeeAdvance
|
||||
{
|
||||
if ($employeeAdvance->status === EmployeeAdvanceStatus::PAID) {
|
||||
throw ValidationException::withMessages([
|
||||
'amount' => 'Kasbon yang sudah dibayar tidak dapat diedit.',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($employeeAdvance->status === EmployeeAdvanceStatus::APPROVED && $employeeAdvance->cash_transaction_id) {
|
||||
$oldAmount = $employeeAdvance->amount;
|
||||
$newAmount = $data['amount'];
|
||||
|
||||
if ($oldAmount !== $newAmount) {
|
||||
$employeeAdvance = DB::transaction(function () use ($employeeAdvance, $data, $oldAmount, $newAmount) {
|
||||
$this->creditCash(
|
||||
$oldAmount,
|
||||
'Pembatalan kasbon: '.$employeeAdvance->description,
|
||||
CashTransactionType::DEPOSIT,
|
||||
);
|
||||
|
||||
$cashTransaction = $this->debitCash(
|
||||
$newAmount,
|
||||
'Kasbon: '.$data['description'],
|
||||
CashTransactionType::EMPLOYEE_ADVANCE,
|
||||
);
|
||||
|
||||
$employeeAdvance->update([
|
||||
'amount' => $newAmount,
|
||||
'description' => $data['description'],
|
||||
'due_date' => $data['due_date'],
|
||||
'cash_transaction_id' => $cashTransaction->id,
|
||||
]);
|
||||
|
||||
return $employeeAdvance;
|
||||
});
|
||||
|
||||
return $employeeAdvance;
|
||||
}
|
||||
}
|
||||
|
||||
$employeeAdvance->update([
|
||||
'amount' => $data['amount'],
|
||||
'description' => $data['description'],
|
||||
@ -84,29 +125,60 @@ public function update(EmployeeAdvance $employeeAdvance, array $data): EmployeeA
|
||||
|
||||
public function delete(EmployeeAdvance $employeeAdvance): bool
|
||||
{
|
||||
if ($employeeAdvance->status === EmployeeAdvanceStatus::APPROVED && $employeeAdvance->cash_transaction_id) {
|
||||
$cashAccount = $this->getCashAccount();
|
||||
$newBalance = $cashAccount->balance + $employeeAdvance->amount;
|
||||
$cashAccount->update(['balance' => $newBalance]);
|
||||
$employeeAdvance->cashTransaction()->delete();
|
||||
}
|
||||
return DB::transaction(function () use ($employeeAdvance) {
|
||||
if ($employeeAdvance->status === EmployeeAdvanceStatus::APPROVED && $employeeAdvance->cash_transaction_id) {
|
||||
$this->creditCash(
|
||||
$employeeAdvance->amount,
|
||||
'Pembatalan kasbon: '.$employeeAdvance->description,
|
||||
CashTransactionType::DEPOSIT,
|
||||
);
|
||||
$employeeAdvance->cashTransaction()->delete();
|
||||
}
|
||||
|
||||
return $employeeAdvance->delete();
|
||||
if ($employeeAdvance->status === EmployeeAdvanceStatus::PAID) {
|
||||
$this->creditCash(
|
||||
$employeeAdvance->amount,
|
||||
'Pembatalan kasbon: '.$employeeAdvance->description,
|
||||
CashTransactionType::DEPOSIT,
|
||||
);
|
||||
|
||||
$employeeAdvance->load('payments');
|
||||
foreach ($employeeAdvance->payments as $payment) {
|
||||
if ($payment->cash_transaction_id) {
|
||||
$this->debitCash(
|
||||
$payment->amount,
|
||||
'Pembatalan pembayaran kasbon: '.$employeeAdvance->description,
|
||||
CashTransactionType::EXPENSE,
|
||||
);
|
||||
$payment->cashTransaction()->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$employeeAdvance->payments()->delete();
|
||||
}
|
||||
|
||||
return $employeeAdvance->delete();
|
||||
});
|
||||
}
|
||||
|
||||
public function approve(EmployeeAdvance $employeeAdvance): EmployeeAdvance
|
||||
{
|
||||
$cashTransaction = $this->debitCash(
|
||||
amount: $employeeAdvance->amount,
|
||||
description: 'Kasbon: '.$employeeAdvance->description,
|
||||
);
|
||||
$employeeAdvance = DB::transaction(function () use ($employeeAdvance) {
|
||||
$cashTransaction = $this->debitCash(
|
||||
$employeeAdvance->amount,
|
||||
'Kasbon: '.$employeeAdvance->description,
|
||||
CashTransactionType::EMPLOYEE_ADVANCE
|
||||
);
|
||||
|
||||
$employeeAdvance->update([
|
||||
'cash_transaction_id' => $cashTransaction->id,
|
||||
'status' => EmployeeAdvanceStatus::APPROVED,
|
||||
'verified_by_id' => auth()->id(),
|
||||
'verified_at' => now(),
|
||||
]);
|
||||
$employeeAdvance->update([
|
||||
'cash_transaction_id' => $cashTransaction->id,
|
||||
'status' => EmployeeAdvanceStatus::APPROVED,
|
||||
'verified_by_id' => auth()->id(),
|
||||
'verified_at' => now(),
|
||||
]);
|
||||
|
||||
return $employeeAdvance;
|
||||
});
|
||||
|
||||
NotificationService::notify(
|
||||
roles: ['Owner', 'Developer', 'Direktur', 'Admin Toko'],
|
||||
@ -131,8 +203,9 @@ public function pay(EmployeeAdvance $employeeAdvance, int $amount): EmployeeAdva
|
||||
|
||||
$employeeAdvance = DB::transaction(function () use ($employeeAdvance, $amount) {
|
||||
$cashTransaction = $this->creditCash(
|
||||
amount: $amount,
|
||||
description: 'Pembayaran kasbon: '.$employeeAdvance->description,
|
||||
$amount,
|
||||
'Pembayaran kasbon: '.$employeeAdvance->description,
|
||||
CashTransactionType::DEPOSIT
|
||||
);
|
||||
|
||||
EmployeeAdvancePayment::create([
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\Admin\Finance;
|
||||
|
||||
use App\Enums\CashTransactionType;
|
||||
use App\Models\CashAccount;
|
||||
use App\Models\Expense;
|
||||
use App\Services\Concerns\HandlesCashTransactions;
|
||||
@ -175,10 +176,11 @@ public function update(Expense $expense, array $data): Expense
|
||||
public function delete(Expense $expense): bool
|
||||
{
|
||||
return DB::transaction(function () use ($expense) {
|
||||
$cashAccount = CashAccount::firstOrFail();
|
||||
|
||||
$newBalance = $cashAccount->balance + $expense->amount;
|
||||
$cashAccount->update(['balance' => $newBalance]);
|
||||
$this->creditCash(
|
||||
amount: $expense->amount,
|
||||
description: 'Pembatalan pengeluaran: '.$expense->description,
|
||||
type: CashTransactionType::DEPOSIT,
|
||||
);
|
||||
|
||||
// Invalidate receipt cache
|
||||
$media = $expense->getFirstMedia('receipts');
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services\Admin\Finance;
|
||||
|
||||
use App\Enums\CashTransactionType;
|
||||
use App\Enums\PayrollPeriodStatus;
|
||||
use App\Enums\PayrollStatus;
|
||||
use App\Models\Payroll;
|
||||
@ -141,9 +142,10 @@ public function pay(Payroll $payroll): Payroll
|
||||
}
|
||||
|
||||
$payroll = DB::transaction(function () use ($payroll) {
|
||||
$cashTransaction = $this->creditCash(
|
||||
$cashTransaction = $this->debitCash(
|
||||
amount: $payroll->total_amount,
|
||||
description: 'Pembayaran gaji karyawan',
|
||||
type: CashTransactionType::EXPENSE,
|
||||
);
|
||||
|
||||
$payroll->update([
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
namespace App\Services\Admin\HR;
|
||||
|
||||
use App\Models\Attendance;
|
||||
use App\Models\Employee;
|
||||
use App\Models\LeaveRequest;
|
||||
use App\Services\Concerns\RegistersMedia;
|
||||
use App\Services\NotificationService;
|
||||
@ -27,11 +28,12 @@ public function getAll(): Collection
|
||||
->map(fn (Attendance $attendance) => $this->formatAttendance($attendance));
|
||||
}
|
||||
|
||||
public function getByMonth(int $year, int $month): Collection
|
||||
public function getByMonth(int $year, int $month, ?int $employeeId = null): Collection
|
||||
{
|
||||
return Attendance::with(['employee.user.userProfile', 'media'])
|
||||
->whereYear('attendance_date', $year)
|
||||
->whereMonth('attendance_date', $month)
|
||||
->when($employeeId, fn ($q) => $q->where('employee_id', $employeeId))
|
||||
->get()
|
||||
->map(fn (Attendance $attendance) => $this->formatAttendance($attendance));
|
||||
}
|
||||
@ -51,7 +53,14 @@ public function getToday(): ?array
|
||||
return $this->getByDate(now()->toDateString());
|
||||
}
|
||||
|
||||
public function getMonthStats(int $year, int $month): array
|
||||
public function getAllEmployees(): Collection
|
||||
{
|
||||
return Employee::with(['user.userProfile', 'user.roles'])
|
||||
->whereHas('user', fn ($q) => $q->where('is_active', true))
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getMonthStats(int $year, int $month, ?int $employeeId = null): array
|
||||
{
|
||||
$startOfMonth = Carbon::createFromDate($year, $month, 1)->startOfMonth();
|
||||
$endOfMonth = $startOfMonth->copy()->endOfMonth();
|
||||
@ -65,14 +74,20 @@ public function getMonthStats(int $year, int $month): array
|
||||
$current->addDay();
|
||||
}
|
||||
|
||||
$attendanceCount = Attendance::whereYear('attendance_date', $year)
|
||||
->whereMonth('attendance_date', $month)
|
||||
->count();
|
||||
$attendanceQuery = Attendance::whereYear('attendance_date', $year)
|
||||
->whereMonth('attendance_date', $month);
|
||||
if ($employeeId) {
|
||||
$attendanceQuery->where('employee_id', $employeeId);
|
||||
}
|
||||
$attendanceCount = $attendanceQuery->count();
|
||||
|
||||
$leaveDays = LeaveRequest::approved()
|
||||
$leaveQuery = LeaveRequest::approved()
|
||||
->where('start_date', '<=', $endOfMonth)
|
||||
->where('end_date', '>=', $startOfMonth)
|
||||
->get()
|
||||
->where('end_date', '>=', $startOfMonth);
|
||||
if ($employeeId) {
|
||||
$leaveQuery->where('employee_id', $employeeId);
|
||||
}
|
||||
$leaveDays = $leaveQuery->get()
|
||||
->reduce(function ($carry, $leave) use ($startOfMonth, $endOfMonth) {
|
||||
$leaveStart = max($leave->start_date->timestamp, $startOfMonth->timestamp);
|
||||
$leaveEnd = min($leave->end_date->timestamp, $endOfMonth->timestamp);
|
||||
@ -154,6 +169,7 @@ public function checkOut(Attendance $attendance, array $data): Attendance
|
||||
private function formatAttendance(Attendance $attendance): array
|
||||
{
|
||||
$toArray = $attendance->toArray();
|
||||
$toArray['employee_name'] = $attendance->employee?->user?->userProfile?->full_name ?? '-';
|
||||
|
||||
if (is_null($toArray['work_duration_minutes']) && $attendance->check_in_at) {
|
||||
$checkIn = Carbon::parse($attendance->check_in_at);
|
||||
|
||||
@ -10,12 +10,18 @@
|
||||
class EmployeeService
|
||||
{
|
||||
private const ADMIN_ROLES = ['developer', 'owner', 'direktur', 'admin-toko'];
|
||||
private const RESTRICTED_ROLES = ['admin-toko', 'direktur'];
|
||||
|
||||
public function canViewAll(): bool
|
||||
{
|
||||
return auth()->user()->hasAnyRole(self::ADMIN_ROLES);
|
||||
}
|
||||
|
||||
public function shouldHideAdminBahanBaku(): bool
|
||||
{
|
||||
return auth()->user()->hasAnyRole(self::RESTRICTED_ROLES);
|
||||
}
|
||||
|
||||
public function getAll(array $filters = []): Collection
|
||||
{
|
||||
return User::select(['id', 'email', 'username', 'is_active'])
|
||||
@ -29,6 +35,7 @@ public function getAll(array $filters = []): Collection
|
||||
$userRoles = auth()->user()->roles->pluck('name');
|
||||
$q->whereHas('roles', fn ($rq) => $rq->whereIn('name', $userRoles));
|
||||
})
|
||||
->when($this->shouldHideAdminBahanBaku(), fn ($q) => $q->whereDoesntHave('roles', fn ($rq) => $rq->where('name', 'admin-bahan-baku')))
|
||||
->when($filters['employment_status'] ?? null, fn ($q, $status) => $q->whereHas('employee', fn ($eq) => $eq->where('employment_status', $status)))
|
||||
->when(isset($filters['is_active']) && $filters['is_active'] !== '', fn ($q) => $q->where('is_active', filter_var($filters['is_active'], FILTER_VALIDATE_BOOLEAN)))
|
||||
->when($filters['gender'] ?? null, fn ($q, $gender) => $q->whereHas('userProfile', fn ($uq) => $uq->where('gender', $gender)))
|
||||
@ -50,6 +57,7 @@ public function paginated(int $perPage = 25, string $search = '', string $sort =
|
||||
$userRoles = auth()->user()->roles->pluck('name');
|
||||
$q->whereHas('roles', fn ($rq) => $rq->whereIn('name', $userRoles));
|
||||
})
|
||||
->when($this->shouldHideAdminBahanBaku(), fn ($q) => $q->whereDoesntHave('roles', fn ($rq) => $rq->where('name', 'admin-bahan-baku')))
|
||||
->when($search, fn ($q) => $q->whereHas('userProfile', fn ($uq) => $uq->where('full_name', 'like', "%{$search}%")))
|
||||
->when($filters['employment_status'] ?? null, fn ($q, $status) => $q->whereHas('employee', fn ($eq) => $eq->where('employment_status', $status)))
|
||||
->when(isset($filters['is_active']) && $filters['is_active'] !== '', fn ($q) => $q->where('is_active', filter_var($filters['is_active'], FILTER_VALIDATE_BOOLEAN)))
|
||||
|
||||
@ -12,10 +12,16 @@
|
||||
|
||||
class LeaveRequestService
|
||||
{
|
||||
private function canViewAll(): bool
|
||||
{
|
||||
return auth()->user()->hasAnyRole(['developer', 'owner', 'direktur', 'admin-toko']);
|
||||
}
|
||||
|
||||
public function getAll(array $filters = []): Collection
|
||||
{
|
||||
return LeaveRequest::select(['id', 'employee_id', 'start_date', 'end_date', 'total_days', 'status', 'created_at'])
|
||||
->with(['employee.user.userProfile'])
|
||||
->when(! $this->canViewAll(), fn ($q) => $q->whereHas('employee', fn ($eq) => $eq->where('user_id', auth()->id())))
|
||||
->when($filters['status'] ?? null, function ($query, $status) {
|
||||
$query->where('status', $status);
|
||||
})
|
||||
@ -28,6 +34,7 @@ public function paginated(int $perPage = 25, string $search = '', string $sort =
|
||||
return LeaveRequest::query()
|
||||
->select(['id', 'employee_id', 'start_date', 'end_date', 'total_days', 'status', 'created_at'])
|
||||
->with(['employee.user.userProfile'])
|
||||
->when(! $this->canViewAll(), fn ($q) => $q->whereHas('employee', fn ($eq) => $eq->where('user_id', auth()->id())))
|
||||
->when($search, fn ($q) => $q->whereHas('employee.user.userProfile', fn ($uq) => $uq->where('full_name', 'like', "%{$search}%")))
|
||||
->when($filters['status'] ?? null, function ($query, $status) {
|
||||
$query->where('status', $status);
|
||||
|
||||
@ -30,14 +30,14 @@ public function paginated(int $perPage = 25, string $search = '', string $sort =
|
||||
->with([
|
||||
'createdBy:id',
|
||||
'createdBy.userProfile:id,user_id,full_name',
|
||||
'restockItems' => fn($q) => $q
|
||||
'restockItems' => fn ($q) => $q
|
||||
->select(['id', 'restock_id', 'product_variant_id', 'quantity', 'unit_price', 'subtotal'])
|
||||
->orderByRaw('(SELECT name FROM product_variants WHERE product_variants.id = restock_items.product_variant_id)'),
|
||||
'restockItems.productVariant:id,product_id,name,stock,reject_stock,retail_stock',
|
||||
'restockItems.productVariant.product:id,name',
|
||||
])
|
||||
->when($search, function ($q) use ($search) {
|
||||
$q->whereHas('restockItems.productVariant.product', fn($sq) => $sq->where('name', 'like', "%{$search}%"))
|
||||
$q->whereHas('restockItems.productVariant.product', fn ($sq) => $sq->where('name', 'like', "%{$search}%"))
|
||||
->orWhere('notes', 'like', "%{$search}%");
|
||||
})
|
||||
->orderBy($sort, $direction)
|
||||
@ -79,11 +79,11 @@ public function getForCreate(): array
|
||||
: null;
|
||||
|
||||
$capitalPrice = $variant->productPrices
|
||||
->first(fn($price) => $price->type === PriceType::CAPITAL);
|
||||
->first(fn ($price) => $price->type === PriceType::CAPITAL);
|
||||
$variant->capital_price = $capitalPrice?->price ?? 0;
|
||||
|
||||
$rejectPrice = $variant->productPrices
|
||||
->first(fn($price) => $price->type === PriceType::REJECT);
|
||||
->first(fn ($price) => $price->type === PriceType::REJECT);
|
||||
$variant->reject_price = $rejectPrice?->price ?? 0;
|
||||
});
|
||||
}),
|
||||
@ -93,7 +93,7 @@ public function getForCreate(): array
|
||||
public function getForEdit(Restock $restock): array
|
||||
{
|
||||
$restock->load([
|
||||
'restockItems' => fn($q) => $q
|
||||
'restockItems' => fn ($q) => $q
|
||||
->orderByRaw('(SELECT name FROM product_variants WHERE product_variants.id = restock_items.product_variant_id)'),
|
||||
'restockItems.productVariant.product',
|
||||
]);
|
||||
@ -108,7 +108,7 @@ public function getForEdit(Restock $restock): array
|
||||
'photo_url' => $media
|
||||
? $this->s3Service->getTemporaryUrl($media->file_name)
|
||||
: null,
|
||||
'items' => $restock->restockItems->map(fn(RestockItem $item) => [
|
||||
'items' => $restock->restockItems->map(fn (RestockItem $item) => [
|
||||
'id' => $item->id,
|
||||
'product_variant_id' => $item->product_variant_id,
|
||||
'quantity' => $item->quantity,
|
||||
@ -145,7 +145,7 @@ public function create(array $data): Restock
|
||||
NotificationService::notify(
|
||||
roles: ['Owner', 'Developer', 'Admin Toko'],
|
||||
title: 'Restock Baru',
|
||||
body: 'Restock ' . ($stockType === ProductStockQuality::GOOD->value ? 'produk' : 'reject') . ' sebesar Rp ' . number_format($subtotal, 0, ',', '.') . ' berhasil dicatat oleh ' . auth()->user()->full_name . '.',
|
||||
body: 'Restock '.($stockType === ProductStockQuality::GOOD->value ? 'produk' : 'reject').' sebesar Rp '.number_format($subtotal, 0, ',', '.').' berhasil dicatat oleh '.auth()->user()->full_name.'.',
|
||||
url: route('admin.manage.restocks.index'),
|
||||
);
|
||||
|
||||
@ -219,7 +219,7 @@ private function buildItemRows(array $items, string $stockType, $now, int &$subt
|
||||
->get()
|
||||
->mapWithKeys(function (ProductVariant $variant) use ($priceType) {
|
||||
$price = $variant->productPrices
|
||||
->first(fn($p) => $p->type === $priceType);
|
||||
->first(fn ($p) => $p->type === $priceType);
|
||||
|
||||
return [$variant->id => $price?->price ?? 0];
|
||||
});
|
||||
|
||||
@ -53,18 +53,18 @@ public function paginated(int $perPage = 25, string $search = '', string $sort =
|
||||
'orderItems.productVariant.product:id,name',
|
||||
])
|
||||
->when($search, function ($q) use ($search) {
|
||||
$q->whereHas('orderItems.productVariant.product', fn($sq) => $sq->where('name', 'like', "%{$search}%"))
|
||||
$q->whereHas('orderItems.productVariant.product', fn ($sq) => $sq->where('name', 'like', "%{$search}%"))
|
||||
->orWhere('order_number', 'like', "%{$search}%")
|
||||
->orWhere('notes', 'like', "%{$search}%");
|
||||
})
|
||||
->when($filters['status'] ?? null, fn($q, $status) => $q->where('status', $status))
|
||||
->when($filters['channel'] ?? null, fn($q, $channel) => $q->where('channel', $channel))
|
||||
->when($filters['payment_type'] ?? null, fn($q, $paymentType) => $q->where('payment_type', $paymentType))
|
||||
->when($filters['customer_id'] ?? null, fn($q, $customerId) => $q->where('customer_id', $customerId))
|
||||
->when($filters['marketing_id'] ?? null, fn($q, $marketingId) => $q->where('marketing_id', $marketingId))
|
||||
->when($filters['created_by_id'] ?? null, fn($q, $createdById) => $q->where('created_by_id', $createdById))
|
||||
->when($filters['date_from'] ?? null, fn($q, $dateFrom) => $q->whereDate('created_at', '>=', $dateFrom))
|
||||
->when($filters['date_to'] ?? null, fn($q, $dateTo) => $q->whereDate('created_at', '<=', $dateTo))
|
||||
->when($filters['status'] ?? null, fn ($q, $status) => $q->where('status', $status))
|
||||
->when($filters['channel'] ?? null, fn ($q, $channel) => $q->where('channel', $channel))
|
||||
->when($filters['payment_type'] ?? null, fn ($q, $paymentType) => $q->where('payment_type', $paymentType))
|
||||
->when($filters['customer_id'] ?? null, fn ($q, $customerId) => $q->where('customer_id', $customerId))
|
||||
->when($filters['marketing_id'] ?? null, fn ($q, $marketingId) => $q->where('marketing_id', $marketingId))
|
||||
->when($filters['created_by_id'] ?? null, fn ($q, $createdById) => $q->where('created_by_id', $createdById))
|
||||
->when($filters['date_from'] ?? null, fn ($q, $dateFrom) => $q->whereDate('created_at', '>=', $dateFrom))
|
||||
->when($filters['date_to'] ?? null, fn ($q, $dateTo) => $q->whereDate('created_at', '<=', $dateTo))
|
||||
->orderBy($sort, $direction)
|
||||
->paginate($perPage);
|
||||
|
||||
@ -99,14 +99,14 @@ public function getSummary(array $filters = []): array
|
||||
->selectRaw('COALESCE(SUM(subtotal) - SUM(COALESCE(nego_price, subtotal)), 0) as total_discount')
|
||||
->selectRaw('COALESCE(SUM(total_amount), 0) as total_amount')
|
||||
->selectRaw('COALESCE(SUM(cogs), 0) as total_cogs')
|
||||
->when($filters['status'] ?? null, fn($q, $status) => $q->where('status', $status))
|
||||
->when($filters['channel'] ?? null, fn($q, $channel) => $q->where('channel', $channel))
|
||||
->when($filters['payment_type'] ?? null, fn($q, $paymentType) => $q->where('payment_type', $paymentType))
|
||||
->when($filters['customer_id'] ?? null, fn($q, $customerId) => $q->where('customer_id', $customerId))
|
||||
->when($filters['marketing_id'] ?? null, fn($q, $marketingId) => $q->where('marketing_id', $marketingId))
|
||||
->when($filters['created_by_id'] ?? null, fn($q, $createdById) => $q->where('created_by_id', $createdById))
|
||||
->when($filters['date_from'] ?? null, fn($q, $dateFrom) => $q->whereDate('created_at', '>=', $dateFrom))
|
||||
->when($filters['date_to'] ?? null, fn($q, $dateTo) => $q->whereDate('created_at', '<=', $dateTo))
|
||||
->when($filters['status'] ?? null, fn ($q, $status) => $q->where('status', $status))
|
||||
->when($filters['channel'] ?? null, fn ($q, $channel) => $q->where('channel', $channel))
|
||||
->when($filters['payment_type'] ?? null, fn ($q, $paymentType) => $q->where('payment_type', $paymentType))
|
||||
->when($filters['customer_id'] ?? null, fn ($q, $customerId) => $q->where('customer_id', $customerId))
|
||||
->when($filters['marketing_id'] ?? null, fn ($q, $marketingId) => $q->where('marketing_id', $marketingId))
|
||||
->when($filters['created_by_id'] ?? null, fn ($q, $createdById) => $q->where('created_by_id', $createdById))
|
||||
->when($filters['date_from'] ?? null, fn ($q, $dateFrom) => $q->whereDate('created_at', '>=', $dateFrom))
|
||||
->when($filters['date_to'] ?? null, fn ($q, $dateTo) => $q->whereDate('created_at', '<=', $dateTo))
|
||||
->first();
|
||||
|
||||
return [
|
||||
@ -134,9 +134,9 @@ public function getFilterOptions(): array
|
||||
->with('userProfile:id,user_id,full_name')
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->filter(fn(User $user) => $user->userProfile?->full_name)
|
||||
->filter(fn (User $user) => $user->userProfile?->full_name)
|
||||
->values()
|
||||
->map(fn(User $user) => [
|
||||
->map(fn (User $user) => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->userProfile->full_name,
|
||||
]),
|
||||
@ -162,7 +162,7 @@ public function getForCreate(): array
|
||||
? $this->s3Service->getTemporaryUrl($media->file_name)
|
||||
: null;
|
||||
|
||||
$prices = $variant->productPrices->mapWithKeys(fn($p) => [$p->type->value => $p->price]);
|
||||
$prices = $variant->productPrices->mapWithKeys(fn ($p) => [$p->type->value => $p->price]);
|
||||
$variant->prices = $prices;
|
||||
});
|
||||
}),
|
||||
@ -176,11 +176,11 @@ public function getForCreate(): array
|
||||
->with('userProfile:id,user_id,full_name')
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->filter(fn(User $user) => $user->userProfile?->full_name)
|
||||
->filter(fn (User $user) => $user->userProfile?->full_name)
|
||||
->values(),
|
||||
'channelOptions' => OrderChannel::toSelect(),
|
||||
'paymentTypeOptions' => PaymentType::toSelect(),
|
||||
'priceTypeOptions' => PriceType::toSelect()->filter(fn($p) => $p['value'] !== PriceType::CAPITAL->value)->values(),
|
||||
'priceTypeOptions' => PriceType::toSelect()->filter(fn ($p) => $p['value'] !== PriceType::CAPITAL->value)->values(),
|
||||
];
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ public function getForEdit(Order $order): array
|
||||
'photo_url' => $media
|
||||
? $this->s3Service->getTemporaryUrl($media->file_name)
|
||||
: null,
|
||||
'items' => $order->orderItems->map(fn(OrderItem $item) => [
|
||||
'items' => $order->orderItems->map(fn (OrderItem $item) => [
|
||||
'id' => $item->id,
|
||||
'product_variant_id' => $item->product_variant_id,
|
||||
'quantity' => $item->quantity,
|
||||
@ -270,7 +270,7 @@ public function create(array $data): Order
|
||||
NotificationService::notify(
|
||||
roles: ['Owner', 'Developer', 'Admin Toko'],
|
||||
title: 'Transaksi Baru',
|
||||
body: 'Transaksi ' . $order->order_number . ' sebesar Rp ' . number_format($totalAmount, 0, ',', '.') . ' berhasil dicatat oleh ' . auth()->user()->full_name . '.',
|
||||
body: 'Transaksi '.$order->order_number.' sebesar Rp '.number_format($totalAmount, 0, ',', '.').' berhasil dicatat oleh '.auth()->user()->full_name.'.',
|
||||
url: route('admin.manage.transactions.index'),
|
||||
);
|
||||
|
||||
@ -379,14 +379,14 @@ private function buildItemRows(array $items, string $stockType, string $priceTyp
|
||||
|
||||
$prices = $variants->mapWithKeys(function (ProductVariant $variant) use ($resolvedPriceType) {
|
||||
$price = $variant->productPrices
|
||||
->first(fn($p) => $p->type === $resolvedPriceType);
|
||||
->first(fn ($p) => $p->type === $resolvedPriceType);
|
||||
|
||||
return [$variant->id => $price?->price ?? 0];
|
||||
});
|
||||
|
||||
$capitalPrices = $variants->mapWithKeys(function (ProductVariant $variant) {
|
||||
$price = $variant->productPrices
|
||||
->first(fn($p) => $p->type === PriceType::CAPITAL);
|
||||
->first(fn ($p) => $p->type === PriceType::CAPITAL);
|
||||
|
||||
return [$variant->id => $price?->price ?? 0];
|
||||
});
|
||||
@ -429,6 +429,6 @@ private function generateOrderNumber(): string
|
||||
$sequence = 1;
|
||||
}
|
||||
|
||||
return $prefix . $date . str_pad($sequence, 4, '0', STR_PAD_LEFT);
|
||||
return $prefix.$date.str_pad($sequence, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,11 +3,58 @@
|
||||
namespace App\Services\Concerns;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
trait RegistersMedia
|
||||
{
|
||||
private function registerMediaFromBase64(
|
||||
Model $model,
|
||||
string $base64Data,
|
||||
string $collectionName,
|
||||
string $folder,
|
||||
): void {
|
||||
$dataUrl = $base64Data;
|
||||
$mime = 'image/jpeg';
|
||||
|
||||
if (preg_match('/^data:(.+?);base64,/', $dataUrl, $matches)) {
|
||||
$mime = $matches[1];
|
||||
$dataUrl = preg_replace('/^data:.+?;base64,/', '', $dataUrl);
|
||||
}
|
||||
|
||||
$binary = base64_decode($dataUrl, true);
|
||||
|
||||
if ($binary === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$extension = match ($mime) {
|
||||
'image/png' => 'png',
|
||||
'image/webp' => 'webp',
|
||||
'image/gif' => 'gif',
|
||||
default => 'jpg',
|
||||
};
|
||||
|
||||
$date = now()->format('Y/m/d');
|
||||
$uuid = Str::uuid();
|
||||
$key = "{$folder}/{$date}/{$uuid}/photo.{$extension}";
|
||||
|
||||
Storage::disk('s3')->put($key, $binary, [
|
||||
'ContentType' => $mime,
|
||||
'ACL' => 'public-read',
|
||||
]);
|
||||
|
||||
$this->registerMedia(
|
||||
model: $model,
|
||||
s3Key: $key,
|
||||
collectionName: $collectionName,
|
||||
mimeType: $mime,
|
||||
fileSize: strlen($binary),
|
||||
orderColumn: 1,
|
||||
);
|
||||
}
|
||||
|
||||
private function registerMedia(
|
||||
Model $model,
|
||||
string $s3Key,
|
||||
|
||||
@ -21,14 +21,14 @@ public function run(): void
|
||||
'leave_requests' => ['view', 'create', 'update', 'delete', 'verify'],
|
||||
'categories' => ['view', 'create', 'update', 'delete'],
|
||||
'customers' => ['view', 'create', 'update', 'delete'],
|
||||
'products' => ['view', 'create', 'update', 'delete', 'toggle_status'],
|
||||
'products' => ['view', 'create', 'update', 'delete', 'toggle_status', 'transfer_stock', 'view_stock_mutations'],
|
||||
'stocks' => ['view'],
|
||||
'orders' => ['view', 'create', 'update', 'delete', 'send', 'complete', 'cancel'],
|
||||
'cuttings' => ['view', 'create', 'update', 'delete', 'complete'],
|
||||
'cash' => ['view', 'deposit', 'withdraw', 'update', 'delete'],
|
||||
'expenses' => ['view', 'create', 'update', 'delete'],
|
||||
'activity_logs' => ['view'],
|
||||
'employee_advances' => ['view', 'create', 'update', 'delete', 'pay', 'verify'],
|
||||
'employee_advances' => ['view', 'create', 'update', 'delete', 'pay', 'view_payments', 'verify'],
|
||||
'payroll' => ['view', 'pay', 'cancel', 'adjust'],
|
||||
'owner_verifications' => ['view', 'verify', 'reject'],
|
||||
'restocks' => ['view', 'create', 'update', 'delete'],
|
||||
@ -60,7 +60,7 @@ public function run(): void
|
||||
|
||||
$developerOwnerPerms = array_values(array_filter(
|
||||
$allPermissions,
|
||||
fn ($p) => ! in_array($p, $excludedFromDeveloperOwner, true)
|
||||
fn($p) => ! in_array($p, $excludedFromDeveloperOwner, true)
|
||||
));
|
||||
|
||||
$rolePermissions = [
|
||||
@ -92,7 +92,6 @@ public function run(): void
|
||||
'analysis.top_products',
|
||||
'analysis.marketing_sales',
|
||||
|
||||
'stocks.view',
|
||||
'stok_opnames.view',
|
||||
|
||||
'attendances.view',
|
||||
@ -124,6 +123,8 @@ public function run(): void
|
||||
'products.update',
|
||||
'products.delete',
|
||||
'products.toggle_status',
|
||||
'products.transfer_stock',
|
||||
'products.view_stock_mutations',
|
||||
|
||||
'owner_verifications.view',
|
||||
|
||||
@ -153,9 +154,12 @@ public function run(): void
|
||||
'employee_advances.update',
|
||||
'employee_advances.delete',
|
||||
'employee_advances.pay',
|
||||
'employee_advances.view_payments',
|
||||
|
||||
'payroll.view',
|
||||
'payroll.adjust',
|
||||
'payroll.pay',
|
||||
'payroll.cancel',
|
||||
|
||||
'settings.view_system',
|
||||
'settings.update_system',
|
||||
@ -220,9 +224,9 @@ public function run(): void
|
||||
'employee_advances.update',
|
||||
'employee_advances.delete',
|
||||
'employee_advances.pay',
|
||||
'employee_advances.view_payments',
|
||||
|
||||
'payroll.view',
|
||||
'payroll.adjust',
|
||||
], true);
|
||||
})),
|
||||
|
||||
@ -250,7 +254,6 @@ public function run(): void
|
||||
'raw_materials.create',
|
||||
'raw_materials.update',
|
||||
'raw_materials.toggle_status',
|
||||
'stocks.view',
|
||||
|
||||
'owner_verifications.view',
|
||||
|
||||
@ -308,6 +311,7 @@ public function run(): void
|
||||
'employee_advances.update',
|
||||
'employee_advances.delete',
|
||||
'employee_advances.pay',
|
||||
'employee_advances.view_payments',
|
||||
|
||||
'payroll.view',
|
||||
], true);
|
||||
@ -346,6 +350,7 @@ public function run(): void
|
||||
'employee_advances.update',
|
||||
'employee_advances.delete',
|
||||
'employee_advances.pay',
|
||||
'employee_advances.view_payments',
|
||||
|
||||
'payroll.view',
|
||||
], true);
|
||||
@ -361,6 +366,7 @@ public function run(): void
|
||||
'dashboard.orders_payment',
|
||||
'dashboard.orders_marketing',
|
||||
'dashboard.orders_status',
|
||||
|
||||
'analysis.view',
|
||||
'analysis.attendance',
|
||||
'analysis.cash',
|
||||
@ -375,29 +381,38 @@ public function run(): void
|
||||
'analysis.top_customers',
|
||||
'analysis.top_products',
|
||||
'analysis.marketing_sales',
|
||||
|
||||
'employees.view',
|
||||
|
||||
'attendances.view',
|
||||
'attendances.create',
|
||||
'attendances.delete',
|
||||
'attendances.manage',
|
||||
|
||||
'leave_requests.view',
|
||||
'leave_requests.create',
|
||||
'leave_requests.update',
|
||||
'leave_requests.delete',
|
||||
|
||||
'categories.view',
|
||||
|
||||
'customers.view',
|
||||
|
||||
'products.view',
|
||||
'stocks.view',
|
||||
|
||||
'orders.view',
|
||||
'cuttings.view',
|
||||
|
||||
'cash.view',
|
||||
|
||||
'expenses.view',
|
||||
|
||||
'activity_logs.view',
|
||||
|
||||
'employee_advances.view',
|
||||
'employee_advances.create',
|
||||
'employee_advances.update',
|
||||
'employee_advances.delete',
|
||||
'employee_advances.pay',
|
||||
|
||||
'payroll.view',
|
||||
], true);
|
||||
})),
|
||||
@ -405,19 +420,23 @@ public function run(): void
|
||||
'non-operator' => array_values(array_filter($allPermissions, function ($p) {
|
||||
return in_array($p, [
|
||||
'dashboard.view',
|
||||
|
||||
'analysis.view',
|
||||
'analysis.attendance',
|
||||
|
||||
'attendances.view',
|
||||
'attendances.create',
|
||||
|
||||
'leave_requests.view',
|
||||
'leave_requests.create',
|
||||
'leave_requests.update',
|
||||
'leave_requests.delete',
|
||||
|
||||
'employee_advances.view',
|
||||
'employee_advances.create',
|
||||
'employee_advances.update',
|
||||
'employee_advances.delete',
|
||||
'employee_advances.pay',
|
||||
|
||||
'payroll.view',
|
||||
], true);
|
||||
})),
|
||||
@ -425,24 +444,28 @@ public function run(): void
|
||||
'stok-opname' => array_values(array_filter($allPermissions, function ($p) {
|
||||
return in_array($p, [
|
||||
'dashboard.view',
|
||||
|
||||
'attendances.view',
|
||||
'attendances.create',
|
||||
|
||||
'leave_requests.view',
|
||||
'leave_requests.create',
|
||||
'leave_requests.update',
|
||||
'leave_requests.delete',
|
||||
|
||||
'products.view',
|
||||
'stocks.view',
|
||||
|
||||
'stok_opnames.view',
|
||||
'stok_opnames.create',
|
||||
'stok_opnames.update',
|
||||
'stok_opnames.delete',
|
||||
'stok_opnames.submit',
|
||||
|
||||
'employee_advances.view',
|
||||
'employee_advances.create',
|
||||
'employee_advances.update',
|
||||
'employee_advances.delete',
|
||||
'employee_advances.pay',
|
||||
|
||||
'payroll.view',
|
||||
], true);
|
||||
})),
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
import L from 'leaflet';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
|
||||
interface LocationMapProps {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
@ -13,52 +9,18 @@ export function LocationMap({
|
||||
latitude,
|
||||
longitude,
|
||||
height = '250px',
|
||||
zoom = 15,
|
||||
zoom = 17,
|
||||
}: LocationMapProps) {
|
||||
const mapRef = useRef<HTMLDivElement>(null);
|
||||
const mapInstanceRef = useRef<L.Map | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mapRef.current || mapInstanceRef.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
const map = L.map(mapRef.current, {
|
||||
center: [latitude, longitude],
|
||||
zoom,
|
||||
zoomControl: false,
|
||||
attributionControl: true,
|
||||
});
|
||||
|
||||
L.control.zoom({ position: 'topright' }).addTo(map);
|
||||
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution:
|
||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
|
||||
}).addTo(map);
|
||||
|
||||
const icon = L.divIcon({
|
||||
html: `<div style="background: #ef4444; width: 24px; height: 24px; border-radius: 50%; border: 3px solid white; box-shadow: 0 2px 6px rgba(0,0,0,0.3);"></div>`,
|
||||
className: '',
|
||||
iconSize: [24, 24],
|
||||
iconAnchor: [12, 12],
|
||||
});
|
||||
|
||||
L.marker([latitude, longitude], { icon }).addTo(map);
|
||||
|
||||
mapInstanceRef.current = map;
|
||||
|
||||
return () => {
|
||||
map.remove();
|
||||
mapInstanceRef.current = null;
|
||||
};
|
||||
}, [latitude, longitude, zoom]);
|
||||
const src = `https://maps.google.com/maps?q=${latitude},${longitude}&z=${zoom}&t=k&output=embed`;
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={mapRef}
|
||||
style={{ height, width: '100%' }}
|
||||
<iframe
|
||||
src={src}
|
||||
style={{ height, width: '100%', border: 0 }}
|
||||
className="rounded-lg"
|
||||
loading="lazy"
|
||||
referrerPolicy="no-referrer-when-downgrade"
|
||||
title="Lokasi Presensi"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ export function createCashAccountColumns(
|
||||
): ColumnDef<CashAccount>[] {
|
||||
const { handleEdit, handleDeleteClick, can } = params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<CashAccount>[] = [
|
||||
{
|
||||
accessorKey: 'name',
|
||||
header: () => <span>Nama</span>,
|
||||
@ -39,7 +39,10 @@ export function createCashAccountColumns(
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (can('cash.update') || can('cash.delete')) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -70,6 +73,8 @@ export function createCashAccountColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type { ColumnDef } from '@tanstack/react-table';
|
||||
import { Pencil, Trash2 } from 'lucide-react';
|
||||
import { ImagePreviewButton } from '@/components/image-preview-button';
|
||||
import { RowActions } from '@/components/row-actions';
|
||||
import type { ColumnDef } from '@tanstack/react-table';
|
||||
import { Pencil, Trash2 } from 'lucide-react';
|
||||
|
||||
export type CashTransaction = {
|
||||
id: number;
|
||||
@ -30,23 +30,12 @@ function getTypeLabel(type: string): string {
|
||||
deposit: 'Deposit',
|
||||
withdrawal: 'Withdrawal',
|
||||
expense: 'Pengeluaran',
|
||||
transfer: 'Transfer',
|
||||
employee_advance: 'Kasbon',
|
||||
};
|
||||
|
||||
return labels[type] ?? type;
|
||||
}
|
||||
|
||||
function getReferenceLabel(type: string): string {
|
||||
const labels: Record<string, string> = {
|
||||
'App\\Models\\Expense': 'Pengeluaran',
|
||||
'App\\Models\\Order': 'Penjualan Tunai',
|
||||
'App\\Models\\Purchase': 'Belanja',
|
||||
'App\\Models\\CashAccount': 'Transfer Kas',
|
||||
};
|
||||
|
||||
return labels[type] ?? '-';
|
||||
}
|
||||
|
||||
type CreateColumnsParams = {
|
||||
handleEdit: (transaction: CashTransaction) => void;
|
||||
handleDeleteClick: (transaction: CashTransaction) => void;
|
||||
@ -58,7 +47,7 @@ export function createTransactionColumns(
|
||||
): ColumnDef<CashTransaction>[] {
|
||||
const { handleEdit, handleDeleteClick, can } = params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<CashTransaction>[] = [
|
||||
{
|
||||
accessorKey: 'formatted_created_at',
|
||||
header: () => <span>Tanggal</span>,
|
||||
@ -77,11 +66,6 @@ export function createTransactionColumns(
|
||||
<span className="font-medium">
|
||||
{getTypeLabel(transaction.type)}
|
||||
</span>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{getReferenceLabel(
|
||||
transaction.reference?.type ?? '',
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
@ -152,7 +136,10 @@ export function createTransactionColumns(
|
||||
return <span>{createdBy?.user_profile?.full_name ?? '-'}</span>;
|
||||
},
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (can('cash.update') || can('cash.delete')) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -190,6 +177,8 @@ export function createTransactionColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ export function createEmployeeAdvanceColumns(
|
||||
const { handleEdit, handleDeleteClick, handleApprove, handlePay, handleShowPayments, can, authUserId } =
|
||||
params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<EmployeeAdvance>[] = [
|
||||
{
|
||||
accessorKey: 'formatted_created_at',
|
||||
header: () => <span>Tanggal</span>,
|
||||
@ -162,7 +162,16 @@ export function createEmployeeAdvanceColumns(
|
||||
<span>{getStatusBadge(row.getValue('status') as string)}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (
|
||||
can('employee_advances.verify') ||
|
||||
can('employee_advances.pay') ||
|
||||
can('employee_advances.view_payments') ||
|
||||
can('employee_advances.update') ||
|
||||
can('employee_advances.delete')
|
||||
) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -198,7 +207,7 @@ export function createEmployeeAdvanceColumns(
|
||||
{
|
||||
label: 'Riwayat',
|
||||
icon: <History className="h-4 w-4" />,
|
||||
show: employeeAdvance.payments.length > 0,
|
||||
show: can('employee_advances.view_payments') && employeeAdvance.payments.length > 0,
|
||||
onClick: () => handleShowPayments(employeeAdvance),
|
||||
},
|
||||
{
|
||||
@ -226,6 +235,8 @@ export function createEmployeeAdvanceColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ export function createExpenseColumns(
|
||||
): ColumnDef<Expense>[] {
|
||||
const { handleEdit, handleDeleteClick, can } = params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<Expense>[] = [
|
||||
{
|
||||
accessorKey: 'formatted_created_at',
|
||||
header: () => <span>Tanggal</span>,
|
||||
@ -69,8 +69,8 @@ export function createExpenseColumns(
|
||||
accessorKey: 'formatted_amount',
|
||||
header: () => <span>Jumlah</span>,
|
||||
cell: ({ row }) => (
|
||||
<span className="font-medium text-red-600">
|
||||
- {row.getValue('formatted_amount') as string}
|
||||
<span className="font-medium">
|
||||
{row.getValue('formatted_amount') as string}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
@ -83,7 +83,10 @@ export function createExpenseColumns(
|
||||
return <span>{createdBy?.user_profile?.full_name ?? '-'}</span>;
|
||||
},
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (can('expenses.update') || can('expenses.delete')) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -114,6 +117,8 @@ export function createExpenseColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -174,58 +174,57 @@ export function createPayrollPeriodColumns(
|
||||
});
|
||||
}
|
||||
|
||||
columns.push(
|
||||
{
|
||||
accessorKey: 'status',
|
||||
header: () => <span>Status</span>,
|
||||
cell: ({ row }) => (
|
||||
<span>{getStatusBadge(row.getValue('status') as string)}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
className: 'w-[100px] text-center',
|
||||
headerClassName: 'w-[100px] text-center',
|
||||
},
|
||||
cell: ({ row }) => {
|
||||
const period = row.original;
|
||||
columns.push({
|
||||
accessorKey: 'status',
|
||||
header: () => <span>Status</span>,
|
||||
cell: ({ row }) => (
|
||||
<span>{getStatusBadge(row.getValue('status') as string)}</span>
|
||||
),
|
||||
});
|
||||
|
||||
return (
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Lihat Detail',
|
||||
icon: <Eye className="h-4 w-4" />,
|
||||
href: showUrl(period.id),
|
||||
},
|
||||
{
|
||||
label: 'Tutup Periode',
|
||||
icon: (
|
||||
<Lock className="h-4 w-4 text-orange-600" />
|
||||
),
|
||||
show:
|
||||
can('payroll.adjust') &&
|
||||
period.status === 'open',
|
||||
onClick: () => handleClose(period),
|
||||
},
|
||||
{
|
||||
label: 'Buka Periode',
|
||||
icon: (
|
||||
<Unlock className="h-4 w-4 text-blue-600" />
|
||||
),
|
||||
show:
|
||||
can('payroll.adjust') &&
|
||||
period.status === 'closed',
|
||||
onClick: () => handleReopen(period),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
},
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
className: 'w-[100px] text-center',
|
||||
headerClassName: 'w-[100px] text-center',
|
||||
},
|
||||
);
|
||||
cell: ({ row }) => {
|
||||
const period = row.original;
|
||||
|
||||
return (
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Lihat Detail',
|
||||
icon: <Eye className="h-4 w-4" />,
|
||||
href: showUrl(period.id),
|
||||
},
|
||||
{
|
||||
label: 'Tutup Periode',
|
||||
icon: (
|
||||
<Lock className="h-4 w-4 text-orange-600" />
|
||||
),
|
||||
show:
|
||||
can('payroll.adjust') &&
|
||||
period.status === 'open',
|
||||
onClick: () => handleClose(period),
|
||||
},
|
||||
{
|
||||
label: 'Buka Periode',
|
||||
icon: (
|
||||
<Unlock className="h-4 w-4 text-blue-600" />
|
||||
),
|
||||
show:
|
||||
can('payroll.adjust') &&
|
||||
period.status === 'closed',
|
||||
onClick: () => handleReopen(period),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ import { toast } from 'sonner';
|
||||
import { CameraCapture } from '@/components/camera-capture';
|
||||
import { LocationMap } from '@/components/location-map';
|
||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import {
|
||||
@ -44,6 +45,7 @@ type Attendance = {
|
||||
check_out_latitude: number | null;
|
||||
check_out_longitude: number | null;
|
||||
work_duration_minutes: number | null;
|
||||
employee_name: string;
|
||||
};
|
||||
|
||||
type MonthStats = {
|
||||
@ -58,11 +60,12 @@ type Props = {
|
||||
todayAttendance: Attendance | null;
|
||||
currentYear: number;
|
||||
currentMonth: number;
|
||||
monthStats: MonthStats;
|
||||
monthStats: MonthStats | null;
|
||||
hrSettings: {
|
||||
scheduled_check_in_time: string;
|
||||
scheduled_check_out_time: string;
|
||||
};
|
||||
isAdmin: boolean;
|
||||
};
|
||||
|
||||
const WEEKDAYS = ['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'];
|
||||
@ -83,16 +86,6 @@ function isSameDay(d1: Date, d2: Date): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function checkIsToday(date: Date): boolean {
|
||||
const t = new Date();
|
||||
|
||||
return (
|
||||
date.getDate() === t.getDate() &&
|
||||
date.getMonth() === t.getMonth() &&
|
||||
date.getFullYear() === t.getFullYear()
|
||||
);
|
||||
}
|
||||
|
||||
function isWeekend(date: Date): boolean {
|
||||
const day = date.getDay();
|
||||
|
||||
@ -105,8 +98,8 @@ function isLate(
|
||||
officeMinute: number,
|
||||
): boolean {
|
||||
if (!checkInAt) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const d = new Date(checkInAt);
|
||||
const h = d.getHours();
|
||||
@ -121,8 +114,8 @@ function getLateMinutes(
|
||||
officeMinute: number,
|
||||
): number {
|
||||
if (!checkInAt || !isLate(checkInAt, officeHour, officeMinute)) {
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const d = new Date(checkInAt);
|
||||
const officeStart = new Date(d);
|
||||
@ -133,15 +126,15 @@ return 0;
|
||||
|
||||
function formatMinutes(minutes: number | null): string {
|
||||
if (!minutes) {
|
||||
return '-';
|
||||
}
|
||||
return '-';
|
||||
}
|
||||
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const mins = Math.floor(minutes % 60);
|
||||
|
||||
if (mins === 0) {
|
||||
return `${hours} jam`;
|
||||
}
|
||||
return `${hours} jam`;
|
||||
}
|
||||
|
||||
return `${hours} jam ${mins} menit`;
|
||||
}
|
||||
@ -153,6 +146,7 @@ export default function AttendanceIndex({
|
||||
currentMonth,
|
||||
monthStats,
|
||||
hrSettings,
|
||||
isAdmin,
|
||||
}: Props) {
|
||||
const [officeHour, officeMinute] = hrSettings.scheduled_check_in_time
|
||||
.split(':')
|
||||
@ -173,21 +167,17 @@ export default function AttendanceIndex({
|
||||
const viewYear = viewDate.getFullYear();
|
||||
const viewMonth = viewDate.getMonth() + 1;
|
||||
|
||||
const attendanceDates = useMemo(() => {
|
||||
const dates = new Map<string, Attendance>();
|
||||
const attendanceByDate = useMemo(() => {
|
||||
const map = new Map<string, Attendance[]>();
|
||||
attendances.forEach((att) => {
|
||||
dates.set(att.attendance_date, att);
|
||||
const existing = map.get(att.attendance_date) ?? [];
|
||||
existing.push(att);
|
||||
map.set(att.attendance_date, existing);
|
||||
});
|
||||
|
||||
return dates;
|
||||
return map;
|
||||
}, [attendances]);
|
||||
|
||||
const selectedAttendance = useMemo(() => {
|
||||
const dateStr = format(selectedDate, 'yyyy-MM-dd');
|
||||
|
||||
return attendanceDates.get(dateStr) ?? null;
|
||||
}, [selectedDate, attendanceDates]);
|
||||
|
||||
const calendarDays = useMemo(() => {
|
||||
const daysInMonth = getDaysInMonth(viewYear, viewMonth);
|
||||
const firstDay = getFirstDayOfMonth(viewYear, viewMonth);
|
||||
@ -232,8 +222,51 @@ export default function AttendanceIndex({
|
||||
return days;
|
||||
}, [viewYear, viewMonth]);
|
||||
|
||||
const handlePrevMonth = () => setViewDate((d) => subMonths(d, 1));
|
||||
const handleNextMonth = () => setViewDate((d) => addMonths(d, 1));
|
||||
const handlePrevMonth = () => {
|
||||
const newDate = subMonths(viewDate, 1);
|
||||
setViewDate(newDate);
|
||||
|
||||
if (!isAdmin) {
|
||||
router.get(
|
||||
attendanceIndex.url(),
|
||||
{
|
||||
year: newDate.getFullYear(),
|
||||
month: newDate.getMonth() + 1,
|
||||
},
|
||||
{ preserveState: true, preserveScroll: true },
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleNextMonth = () => {
|
||||
const newDate = addMonths(viewDate, 1);
|
||||
setViewDate(newDate);
|
||||
|
||||
if (!isAdmin) {
|
||||
router.get(
|
||||
attendanceIndex.url(),
|
||||
{
|
||||
year: newDate.getFullYear(),
|
||||
month: newDate.getMonth() + 1,
|
||||
},
|
||||
{ preserveState: true, preserveScroll: true },
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleGoToToday = () => {
|
||||
const now = new Date();
|
||||
setViewDate(now);
|
||||
setSelectedDate(now);
|
||||
|
||||
if (!isAdmin) {
|
||||
router.get(
|
||||
attendanceIndex.url(),
|
||||
{ year: now.getFullYear(), month: now.getMonth() + 1 },
|
||||
{ preserveState: true, preserveScroll: true },
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCameraCapture = (dataUrl: string) => {
|
||||
setShowCamera(false);
|
||||
@ -290,8 +323,8 @@ export default function AttendanceIndex({
|
||||
|
||||
function formatTime(dateStr: string | null): string {
|
||||
if (!dateStr) {
|
||||
return '-';
|
||||
}
|
||||
return '-';
|
||||
}
|
||||
|
||||
return format(new Date(dateStr), 'HH:mm');
|
||||
}
|
||||
@ -305,167 +338,168 @@ return '-';
|
||||
<>
|
||||
<Head title="Presensi" />
|
||||
|
||||
<div className="flex h-full flex-1 flex-col gap-6 overflow-x-auto p-4 md:p-6">
|
||||
<div className="flex min-h-full flex-1 flex-col gap-6 overflow-auto p-4 md:p-6">
|
||||
<div>
|
||||
<h2 className="text-2xl font-semibold tracking-tight">
|
||||
Presensi
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
{/* Alert Status Presensi */}
|
||||
<Alert>
|
||||
<CalendarCheck className="h-4 w-4" />
|
||||
<AlertTitle>Presensi Hari Ini</AlertTitle>
|
||||
<AlertDescription>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
{hasCheckedIn ? (
|
||||
<div className="flex items-center gap-4 text-sm">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<CheckCircle2 className="h-3.5 w-3.5 text-green-600" />
|
||||
<span className="text-muted-foreground">
|
||||
Masuk:
|
||||
</span>
|
||||
<span className="font-medium">
|
||||
{formatTime(
|
||||
todayAttendance?.check_in_at,
|
||||
{!isAdmin && (
|
||||
<Alert>
|
||||
<CalendarCheck className="h-4 w-4" />
|
||||
<AlertTitle>Presensi Hari Ini</AlertTitle>
|
||||
<AlertDescription>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
{hasCheckedIn ? (
|
||||
<div className="flex items-center gap-4 text-sm">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<CheckCircle2 className="h-3.5 w-3.5 text-green-600" />
|
||||
<span className="text-muted-foreground">
|
||||
Masuk:
|
||||
</span>
|
||||
<span className="font-medium">
|
||||
{formatTime(
|
||||
todayAttendance?.check_in_at,
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
{hasCheckedOut ? (
|
||||
<>
|
||||
<CheckCircle2 className="h-3.5 w-3.5 text-green-600" />
|
||||
<span className="text-muted-foreground">
|
||||
Pulang:
|
||||
</span>
|
||||
<span className="font-medium">
|
||||
{formatTime(
|
||||
todayAttendance?.check_out_at,
|
||||
)}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Clock className="h-3.5 w-3.5 text-orange-500" />
|
||||
<span className="text-muted-foreground">
|
||||
Pulang:
|
||||
</span>
|
||||
<span className="font-medium text-orange-600">
|
||||
Belum
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
{hasCheckedOut ? (
|
||||
<>
|
||||
<CheckCircle2 className="h-3.5 w-3.5 text-green-600" />
|
||||
<span className="text-muted-foreground">
|
||||
Pulang:
|
||||
</span>
|
||||
<span className="font-medium">
|
||||
{formatTime(
|
||||
todayAttendance?.check_out_at,
|
||||
)}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Clock className="h-3.5 w-3.5 text-orange-500" />
|
||||
<span className="text-muted-foreground">
|
||||
Pulang:
|
||||
</span>
|
||||
<span className="font-medium text-orange-600">
|
||||
Belum
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Anda belum melakukan presensi hari ini
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Anda belum melakukan presensi hari ini
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{locationLoading && (
|
||||
<span className="text-xs text-muted-foreground">
|
||||
Mendapatkan lokasi...
|
||||
</span>
|
||||
)}
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleCheckIn}
|
||||
disabled={hasCheckedIn || locationLoading}
|
||||
>
|
||||
<LogIn className="mr-1.5 h-3.5 w-3.5" />
|
||||
Presensi Masuk
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={handleCheckOut}
|
||||
disabled={
|
||||
!hasCheckedIn ||
|
||||
hasCheckedOut ||
|
||||
locationLoading
|
||||
}
|
||||
>
|
||||
<LogOut className="mr-1.5 h-3.5 w-3.5" />
|
||||
Presensi Pulang
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{monthStats && (
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
|
||||
<Card>
|
||||
<CardContent className="flex items-center gap-3 py-3">
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-blue-100">
|
||||
<CalendarDays className="h-5 w-5 text-blue-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Hari Kerja
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{locationLoading && (
|
||||
<span className="text-xs text-muted-foreground">
|
||||
Mendapatkan lokasi...
|
||||
</span>
|
||||
)}
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleCheckIn}
|
||||
disabled={hasCheckedIn || locationLoading}
|
||||
>
|
||||
<LogIn className="mr-1.5 h-3.5 w-3.5" />
|
||||
Presensi Masuk
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={handleCheckOut}
|
||||
disabled={
|
||||
!hasCheckedIn ||
|
||||
hasCheckedOut ||
|
||||
locationLoading
|
||||
}
|
||||
>
|
||||
<LogOut className="mr-1.5 h-3.5 w-3.5" />
|
||||
Presensi Pulang
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
{/* Summary Stats */}
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
|
||||
<Card>
|
||||
<CardContent className="flex items-center gap-3 py-3">
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-blue-100">
|
||||
<CalendarDays className="h-5 w-5 text-blue-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Hari Kerja
|
||||
</p>
|
||||
<p className="text-lg font-bold">
|
||||
{monthStats.working_days}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="flex items-center gap-3 py-3">
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-green-100">
|
||||
<CheckCircle2 className="h-5 w-5 text-green-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Hadir
|
||||
</p>
|
||||
<p className="text-lg font-bold">
|
||||
{monthStats.present}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="flex items-center gap-3 py-3">
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-red-100">
|
||||
<UserX className="h-5 w-5 text-red-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Tidak Hadir
|
||||
</p>
|
||||
<p className="text-lg font-bold">
|
||||
{monthStats.absent}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="flex items-center gap-3 py-3">
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-amber-100">
|
||||
<Wallet className="h-5 w-5 text-amber-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Cuti
|
||||
</p>
|
||||
<p className="text-lg font-bold">
|
||||
{monthStats.leave}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
<p className="text-lg font-bold">
|
||||
{monthStats.working_days}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="flex items-center gap-3 py-3">
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-green-100">
|
||||
<CheckCircle2 className="h-5 w-5 text-green-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Hadir
|
||||
</p>
|
||||
<p className="text-lg font-bold">
|
||||
{monthStats.present}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="flex items-center gap-3 py-3">
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-red-100">
|
||||
<UserX className="h-5 w-5 text-red-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Tidak Hadir
|
||||
</p>
|
||||
<p className="text-lg font-bold">
|
||||
{monthStats.absent}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card>
|
||||
<CardContent className="flex items-center gap-3 py-3">
|
||||
<div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-amber-100">
|
||||
<Wallet className="h-5 w-5 text-amber-600" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Cuti
|
||||
</p>
|
||||
<p className="text-lg font-bold">
|
||||
{monthStats.leave}
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Card
|
||||
className="overflow-hidden"
|
||||
style={{ '--card-spacing': '0px' } as React.CSSProperties}
|
||||
>
|
||||
{/* Calendar Header */}
|
||||
<div className="flex items-center justify-between border-b px-6 py-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex flex-col items-center overflow-hidden rounded-lg ring-1 ring-border">
|
||||
@ -503,10 +537,7 @@ return '-';
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-8 px-3 text-xs font-medium"
|
||||
onClick={() => {
|
||||
setViewDate(new Date());
|
||||
setSelectedDate(new Date());
|
||||
}}
|
||||
onClick={handleGoToToday}
|
||||
>
|
||||
Hari ini
|
||||
</Button>
|
||||
@ -521,7 +552,6 @@ return '-';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Weekday Headers */}
|
||||
<div className="grid grid-cols-7 border-b">
|
||||
{WEEKDAYS.map((day) => (
|
||||
<div
|
||||
@ -533,11 +563,10 @@ return '-';
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Calendar Grid */}
|
||||
<div className="grid grid-cols-7">
|
||||
{calendarDays.map((cell, idx) => {
|
||||
const dateStr = format(cell.date, 'yyyy-MM-dd');
|
||||
const attendance = attendanceDates.get(dateStr);
|
||||
const dayAttendances = attendanceByDate.get(dateStr) ?? [];
|
||||
const isSelected = isSameDay(
|
||||
cell.date,
|
||||
selectedDate,
|
||||
@ -547,47 +576,33 @@ return '-';
|
||||
new Date(),
|
||||
);
|
||||
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
const todayMidnight = new Date();
|
||||
todayMidnight.setHours(0, 0, 0, 0);
|
||||
const cellDate = new Date(cell.date);
|
||||
cellDate.setHours(0, 0, 0, 0);
|
||||
|
||||
const isPastDate = cellDate < today;
|
||||
const isPastDate = cellDate < todayMidnight;
|
||||
const showAbsent =
|
||||
cell.isCurrentMonth &&
|
||||
isPastDate &&
|
||||
!isWeekend(cell.date) &&
|
||||
!attendance;
|
||||
|
||||
const late = attendance
|
||||
? isLate(
|
||||
attendance.check_in_at,
|
||||
officeHour,
|
||||
officeMinute,
|
||||
)
|
||||
: false;
|
||||
const lateMins = attendance
|
||||
? getLateMinutes(
|
||||
attendance.check_in_at,
|
||||
officeHour,
|
||||
officeMinute,
|
||||
)
|
||||
: 0;
|
||||
dayAttendances.length === 0;
|
||||
|
||||
return (
|
||||
<button
|
||||
<div
|
||||
key={idx}
|
||||
onClick={() => {
|
||||
setSelectedDate(cell.date);
|
||||
|
||||
if (attendance) {
|
||||
setDetailAttendance(attendance);
|
||||
}
|
||||
if (!isAdmin && dayAttendances.length > 0) {
|
||||
setDetailAttendance(dayAttendances[0]);
|
||||
}
|
||||
}}
|
||||
className={`group relative flex min-h-[100px] flex-col p-2 text-left transition-colors hover:bg-muted/50 ${
|
||||
!cell.isCurrentMonth
|
||||
? 'bg-muted/30 text-muted-foreground/50'
|
||||
: ''
|
||||
} ${isSelected ? 'bg-muted/50' : ''} ${
|
||||
!isAdmin && dayAttendances.length > 0 ? 'cursor-pointer' : ''
|
||||
}`}
|
||||
style={{
|
||||
borderRight: '1px solid var(--border)',
|
||||
@ -607,43 +622,89 @@ setDetailAttendance(attendance);
|
||||
{cell.day}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-1 flex flex-col gap-0.5">
|
||||
{attendance && (
|
||||
<div className="mt-1 flex flex-col gap-0.5 overflow-hidden">
|
||||
{isAdmin ? (
|
||||
<>
|
||||
<span
|
||||
className={`inline-flex items-center justify-center rounded-full px-1.5 py-0.5 text-[10px] font-semibold ${late ? 'bg-yellow-100 text-yellow-700' : 'bg-green-100 text-green-700'}`}
|
||||
>
|
||||
{late
|
||||
? 'Terlambat'
|
||||
: 'Hadir'}
|
||||
</span>
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
Masuk :{' '}
|
||||
{formatTime(
|
||||
attendance.check_in_at,
|
||||
)}
|
||||
</span>
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
Pulang :{' '}
|
||||
{formatTime(
|
||||
attendance.check_out_at,
|
||||
)}
|
||||
</span>
|
||||
{late && (
|
||||
<span className="text-[10px] text-yellow-600">
|
||||
Telat :{' '}
|
||||
{formatMinutes(
|
||||
lateMins,
|
||||
)}{' '}
|
||||
menit
|
||||
</span>
|
||||
)}
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
Jam Kerja :{' '}
|
||||
{formatMinutes(
|
||||
attendance.work_duration_minutes,
|
||||
)}
|
||||
</span>
|
||||
{dayAttendances.map((att) => {
|
||||
const late = isLate(
|
||||
att.check_in_at,
|
||||
officeHour,
|
||||
officeMinute,
|
||||
);
|
||||
|
||||
return (
|
||||
<button
|
||||
key={att.id}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setDetailAttendance(att);
|
||||
}}
|
||||
className="w-full"
|
||||
>
|
||||
<Badge
|
||||
variant={late ? 'destructive' : 'default'}
|
||||
className="w-full justify-center cursor-pointer truncate"
|
||||
>
|
||||
{att.employee_name}
|
||||
</Badge>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{dayAttendances.length > 0 && (() => {
|
||||
const att = dayAttendances[0];
|
||||
const late = isLate(
|
||||
att.check_in_at,
|
||||
officeHour,
|
||||
officeMinute,
|
||||
);
|
||||
const lateMins = getLateMinutes(
|
||||
att.check_in_at,
|
||||
officeHour,
|
||||
officeMinute,
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<span
|
||||
className={`inline-flex items-center justify-center rounded-full px-1.5 py-0.5 text-[10px] font-semibold ${late ? 'bg-yellow-100 text-yellow-700' : 'bg-green-100 text-green-700'}`}
|
||||
>
|
||||
{late
|
||||
? 'Terlambat'
|
||||
: 'Hadir'}
|
||||
</span>
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
Masuk :{' '}
|
||||
{formatTime(
|
||||
att.check_in_at,
|
||||
)}
|
||||
</span>
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
Pulang :{' '}
|
||||
{formatTime(
|
||||
att.check_out_at,
|
||||
)}
|
||||
</span>
|
||||
{late && (
|
||||
<span className="text-[10px] text-yellow-600">
|
||||
Telat :{' '}
|
||||
{formatMinutes(
|
||||
lateMins,
|
||||
)}{' '}
|
||||
menit
|
||||
</span>
|
||||
)}
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
Jam Kerja :{' '}
|
||||
{formatMinutes(
|
||||
att.work_duration_minutes,
|
||||
)}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</>
|
||||
)}
|
||||
{showAbsent && (
|
||||
@ -652,7 +713,7 @@ setDetailAttendance(attendance);
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
@ -673,6 +734,9 @@ setDetailAttendance(attendance);
|
||||
<DialogContent className="sm:max-w-2xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>
|
||||
{isAdmin && detailAttendance?.employee_name
|
||||
? `${detailAttendance.employee_name} - `
|
||||
: ''}
|
||||
Detail Presensi -{' '}
|
||||
{detailAttendance &&
|
||||
format(
|
||||
@ -749,19 +813,37 @@ setDetailAttendance(attendance);
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-sm font-medium text-muted-foreground">
|
||||
Lokasi Presensi
|
||||
</span>
|
||||
<LocationMap
|
||||
latitude={
|
||||
detailAttendance.check_in_latitude
|
||||
}
|
||||
longitude={
|
||||
detailAttendance.check_in_longitude
|
||||
}
|
||||
height="200px"
|
||||
/>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-sm font-medium text-muted-foreground">
|
||||
Lokasi Masuk
|
||||
</span>
|
||||
<LocationMap
|
||||
latitude={
|
||||
detailAttendance.check_in_latitude
|
||||
}
|
||||
longitude={
|
||||
detailAttendance.check_in_longitude
|
||||
}
|
||||
height="200px"
|
||||
/>
|
||||
</div>
|
||||
{detailAttendance.check_out_latitude && detailAttendance.check_out_longitude && (
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-sm font-medium text-muted-foreground">
|
||||
Lokasi Pulang
|
||||
</span>
|
||||
<LocationMap
|
||||
latitude={
|
||||
detailAttendance.check_out_latitude
|
||||
}
|
||||
longitude={
|
||||
detailAttendance.check_out_longitude
|
||||
}
|
||||
height="200px"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@ -54,7 +54,7 @@ export function createEmployeeColumns(
|
||||
canViewAll,
|
||||
} = params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<Employee>[] = [
|
||||
{
|
||||
accessorKey: 'user_profile.full_name',
|
||||
id: 'full_name',
|
||||
@ -154,7 +154,14 @@ export function createEmployeeColumns(
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (
|
||||
can('employees.update') ||
|
||||
can('employees.reset_password') ||
|
||||
can('employees.delete')
|
||||
) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -193,6 +200,8 @@ export function createEmployeeColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -161,35 +161,41 @@ export default function EmployeeEdit({ employee, roles, canViewAll }: Props) {
|
||||
*
|
||||
</span>
|
||||
</Label>
|
||||
<Combobox
|
||||
items={roles}
|
||||
itemToStringLabel={(r) => r.name}
|
||||
value={selectedRole}
|
||||
onValueChange={(value) =>
|
||||
setSelectedRole(value)
|
||||
}
|
||||
>
|
||||
<ComboboxInput
|
||||
placeholder="Cari role..."
|
||||
className="w-full"
|
||||
/>
|
||||
<ComboboxContent>
|
||||
<ComboboxEmpty>
|
||||
Tidak ada role
|
||||
ditemukan.
|
||||
</ComboboxEmpty>
|
||||
<ComboboxList>
|
||||
{(role) => (
|
||||
<ComboboxItem
|
||||
key={role.id}
|
||||
value={role}
|
||||
>
|
||||
{role.name}
|
||||
</ComboboxItem>
|
||||
)}
|
||||
</ComboboxList>
|
||||
</ComboboxContent>
|
||||
</Combobox>
|
||||
{canViewAll ? (
|
||||
<Combobox
|
||||
items={roles}
|
||||
itemToStringLabel={(r) => r.name}
|
||||
value={selectedRole}
|
||||
onValueChange={(value) =>
|
||||
setSelectedRole(value)
|
||||
}
|
||||
>
|
||||
<ComboboxInput
|
||||
placeholder="Cari role..."
|
||||
className="w-full"
|
||||
/>
|
||||
<ComboboxContent>
|
||||
<ComboboxEmpty>
|
||||
Tidak ada role
|
||||
ditemukan.
|
||||
</ComboboxEmpty>
|
||||
<ComboboxList>
|
||||
{(role) => (
|
||||
<ComboboxItem
|
||||
key={role.id}
|
||||
value={role}
|
||||
>
|
||||
{role.name}
|
||||
</ComboboxItem>
|
||||
)}
|
||||
</ComboboxList>
|
||||
</ComboboxContent>
|
||||
</Combobox>
|
||||
) : (
|
||||
<div className="flex h-10 w-full items-center rounded-md border border-input bg-muted px-3 py-2 text-sm">
|
||||
{selectedRole?.name ?? '-'}
|
||||
</div>
|
||||
)}
|
||||
<InputError
|
||||
message={errors.role}
|
||||
/>
|
||||
|
||||
@ -64,7 +64,7 @@ export function createLeaveRequestColumns(
|
||||
const { handleEdit, handleDeleteClick, handleApprove, handleReject, can } =
|
||||
params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<LeaveRequest>[] = [
|
||||
{
|
||||
id: 'employee_name',
|
||||
header: () => <span>Oleh</span>,
|
||||
@ -112,7 +112,14 @@ export function createLeaveRequestColumns(
|
||||
<span>{getStatusBadge(row.getValue('status') as string)}</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (
|
||||
can('leave_requests.verify') ||
|
||||
can('leave_requests.update') ||
|
||||
can('leave_requests.delete')
|
||||
) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -167,6 +174,8 @@ export function createLeaveRequestColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -139,25 +139,27 @@ export function CuttingCardRow({
|
||||
)}
|
||||
</div>
|
||||
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('cuttings.update'),
|
||||
onClick: () => onEdit(cutting),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('cuttings.delete'),
|
||||
onClick: () => onDelete(cutting),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
{(can('cuttings.update') || can('cuttings.delete')) && (
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('cuttings.update'),
|
||||
onClick: () => onEdit(cutting),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('cuttings.delete'),
|
||||
onClick: () => onDelete(cutting),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@ -126,25 +126,27 @@ export function PurchaseCardRow({
|
||||
)}
|
||||
</div>
|
||||
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('purchases.update'),
|
||||
onClick: () => onEdit(purchase),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('purchases.delete'),
|
||||
onClick: () => onDelete(purchase),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
{(can('purchases.update') || can('purchases.delete')) && (
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('purchases.update'),
|
||||
onClick: () => onEdit(purchase),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('purchases.delete'),
|
||||
onClick: () => onDelete(purchase),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@ -135,25 +135,27 @@ export function RestockCardRow({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('restocks.update'),
|
||||
onClick: () => onEdit(restock),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('restocks.delete'),
|
||||
onClick: () => onDelete(restock),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
{(can('restocks.update') || can('restocks.delete')) && (
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('restocks.update'),
|
||||
onClick: () => onEdit(restock),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('restocks.delete'),
|
||||
onClick: () => onDelete(restock),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@ -183,57 +183,59 @@ export function TransactionCardRow({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<RowActions
|
||||
actions={[
|
||||
...(transaction.status === 'pending' && can('orders.update')
|
||||
? [
|
||||
{
|
||||
label: 'Kirim',
|
||||
icon: <Send className="h-4 w-4" />,
|
||||
onClick: () => onUpdateStatus(transaction, 'processing'),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...((transaction.status === 'pending' || transaction.status === 'processing') && can('orders.update')
|
||||
? [
|
||||
{
|
||||
label: 'Selesai',
|
||||
icon: <CheckCircle className="h-4 w-4" />,
|
||||
onClick: () => onUpdateStatus(transaction, 'completed'),
|
||||
},
|
||||
{
|
||||
label: 'Dibatalkan',
|
||||
icon: <XCircle className="h-4 w-4 text-destructive" />,
|
||||
onClick: () => onUpdateStatus(transaction, 'cancelled'),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(transaction.status === 'completed' && can('orders.update')
|
||||
? [
|
||||
{
|
||||
label: 'Refund',
|
||||
icon: <XCircle className="h-4 w-4 text-destructive" />,
|
||||
onClick: () => onUpdateStatus(transaction, 'refunded'),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('orders.update'),
|
||||
onClick: () => onEdit(transaction),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('orders.delete'),
|
||||
onClick: () => onDelete(transaction),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
{(can('orders.update') || can('orders.delete')) && (
|
||||
<RowActions
|
||||
actions={[
|
||||
...(transaction.status === 'pending' && can('orders.update')
|
||||
? [
|
||||
{
|
||||
label: 'Kirim',
|
||||
icon: <Send className="h-4 w-4" />,
|
||||
onClick: () => onUpdateStatus(transaction, 'processing'),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...((transaction.status === 'pending' || transaction.status === 'processing') && can('orders.update')
|
||||
? [
|
||||
{
|
||||
label: 'Selesai',
|
||||
icon: <CheckCircle className="h-4 w-4" />,
|
||||
onClick: () => onUpdateStatus(transaction, 'completed'),
|
||||
},
|
||||
{
|
||||
label: 'Dibatalkan',
|
||||
icon: <XCircle className="h-4 w-4 text-destructive" />,
|
||||
onClick: () => onUpdateStatus(transaction, 'cancelled'),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(transaction.status === 'completed' && can('orders.update')
|
||||
? [
|
||||
{
|
||||
label: 'Refund',
|
||||
icon: <XCircle className="h-4 w-4 text-destructive" />,
|
||||
onClick: () => onUpdateStatus(transaction, 'refunded'),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('orders.update'),
|
||||
onClick: () => onEdit(transaction),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('orders.delete'),
|
||||
onClick: () => onDelete(transaction),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@ -18,7 +18,7 @@ export function createCategoryColumns(
|
||||
): ColumnDef<Category>[] {
|
||||
const { handleEdit, handleDeleteClick, can } = params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<Category>[] = [
|
||||
{
|
||||
accessorKey: 'name',
|
||||
header: () => <span>Nama</span>,
|
||||
@ -28,7 +28,10 @@ export function createCategoryColumns(
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (can('categories.update') || can('categories.delete')) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -59,6 +62,8 @@ export function createCategoryColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ export function createCustomerColumns(
|
||||
): ColumnDef<Customer>[] {
|
||||
const { handleEdit, handleDeleteClick, can } = params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<Customer>[] = [
|
||||
{
|
||||
accessorKey: 'name',
|
||||
header: () => <span>Nama</span>,
|
||||
@ -46,7 +46,10 @@ export function createCustomerColumns(
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (can('customers.update') || can('customers.delete')) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -77,6 +80,8 @@ export function createCustomerColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ export function createProductColumns(
|
||||
can,
|
||||
} = params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<Product>[] = [
|
||||
{
|
||||
id: 'expand',
|
||||
header: '',
|
||||
@ -338,7 +338,10 @@ export function createProductColumns(
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (can('products.update') || can('products.delete')) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -369,6 +372,8 @@ export function createProductColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -144,25 +144,27 @@ export function ProductCardRow({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('products.update'),
|
||||
onClick: () => onEdit(product),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('products.delete'),
|
||||
onClick: () => onDelete(product),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
{(can('products.update') || can('products.delete')) && (
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('products.update'),
|
||||
onClick: () => onEdit(product),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('products.delete'),
|
||||
onClick: () => onDelete(product),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@ -34,6 +34,8 @@ export function VariantSubRow({
|
||||
variant: ProductVariant;
|
||||
} | null>(null);
|
||||
|
||||
const canAnyAction = can('products.transfer_stock') || can('products.view_stock_mutations') || can('products.update') || can('products.delete');
|
||||
|
||||
return (
|
||||
<div className="overflow-x-auto">
|
||||
<Table>
|
||||
@ -52,16 +54,18 @@ export function VariantSubRow({
|
||||
</TableHead>
|
||||
<TableHead className="text-center">Stok Ecer</TableHead>
|
||||
<TableHead>Harga</TableHead>
|
||||
<TableHead className="w-[120px] text-center">
|
||||
Aksi
|
||||
</TableHead>
|
||||
{canAnyAction && (
|
||||
<TableHead className="w-[120px] text-center">
|
||||
Aksi
|
||||
</TableHead>
|
||||
)}
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{variants.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell
|
||||
colSpan={8}
|
||||
colSpan={canAnyAction ? 8 : 7}
|
||||
className="text-center text-muted-foreground"
|
||||
>
|
||||
Tidak ada varian.
|
||||
@ -116,63 +120,65 @@ export function VariantSubRow({
|
||||
'-'
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Transfer Stok',
|
||||
icon: (
|
||||
<ArrowRightLeft className="h-4 w-4" />
|
||||
),
|
||||
show: can('stocks.view'),
|
||||
onClick: () =>
|
||||
setTransferVariant({
|
||||
product,
|
||||
variant,
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: 'Mutasi Stok',
|
||||
icon: (
|
||||
<ScrollText className="h-4 w-4" />
|
||||
),
|
||||
show: can('stocks.view'),
|
||||
onClick: () => {
|
||||
router.visit(
|
||||
stockMutations.url({
|
||||
product: product.id,
|
||||
variant: variant.id,
|
||||
{canAnyAction && (
|
||||
<TableCell>
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Transfer Stok',
|
||||
icon: (
|
||||
<ArrowRightLeft className="h-4 w-4" />
|
||||
),
|
||||
show: can('products.transfer_stock'),
|
||||
onClick: () =>
|
||||
setTransferVariant({
|
||||
product,
|
||||
variant,
|
||||
}),
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: (
|
||||
<Pencil className="h-4 w-4" />
|
||||
),
|
||||
show: can('products.update'),
|
||||
onClick: () =>
|
||||
onEditVariant(
|
||||
product,
|
||||
variant,
|
||||
{
|
||||
label: 'Mutasi Stok',
|
||||
icon: (
|
||||
<ScrollText className="h-4 w-4" />
|
||||
),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('products.delete'),
|
||||
onClick: () =>
|
||||
onDeleteVariantClick(
|
||||
product,
|
||||
variant,
|
||||
show: can('products.view_stock_mutations'),
|
||||
onClick: () => {
|
||||
router.visit(
|
||||
stockMutations.url({
|
||||
product: product.id,
|
||||
variant: variant.id,
|
||||
}),
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: (
|
||||
<Pencil className="h-4 w-4" />
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</TableCell>
|
||||
show: can('products.update'),
|
||||
onClick: () =>
|
||||
onEditVariant(
|
||||
product,
|
||||
variant,
|
||||
),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('products.delete'),
|
||||
onClick: () =>
|
||||
onDeleteVariantClick(
|
||||
product,
|
||||
variant,
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</TableCell>
|
||||
)}
|
||||
</TableRow>
|
||||
))
|
||||
)}
|
||||
|
||||
@ -94,25 +94,27 @@ export function RawMaterialCardRow({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('raw_materials.update'),
|
||||
onClick: () => onEdit(rawMaterial),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('raw_materials.delete'),
|
||||
onClick: () => onDelete(rawMaterial),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
{(can('raw_materials.update') || can('raw_materials.delete')) && (
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: <Pencil className="h-4 w-4" />,
|
||||
show: can('raw_materials.update'),
|
||||
onClick: () => onEdit(rawMaterial),
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('raw_materials.delete'),
|
||||
onClick: () => onDelete(rawMaterial),
|
||||
},
|
||||
]}
|
||||
wrapperClassName="flex shrink-0 items-center gap-1"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@ -47,6 +47,8 @@ export function RawMaterialVariantSubRow({
|
||||
);
|
||||
}
|
||||
|
||||
const canAnyAction = can('raw_materials.update') || can('raw_materials.delete');
|
||||
|
||||
return (
|
||||
<div className="overflow-x-auto">
|
||||
<Table>
|
||||
@ -59,16 +61,18 @@ export function RawMaterialVariantSubRow({
|
||||
<TableHead>Nama Varian</TableHead>
|
||||
<TableHead>Harga</TableHead>
|
||||
<TableHead className="text-center">Stok</TableHead>
|
||||
<TableHead className="w-[100px] text-center">
|
||||
Aksi
|
||||
</TableHead>
|
||||
{canAnyAction && (
|
||||
<TableHead className="w-[100px] text-center">
|
||||
Aksi
|
||||
</TableHead>
|
||||
)}
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{variants.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell
|
||||
colSpan={6}
|
||||
colSpan={canAnyAction ? 6 : 5}
|
||||
className="text-center text-muted-foreground"
|
||||
>
|
||||
Tidak ada varian.
|
||||
@ -101,37 +105,39 @@ export function RawMaterialVariantSubRow({
|
||||
<TableCell className="text-center">
|
||||
{formatNumber(variant.stock)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: (
|
||||
<Pencil className="h-4 w-4" />
|
||||
),
|
||||
show: can('raw_materials.update'),
|
||||
onClick: () => {
|
||||
router.visit(
|
||||
variantEdit.url({
|
||||
rawMaterial:
|
||||
rawMaterial.id,
|
||||
variant: variant.id,
|
||||
}),
|
||||
);
|
||||
{canAnyAction && (
|
||||
<TableCell>
|
||||
<RowActions
|
||||
actions={[
|
||||
{
|
||||
label: 'Edit',
|
||||
icon: (
|
||||
<Pencil className="h-4 w-4" />
|
||||
),
|
||||
show: can('raw_materials.update'),
|
||||
onClick: () => {
|
||||
router.visit(
|
||||
variantEdit.url({
|
||||
rawMaterial:
|
||||
rawMaterial.id,
|
||||
variant: variant.id,
|
||||
}),
|
||||
);
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('raw_materials.delete'),
|
||||
onClick: () =>
|
||||
setDeletingVariant(variant),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</TableCell>
|
||||
{
|
||||
label: 'Hapus',
|
||||
icon: (
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
),
|
||||
show: can('raw_materials.delete'),
|
||||
onClick: () =>
|
||||
setDeletingVariant(variant),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</TableCell>
|
||||
)}
|
||||
</TableRow>
|
||||
))
|
||||
)}
|
||||
|
||||
@ -20,7 +20,7 @@ export function createSupplierColumns(
|
||||
): ColumnDef<Supplier>[] {
|
||||
const { handleEdit, handleDeleteClick, can } = params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<Supplier>[] = [
|
||||
{
|
||||
accessorKey: 'name',
|
||||
header: () => <span>Nama</span>,
|
||||
@ -46,7 +46,10 @@ export function createSupplierColumns(
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (can('suppliers.update') || can('suppliers.delete')) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -77,6 +80,8 @@ export function createSupplierColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ export function createRoleColumns(
|
||||
): ColumnDef<Role>[] {
|
||||
const { handleEdit, handleDeleteClick, can } = params;
|
||||
|
||||
return [
|
||||
const columns: ColumnDef<Role>[] = [
|
||||
{
|
||||
accessorKey: 'name',
|
||||
header: () => <span>Nama Role</span>,
|
||||
@ -44,7 +44,10 @@ export function createRoleColumns(
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
if (can('roles.update') || can('roles.delete')) {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
header: () => <span className="block text-center">Aksi</span>,
|
||||
meta: {
|
||||
@ -75,6 +78,8 @@ export function createRoleColumns(
|
||||
/>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
@ -45,8 +45,8 @@
|
||||
Route::delete('products/{product}/variants/{variant}', [ProductVariantController::class, 'destroy'])->name('products.variants.destroy')->middleware('permission:products.delete');
|
||||
Route::get('products/{product}/variants/{variant}/edit', [ProductVariantController::class, 'edit'])->name('products.variants.edit')->middleware('permission:products.update');
|
||||
Route::put('products/{product}/variants/{variant}', [ProductVariantController::class, 'update'])->name('products.variants.update')->middleware('permission:products.update');
|
||||
Route::post('products/{product}/variants/{variant}/transfer-stock', [ProductVariantController::class, 'transferStock'])->name('products.variants.transfer-stock')->middleware('permission:products.update');
|
||||
Route::get('products/{product}/variants/{variant}/stock-mutations', [StockMutationController::class, 'index'])->name('products.variants.stock-mutations')->middleware('permission:products.view');
|
||||
Route::post('products/{product}/variants/{variant}/transfer-stock', [ProductVariantController::class, 'transferStock'])->name('products.variants.transfer-stock')->middleware('permission:products.transfer_stock');
|
||||
Route::get('products/{product}/variants/{variant}/stock-mutations', [StockMutationController::class, 'index'])->name('products.variants.stock-mutations')->middleware('permission:products.view_stock_mutations');
|
||||
|
||||
Route::resource('raw-materials', RawMaterialController::class)->except(['show'])->middleware('permission:raw_materials.view|raw_materials.create|raw_materials.update|raw_materials.delete');
|
||||
Route::post('raw-materials/{rawMaterial}/toggle-status', [RawMaterialController::class, 'toggleStatus'])->name('raw-materials.toggle-status')->middleware('permission:raw_materials.toggle_status');
|
||||
@ -101,8 +101,8 @@
|
||||
Route::post('employees/{user}/reset-password', [EmployeeController::class, 'resetPassword'])->name('employees.reset-password')->middleware('permission:employees.reset_password');
|
||||
|
||||
Route::get('attendances', [AttendanceController::class, 'index'])->name('attendances.index')->middleware('permission:attendances.view');
|
||||
Route::post('attendances', [AttendanceController::class, 'store'])->name('attendances.store')->middleware('permission:attendances.manage');
|
||||
Route::put('attendances/{attendance}', [AttendanceController::class, 'update'])->name('attendances.update')->middleware('permission:attendances.manage');
|
||||
Route::post('attendances', [AttendanceController::class, 'store'])->name('attendances.store')->middleware('permission:attendances.create');
|
||||
Route::put('attendances/{attendance}', [AttendanceController::class, 'update'])->name('attendances.update')->middleware('permission:attendances.create');
|
||||
Route::get('attendances/by-date', [AttendanceController::class, 'byDate'])->name('attendances.by-date')->middleware('permission:attendances.view');
|
||||
|
||||
Route::resource('leave-requests', LeaveRequestController::class)->except(['show', 'create', 'edit'])->middleware('permission:leave_requests.view|leave_requests.create|leave_requests.update|leave_requests.delete');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user