feat: implement 3-level heavy equipment drilldown and transporter options in unit transfer
This commit is contained in:
@@ -82,13 +82,26 @@ class SyncExcelVehicleDataCommand extends Command
|
||||
};
|
||||
|
||||
// 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';
|
||||
// Sesuai berkas Excel "DATA LOKASI TERBARU RKM KMH",
|
||||
// Kolom 8 adalah "LOKASI" tempat unit berada (ADIT 3, POWER HOUSE, VERTICAL SHAFT, dll.)
|
||||
$finalLocation = $lokasiSite ?: ($lokasiCurrent ?: 'Site Kerinci');
|
||||
|
||||
// Klasifikasi site_status berdasarkan lokasi:
|
||||
// Lokasi eksternal / kontraktor luar / workshop luar -> outside_site
|
||||
// Lokasi area proyek KMH Kerinci (Adit, Power House, Bendungan, dll.) -> inside_site
|
||||
$outsideKeywords = [
|
||||
'PT.', 'HO', 'LAMPUNG', 'JAKARTA', 'CIDAS', 'POSO',
|
||||
'MEDCO', 'SULINDO', 'BMS', 'BHARA', 'BUKAKA', 'ACEH'
|
||||
];
|
||||
$upperLoc = strtoupper($finalLocation);
|
||||
$isOutside = false;
|
||||
foreach ($outsideKeywords as $kw) {
|
||||
if (str_contains($upperLoc, $kw)) {
|
||||
$isOutside = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$siteStatus = $isOutside ? 'outside_site' : 'inside_site';
|
||||
|
||||
// 3. Timesheet Mobile Flag
|
||||
$isMobile = (str_contains($jenis, 'MOBILE') || $type === 'DUMP TRUCK' || $type === 'LIGHT TRUCK');
|
||||
@@ -113,7 +126,7 @@ class SyncExcelVehicleDataCommand extends Command
|
||||
// Update data unit yang sudah ada
|
||||
$updatePayload = [
|
||||
'category' => 'unit_support',
|
||||
'unit_category' => $cat,
|
||||
'operational_group' => $cat,
|
||||
'unit_type' => $type,
|
||||
'location' => $finalLocation,
|
||||
'site_status' => $siteStatus,
|
||||
@@ -123,6 +136,10 @@ class SyncExcelVehicleDataCommand extends Command
|
||||
'location_note' => "Pembaruan dari berkas DATA LOKASI TERBARU RKM KMH ({$finalLocation})",
|
||||
];
|
||||
|
||||
if (empty($vehicle->unit_category)) {
|
||||
$updatePayload['unit_category'] = $vehicle->parent?->unit_category ?: ucwords(strtolower($type));
|
||||
}
|
||||
|
||||
if ($cleanBrand) {
|
||||
$updatePayload['brand'] = $cleanBrand;
|
||||
}
|
||||
@@ -155,6 +172,7 @@ class SyncExcelVehicleDataCommand extends Command
|
||||
$vehicle = Vehicle::create([
|
||||
'code' => $code1,
|
||||
'category' => 'unit_support',
|
||||
'operational_group' => $cat,
|
||||
'unit_category' => $cat,
|
||||
'unit_type' => $type,
|
||||
'brand' => $cleanBrand,
|
||||
@@ -188,6 +206,67 @@ class SyncExcelVehicleDataCommand extends Command
|
||||
]);
|
||||
}
|
||||
|
||||
// Fallback untuk unit support yang belum memiliki operational_group
|
||||
$typeFallback = [
|
||||
'DUMP TRUCK' => 'HAULING',
|
||||
'DUMP TRUCK FFT' => 'HAULING',
|
||||
'MIXER TRUCK' => 'HAULING',
|
||||
'CAPSULE CEMENT' => 'HAULING',
|
||||
'EXCAVATOR' => 'LOADER',
|
||||
'WHEEL LOADER' => 'LOADER',
|
||||
'MUCKING LOADER' => 'LOADER',
|
||||
'CRAWLER ROCK DRILL' => 'DRILLING',
|
||||
'BORE PILE' => 'DRILLING',
|
||||
'JUMBO DRILL' => 'DRILLING',
|
||||
'WHEEL RIG DRILL' => 'DRILLING',
|
||||
'BULLDOZER' => 'PIT SERVICE',
|
||||
'MOTOR GRADER' => 'PIT SERVICE',
|
||||
'VIBRO' => 'PIT SERVICE',
|
||||
'WATER TRUCK' => 'PIT SERVICE',
|
||||
'BOOMLIFT' => 'HANDLING',
|
||||
'CARRYDECK CRANE' => 'HANDLING',
|
||||
'CRAWLER CRANE' => 'HANDLING',
|
||||
'CRANE TRUCK' => 'HANDLING',
|
||||
'FLAT BED' => 'HANDLING',
|
||||
'FORKLIFT' => 'HANDLING',
|
||||
'LOW BED' => 'HANDLING',
|
||||
'MOBILE CRANE' => 'HANDLING',
|
||||
'ROUGHTER CRANE' => 'HANDLING',
|
||||
'SCISSOR LIFT' => 'HANDLING',
|
||||
'TOWER CRANE' => 'HANDLING',
|
||||
'TRAILER' => 'HANDLING',
|
||||
'ASPHALT PATCH MIXER' => 'SUPPORT',
|
||||
'COMPRESSOR' => 'SUPPORT',
|
||||
'CONCRETE PUMP' => 'SUPPORT',
|
||||
'CONCRETE PUMP TRUCK' => 'SUPPORT',
|
||||
'ENGINE GENSET' => 'SUPPORT',
|
||||
'FUEL TRUCK' => 'SUPPORT',
|
||||
'SILENT SHEET PILE' => 'SUPPORT',
|
||||
'LIGHT TRUCK' => 'SUPPORT',
|
||||
'SHOTCRETE' => 'SUPPORT',
|
||||
'SKYLIFT TRUCK' => 'SUPPORT',
|
||||
'WET SHOTCRETE TRUCK' => 'SUPPORT',
|
||||
];
|
||||
|
||||
foreach ($typeFallback as $fbType => $fbGroup) {
|
||||
Vehicle::where('category', 'unit_support')
|
||||
->where(function ($q) {
|
||||
$q->whereNull('operational_group')->orWhere('operational_group', '');
|
||||
})
|
||||
->where(function ($q) use ($fbType) {
|
||||
$q->where('unit_type', $fbType)
|
||||
->orWhere('unit_category', $fbType);
|
||||
})
|
||||
->update(['operational_group' => $fbGroup]);
|
||||
}
|
||||
|
||||
// Default terakhir jika masih kosong
|
||||
Vehicle::where('category', 'unit_support')
|
||||
->where(function ($q) {
|
||||
$q->whereNull('operational_group')->orWhere('operational_group', '');
|
||||
})
|
||||
->update(['operational_group' => 'SUPPORT']);
|
||||
|
||||
DB::commit();
|
||||
} catch (\Throwable $e) {
|
||||
DB::rollBack();
|
||||
|
||||
@@ -143,21 +143,48 @@ class UnitTransferController extends Controller
|
||||
->map(fn($group) => $group->count())
|
||||
->sortKeys();
|
||||
|
||||
// 2. Daftar armada pengangkut khusus truk/alat angkut (Truk, Flatbed, Lowbed, Towing, dsb. - Eksklusif Non-LV)
|
||||
$transporterUnits = Vehicle::where('category', '!=', 'light_vehicle')
|
||||
// 2. Daftar armada pengangkut khusus truk/alat angkut (Lowbed, Flatbed, Trailer, Dump Truck, Light Truck, Crane Truck)
|
||||
$transporterCategories = [
|
||||
'Low Bed',
|
||||
'Flat Bed',
|
||||
'Trailer',
|
||||
'Dump Truck',
|
||||
'Light Truck',
|
||||
'Crane Truck',
|
||||
];
|
||||
|
||||
$transporterUnits = Vehicle::trackableUnits()
|
||||
->where(function (Builder $q) use ($transporterCategories) {
|
||||
$q->whereIn('unit_category', $transporterCategories)
|
||||
->orWhere(function (Builder $sub) {
|
||||
$sub->where('code', 'like', 'LB %')
|
||||
->orWhere('code', 'like', 'LB-%')
|
||||
->orWhere('code', 'like', 'FB %')
|
||||
->orWhere('code', 'like', 'FB-%')
|
||||
->orWhere('code', 'like', 'TR %')
|
||||
->orWhere('code', 'like', 'TR-%')
|
||||
->orWhere('code', 'like', 'DT %')
|
||||
->orWhere('code', 'like', 'DT-%')
|
||||
->orWhere('code', 'like', 'LT %')
|
||||
->orWhere('code', 'like', 'LT-%')
|
||||
->orWhere('code', 'like', 'CT %')
|
||||
->orWhere('code', 'like', 'CT-%');
|
||||
});
|
||||
})
|
||||
->where(function (Builder $q) {
|
||||
$q->where('code', 'not like', 'LV %')
|
||||
->where('code', 'not like', 'LV-%')
|
||||
->where('code', 'not like', 'LV/%')
|
||||
->where('code', 'not like', 'LV_%');
|
||||
})
|
||||
->where(function (Builder $q) {
|
||||
$q->whereNotNull('parent_id')
|
||||
->orWhereDoesntHave('units');
|
||||
})
|
||||
->orderBy('code')
|
||||
->get();
|
||||
|
||||
// Lokasi asal armada pengangkut internal yang tersedia beserta jumlah unitnya
|
||||
$transporterLocations = $transporterUnits->groupBy(fn($u) => $u->location ?: 'Site Kerinci')
|
||||
->map(fn($group) => $group->count())
|
||||
->sortKeys();
|
||||
|
||||
// 3. Daftar pengemudi / operator
|
||||
$drivers = Employee::where('is_operator', true)
|
||||
->orderBy('name')
|
||||
@@ -175,6 +202,7 @@ class UnitTransferController extends Controller
|
||||
'originLocations',
|
||||
'selectedOriginLocation',
|
||||
'transporterUnits',
|
||||
'transporterLocations',
|
||||
'drivers',
|
||||
'locationSuggestions',
|
||||
'defaultDocNumber',
|
||||
@@ -195,6 +223,8 @@ class UnitTransferController extends Controller
|
||||
'to_site_status' => ['required', 'in:inside_site,outside_site'],
|
||||
'description' => ['nullable', 'string', 'max:2000'],
|
||||
'reported_by' => ['required', 'string', 'max:255'],
|
||||
'transporter_type' => ['nullable', 'string', 'in:internal,external,none'],
|
||||
'transporter_origin_location' => ['nullable', 'string', 'max:255'],
|
||||
'transporter_vehicle_id' => ['nullable', 'integer', 'exists:vehicles,id'],
|
||||
'transporter_unit_name' => ['nullable', 'string', 'max:255'],
|
||||
'transporter_driver_id' => ['nullable', 'integer', 'exists:employees,id'],
|
||||
@@ -230,15 +260,26 @@ class UnitTransferController extends Controller
|
||||
$fromLocation = $vehicle->location ?: ($validated['from_location'] ?? 'Site Kerinci');
|
||||
$fromSiteStatus = $vehicle->site_status ?: 'inside_site';
|
||||
|
||||
// Sumber Armada Pengangkut (Internal / External / None)
|
||||
$transporterType = $validated['transporter_type'] ?? (!empty($validated['transporter_vehicle_id']) ? 'internal' : (!empty($validated['transporter_unit_name']) ? 'external' : 'none'));
|
||||
$transporterVehicleId = ($transporterType === 'internal') ? ($validated['transporter_vehicle_id'] ?? null) : null;
|
||||
$transporterOriginLocation = !empty($validated['transporter_origin_location']) ? trim($validated['transporter_origin_location']) : null;
|
||||
|
||||
// Nama armada pengangkut
|
||||
$transporterUnitName = !empty($validated['transporter_unit_name']) ? trim($validated['transporter_unit_name']) : null;
|
||||
if (empty($transporterUnitName) && !empty($validated['transporter_vehicle_id'])) {
|
||||
$transporterVeh = Vehicle::find($validated['transporter_vehicle_id']);
|
||||
if ($transporterType === 'internal' && !empty($transporterVehicleId)) {
|
||||
$transporterVeh = Vehicle::find($transporterVehicleId);
|
||||
if ($transporterVeh) {
|
||||
$plate = $transporterVeh->license_plate ? " ({$transporterVeh->license_plate})" : '';
|
||||
$transporterUnitName = "{$transporterVeh->code} - {$transporterVeh->brand_type}{$plate}";
|
||||
if (empty($transporterOriginLocation)) {
|
||||
$transporterOriginLocation = $transporterVeh->location ?: 'Site Kerinci';
|
||||
}
|
||||
}
|
||||
} elseif ($transporterType === 'none') {
|
||||
$transporterUnitName = 'Mobilisasi Mandiri (Tanpa Pengangkut)';
|
||||
$transporterOriginLocation = null;
|
||||
}
|
||||
|
||||
// Nama driver pengangkut
|
||||
$transporterDriverName = !empty($validated['transporter_driver_name']) ? trim($validated['transporter_driver_name']) : null;
|
||||
@@ -271,7 +312,9 @@ class UnitTransferController extends Controller
|
||||
'description' => !empty($validated['description']) ? trim($validated['description']) : null,
|
||||
'reported_by' => $reportedBy,
|
||||
'user_id' => auth()->id(),
|
||||
'transporter_vehicle_id' => $validated['transporter_vehicle_id'] ?? null,
|
||||
'transporter_type' => $transporterType,
|
||||
'transporter_vehicle_id' => $transporterVehicleId,
|
||||
'transporter_origin_location' => $transporterOriginLocation,
|
||||
'transporter_unit_name' => $transporterUnitName,
|
||||
'transporter_driver_id' => $validated['transporter_driver_id'] ?? null,
|
||||
'transporter_driver_name' => $transporterDriverName,
|
||||
@@ -294,6 +337,9 @@ class UnitTransferController extends Controller
|
||||
|
||||
// 3. Catat di audit log riwayat pergerakan unit (VehicleLocationHistory)
|
||||
$transporterSummary = $transporterUnitName ? " Pengangkut: {$transporterUnitName}" : "";
|
||||
if ($transporterOriginLocation) {
|
||||
$transporterSummary .= " [Asal: {$transporterOriginLocation}]";
|
||||
}
|
||||
if ($transporterDriverName) {
|
||||
$transporterSummary .= " (Driver: {$transporterDriverName})";
|
||||
}
|
||||
@@ -314,9 +360,9 @@ class UnitTransferController extends Controller
|
||||
'recorded_at' => Carbon::now(),
|
||||
]);
|
||||
|
||||
// 4. Jika opsi perbarui posisi truk pengangkut aktif
|
||||
if ($updateTransporter && !empty($validated['transporter_vehicle_id'])) {
|
||||
$transporterVeh = Vehicle::find($validated['transporter_vehicle_id']);
|
||||
// 4. Jika opsi perbarui posisi truk pengangkut aktif (Hanya armada internal)
|
||||
if ($transporterType === 'internal' && $updateTransporter && !empty($transporterVehicleId)) {
|
||||
$transporterVeh = Vehicle::find($transporterVehicleId);
|
||||
if ($transporterVeh && $transporterVeh->id !== $vehicle->id) {
|
||||
$transporterNote = $docNumber
|
||||
? "Armada Pengangkut BAST {$docNumber} untuk {$vehicle->code} ke {$toLocation}"
|
||||
@@ -332,6 +378,7 @@ class UnitTransferController extends Controller
|
||||
$transporterHistNote = $docNumber
|
||||
? "Armada Pengangkut: Mengantar {$vehicle->code} ({$vehicle->brand_type}) via BAST {$docNumber} ke {$toLocation}"
|
||||
: "Armada Pengangkut: Mengantar {$vehicle->code} ({$vehicle->brand_type}) transfer internal ke {$toLocation}";
|
||||
|
||||
VehicleLocationHistory::create([
|
||||
'vehicle_id' => $transporterVeh->id,
|
||||
'site_status' => $validated['to_site_status'],
|
||||
|
||||
@@ -277,9 +277,14 @@ class VehicleController extends Controller
|
||||
|
||||
/**
|
||||
* Halaman khusus pengelolaan Kategori Kendaraan Berat (Heavy Equipment / Alat Berat).
|
||||
* Mendukung navigasi hirarki 3 level:
|
||||
* - Level 1: Kelompok Operasional (HAULING, LOADER, SUPPORT, HANDLING, DRILLING, PIT SERVICE)
|
||||
* - Level 2: Tipe Alat Berat di dalam Kelompok (Dump Truck, Mixer Truck, Excavator, dll.)
|
||||
* - Level 3: Daftar Unit Fisik individual (DT 01, EX 01, dll.)
|
||||
*/
|
||||
public function indexSupport(Request $request): View
|
||||
{
|
||||
$selectedGroup = $request->input('group');
|
||||
$selectedType = $request->input('type');
|
||||
|
||||
// Master data daftar divisi perusahaan (gabungan standar + data existing di Employee & Vehicle)
|
||||
@@ -307,7 +312,58 @@ class VehicleController extends Controller
|
||||
->values()
|
||||
->all();
|
||||
|
||||
// Master data daftar kategori & tipe alat berat
|
||||
// Master data daftar kelompok operasional, kategori & tipe alat berat
|
||||
$availableGroups = ['HAULING', 'LOADER', 'SUPPORT', 'HANDLING', 'DRILLING', 'PIT SERVICE'];
|
||||
|
||||
$groupTypesMap = [
|
||||
'HAULING' => ['DUMP TRUCK', 'MIXER TRUCK', 'CAPSULE CEMENT', 'LOW BED', 'DUMP TRUCK FFT'],
|
||||
'LOADER' => ['EXCAVATOR', 'WHEEL LOADER', 'MUCKING LOADER'],
|
||||
'SUPPORT' => ['COMPRESSOR', 'CONCRETE PUMP', 'ENGINE GENSET', 'CONCRETE PUMP TRUCK', 'LIGHT TRUCK', 'SHOTCRETE', 'WET SHOTCRETE TRUCK', 'FUEL TRUCK', 'WATER TRUCK', 'SILENT SHEET PILE', 'SKYLIFT TRUCK', 'ASPHALT PATCH MIXER'],
|
||||
'HANDLING' => ['FORKLIFT', 'CRANE TRUCK', 'ROUGHTER CRANE', 'BOOMLIFT', 'CRAWLER CRANE', 'SCISSOR LIFT', 'TRAILER', 'TOWER CRANE', 'FLAT BED', 'CARRYDECK CRANE', 'LOW BED', 'MOBILE CRANE'],
|
||||
'DRILLING' => ['CRAWLER ROCK DRILL', 'BORE PILE', 'JUMBO DRILL', 'WHEEL RIG DRILL'],
|
||||
'PIT SERVICE' => ['BULLDOZER', 'VIBRO', 'WATER TRUCK', 'MOTOR GRADER'],
|
||||
];
|
||||
|
||||
// Gabungkan tipe dari database agar dinamis jika ada custom type baru
|
||||
$dbGroupTypes = Vehicle::where('category', 'unit_support')
|
||||
->whereNotNull('operational_group')
|
||||
->whereNotNull('unit_type')
|
||||
->where('unit_type', '!=', '')
|
||||
->select('operational_group', 'unit_type')
|
||||
->distinct()
|
||||
->get();
|
||||
foreach ($dbGroupTypes as $gt) {
|
||||
$grpKey = strtoupper(trim($gt->operational_group));
|
||||
$tVal = strtoupper(trim($gt->unit_type));
|
||||
if (!isset($groupTypesMap[$grpKey])) {
|
||||
$groupTypesMap[$grpKey] = [];
|
||||
}
|
||||
if (!in_array($tVal, $groupTypesMap[$grpKey])) {
|
||||
$groupTypesMap[$grpKey][] = $tVal;
|
||||
}
|
||||
}
|
||||
foreach ($groupTypesMap as $grpKey => &$tList) {
|
||||
sort($tList);
|
||||
}
|
||||
unset($tList);
|
||||
|
||||
$availableLocations = Vehicle::whereNotNull('location')
|
||||
->where('location', '!=', '')
|
||||
->distinct()
|
||||
->pluck('location')
|
||||
->sort()
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$availableBrands = Vehicle::where('category', 'unit_support')
|
||||
->whereNotNull('brand')
|
||||
->where('brand', '!=', '')
|
||||
->distinct()
|
||||
->pluck('brand')
|
||||
->sort()
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$availableCategories = Vehicle::where('category', 'unit_support')
|
||||
->whereNotNull('unit_category')
|
||||
->where('unit_category', '!=', '')
|
||||
@@ -323,8 +379,81 @@ class VehicleController extends Controller
|
||||
|
||||
$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)
|
||||
// Metadata kelompok operasional (icon, badge style, keterangan)
|
||||
$groupMetadata = [
|
||||
'HAULING' => [
|
||||
'icon' => 'fa-truck-moving',
|
||||
'color' => 'indigo',
|
||||
'badge' => 'bg-indigo-50 text-indigo-700 border-indigo-200',
|
||||
'icon_bg' => 'bg-indigo-100 text-indigo-800 border-indigo-300',
|
||||
'desc' => 'Armada pengangkutan material tanah, batuan, semen, beton curah, dan mobilisasi berat (Dump Truck, Truk Mixer, Capsule Cement, Low Bed).',
|
||||
],
|
||||
'LOADER' => [
|
||||
'icon' => 'fa-truck-monster',
|
||||
'color' => 'amber',
|
||||
'badge' => 'bg-amber-50 text-amber-800 border-amber-200',
|
||||
'icon_bg' => 'bg-amber-100 text-amber-800 border-amber-300',
|
||||
'desc' => 'Alat pemuatan material, penggalian tanah dan batuan terowongan proyek (Excavator, Wheel Loader, Mucking Loader).',
|
||||
],
|
||||
'SUPPORT' => [
|
||||
'icon' => 'fa-gears',
|
||||
'color' => 'emerald',
|
||||
'badge' => 'bg-emerald-50 text-emerald-800 border-emerald-200',
|
||||
'icon_bg' => 'bg-emerald-100 text-emerald-800 border-emerald-300',
|
||||
'desc' => 'Unit penunjang operasional, kelistrikan, suplai angin kompresi, dan pengecoran (Compressor, Genset, Concrete Pump, Fuel Truck, Light Truck).',
|
||||
],
|
||||
'HANDLING' => [
|
||||
'icon' => 'fa-boxes-stacked',
|
||||
'color' => 'purple',
|
||||
'badge' => 'bg-purple-50 text-purple-700 border-purple-200',
|
||||
'icon_bg' => 'bg-purple-100 text-purple-800 border-purple-300',
|
||||
'desc' => 'Alat pengangkatan dan penanganan material konstruksi serta akses ketinggian (Mobile Crane, Crane Truck, Crawler Crane, Forklift, Boomlift, Scissorlift).',
|
||||
],
|
||||
'DRILLING' => [
|
||||
'icon' => 'fa-arrows-down-to-line',
|
||||
'color' => 'rose',
|
||||
'badge' => 'bg-rose-50 text-rose-700 border-rose-200',
|
||||
'icon_bg' => 'bg-rose-100 text-rose-800 border-rose-300',
|
||||
'desc' => 'Alat pengeboran batuan keras, tiang pancang, dan pekerjaan bawah tanah (Crawler Rock Drill, Bore Pile, Jumbo Drill, Wheel Rig Drill).',
|
||||
],
|
||||
'PIT SERVICE' => [
|
||||
'icon' => 'fa-mountain',
|
||||
'color' => 'cyan',
|
||||
'badge' => 'bg-cyan-50 text-cyan-800 border-cyan-200',
|
||||
'icon_bg' => 'bg-cyan-100 text-cyan-800 border-cyan-300',
|
||||
'desc' => 'Alat pemeliharaan jalan tambang, perataan tanah, dan penyiraman debu lintasan proyek (Bulldozer, Motor Grader, Vibro Roller, Water Truck).',
|
||||
],
|
||||
];
|
||||
|
||||
// Global statistik untuk header
|
||||
$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');
|
||||
$totalGroups = count($availableGroups);
|
||||
|
||||
$perPage = (int) $request->input('per_page', 15);
|
||||
if (!in_array($perPage, [15, 50, 100])) {
|
||||
$perPage = 15;
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// LEVEL 3: JIKA USER MEMILIH TIPE TERTENTU (Daftar Unit Fisik)
|
||||
// =========================================================================
|
||||
if ($selectedType) {
|
||||
$level = 'units';
|
||||
|
||||
// Auto-detect group jika tidak disuplai
|
||||
if (!$selectedGroup) {
|
||||
$sampleUnit = Vehicle::where('category', 'unit_support')
|
||||
->where(function ($q) use ($selectedType) {
|
||||
$q->where('unit_type', $selectedType)->orWhere('unit_category', $selectedType);
|
||||
})->first();
|
||||
$selectedGroup = $sampleUnit?->operational_group ?: 'SUPPORT';
|
||||
}
|
||||
|
||||
$unitsQuery = Vehicle::where('category', 'unit_support')
|
||||
->where(function ($q) use ($selectedType) {
|
||||
$q->where('unit_type', $selectedType)
|
||||
@@ -353,12 +482,8 @@ class VehicleController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
$perPage = (int) $request->input('per_page', 15);
|
||||
if (!in_array($perPage, [15, 50, 100])) {
|
||||
$perPage = 15;
|
||||
}
|
||||
|
||||
$typeUnits = $unitsQuery->orderBy('code')->paginate($perPage)->withQueryString();
|
||||
$vehicles = $typeUnits;
|
||||
|
||||
// Statistik Khusus Tipe Terpilih
|
||||
$allOfType = Vehicle::where('category', 'unit_support')
|
||||
@@ -375,16 +500,12 @@ class VehicleController extends Controller
|
||||
$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(
|
||||
'level',
|
||||
'selectedGroup',
|
||||
'selectedType',
|
||||
'typeUnits',
|
||||
'vehicles',
|
||||
'totalUnitsOfType',
|
||||
'opCount',
|
||||
'stCount',
|
||||
@@ -392,10 +513,16 @@ class VehicleController extends Controller
|
||||
'insideCount',
|
||||
'outsideCount',
|
||||
'totalSupport',
|
||||
'totalGroups',
|
||||
'totalUnits',
|
||||
'totalOperation',
|
||||
'totalStandby',
|
||||
'totalBreakdown',
|
||||
'groupMetadata',
|
||||
'groupTypesMap',
|
||||
'availableLocations',
|
||||
'availableBrands',
|
||||
'availableGroups',
|
||||
'availableCategories',
|
||||
'availableTypes',
|
||||
'availableDivisions',
|
||||
@@ -403,21 +530,25 @@ class VehicleController extends Controller
|
||||
));
|
||||
}
|
||||
|
||||
// 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');
|
||||
// =========================================================================
|
||||
// LEVEL 2: JIKA USER MEMILIH KELOMPOK OPERASIONAL (Daftar Tipe Alat di Kelompok Tersebut)
|
||||
// =========================================================================
|
||||
if ($selectedGroup) {
|
||||
$level = 'types';
|
||||
|
||||
// Query pengelompokan berdasarkan tipe
|
||||
$hasTypes = Vehicle::where('category', 'unit_support')->whereNotNull('unit_type')->where('unit_type', '!=', '')->exists();
|
||||
$groupUnitsQuery = Vehicle::where('category', 'unit_support')->where('operational_group', $selectedGroup);
|
||||
$groupTotalUnits = (clone $groupUnitsQuery)->count();
|
||||
$groupOpCount = (clone $groupUnitsQuery)->where('status', 'Operation')->count();
|
||||
$groupStCount = (clone $groupUnitsQuery)->where('status', 'Standby')->count();
|
||||
$groupBdCount = (clone $groupUnitsQuery)->where('status', 'Breakdown')->count();
|
||||
$groupInsideCount = (clone $groupUnitsQuery)->where('site_status', 'inside_site')->count();
|
||||
$groupOutsideCount = (clone $groupUnitsQuery)->where('site_status', 'outside_site')->count();
|
||||
$groupTypesCount = (clone $groupUnitsQuery)->whereNotNull('unit_type')->where('unit_type', '!=', '')->distinct('unit_type')->count('unit_type');
|
||||
|
||||
if ($hasTypes) {
|
||||
$typeGroupsQuery = Vehicle::where('category', 'unit_support')
|
||||
$typesQuery = Vehicle::where('category', 'unit_support')
|
||||
->where('operational_group', $selectedGroup)
|
||||
->select(
|
||||
DB::raw("COALESCE(NULLIF(unit_type, ''), 'LAINNYA') as unit_type"),
|
||||
'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"),
|
||||
@@ -430,14 +561,14 @@ class VehicleController extends Controller
|
||||
DB::raw('MIN(id) as sample_id'),
|
||||
DB::raw('MIN(code) as code')
|
||||
)
|
||||
->groupBy(DB::raw("COALESCE(NULLIF(unit_type, ''), 'LAINNYA')"));
|
||||
->groupBy('unit_type');
|
||||
|
||||
if ($request->filled('unit_category')) {
|
||||
$typeGroupsQuery->where('unit_category', $request->input('unit_category'));
|
||||
$typesQuery->where('unit_category', $request->input('unit_category'));
|
||||
}
|
||||
if ($request->filled('search')) {
|
||||
$search = trim($request->input('search'));
|
||||
$typeGroupsQuery->where(function ($q) use ($search) {
|
||||
$typesQuery->where(function ($q) use ($search) {
|
||||
$q->where('unit_type', 'like', "%{$search}%")
|
||||
->orWhere('unit_category', 'like', "%{$search}%")
|
||||
->orWhere('brand_type', 'like', "%{$search}%")
|
||||
@@ -445,40 +576,98 @@ class VehicleController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
$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();
|
||||
}
|
||||
$types = $typesQuery->orderByDesc(DB::raw('COUNT(*)'))->paginate($perPage)->withQueryString();
|
||||
$vehicles = $types;
|
||||
|
||||
return view('qma.vehicles_support', compact(
|
||||
'level',
|
||||
'selectedGroup',
|
||||
'types',
|
||||
'vehicles',
|
||||
'groupTotalUnits',
|
||||
'groupOpCount',
|
||||
'groupStCount',
|
||||
'groupBdCount',
|
||||
'groupInsideCount',
|
||||
'groupOutsideCount',
|
||||
'groupTypesCount',
|
||||
'totalSupport',
|
||||
'totalGroups',
|
||||
'totalUnits',
|
||||
'totalOperation',
|
||||
'totalStandby',
|
||||
'totalBreakdown',
|
||||
'groupMetadata',
|
||||
'groupTypesMap',
|
||||
'availableLocations',
|
||||
'availableBrands',
|
||||
'availableGroups',
|
||||
'availableCategories',
|
||||
'availableTypes',
|
||||
'availableDivisions',
|
||||
'existingCodes'
|
||||
));
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// LEVEL 1: TAMPILAN UTAMA (6 KELOMPOK OPERASIONAL BESAR)
|
||||
// =========================================================================
|
||||
$level = 'groups';
|
||||
|
||||
$groupsQuery = Vehicle::where('category', 'unit_support')
|
||||
->select(
|
||||
'operational_group',
|
||||
DB::raw('COUNT(DISTINCT unit_type) as types_count'),
|
||||
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('MIN(code) as sample_code')
|
||||
)
|
||||
->groupBy('operational_group');
|
||||
|
||||
if ($request->filled('search')) {
|
||||
$search = trim($request->input('search'));
|
||||
$groupsQuery->where(function ($q) use ($search) {
|
||||
$q->where('operational_group', 'like', "%{$search}%")
|
||||
->orWhere('unit_type', 'like', "%{$search}%")
|
||||
->orWhere('unit_category', 'like', "%{$search}%")
|
||||
->orWhere('brand_type', 'like', "%{$search}%")
|
||||
->orWhere('code', 'like', "%{$search}%");
|
||||
});
|
||||
}
|
||||
|
||||
$groups = $groupsQuery
|
||||
->orderByRaw("CASE operational_group
|
||||
WHEN 'HAULING' THEN 1
|
||||
WHEN 'LOADER' THEN 2
|
||||
WHEN 'SUPPORT' THEN 3
|
||||
WHEN 'HANDLING' THEN 4
|
||||
WHEN 'DRILLING' THEN 5
|
||||
WHEN 'PIT SERVICE' THEN 6
|
||||
ELSE 7 END")
|
||||
->paginate($perPage)
|
||||
->withQueryString();
|
||||
|
||||
$vehicles = $groups;
|
||||
|
||||
return view('qma.vehicles_support', compact(
|
||||
'level',
|
||||
'groups',
|
||||
'vehicles',
|
||||
'totalSupport',
|
||||
'totalGroups',
|
||||
'totalUnits',
|
||||
'totalOperation',
|
||||
'totalStandby',
|
||||
'totalBreakdown',
|
||||
'groupMetadata',
|
||||
'groupTypesMap',
|
||||
'availableLocations',
|
||||
'availableBrands',
|
||||
'availableGroups',
|
||||
'availableCategories',
|
||||
'availableTypes',
|
||||
'availableDivisions',
|
||||
@@ -495,6 +684,19 @@ class VehicleController extends Controller
|
||||
|
||||
$query = $category->units();
|
||||
|
||||
if ($request->filled('group') || $request->filled('operational_group')) {
|
||||
$grp = $request->input('group') ?: $request->input('operational_group');
|
||||
$query->where('operational_group', $grp);
|
||||
}
|
||||
|
||||
if ($request->filled('type') || $request->filled('unit_type')) {
|
||||
$t = $request->input('type') ?: $request->input('unit_type');
|
||||
$query->where(function ($q) use ($t) {
|
||||
$q->where('unit_type', $t)
|
||||
->orWhere('unit_category', $t);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->filled('status')) {
|
||||
$query->where('status', $request->input('status'));
|
||||
}
|
||||
@@ -572,6 +774,19 @@ class VehicleController extends Controller
|
||||
{
|
||||
$query = Vehicle::unitSupportPhysical()->with('parent');
|
||||
|
||||
if ($request->filled('group') || $request->filled('operational_group')) {
|
||||
$grp = $request->input('group') ?: $request->input('operational_group');
|
||||
$query->where('operational_group', $grp);
|
||||
}
|
||||
|
||||
if ($request->filled('type') || $request->filled('unit_type')) {
|
||||
$t = $request->input('type') ?: $request->input('unit_type');
|
||||
$query->where(function ($q) use ($t) {
|
||||
$q->where('unit_type', $t)
|
||||
->orWhere('unit_category', $t);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->filled('status')) {
|
||||
$query->where('status', $request->input('status'));
|
||||
}
|
||||
@@ -611,6 +826,19 @@ class VehicleController extends Controller
|
||||
{
|
||||
$query = Vehicle::unitSupportCategories()->withCount('units');
|
||||
|
||||
if ($request->filled('group') || $request->filled('operational_group')) {
|
||||
$grp = $request->input('group') ?: $request->input('operational_group');
|
||||
$query->where('operational_group', $grp);
|
||||
}
|
||||
|
||||
if ($request->filled('type') || $request->filled('unit_type')) {
|
||||
$t = $request->input('type') ?: $request->input('unit_type');
|
||||
$query->where(function ($q) use ($t) {
|
||||
$q->where('unit_type', $t)
|
||||
->orWhere('unit_category', $t);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->filled('status')) {
|
||||
$query->where('status', $request->input('status'));
|
||||
}
|
||||
@@ -861,6 +1089,19 @@ class VehicleController extends Controller
|
||||
$category = Vehicle::unitSupportCategories()->withCount('units')->findOrFail($id);
|
||||
$query = $category->units();
|
||||
|
||||
if ($request->filled('group') || $request->filled('operational_group')) {
|
||||
$grp = $request->input('group') ?: $request->input('operational_group');
|
||||
$query->where('operational_group', $grp);
|
||||
}
|
||||
|
||||
if ($request->filled('type') || $request->filled('unit_type')) {
|
||||
$t = $request->input('type') ?: $request->input('unit_type');
|
||||
$query->where(function ($q) use ($t) {
|
||||
$q->where('unit_type', $t)
|
||||
->orWhere('unit_category', $t);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->filled('status')) {
|
||||
$query->where('status', $request->input('status'));
|
||||
}
|
||||
@@ -938,6 +1179,19 @@ class VehicleController extends Controller
|
||||
$category = Vehicle::unitSupportCategories()->withCount('units')->findOrFail($id);
|
||||
$query = $category->units();
|
||||
|
||||
if ($request->filled('group') || $request->filled('operational_group')) {
|
||||
$grp = $request->input('group') ?: $request->input('operational_group');
|
||||
$query->where('operational_group', $grp);
|
||||
}
|
||||
|
||||
if ($request->filled('type') || $request->filled('unit_type')) {
|
||||
$t = $request->input('type') ?: $request->input('unit_type');
|
||||
$query->where(function ($q) use ($t) {
|
||||
$q->where('unit_type', $t)
|
||||
->orWhere('unit_category', $t);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->filled('status')) {
|
||||
$query->where('status', $request->input('status'));
|
||||
}
|
||||
@@ -1103,7 +1357,7 @@ class VehicleController extends Controller
|
||||
$rules = [
|
||||
'code' => ['required', 'string', 'max:50', 'unique:vehicles,code'],
|
||||
'category' => ['required', 'in:light_vehicle,unit_support'],
|
||||
'brand_type' => ['required', 'string', 'max:150'],
|
||||
'brand_type' => [$category === 'unit_support' ? 'nullable' : 'required', 'string', 'max:150'],
|
||||
'license_plate' => ['nullable', 'string', 'max:30'],
|
||||
'serial_number' => ['nullable', 'string', 'max:100'],
|
||||
'ownership' => ['nullable', 'string', 'max:150'],
|
||||
@@ -1118,12 +1372,14 @@ class VehicleController extends Controller
|
||||
// Atribut opsional spesifik Heavy Equipment (Kendaraan Berat)
|
||||
if ($category === 'unit_support') {
|
||||
$rules = array_merge($rules, [
|
||||
'operational_group' => ['required', 'string', 'max:50'],
|
||||
'unit_type' => ['required', 'string', 'max:100'],
|
||||
'unit_category' => ['nullable', 'string', 'max:100'],
|
||||
'unit_type' => ['nullable', 'string', 'max:100'],
|
||||
'brand' => ['nullable', 'string', 'max:100'],
|
||||
'model_number' => ['nullable', 'string', 'max:100'],
|
||||
'production_year' => ['nullable', 'integer', 'min:1980', 'max:' . (date('Y') + 1)],
|
||||
'location' => ['nullable', 'string', 'max:150'],
|
||||
'site_status' => ['nullable', 'in:inside_site,outside_site'],
|
||||
'fuel_consumption' => ['nullable', 'numeric', 'min:0'],
|
||||
'silo_document' => ['nullable', 'string', 'max:150'],
|
||||
'stnk_document' => ['nullable', 'string', 'max:150'],
|
||||
@@ -1135,6 +1391,8 @@ class VehicleController extends Controller
|
||||
$validated = $request->validate($rules, [
|
||||
'code.required' => 'Kode kendaraan wajib diisi.',
|
||||
'code.unique' => 'Kode sudah ada, silakan gunakan kode lain.',
|
||||
'operational_group.required' => 'Kelompok operasional wajib dipilih.',
|
||||
'unit_type.required' => 'Tipe alat berat wajib dipilih/diisi.',
|
||||
'brand_type.required' => 'Merek dan spesifikasi/tipe wajib diisi.',
|
||||
'current_km.required' => 'Nilai KM / HM awal wajib diisi.',
|
||||
'status.required' => 'Status operasional wajib dipilih.',
|
||||
@@ -1143,6 +1401,37 @@ class VehicleController extends Controller
|
||||
if ($category === 'unit_support') {
|
||||
$validated['status'] = $validated['status'] ?? 'Operation';
|
||||
$validated['current_km'] = $validated['current_km'] ?? 0;
|
||||
$validated['code'] = strtoupper(trim($validated['code']));
|
||||
$validated['operational_group'] = strtoupper(trim($validated['operational_group']));
|
||||
$validated['unit_type'] = strtoupper(trim($validated['unit_type']));
|
||||
$validated['unit_category'] = !empty($validated['unit_category']) ? $validated['unit_category'] : $validated['unit_type'];
|
||||
|
||||
// Jika brand_type kosong, susun otomatis dari brand dan model_number
|
||||
if (empty($validated['brand_type'])) {
|
||||
$brandPart = trim(($validated['brand'] ?? '') . ' ' . ($validated['model_number'] ?? ''));
|
||||
$validated['brand_type'] = $brandPart ?: $validated['unit_type'];
|
||||
}
|
||||
|
||||
// Site status auto-detection jika kosong
|
||||
if (empty($validated['site_status']) && !empty($validated['location'])) {
|
||||
$upperLoc = strtoupper($validated['location']);
|
||||
$outsideKeywords = ['PT.', 'HO', 'LAMPUNG', 'JAKARTA', 'CIDAS', 'POSO', 'MEDCO', 'SULINDO', 'BMS', 'BHARA', 'BUKAKA', 'ACEH'];
|
||||
$isOutside = false;
|
||||
foreach ($outsideKeywords as $kw) {
|
||||
if (str_contains($upperLoc, $kw)) {
|
||||
$isOutside = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$validated['site_status'] = $isOutside ? 'outside_site' : 'inside_site';
|
||||
} elseif (empty($validated['site_status'])) {
|
||||
$validated['site_status'] = 'inside_site';
|
||||
}
|
||||
|
||||
if (!empty($validated['location'])) {
|
||||
$validated['location_updated_at'] = now();
|
||||
$validated['location_updated_by'] = auth()->user()?->name ?? 'Admin QMA';
|
||||
}
|
||||
}
|
||||
|
||||
$validated['is_timesheet_mobile'] = $request->boolean('is_timesheet_mobile');
|
||||
@@ -1156,19 +1445,20 @@ class VehicleController extends Controller
|
||||
$vehicle = Vehicle::create($validated);
|
||||
|
||||
if ($vehicle->isSupportCategory()) {
|
||||
// Otomatis buatkan Master Template P2H baru (default kosong tanpa butir pertanyaan)
|
||||
// Otomatis buatkan Master Template P2H baru jika belum ada
|
||||
$templateCode = $vehicle->unit_type ?: $vehicle->code;
|
||||
$template = P2hTemplate::firstOrCreate(
|
||||
['code' => $vehicle->code],
|
||||
['code' => $templateCode],
|
||||
[
|
||||
'name' => $vehicle->unit_category ?: $vehicle->brand_type,
|
||||
'description' => "Template form inspeksi P2H resmi untuk kategori {$vehicle->brand_type} (Kode: {$vehicle->code}).",
|
||||
'name' => $vehicle->unit_type ?: $vehicle->brand_type,
|
||||
'description' => "Template form inspeksi P2H resmi untuk {$vehicle->unit_type} (Kode: {$templateCode}).",
|
||||
'is_active' => true,
|
||||
]
|
||||
);
|
||||
$vehicle->update(['p2h_template_id' => $template->id]);
|
||||
}
|
||||
|
||||
$categoryLabel = $vehicle->isLightVehicle() ? 'Light Vehicle (LV)' : 'Kategori Heavy Equipment';
|
||||
$categoryLabel = $vehicle->isLightVehicle() ? 'Light Vehicle (LV)' : 'Unit Heavy Equipment';
|
||||
|
||||
return back()->with('success', "Data {$categoryLabel} [{$vehicle->code}] berhasil ditambahkan ke sistem.");
|
||||
}
|
||||
@@ -1186,19 +1476,21 @@ class VehicleController extends Controller
|
||||
$rules = [
|
||||
'code' => ['required', 'string', 'max:50', Rule::unique('vehicles', 'code')->ignore($vehicle->id)],
|
||||
'category' => ['required', 'in:light_vehicle,unit_support'],
|
||||
'brand_type' => ['required', 'string', 'max:150'],
|
||||
'brand_type' => [$vehicle->isSupportCategory() ? 'nullable' : 'required', 'string', 'max:150'],
|
||||
'license_plate' => ['nullable', 'string', 'max:30'],
|
||||
'serial_number' => ['nullable', 'string', 'max:100'],
|
||||
'ownership' => ['nullable', 'string', 'max:150'],
|
||||
'division' => ['nullable', 'string', 'max:100'],
|
||||
'status' => [$vehicle->isSupportCategory() ? 'nullable' : 'required', 'string', 'in:Operation,Standby,Breakdown,Maintenance'],
|
||||
'status' => ['required', 'string', 'in:Operation,Standby,Breakdown,Maintenance'],
|
||||
'current_km' => [$vehicle->isSupportCategory() ? 'nullable' : 'required', 'numeric', 'min:0'],
|
||||
'operational_group' => ['nullable', 'string', 'max:50'],
|
||||
'unit_category' => ['nullable', 'string', 'max:100'],
|
||||
'unit_type' => ['nullable', 'string', 'max:100'],
|
||||
'brand' => ['nullable', 'string', 'max:100'],
|
||||
'model_number' => ['nullable', 'string', 'max:100'],
|
||||
'production_year' => ['nullable', 'integer', 'min:1980', 'max:' . (date('Y') + 1)],
|
||||
'location' => ['nullable', 'string', 'max:150'],
|
||||
'site_status' => ['nullable', 'in:inside_site,outside_site'],
|
||||
'fuel_consumption' => ['nullable', 'numeric', 'min:0'],
|
||||
'silo_document' => ['nullable', 'string', 'max:150'],
|
||||
'stnk_document' => ['nullable', 'string', 'max:150'],
|
||||
@@ -1216,6 +1508,39 @@ class VehicleController extends Controller
|
||||
'current_km.required' => 'Nilai KM / HM wajib diisi.',
|
||||
]);
|
||||
|
||||
if ($vehicle->isSupportCategory()) {
|
||||
$validated['code'] = strtoupper(trim($validated['code']));
|
||||
if (!empty($validated['operational_group'])) {
|
||||
$validated['operational_group'] = strtoupper(trim($validated['operational_group']));
|
||||
}
|
||||
if (!empty($validated['unit_type'])) {
|
||||
$validated['unit_type'] = strtoupper(trim($validated['unit_type']));
|
||||
$validated['unit_category'] = !empty($validated['unit_category']) ? $validated['unit_category'] : $validated['unit_type'];
|
||||
}
|
||||
if (empty($validated['brand_type'])) {
|
||||
$brandPart = trim(($validated['brand'] ?? '') . ' ' . ($validated['model_number'] ?? ''));
|
||||
$validated['brand_type'] = $brandPart ?: ($vehicle->brand_type ?: $validated['code']);
|
||||
}
|
||||
if ($request->filled('site_status')) {
|
||||
$validated['site_status'] = $request->input('site_status');
|
||||
} elseif (!empty($validated['location']) && $validated['location'] !== $vehicle->location) {
|
||||
$upperLoc = strtoupper($validated['location']);
|
||||
$outsideKeywords = ['PT.', 'HO', 'LAMPUNG', 'JAKARTA', 'CIDAS', 'POSO', 'MEDCO', 'SULINDO', 'BMS', 'BHARA', 'BUKAKA', 'ACEH'];
|
||||
$isOutside = false;
|
||||
foreach ($outsideKeywords as $kw) {
|
||||
if (str_contains($upperLoc, $kw)) {
|
||||
$isOutside = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$validated['site_status'] = $isOutside ? 'outside_site' : 'inside_site';
|
||||
}
|
||||
if (!empty($validated['location']) && $validated['location'] !== $vehicle->location) {
|
||||
$validated['location_updated_at'] = now();
|
||||
$validated['location_updated_by'] = auth()->user()?->name ?? 'Admin QMA';
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->hasFile('photo')) {
|
||||
ImageCompressionService::deleteIfExists($vehicle->photo_path);
|
||||
$validated['photo_path'] = ImageCompressionService::uploadAndCompress($request->file('photo'), 'vehicles', 800, 800, 75);
|
||||
|
||||
@@ -24,7 +24,9 @@ class UnitTransfer extends Model
|
||||
'description',
|
||||
'reported_by',
|
||||
'user_id',
|
||||
'transporter_type',
|
||||
'transporter_vehicle_id',
|
||||
'transporter_origin_location',
|
||||
'transporter_unit_name',
|
||||
'transporter_driver_id',
|
||||
'transporter_driver_name',
|
||||
|
||||
@@ -29,6 +29,7 @@ class Vehicle extends Model
|
||||
'photo_path',
|
||||
'unit_category',
|
||||
'unit_type',
|
||||
'operational_group',
|
||||
'brand',
|
||||
'model_number',
|
||||
'production_year',
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('unit_transfers', function (Blueprint $table) {
|
||||
$table->string('transporter_type', 30)->default('internal')->after('user_id');
|
||||
$table->string('transporter_origin_location', 255)->nullable()->after('transporter_vehicle_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('unit_transfers', function (Blueprint $table) {
|
||||
$table->dropColumn(['transporter_type', 'transporter_origin_location']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('vehicles', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('vehicles', 'operational_group')) {
|
||||
$table->string('operational_group', 50)->nullable()->after('unit_type')->index();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('vehicles', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('vehicles', 'operational_group')) {
|
||||
$table->dropColumn('operational_group');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -282,11 +282,55 @@
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="text-base font-extrabold text-slate-900">2. Armada & Supir Pengangkut (Transporter)</h3>
|
||||
<p class="text-xs text-slate-500">Truk pengangkut dapat dipilih dari lokasi yang sama atau dimobilisasi dari pool/workshop lain.</p>
|
||||
<p class="text-xs text-slate-500">Pilih kendaraan pengangkut dari armada internal proyek KMH atau input armada dari vendor/rekanan luar.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Banner Info Logistik Rute (Muncul saat Truk dipilih) -->
|
||||
<!-- Pilihan Jenis Pengangkut: Dari Dalam KMH (Internal) vs Dari Luar KMH (Eksternal) -->
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-slate-700 mb-2">
|
||||
Asal Armada Pengangkut <span class="text-rose-500">*</span>
|
||||
</label>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3 max-w-xl">
|
||||
<!-- Opsi 1: Dari Dalam KMH -->
|
||||
<label id="card_transporter_internal" class="flex items-center space-x-3 p-3 rounded-xl border-2 border-blue-600 bg-blue-50/50 text-blue-950 transition cursor-pointer shadow-xs">
|
||||
<input type="radio"
|
||||
name="transporter_type"
|
||||
value="internal"
|
||||
id="radio_transporter_internal"
|
||||
{{ old('transporter_type', 'internal') === 'internal' ? 'checked' : '' }}
|
||||
onchange="onTransporterTypeChanged(this.value)"
|
||||
class="text-blue-600 focus:ring-blue-500">
|
||||
<div class="text-left">
|
||||
<span class="block text-xs font-bold flex items-center space-x-1.5">
|
||||
<i class="fa-solid fa-building-shield text-blue-600"></i>
|
||||
<span>Dari Dalam KMH (Armada Internal)</span>
|
||||
</span>
|
||||
<span class="text-[10px] text-slate-500 block mt-0.5">Pilih lokasi asal armada & unit pengangkut proyek</span>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<!-- Opsi 2: Dari Luar KMH -->
|
||||
<label id="card_transporter_external" class="flex items-center space-x-3 p-3 rounded-xl border border-slate-200 hover:border-slate-300 bg-white text-slate-700 transition cursor-pointer">
|
||||
<input type="radio"
|
||||
name="transporter_type"
|
||||
value="external"
|
||||
id="radio_transporter_external"
|
||||
{{ old('transporter_type') === 'external' ? 'checked' : '' }}
|
||||
onchange="onTransporterTypeChanged(this.value)"
|
||||
class="text-blue-600 focus:ring-blue-500">
|
||||
<div class="text-left">
|
||||
<span class="block text-xs font-bold flex items-center space-x-1.5">
|
||||
<i class="fa-solid fa-truck-ramp-box text-slate-500"></i>
|
||||
<span>Dari Luar KMH (Rental / Vendor)</span>
|
||||
</span>
|
||||
<span class="text-[10px] text-slate-500 block mt-0.5">Input manual lokasi asal & nama unit rekanan luar</span>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Banner Info Logistik Rute (Muncul saat Truk dipilih / terisi) -->
|
||||
<div id="routeLogisticsBanner" class="hidden p-3.5 rounded-xl bg-blue-50/80 border border-blue-200 text-xs text-blue-900 flex items-start space-x-3">
|
||||
<i class="fa-solid fa-route text-blue-700 text-sm mt-0.5"></i>
|
||||
<div class="flex-1">
|
||||
@@ -295,51 +339,66 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Grid 2 Kolom: Pilih Mobil Pengangkut & Nama Pengangkut -->
|
||||
<!-- ============================================== -->
|
||||
<!-- KONTAINER 1: PENGANGKUT DARI DALAM KMH -->
|
||||
<!-- ============================================== -->
|
||||
<div id="transporterInternalContainer" class="space-y-4">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<!-- Pilih Mobil dari Unit Kita -->
|
||||
<!-- KIRI: PILIH LOKASI ASAL PENGANGKUT (INTERNAL) -->
|
||||
<div>
|
||||
<label for="transporter_vehicle_id" class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||
<span>Pilih Kendaraan Pengangkut (Armada Kita)</span>
|
||||
<span id="transporterLocationHint" class="text-[10px] text-slate-400 font-normal">Truk / Lowbed / Towing</span>
|
||||
<label for="transporter_origin_location_select" class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||
<span>Lokasi Asal Kendaraan Pengangkut</span>
|
||||
<span class="text-[10px] text-blue-700 font-semibold">Filter Berdasarkan Posisi</span>
|
||||
</label>
|
||||
<select name="transporter_vehicle_id"
|
||||
id="transporter_vehicle_id"
|
||||
onchange="onTransporterSelected(this)"
|
||||
class="w-full px-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition bg-white text-slate-800">
|
||||
<option value="">-- Tanpa Truk Pengangkut / Rental Luar / Mobilisasi Mandiri --</option>
|
||||
@foreach($transporterUnits as $tu)
|
||||
<option value="{{ $tu->id }}"
|
||||
data-code="{{ $tu->code }}"
|
||||
data-name="{{ $tu->code }} - {{ $tu->brand_type }}{{ $tu->license_plate ? ' (' . $tu->license_plate . ')' : '' }}"
|
||||
data-location="{{ $tu->location ?: 'Pool Workshop GA' }}"
|
||||
{{ old('transporter_vehicle_id') == $tu->id ? 'selected' : '' }}>
|
||||
{{ $tu->code }} - {{ $tu->brand_type }} [Posisi: {{ $tu->location ?: 'Pool Workshop' }}]
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-map-pin absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<select id="transporter_origin_location_select"
|
||||
onchange="onTransporterOriginChanged(this.value)"
|
||||
class="w-full pl-9 pr-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-600 transition bg-white text-slate-800 font-bold">
|
||||
<option value="" selected>-- Pilih Lokasi Asal Kendaraan Pengangkut --</option>
|
||||
<option value="ALL">[Tampilkan Semua Lokasi / Semua Armada]</option>
|
||||
@foreach($transporterLocations as $tLoc => $tCount)
|
||||
<option value="{{ $tLoc }}" {{ old('transporter_origin_location') === $tLoc ? 'selected' : '' }}>
|
||||
{{ $tLoc }} ({{ $tCount }} Unit Tersedia)
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<p class="text-[10px] text-slate-400 mt-1">Pilih lokasi asal untuk memfilter unit pengangkut yang standby di titik tersebut.</p>
|
||||
</div>
|
||||
|
||||
<!-- Input / Snapshot Nama Armada Pengangkut -->
|
||||
<!-- KANAN: PILIH KENDARAAN PENGANGKUT (INPUT KETIKAN TERFILTER) -->
|
||||
<div>
|
||||
<label for="transporter_unit_name" class="block text-xs font-bold text-slate-700 mb-1.5">
|
||||
Identitas / Keterangan Kendaraan Pengangkut
|
||||
<label for="internal_transporter_search" class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||
<span>Kendaraan Pengangkut (Armada Kita)</span>
|
||||
<span id="transporterCounterBadge" class="text-[10px] font-semibold text-blue-700 bg-blue-50 px-2 py-0.5 rounded border border-blue-200 hidden"></span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-truck absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<i class="fa-solid fa-truck-moving absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text"
|
||||
name="transporter_unit_name"
|
||||
id="transporter_unit_name"
|
||||
value="{{ old('transporter_unit_name') }}"
|
||||
placeholder="Contoh: DT-05 Hino 500 / Truk Towing Rekanan Luar"
|
||||
class="w-full pl-9 pr-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition bg-white text-slate-800 font-semibold">
|
||||
id="internal_transporter_search"
|
||||
list="internalTransporterSuggestionList"
|
||||
placeholder="Ketik kode/tipe truk (cth: LB 01, DT 05, Lowbed...)"
|
||||
oninput="onInternalTransporterInput(this.value)"
|
||||
autocomplete="off"
|
||||
class="w-full pl-9 pr-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-600 transition bg-white text-slate-800 font-semibold">
|
||||
</div>
|
||||
<p class="text-[10px] text-slate-400 mt-1">Otomatis terisi jika memilih armada internal, atau ketik nama vendor/unit rekanan luar.</p>
|
||||
<p class="text-[10px] text-slate-400 mt-1">Ketik atau pilih dari rekomendasi truk pengangkut internal (Lowbed, Flatbed, Dump Truck, Trailer, dll.).</p>
|
||||
|
||||
<!-- Datalist Autocomplete Khusus Truk Pengangkut Internal -->
|
||||
<datalist id="internalTransporterSuggestionList">
|
||||
@foreach($transporterUnits as $tu)
|
||||
<option value="{{ $tu->code }} - {{ $tu->brand_type }}{{ $tu->license_plate ? ' (' . $tu->license_plate . ')' : '' }} [Posisi: {{ $tu->location ?: 'Site Kerinci' }}]" data-id="{{ $tu->id }}">
|
||||
@endforeach
|
||||
</datalist>
|
||||
|
||||
<!-- Hidden ID untuk backend -->
|
||||
<input type="hidden" name="transporter_vehicle_id" id="transporter_vehicle_id" value="{{ old('transporter_vehicle_id') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Opsi Sinkronisasi Lokasi Truk Pengangkut -->
|
||||
<div class="p-3 rounded-xl bg-slate-50 border border-slate-200 flex items-center space-x-3">
|
||||
<!-- Opsi Sinkronisasi Lokasi Truk Pengangkut Internal -->
|
||||
<div id="transporterUpdateCheckboxWrapper" class="p-3 rounded-xl bg-slate-50 border border-slate-200 flex items-center space-x-3">
|
||||
<input type="checkbox"
|
||||
name="update_transporter_location"
|
||||
id="update_transporter_location"
|
||||
@@ -350,9 +409,58 @@
|
||||
Perbarui juga posisi terkini truk pengangkut ke lokasi tujuan setelah proses pemindahan selesai
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ============================================== -->
|
||||
<!-- KONTAINER 2: PENGANGKUT DARI LUAR KMH -->
|
||||
<!-- ============================================== -->
|
||||
<div id="transporterExternalContainer" class="hidden space-y-4">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<!-- KIRI: ASAL KENDARAAN PENGANGKUT (ISIAN TEKS MANUAL) -->
|
||||
<div>
|
||||
<label for="transporter_origin_location_input" class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||
<span>Asal Kendaraan Pengangkut (Luar)</span>
|
||||
<span class="text-[10px] text-slate-400 font-normal">Ketik Bebas / Rekomendasi</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-map-location-dot absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text"
|
||||
id="transporter_origin_location_input"
|
||||
list="locationSuggestionList"
|
||||
placeholder="Contoh: Pool Jambi, Workshop Padang, PT Bhara Seva..."
|
||||
oninput="onExternalOriginInput(this.value)"
|
||||
value="{{ old('transporter_type') === 'external' ? old('transporter_origin_location') : '' }}"
|
||||
class="w-full pl-9 pr-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-600 transition bg-white text-slate-800 font-semibold">
|
||||
</div>
|
||||
<p class="text-[10px] text-slate-400 mt-1">Ketik kota asal, pool rekanan, atau nama subkon penyedia armada.</p>
|
||||
</div>
|
||||
|
||||
<!-- KANAN: IDENTITAS / NAMA KENDARAAN PENGANGKUT (ISIAN TEKS MANUAL) -->
|
||||
<div>
|
||||
<label for="transporter_unit_name_input" class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||
<span>Identitas / Nama Kendaraan Pengangkut</span>
|
||||
<span class="text-[10px] text-slate-400 font-normal">Isian Teks Bebas</span>
|
||||
</label>
|
||||
<div class="relative">
|
||||
<i class="fa-solid fa-truck absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<input type="text"
|
||||
id="transporter_unit_name_input"
|
||||
placeholder="Contoh: Truk Tronton Hino BA 1234 XY / Lowbed Rental PT Surya"
|
||||
oninput="onExternalUnitNameInput(this.value)"
|
||||
value="{{ old('transporter_type') === 'external' ? old('transporter_unit_name') : '' }}"
|
||||
class="w-full pl-9 pr-3.5 py-2.5 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-600 transition bg-white text-slate-800 font-semibold">
|
||||
</div>
|
||||
<p class="text-[10px] text-slate-400 mt-1">Ketik jenis kendaraan, nomor plat polisi, atau identitas unit rekanan luar.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Field Hidden Final yang Dikirim ke Server -->
|
||||
<input type="hidden" name="transporter_origin_location" id="final_transporter_origin_location" value="{{ old('transporter_origin_location') }}">
|
||||
<input type="hidden" name="transporter_unit_name" id="final_transporter_unit_name" value="{{ old('transporter_unit_name') }}">
|
||||
|
||||
<!-- Grid 2 Kolom: Supir Pengangkut & Catatan Angkutan -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 pt-1">
|
||||
<!-- Supir Pengangkut -->
|
||||
<div>
|
||||
<label for="transporter_driver_name" class="block text-xs font-bold text-slate-700 mb-1.5 flex items-center justify-between">
|
||||
@@ -482,8 +590,20 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Inisialisasi daftar semua unit alat berat dari options
|
||||
// Inisialisasi daftar semua unit alat berat & armada pengangkut
|
||||
let allHeavyUnits = [];
|
||||
let allTransporterUnits = [
|
||||
@foreach($transporterUnits as $tu)
|
||||
{
|
||||
id: {{ $tu->id }},
|
||||
code: @json($tu->code),
|
||||
name: @json($tu->code . ' - ' . $tu->brand_type . ($tu->license_plate ? ' (' . $tu->license_plate . ')' : '')),
|
||||
location: @json($tu->location ?: 'Site Kerinci'),
|
||||
category: @json($tu->unit_category ?? 'Truk'),
|
||||
text: @json($tu->code . ' - ' . $tu->brand_type . ($tu->license_plate ? ' (' . $tu->license_plate . ')' : '') . ' [Posisi: ' . ($tu->location ?: 'Site Kerinci') . ']')
|
||||
},
|
||||
@endforeach
|
||||
];
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const unitSelect = document.getElementById('vehicle_id');
|
||||
@@ -504,17 +624,193 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Cek jika sudah ada lokasi awal (dari old value atau selectedOriginLocation)
|
||||
// Cek jika sudah ada lokasi awal alat berat (dari old value atau selectedOriginLocation)
|
||||
const originSelect = document.getElementById('origin_location');
|
||||
if (originSelect && originSelect.value) {
|
||||
onOriginLocationChanged(originSelect.value, "{{ old('vehicle_id', $selectedVehicleId ?? '') }}");
|
||||
}
|
||||
|
||||
// Inisialisasi tampilan jenis pengangkut (internal vs external)
|
||||
const currentTransporterType = document.querySelector('input[name="transporter_type"]:checked')?.value || 'internal';
|
||||
onTransporterTypeChanged(currentTransporterType);
|
||||
|
||||
// Inisialisasi datalist saran truk internal
|
||||
const oldTransporterOrigin = "{{ old('transporter_origin_location') }}";
|
||||
const oldTransporterId = "{{ old('transporter_vehicle_id') }}";
|
||||
if (currentTransporterType === 'internal') {
|
||||
if (oldTransporterOrigin) {
|
||||
const tLocSelect = document.getElementById('transporter_origin_location_select');
|
||||
if (tLocSelect) tLocSelect.value = oldTransporterOrigin;
|
||||
onTransporterOriginChanged(oldTransporterOrigin, oldTransporterId);
|
||||
} else if (oldTransporterId) {
|
||||
const matched = allTransporterUnits.find(u => String(u.id) === String(oldTransporterId));
|
||||
if (matched) {
|
||||
const tLocSelect = document.getElementById('transporter_origin_location_select');
|
||||
if (tLocSelect) tLocSelect.value = matched.location;
|
||||
onTransporterOriginChanged(matched.location, oldTransporterId);
|
||||
} else {
|
||||
onTransporterOriginChanged('');
|
||||
}
|
||||
} else {
|
||||
onTransporterOriginChanged('');
|
||||
}
|
||||
}
|
||||
|
||||
// Inisialisasi tampilan BAST berdasarkan status site awal
|
||||
const currentSiteStatus = document.querySelector('input[name="to_site_status"]:checked')?.value || 'inside_site';
|
||||
onSiteStatusChanged(currentSiteStatus);
|
||||
});
|
||||
|
||||
/**
|
||||
* Handler untuk Jenis Pengangkut (Dari Dalam KMH vs Dari Luar KMH)
|
||||
*/
|
||||
function onTransporterTypeChanged(type) {
|
||||
const cardInternal = document.getElementById('card_transporter_internal');
|
||||
const cardExternal = document.getElementById('card_transporter_external');
|
||||
const containerInternal = document.getElementById('transporterInternalContainer');
|
||||
const containerExternal = document.getElementById('transporterExternalContainer');
|
||||
const updateCheckboxWrapper = document.getElementById('transporterUpdateCheckboxWrapper');
|
||||
const updateCheckbox = document.getElementById('update_transporter_location');
|
||||
|
||||
if (type === 'external') {
|
||||
// Style Card External Aktif
|
||||
cardExternal.className = 'flex items-center space-x-3 p-3 rounded-xl border-2 border-blue-600 bg-blue-50/50 text-blue-950 transition cursor-pointer shadow-xs';
|
||||
cardInternal.className = 'flex items-center space-x-3 p-3 rounded-xl border border-slate-200 hover:border-slate-300 bg-white text-slate-700 transition cursor-pointer';
|
||||
|
||||
containerInternal.classList.add('hidden');
|
||||
containerExternal.classList.remove('hidden');
|
||||
if (updateCheckboxWrapper) updateCheckboxWrapper.classList.add('hidden');
|
||||
if (updateCheckbox) updateCheckbox.checked = false;
|
||||
|
||||
// Kosongkan seleksi unit internal
|
||||
const vId = document.getElementById('transporter_vehicle_id');
|
||||
if (vId) vId.value = '';
|
||||
|
||||
// Sinkronkan data dari input teks external
|
||||
const extOrigin = document.getElementById('transporter_origin_location_input')?.value.trim() || '';
|
||||
const extName = document.getElementById('transporter_unit_name_input')?.value.trim() || '';
|
||||
document.getElementById('final_transporter_origin_location').value = extOrigin;
|
||||
document.getElementById('final_transporter_unit_name').value = extName;
|
||||
} else {
|
||||
// Style Card Internal Aktif
|
||||
cardInternal.className = 'flex items-center space-x-3 p-3 rounded-xl border-2 border-blue-600 bg-blue-50/50 text-blue-950 transition cursor-pointer shadow-xs';
|
||||
cardExternal.className = 'flex items-center space-x-3 p-3 rounded-xl border border-slate-200 hover:border-slate-300 bg-white text-slate-700 transition cursor-pointer';
|
||||
|
||||
containerInternal.classList.remove('hidden');
|
||||
containerExternal.classList.add('hidden');
|
||||
if (updateCheckboxWrapper) updateCheckboxWrapper.classList.remove('hidden');
|
||||
if (updateCheckbox) updateCheckbox.checked = true;
|
||||
|
||||
// Sinkronkan data dari input pencarian internal
|
||||
const searchInput = document.getElementById('internal_transporter_search');
|
||||
if (searchInput) onInternalTransporterInput(searchInput.value);
|
||||
}
|
||||
|
||||
updateRouteBanner();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler ketika Lokasi Asal Armada Pengangkut Internal Berubah
|
||||
*/
|
||||
function onTransporterOriginChanged(selectedLocation, preselectId = null) {
|
||||
const datalist = document.getElementById('internalTransporterSuggestionList');
|
||||
const badge = document.getElementById('transporterCounterBadge');
|
||||
const searchInput = document.getElementById('internal_transporter_search');
|
||||
if (!datalist) return;
|
||||
|
||||
datalist.innerHTML = '';
|
||||
|
||||
const filtered = (!selectedLocation || selectedLocation === 'ALL')
|
||||
? allTransporterUnits
|
||||
: allTransporterUnits.filter(u => u.location === selectedLocation);
|
||||
|
||||
if (badge) {
|
||||
badge.classList.remove('hidden');
|
||||
badge.textContent = `${filtered.length} Truk Tersedia`;
|
||||
}
|
||||
|
||||
if (searchInput) {
|
||||
if (selectedLocation && selectedLocation !== 'ALL') {
|
||||
searchInput.placeholder = `Ketik kode truk di ${selectedLocation} (${filtered.length} truk)...`;
|
||||
} else {
|
||||
searchInput.placeholder = `Ketik kode/tipe truk (${filtered.length} truk tersedia)...`;
|
||||
}
|
||||
}
|
||||
|
||||
filtered.forEach(u => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = u.text;
|
||||
opt.setAttribute('data-id', u.id);
|
||||
datalist.appendChild(opt);
|
||||
});
|
||||
|
||||
if (preselectId) {
|
||||
const matched = allTransporterUnits.find(u => String(u.id) === String(preselectId));
|
||||
if (matched && searchInput) {
|
||||
searchInput.value = matched.text;
|
||||
onInternalTransporterInput(matched.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler ketika input ketikan truk internal berubah (Autocomplete / Pencarian)
|
||||
*/
|
||||
function onInternalTransporterInput(val) {
|
||||
val = (val || '').trim();
|
||||
const finalOrigin = document.getElementById('final_transporter_origin_location');
|
||||
const finalName = document.getElementById('final_transporter_unit_name');
|
||||
const vehicleIdInput = document.getElementById('transporter_vehicle_id');
|
||||
|
||||
if (!val) {
|
||||
if (vehicleIdInput) vehicleIdInput.value = '';
|
||||
if (finalName) finalName.value = '';
|
||||
if (finalOrigin) finalOrigin.value = '';
|
||||
updateRouteBanner();
|
||||
return;
|
||||
}
|
||||
|
||||
// Cari unit yang cocok di allTransporterUnits berdasarkan kode atau nama lengkap
|
||||
const valUpper = val.toUpperCase();
|
||||
const matched = allTransporterUnits.find(u =>
|
||||
valUpper === u.code.toUpperCase() ||
|
||||
valUpper === u.text.toUpperCase() ||
|
||||
valUpper === u.name.toUpperCase() ||
|
||||
valUpper.startsWith(u.code.toUpperCase() + ' ') ||
|
||||
valUpper.startsWith(u.code.toUpperCase() + '-')
|
||||
);
|
||||
|
||||
if (matched) {
|
||||
if (vehicleIdInput) vehicleIdInput.value = matched.id;
|
||||
if (finalName) finalName.value = matched.name;
|
||||
if (finalOrigin) finalOrigin.value = matched.location;
|
||||
} else {
|
||||
// Teks ketikan bebas
|
||||
if (vehicleIdInput) vehicleIdInput.value = '';
|
||||
if (finalName) finalName.value = val;
|
||||
}
|
||||
|
||||
updateRouteBanner();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler input Asal Kendaraan Luar
|
||||
*/
|
||||
function onExternalOriginInput(val) {
|
||||
const finalOrigin = document.getElementById('final_transporter_origin_location');
|
||||
if (finalOrigin) finalOrigin.value = (val || '').trim();
|
||||
updateRouteBanner();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler input Nama / Identitas Kendaraan Luar
|
||||
*/
|
||||
function onExternalUnitNameInput(val) {
|
||||
const finalName = document.getElementById('final_transporter_unit_name');
|
||||
if (finalName) finalName.value = (val || '').trim();
|
||||
updateRouteBanner();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler untuk Area Tujuan (Di Dalam Site vs Di Luar Site)
|
||||
* Nomor BAST dan Dokumen hanya muncul saat transfer ke LUAR site.
|
||||
@@ -679,46 +975,49 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler saat Armada Pengangkut Terpilih
|
||||
*/
|
||||
function onTransporterSelected(selectElement) {
|
||||
const option = selectElement.options[selectElement.selectedIndex];
|
||||
const nameInput = document.getElementById('transporter_unit_name');
|
||||
if (option && option.value) {
|
||||
const dataName = option.getAttribute('data-name');
|
||||
if (dataName) {
|
||||
nameInput.value = dataName;
|
||||
}
|
||||
}
|
||||
updateRouteBanner();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Banner Logistik Rute Perjalanan
|
||||
* Update Banner Logistik Rute Perjalanan (Mendukung Internal & Eksternal)
|
||||
*/
|
||||
function updateRouteBanner() {
|
||||
const banner = document.getElementById('routeLogisticsBanner');
|
||||
const text = document.getElementById('routeLogisticsText');
|
||||
const transporterSelect = document.getElementById('transporter_vehicle_id');
|
||||
const originSelect = document.getElementById('origin_location');
|
||||
const destinationInput = document.getElementById('to_location');
|
||||
const transporterType = document.querySelector('input[name="transporter_type"]:checked')?.value || 'internal';
|
||||
|
||||
const optTransporter = transporterSelect.options[transporterSelect.selectedIndex];
|
||||
if (!optTransporter || !optTransporter.value) {
|
||||
if (!banner || !text) return;
|
||||
|
||||
const originLoc = originSelect && originSelect.value && originSelect.value !== 'ALL' ? originSelect.value : 'Lokasi Asal Alat Berat';
|
||||
const destLoc = destinationInput && destinationInput.value ? destinationInput.value : '[Lokasi Tujuan Baru]';
|
||||
|
||||
if (transporterType === 'internal') {
|
||||
const truckName = document.getElementById('final_transporter_unit_name')?.value || document.getElementById('internal_transporter_search')?.value.trim();
|
||||
const truckLoc = document.getElementById('final_transporter_origin_location')?.value || 'Site Kerinci';
|
||||
|
||||
if (!truckName) {
|
||||
banner.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
const transporterCode = optTransporter.getAttribute('data-code');
|
||||
const transporterLoc = optTransporter.getAttribute('data-location') || 'Pool Workshop';
|
||||
const originLoc = originSelect.value && originSelect.value !== 'ALL' ? originSelect.value : 'Lokasi Asal Alat Berat';
|
||||
const destLoc = destinationInput.value ? destinationInput.value : '[Lokasi Tujuan Baru]';
|
||||
banner.classList.remove('hidden');
|
||||
if (truckLoc === originLoc) {
|
||||
text.innerHTML = `Truk <strong>${truckName}</strong> saat ini standby di <strong>${truckLoc}</strong> (sama dengan lokasi alat berat) → Langsung mengangkut unit menuju tujuan <strong>${destLoc}</strong>.`;
|
||||
} else {
|
||||
text.innerHTML = `Truk <strong>${truckName}</strong> diberangkatkan dari <strong>${truckLoc}</strong> → Menjemput alat berat di <strong>${originLoc}</strong> → Mengantarkannya ke tujuan <strong>${destLoc}</strong>.`;
|
||||
}
|
||||
} else {
|
||||
const extOrigin = document.getElementById('transporter_origin_location_input')?.value.trim();
|
||||
const extName = document.getElementById('transporter_unit_name_input')?.value.trim();
|
||||
|
||||
if (!extName && !extOrigin) {
|
||||
banner.classList.add('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
const displayOrigin = extOrigin ? extOrigin : 'Luar Proyek';
|
||||
const displayName = extName ? extName : 'Armada Eksternal';
|
||||
|
||||
banner.classList.remove('hidden');
|
||||
if (transporterLoc === originLoc) {
|
||||
text.innerHTML = `Truk <strong>${transporterCode}</strong> saat ini standby di <strong>${transporterLoc}</strong> (sama dengan lokasi alat berat) → Langsung mengangkut unit menuju tujuan <strong>${destLoc}</strong>.`;
|
||||
} else {
|
||||
text.innerHTML = `Truk <strong>${transporterCode}</strong> diberangkatkan dari <strong>${transporterLoc}</strong> → Menjemput alat berat di <strong>${originLoc}</strong> → Mengantarkannya ke tujuan <strong>${destLoc}</strong>.`;
|
||||
text.innerHTML = `Armada luar (<strong>${displayName}</strong>) diberangkatkan dari <strong>${displayOrigin}</strong> → Menjemput alat berat di <strong>${originLoc}</strong> → Mengantarkannya ke tujuan <strong>${destLoc}</strong>.`;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
@section('title', 'Transfer Unit Alat Berat - Admin QMA | PT Kerinci Merangin Hidro')
|
||||
|
||||
@section('content')
|
||||
<div class="w-full space-y-6">
|
||||
<div class="w-full space-y-4 sm:space-y-5">
|
||||
|
||||
<!-- Header Judul & Tombol Aksi (Persis Format Standar HSE Employees) -->
|
||||
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4">
|
||||
<!-- Header Judul & Tombol Aksi -->
|
||||
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-3">
|
||||
<div>
|
||||
<div class="flex items-center space-x-1.5 mb-1">
|
||||
<div class="flex items-center space-x-1.5 mb-0.5">
|
||||
<span class="text-xs font-bold uppercase tracking-wider text-[#1b5e20]">
|
||||
MANAJEMEN SISTEM
|
||||
</span>
|
||||
@@ -19,22 +19,22 @@
|
||||
<i class="fa-solid fa-info"></i>
|
||||
</button>
|
||||
</div>
|
||||
<h2 class="text-3xl sm:text-4xl font-extrabold text-slate-900 tracking-tight">
|
||||
<h2 class="text-2xl sm:text-3xl font-extrabold text-slate-900 tracking-tight">
|
||||
Transfer Unit Alat Berat
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<!-- Tombol Aksi Kanan -->
|
||||
<div class="flex items-center gap-2.5 sm:gap-3 w-full sm:w-auto">
|
||||
<div class="flex items-center gap-2 sm:gap-2.5 w-full sm:w-auto">
|
||||
<!-- Dropdown Menu Ekspor Format it.allrole.web.id -->
|
||||
<div class="relative inline-block w-full sm:w-auto flex-1 sm:flex-none" id="exportDropdownContainer">
|
||||
<button type="button"
|
||||
onclick="toggleExportMenu(event)"
|
||||
id="btnExportTrigger"
|
||||
class="w-full sm:w-auto border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold flex items-center justify-center space-x-2 transition shadow-sm cursor-pointer">
|
||||
class="w-full sm:w-auto border border-emerald-600/30 text-emerald-900 bg-white hover:bg-emerald-50/50 px-3 sm:px-3.5 py-2 rounded-xl text-xs font-bold flex items-center justify-center space-x-1.5 transition shadow-2xs cursor-pointer">
|
||||
<i class="fa-regular fa-file-excel text-emerald-700 text-sm"></i>
|
||||
<span class="truncate">Ekspor Data</span>
|
||||
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-0.5 sm:ml-1"></i>
|
||||
<i class="fa-solid fa-chevron-down text-[9px] text-slate-400 ml-0.5"></i>
|
||||
</button>
|
||||
<div id="exportMenu" style="display: none;" class="absolute right-0 mt-2 w-52 bg-white rounded-xl shadow-[0_8px_30px_rgb(0,0,0,0.12)] border border-slate-100 z-50 overflow-hidden">
|
||||
<a href="{{ route('qma.unit_transfers.export_pdf', request()->query()) }}" target="_blank" class="flex items-center px-4 py-3 text-xs text-slate-700 hover:bg-slate-50 hover:text-[#1b5e20] font-bold transition">
|
||||
@@ -51,21 +51,9 @@
|
||||
|
||||
@canany(['qma.vehicles.create', 'qma.vehicles.edit'])
|
||||
<a href="{{ route('qma.unit_transfers.create') }}"
|
||||
class="flex items-center justify-center space-x-2 bg-[#1b5e20] hover:bg-[#144919] text-white px-3 sm:px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm cursor-pointer whitespace-nowrap">
|
||||
<i class="fa-solid fa-truck-moving text-sm"></i>
|
||||
<span class="hidden sm:inline">Transfer Unit Baru</span>
|
||||
<span class="sm:hidden">Transfer Baru</span>
|
||||
</a>
|
||||
@endcanany
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tombol Buat Transfer Unit Baru -->
|
||||
@canany(['qma.vehicles.create', 'qma.vehicles.edit'])
|
||||
<a href="{{ route('qma.unit_transfers.create') }}"
|
||||
class="inline-flex items-center justify-center space-x-2 bg-[#1b5e20] hover:bg-[#144919] text-white px-4 py-2.5 rounded-xl text-xs font-bold transition shadow-sm cursor-pointer whitespace-nowrap">
|
||||
<i class="fa-solid fa-plus text-xs"></i>
|
||||
<span>Buat Transfer Unit</span>
|
||||
class="flex-1 sm:flex-none flex items-center justify-center space-x-1.5 bg-[#1b5e20] hover:bg-[#144919] text-white px-3.5 py-2 rounded-xl text-xs font-bold transition shadow-2xs cursor-pointer whitespace-nowrap">
|
||||
<i class="fa-solid fa-truck-moving text-xs"></i>
|
||||
<span>Transfer Unit Baru</span>
|
||||
</a>
|
||||
@endcanany
|
||||
</div>
|
||||
@@ -73,8 +61,8 @@
|
||||
|
||||
<!-- Alert Notifikasi Flash -->
|
||||
@if(session('success'))
|
||||
<div class="flex items-center space-x-3 p-4 bg-emerald-50/90 border border-emerald-200 rounded-2xl text-emerald-800 text-xs sm:text-sm font-semibold shadow-2xs">
|
||||
<div class="w-7 h-7 rounded-full bg-emerald-100 text-emerald-700 flex items-center justify-center shrink-0">
|
||||
<div class="flex items-center space-x-3 p-3.5 bg-emerald-50/90 border border-emerald-200 rounded-xl text-emerald-800 text-xs font-semibold shadow-2xs">
|
||||
<div class="w-6 h-6 rounded-full bg-emerald-100 text-emerald-700 flex items-center justify-center shrink-0 text-xs">
|
||||
<i class="fa-solid fa-check"></i>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
@@ -84,8 +72,8 @@
|
||||
@endif
|
||||
|
||||
@if(session('error'))
|
||||
<div class="flex items-center space-x-3 p-4 bg-rose-50/90 border border-rose-200 rounded-2xl text-rose-800 text-xs sm:text-sm font-semibold shadow-2xs">
|
||||
<div class="w-7 h-7 rounded-full bg-rose-100 text-rose-700 flex items-center justify-center shrink-0">
|
||||
<div class="flex items-center space-x-3 p-3.5 bg-rose-50/90 border border-rose-200 rounded-xl text-rose-800 text-xs font-semibold shadow-2xs">
|
||||
<div class="w-6 h-6 rounded-full bg-rose-100 text-rose-700 flex items-center justify-center shrink-0 text-xs">
|
||||
<i class="fa-solid fa-triangle-exclamation"></i>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
@@ -94,53 +82,76 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<!-- KPI Ringkasan Pemindahan Unit -->
|
||||
<div class="grid grid-cols-2 lg:grid-cols-4 gap-3.5">
|
||||
<!-- KPI Ringkasan Pemindahan Unit (Ramping & Sleek) -->
|
||||
<div class="grid grid-cols-2 lg:grid-cols-4 gap-2.5 sm:gap-3">
|
||||
<!-- 1. Total Transfer -->
|
||||
<div class="bg-white p-4 rounded-2xl border border-slate-200/80 shadow-xs">
|
||||
<p class="text-[11px] font-bold uppercase tracking-wider text-slate-400">Total Pemindahan</p>
|
||||
<h3 class="text-2xl font-black text-slate-800 mt-1">{{ number_format($totalTransfers, 0, ',', '.') }}</h3>
|
||||
<span class="text-[10px] text-slate-400 font-medium block mt-1">Semua Dokumen BAST</span>
|
||||
<div class="bg-white p-3 sm:p-3.5 rounded-xl border border-slate-200/80 shadow-2xs flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-[10px] font-bold uppercase tracking-wider text-slate-400">Total BAST</p>
|
||||
<h3 class="text-lg sm:text-xl font-black text-slate-800 mt-0.5">{{ number_format($totalTransfers, 0, ',', '.') }}</h3>
|
||||
<span class="text-[10px] text-slate-400 font-medium">Semua Dokumen</span>
|
||||
</div>
|
||||
<div class="w-8 h-8 rounded-lg bg-slate-100 text-slate-600 flex items-center justify-center text-xs shrink-0">
|
||||
<i class="fa-solid fa-file-contract"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 2. Pemindahan Bulan Ini -->
|
||||
<div class="bg-white p-4 rounded-2xl border border-blue-200/80 shadow-xs bg-gradient-to-br from-white to-blue-50/30">
|
||||
<p class="text-[11px] font-bold uppercase tracking-wider text-blue-700">Bulan Ini</p>
|
||||
<h3 class="text-2xl font-black text-blue-800 mt-1">{{ number_format($thisMonthCount, 0, ',', '.') }}</h3>
|
||||
<span class="text-[10px] text-blue-600 font-semibold block mt-1">{{ \Carbon\Carbon::now()->translatedFormat('F Y') }}</span>
|
||||
<div class="bg-white p-3 sm:p-3.5 rounded-xl border border-blue-200/80 shadow-2xs flex items-center justify-between bg-gradient-to-br from-white to-blue-50/20">
|
||||
<div>
|
||||
<p class="text-[10px] font-bold uppercase tracking-wider text-blue-700">Bulan Ini</p>
|
||||
<h3 class="text-lg sm:text-xl font-black text-blue-800 mt-0.5">{{ number_format($thisMonthCount, 0, ',', '.') }}</h3>
|
||||
<span class="text-[10px] text-blue-600 font-semibold">{{ \Carbon\Carbon::now()->translatedFormat('M Y') }}</span>
|
||||
</div>
|
||||
<div class="w-8 h-8 rounded-lg bg-blue-50 text-blue-600 flex items-center justify-center text-xs shrink-0">
|
||||
<i class="fa-solid fa-calendar-check"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3. Di Dalam Site -->
|
||||
<div class="bg-white p-4 rounded-2xl border border-emerald-200/80 shadow-xs bg-gradient-to-br from-white to-emerald-50/30">
|
||||
<p class="text-[11px] font-bold uppercase tracking-wider text-emerald-700">Tujuan In-Site</p>
|
||||
<h3 class="text-2xl font-black text-emerald-800 mt-1">{{ number_format($insideCount, 0, ',', '.') }}</h3>
|
||||
<span class="text-[10px] text-emerald-600 font-semibold block mt-1">Area Proyek KMH</span>
|
||||
<div class="bg-white p-3 sm:p-3.5 rounded-xl border border-emerald-200/80 shadow-2xs flex items-center justify-between bg-gradient-to-br from-white to-emerald-50/20">
|
||||
<div>
|
||||
<p class="text-[10px] font-bold uppercase tracking-wider text-emerald-700">Tujuan In-Site</p>
|
||||
<h3 class="text-lg sm:text-xl font-black text-emerald-800 mt-0.5">{{ number_format($insideCount, 0, ',', '.') }}</h3>
|
||||
<span class="text-[10px] text-emerald-600 font-semibold">Area Proyek</span>
|
||||
</div>
|
||||
<div class="w-8 h-8 rounded-lg bg-emerald-50 text-emerald-600 flex items-center justify-center text-xs shrink-0">
|
||||
<i class="fa-solid fa-location-dot"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 4. Di Luar Site -->
|
||||
<div class="bg-white p-4 rounded-2xl border border-amber-200/80 shadow-xs bg-gradient-to-br from-white to-amber-50/30">
|
||||
<p class="text-[11px] font-bold uppercase tracking-wider text-amber-700">Tujuan Out-Site</p>
|
||||
<h3 class="text-2xl font-black text-amber-800 mt-1">{{ number_format($outsideCount, 0, ',', '.') }}</h3>
|
||||
<span class="text-[10px] text-amber-600 font-semibold block mt-1">Workshop/Luar Proyek</span>
|
||||
<div class="bg-white p-3 sm:p-3.5 rounded-xl border border-amber-200/80 shadow-2xs flex items-center justify-between bg-gradient-to-br from-white to-amber-50/20">
|
||||
<div>
|
||||
<p class="text-[10px] font-bold uppercase tracking-wider text-amber-700">Tujuan Out-Site</p>
|
||||
<h3 class="text-lg sm:text-xl font-black text-amber-800 mt-0.5">{{ number_format($outsideCount, 0, ',', '.') }}</h3>
|
||||
<span class="text-[10px] text-amber-600 font-semibold">Workshop/Luar</span>
|
||||
</div>
|
||||
<div class="w-8 h-8 rounded-lg bg-amber-50 text-amber-600 flex items-center justify-center text-xs shrink-0">
|
||||
<i class="fa-solid fa-arrow-up-right-from-square"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filter Card -->
|
||||
<div class="bg-white p-4 rounded-2xl border border-slate-200/80 shadow-xs">
|
||||
<form method="GET" action="{{ route('qma.unit_transfers.index') }}" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-5 gap-3 items-center">
|
||||
<!-- Search Text -->
|
||||
<div class="relative md:col-span-2">
|
||||
<i class="fa-solid fa-magnifying-glass absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"></i>
|
||||
<!-- Kotak Pencarian & Filter Ramping (Inline Format Referensi HSE) -->
|
||||
<form method="GET" action="{{ route('qma.unit_transfers.index') }}" id="transferFilterForm" class="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-2.5 sm:gap-3">
|
||||
<!-- Search Text (Kiri) -->
|
||||
<div class="relative w-full sm:max-w-md">
|
||||
<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>
|
||||
</span>
|
||||
<input type="text"
|
||||
name="search"
|
||||
id="transferSearchInput"
|
||||
value="{{ request('search') }}"
|
||||
placeholder="Cari No BAST, Unit, Lokasi, Driver, Pelapor..."
|
||||
class="w-full pl-9 pr-3 py-2 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition">
|
||||
placeholder="Cari No BAST, unit, lokasi, pengangkut, pelapor..."
|
||||
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-[#1b5e20] focus:ring-2 focus:ring-[#1b5e20]/10 shadow-sm transition">
|
||||
</div>
|
||||
|
||||
<!-- Filter Dropdown (Kanan) -->
|
||||
<div class="flex flex-wrap items-center gap-2 sm:gap-2.5 w-full sm:w-auto">
|
||||
<!-- Filter Alat Berat -->
|
||||
<div>
|
||||
<select name="vehicle_id" class="w-full px-3 py-2 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition bg-white text-slate-700">
|
||||
<select name="vehicle_id" 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] shadow-sm transition max-w-[200px] truncate">
|
||||
<option value="all">Semua Alat Berat</option>
|
||||
@foreach($heavyUnits as $hu)
|
||||
<option value="{{ $hu->id }}" {{ request('vehicle_id') == $hu->id ? 'selected' : '' }}>
|
||||
@@ -148,32 +159,23 @@
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Filter Status Area Tujuan -->
|
||||
<div>
|
||||
<select name="to_site_status" class="w-full px-3 py-2 text-xs rounded-xl border border-slate-200 focus:outline-none focus:ring-2 focus:ring-[#1b5e20]/20 focus:border-[#1b5e20] transition bg-white text-slate-700">
|
||||
<select name="to_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] shadow-sm transition">
|
||||
<option value="all" {{ request('to_site_status') === 'all' ? 'selected' : '' }}>Semua Area Tujuan</option>
|
||||
<option value="inside_site" {{ request('to_site_status') === 'inside_site' ? 'selected' : '' }}>Di Dalam Site</option>
|
||||
<option value="outside_site" {{ request('to_site_status') === 'outside_site' ? 'selected' : '' }}>Di Luar Site</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Tombol Filter & Reset -->
|
||||
<div class="flex items-center space-x-2">
|
||||
<button type="submit" class="flex-1 px-4 py-2 bg-slate-900 hover:bg-slate-800 text-white text-xs font-bold rounded-xl transition shadow-sm cursor-pointer text-center">
|
||||
Filter
|
||||
</button>
|
||||
@if(request()->anyFilled(['search', 'vehicle_id', 'to_site_status', 'start_date', 'end_date']))
|
||||
<a href="{{ route('qma.unit_transfers.index') }}" class="px-3 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition whitespace-nowrap" title="Reset Filter">
|
||||
<i class="fa-solid fa-rotate-left"></i>
|
||||
<a href="{{ route('qma.unit_transfers.index') }}" class="px-2.5 py-2 rounded-xl text-xs font-semibold text-rose-600 bg-rose-50 border border-rose-200 hover:bg-rose-100 transition whitespace-nowrap" title="Reset Filter">
|
||||
<i class="fa-solid fa-rotate-left mr-1"></i>Reset
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Tabel Riwayat Transfer Unit dengan Header Biru Tua Navy (Format Ramping & Nyaman) -->
|
||||
<!-- Tabel Riwayat Transfer Unit -->
|
||||
<div class="bg-white rounded-none sm:rounded-2xl border border-slate-200 shadow-sm overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full text-xs text-left border-collapse">
|
||||
@@ -267,12 +269,18 @@
|
||||
|
||||
<!-- 5. Armada & Supir Pengangkut -->
|
||||
<td class="py-2.5 px-3.5 whitespace-nowrap">
|
||||
<div class="font-semibold text-slate-800 text-xs flex items-center gap-1">
|
||||
<div class="font-semibold text-slate-800 text-xs flex items-center gap-1.5">
|
||||
<i class="fa-solid fa-truck-moving text-slate-400 text-[10px]"></i>
|
||||
<span>{{ $t->transporter_unit_name ?: ($t->transporterVehicle?->code ?? 'Tanpa Pengangkut') }}</span>
|
||||
@if($t->transporter_type === 'external' || (!$t->transporter_vehicle_id && $t->transporter_unit_name))
|
||||
<span class="text-[9px] px-1.5 py-0.2 rounded font-bold bg-amber-50 text-amber-700 border border-amber-200">Luar</span>
|
||||
@endif
|
||||
</div>
|
||||
<div class="text-[11px] text-slate-500 mt-0.5">
|
||||
{{ $t->transporter_driver_name ?: ($t->transporterDriver?->name ?? '-') }}
|
||||
<div class="text-[11px] text-slate-500 mt-0.5 flex items-center gap-1.5">
|
||||
<span>{{ $t->transporter_driver_name ?: ($t->transporterDriver?->name ?? '-') }}</span>
|
||||
@if($t->transporter_origin_location)
|
||||
<span class="text-[10px] text-slate-400">| Asal: {{ $t->transporter_origin_location }}</span>
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -310,18 +318,18 @@
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="7" class="py-12 text-center text-slate-400">
|
||||
<div class="w-14 h-14 rounded-full bg-slate-100 flex items-center justify-center mx-auto mb-2 text-slate-400 text-xl">
|
||||
<td colspan="7" class="py-8 sm:py-10 text-center text-slate-400">
|
||||
<div class="w-11 h-11 rounded-full bg-slate-100 flex items-center justify-center mx-auto mb-2 text-slate-400 text-lg">
|
||||
<i class="fa-solid fa-truck-ramp-box"></i>
|
||||
</div>
|
||||
<p class="text-xs font-bold text-slate-700">Belum Ada Data Pemindahan Unit</p>
|
||||
<p class="text-[11px] text-slate-400 mt-0.5 max-w-sm mx-auto">
|
||||
Belum ada transaksi pemindahan alat berat yang tercatat. Silakan klik tombol "Buat Transfer Unit" untuk membuat Berita Acara baru.
|
||||
Belum ada transaksi pemindahan alat berat yang tercatat. Silakan klik tombol di bawah untuk membuat Berita Acara baru.
|
||||
</p>
|
||||
@canany(['qma.vehicles.create', 'qma.vehicles.edit'])
|
||||
<div class="mt-4">
|
||||
<a href="{{ route('qma.unit_transfers.create') }}" class="inline-flex items-center space-x-1.5 px-4 py-2 bg-[#1b5e20] hover:bg-[#144919] text-white rounded-xl text-xs font-bold transition shadow-sm">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
<div class="mt-3">
|
||||
<a href="{{ route('qma.unit_transfers.create') }}" class="inline-flex items-center space-x-1.5 px-3.5 py-1.5 bg-[#1b5e20] hover:bg-[#144919] text-white rounded-xl text-xs font-bold transition shadow-2xs">
|
||||
<i class="fa-solid fa-plus text-xs"></i>
|
||||
<span>Buat Transfer Unit Baru</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -190,8 +190,21 @@
|
||||
<td class="py-2.5 px-4 font-bold text-slate-600 w-1/3">Kendaraan Pengangkut</td>
|
||||
<td class="py-2.5 px-4 font-bold text-slate-900">
|
||||
{{ $transfer->transporter_unit_name ?: ($transfer->transporterVehicle?->code ?? 'Tanpa Truk Pengangkut (Mobilisasi Mandiri)') }}
|
||||
@if($transfer->transporter_type === 'external' || (!$transfer->transporter_vehicle_id && $transfer->transporter_unit_name))
|
||||
<span class="ml-2 px-2 py-0.5 rounded-full text-[10px] font-bold bg-amber-100 text-amber-800 border border-amber-200">Armada Luar / Rekanan</span>
|
||||
@elseif($transfer->transporter_vehicle_id)
|
||||
<span class="ml-2 px-2 py-0.5 rounded-full text-[10px] font-bold bg-blue-100 text-blue-800 border border-blue-200">Armada Internal KMH</span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@if($transfer->transporter_origin_location)
|
||||
<tr>
|
||||
<td class="py-2.5 px-4 font-bold text-slate-600">Asal Kendaraan Pengangkut</td>
|
||||
<td class="py-2.5 px-4 font-semibold text-slate-800">
|
||||
<i class="fa-solid fa-map-pin text-emerald-600 mr-1.5"></i>{{ $transfer->transporter_origin_location }}
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
<tr>
|
||||
<td class="py-2.5 px-4 font-bold text-slate-600">Nama Pengemudi / Driver</td>
|
||||
<td class="py-2.5 px-4 font-semibold text-slate-800">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Vehicle;
|
||||
use Database\Seeders\RolePermissionSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class QmaHeavyEquipmentThreeLevelNavigationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private User $qmaAdmin;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->seed(RolePermissionSeeder::class);
|
||||
|
||||
$this->qmaAdmin = User::factory()->create([
|
||||
'name' => 'Admin QMA Test',
|
||||
'username' => 'qma_test_3level',
|
||||
'role' => 'qma_admin',
|
||||
]);
|
||||
$this->qmaAdmin->assignRole('qma_admin');
|
||||
|
||||
// 1. Hauling Units (Dump Truck & Mixer Truck)
|
||||
Vehicle::create([
|
||||
'code' => 'DT-01',
|
||||
'category' => 'unit_support',
|
||||
'operational_group' => 'HAULING',
|
||||
'unit_category' => 'Dump Truck',
|
||||
'unit_type' => 'DUMP TRUCK',
|
||||
'brand' => 'HOWO',
|
||||
'brand_type' => 'HOWO SINOTRUK 336',
|
||||
'model_number' => 'ZZ3257N3847',
|
||||
'serial_number' => 'HW123456',
|
||||
'location' => 'Main Dam',
|
||||
'site_status' => 'inside_site',
|
||||
'status' => 'Operation',
|
||||
]);
|
||||
|
||||
Vehicle::create([
|
||||
'code' => 'DT-02',
|
||||
'category' => 'unit_support',
|
||||
'operational_group' => 'HAULING',
|
||||
'unit_category' => 'Dump Truck',
|
||||
'unit_type' => 'DUMP TRUCK',
|
||||
'brand' => 'HOWO',
|
||||
'brand_type' => 'HOWO SINOTRUK 336',
|
||||
'location' => 'Adit 3',
|
||||
'site_status' => 'inside_site',
|
||||
'status' => 'Standby',
|
||||
]);
|
||||
|
||||
Vehicle::create([
|
||||
'code' => 'MT-01',
|
||||
'category' => 'unit_support',
|
||||
'operational_group' => 'HAULING',
|
||||
'unit_category' => 'Truk Mixer',
|
||||
'unit_type' => 'MIXER TRUCK',
|
||||
'brand' => 'YUCHAI',
|
||||
'brand_type' => 'YUCHAI DIECI',
|
||||
'location' => 'Batching Plant',
|
||||
'site_status' => 'inside_site',
|
||||
'status' => 'Operation',
|
||||
]);
|
||||
|
||||
// 2. Loader Units (Excavator)
|
||||
Vehicle::create([
|
||||
'code' => 'EX-01',
|
||||
'category' => 'unit_support',
|
||||
'operational_group' => 'LOADER',
|
||||
'unit_category' => 'Excavator',
|
||||
'unit_type' => 'EXCAVATOR',
|
||||
'brand' => 'KOMATSU',
|
||||
'brand_type' => 'KOMATSU PC200-8',
|
||||
'location' => 'Power House',
|
||||
'site_status' => 'inside_site',
|
||||
'status' => 'Operation',
|
||||
]);
|
||||
|
||||
// 3. Support Units (Compressor)
|
||||
Vehicle::create([
|
||||
'code' => 'CP-01',
|
||||
'category' => 'unit_support',
|
||||
'operational_group' => 'SUPPORT',
|
||||
'unit_category' => 'Engine Compressor',
|
||||
'unit_type' => 'COMPRESSOR',
|
||||
'brand' => 'AIRMAN',
|
||||
'brand_type' => 'AIRMAN PDS655S',
|
||||
'location' => 'Adit 2',
|
||||
'site_status' => 'inside_site',
|
||||
'status' => 'Breakdown',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Level 1: Halaman utama menampilkan daftar Kelompok Operasional (HAULING, LOADER, SUPPORT, dll).
|
||||
*/
|
||||
public function test_level_1_shows_operational_groups(): void
|
||||
{
|
||||
$response = $this->actingAs($this->qmaAdmin)->get('/qma/vehicles/unit-support');
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertViewIs('qma.vehicles_support');
|
||||
$response->assertViewHas('level', 'groups');
|
||||
$response->assertViewHas('groups');
|
||||
|
||||
// Memastikan nama-nama kelompok operasional tampil di tabel Level 1
|
||||
$response->assertSee('HAULING');
|
||||
$response->assertSee('LOADER');
|
||||
$response->assertSee('SUPPORT');
|
||||
$response->assertSee('Lihat Kategori');
|
||||
}
|
||||
|
||||
/**
|
||||
* Level 2: Memilih salah satu Kelompok Operasional menampilkan daftar tipe alat di dalamnya.
|
||||
*/
|
||||
public function test_level_2_shows_types_in_selected_group(): void
|
||||
{
|
||||
$response = $this->actingAs($this->qmaAdmin)->get('/qma/vehicles/unit-support?group=HAULING');
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertViewIs('qma.vehicles_support');
|
||||
$response->assertViewHas('level', 'types');
|
||||
$response->assertViewHas('selectedGroup', 'HAULING');
|
||||
|
||||
// Tipe dalam kelompok HAULING
|
||||
$response->assertSee('DUMP TRUCK');
|
||||
$response->assertSee('MIXER TRUCK');
|
||||
|
||||
$typesInView = collect($response->viewData('types')->items())->pluck('unit_type')->all();
|
||||
$this->assertContains('DUMP TRUCK', $typesInView);
|
||||
$this->assertContains('MIXER TRUCK', $typesInView);
|
||||
$this->assertNotContains('EXCAVATOR', $typesInView);
|
||||
$this->assertNotContains('COMPRESSOR', $typesInView);
|
||||
|
||||
// Breadcrumb & tombol kembali
|
||||
$response->assertSee('Semua Kelompok');
|
||||
$response->assertSee('Buka Unit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Level 3: Memilih tipe alat menampilkan daftar unit fisik individual.
|
||||
*/
|
||||
public function test_level_3_shows_physical_units(): void
|
||||
{
|
||||
$response = $this->actingAs($this->qmaAdmin)->get('/qma/vehicles/unit-support?group=HAULING&type=DUMP+TRUCK');
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertViewIs('qma.vehicles_support');
|
||||
$response->assertViewHas('level', 'units');
|
||||
$response->assertViewHas('selectedGroup', 'HAULING');
|
||||
$response->assertViewHas('selectedType', 'DUMP TRUCK');
|
||||
|
||||
// Unit fisik Dump Truck
|
||||
$response->assertSee('DT-01');
|
||||
$response->assertSee('DT-02');
|
||||
$response->assertSee('HOWO SINOTRUK 336');
|
||||
$response->assertSee('Main Dam');
|
||||
|
||||
$codesInView = collect($response->viewData('typeUnits')->items())->pluck('code')->all();
|
||||
$this->assertContains('DT-01', $codesInView);
|
||||
$this->assertContains('DT-02', $codesInView);
|
||||
$this->assertNotContains('MT-01', $codesInView);
|
||||
$this->assertNotContains('EX-01', $codesInView);
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-detect group jika user hanya memasukkan query parameter `type`.
|
||||
*/
|
||||
public function test_level_3_auto_detects_group_when_only_type_passed(): void
|
||||
{
|
||||
$response = $this->actingAs($this->qmaAdmin)->get('/qma/vehicles/unit-support?type=EXCAVATOR');
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertViewHas('level', 'units');
|
||||
$response->assertViewHas('selectedGroup', 'LOADER');
|
||||
$response->assertViewHas('selectedType', 'EXCAVATOR');
|
||||
$response->assertSee('EX-01');
|
||||
$response->assertSee('Power House');
|
||||
}
|
||||
}
|
||||
@@ -379,4 +379,37 @@ class QmaUnitTransferTest extends TestCase
|
||||
$this->assertEquals('Adit 2 Intake', $transporterHistory->location);
|
||||
$this->assertStringContainsString('Mengantar EXCA-01', $transporterHistory->note);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test transfer unit dengan armada pengangkut eksternal (rental/luar)
|
||||
* dengan asal kendaraan manual dan nama unit manual.
|
||||
*/
|
||||
public function test_store_transfer_with_external_transporter(): void
|
||||
{
|
||||
Storage::fake('public');
|
||||
|
||||
$payload = [
|
||||
'vehicle_id' => $this->heavyEquipment->id,
|
||||
'from_location' => 'Main Dam',
|
||||
'transfer_date' => Carbon::now()->format('Y-m-d'),
|
||||
'to_location' => 'Adit 2 Intake',
|
||||
'to_site_status' => 'inside_site',
|
||||
'reported_by' => 'Staff QMA Logistik',
|
||||
'transporter_type' => 'external',
|
||||
'transporter_origin_location' => 'Pool Jambi',
|
||||
'transporter_unit_name' => 'Truk Tronton BA 1234 XY (Vendor Subkon)',
|
||||
'transporter_driver_name' => 'Budi Supir Rental',
|
||||
'transporter_description' => 'Lashing rantai 4 titik aman',
|
||||
];
|
||||
|
||||
$response = $this->actingAs($this->qmaAdmin)->post(route('qma.unit_transfers.store'), $payload);
|
||||
$response->assertSessionHas('success');
|
||||
|
||||
$transfer = UnitTransfer::latest('id')->first();
|
||||
$this->assertEquals('external', $transfer->transporter_type);
|
||||
$this->assertNull($transfer->transporter_vehicle_id);
|
||||
$this->assertEquals('Pool Jambi', $transfer->transporter_origin_location);
|
||||
$this->assertEquals('Truk Tronton BA 1234 XY (Vendor Subkon)', $transfer->transporter_unit_name);
|
||||
$this->assertEquals('Budi Supir Rental', $transfer->transporter_driver_name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user