@if ($change_order->id) {!! Form::model($change_order, ['route' => ['admin.contracts.change-requests.update', ['change_request' => $change_order, 'contract' => $change_order->contract, 'contract_id' => $change_order->contract]], 'method' => 'PUT']) !!} @else {!! Form::model($change_order, ['route' => ['admin.contracts.change-requests.store', ['table_id' => request()->table_id] + (isset($contract) ? ['contract_id' => $contract] : [])], 'method' => 'POST', 'id' => 'create-change-request-form']) !!} @endif {{-- @dd($change_order) --}}
@php $contract = isset($contract) ? $contract : $change_order->contract; @endphp @if(!isset($contract?->id)) {{-- client --}}
{{ Form::label('company_id', __('Client'), ['class' => 'col-form-label']) }} {!! Form::select('company_id', $change_order->contract ? [$change_order->contract->assignable->uuid => $change_order->contract->assignable->name] : [], @$change_order->contract?->assignable->uuid, [ 'id' => 'client_id-select', 'class' => 'form-select dependent-select required', 'data-kt-select2' => 'true', 'data-placeholder' => 'Select Client', 'data-remote' => route('resource-select', ['groupedCompany']), 'data-allow-clear' => 'true' ]) !!}
{{-- program --}}
{!! Form::label('program_id', 'Programs', ['class' => 'col-form-label'] ) !!} {!! Form::select('program_id', [], [], [ 'class' => 'form-select dependent-select', 'data-kt-select2' => 'true', 'id' => 'program_id-select', 'data-placeholder' => __('All'), 'data-allow-clear' => 'true', 'data-remote' => route('resource-select', ['Program', 'dependent' => 'company_id']), 'data-dependent_id' => 'client_id-select' ]) !!}
{{-- reference_id --}}
{!! Form::label('reference_id', 'Reference ID', ['class' => 'col-form-label']) !!} {!! Form::text('reference_id', null, [ 'id' => 'cont-ref-id', 'class' => 'form-control selected-cont-ref-id', 'placeholder' => 'Reference ID', 'data-dependent_id' => 'client_id-select', 'data-dependent_3' => 'program_id-select' ]) !!}
{{-- Contract --}}
{!! Form::select('contract_id', $change_order->contract ? [$change_order->contract->uuid => $change_order->contract->subject] : [], $contract?->uuid ?? null, [ 'data-placeholder' => 'Select Contract', 'class' => 'form-select', 'data-kt-select2' => 'true', 'data-remote' => route('resource-select', ['Contract', 'dependent' => 'company_id', 'dependent_3_col' => 'program_id', 'dependent_4_col' => 'reference_id']), 'data-dependent_id' => 'client_id-select', 'data-dependent_3' => 'program_id-select', 'data-dependent_4' => 'cont-ref-id', 'id' => 'contract_id' ])!!}
@endif @php $ac_sec_same_class = (isset($contract?->id) || $change_order->id) ? '' : 'd-none'; @endphp
@php $existing_change_order = $contract?->changeRequests()->where('status', 'Pending')->when(isset($change_order) && $change_order->id, fn($q) => $q->where('id', '!=', $change_order->id))->first(); if($existing_change_order?->id){ $ac_sec_same_class = 'd-none'; } @endphp
{{-- Selected Contract Details (subject, value, start date, end date) in warning message--}}
@if(!($existing_change_order?->id))
id || $change_order->action == 'Terms Update') && $contract?->status != 'Paused')>
action == 'Pause Contract')>
action == 'Resume' || $contract?->status == 'Paused')>
action == 'Termination')>
action, ['Early Completed', 'Completed']))>
{!! Form::hidden('change_request_type', 'update-terms', ['id' => 'change-request-type', 'class' => 'dependent-select']) !!}
{{--
action != 'Early Completed')>
action == 'Early Completed')>
--}}
Update Terms
{!! Form::text('current_amount', @$contract?->printable_value ?? null, ['class' => 'form-control', 'disabled','placeholder' => __('value'), 'data-value' => @$contract?->value ?? null, 'data-currency' => $contract?->currency]) !!}
{!! Form::text('new_value', @$modifications['new_value'] ? cMoney($modifications['new_value'], $snapshot['currency'], true) : null, ['class' => 'form-control new_value', 'disabled','placeholder' => __('Value')]) !!}
@$snapshot['value'])>
{!! Form::number('value_change', abs(@$modifications['new_value'] - @$snapshot['value']), ['class' => 'form-control value_change', 'placeholder' => __('Value')]) !!}

