Commit 72872427 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Add monthly salary field to trainer wizard when compensation model is 'salary'

Salaried trainers now get asked for their monthly amount, which is stored
on the employee record (salary_amount + salary_frequency='monthly').
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 4649176b
...@@ -63,6 +63,7 @@ class CreateTrainerWizard extends Component ...@@ -63,6 +63,7 @@ class CreateTrainerWizard extends Component
// Step 5: Compensation // Step 5: Compensation
public string $compensationModel = ''; public string $compensationModel = '';
public string $monthlySalary = '';
public string $hourlyRate = ''; public string $hourlyRate = '';
public string $sessionRate = ''; public string $sessionRate = '';
public string $groupRate = ''; public string $groupRate = '';
...@@ -267,7 +268,7 @@ public function rulesForStep(int $step): array ...@@ -267,7 +268,7 @@ public function rulesForStep(int $step): array
'revenue_share' => ['revenueSharePercent' => 'required|numeric|min:0.01|max:100'], 'revenue_share' => ['revenueSharePercent' => 'required|numeric|min:0.01|max:100'],
'hybrid' => ['sessionRate' => 'required|numeric|min:1'], 'hybrid' => ['sessionRate' => 'required|numeric|min:1'],
'contract' => ['sessionRate' => 'required|numeric|min:1'], 'contract' => ['sessionRate' => 'required|numeric|min:1'],
'salary' => [], 'salary' => ['monthlySalary' => 'required|numeric|min:1'],
default => [], default => [],
} }
), ),
...@@ -317,6 +318,9 @@ public function messagesForStep(int $step): array ...@@ -317,6 +318,9 @@ public function messagesForStep(int $step): array
5 => [ 5 => [
'compensationModel.required' => 'نموذج التعويض مطلوب', 'compensationModel.required' => 'نموذج التعويض مطلوب',
'compensationModel.in' => 'نموذج التعويض غير صالح', 'compensationModel.in' => 'نموذج التعويض غير صالح',
'monthlySalary.required' => 'الراتب الشهري مطلوب',
'monthlySalary.numeric' => 'الراتب الشهري يجب أن يكون رقماً',
'monthlySalary.min' => 'الراتب الشهري يجب أن يكون أكبر من صفر',
'hourlyRate.required' => 'معدل الساعة مطلوب لهذا النموذج', 'hourlyRate.required' => 'معدل الساعة مطلوب لهذا النموذج',
'hourlyRate.numeric' => 'معدل الساعة يجب أن يكون رقماً', 'hourlyRate.numeric' => 'معدل الساعة يجب أن يكون رقماً',
'hourlyRate.min' => 'معدل الساعة يجب أن يكون أكبر من صفر', 'hourlyRate.min' => 'معدل الساعة يجب أن يكون أكبر من صفر',
...@@ -422,6 +426,8 @@ public function confirm(): void ...@@ -422,6 +426,8 @@ public function confirm(): void
'employment_type' => $this->employmentType, 'employment_type' => $this->employmentType,
'start_date' => $this->startDate, 'start_date' => $this->startDate,
'branch_id' => $this->branchId, 'branch_id' => $this->branchId,
'salary_amount' => $this->monthlySalary ? (int) round((float) $this->monthlySalary * 100) : null,
'salary_frequency' => $this->monthlySalary ? 'monthly' : null,
]; ];
$employee = app(EmployeeService::class)->create($employeeData, auth()->user()); $employee = app(EmployeeService::class)->create($employeeData, auth()->user());
......
...@@ -311,6 +311,20 @@ class="rounded border-gray-300 text-blue-600 focus:ring-blue-500"> ...@@ -311,6 +311,20 @@ class="rounded border-gray-300 text-blue-600 focus:ring-blue-500">
@error('compensationModel') <p class="mt-1 text-xs text-red-600">{{ $message }}</p> @enderror @error('compensationModel') <p class="mt-1 text-xs text-red-600">{{ $message }}</p> @enderror
</div> </div>
@if($compensationModel === 'salary')
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">
{{ __('الراتب الشهري') }} <span class="text-red-500">*</span>
</label>
<div class="relative">
<input type="number" wire:model="monthlySalary" dir="ltr" step="0.01" min="0"
class="w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm pe-12 @error('monthlySalary') border-red-500 @enderror">
<span class="absolute end-3 top-1/2 -translate-y-1/2 text-xs text-gray-400">{{ __('ج.م') }}</span>
</div>
@error('monthlySalary') <p class="mt-1 text-xs text-red-600">{{ $message }}</p> @enderror
</div>
@endif
@if(in_array($compensationModel, ['hourly', 'hybrid'])) @if(in_array($compensationModel, ['hourly', 'hybrid']))
<div> <div>
<label class="block text-sm font-medium text-gray-700 mb-1"> <label class="block text-sm font-medium text-gray-700 mb-1">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment