@extends('layouts.app') @section('content')

@lang('goals::goals.add_goal')

{{ Form::open(['url' => route('goal.store', $id), 'method' => 'POST', 'id' => 'goalForm']) }}
@component('components.widget', ['class' => 'box-solid'])
{!! Form::label('user_id', __('user.name') . ':') !!} {!! Form::select('user_id', $users ?? [], null, [ 'class' => 'form-control select2', 'id' => 'user_id', 'required', 'placeholder' => __('messages.please_select') ]) !!}
@foreach ($goals as $index => $goal)
@lang('goals::goals.goal') #{{ $index + 1 }}
{{-- Item Name (readonly) --}}
{!! Form::label("goals[$index][item_name]", __('goals::goals.item_name')) !!} {!! Form::text("goals[$index][item_name]", $goal->item_name, ['class' => 'form-control', 'readonly']) !!}
{{-- Type (readonly) --}}
{!! Form::label("goals[$index][type_translated]", __('lang_v1.type')) !!} {!! Form::text("goals[$index][type_translated]", $goal->type_translated, ['class' => 'form-control goal-type', 'readonly']) !!}
{!! Form::label("goals[$index][goal_type]", __('lang_v1.type')) !!} {!! Form::text("goals[$index][goal_type]",$goal->goal_type , ['class' => 'form-control goal-type', 'readonly']) !!}
{{-- Amount Type (only for product type, selectable) --}} @if (strtolower($goal->goal_type) == 'product')
{!! Form::label("goals[$index][amount_type]", __('goals::goals.amount_type')) !!} {!! Form::select( "goals[$index][amount_type]", ['amount' => __('sale.amount'), 'quantity' => __('lang_v1.quantity')], null, ['class' => 'form-control amount-type-select input_number'], ) !!}
@else {!! Form::hidden("goals[$index][amount_type]", 'amount') !!} @endif {{-- Amount (editable) --}}
{!! Form::label("goals[$index][amount]", __('goals::goals.amount') . ':*') !!} {!! Form::number("goals[$index][amount]", null, [ 'class' => 'form-control amount-input payment_amount', 'min' => 0, 'step' => 'any', 'required', ]) !!}
{{-- Reward Amount (editable) --}}
{!! Form::label("goals[$index][reward_amount]", __('goals::goals.reward_amount') . ':*') !!} {!! Form::number("goals[$index][reward_amount]", null, [ 'class' => 'form-control reward-amount-input payment_amount', 'min' => 0, 'step' => 'any', 'required', ]) !!}
{{-- Hidden item_id (for backend) --}} {!! Form::hidden("goals[$index][item_id]", $goal->item_id) !!} {{-- Child Goals container --}}
@lang('goals::goals.child_goal')
{{-- Child goals will be appended here dynamically --}}
@endforeach @endcomponent
{{ Form::close() }}
@endsection @section('javascript') @endsection