{{ Form::label('c_end_date', __('Current End Date'), ['class' => 'col-form-label']) }} {!! Form::date('c_end_date', @$contract?->end_date, ['class' => 'form-control calculator_input_date', 'disabled','placeholder' => __('End Date')]) !!}
{{-- due date --}}
{{ Form::label('new_end_date', __('New End Date'), ['class' => 'col-form-label']) }} {!! Form::date('new_end_date', $modifications['new_end_date'] ?? null, ['class' => 'form-control flatpickr calculated_date', 'placeholder' => __('End Date')]) !!}
@$snapshot['end_date'])>
{!! Form::number('timeline_change', @$modifications['new_end_date']?->diffInDays(@$snapshot['end_date']), ['class' => 'form-control timeline_change', 'placeholder' => __('Value')]) !!} {!! Form::select('timeline_unit', ['Day' => 'Day(s)', 'Month' => 'Month(s)', 'Year' => 'Year(s)'], null, [ 'data-start-date' => @$snapshot['end_date'], 'class' => 'form-select timeline_change_unit', 'data-kt-select2' => 'true' ])!!}
Resume Contract
{!! Form::text('current_amount', @$contract?->printable_value ?? null, ['class' => 'form-control', 'disabled','placeholder' => __('value'), 'data-value' => @$contract?->value ?? null, 'data-currency' => $contract?->currency]) !!}
{!! Form::text('new_value_resume', @$modifications['new_value_resume'] ? cMoney($modifications['new_value_resume'], $contract?->currency, true) : null, ['class' => 'form-control new_value', 'disabled','placeholder' => __('Value')]) !!}
contract) || @$modifications['new_value_resume'] == @$snapshot['value'])>
@$snapshot['value'])>
{!! Form::number('value_change_resume', @$modifications['new_value_resume'] - @$snapshot['value'], ['class' => 'form-control value_change', 'placeholder' => __('Value')]) !!}

{{ Form::label('c_start_date', __('Start Date'), ['class' => 'col-form-label']) }} {!! Form::date('c_start_date', @$contract?->start_date, ['class' => 'form-control calculator_input_date', 'disabled','placeholder' => __('Start Date')]) !!}
{{-- due date --}}
{{ Form::label('start_date', __('New Start Date'), ['class' => 'col-form-label']) }} {!! Form::date('start_date', @$modifications['start_date'], ['class' => 'form-control flatpickr calculated_date', 'placeholder' => __('Start Date')]) !!}
@$snapshot['start_date'])>
{!! Form::number('timeline_change', @$modifications['start_date']?->diffInDays(@$snapshot['start_date']), ['class' => 'form-control timeline_change', 'placeholder' => __('Value')]) !!} {!! Form::select('timeline_unit', ['Day' => 'Day(s)', 'Month' => 'Month(s)', 'Year' => 'Year(s)'], null, [ 'data-start-date' => @$snapshot['start_date'], 'class' => 'form-select timeline_change_unit', 'data-kt-select2' => 'true' ])!!}

{{ Form::label('c_end_date', __('End Date'), ['class' => 'col-form-label']) }} {!! Form::date('c_end_date', @$contract?->end_date, ['class' => 'form-control calculator_input_date', 'disabled','placeholder' => __('End Date')]) !!}
{{-- due date --}}
{{ Form::label('end_date', __('New End Date'), ['class' => 'col-form-label']) }} {!! Form::date('end_date', @$modifications['end_date'], ['class' => 'form-control flatpickr calculated_date', 'placeholder' => __('End Date')]) !!}
@$snapshot['end_date'])>
{!! Form::number('timeline_change', @$modifications['end_date']?->diffInDays(@$snapshot['end_date']), ['class' => 'form-control timeline_change', 'placeholder' => __('Value')]) !!} {!! Form::select('timeline_unit', ['Day' => 'Day(s)', 'Month' => 'Month(s)', 'Year' => 'Year(s)'], null, [ 'data-start-date' => @$snapshot['end_date'], 'class' => 'form-select timeline_change_unit', 'data-kt-select2' => 'true' ])!!}
@endif
{{ Form::label('event_date', __($change_order->getEventDateTitle()), ['class' => 'col-form-label event_date_label']) }} {!! Form::date('event_date', @$modifications['event_date'], ['class' => 'form-control flatpickr', 'placeholder' => __('Select Date')]) !!}
{{-- requested at --}}
{!! Form::date('requested_at', $change_order->requested_at, ['class' => 'form-control flatpickr', 'placeholder' => __('Requested At')]) !!}
{{--
{!! Form::text('reason', null, ['class' => 'form-control', 'placeholder' => __('Reason')]) !!}
--}}
{!! Form::label('description', 'Description', ['class' => 'col-form-label']) !!} {!! Form::textarea('description', null, ['class' => 'form-control', 'rows' => 2]) !!}
@can('review change request')
@endcan
{!! Form::close() !!}