@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 --}}
@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--}}
Contract Details
- Subject:
{{$contract?->subject}}
- Company:
{{$contract?->assignable?->name}}
- Propgram:
{{$contract?->program?->name}}
- Value:
{{$contract ? cMoney($contract->value, $contract->currency, true) : '' }}
- Start Date:
{{ formatDateTime($contract?->start_date) }}
- End Date:
{{ formatDateTime($contract?->end_date) }}
- Reference ID:
{{ $contract?->refrence_id }}
@if(!($existing_change_order?->id))
{!! Form::hidden('change_request_type', 'update-terms', ['id' => 'change-request-type', 'class' => 'dependent-select']) !!}
{{--
--}}
{!! 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')]) !!}
{{ 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')]) !!}
{!! 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')]) !!}
{{ 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')]) !!}
{{ 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')]) !!}
@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() !!}