@extends('admin.layouts.app') @section('title', get_setting('site_name').' | '.__('Salary Structure Rules')) @section('content') @php $scopedRulesOn = (int) get_setting('salary_structure_scoped_rules') === 1; $rules = old('rules', $row->rules ?? []); if (! is_array($rules) || count($rules) === 0) { $rules = [\App\Services\SalaryStructureService::normalizeRule([ 'id' => 'new_1', 'label' => '', 'type' => \App\Services\SalaryStructureService::TYPE_PERCENT_OF_BASIC, 'apply_at' => \App\Services\SalaryStructureService::APPLY_SETUP, 'percent' => 0, 'target' => 'house_rent', 'enabled' => true, 'sort' => 10, 'scope_mode' => 'all', 'scope_ids' => [], ])]; } $targetLabels = [ 'basic_salary' => __('Basic Salary'), 'house_rent' => __('House Rent'), 'medical' => __('Medical'), 'food' => __('Food / Lunch'), 'conveyance' => __('Conveyance / Travel'), 'utility' => __('Utility / Mobile'), 'Others' => __('Others'), 'provident_fund' => __('Provident Fund'), ]; @endphp
{{ __('Salary Structure Rules') }}
@if((int) get_setting('salary_structure_rules') !== 1) {{ __('Rules feature OFF') }} @else {{ __('Rules ON') }} @endif @if($scopedRulesOn) {{ __('Scoped rules ON') }} @else {{ __('Scoped rules OFF — all employees') }} @endif

{{ __('Company-wide allowance formulas. Enter basic on salary setup; rules fill components. Lunch and bill overrides apply at payroll.') }}

@if($scopedRulesOn)

{{ __('Scoped rules enabled. Each rule can target all staff, selected branches, departments, or employees. When several rules match the same slot, priority is: employee → department → branch → all.') }} {{ __('Change in Website Settings') }}

@else

{{ __('All rules currently apply to every employee. Enable') }} {{ __('Salary Structure Scoped Rules') }} {{ __('in Website Settings to limit lunch and other allowances by branch, department, or employee.') }}

@endif
@csrf
@csrf
@if($scopedRulesOn) @endif @foreach($rules as $i => $rule) @php $rule = is_array($rule) ? $rule : []; $scopeMode = $rule['scope_mode'] ?? 'all'; $scopeIds = $rule['scope_ids'] ?? []; @endphp @if($scopedRulesOn) @else @endif @endforeach
{{ __('On') }} {{ __('Label') }} {{ __('Type') }} {{ __('% / Amount / Rate') }} {{ __('Apply at') }} {{ __('Target') }}{{ __('Scope') }}{{ __('Payroll override') }} {{ __('Sort') }}
{{ __('Salary Setup') }}
@endsection @section('script') @endsection