@php $isEdit = !empty($assignment); $action = $isEdit ? action([\App\Http\Controllers\HoldingController::class, 'updateAssignment'], [$assignment->id]) : action([\App\Http\Controllers\HoldingController::class, 'storeAssignment']); $selectedDesignation = $assignment->meta['hrm_designation_id'] ?? null; @endphp {!! Form::open(['url' => $action, 'method' => $isEdit ? 'put' : 'post', 'id' => 'holding_assignment_form']) !!}

{{ $isEdit ? __('lang_v1.holding_edit_assignment') : __('lang_v1.holding_add_employment_assignment') }}

{!! Form::label('user_id', __('role.user') . ':*') !!} {!! Form::select('user_id', $users, $assignment->user_id ?? null, ['class' => 'form-control select2 holding-assignment-user', 'required', 'placeholder' => __('role.user')]) !!}
{!! Form::label('entity_id', __('lang_v1.holding_entity') . ':*') !!} {!! Form::select('entity_id', $entities, $assignment->entity_id ?? null, ['class' => 'form-control select2', 'required', 'placeholder' => __('lang_v1.holding_entity')]) !!}
{!! Form::label('org_unit_id', __('lang_v1.holding_org_unit') . ':') !!} {!! Form::select('org_unit_id', $units, $assignment->org_unit_id ?? null, ['class' => 'form-control select2 holding-assignment-org-unit', 'placeholder' => __('lang_v1.holding_org_unit')]) !!}
{!! Form::label('role_id', __('role.role') . ':') !!} {!! Form::select('role_id', $roles, $assignment->role_id ?? null, ['class' => 'form-control select2', 'placeholder' => __('role.role')]) !!}
{!! Form::label('hrm_designation_id', __('lang_v1.holding_job_title') . ' (HRM):') !!} {!! Form::select('hrm_designation_id', $designations, $selectedDesignation, ['class' => 'form-control select2 holding-assignment-designation', 'placeholder' => __('lang_v1.holding_select_hrm_designation')]) !!}

@lang('lang_v1.holding_designation_hrm_hint')

{!! Form::label('title', __('lang_v1.holding_job_title_custom') . ':') !!} {!! Form::text('title', empty($selectedDesignation) ? ($assignment->title ?? null) : null, ['class' => 'form-control holding-assignment-title-custom', 'placeholder' => __('lang_v1.holding_job_title_custom_placeholder')]) !!}
{!! Form::label('employment_type', __('lang_v1.type') . ':') !!} {!! Form::select('employment_type', $employmentTypes, $assignment->employment_type ?? 'employee', ['class' => 'form-control select2']) !!}
{!! Form::label('start_date', __('lang_v1.holding_start_date') . ':') !!} {!! Form::text('start_date', !empty($assignment->start_date) ? format_date($assignment->start_date) : null, ['class' => 'form-control holding-date-picker', 'readonly', 'autocomplete' => 'off']) !!}
{!! Form::label('end_date', __('lang_v1.holding_end_date') . ':') !!} {!! Form::text('end_date', !empty($assignment->end_date) ? format_date($assignment->end_date) : null, ['class' => 'form-control holding-date-picker', 'readonly', 'autocomplete' => 'off']) !!}
  
{!! Form::close() !!}