feat: timesheet auto hm, sync excel vehicle locations, heavy equipment grouped by type, 2-party bast signature, and compact role permission ui
This commit is contained in:
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\UnitSupportTimesheet;
|
||||||
|
use App\Models\Vehicle;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class RecalculateTimesheetHoursCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'qma:recalculate-timesheet-hours';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Hitung otomatis dan perbarui finish HM serta durasi jam operasional (1 HM = 1 Jam) dari entri kronologis berikutnya';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$this->info('Memulai rekalkulasi finish HM & jam operasi timesheet unit support...');
|
||||||
|
|
||||||
|
$vehicles = Vehicle::whereHas('supportTimesheets')->get();
|
||||||
|
$totalUpdated = 0;
|
||||||
|
|
||||||
|
foreach ($vehicles as $veh) {
|
||||||
|
$timesheets = UnitSupportTimesheet::where('vehicle_id', $veh->id)
|
||||||
|
->orderBy('date', 'asc')
|
||||||
|
->orderBy('start_time', 'asc')
|
||||||
|
->orderBy('id', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$count = $timesheets->count();
|
||||||
|
for ($i = 0; $i < $count - 1; $i++) {
|
||||||
|
$current = $timesheets[$i];
|
||||||
|
$next = $timesheets[$i + 1];
|
||||||
|
|
||||||
|
// Jika current belum memiliki end_meter atau bernilai 0
|
||||||
|
if ($current->end_meter === null || (float) $current->end_meter == 0) {
|
||||||
|
if ($next->start_meter !== null && (float) $next->start_meter >= (float) $current->start_meter) {
|
||||||
|
$diff = (float) $next->start_meter - (float) $current->start_meter;
|
||||||
|
$current->update([
|
||||||
|
'end_meter' => $next->start_meter,
|
||||||
|
'operating_hours' => $diff,
|
||||||
|
]);
|
||||||
|
$totalUpdated++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info("Rekalkulasi selesai. Sebanyak {$totalUpdated} entri timesheet berhasil diperbarui.");
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Vehicle;
|
||||||
|
use App\Models\VehicleLocationHistory;
|
||||||
|
use App\Services\SimpleXlsxImporter;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class SyncExcelVehicleDataCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'qma:sync-excel-locations {--file=Berkas/DATA LOKASI TERBARU RKM KMH.xlsx}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Perbarui lokasi, status site, tipe, dan spesifikasi unit alat berat (Heavy Equipment) dari berkas Excel DATA LOKASI TERBARU RKM KMH';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$filePath = base_path($this->option('file'));
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
$this->error("Berkas Excel tidak ditemukan di: {$filePath}");
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info("Membaca berkas: {$filePath} ...");
|
||||||
|
$rows = SimpleXlsxImporter::parse($filePath);
|
||||||
|
$totalRows = count($rows);
|
||||||
|
$this->info("Total baris terbaca: {$totalRows}");
|
||||||
|
|
||||||
|
if ($totalRows < 2) {
|
||||||
|
$this->warn('Berkas Excel kosong atau tidak memiliki baris data.');
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$updatedCount = 0;
|
||||||
|
$createdCount = 0;
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
for ($i = 1; $i < $totalRows; $i++) {
|
||||||
|
$r = $rows[$i];
|
||||||
|
$code1 = trim($r[4] ?? '');
|
||||||
|
if (!$code1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cat = trim($r[2] ?? '') ?: 'SUPPORT';
|
||||||
|
$type = trim($r[3] ?? '') ?: 'HEAVY EQUIPMENT';
|
||||||
|
$statusRaw = strtoupper(trim($r[6] ?? ''));
|
||||||
|
$jenis = strtoupper(trim($r[7] ?? ''));
|
||||||
|
$lokasiSite = trim($r[8] ?? '');
|
||||||
|
$plate = trim($r[9] ?? '');
|
||||||
|
$assetNo = trim($r[10] ?? '');
|
||||||
|
$brand = trim($r[11] ?? '');
|
||||||
|
$model = trim($r[12] ?? '');
|
||||||
|
$serial = trim($r[13] ?? '');
|
||||||
|
$prodYear = trim($r[16] ?? '');
|
||||||
|
$lokasiCurrent = trim($r[18] ?? '');
|
||||||
|
$owner = trim($r[20] ?? '');
|
||||||
|
|
||||||
|
// 1. Status Operasional
|
||||||
|
$status = match ($statusRaw) {
|
||||||
|
'OPERASI', 'OPERATION' => 'Operation',
|
||||||
|
'BREAKDOWN' => 'Breakdown',
|
||||||
|
'STANDBY' => 'Standby',
|
||||||
|
'MAINTENANCE' => 'Maintenance',
|
||||||
|
default => 'Standby',
|
||||||
|
};
|
||||||
|
|
||||||
|
// 2. Lokasi & Status Area (Inside / Outside Site)
|
||||||
|
if (strtoupper($lokasiCurrent) === 'SITE' || empty($lokasiCurrent)) {
|
||||||
|
$finalLocation = $lokasiSite ?: 'Site Kerinci';
|
||||||
|
$siteStatus = 'inside_site';
|
||||||
|
} else {
|
||||||
|
$finalLocation = $lokasiCurrent;
|
||||||
|
$siteStatus = 'outside_site';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Timesheet Mobile Flag
|
||||||
|
$isMobile = (str_contains($jenis, 'MOBILE') || $type === 'DUMP TRUCK' || $type === 'LIGHT TRUCK');
|
||||||
|
|
||||||
|
// 4. Cari unit di database (cocokkan kode asli, kode tanpa spasi, atau nomor seri)
|
||||||
|
$cleanCode = preg_replace('/[^a-zA-Z0-9]/', '', $code1);
|
||||||
|
$vehicle = Vehicle::where('code', $code1)
|
||||||
|
->orWhereRaw("REPLACE(REPLACE(code, ' ', ''), '-', '') = ?", [$cleanCode])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$vehicle && !empty($serial) && $serial !== '?') {
|
||||||
|
$vehicle = Vehicle::where('serial_number', $serial)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
$cleanBrand = ($brand !== '?' && !empty($brand)) ? $brand : null;
|
||||||
|
$cleanModel = ($model !== '?' && !empty($model)) ? $model : null;
|
||||||
|
$cleanSerial = ($serial !== '?' && !empty($serial)) ? $serial : null;
|
||||||
|
$yearInt = (is_numeric($prodYear) && (int) $prodYear > 1950 && (int) $prodYear < 2100) ? (int) $prodYear : null;
|
||||||
|
$brandTypeCombined = trim(($cleanBrand ?? '') . ' ' . ($cleanModel ?? ''));
|
||||||
|
|
||||||
|
if ($vehicle) {
|
||||||
|
// Update data unit yang sudah ada
|
||||||
|
$updatePayload = [
|
||||||
|
'category' => 'unit_support',
|
||||||
|
'unit_category' => $cat,
|
||||||
|
'unit_type' => $type,
|
||||||
|
'location' => $finalLocation,
|
||||||
|
'site_status' => $siteStatus,
|
||||||
|
'status' => $status,
|
||||||
|
'location_updated_at' => Carbon::now(),
|
||||||
|
'location_updated_by' => 'Import Berkas Excel Lokasi',
|
||||||
|
'location_note' => "Pembaruan dari berkas DATA LOKASI TERBARU RKM KMH ({$finalLocation})",
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($cleanBrand) {
|
||||||
|
$updatePayload['brand'] = $cleanBrand;
|
||||||
|
}
|
||||||
|
if ($cleanModel) {
|
||||||
|
$updatePayload['model_number'] = $cleanModel;
|
||||||
|
}
|
||||||
|
if (empty($vehicle->brand_type) && !empty($brandTypeCombined)) {
|
||||||
|
$updatePayload['brand_type'] = $brandTypeCombined;
|
||||||
|
}
|
||||||
|
if ($cleanSerial && empty($vehicle->serial_number)) {
|
||||||
|
$updatePayload['serial_number'] = $cleanSerial;
|
||||||
|
}
|
||||||
|
if ($yearInt && empty($vehicle->production_year)) {
|
||||||
|
$updatePayload['production_year'] = $yearInt;
|
||||||
|
}
|
||||||
|
if (!empty($plate) && empty($vehicle->license_plate)) {
|
||||||
|
$updatePayload['license_plate'] = $plate;
|
||||||
|
}
|
||||||
|
if (!empty($owner)) {
|
||||||
|
$updatePayload['ownership'] = $owner;
|
||||||
|
}
|
||||||
|
if ($isMobile) {
|
||||||
|
$updatePayload['is_timesheet_mobile'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$vehicle->update($updatePayload);
|
||||||
|
$updatedCount++;
|
||||||
|
} else {
|
||||||
|
// Buat unit baru jika belum terdaftar
|
||||||
|
$vehicle = Vehicle::create([
|
||||||
|
'code' => $code1,
|
||||||
|
'category' => 'unit_support',
|
||||||
|
'unit_category' => $cat,
|
||||||
|
'unit_type' => $type,
|
||||||
|
'brand' => $cleanBrand,
|
||||||
|
'model_number' => $cleanModel,
|
||||||
|
'brand_type' => !empty($brandTypeCombined) ? $brandTypeCombined : $type,
|
||||||
|
'serial_number' => $cleanSerial,
|
||||||
|
'license_plate' => $plate ?: null,
|
||||||
|
'production_year' => $yearInt,
|
||||||
|
'location' => $finalLocation,
|
||||||
|
'site_status' => $siteStatus,
|
||||||
|
'status' => $status,
|
||||||
|
'ownership' => $owner ?: 'PT Kerinci Merangin Hidro',
|
||||||
|
'is_timesheet_mobile' => $isMobile,
|
||||||
|
'location_updated_at' => Carbon::now(),
|
||||||
|
'location_updated_by' => 'Import Berkas Excel Lokasi',
|
||||||
|
'location_note' => "Pendaftaran baru dari berkas DATA LOKASI TERBARU RKM KMH",
|
||||||
|
]);
|
||||||
|
$createdCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Catat riwayat lokasi unit
|
||||||
|
VehicleLocationHistory::create([
|
||||||
|
'vehicle_id' => $vehicle->id,
|
||||||
|
'site_status' => $siteStatus,
|
||||||
|
'location' => $finalLocation,
|
||||||
|
'note' => "Sinkronisasi Berkas Excel: Status {$status} di {$finalLocation}",
|
||||||
|
'source' => 'import',
|
||||||
|
'user_id' => null,
|
||||||
|
'user_name' => 'Import Berkas Excel Lokasi',
|
||||||
|
'recorded_at' => Carbon::now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
$this->error("Gagal melakukan sinkronisasi: " . $e->getMessage());
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info("Sinkronisasi Selesai!");
|
||||||
|
$this->info("- Unit diperbarui: {$updatedCount}");
|
||||||
|
$this->info("- Unit baru dibuat: {$createdCount}");
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -134,12 +134,15 @@ class SupportTimesheetController extends Controller
|
|||||||
$timesheets = $query->paginate($perPage)->withQueryString();
|
$timesheets = $query->paginate($perPage)->withQueryString();
|
||||||
|
|
||||||
// KPI Ringkasan Data Terfilter
|
// KPI Ringkasan Data Terfilter
|
||||||
$statsQuery = clone $this->getFilteredQuery($request);
|
$statsItems = (clone $this->getFilteredQuery($request))->get();
|
||||||
$totalEntries = (clone $statsQuery)->count();
|
$totalEntries = $statsItems->count();
|
||||||
$totalOperatingHours = (clone $statsQuery)->sum('operating_hours');
|
$totalOperatingHours = 0.0;
|
||||||
$totalFuelLiters = (clone $statsQuery)->sum('fuel_liters');
|
foreach ($statsItems as $item) {
|
||||||
$activeUnitsCount = (clone $statsQuery)->distinct('vehicle_id')->count('vehicle_id');
|
$totalOperatingHours += (float) ($item->effective_operating_hours ?? 0);
|
||||||
$breakdownCount = (clone $statsQuery)->where('status', 'Breakdown')->count();
|
}
|
||||||
|
$totalFuelLiters = $statsItems->sum('fuel_liters');
|
||||||
|
$activeUnitsCount = $statsItems->pluck('vehicle_id')->unique()->count();
|
||||||
|
$breakdownCount = $statsItems->where('status', 'Breakdown')->count();
|
||||||
|
|
||||||
// Data Master untuk Form & Filter
|
// Data Master untuk Form & Filter
|
||||||
$unitSupports = Vehicle::unitSupports()
|
$unitSupports = Vehicle::unitSupports()
|
||||||
@@ -168,8 +171,37 @@ class SupportTimesheetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$shifts = self::SHIFTS;
|
$shifts = self::SHIFTS;
|
||||||
$activityTypes = self::PRESET_ACTIVITIES;
|
|
||||||
$locationSuggestions = UnitManagementController::getAllLocationSuggestions();
|
// Ambil preset + aktivitas yang pernah diisi secara dinamis di database
|
||||||
|
$dbActivities = UnitSupportTimesheet::whereNotNull('activity_type')
|
||||||
|
->where('activity_type', '!=', '')
|
||||||
|
->distinct()
|
||||||
|
->pluck('activity_type')
|
||||||
|
->all();
|
||||||
|
|
||||||
|
$activityTypes = collect(self::PRESET_ACTIVITIES)
|
||||||
|
->merge($dbActivities)
|
||||||
|
->map(fn($a) => trim($a))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
|
||||||
|
// Ambil seluruh saran lokasi dari gerbang, kendaraan, riwayat, dan timesheet
|
||||||
|
$dbTimesheetLocs = UnitSupportTimesheet::whereNotNull('location')
|
||||||
|
->where('location', '!=', '')
|
||||||
|
->distinct()
|
||||||
|
->pluck('location')
|
||||||
|
->all();
|
||||||
|
|
||||||
|
$locationSuggestions = collect(UnitManagementController::getAllLocationSuggestions())
|
||||||
|
->merge($dbTimesheetLocs)
|
||||||
|
->map(fn($l) => trim($l))
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->sort()
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
|
||||||
$unitLocations = $unitSupports->groupBy(function ($u) {
|
$unitLocations = $unitSupports->groupBy(function ($u) {
|
||||||
return trim($u->location) ?: 'Site Kerinci';
|
return trim($u->location) ?: 'Site Kerinci';
|
||||||
@@ -282,7 +314,26 @@ class SupportTimesheetController extends Controller
|
|||||||
$endMeter = isset($validated['end_meter']) && $validated['end_meter'] !== '' && $validated['end_meter'] !== null
|
$endMeter = isset($validated['end_meter']) && $validated['end_meter'] !== '' && $validated['end_meter'] !== null
|
||||||
? (float) $validated['end_meter']
|
? (float) $validated['end_meter']
|
||||||
: null;
|
: null;
|
||||||
$operatingHours = $endMeter !== null ? max(0, $endMeter - $startMeter) : null;
|
|
||||||
|
if ($endMeter === null) {
|
||||||
|
$nextEntry = UnitSupportTimesheet::where('vehicle_id', $vehicle->id)
|
||||||
|
->where(function ($q) use ($validated, $startMeter) {
|
||||||
|
$q->where('date', '>', $validated['date'])
|
||||||
|
->orWhere(function ($sq) use ($validated, $startMeter) {
|
||||||
|
$sq->where('date', $validated['date'])
|
||||||
|
->where('start_meter', '>=', $startMeter);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->orderBy('date', 'asc')
|
||||||
|
->orderBy('id', 'asc')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($nextEntry && (float) $nextEntry->start_meter >= $startMeter) {
|
||||||
|
$endMeter = (float) $nextEntry->start_meter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$operatingHours = $endMeter !== null ? max(0.0, $endMeter - $startMeter) : null;
|
||||||
$shift = $validated['shift'] ?: 'Shift Siang';
|
$shift = $validated['shift'] ?: 'Shift Siang';
|
||||||
$updaterName = auth()->user()?->name ?? 'Admin QMA';
|
$updaterName = auth()->user()?->name ?? 'Admin QMA';
|
||||||
$timesheetNo = null;
|
$timesheetNo = null;
|
||||||
@@ -325,6 +376,25 @@ class SupportTimesheetController extends Controller
|
|||||||
'created_by_user_id' => auth()->id(),
|
'created_by_user_id' => auth()->id(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// 1b. Perbarui entri sebelumnya yang belum memiliki end_meter untuk unit yang sama (1 HM = 1 Jam)
|
||||||
|
$prevTimesheet = UnitSupportTimesheet::where('vehicle_id', $vehicle->id)
|
||||||
|
->where('id', '<', $timesheet->id)
|
||||||
|
->whereDate('date', '<=', $validated['date'])
|
||||||
|
->where(function ($q) {
|
||||||
|
$q->whereNull('end_meter')
|
||||||
|
->orWhere('end_meter', '<=', 0);
|
||||||
|
})
|
||||||
|
->orderByDesc('id')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($prevTimesheet && (float) $startMeter >= (float) $prevTimesheet->start_meter) {
|
||||||
|
$prevDiff = (float) $startMeter - (float) $prevTimesheet->start_meter;
|
||||||
|
$prevTimesheet->update([
|
||||||
|
'end_meter' => $startMeter,
|
||||||
|
'operating_hours' => $prevDiff,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// 2. Sinkronisasi Master Kendaraan (Odometer & Posisi di Manajemen Unit)
|
// 2. Sinkronisasi Master Kendaraan (Odometer & Posisi di Manajemen Unit)
|
||||||
$updateData = [
|
$updateData = [
|
||||||
'status' => $validated['status'],
|
'status' => $validated['status'],
|
||||||
@@ -511,6 +581,9 @@ class SupportTimesheetController extends Controller
|
|||||||
|
|
||||||
$rows = [];
|
$rows = [];
|
||||||
foreach ($timesheets as $idx => $ts) {
|
foreach ($timesheets as $idx => $ts) {
|
||||||
|
$endMeter = $ts->effective_end_meter;
|
||||||
|
$opHours = $ts->effective_operating_hours;
|
||||||
|
|
||||||
$rows[] = [
|
$rows[] = [
|
||||||
$idx + 1,
|
$idx + 1,
|
||||||
$ts->timesheet_no,
|
$ts->timesheet_no,
|
||||||
@@ -523,8 +596,8 @@ class SupportTimesheetController extends Controller
|
|||||||
$ts->operator?->nik ?: '-',
|
$ts->operator?->nik ?: '-',
|
||||||
$ts->meter_type,
|
$ts->meter_type,
|
||||||
number_format($ts->start_meter, 2, ',', '.'),
|
number_format($ts->start_meter, 2, ',', '.'),
|
||||||
number_format($ts->end_meter, 2, ',', '.'),
|
$endMeter !== null ? number_format($endMeter, 2, ',', '.') : '-',
|
||||||
number_format($ts->operating_hours, 2, ',', '.'),
|
$opHours !== null ? number_format($opHours, 2, ',', '.') : '-',
|
||||||
number_format($ts->standby_hours, 2, ',', '.'),
|
number_format($ts->standby_hours, 2, ',', '.'),
|
||||||
number_format($ts->breakdown_hours, 2, ',', '.'),
|
number_format($ts->breakdown_hours, 2, ',', '.'),
|
||||||
$ts->location,
|
$ts->location,
|
||||||
@@ -606,6 +679,9 @@ class SupportTimesheetController extends Controller
|
|||||||
|
|
||||||
$rows = [];
|
$rows = [];
|
||||||
foreach ($timesheets as $idx => $ts) {
|
foreach ($timesheets as $idx => $ts) {
|
||||||
|
$endMeter = $ts->effective_end_meter;
|
||||||
|
$opHours = $ts->effective_operating_hours;
|
||||||
|
|
||||||
$rows[] = [
|
$rows[] = [
|
||||||
$idx + 1,
|
$idx + 1,
|
||||||
$ts->date ? $ts->date->format('d/m/Y') : '-',
|
$ts->date ? $ts->date->format('d/m/Y') : '-',
|
||||||
@@ -614,8 +690,8 @@ class SupportTimesheetController extends Controller
|
|||||||
$ts->operator?->name ? ($ts->operator->name . ' (' . ($ts->operator->employee_type ?: 'Karyawan') . ')') : '-',
|
$ts->operator?->name ? ($ts->operator->name . ' (' . ($ts->operator->employee_type ?: 'Karyawan') . ')') : '-',
|
||||||
$ts->shift,
|
$ts->shift,
|
||||||
number_format($ts->start_meter, 1, ',', '.'),
|
number_format($ts->start_meter, 1, ',', '.'),
|
||||||
number_format($ts->end_meter, 1, ',', '.'),
|
$endMeter !== null ? number_format($endMeter, 1, ',', '.') : '-',
|
||||||
number_format($ts->operating_hours, 1, ',', '.') . ' ' . $ts->meter_type,
|
($opHours !== null ? number_format($opHours, 1, ',', '.') : '-') . ' ' . $ts->meter_type,
|
||||||
$ts->location,
|
$ts->location,
|
||||||
$ts->status,
|
$ts->status,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -280,53 +280,7 @@ class VehicleController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function indexSupport(Request $request): View
|
public function indexSupport(Request $request): View
|
||||||
{
|
{
|
||||||
$query = Vehicle::unitSupportCategories()->withCount('units');
|
$selectedType = $request->input('type');
|
||||||
|
|
||||||
// Filter Status Operasional
|
|
||||||
if ($request->filled('status')) {
|
|
||||||
$query->where('status', $request->input('status'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter Kategori Heavy Equipment (Excavator, Crane, Bulldozer, dll)
|
|
||||||
if ($request->filled('unit_category')) {
|
|
||||||
$query->where('unit_category', $request->input('unit_category'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter Pencarian Keyword Heavy Equipment
|
|
||||||
if ($request->filled('search')) {
|
|
||||||
$search = trim($request->input('search'));
|
|
||||||
$query->where(function ($q) use ($search) {
|
|
||||||
$q->where('code', 'like', "%{$search}%")
|
|
||||||
->orWhere('brand_type', 'like', "%{$search}%")
|
|
||||||
->orWhere('unit_category', 'like', "%{$search}%")
|
|
||||||
->orWhere('unit_type', 'like', "%{$search}%")
|
|
||||||
->orWhere('brand', 'like', "%{$search}%")
|
|
||||||
->orWhere('model_number', 'like', "%{$search}%")
|
|
||||||
->orWhere('location', 'like', "%{$search}%")
|
|
||||||
->orWhere('ownership', 'like', "%{$search}%")
|
|
||||||
->orWhere('division', 'like', "%{$search}%");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$perPage = (int) $request->input('per_page', 15);
|
|
||||||
if (!in_array($perPage, [15, 50, 100])) {
|
|
||||||
$perPage = 15;
|
|
||||||
}
|
|
||||||
|
|
||||||
$vehicles = $query->orderBy('code')->paginate($perPage)->withQueryString();
|
|
||||||
|
|
||||||
// Statistik Ringkasan Khusus Heavy Equipment
|
|
||||||
$totalSupport = Vehicle::unitSupportCategories()->count();
|
|
||||||
$totalUnits = Vehicle::unitSupportPhysical()->count();
|
|
||||||
$totalOperation = Vehicle::unitSupportCategories()->where('status', 'Operation')->count();
|
|
||||||
$totalStandby = Vehicle::unitSupportCategories()->where('status', 'Standby')->count();
|
|
||||||
$totalBreakdown = Vehicle::unitSupportCategories()->where('status', 'Breakdown')->count();
|
|
||||||
|
|
||||||
// Daftar kategori alat berat yang terdaftar untuk opsi filter
|
|
||||||
$availableCategories = Vehicle::unitSupportCategories()
|
|
||||||
->whereNotNull('unit_category')
|
|
||||||
->distinct()
|
|
||||||
->pluck('unit_category');
|
|
||||||
|
|
||||||
// Master data daftar divisi perusahaan (gabungan standar + data existing di Employee & Vehicle)
|
// Master data daftar divisi perusahaan (gabungan standar + data existing di Employee & Vehicle)
|
||||||
$standardDivisions = collect([
|
$standardDivisions = collect([
|
||||||
@@ -353,8 +307,170 @@ class VehicleController extends Controller
|
|||||||
->values()
|
->values()
|
||||||
->all();
|
->all();
|
||||||
|
|
||||||
// Daftar semua kode Heavy Equipment untuk validasi unik langsung di form
|
// Master data daftar kategori & tipe alat berat
|
||||||
$existingCodes = Vehicle::unitSupports()->pluck('code')->map(fn($c) => strtoupper(trim($c)))->values()->all();
|
$availableCategories = Vehicle::where('category', 'unit_support')
|
||||||
|
->whereNotNull('unit_category')
|
||||||
|
->where('unit_category', '!=', '')
|
||||||
|
->distinct()
|
||||||
|
->pluck('unit_category');
|
||||||
|
|
||||||
|
$availableTypes = Vehicle::where('category', 'unit_support')
|
||||||
|
->whereNotNull('unit_type')
|
||||||
|
->where('unit_type', '!=', '')
|
||||||
|
->distinct()
|
||||||
|
->orderBy('unit_type')
|
||||||
|
->pluck('unit_type');
|
||||||
|
|
||||||
|
$existingCodes = Vehicle::where('category', 'unit_support')->pluck('code')->map(fn($c) => strtoupper(trim($c)))->values()->all();
|
||||||
|
|
||||||
|
// 1. JIKA USER MEMILIH / MASUK KE TIPE TERTENTU (Tampilkan unit-unit fisik tipe tersebut)
|
||||||
|
if ($selectedType) {
|
||||||
|
$unitsQuery = Vehicle::where('category', 'unit_support')
|
||||||
|
->where(function ($q) use ($selectedType) {
|
||||||
|
$q->where('unit_type', $selectedType)
|
||||||
|
->orWhere('unit_category', $selectedType);
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($request->filled('status')) {
|
||||||
|
$unitsQuery->where('status', $request->input('status'));
|
||||||
|
}
|
||||||
|
if ($request->filled('site_status')) {
|
||||||
|
$unitsQuery->where('site_status', $request->input('site_status'));
|
||||||
|
}
|
||||||
|
if ($request->filled('location')) {
|
||||||
|
$unitsQuery->where('location', $request->input('location'));
|
||||||
|
}
|
||||||
|
if ($request->filled('search')) {
|
||||||
|
$search = trim($request->input('search'));
|
||||||
|
$unitsQuery->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'like', "%{$search}%")
|
||||||
|
->orWhere('brand', 'like', "%{$search}%")
|
||||||
|
->orWhere('brand_type', 'like', "%{$search}%")
|
||||||
|
->orWhere('model_number', 'like', "%{$search}%")
|
||||||
|
->orWhere('serial_number', 'like', "%{$search}%")
|
||||||
|
->orWhere('license_plate', 'like', "%{$search}%")
|
||||||
|
->orWhere('location', 'like', "%{$search}%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$perPage = (int) $request->input('per_page', 15);
|
||||||
|
if (!in_array($perPage, [15, 50, 100])) {
|
||||||
|
$perPage = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
$typeUnits = $unitsQuery->orderBy('code')->paginate($perPage)->withQueryString();
|
||||||
|
|
||||||
|
// Statistik Khusus Tipe Terpilih
|
||||||
|
$allOfType = Vehicle::where('category', 'unit_support')
|
||||||
|
->where(function ($q) use ($selectedType) {
|
||||||
|
$q->where('unit_type', $selectedType)
|
||||||
|
->orWhere('unit_category', $selectedType);
|
||||||
|
})
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$totalUnitsOfType = $allOfType->count();
|
||||||
|
$opCount = $allOfType->where('status', 'Operation')->count();
|
||||||
|
$stCount = $allOfType->where('status', 'Standby')->count();
|
||||||
|
$bdCount = $allOfType->where('status', 'Breakdown')->count();
|
||||||
|
$insideCount = $allOfType->where('site_status', 'inside_site')->count();
|
||||||
|
$outsideCount = $allOfType->where('site_status', 'outside_site')->count();
|
||||||
|
|
||||||
|
// Total global statistik untuk header
|
||||||
|
$totalUnits = Vehicle::where('category', 'unit_support')->count();
|
||||||
|
$totalOperation = Vehicle::where('category', 'unit_support')->where('status', 'Operation')->count();
|
||||||
|
$totalStandby = Vehicle::where('category', 'unit_support')->where('status', 'Standby')->count();
|
||||||
|
$totalBreakdown = Vehicle::where('category', 'unit_support')->where('status', 'Breakdown')->count();
|
||||||
|
$totalSupport = $availableTypes->count();
|
||||||
|
|
||||||
|
return view('qma.vehicles_support', compact(
|
||||||
|
'selectedType',
|
||||||
|
'typeUnits',
|
||||||
|
'totalUnitsOfType',
|
||||||
|
'opCount',
|
||||||
|
'stCount',
|
||||||
|
'bdCount',
|
||||||
|
'insideCount',
|
||||||
|
'outsideCount',
|
||||||
|
'totalSupport',
|
||||||
|
'totalUnits',
|
||||||
|
'totalOperation',
|
||||||
|
'totalStandby',
|
||||||
|
'totalBreakdown',
|
||||||
|
'availableCategories',
|
||||||
|
'availableTypes',
|
||||||
|
'availableDivisions',
|
||||||
|
'existingCodes'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. TAMPILAN UTAMA: PENGELOMPOKAN BERDASARKAN TYPE DULU
|
||||||
|
$allSupportQuery = Vehicle::where('category', 'unit_support');
|
||||||
|
$totalUnits = (clone $allSupportQuery)->count();
|
||||||
|
$totalOperation = (clone $allSupportQuery)->where('status', 'Operation')->count();
|
||||||
|
$totalStandby = (clone $allSupportQuery)->where('status', 'Standby')->count();
|
||||||
|
$totalBreakdown = (clone $allSupportQuery)->where('status', 'Breakdown')->count();
|
||||||
|
$totalSupport = (clone $allSupportQuery)->whereNotNull('unit_type')->where('unit_type', '!=', '')->distinct('unit_type')->count('unit_type');
|
||||||
|
|
||||||
|
// Query pengelompokan berdasarkan tipe
|
||||||
|
$hasTypes = Vehicle::where('category', 'unit_support')->whereNotNull('unit_type')->where('unit_type', '!=', '')->exists();
|
||||||
|
|
||||||
|
if ($hasTypes) {
|
||||||
|
$typeGroupsQuery = Vehicle::where('category', 'unit_support')
|
||||||
|
->select(
|
||||||
|
DB::raw("COALESCE(NULLIF(unit_type, ''), 'LAINNYA') as unit_type"),
|
||||||
|
DB::raw('MAX(unit_category) as unit_category'),
|
||||||
|
DB::raw('COUNT(*) as units_count'),
|
||||||
|
DB::raw("SUM(CASE WHEN status = 'Operation' THEN 1 ELSE 0 END) as total_operation"),
|
||||||
|
DB::raw("SUM(CASE WHEN status = 'Standby' THEN 1 ELSE 0 END) as total_standby"),
|
||||||
|
DB::raw("SUM(CASE WHEN status = 'Breakdown' THEN 1 ELSE 0 END) as total_breakdown"),
|
||||||
|
DB::raw("SUM(CASE WHEN site_status = 'inside_site' THEN 1 ELSE 0 END) as inside_site_count"),
|
||||||
|
DB::raw("SUM(CASE WHEN site_status = 'outside_site' THEN 1 ELSE 0 END) as outside_site_count"),
|
||||||
|
DB::raw('MAX(brand_type) as sample_brand_type'),
|
||||||
|
DB::raw('MAX(photo_path) as sample_photo'),
|
||||||
|
DB::raw('MIN(id) as sample_id'),
|
||||||
|
DB::raw('MIN(code) as code')
|
||||||
|
)
|
||||||
|
->groupBy(DB::raw("COALESCE(NULLIF(unit_type, ''), 'LAINNYA')"));
|
||||||
|
|
||||||
|
if ($request->filled('unit_category')) {
|
||||||
|
$typeGroupsQuery->where('unit_category', $request->input('unit_category'));
|
||||||
|
}
|
||||||
|
if ($request->filled('search')) {
|
||||||
|
$search = trim($request->input('search'));
|
||||||
|
$typeGroupsQuery->where(function ($q) use ($search) {
|
||||||
|
$q->where('unit_type', 'like', "%{$search}%")
|
||||||
|
->orWhere('unit_category', 'like', "%{$search}%")
|
||||||
|
->orWhere('brand_type', 'like', "%{$search}%")
|
||||||
|
->orWhere('code', 'like', "%{$search}%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$perPage = (int) $request->input('per_page', 15);
|
||||||
|
if (!in_array($perPage, [15, 50, 100])) {
|
||||||
|
$perPage = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
$vehicles = $typeGroupsQuery->orderByDesc(DB::raw('COUNT(*)'))->paginate($perPage)->withQueryString();
|
||||||
|
} else {
|
||||||
|
// Fallback untuk DB sebelum sync excel atau legacy category format
|
||||||
|
$query = Vehicle::unitSupportCategories()->withCount('units');
|
||||||
|
if ($request->filled('status')) {
|
||||||
|
$query->where('status', $request->input('status'));
|
||||||
|
}
|
||||||
|
if ($request->filled('unit_category')) {
|
||||||
|
$query->where('unit_category', $request->input('unit_category'));
|
||||||
|
}
|
||||||
|
if ($request->filled('search')) {
|
||||||
|
$search = trim($request->input('search'));
|
||||||
|
$query->where(function ($q) use ($search) {
|
||||||
|
$q->where('code', 'like', "%{$search}%")
|
||||||
|
->orWhere('brand_type', 'like', "%{$search}%")
|
||||||
|
->orWhere('unit_category', 'like', "%{$search}%");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$perPage = (int) $request->input('per_page', 15);
|
||||||
|
$vehicles = $query->orderBy('code')->paginate($perPage)->withQueryString();
|
||||||
|
}
|
||||||
|
|
||||||
return view('qma.vehicles_support', compact(
|
return view('qma.vehicles_support', compact(
|
||||||
'vehicles',
|
'vehicles',
|
||||||
@@ -364,6 +480,7 @@ class VehicleController extends Controller
|
|||||||
'totalStandby',
|
'totalStandby',
|
||||||
'totalBreakdown',
|
'totalBreakdown',
|
||||||
'availableCategories',
|
'availableCategories',
|
||||||
|
'availableTypes',
|
||||||
'availableDivisions',
|
'availableDivisions',
|
||||||
'existingCodes'
|
'existingCodes'
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ class UnitSupportTimesheet extends Model
|
|||||||
'fuel_liters' => 'decimal:2',
|
'fuel_liters' => 'decimal:2',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $appends = [
|
||||||
|
'effective_end_meter',
|
||||||
|
'effective_operating_hours',
|
||||||
|
];
|
||||||
|
|
||||||
public function vehicle(): BelongsTo
|
public function vehicle(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Vehicle::class);
|
return $this->belongsTo(Vehicle::class);
|
||||||
@@ -60,6 +65,53 @@ class UnitSupportTimesheet extends Model
|
|||||||
return $this->belongsTo(User::class, 'created_by_user_id');
|
return $this->belongsTo(User::class, 'created_by_user_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dapatkan meter akhir efektif.
|
||||||
|
* Jika end_meter sudah diisi, gunakan nilainya.
|
||||||
|
* Jika belum, cari dari start_meter entri berikutnya untuk unit yang sama.
|
||||||
|
*/
|
||||||
|
public function getEffectiveEndMeterAttribute(): ?float
|
||||||
|
{
|
||||||
|
if ($this->end_meter !== null && (float) $this->end_meter > 0) {
|
||||||
|
return (float) $this->end_meter;
|
||||||
|
}
|
||||||
|
|
||||||
|
$next = static::where('vehicle_id', $this->vehicle_id)
|
||||||
|
->where(function ($q) {
|
||||||
|
$q->where('date', '>', $this->date)
|
||||||
|
->orWhere(function ($sq) {
|
||||||
|
$sq->where('date', $this->date)
|
||||||
|
->where('id', '>', $this->id);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->orderBy('date', 'asc')
|
||||||
|
->orderBy('id', 'asc')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($next && $next->start_meter !== null && (float) $next->start_meter >= (float) $this->start_meter) {
|
||||||
|
return (float) $next->start_meter;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dapatkan jam kerja operasional efektif (1 HM = 1 Jam).
|
||||||
|
*/
|
||||||
|
public function getEffectiveOperatingHoursAttribute(): ?float
|
||||||
|
{
|
||||||
|
if ($this->operating_hours !== null && (float) $this->operating_hours > 0) {
|
||||||
|
return (float) $this->operating_hours;
|
||||||
|
}
|
||||||
|
|
||||||
|
$end = $this->effective_end_meter;
|
||||||
|
if ($end !== null && $this->start_meter !== null) {
|
||||||
|
return max(0.0, (float) $end - (float) $this->start_meter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate nomor timesheet unik harian (Format: TS-US-YYYYMMDD-0001).
|
* Generate nomor timesheet unik harian (Format: TS-US-YYYYMMDD-0001).
|
||||||
* Dilengkapi mitigasi tabrakan concurrency dan pengecekan soft deleted records.
|
* Dilengkapi mitigasi tabrakan concurrency dan pengecekan soft deleted records.
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
if (app()->environment('testing')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$filePath = base_path('Berkas/DATA LOKASI TERBARU RKM KMH.xlsx');
|
||||||
|
if (file_exists($filePath)) {
|
||||||
|
Artisan::call('qma:sync-excel-locations');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// No-op
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<h1 class="text-2xl font-black text-slate-800 tracking-tight flex items-center gap-2.5">
|
<h1 class="text-2xl font-black text-slate-800 tracking-tight flex items-center gap-2.5">
|
||||||
<span class="w-2.5 h-7 rounded-full bg-indigo-600 inline-block"></span>
|
<span class="w-2.5 h-7 rounded-full bg-indigo-600 inline-block"></span>
|
||||||
<span>Matriks Peran & Hak Akses Pengguna</span>
|
<span>Matriks Role & Hak Akses Pengguna</span>
|
||||||
<!-- Tooltip Super Admin Priviledge -->
|
<!-- Tooltip Super Admin Priviledge -->
|
||||||
<div class="relative group/tip inline-flex">
|
<div class="relative group/tip inline-flex">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
@@ -75,158 +75,258 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<!-- Ringkasan Role Cards -->
|
<!-- Selector Tab Role Interaktif (Compact & User Friendly) -->
|
||||||
|
<div class="space-y-3">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<span class="text-xs font-bold uppercase tracking-wider text-slate-500 flex items-center gap-1.5">
|
||||||
|
<i class="fa-solid fa-id-badge text-indigo-600"></i>
|
||||||
|
<span>Pilih Peran Pengguna (Role):</span>
|
||||||
|
</span>
|
||||||
|
<span class="text-[11px] text-slate-400">Pilih salah satu peran untuk melihat dan mengatur izinnya</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3">
|
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3">
|
||||||
@foreach($roles as $role)
|
@foreach($roles as $role)
|
||||||
@php
|
@php
|
||||||
$isCoreRole = in_array($role->name, ['super_admin', 'hse_admin', 'qma_admin', 'pg_admin', 'gate_officer']);
|
$isCoreRole = in_array($role->name, ['super_admin', 'hse_admin', 'qma_admin', 'pg_admin', 'gate_officer']);
|
||||||
$badgeColor = match($role->name) {
|
$dotColor = match($role->name) {
|
||||||
'super_admin' => 'bg-indigo-600 text-white',
|
'super_admin' => 'bg-indigo-600',
|
||||||
'hse_admin' => 'bg-emerald-600 text-white',
|
'hse_admin' => 'bg-emerald-600',
|
||||||
'qma_admin' => 'bg-blue-600 text-white',
|
'qma_admin' => 'bg-blue-600',
|
||||||
'pg_admin' => 'bg-purple-600 text-white',
|
'pg_admin' => 'bg-purple-600',
|
||||||
'gate_officer' => 'bg-amber-600 text-white',
|
'gate_officer' => 'bg-amber-600',
|
||||||
default => 'bg-slate-700 text-white'
|
default => 'bg-slate-700'
|
||||||
};
|
};
|
||||||
@endphp
|
@endphp
|
||||||
<div class="bg-white border border-slate-200/80 rounded-2xl p-4 shadow-sm flex flex-col justify-between">
|
|
||||||
<div>
|
|
||||||
<div class="flex items-center justify-between mb-2">
|
|
||||||
<span class="w-2.5 h-2.5 rounded-full {{ $badgeColor }}"></span>
|
|
||||||
@if(!$isCoreRole)
|
|
||||||
<button type="button"
|
<button type="button"
|
||||||
onclick='openDeleteRoleModal({{ $role->id }}, "{{ $role->name }}")'
|
onclick="switchRoleTab({{ $role->id }})"
|
||||||
class="text-slate-400 hover:text-rose-600 transition"
|
id="tab-btn-{{ $role->id }}"
|
||||||
|
class="role-tab-btn text-left p-3.5 rounded-2xl border transition duration-200 relative group flex flex-col justify-between {{ $loop->first ? 'border-indigo-600 bg-indigo-50/60 ring-2 ring-indigo-500/20 shadow-sm' : 'border-slate-200/80 bg-white hover:bg-slate-50 hover:border-slate-300' }}">
|
||||||
|
<div class="w-full">
|
||||||
|
<div class="flex items-center justify-between mb-2">
|
||||||
|
<span class="w-2.5 h-2.5 rounded-full {{ $dotColor }}"></span>
|
||||||
|
@if(!$isCoreRole)
|
||||||
|
<span onclick="event.stopPropagation(); openDeleteRoleModal({{ $role->id }}, '{{ $role->name }}')"
|
||||||
|
class="text-slate-300 hover:text-rose-600 p-1 -mr-1 transition"
|
||||||
title="Hapus Role Kustom">
|
title="Hapus Role Kustom">
|
||||||
<i class="fa-solid fa-trash-can text-xs"></i>
|
<i class="fa-solid fa-trash-can text-xs"></i>
|
||||||
</button>
|
</span>
|
||||||
@else
|
@else
|
||||||
<span class="text-[9px] font-bold text-slate-400 uppercase tracking-wider">Peran Utama</span>
|
<span class="text-[9px] font-bold text-slate-400 uppercase tracking-wider">Peran Utama</span>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<h2 class="text-xs font-bold text-slate-800 capitalize">{{ str_replace('_', ' ', $role->name) }}</h2>
|
<h2 class="text-xs font-bold text-slate-800 capitalize leading-snug">
|
||||||
<p class="text-[10px] text-slate-400 mt-0.5 font-mono">{{ $role->name }}</p>
|
{{ str_replace('_', ' ', $role->name) }}
|
||||||
|
</h2>
|
||||||
|
<p class="text-[10px] text-slate-400 font-mono mt-0.5 truncate">{{ $role->name }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-3 pt-2.5 border-t border-slate-100 flex items-center justify-between text-[11px]">
|
|
||||||
<span class="text-slate-500">Jumlah Hak Akses:</span>
|
<div class="mt-3 pt-2 border-t border-slate-100 flex items-center justify-between text-[11px] w-full">
|
||||||
|
<span class="text-slate-500">Izin Akses:</span>
|
||||||
@if($role->name === 'super_admin')
|
@if($role->name === 'super_admin')
|
||||||
<div class="relative group/tip inline-flex">
|
<span class="font-black text-indigo-700 flex items-center gap-1">
|
||||||
<span class="font-bold text-indigo-700 cursor-help flex items-center gap-1">
|
<i class="fa-solid fa-crown text-[9px] text-amber-500"></i>
|
||||||
<span>Akses Lengkap</span>
|
<span>Penuh</span>
|
||||||
<i class="fa-solid fa-circle-info text-[10px] text-indigo-400"></i>
|
|
||||||
</span>
|
</span>
|
||||||
<div class="absolute right-0 bottom-full mb-2 hidden group-hover/tip:block z-50 w-72 p-3 bg-slate-900 text-white text-xs rounded-xl shadow-xl pointer-events-none">
|
|
||||||
<div class="flex items-start gap-2">
|
|
||||||
<i class="fa-solid fa-crown text-amber-400 text-xs mt-0.5 flex-shrink-0"></i>
|
|
||||||
<div>
|
|
||||||
<strong class="font-bold text-white text-xs block">Hak Akses Penuh Super Administrator</strong>
|
|
||||||
<p class="text-slate-300 text-[11px] mt-0.5 leading-relaxed">
|
|
||||||
Secara otomatis memiliki akses penuh ke seluruh menu dan modul sistem tanpa batasan.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="absolute -bottom-1 right-3 w-2 h-2 bg-slate-900 rotate-45"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@else
|
@else
|
||||||
<span class="font-bold text-indigo-700">
|
<span class="font-bold text-indigo-700 role-perm-badge-count" data-role-id="{{ $role->id }}">
|
||||||
{{ $role->permissions->count() . ' Izin' }}
|
{{ $role->permissions->count() }} Izin
|
||||||
</span>
|
</span>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</button>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Matriks Role & Permissions Table -->
|
<!-- Kontainer Panel Hak Akses Per Role (Hanya Role Aktif yang Ditampilkan) -->
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
@foreach($roles as $role)
|
@foreach($roles as $role)
|
||||||
<div class="bg-white border border-slate-200/80 rounded-2xl shadow-sm overflow-hidden">
|
@php
|
||||||
<div class="px-5 py-3.5 bg-slate-50 border-b border-slate-100 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
|
$rolePermNames = $role->permissions->pluck('name')->toArray();
|
||||||
<div class="flex items-center gap-3">
|
$isSuperAdmin = $role->name === 'super_admin';
|
||||||
<div class="w-8 h-8 rounded-xl bg-indigo-50 border border-indigo-100 text-indigo-700 flex items-center justify-center font-bold text-xs">
|
@endphp
|
||||||
|
<div id="role-panel-{{ $role->id }}"
|
||||||
|
class="role-panel bg-white border border-slate-200/80 rounded-2xl shadow-sm overflow-hidden {{ $loop->first ? '' : 'hidden' }}">
|
||||||
|
|
||||||
|
<!-- Panel Header Sticky/Top Bar -->
|
||||||
|
<div class="px-5 py-4 bg-slate-50/80 border-b border-slate-200/70 flex flex-col md:flex-row md:items-center md:justify-between gap-4">
|
||||||
|
<div class="flex items-start sm:items-center gap-3">
|
||||||
|
<div class="w-10 h-10 rounded-xl bg-indigo-600 text-white flex items-center justify-center font-bold text-sm shadow-sm flex-shrink-0">
|
||||||
<i class="fa-solid fa-shield-halved"></i>
|
<i class="fa-solid fa-shield-halved"></i>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h2 class="text-sm font-bold text-slate-900 capitalize flex items-center gap-2">
|
<div class="flex items-center gap-2 flex-wrap">
|
||||||
<span>Peran: {{ str_replace('_', ' ', $role->name) }}</span>
|
<h2 class="text-base font-extrabold text-slate-800 capitalize">
|
||||||
@if($role->name === 'super_admin')
|
Pengaturan Hak Akses: {{ str_replace('_', ' ', $role->name) }}
|
||||||
<div class="relative group/satip inline-flex">
|
</h2>
|
||||||
<span class="px-2 py-0.5 rounded-full text-[9px] font-black bg-indigo-100 text-indigo-800 flex items-center gap-1 cursor-help">
|
@if($isSuperAdmin)
|
||||||
<i class="fa-solid fa-crown text-[8px]"></i>
|
<span class="px-2.5 py-0.5 rounded-full text-[10px] font-black bg-amber-100 text-amber-800 border border-amber-200 inline-flex items-center gap-1">
|
||||||
<span>AKSES LENGKAP</span>
|
<i class="fa-solid fa-crown text-[9px]"></i>
|
||||||
<i class="fa-solid fa-circle-info text-[9px] text-indigo-500"></i>
|
<span>BYPASS PENUH</span>
|
||||||
</span>
|
</span>
|
||||||
<div class="absolute left-0 top-full mt-2 hidden group-hover/satip:block z-50 w-72 sm:w-80 p-3 bg-slate-900 text-white text-xs rounded-xl shadow-xl pointer-events-none">
|
@else
|
||||||
<div class="flex items-start gap-2.5">
|
<span class="px-2.5 py-0.5 rounded-full text-[10px] font-bold bg-indigo-100 text-indigo-800 border border-indigo-200">
|
||||||
<i class="fa-solid fa-crown text-amber-400 text-xs mt-0.5 flex-shrink-0"></i>
|
Peran: <code class="font-mono">{{ $role->name }}</code>
|
||||||
<div>
|
</span>
|
||||||
<strong class="font-bold text-white text-xs block">Hak Akses Penuh Super Administrator</strong>
|
@endif
|
||||||
<p class="text-slate-300 text-[11px] mt-0.5 leading-relaxed">
|
</div>
|
||||||
Akun dengan peran <strong>Super Administrator</strong> secara otomatis memiliki akses penuh ke seluruh menu dan modul sistem tanpa batasan. Pilihan centang di bawah digunakan untuk mengatur batasan akses peran staf operasional lainnya.
|
<p class="text-xs text-slate-500 mt-0.5">
|
||||||
|
@if($isSuperAdmin)
|
||||||
|
Peran ini adalah tingkat tertinggi sistem. Seluruh hak akses otomatis aktif secara permanen.
|
||||||
|
@else
|
||||||
|
Centang fitur atau menu yang boleh diakses dan dijalankan oleh pengguna dengan peran ini.
|
||||||
|
@endif
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="absolute -top-1 left-4 w-2 h-2 bg-slate-900 rotate-45"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</h2>
|
|
||||||
<p class="text-[11px] text-slate-400">Atur centang hak akses menu yang diizinkan untuk peran pengguna ini.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if($role->name !== 'super_admin')
|
<!-- Tombol Aksi & Simpan -->
|
||||||
|
<div class="flex items-center gap-2 self-end md:self-auto flex-wrap">
|
||||||
|
@if(!$isSuperAdmin)
|
||||||
|
<button type="button"
|
||||||
|
onclick="toggleAllRolePermissions({{ $role->id }}, true)"
|
||||||
|
class="px-3 py-2 bg-slate-100 hover:bg-slate-200 text-slate-700 rounded-xl text-xs font-bold transition flex items-center gap-1.5"
|
||||||
|
title="Centang semua hak akses untuk peran ini">
|
||||||
|
<i class="fa-solid fa-check-double text-indigo-600"></i>
|
||||||
|
<span>Pilih Semua</span>
|
||||||
|
</button>
|
||||||
|
<button type="button"
|
||||||
|
onclick="toggleAllRolePermissions({{ $role->id }}, false)"
|
||||||
|
class="px-3 py-2 bg-slate-100 hover:bg-slate-200 text-slate-700 rounded-xl text-xs font-bold transition flex items-center gap-1.5"
|
||||||
|
title="Hilangkan semua centang untuk peran ini">
|
||||||
|
<i class="fa-solid fa-rotate-left text-slate-500"></i>
|
||||||
|
<span>Kosongkan</span>
|
||||||
|
</button>
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
form="form-role-{{ $role->id }}"
|
form="form-role-{{ $role->id }}"
|
||||||
class="inline-flex items-center gap-1.5 px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-sm transition self-end sm:self-auto">
|
class="inline-flex items-center gap-2 px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-md shadow-indigo-600/20 transition">
|
||||||
<i class="fa-solid fa-floppy-disk"></i>
|
<i class="fa-solid fa-floppy-disk"></i>
|
||||||
<span>Simpan Hak Akses</span>
|
<span>Simpan Perubahan</span>
|
||||||
</button>
|
</button>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if($isSuperAdmin)
|
||||||
|
<!-- Notifikasi Super Admin Bypass -->
|
||||||
|
<div class="m-5 p-4 rounded-xl bg-amber-50/70 border border-amber-200/80 flex items-start gap-3 text-amber-900 text-xs">
|
||||||
|
<i class="fa-solid fa-circle-exclamation text-amber-600 text-base mt-0.5 flex-shrink-0"></i>
|
||||||
|
<div>
|
||||||
|
<strong class="font-bold block">Hak Akses Super Administrator Tidak Terbatas</strong>
|
||||||
|
<p class="text-amber-800 text-[11px] mt-0.5 leading-relaxed">
|
||||||
|
Sesuai arsitektur keamanan Spatie RBAC, pengguna dengan peran <code>super_admin</code> memiliki hak <em>Gate::before bypass</em> yang mengizinkan akses ke seluruh API, controller, rute, dan menu tanpa perlu diverifikasi satu per satu.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<!-- Search Filter Bar per Role -->
|
||||||
|
<div class="px-5 pt-4 pb-2 flex flex-col sm:flex-row items-center justify-between gap-3 border-b border-slate-100">
|
||||||
|
<div class="relative w-full sm:w-80">
|
||||||
|
<i class="fa-solid fa-magnifying-glass absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||||
|
<input type="text"
|
||||||
|
id="search-role-{{ $role->id }}"
|
||||||
|
oninput="filterRolePermissions({{ $role->id }}, this.value)"
|
||||||
|
placeholder="Cari izin / nama menu (misal: p2h, simper, gate)..."
|
||||||
|
class="w-full pl-9 pr-8 py-2 bg-slate-50 border border-slate-200 rounded-xl text-xs focus:ring-2 focus:ring-indigo-500 focus:bg-white focus:border-indigo-500 transition">
|
||||||
|
<button type="button"
|
||||||
|
onclick="clearRoleSearch({{ $role->id }})"
|
||||||
|
id="clear-search-{{ $role->id }}"
|
||||||
|
class="absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 hidden text-xs">
|
||||||
|
<i class="fa-solid fa-circle-xmark"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="text-[11px] text-slate-500 flex items-center gap-2">
|
||||||
|
<span class="w-2 h-2 rounded-full bg-emerald-500"></span>
|
||||||
|
<span>Total Terpilih:</span>
|
||||||
|
<strong class="font-bold text-slate-800" id="selected-stat-{{ $role->id }}">{{ count($rolePermNames) }}</strong>
|
||||||
|
<span class="text-slate-400">izin aktif</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Form Modul & Permission Checklists -->
|
||||||
<form id="form-role-{{ $role->id }}"
|
<form id="form-role-{{ $role->id }}"
|
||||||
action="{{ route('admin.roles.permissions.update', $role->id) }}"
|
action="{{ route('admin.roles.permissions.update', $role->id) }}"
|
||||||
method="POST"
|
method="POST"
|
||||||
class="p-5">
|
class="p-5">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
@php
|
<div id="module-grid-{{ $role->id }}" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5">
|
||||||
$rolePermNames = $role->permissions->pluck('name')->toArray();
|
|
||||||
@endphp
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
||||||
@foreach($modules as $moduleKey => $module)
|
@foreach($modules as $moduleKey => $module)
|
||||||
<div class="bg-slate-50/70 border border-slate-200/60 rounded-xl p-4 space-y-3">
|
@php
|
||||||
<h3 class="text-xs font-bold text-slate-800 flex items-center justify-between pb-2 border-b border-slate-200/60">
|
$totalInModule = count($module['permissions']);
|
||||||
<span class="flex items-center gap-1.5">
|
$activeInModule = 0;
|
||||||
<i class="{{ $module['icon'] }} text-indigo-600 text-xs"></i>
|
foreach($module['permissions'] as $pKey => $pMeta) {
|
||||||
<span>{{ $module['name'] }}</span>
|
if ($isSuperAdmin || in_array($pKey, $rolePermNames)) {
|
||||||
</span>
|
$activeInModule++;
|
||||||
<span class="text-[10px] text-slate-400 font-semibold">{{ count($module['permissions']) }} hak akses</span>
|
}
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
<div class="perm-module-card bg-slate-50/70 border border-slate-200/70 rounded-xl p-4 flex flex-col justify-between space-y-3 transition"
|
||||||
|
data-module-key="{{ $moduleKey }}">
|
||||||
|
<div>
|
||||||
|
<!-- Header Modul -->
|
||||||
|
<div class="flex items-center justify-between pb-2.5 border-b border-slate-200/60 mb-2.5">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<div class="w-6 h-6 rounded-lg bg-indigo-50 text-indigo-600 flex items-center justify-center text-xs">
|
||||||
|
<i class="{{ $module['icon'] }}"></i>
|
||||||
|
</div>
|
||||||
|
<h3 class="text-xs font-bold text-slate-800 leading-snug">
|
||||||
|
{{ $module['name'] }}
|
||||||
</h3>
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="space-y-2">
|
<div class="flex items-center gap-2">
|
||||||
|
<span class="text-[10px] font-bold text-slate-500 bg-white px-2 py-0.5 rounded-md border border-slate-200/80 module-counter"
|
||||||
|
id="mod-count-{{ $role->id }}-{{ $moduleKey }}">
|
||||||
|
{{ $activeInModule }}/{{ $totalInModule }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
@if(!$isSuperAdmin)
|
||||||
|
<div class="flex items-center space-x-1">
|
||||||
|
<button type="button"
|
||||||
|
onclick="toggleModuleCheckboxes({{ $role->id }}, '{{ $moduleKey }}', true)"
|
||||||
|
class="text-[10px] font-bold text-indigo-600 hover:text-indigo-800 px-1 py-0.5 hover:bg-indigo-50 rounded transition"
|
||||||
|
title="Centang semua di modul ini">
|
||||||
|
Semua
|
||||||
|
</button>
|
||||||
|
<span class="text-slate-300 text-[10px]">|</span>
|
||||||
|
<button type="button"
|
||||||
|
onclick="toggleModuleCheckboxes({{ $role->id }}, '{{ $moduleKey }}', false)"
|
||||||
|
class="text-[10px] font-bold text-slate-500 hover:text-slate-700 px-1 py-0.5 hover:bg-slate-200/50 rounded transition"
|
||||||
|
title="Batalkan centang modul ini">
|
||||||
|
Batal
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Daftar Permission -->
|
||||||
|
<div class="space-y-1.5">
|
||||||
@foreach($module['permissions'] as $permKey => $permMeta)
|
@foreach($module['permissions'] as $permKey => $permMeta)
|
||||||
@php
|
@php
|
||||||
$isChecked = $role->name === 'super_admin' || in_array($permKey, $rolePermNames);
|
$isChecked = $isSuperAdmin || in_array($permKey, $rolePermNames);
|
||||||
@endphp
|
@endphp
|
||||||
<label class="flex items-start gap-2.5 text-xs text-slate-700 cursor-pointer select-none group p-2 rounded-lg hover:bg-white hover:shadow-xs border border-transparent hover:border-slate-200/60 transition">
|
<label class="perm-item flex items-start gap-2.5 text-xs text-slate-700 cursor-pointer select-none group p-2 rounded-lg hover:bg-white hover:shadow-xs border border-transparent hover:border-slate-200/60 transition {{ $isChecked ? 'bg-indigo-50/20' : '' }}"
|
||||||
|
data-search-text="{{ strtolower($permMeta['label'] . ' ' . $permMeta['description'] . ' ' . $permKey . ' ' . $module['name']) }}">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
name="permissions[]"
|
name="permissions[]"
|
||||||
value="{{ $permKey }}"
|
value="{{ $permKey }}"
|
||||||
|
data-module="{{ $moduleKey }}"
|
||||||
|
onchange="onPermissionChange({{ $role->id }}, '{{ $moduleKey }}')"
|
||||||
{{ $isChecked ? 'checked' : '' }}
|
{{ $isChecked ? 'checked' : '' }}
|
||||||
{{ $role->name === 'super_admin' ? 'disabled' : '' }}
|
{{ $isSuperAdmin ? 'disabled' : '' }}
|
||||||
class="mt-1 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500 transition">
|
class="perm-checkbox-{{ $role->id }} mt-0.5 rounded border-slate-300 text-indigo-600 focus:ring-indigo-500 transition">
|
||||||
<div>
|
<div class="flex-1 min-w-0">
|
||||||
<span class="text-xs font-bold text-slate-800 group-hover:text-indigo-600 transition block">
|
<span class="text-xs font-bold text-slate-800 group-hover:text-indigo-600 transition block">
|
||||||
{{ $permMeta['label'] }}
|
{{ $permMeta['label'] }}
|
||||||
</span>
|
</span>
|
||||||
<p class="text-[11px] text-slate-500 mt-0.5 leading-snug">
|
<p class="text-[11px] text-slate-500 mt-0.5 leading-snug">
|
||||||
{{ $permMeta['description'] }}
|
{{ $permMeta['description'] }}
|
||||||
</p>
|
</p>
|
||||||
<span class="font-mono text-[10px] text-slate-400 mt-1 block">
|
<span class="font-mono text-[9px] text-slate-400 mt-0.5 block truncate">
|
||||||
{{ $permKey }}
|
{{ $permKey }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -234,8 +334,35 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Empty Search Result State -->
|
||||||
|
<div id="empty-search-{{ $role->id }}" class="hidden py-12 text-center">
|
||||||
|
<div class="w-12 h-12 rounded-full bg-slate-100 text-slate-400 flex items-center justify-center mx-auto mb-2 text-base">
|
||||||
|
<i class="fa-solid fa-magnifying-glass"></i>
|
||||||
|
</div>
|
||||||
|
<h4 class="text-xs font-bold text-slate-700">Tidak ada hak akses yang cocok</h4>
|
||||||
|
<p class="text-[11px] text-slate-400 mt-0.5">Coba gunakan kata kunci pencarian yang lain.</p>
|
||||||
|
<button type="button" onclick="clearRoleSearch({{ $role->id }})" class="mt-3 px-3 py-1.5 bg-indigo-50 text-indigo-600 hover:bg-indigo-100 rounded-lg text-xs font-bold transition">
|
||||||
|
Reset Pencarian
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if(!$isSuperAdmin)
|
||||||
|
<!-- Bottom Action Bar -->
|
||||||
|
<div class="mt-6 pt-4 border-t border-slate-100 flex items-center justify-between">
|
||||||
|
<p class="text-xs text-slate-400">
|
||||||
|
Pastikan klik tombol <strong>Simpan Perubahan</strong> untuk menerapkan hak akses ke pengguna terkait.
|
||||||
|
</p>
|
||||||
|
<button type="submit"
|
||||||
|
class="inline-flex items-center gap-2 px-5 py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white rounded-xl text-xs font-bold shadow-md shadow-indigo-600/20 transition">
|
||||||
|
<i class="fa-solid fa-floppy-disk"></i>
|
||||||
|
<span>Simpan Perubahan</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@@ -306,6 +433,164 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// Tab switching antar Role
|
||||||
|
function switchRoleTab(roleId) {
|
||||||
|
// Sembunyikan semua panel role
|
||||||
|
document.querySelectorAll('.role-panel').forEach(panel => {
|
||||||
|
panel.classList.add('hidden');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Non-aktifkan semua styling tombol tab
|
||||||
|
document.querySelectorAll('.role-tab-btn').forEach(btn => {
|
||||||
|
btn.classList.remove('border-indigo-600', 'bg-indigo-50/60', 'ring-2', 'ring-indigo-500/20', 'shadow-sm');
|
||||||
|
btn.classList.add('border-slate-200/80', 'bg-white');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tampilkan panel role terpilih
|
||||||
|
const activePanel = document.getElementById(`role-panel-${roleId}`);
|
||||||
|
if (activePanel) {
|
||||||
|
activePanel.classList.remove('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aktifkan styling tab terpilih
|
||||||
|
const activeBtn = document.getElementById(`tab-btn-${roleId}`);
|
||||||
|
if (activeBtn) {
|
||||||
|
activeBtn.classList.remove('border-slate-200/80', 'bg-white');
|
||||||
|
activeBtn.classList.add('border-indigo-600', 'bg-indigo-50/60', 'ring-2', 'ring-indigo-500/20', 'shadow-sm');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle semua checkbox untuk role tertentu
|
||||||
|
function toggleAllRolePermissions(roleId, checked) {
|
||||||
|
const checkboxes = document.querySelectorAll(`.perm-checkbox-${roleId}`);
|
||||||
|
checkboxes.forEach(cb => {
|
||||||
|
if (!cb.disabled) {
|
||||||
|
cb.checked = checked;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
updateRoleStats(roleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle checkbox per modul
|
||||||
|
function toggleModuleCheckboxes(roleId, moduleKey, checked) {
|
||||||
|
const checkboxes = document.querySelectorAll(`#form-role-${roleId} input[data-module="${moduleKey}"]`);
|
||||||
|
checkboxes.forEach(cb => {
|
||||||
|
if (!cb.disabled) {
|
||||||
|
cb.checked = checked;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
onPermissionChange(roleId, moduleKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handler ketika ada checkbox yang berubah
|
||||||
|
function onPermissionChange(roleId, moduleKey) {
|
||||||
|
// Update counter per modul
|
||||||
|
const modCheckboxes = document.querySelectorAll(`#form-role-${roleId} input[data-module="${moduleKey}"]`);
|
||||||
|
const checkedInMod = Array.from(modCheckboxes).filter(cb => cb.checked).length;
|
||||||
|
const totalInMod = modCheckboxes.length;
|
||||||
|
|
||||||
|
const counterEl = document.getElementById(`mod-count-${roleId}-${moduleKey}`);
|
||||||
|
if (counterEl) {
|
||||||
|
counterEl.textContent = `${checkedInMod}/${totalInMod}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRoleStats(roleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update counter total hak akses aktif untuk suatu role
|
||||||
|
function updateRoleStats(roleId) {
|
||||||
|
const allCheckboxes = document.querySelectorAll(`.perm-checkbox-${roleId}`);
|
||||||
|
const totalChecked = Array.from(allCheckboxes).filter(cb => cb.checked).length;
|
||||||
|
|
||||||
|
// Update badge di header panel
|
||||||
|
const statEl = document.getElementById(`selected-stat-${roleId}`);
|
||||||
|
if (statEl) {
|
||||||
|
statEl.textContent = totalChecked;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update badge di tombol tab atas
|
||||||
|
const tabBadge = document.querySelector(`.role-perm-badge-count[data-role-id="${roleId}"]`);
|
||||||
|
if (tabBadge) {
|
||||||
|
tabBadge.textContent = `${totalChecked} Izin`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update semua counter modul
|
||||||
|
const modules = new Set();
|
||||||
|
allCheckboxes.forEach(cb => {
|
||||||
|
const m = cb.getAttribute('data-module');
|
||||||
|
if (m) modules.add(m);
|
||||||
|
});
|
||||||
|
|
||||||
|
modules.forEach(m => {
|
||||||
|
const modCheckboxes = document.querySelectorAll(`#form-role-${roleId} input[data-module="${m}"]`);
|
||||||
|
const checkedInMod = Array.from(modCheckboxes).filter(cb => cb.checked).length;
|
||||||
|
const totalInMod = modCheckboxes.length;
|
||||||
|
const counterEl = document.getElementById(`mod-count-${roleId}-${m}`);
|
||||||
|
if (counterEl) {
|
||||||
|
counterEl.textContent = `${checkedInMod}/${totalInMod}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Live Search Filter Hak Akses
|
||||||
|
function filterRolePermissions(roleId, rawKeyword) {
|
||||||
|
const keyword = (rawKeyword || '').toLowerCase().trim();
|
||||||
|
const clearBtn = document.getElementById(`clear-search-${roleId}`);
|
||||||
|
if (clearBtn) {
|
||||||
|
clearBtn.classList.toggle('hidden', keyword.length === 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const panel = document.getElementById(`role-panel-${roleId}`);
|
||||||
|
if (!panel) return;
|
||||||
|
|
||||||
|
const moduleCards = panel.querySelectorAll('.perm-module-card');
|
||||||
|
let totalVisibleCards = 0;
|
||||||
|
|
||||||
|
moduleCards.forEach(card => {
|
||||||
|
const items = card.querySelectorAll('.perm-item');
|
||||||
|
let visibleInCard = 0;
|
||||||
|
|
||||||
|
items.forEach(item => {
|
||||||
|
const text = item.getAttribute('data-search-text') || '';
|
||||||
|
if (!keyword || text.includes(keyword)) {
|
||||||
|
item.classList.remove('hidden');
|
||||||
|
visibleInCard++;
|
||||||
|
} else {
|
||||||
|
item.classList.add('hidden');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (visibleInCard > 0) {
|
||||||
|
card.classList.remove('hidden');
|
||||||
|
totalVisibleCards++;
|
||||||
|
} else {
|
||||||
|
card.classList.add('hidden');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const emptyState = document.getElementById(`empty-search-${roleId}`);
|
||||||
|
const moduleGrid = document.getElementById(`module-grid-${roleId}`);
|
||||||
|
if (emptyState && moduleGrid) {
|
||||||
|
if (totalVisibleCards === 0 && keyword.length > 0) {
|
||||||
|
emptyState.classList.remove('hidden');
|
||||||
|
moduleGrid.classList.add('hidden');
|
||||||
|
} else {
|
||||||
|
emptyState.classList.add('hidden');
|
||||||
|
moduleGrid.classList.remove('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearRoleSearch(roleId) {
|
||||||
|
const input = document.getElementById(`search-role-${roleId}`);
|
||||||
|
if (input) {
|
||||||
|
input.value = '';
|
||||||
|
filterRolePermissions(roleId, '');
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modal Manajemen Role
|
||||||
function openCreateRoleModal() {
|
function openCreateRoleModal() {
|
||||||
document.getElementById('createRoleModal').classList.remove('hidden');
|
document.getElementById('createRoleModal').classList.remove('hidden');
|
||||||
document.documentElement.classList.add('modal-open');
|
document.documentElement.classList.add('modal-open');
|
||||||
|
|||||||
@@ -301,11 +301,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<!-- Odometer Awal -->
|
<!-- Odometer Awal & Akhir -->
|
||||||
<td class="py-3.5 px-4 text-center font-mono whitespace-nowrap">
|
<td class="py-3.5 px-4 text-center font-mono whitespace-nowrap">
|
||||||
<span class="text-xs font-bold text-slate-900 bg-slate-100 px-2.5 py-1 rounded-lg border border-slate-200">
|
<div class="text-xs font-bold text-slate-900 bg-slate-100 px-2.5 py-1 rounded-lg border border-slate-200 inline-block">
|
||||||
{{ number_format($ts->start_meter, 1, ',', '.') }} {{ $ts->meter_type }}
|
{{ number_format($ts->start_meter, 1, ',', '.') }} {{ $ts->meter_type }}@if($ts->effective_end_meter) <span class="text-slate-400 font-normal">s/d</span> <span class="text-emerald-700">{{ number_format($ts->effective_end_meter, 1, ',', '.') }} {{ $ts->meter_type }}</span>@endif
|
||||||
</span>
|
</div>
|
||||||
|
@if($ts->effective_operating_hours !== null && $ts->effective_operating_hours > 0)
|
||||||
|
<div class="text-[10px] text-emerald-700 font-semibold font-sans mt-0.5">
|
||||||
|
+{{ number_format($ts->effective_operating_hours, 1, ',', '.') }} Jam Operasi
|
||||||
|
</div>
|
||||||
|
@elseif($ts->effective_end_meter)
|
||||||
|
<div class="text-[10px] text-slate-400 font-sans mt-0.5">0.0 Jam</div>
|
||||||
|
@else
|
||||||
|
<div class="text-[10px] text-amber-600 font-sans mt-0.5 flex items-center justify-center gap-1">
|
||||||
|
<span class="w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"></span>
|
||||||
|
<span>Berjalan (Finish Otomatis)</span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<!-- Lokasi & Aktivitas -->
|
<!-- Lokasi & Aktivitas -->
|
||||||
@@ -361,9 +373,9 @@
|
|||||||
'operator_type' => $ts->operator?->employee_type ?: 'Karyawan',
|
'operator_type' => $ts->operator?->employee_type ?: 'Karyawan',
|
||||||
'operator_nik' => $ts->operator?->nik ?: '-',
|
'operator_nik' => $ts->operator?->nik ?: '-',
|
||||||
'start_meter' => number_format($ts->start_meter, 1, ',', '.'),
|
'start_meter' => number_format($ts->start_meter, 1, ',', '.'),
|
||||||
'end_meter' => number_format($ts->end_meter, 1, ',', '.'),
|
'end_meter' => $ts->effective_end_meter !== null ? number_format($ts->effective_end_meter, 1, ',', '.') : '-',
|
||||||
'meter_type' => $ts->meter_type,
|
'meter_type' => $ts->meter_type,
|
||||||
'operating_hours' => number_format($ts->operating_hours, 1, ',', '.'),
|
'operating_hours' => $ts->effective_operating_hours !== null ? number_format($ts->effective_operating_hours, 1, ',', '.') : '-',
|
||||||
'standby_hours' => number_format($ts->standby_hours, 1, ',', '.'),
|
'standby_hours' => number_format($ts->standby_hours, 1, ',', '.'),
|
||||||
'breakdown_hours' => number_format($ts->breakdown_hours, 1, ',', '.'),
|
'breakdown_hours' => number_format($ts->breakdown_hours, 1, ',', '.'),
|
||||||
'fuel_liters' => $ts->fuel_liters ? number_format($ts->fuel_liters, 0, ',', '.') : '-',
|
'fuel_liters' => $ts->fuel_liters ? number_format($ts->fuel_liters, 0, ',', '.') : '-',
|
||||||
@@ -479,37 +491,37 @@
|
|||||||
<!-- Baris 1: Lokasi Kerja & Heavy Equipment -->
|
<!-- Baris 1: Lokasi Kerja & Heavy Equipment -->
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||||
Lokasi Kerja <span class="text-rose-500">*</span>
|
<span>Lokasi Kerja <span class="text-rose-500">*</span></span>
|
||||||
<span class="sr-only">Tentukan Lokasi Dulu</span>
|
<span class="sr-only">Tentukan Lokasi Dulu</span>
|
||||||
|
<span class="text-[10px] text-emerald-700 font-semibold">Bisa ketik / pilih</span>
|
||||||
</label>
|
</label>
|
||||||
<select id="addLocationSelect"
|
<div class="relative">
|
||||||
|
<input type="text"
|
||||||
|
id="addLocationInput"
|
||||||
|
name="location"
|
||||||
|
list="addLocationsDatalist"
|
||||||
required
|
required
|
||||||
onchange="onTimesheetLocationChanged(this.value, 'add')"
|
autocomplete="off"
|
||||||
|
placeholder="Pilih atau ketik lokasi kerja..."
|
||||||
|
oninput="onTimesheetLocationTyped(this.value, 'add')"
|
||||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition">
|
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition">
|
||||||
<option value="" disabled selected>-- Pilih Lokasi Kerja --</option>
|
<datalist id="addLocationsDatalist">
|
||||||
<option value="ALL">[Semua Lokasi / Semua Unit]</option>
|
<option value="[Semua Unit]">[Semua Lokasi / Tampilkan Semua Unit]</option>
|
||||||
@foreach($unitLocations as $locName => $count)
|
@foreach($unitLocations as $locName => $count)
|
||||||
<option value="{{ $locName }}">{{ $locName }} ({{ $count }} Unit Ready)</option>
|
<option value="{{ $locName }}">{{ $locName }} ({{ $count }} Unit Ready)</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
@if(isset($otherLocations) && count($otherLocations))
|
@foreach($locationSuggestions as $suggLoc)
|
||||||
<optgroup label="Lokasi Lainnya di Site">
|
@if(!isset($unitLocations[$suggLoc]))
|
||||||
@foreach($otherLocations as $otherLoc)
|
<option value="{{ $suggLoc }}">{{ $suggLoc }}</option>
|
||||||
<option value="{{ $otherLoc }}">{{ $otherLoc }} (0 Unit)</option>
|
|
||||||
@endforeach
|
|
||||||
</optgroup>
|
|
||||||
@endif
|
@endif
|
||||||
<option value="__CUSTOM__">+ Ketik Lokasi Baru...</option>
|
@endforeach
|
||||||
</select>
|
</datalist>
|
||||||
<div id="addCustomLocationWrapper" class="hidden mt-2">
|
|
||||||
<input type="text"
|
|
||||||
id="addCustomLocationInput"
|
|
||||||
name="custom_location"
|
|
||||||
placeholder="Ketik nama lokasi kerja baru..."
|
|
||||||
oninput="onCustomLocationTyped(this.value, 'add')"
|
|
||||||
class="w-full text-xs px-3.5 py-2 rounded-xl border border-emerald-300 bg-emerald-50/40 text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20]">
|
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="location" id="addFinalLocation" required>
|
<input type="hidden" id="addFinalLocation" value="">
|
||||||
|
<p class="text-[10px] text-slate-400 mt-1">
|
||||||
|
Pilih dari daftar atau ketik lokasi baru (otomatis tersimpan ke database).
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -626,7 +638,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Baris 4: Meter Awal & Satuan Meteran -->
|
<!-- Baris 4: Meter Awal & Meter Akhir (Finish HM) -->
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
||||||
@@ -644,6 +656,28 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||||
|
<span>Meter Akhir (Finish HM/KM)</span>
|
||||||
|
<span class="text-[10px] text-emerald-700 font-semibold">Otomatis / Opsional</span>
|
||||||
|
</label>
|
||||||
|
<div class="relative">
|
||||||
|
<input type="number"
|
||||||
|
step="0.01"
|
||||||
|
name="end_meter"
|
||||||
|
id="addEndMeter"
|
||||||
|
placeholder="Dihitung otomatis jika kosong"
|
||||||
|
class="w-full text-xs pl-3.5 pr-14 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono font-bold focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition">
|
||||||
|
<span id="addEndMeterUnitLabel" class="absolute right-3.5 top-1/2 -translate-y-1/2 text-xs font-extrabold text-slate-400">HM</span>
|
||||||
|
</div>
|
||||||
|
<p class="text-[10px] text-slate-400 mt-1">
|
||||||
|
<i class="fa-solid fa-clock text-emerald-600 mr-0.5"></i> 1 HM = 1 Jam. Dihitung otomatis saat entri berikutnya diinput.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Baris 4b: Satuan Meteran & Status Akhir Unit -->
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
||||||
Satuan Meteran <span class="text-rose-500">*</span>
|
Satuan Meteran <span class="text-rose-500">*</span>
|
||||||
@@ -653,10 +687,7 @@
|
|||||||
<option value="KM">KM (Odometer)</option>
|
<option value="KM">KM (Odometer)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Baris 5: Status Akhir Unit (Shift diset otomatis) -->
|
|
||||||
<input type="hidden" name="shift" value="Shift Siang">
|
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
||||||
Status Akhir Unit <span class="text-rose-500">*</span>
|
Status Akhir Unit <span class="text-rose-500">*</span>
|
||||||
@@ -668,6 +699,9 @@
|
|||||||
<option value="Maintenance">Maintenance (Servis Rutin)</option>
|
<option value="Maintenance">Maintenance (Servis Rutin)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="hidden" name="shift" value="Shift Siang">
|
||||||
|
|
||||||
<!-- Baris 6: Rincian Tugas & Catatan -->
|
<!-- Baris 6: Rincian Tugas & Catatan -->
|
||||||
<div>
|
<div>
|
||||||
@@ -811,37 +845,37 @@
|
|||||||
<!-- Baris 1: Lokasi Kerja & Heavy Equipment -->
|
<!-- Baris 1: Lokasi Kerja & Heavy Equipment -->
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||||
Lokasi Kerja <span class="text-rose-500">*</span>
|
<span>Lokasi Kerja <span class="text-rose-500">*</span></span>
|
||||||
<span class="sr-only">Tentukan Lokasi Dulu</span>
|
<span class="sr-only">Tentukan Lokasi Dulu</span>
|
||||||
|
<span class="text-[10px] text-emerald-700 font-semibold">Bisa ketik / pilih</span>
|
||||||
</label>
|
</label>
|
||||||
<select id="editLocationSelect"
|
<div class="relative">
|
||||||
|
<input type="text"
|
||||||
|
id="editLocationInput"
|
||||||
|
name="location"
|
||||||
|
list="editLocationsDatalist"
|
||||||
required
|
required
|
||||||
onchange="onTimesheetLocationChanged(this.value, 'edit')"
|
autocomplete="off"
|
||||||
|
placeholder="Pilih atau ketik lokasi kerja..."
|
||||||
|
oninput="onTimesheetLocationTyped(this.value, 'edit')"
|
||||||
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition">
|
class="w-full text-xs px-3.5 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition">
|
||||||
<option value="" disabled selected>-- Pilih Lokasi Kerja --</option>
|
<datalist id="editLocationsDatalist">
|
||||||
<option value="ALL">[Semua Lokasi / Semua Unit]</option>
|
<option value="[Semua Unit]">[Semua Lokasi / Tampilkan Semua Unit]</option>
|
||||||
@foreach($unitLocations as $locName => $count)
|
@foreach($unitLocations as $locName => $count)
|
||||||
<option value="{{ $locName }}">{{ $locName }} ({{ $count }} Unit Ready)</option>
|
<option value="{{ $locName }}">{{ $locName }} ({{ $count }} Unit Ready)</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
@if(isset($otherLocations) && count($otherLocations))
|
@foreach($locationSuggestions as $suggLoc)
|
||||||
<optgroup label="Lokasi Lainnya di Site">
|
@if(!isset($unitLocations[$suggLoc]))
|
||||||
@foreach($otherLocations as $otherLoc)
|
<option value="{{ $suggLoc }}">{{ $suggLoc }}</option>
|
||||||
<option value="{{ $otherLoc }}">{{ $otherLoc }} (0 Unit)</option>
|
|
||||||
@endforeach
|
|
||||||
</optgroup>
|
|
||||||
@endif
|
@endif
|
||||||
<option value="__CUSTOM__">+ Ketik Lokasi Baru...</option>
|
@endforeach
|
||||||
</select>
|
</datalist>
|
||||||
<div id="editCustomLocationWrapper" class="hidden mt-2">
|
|
||||||
<input type="text"
|
|
||||||
id="editCustomLocationInput"
|
|
||||||
name="custom_location"
|
|
||||||
placeholder="Ketik nama lokasi kerja baru..."
|
|
||||||
oninput="onCustomLocationTyped(this.value, 'edit')"
|
|
||||||
class="w-full text-xs px-3.5 py-2 rounded-xl border border-emerald-300 bg-emerald-50/40 text-slate-800 font-semibold focus:outline-none focus:border-[#1b5e20]">
|
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="location" id="editFinalLocation" required>
|
<input type="hidden" id="editFinalLocation" value="">
|
||||||
|
<p class="text-[10px] text-slate-400 mt-1">
|
||||||
|
Pilih dari daftar atau ketik lokasi baru (otomatis tersimpan).
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
@@ -956,7 +990,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Baris 4: Meter Awal & Satuan Meteran -->
|
<!-- Baris 4: Meter Awal & Meter Akhir (Finish HM) -->
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
||||||
@@ -974,6 +1008,28 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||||
|
<span>Meter Akhir (Finish HM/KM)</span>
|
||||||
|
<span class="text-[10px] text-emerald-700 font-semibold">Otomatis / Opsional</span>
|
||||||
|
</label>
|
||||||
|
<div class="relative">
|
||||||
|
<input type="number"
|
||||||
|
step="0.01"
|
||||||
|
name="end_meter"
|
||||||
|
id="editEndMeter"
|
||||||
|
placeholder="Dihitung otomatis jika kosong"
|
||||||
|
class="w-full text-xs pl-3.5 pr-14 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 font-mono font-bold focus:outline-none focus:border-[#1b5e20] focus:ring-1 focus:ring-[#1b5e20] transition">
|
||||||
|
<span id="editEndMeterUnitLabel" class="absolute right-3.5 top-1/2 -translate-y-1/2 text-xs font-extrabold text-slate-400">HM</span>
|
||||||
|
</div>
|
||||||
|
<p class="text-[10px] text-slate-400 mt-1">
|
||||||
|
<i class="fa-solid fa-clock text-emerald-600 mr-0.5"></i> 1 HM = 1 Jam. Dihitung otomatis saat entri berikutnya diinput.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Baris 4b: Satuan Meteran & Status Akhir Unit -->
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
||||||
Satuan Meteran <span class="text-rose-500">*</span>
|
Satuan Meteran <span class="text-rose-500">*</span>
|
||||||
@@ -983,10 +1039,7 @@
|
|||||||
<option value="KM">KM (Odometer)</option>
|
<option value="KM">KM (Odometer)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Baris 5: Status Akhir Unit (Shift disimpan secara otomatis) -->
|
|
||||||
<input type="hidden" name="shift" id="editShift" value="Shift Siang">
|
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
<label class="block text-xs font-bold text-slate-700 mb-1.5">
|
||||||
Status Akhir Unit <span class="text-rose-500">*</span>
|
Status Akhir Unit <span class="text-rose-500">*</span>
|
||||||
@@ -998,6 +1051,10 @@
|
|||||||
<option value="Maintenance">Maintenance (Servis Rutin)</option>
|
<option value="Maintenance">Maintenance (Servis Rutin)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Baris 5: Shift (disimpan otomatis) -->
|
||||||
|
<input type="hidden" name="shift" id="editShift" value="Shift Siang">
|
||||||
|
|
||||||
<!-- Baris 6: Deskripsi & Catatan -->
|
<!-- Baris 6: Deskripsi & Catatan -->
|
||||||
<div>
|
<div>
|
||||||
@@ -1318,23 +1375,15 @@
|
|||||||
const modal = document.getElementById('addTimesheetModal');
|
const modal = document.getElementById('addTimesheetModal');
|
||||||
if (modal) {
|
if (modal) {
|
||||||
// Reset form pilihan lokasi & unit
|
// Reset form pilihan lokasi & unit
|
||||||
const addLocSelect = document.getElementById('addLocationSelect');
|
const addLocInput = document.getElementById('addLocationInput');
|
||||||
if (addLocSelect) addLocSelect.selectedIndex = 0;
|
if (addLocInput) addLocInput.value = '';
|
||||||
const customWrap = document.getElementById('addCustomLocationWrapper');
|
|
||||||
if (customWrap) customWrap.classList.add('hidden');
|
|
||||||
const customInput = document.getElementById('addCustomLocationInput');
|
|
||||||
if (customInput) customInput.value = '';
|
|
||||||
const finalLoc = document.getElementById('addFinalLocation');
|
const finalLoc = document.getElementById('addFinalLocation');
|
||||||
if (finalLoc) finalLoc.value = '';
|
if (finalLoc) finalLoc.value = '';
|
||||||
|
|
||||||
const vehSelect = document.getElementById('addVehicleSelect');
|
const endMeter = document.getElementById('addEndMeter');
|
||||||
if (vehSelect) {
|
if (endMeter) endMeter.value = '';
|
||||||
vehSelect.innerHTML = '<option value="" disabled selected>-- Pilih Lokasi Kerja Terlebih Dahulu --</option>';
|
|
||||||
}
|
onTimesheetLocationTyped('', 'add');
|
||||||
const counter = document.getElementById('addUnitCounterBadge');
|
|
||||||
if (counter) counter.classList.add('hidden');
|
|
||||||
const preview = document.getElementById('addVehiclePreview');
|
|
||||||
if (preview) preview.classList.add('hidden');
|
|
||||||
|
|
||||||
const startMeter = document.getElementById('addStartMeter');
|
const startMeter = document.getElementById('addStartMeter');
|
||||||
if (startMeter) startMeter.value = '';
|
if (startMeter) startMeter.value = '';
|
||||||
@@ -1424,37 +1473,14 @@
|
|||||||
document.getElementById('editTimesheetSubtitle').textContent = `No: ${ts.timesheet_no} (${unitCode || '-'})`;
|
document.getElementById('editTimesheetSubtitle').textContent = `No: ${ts.timesheet_no} (${unitCode || '-'})`;
|
||||||
|
|
||||||
// 1. Sinkronisasi Lokasi Kerja
|
// 1. Sinkronisasi Lokasi Kerja
|
||||||
const locSelect = document.getElementById('editLocationSelect');
|
const locInput = document.getElementById('editLocationInput');
|
||||||
const finalLoc = document.getElementById('editFinalLocation');
|
const finalLoc = document.getElementById('editFinalLocation');
|
||||||
const customWrap = document.getElementById('editCustomLocationWrapper');
|
|
||||||
const targetLoc = ts.location || '';
|
const targetLoc = ts.location || '';
|
||||||
|
if (locInput) locInput.value = targetLoc;
|
||||||
finalLoc.value = targetLoc;
|
if (finalLoc) finalLoc.value = targetLoc;
|
||||||
|
|
||||||
let matched = false;
|
|
||||||
if (locSelect) {
|
|
||||||
for (let i = 0; i < locSelect.options.length; i++) {
|
|
||||||
if (locSelect.options[i].value.toLowerCase() === targetLoc.toLowerCase()) {
|
|
||||||
locSelect.selectedIndex = i;
|
|
||||||
matched = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!matched && targetLoc) {
|
|
||||||
// Tambahkan option lokasi baru jika belum terdaftar
|
|
||||||
const newOpt = document.createElement('option');
|
|
||||||
newOpt.value = targetLoc;
|
|
||||||
newOpt.textContent = `${targetLoc} (Lokasi Riwayat)`;
|
|
||||||
locSelect.appendChild(newOpt);
|
|
||||||
locSelect.value = targetLoc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (customWrap) customWrap.classList.add('hidden');
|
|
||||||
|
|
||||||
// Filter unit pada lokasi ini dengan memilih ts.vehicle_id
|
// Filter unit pada lokasi ini dengan memilih ts.vehicle_id
|
||||||
onTimesheetLocationChanged(locSelect ? locSelect.value : targetLoc, 'edit', ts.vehicle_id);
|
onTimesheetLocationTyped(targetLoc, 'edit', ts.vehicle_id);
|
||||||
|
|
||||||
// Cari jenis operator yang sedang diedit untuk mengaktifkan filter yang sesuai
|
// Cari jenis operator yang sedang diedit untuk mengaktifkan filter yang sesuai
|
||||||
let selectedOpType = 'all';
|
let selectedOpType = 'all';
|
||||||
@@ -1487,6 +1513,10 @@
|
|||||||
document.getElementById('editMeterType').value = ts.meter_type || 'HM';
|
document.getElementById('editMeterType').value = ts.meter_type || 'HM';
|
||||||
|
|
||||||
document.getElementById('editStartMeter').value = ts.start_meter;
|
document.getElementById('editStartMeter').value = ts.start_meter;
|
||||||
|
const editEndMeter = document.getElementById('editEndMeter');
|
||||||
|
if (editEndMeter) {
|
||||||
|
editEndMeter.value = (ts.end_meter && ts.end_meter !== '-') ? ts.end_meter.replace('.', '').replace(',', '.') : '';
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById('editActivityType').value = ts.activity_type;
|
document.getElementById('editActivityType').value = ts.activity_type;
|
||||||
document.getElementById('editStatus').value = ts.status || 'Operation';
|
document.getElementById('editStatus').value = ts.status || 'Operation';
|
||||||
@@ -1520,10 +1550,17 @@
|
|||||||
modal.style.display = 'none';
|
modal.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Handler saat Lokasi Kerja Dipilih (Filter Heavy Equipment yang Ready di Lokasi tersebut)
|
// 5. Handler saat Lokasi Kerja Diketik / Dipilih via Datalist Input
|
||||||
|
function onTimesheetLocationTyped(val, prefix, preselectVehicleId = null) {
|
||||||
|
const trimmed = (val || '').trim();
|
||||||
|
const finalLoc = document.getElementById(`${prefix}FinalLocation`);
|
||||||
|
if (finalLoc) {
|
||||||
|
finalLoc.value = (trimmed === '[Semua Unit]' || trimmed === 'ALL') ? '' : trimmed;
|
||||||
|
}
|
||||||
|
onTimesheetLocationChanged(trimmed, prefix, preselectVehicleId);
|
||||||
|
}
|
||||||
|
|
||||||
function onTimesheetLocationChanged(selectedLoc, prefix, preselectVehicleId = null) {
|
function onTimesheetLocationChanged(selectedLoc, prefix, preselectVehicleId = null) {
|
||||||
const customWrapper = document.getElementById(`${prefix}CustomLocationWrapper`);
|
|
||||||
const customInput = document.getElementById(`${prefix}CustomLocationInput`);
|
|
||||||
const finalLocation = document.getElementById(`${prefix}FinalLocation`);
|
const finalLocation = document.getElementById(`${prefix}FinalLocation`);
|
||||||
const vehicleSelect = document.getElementById(`${prefix}VehicleSelect`);
|
const vehicleSelect = document.getElementById(`${prefix}VehicleSelect`);
|
||||||
const counterBadge = document.getElementById(`${prefix}UnitCounterBadge`);
|
const counterBadge = document.getElementById(`${prefix}UnitCounterBadge`);
|
||||||
@@ -1531,39 +1568,28 @@
|
|||||||
|
|
||||||
if (!vehicleSelect) return;
|
if (!vehicleSelect) return;
|
||||||
|
|
||||||
// Tangani pilihan custom atau ALL
|
|
||||||
if (selectedLoc === '__CUSTOM__') {
|
|
||||||
if (customWrapper) customWrapper.classList.remove('hidden');
|
|
||||||
if (customInput) {
|
|
||||||
customInput.focus();
|
|
||||||
if (finalLocation) finalLocation.value = customInput.value.trim();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (customWrapper) customWrapper.classList.add('hidden');
|
|
||||||
if (finalLocation) {
|
if (finalLocation) {
|
||||||
finalLocation.value = (selectedLoc === 'ALL' || !selectedLoc) ? '' : selectedLoc;
|
finalLocation.value = (selectedLoc === 'ALL' || selectedLoc === '[Semua Unit]' || !selectedLoc) ? '' : selectedLoc;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const allUnits = window.unitSupportsData || [];
|
const allUnits = window.unitSupportsData || [];
|
||||||
let filteredUnits = [];
|
let filteredUnits = [];
|
||||||
|
|
||||||
if (!selectedLoc) {
|
if (!selectedLoc || selectedLoc === 'ALL' || selectedLoc === '[Semua Unit]') {
|
||||||
vehicleSelect.innerHTML = '<option value="" disabled selected>-- Pilih Lokasi Kerja Terlebih Dahulu --</option>';
|
|
||||||
if (counterBadge) counterBadge.classList.add('hidden');
|
|
||||||
if (previewEl) previewEl.classList.add('hidden');
|
|
||||||
filterOperatorSelect('all', prefix);
|
|
||||||
return;
|
|
||||||
} else if (selectedLoc === 'ALL' || selectedLoc === '__CUSTOM__') {
|
|
||||||
filteredUnits = allUnits;
|
filteredUnits = allUnits;
|
||||||
} else {
|
} else {
|
||||||
const norm = selectedLoc.trim().toLowerCase();
|
const norm = selectedLoc.trim().toLowerCase();
|
||||||
filteredUnits = allUnits.filter(u => {
|
filteredUnits = allUnits.filter(u => {
|
||||||
const uLoc = (u.location || 'Site Kerinci').trim().toLowerCase();
|
const uLoc = (u.location || 'Site Kerinci').trim().toLowerCase();
|
||||||
return uLoc === norm;
|
return uLoc === norm || uLoc.includes(norm);
|
||||||
});
|
});
|
||||||
|
// Jika lokasi yang diketik adalah lokasi baru, tetap tampilkan semua unit agar bisa dipilih
|
||||||
|
if (filteredUnits.length === 0) {
|
||||||
|
filteredUnits = allUnits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Jika dalam mode edit dan preselectVehicleId tidak ditemukan di lokasi ini (misal unit berpindah setelah ts dicatat), sertakan unit tersebut
|
// Jika dalam mode edit dan preselectVehicleId tidak ditemukan di lokasi ini, sertakan unit tersebut
|
||||||
if (preselectVehicleId) {
|
if (preselectVehicleId) {
|
||||||
const foundInFiltered = filteredUnits.some(u => String(u.id) === String(preselectVehicleId));
|
const foundInFiltered = filteredUnits.some(u => String(u.id) === String(preselectVehicleId));
|
||||||
if (!foundInFiltered) {
|
if (!foundInFiltered) {
|
||||||
@@ -1571,17 +1597,12 @@
|
|||||||
if (extra) filteredUnits.unshift(extra);
|
if (extra) filteredUnits.unshift(extra);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Update badge counter
|
// Update badge counter
|
||||||
if (counterBadge) {
|
if (counterBadge) {
|
||||||
counterBadge.classList.remove('hidden');
|
counterBadge.classList.remove('hidden');
|
||||||
if (selectedLoc === 'ALL' || selectedLoc === '__CUSTOM__') {
|
|
||||||
counterBadge.textContent = `${filteredUnits.length} Total Unit`;
|
|
||||||
} else {
|
|
||||||
counterBadge.textContent = `${filteredUnits.length} Unit Ready`;
|
counterBadge.textContent = `${filteredUnits.length} Unit Ready`;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Render option heavy equipment
|
// Render option heavy equipment
|
||||||
vehicleSelect.innerHTML = '';
|
vehicleSelect.innerHTML = '';
|
||||||
@@ -1590,7 +1611,7 @@
|
|||||||
defaultPrompt.disabled = true;
|
defaultPrompt.disabled = true;
|
||||||
defaultPrompt.textContent = filteredUnits.length > 0
|
defaultPrompt.textContent = filteredUnits.length > 0
|
||||||
? `-- Pilih Heavy Equipment (${filteredUnits.length} Unit Ready) --`
|
? `-- Pilih Heavy Equipment (${filteredUnits.length} Unit Ready) --`
|
||||||
: `-- Tidak ada unit di lokasi ini (Pilih 'Semua Unit') --`;
|
: `-- Tidak ada unit (${allUnits.length} Unit Total) --`;
|
||||||
vehicleSelect.appendChild(defaultPrompt);
|
vehicleSelect.appendChild(defaultPrompt);
|
||||||
|
|
||||||
let hasSelected = false;
|
let hasSelected = false;
|
||||||
@@ -1670,10 +1691,13 @@
|
|||||||
updateMeterUnitLabels(prefix);
|
updateMeterUnitLabels(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jika lokasi kerja dipilih 'ALL', sinkronkan finalLocation ke lokasi unit
|
// Jika lokasi kerja dipilih 'ALL' atau kosong, sinkronkan ke lokasi unit
|
||||||
const locSelect = document.getElementById(`${prefix}LocationSelect`);
|
const locInput = document.getElementById(`${prefix}LocationInput`);
|
||||||
const finalLoc = document.getElementById(`${prefix}FinalLocation`);
|
const finalLoc = document.getElementById(`${prefix}FinalLocation`);
|
||||||
if (locSelect && locSelect.value === 'ALL' && finalLoc && !finalLoc.value) {
|
if (locInput && (!locInput.value || locInput.value === 'ALL' || locInput.value === '[Semua Unit]')) {
|
||||||
|
locInput.value = unitLocation;
|
||||||
|
}
|
||||||
|
if (finalLoc && (!finalLoc.value || finalLoc.value === 'ALL' || finalLoc.value === '[Semua Unit]')) {
|
||||||
finalLoc.value = unitLocation;
|
finalLoc.value = unitLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1690,6 +1714,10 @@
|
|||||||
if (label) {
|
if (label) {
|
||||||
label.textContent = unit;
|
label.textContent = unit;
|
||||||
}
|
}
|
||||||
|
const endLabel = document.getElementById(`${prefix}EndMeterUnitLabel`);
|
||||||
|
if (endLabel) {
|
||||||
|
endLabel.textContent = unit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('addMeterType')?.addEventListener('change', () => updateMeterUnitLabels('add'));
|
document.getElementById('addMeterType')?.addEventListener('change', () => updateMeterUnitLabels('add'));
|
||||||
|
|||||||
@@ -233,62 +233,34 @@
|
|||||||
Demikian Berita Acara ini dibuat dengan sebenarnya dalam rangkap yang sah untuk dipergunakan sebagaimana mestinya dalam tertib administrasi aset dan operasional alat berat proyek Kerinci Merangin Hidro.
|
Demikian Berita Acara ini dibuat dengan sebenarnya dalam rangkap yang sah untuk dipergunakan sebagaimana mestinya dalam tertib administrasi aset dan operasional alat berat proyek Kerinci Merangin Hidro.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<!-- KOLOM TANDA TANGAN (4 PIHAK) -->
|
<!-- KOLOM TANDA TANGAN (2 PIHAK) -->
|
||||||
<div class="pt-6">
|
<div class="pt-6">
|
||||||
<div class="grid grid-cols-2 sm:grid-cols-4 gap-4 text-center text-xs">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-8 text-center text-xs max-w-2xl mx-auto">
|
||||||
<!-- 1. Yang Menyerahkan (Driver / Pengangkut) -->
|
<!-- 1. Yang Melakukan / Mencatat Pemindahan -->
|
||||||
<div class="flex flex-col justify-between min-h-[140px] p-2 border border-slate-200 rounded-xl bg-slate-50/40">
|
<div class="flex flex-col justify-between min-h-[150px] p-4 border border-slate-200 rounded-xl bg-slate-50/40 shadow-sm">
|
||||||
<p class="font-bold text-slate-600 text-[11px]">Yang Menyerahkan / Pengangkut,</p>
|
<p class="font-bold text-slate-700 text-xs uppercase tracking-wider">Yang Mencatat Pemindahan,</p>
|
||||||
<div class="py-6">
|
<div class="py-8">
|
||||||
<span class="text-[10px] text-slate-300 italic">(Tanda Tangan)</span>
|
<span class="text-[11px] text-slate-400 italic">( Tanda Tangan )</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p class="font-bold text-slate-900 border-t border-slate-300 pt-1">
|
<p class="font-bold text-slate-900 border-t border-slate-300 pt-2 text-sm">
|
||||||
{{ $transfer->transporter_driver_name ?: 'Driver Pengangkut' }}
|
{{ $transfer->user?->name ?? $transfer->reported_by }}
|
||||||
</p>
|
</p>
|
||||||
<p class="text-[10px] text-slate-400">Pengemudi / Operator</p>
|
<p class="text-[11px] text-slate-500 font-medium">Petugas Pemindahan / Pelapor</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 2. Yang Melaporkan (Petugas QMA) -->
|
<!-- 2. Admin QMA (Mengetahui / Menyetujui) -->
|
||||||
<div class="flex flex-col justify-between min-h-[140px] p-2 border border-slate-200 rounded-xl bg-slate-50/40">
|
<div class="flex flex-col justify-between min-h-[150px] p-4 border border-slate-200 rounded-xl bg-slate-50/40 shadow-sm">
|
||||||
<p class="font-bold text-slate-600 text-[11px]">Yang Melaporkan,</p>
|
<p class="font-bold text-slate-700 text-xs uppercase tracking-wider">Mengetahui / Menyetujui,</p>
|
||||||
<div class="py-6">
|
<div class="py-8">
|
||||||
<span class="text-[10px] text-slate-300 italic">(Tanda Tangan)</span>
|
<span class="text-[11px] text-slate-400 italic">( Tanda Tangan )</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p class="font-bold text-slate-900 border-t border-slate-300 pt-1">
|
<p class="font-bold text-slate-900 border-t border-slate-300 pt-2 text-sm">
|
||||||
{{ $transfer->reported_by }}
|
|
||||||
</p>
|
|
||||||
<p class="text-[10px] text-slate-400">Petugas QMA Field</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 3. Yang Menerima (Penanggung Jawab Lokasi Baru) -->
|
|
||||||
<div class="flex flex-col justify-between min-h-[140px] p-2 border border-slate-200 rounded-xl bg-slate-50/40">
|
|
||||||
<p class="font-bold text-slate-600 text-[11px]">Yang Menerima,</p>
|
|
||||||
<div class="py-6">
|
|
||||||
<span class="text-[10px] text-slate-300 italic">(Tanda Tangan)</span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p class="font-bold text-slate-900 border-t border-slate-300 pt-1">
|
|
||||||
( .................................... )
|
( .................................... )
|
||||||
</p>
|
</p>
|
||||||
<p class="text-[10px] text-slate-400">PIC {{ $transfer->to_location }}</p>
|
<p class="text-[11px] text-slate-500 font-medium">Admin QMA</p>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- 4. Mengetahui (Superintendent / Site Manager) -->
|
|
||||||
<div class="flex flex-col justify-between min-h-[140px] p-2 border border-slate-200 rounded-xl bg-slate-50/40">
|
|
||||||
<p class="font-bold text-slate-600 text-[11px]">Mengetahui,</p>
|
|
||||||
<div class="py-6">
|
|
||||||
<span class="text-[10px] text-slate-300 italic">(Tanda Tangan)</span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p class="font-bold text-slate-900 border-t border-slate-300 pt-1">
|
|
||||||
( .................................... )
|
|
||||||
</p>
|
|
||||||
<p class="text-[10px] text-slate-400">Superintendent QMA</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -61,8 +61,46 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- Kotak Pencarian & Filter Kategori Alat Berat -->
|
<!-- Top Banner jika sedang melihat unit dalam tipe tertentu -->
|
||||||
|
@if(isset($selectedType) && $selectedType)
|
||||||
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-3 p-4 bg-emerald-50/80 border border-emerald-200 rounded-2xl shadow-2xs">
|
||||||
|
<div class="flex items-center space-x-3">
|
||||||
|
<a href="{{ route('qma.vehicles.support') }}" class="px-3.5 py-2 rounded-xl bg-white border border-emerald-300 hover:bg-emerald-100/60 text-[#1b5e20] text-xs font-bold transition flex items-center gap-1.5 shadow-2xs">
|
||||||
|
<i class="fa-solid fa-arrow-left text-[11px]"></i>
|
||||||
|
<span>Semua Tipe Alat</span>
|
||||||
|
</a>
|
||||||
|
<div>
|
||||||
|
<h3 class="text-sm sm:text-base font-extrabold text-slate-900 flex items-center gap-2">
|
||||||
|
<span>Tipe: {{ $selectedType }}</span>
|
||||||
|
<span class="px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-600 text-white">{{ $totalUnitsOfType ?? $typeUnits->total() }} Unit Fisik</span>
|
||||||
|
</h3>
|
||||||
|
<p class="text-[11px] text-emerald-800 font-medium mt-0.5">
|
||||||
|
Daftar unit alat berat spesifik di bawah tipe {{ $selectedType }}.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-wrap items-center gap-1.5 text-[11px]">
|
||||||
|
<span class="px-2.5 py-1 rounded-lg font-bold bg-emerald-100 text-emerald-800 border border-emerald-200">
|
||||||
|
{{ $opCount ?? 0 }} Operation
|
||||||
|
</span>
|
||||||
|
<span class="px-2.5 py-1 rounded-lg font-bold bg-amber-100 text-amber-800 border border-amber-200">
|
||||||
|
{{ $stCount ?? 0 }} Standby
|
||||||
|
</span>
|
||||||
|
<span class="px-2.5 py-1 rounded-lg font-bold bg-rose-100 text-rose-800 border border-rose-200">
|
||||||
|
{{ $bdCount ?? 0 }} Breakdown
|
||||||
|
</span>
|
||||||
|
<span class="px-2.5 py-1 rounded-lg font-bold bg-blue-100 text-blue-800 border border-blue-200">
|
||||||
|
{{ $insideCount ?? 0 }} Site / {{ $outsideCount ?? 0 }} Luar
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<!-- Kotak Pencarian & Filter Alat Berat -->
|
||||||
<form method="GET" action="{{ route('qma.vehicles.support') }}" id="supportFilterForm" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
|
<form method="GET" action="{{ route('qma.vehicles.support') }}" id="supportFilterForm" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3">
|
||||||
|
@if(isset($selectedType) && $selectedType)
|
||||||
|
<input type="hidden" name="type" value="{{ $selectedType }}">
|
||||||
|
@endif
|
||||||
<div class="relative w-full max-w-sm sm:max-w-md">
|
<div class="relative w-full max-w-sm sm:max-w-md">
|
||||||
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
|
<span class="absolute inset-y-0 left-0 pl-3.5 flex items-center pointer-events-none text-slate-400">
|
||||||
<i class="fa-solid fa-magnifying-glass text-xs"></i>
|
<i class="fa-solid fa-magnifying-glass text-xs"></i>
|
||||||
@@ -71,18 +109,33 @@
|
|||||||
id="supportSearchInput"
|
id="supportSearchInput"
|
||||||
name="search"
|
name="search"
|
||||||
value="{{ request('search') }}"
|
value="{{ request('search') }}"
|
||||||
placeholder="Cari kode unit, model, tipe, lokasi, dokumen..."
|
placeholder="{{ isset($selectedType) && $selectedType ? 'Cari kode unit, seri, model, lokasi di ' . $selectedType . '...' : 'Cari tipe alat berat (Boomlift, Excavator, Dump Truck)...' }}"
|
||||||
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-emerald-600 focus:ring-2 focus:ring-emerald-600/10 shadow-sm transition">
|
class="w-full text-xs pl-10 pr-4 py-2.5 rounded-xl border border-slate-200 bg-white text-slate-800 placeholder-slate-400 focus:outline-none focus:border-emerald-600 focus:ring-2 focus:ring-emerald-600/10 shadow-sm transition">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
@if(!isset($selectedType) || !$selectedType)
|
||||||
<!-- Filter Kategori Alat Berat -->
|
<!-- Filter Kategori Alat Berat -->
|
||||||
<select name="unit_category" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
|
<select name="unit_category" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
|
||||||
<option value="">Semua Kategori Alat</option>
|
<option value="">Semua Kategori (Handling, Support, Hauling...)</option>
|
||||||
@foreach($availableCategories as $cat)
|
@foreach($availableCategories as $cat)
|
||||||
<option value="{{ $cat }}" {{ request('unit_category') === $cat ? 'selected' : '' }}>{{ $cat }}</option>
|
<option value="{{ $cat }}" {{ request('unit_category') === $cat ? 'selected' : '' }}>{{ $cat }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
|
@else
|
||||||
|
<!-- Filter Status Operasional untuk Drilldown Unit -->
|
||||||
|
<select name="status" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
|
||||||
|
<option value="">Semua Status Operasi</option>
|
||||||
|
<option value="Operation" {{ request('status') === 'Operation' ? 'selected' : '' }}>Operation</option>
|
||||||
|
<option value="Standby" {{ request('status') === 'Standby' ? 'selected' : '' }}>Standby</option>
|
||||||
|
<option value="Breakdown" {{ request('status') === 'Breakdown' ? 'selected' : '' }}>Breakdown</option>
|
||||||
|
</select>
|
||||||
|
<select name="site_status" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
|
||||||
|
<option value="">Semua Area</option>
|
||||||
|
<option value="inside_site" {{ request('site_status') === 'inside_site' ? 'selected' : '' }}>Di Dalam Site</option>
|
||||||
|
<option value="outside_site" {{ request('site_status') === 'outside_site' ? 'selected' : '' }}>Di Luar Site</option>
|
||||||
|
</select>
|
||||||
|
@endif
|
||||||
|
|
||||||
<!-- Filter Jumlah Per Halaman -->
|
<!-- Filter Jumlah Per Halaman -->
|
||||||
<select name="per_page" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
|
<select name="per_page" onchange="this.form.submit()" class="text-xs rounded-xl border border-slate-200 bg-white px-3 py-2 text-slate-700 font-semibold focus:outline-none focus:border-[#1b5e20]">
|
||||||
@@ -96,8 +149,8 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div id="supportResetWrapper" class="flex items-center">
|
<div id="supportResetWrapper" class="flex items-center">
|
||||||
@if(request()->anyFilled(['search', 'unit_category', 'per_page']))
|
@if(request()->anyFilled(['search', 'unit_category', 'status', 'site_status', 'per_page']))
|
||||||
<a id="supportResetBtn" href="{{ route('qma.vehicles.support') }}" class="text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1">
|
<a id="supportResetBtn" href="{{ isset($selectedType) && $selectedType ? route('qma.vehicles.support', ['type' => $selectedType]) : route('qma.vehicles.support') }}" class="text-xs text-rose-600 hover:text-rose-800 font-semibold flex items-center space-x-1 whitespace-nowrap ml-1">
|
||||||
<i class="fa-solid fa-rotate-left"></i>
|
<i class="fa-solid fa-rotate-left"></i>
|
||||||
<span>Reset</span>
|
<span>Reset</span>
|
||||||
</a>
|
</a>
|
||||||
@@ -106,19 +159,125 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<!-- Tabel Data Kategori Heavy Equipment (Header Navy Solid #06213f) -->
|
<!-- Tabel Data Heavy Equipment (Header Navy Solid #06213f) -->
|
||||||
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
|
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto">
|
||||||
|
@if(isset($selectedType) && $selectedType)
|
||||||
|
<!-- TABEL 1: DAFTAR UNIT FISIK SPESIFIK TIPE INI -->
|
||||||
<table class="min-w-full text-xs text-left border-collapse">
|
<table class="min-w-full text-xs text-left border-collapse">
|
||||||
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
|
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="py-3.5 px-4 text-center w-12">NO</th>
|
<th class="py-3.5 px-4 text-center w-12">NO</th>
|
||||||
<th class="py-3.5 px-4">KODE KATEGORI</th>
|
<th class="py-3.5 px-4">KODE UNIT</th>
|
||||||
<th class="py-3.5 px-4">KATEGORI ALAT</th>
|
|
||||||
<th class="py-3.5 px-4 text-center">JUMLAH (QTY)</th>
|
|
||||||
<th class="py-3.5 px-4">MEREK & MODEL</th>
|
<th class="py-3.5 px-4">MEREK & MODEL</th>
|
||||||
<th class="py-3.5 px-4">SPESIFIKASI</th>
|
<th class="py-3.5 px-4">NO. SERI / RANGKA</th>
|
||||||
<th class="py-3.5 px-4">DIVISI & KEPEMILIKAN</th>
|
<th class="py-3.5 px-4 text-center">TAHUN</th>
|
||||||
|
<th class="py-3.5 px-4">LOKASI SAAT INI</th>
|
||||||
|
<th class="py-3.5 px-4 text-center">AREA</th>
|
||||||
|
<th class="py-3.5 px-4 text-center">STATUS</th>
|
||||||
|
<th class="py-3.5 px-4 text-center">AKSI</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-slate-100 text-slate-700 bg-white">
|
||||||
|
@forelse($typeUnits as $index => $u)
|
||||||
|
<tr class="hover:bg-slate-50/70 transition">
|
||||||
|
<td class="py-3.5 px-4 text-center font-medium text-slate-400">
|
||||||
|
{{ $typeUnits->firstItem() + $index }}
|
||||||
|
</td>
|
||||||
|
<td class="py-3.5 px-4 font-bold text-slate-900 font-mono text-xs whitespace-nowrap">
|
||||||
|
<span class="bg-blue-50 text-blue-800 px-2.5 py-1 rounded border border-blue-200">
|
||||||
|
{{ $u->code }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="py-3.5 px-4">
|
||||||
|
<div class="font-bold text-slate-900">{{ $u->brand_type ?: ($u->brand ?: '-') }}</div>
|
||||||
|
@if($u->model_number)
|
||||||
|
<div class="text-[10px] text-slate-400 font-mono mt-0.5">Model: {{ $u->model_number }}</div>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="py-3.5 px-4 font-mono text-slate-600">
|
||||||
|
{{ $u->serial_number ?: '-' }}
|
||||||
|
</td>
|
||||||
|
<td class="py-3.5 px-4 text-center text-slate-600">
|
||||||
|
{{ $u->production_year ?: '-' }}
|
||||||
|
</td>
|
||||||
|
<td class="py-3.5 px-4 font-semibold text-slate-800">
|
||||||
|
<div class="flex items-center space-x-1">
|
||||||
|
<i class="fa-solid fa-location-dot text-emerald-600 text-[10px]"></i>
|
||||||
|
<span>{{ $u->location ?: 'Site Kerinci' }}</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
|
<span class="px-2 py-0.5 rounded text-[10px] font-bold {{ $u->isOutsideSite() ? 'bg-amber-50 text-amber-800 border border-amber-200' : 'bg-emerald-50 text-emerald-800 border border-emerald-200' }}">
|
||||||
|
{{ $u->site_status_label }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
|
@if($u->status === 'Operation')
|
||||||
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-50 text-emerald-700 border border-emerald-200">
|
||||||
|
Operation
|
||||||
|
</span>
|
||||||
|
@elseif($u->status === 'Standby')
|
||||||
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-amber-50 text-amber-700 border border-amber-200">
|
||||||
|
Standby
|
||||||
|
</span>
|
||||||
|
@elseif($u->status === 'Breakdown')
|
||||||
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-bold bg-rose-50 text-rose-700 border border-rose-200">
|
||||||
|
Breakdown
|
||||||
|
</span>
|
||||||
|
@else
|
||||||
|
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-slate-100 text-slate-600">
|
||||||
|
{{ $u->status }}
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
|
<div class="flex items-center justify-center space-x-1.5">
|
||||||
|
<button onclick='openDetailModal(@json($u))'
|
||||||
|
class="inline-flex items-center space-x-1 text-slate-600 hover:text-slate-900 hover:bg-slate-100 px-2 py-1 rounded-lg transition"
|
||||||
|
title="Lihat Detail Unit">
|
||||||
|
<i class="fa-regular fa-eye text-sm"></i>
|
||||||
|
</button>
|
||||||
|
@can('qma.vehicles.edit')
|
||||||
|
<button onclick='openEditModal(@json($u))'
|
||||||
|
class="inline-flex items-center space-x-1 text-amber-600 hover:text-amber-800 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
|
||||||
|
title="Edit Data Unit">
|
||||||
|
<i class="fa-regular fa-pen-to-square text-sm"></i>
|
||||||
|
</button>
|
||||||
|
@endcan
|
||||||
|
@can('qma.vehicles.delete')
|
||||||
|
<button type="button"
|
||||||
|
onclick="openDeleteModal('{{ $u->id }}', '{{ $u->code }}', '{{ addslashes($u->brand_type ?? '') }}')"
|
||||||
|
class="inline-flex items-center space-x-1 text-rose-600 hover:text-rose-800 hover:bg-rose-50 px-2 py-1 rounded-lg transition"
|
||||||
|
title="Hapus Unit">
|
||||||
|
<i class="fa-regular fa-trash-can text-sm"></i>
|
||||||
|
</button>
|
||||||
|
@endcan
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="9" class="py-12 text-center text-slate-400">
|
||||||
|
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
|
||||||
|
<p class="text-sm font-semibold text-slate-700">Tidak ada unit fisik untuk tipe {{ $selectedType }}</p>
|
||||||
|
<p class="text-xs text-slate-400 mt-1">Belum ada unit terdaftar atau sesuai kriteria filter.</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@else
|
||||||
|
<!-- TABEL 2: PENGELOMPOKAN BERDASARKAN TIPE HEAVY EQUIPMENT -->
|
||||||
|
<table class="min-w-full text-xs text-left border-collapse">
|
||||||
|
<thead class="bg-[#06213f] text-white font-bold text-[11px] uppercase tracking-wider">
|
||||||
|
<tr>
|
||||||
|
<th class="py-3.5 px-4 text-center w-12">NO</th>
|
||||||
|
<th class="py-3.5 px-4">TIPE ALAT BERAT</th>
|
||||||
|
<th class="py-3.5 px-4">KATEGORI</th>
|
||||||
|
<th class="py-3.5 px-4 text-center">JUMLAH (QTY)</th>
|
||||||
|
<th class="py-3.5 px-4">STATUS OPERASIONAL</th>
|
||||||
|
<th class="py-3.5 px-4">DISTRIBUSI AREA</th>
|
||||||
<th class="py-3.5 px-4 text-center">AKSI</th>
|
<th class="py-3.5 px-4 text-center">AKSI</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -129,84 +288,66 @@
|
|||||||
{{ $vehicles->firstItem() + $index }}
|
{{ $vehicles->firstItem() + $index }}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="py-3.5 px-4 font-bold text-slate-900 font-mono text-xs whitespace-nowrap">
|
<td class="py-3.5 px-4 font-bold text-slate-900 text-xs whitespace-nowrap">
|
||||||
<span class="bg-blue-50 text-blue-800 px-2.5 py-1 rounded border border-blue-200">
|
<a href="{{ route('qma.vehicles.support', ['type' => $v->unit_type]) }}" class="hover:text-[#1b5e20] transition flex items-center space-x-2.5">
|
||||||
{{ $v->code }}
|
<div class="w-8 h-8 rounded-lg bg-emerald-50 text-emerald-800 border border-emerald-200 flex items-center justify-center flex-shrink-0">
|
||||||
</span>
|
<i class="fa-solid fa-truck-monster text-xs"></i>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<span class="font-extrabold text-slate-900 block text-xs">{{ $v->unit_type }}</span>
|
||||||
|
@if(isset($v->sample_brand_type) && $v->sample_brand_type)
|
||||||
|
<span class="text-[10px] text-slate-400 font-normal block">{{ $v->sample_brand_type }}</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="py-3.5 px-4 whitespace-nowrap">
|
<td class="py-3.5 px-4 whitespace-nowrap">
|
||||||
<div class="flex items-center space-x-3">
|
<span class="px-2.5 py-1 rounded-md text-[10px] font-bold bg-slate-100 text-slate-700 border border-slate-200 uppercase tracking-wider">
|
||||||
@if($v->photo_path)
|
{{ $v->unit_category ?? 'SUPPORT' }}
|
||||||
<img src="{{ $v->photo_url }}" alt="{{ $v->code }}" class="w-9 h-9 rounded-lg object-cover border border-slate-200 shadow-2xs flex-shrink-0 cursor-pointer" onclick='openDetailModal(@json($v))'>
|
</span>
|
||||||
@else
|
|
||||||
<div class="w-9 h-9 rounded-lg bg-slate-100 border border-slate-200 flex items-center justify-center text-slate-400 flex-shrink-0">
|
|
||||||
<i class="fa-solid fa-truck-monster text-xs"></i>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
<div>
|
|
||||||
<span class="font-bold text-slate-900 block text-xs">{{ $v->unit_category ?? 'Alat Berat' }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
<a href="{{ route('qma.vehicles.support.units', $v->id) }}"
|
<a href="{{ route('qma.vehicles.support', ['type' => $v->unit_type]) }}"
|
||||||
class="inline-flex items-center space-x-1.5 px-3.5 py-1.5 rounded-full text-xs font-bold bg-[#e8f8f0] text-[#00897b] border border-[#a7f3d0] hover:bg-[#d1fae5] transition shadow-2xs group cursor-pointer"
|
class="inline-flex items-center space-x-1.5 px-3 py-1.5 rounded-full text-xs font-bold bg-[#e8f8f0] text-[#00897b] border border-[#a7f3d0] hover:bg-[#d1fae5] transition shadow-2xs group cursor-pointer"
|
||||||
title="Buka daftar {{ $v->units_count ?? 0 }} unit fisik">
|
title="Buka daftar {{ $v->units_count ?? 0 }} unit fisik tipe {{ $v->unit_type }}">
|
||||||
<span>{{ $v->units_count ?? 0 }} Unit</span>
|
<span>{{ $v->units_count ?? 0 }} Unit</span>
|
||||||
<i class="fa-solid fa-chevron-right text-[10px] ml-1 transition group-hover:translate-x-0.5"></i>
|
<i class="fa-solid fa-chevron-right text-[10px] ml-1 transition group-hover:translate-x-0.5"></i>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="py-3.5 px-4">
|
<td class="py-3.5 px-4">
|
||||||
<div class="font-bold text-slate-900">{{ $v->brand_type }}</div>
|
<div class="flex items-center space-x-2 text-[10px] font-bold">
|
||||||
@if($v->model_number)
|
<span class="text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded border border-emerald-200">
|
||||||
<div class="text-[10px] text-slate-500 font-mono mt-0.5">Model: {{ $v->model_number }}</div>
|
{{ $v->total_operation ?? 0 }} Operasi
|
||||||
@endif
|
</span>
|
||||||
|
<span class="text-amber-700 bg-amber-50 px-2 py-0.5 rounded border border-amber-200">
|
||||||
|
{{ $v->total_standby ?? 0 }} Standby
|
||||||
|
</span>
|
||||||
|
<span class="text-rose-700 bg-rose-50 px-2 py-0.5 rounded border border-rose-200">
|
||||||
|
{{ $v->total_breakdown ?? 0 }} Breakdown
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="py-3.5 px-4 text-slate-700">
|
<td class="py-3.5 px-4 text-slate-600 text-[11px]">
|
||||||
@if($v->unit_type)
|
<span class="font-medium text-emerald-800">{{ $v->inside_site_count ?? 0 }} Di Dalam Site</span>
|
||||||
<span class="font-medium text-xs">{{ $v->unit_type }}</span>
|
<span class="text-slate-300 mx-1">•</span>
|
||||||
@else
|
<span class="text-slate-500">{{ $v->outside_site_count ?? 0 }} Di Luar Site</span>
|
||||||
<span class="text-slate-300">-</span>
|
|
||||||
@endif
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="py-3.5 px-4 text-slate-600">
|
|
||||||
<div class="font-medium text-slate-800">{{ $v->division ?? '-' }}</div>
|
|
||||||
<span class="text-[10px] text-slate-400 block">{{ $v->ownership ?? 'PT Kerinci Merangin Hidro' }}</span>
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
<td class="py-3.5 px-4 text-center whitespace-nowrap">
|
||||||
<div class="flex items-center justify-center space-x-1.5">
|
<a href="{{ route('qma.vehicles.support', ['type' => $v->unit_type]) }}"
|
||||||
<button onclick='openDetailModal(@json($v))'
|
class="inline-flex items-center space-x-1.5 px-3 py-1.5 bg-[#1b5e20] hover:bg-[#144919] text-white rounded-xl text-xs font-bold transition shadow-2xs">
|
||||||
class="inline-flex items-center space-x-1 text-slate-600 hover:text-slate-900 hover:bg-slate-100 px-2 py-1 rounded-lg transition"
|
<i class="fa-regular fa-folder-open text-xs"></i>
|
||||||
title="Lihat Spesifikasi Kategori">
|
<span>Buka Unit</span>
|
||||||
<i class="fa-regular fa-eye text-sm"></i>
|
</a>
|
||||||
</button>
|
|
||||||
@can('qma.vehicles.edit')
|
|
||||||
<button onclick='openEditModal(@json($v))'
|
|
||||||
class="inline-flex items-center space-x-1 text-amber-600 hover:text-amber-800 hover:bg-amber-50 px-2 py-1 rounded-lg transition"
|
|
||||||
title="Edit Data Kategori">
|
|
||||||
<i class="fa-regular fa-pen-to-square text-sm"></i>
|
|
||||||
</button>
|
|
||||||
@endcan
|
|
||||||
@can('qma.vehicles.delete')
|
|
||||||
<button type="button"
|
|
||||||
onclick="openDeleteModal('{{ $v->id }}', '{{ $v->code }}', '{{ addslashes($v->brand_type ?? '') }}')"
|
|
||||||
class="inline-flex items-center space-x-1 text-rose-600 hover:text-rose-800 hover:bg-rose-50 px-2 py-1 rounded-lg transition"
|
|
||||||
title="Hapus Kategori / Unit">
|
|
||||||
<i class="fa-regular fa-trash-can text-sm"></i>
|
|
||||||
</button>
|
|
||||||
@endcan
|
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@empty
|
@empty
|
||||||
<tr id="serverSupportEmptyRow">
|
<tr id="serverSupportEmptyRow">
|
||||||
<td colspan="8" class="py-12 text-center text-slate-400">
|
<td colspan="7" class="py-12 text-center text-slate-400">
|
||||||
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
|
<i class="fa-solid fa-magnifying-glass text-3xl mb-3 block text-slate-300"></i>
|
||||||
@if(request('search'))
|
@if(request('search'))
|
||||||
<p class="text-sm font-semibold text-slate-700">
|
<p class="text-sm font-semibold text-slate-700">
|
||||||
@@ -222,18 +363,23 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<p class="text-sm font-semibold text-slate-700">Belum ada unit alat berat</p>
|
<p class="text-sm font-semibold text-slate-700">Belum ada tipe alat berat</p>
|
||||||
<p class="text-xs text-slate-400 mt-0.5">Belum ada unit alat berat yang sesuai dengan filter.</p>
|
<p class="text-xs text-slate-400 mt-0.5">Belum ada tipe alat berat yang sesuai dengan filter.</p>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforelse
|
@endforelse
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="supportPaginationContainer" class="p-4 bg-slate-50 border-t border-slate-200">
|
<div id="supportPaginationContainer" class="p-4 bg-slate-50 border-t border-slate-200">
|
||||||
|
@if(isset($selectedType) && $selectedType)
|
||||||
|
{{ $typeUnits->links() }}
|
||||||
|
@else
|
||||||
{{ $vehicles->links() }}
|
{{ $vehicles->links() }}
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -675,4 +675,61 @@ class QmaSupportTimesheetTest extends TestCase
|
|||||||
'operator_id' => $opDt->id,
|
'operator_id' => $opDt->id,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uji perhitungan otomatis finish HM dan durasi operasional (1 HM = 1 Jam):
|
||||||
|
* Ketika Budi mengisi 1010 dan berikutnya Joko mengisi 1012, Budi otomatis tercatat selesai di 1012 (2 jam kerja).
|
||||||
|
*/
|
||||||
|
public function test_sequential_timesheets_auto_calculate_finish_hm_and_operating_hours(): void
|
||||||
|
{
|
||||||
|
$today = Carbon::today()->toDateString();
|
||||||
|
|
||||||
|
// 1. Budi mengisi timesheet dengan start_meter 1010 (tanpa end_meter)
|
||||||
|
$budiData = [
|
||||||
|
'vehicle_id' => $this->supportUnit->id,
|
||||||
|
'operator_id' => $this->operator->id,
|
||||||
|
'date' => $today,
|
||||||
|
'start_time' => '08:00',
|
||||||
|
'meter_type' => 'HM',
|
||||||
|
'start_meter' => 1010.00,
|
||||||
|
'location' => 'Adit 3',
|
||||||
|
'activity_type' => 'Galian Material',
|
||||||
|
'status' => 'Operation',
|
||||||
|
];
|
||||||
|
|
||||||
|
$res1 = $this->actingAs($this->qmaAdmin)
|
||||||
|
->post(route('qma.support_timesheet.store'), $budiData);
|
||||||
|
$res1->assertSessionHas('success');
|
||||||
|
|
||||||
|
$budiTs = UnitSupportTimesheet::where('vehicle_id', $this->supportUnit->id)->latest('id')->first();
|
||||||
|
$this->assertNotNull($budiTs);
|
||||||
|
$this->assertEquals(1010.00, (float) $budiTs->start_meter);
|
||||||
|
|
||||||
|
// 2. Joko mengisi timesheet berikutnya untuk unit yang sama dengan start_meter 1012
|
||||||
|
$jokoData = [
|
||||||
|
'vehicle_id' => $this->supportUnit->id,
|
||||||
|
'operator_id' => $this->operator->id,
|
||||||
|
'date' => $today,
|
||||||
|
'start_time' => '11:00',
|
||||||
|
'meter_type' => 'HM',
|
||||||
|
'start_meter' => 1012.00,
|
||||||
|
'location' => 'Power House',
|
||||||
|
'activity_type' => 'Loading Material',
|
||||||
|
'status' => 'Operation',
|
||||||
|
];
|
||||||
|
|
||||||
|
$res2 = $this->actingAs($this->qmaAdmin)
|
||||||
|
->post(route('qma.support_timesheet.store'), $jokoData);
|
||||||
|
$res2->assertSessionHas('success');
|
||||||
|
|
||||||
|
// Budi's timesheet harus otomatis terupdate end_meter = 1012 dan operating_hours = 2.00
|
||||||
|
$budiTs->refresh();
|
||||||
|
$this->assertEquals(1012.00, (float) $budiTs->end_meter);
|
||||||
|
$this->assertEquals(2.00, (float) $budiTs->operating_hours);
|
||||||
|
|
||||||
|
// 3. Uji pada ekspor Excel: Budi's row harus memiliki finish HM 1.012,00 dan jam operasi 2,00 (tidak 0)
|
||||||
|
$excelRes = $this->actingAs($this->qmaAdmin)
|
||||||
|
->get(route('qma.support_timesheet.export_excel'));
|
||||||
|
$excelRes->assertStatus(200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user