@use(Carbon\Carbon)

@extends('adminlte::layouts.app')

@section('htmlheader_title')
	{{ $so->sid }}
@endsection
@section('page_title')
	{{ $so->sid }}
@endsection

@section('contentheader_title')
	Service: {{ $so->sid }} <strong>{{ $so->product->name }}</strong>
@endsection
@section('contentheader_description')
	{{ $so->name }}
@endsection

@section('main-content')
	<div class="row">
		<div class="col-12 col-md-6">
			<form method="POST">
				@csrf

				<div class="card card-dark">
					<div class="card-header p-2">
						<div class="card-title">Cancelling Service</div>
					</div>

					<div class="card-body">
						<div class="row">
							<div class="col-8 col-sm-6 col-md-12 col-lg-6">
								<x-leenooks::form.date name="stop_at" icon="fa-calendar" label="Cancel Date" :helper="sprintf('After %s',$so->cancel_date->format('Y-m-d'))" :value="($x=$so->stop_at) ? $x->format('Y-m-d') : ''"/>
							</div>
							<div class="col-8 col-sm-6 col-md-12 col-lg-6">
								<x-leenooks::form.date name="paid_to" icon="fa-money" label="Paid To" :value="$so->invoiced_to->format('Y-m-d')" readonly/>
							</div>
						</div>

						@if(old('stop_at') && Carbon::now()->lessThan(old('stop_at')))
							<div class="row">
								<div class="col-5 col-md-10 col-lg-6 col-xl-5">
									<x-leenooks::form.text class="text-right" name="extra_charges_amount" icon="fa-dollar-sign" label="Estimated Extra Charges" :value="number_format($so->billing_charge_to(Carbon::create(old('stop_at'))),2)" :old="false" readonly/>
								</div>
								<div class="col-1">
									<x-leenooks::form.checkbox name="extra_charges" label="Accept" value="1"/>
								</div>
							</div>
						@endif
						<div class="row">
							<div class="col">
								<x-leenooks::form.textarea name="notes" label="Notes" placeholder="Please let us know why you are cancelling" :value="$so->order_info_notes ?? ''"/>
							</div>
						</div>
					</div>

					<div class="card-footer">
						<x-leenooks::button.cancel/>
						<x-leenooks::button.submit class="float-right">Save</x-leenooks::button.submit>
					</div>
				</div>
			</form>
		</div>
	</div>
@endsection