fix(hse): allow soft deleting employee without losing operational history, fix simper checklist badge overflow, and enforce valid future expiry date

This commit is contained in:
Ray1111-aa
2026-11-02 14:35:24 +07:00
parent 23377631b3
commit 008e5f6b9d
12 changed files with 302 additions and 58 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ class EmployeeSimper extends Model
public function employee(): BelongsTo
{
return $this->belongsTo(Employee::class);
return $this->belongsTo(Employee::class)->withTrashed();
}
public function simperType(): BelongsTo
+1 -1
View File
@@ -49,7 +49,7 @@ class P2hRecord extends Model
public function employee(): BelongsTo
{
return $this->belongsTo(Employee::class);
return $this->belongsTo(Employee::class)->withTrashed();
}
public function template(): BelongsTo
+29
View File
@@ -98,6 +98,7 @@ class SimperType extends Model
protected $appends = [
'scopes',
'category_scope_display',
'short_scope_display',
];
/**
@@ -184,6 +185,34 @@ class SimperType extends Model
return implode(', ', $formatted);
}
/**
* Teks ringkas pendek untuk badge di UI (maksimal 2 kategori + counter jika panjang).
*/
public function getShortScopeDisplayAttribute(): string
{
$scopes = $this->scopes;
if (empty($scopes) || in_array(self::SCOPE_ALL, $scopes, true)) {
return 'UNIVERSAL';
}
if (count($scopes) === 1 && $scopes[0] === self::SCOPE_LIGHT_VEHICLE) {
return 'LV';
}
$formatted = array_map(function ($s) {
if ($s === self::SCOPE_LIGHT_VEHICLE) return 'LV';
if ($s === self::SCOPE_ALL) return 'Universal';
return strtoupper(str_replace('_', ' ', $s));
}, $scopes);
if (count($formatted) > 2) {
return $formatted[0] . ', ' . $formatted[1] . ' (+' . (count($formatted) - 2) . ')';
}
return implode(', ', $formatted);
}
public function employeeSimpers(): HasMany
{
return $this->hasMany(EmployeeSimper::class);
+1 -1
View File
@@ -57,7 +57,7 @@ class UnitSupportTimesheet extends Model
public function operator(): BelongsTo
{
return $this->belongsTo(Employee::class, 'operator_id');
return $this->belongsTo(Employee::class, 'operator_id')->withTrashed();
}
public function createdByUser(): BelongsTo
+1 -1
View File
@@ -68,7 +68,7 @@ class UnitTransfer extends Model
*/
public function transporterDriver(): BelongsTo
{
return $this->belongsTo(Employee::class, 'transporter_driver_id');
return $this->belongsTo(Employee::class, 'transporter_driver_id')->withTrashed();
}
/**
+1 -1
View File
@@ -56,7 +56,7 @@ class VehicleActivity extends Model
public function driver(): BelongsTo
{
return $this->belongsTo(Employee::class, 'driver_id');
return $this->belongsTo(Employee::class, 'driver_id')->withTrashed();
}
public function gate(): BelongsTo