camper/web/templates/admin/booking/fields.gohtml

284 lines
12 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--
SPDX-FileCopyrightText: 2023 jordi fita mas <jordi@tandem.blog>
SPDX-FileCopyrightText: 2023 Oriol Carbonell <info@oriolcarbonell.cat>
SPDX-License-Identifier: AGPL-3.0-only
-->
{{- /*gotype: dev.tandem.ws/tandem/camper/pkg/booking.adminBookingForm*/ -}}
{{ CSRFInput }}
<fieldset>
<input type="hidden" name="{{ .PaymentSlug.Name }}" value="{{ .PaymentSlug.Val }}">
{{ with .CampsiteType -}}
<label>
{{( pgettext "Accommodation" "title" )}}<br>
<select name="{{ .Name }}"
required
data-hx-get="/admin/bookings/new" data-hx-trigger="change"
{{ template "error-attrs" . }}
>
<option value="">{{( gettext "Choose an accomodation" )}}</option>
{{ template "list-options" . }}
</select><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Dates -}}
<fieldset class="booking-period"
data-hx-get="/admin/bookings/new"
data-hx-trigger="change delay:500ms"
>
{{ with .ArrivalDate -}}
<label>
{{( pgettext "Arrival date" "input" )}}<br>
<input type="date" required
min="{{ formatDateAttr .MinDate }}"
max="{{ formatDateAttr .MaxDate }}"
name="{{ .Name }}" value="{{ .Val }}" {{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .DepartureDate -}}
<label>
{{( pgettext "Departure date" "input" )}}<br>
<input type="date" required
min="{{ formatDateAttr .MinDate }}"
max="{{ formatDateAttr .MaxDate }}"
name="{{ .Name }}" value="{{ .Val }}" {{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
</fieldset>
{{- end }}
{{ with .Options -}}
{{ with .ZonePreferences -}}
<label>{{( pgettext "Area preferences (optional)" "input" )}}<br>
<input type="text"
name="{{ .Name }}" value="{{ .Val }}" {{ template "error-attrs" . }}
><br>
<a href="/{{ currentLocale }}/campground?zones" target="_blank">{{( gettext "Campground map" )}}</a><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{- end }}
{{ with $guests := .Guests -}}
{{ $draft := $.Cart.Draft }}
<fieldset class="booking-items"
data-hx-get="/admin/bookings/new" data-hx-trigger="change"
>
<table>
<thead>
<tr>
<th scope="col">{{( pgettext "Units" "header" )}}</th>
<th scope="col">{{( pgettext "Decription" "header" )}}</th>
<th scope="col" class="numeric">{{( pgettext "Total" "header" )}}</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ $draft.NumNights }}</td>
<td>{{( pgettext "Night" "cart" )}}</td>
<td class="numeric">{{ formatPrice $draft.Nights }}</td>
</tr>
{{ with .NumberAdults -}}
<tr>
<td><input id="adults" type="number" required
name="{{ .Name }}" value="{{ .Val }}"
min="1"{{if not $guests.OverflowAllowed }} max="{{ $guests.MaxGuests }}"{{ end }}
{{ template "error-attrs" . }}
>
</td>
<td>
<label for="adults">{{( pgettext "Adults aged 17 or older" "input" )}}</label><br>
{{ template "error-message" . }}
</td>
<td class="numeric">{{ formatPrice $draft.Adults }}</td>
</tr>
{{- end }}
{{ with .NumberTeenagers -}}
<tr>
<td>
<input id="teenagers" type="number" required
name="{{ .Name }}" value="{{ .Val }}"
min="0"{{if not $guests.OverflowAllowed }} max="{{ $guests.MaxGuests | dec }}"{{ end }}
{{ template "error-attrs" . }}
>
</td>
<td>
<label for="teenagers">{{( pgettext "Teenagers from 11 to 16 years old" "input" )}}</label><br>
{{ template "error-message" . }}
</td>
<td class="numeric">{{ formatPrice $draft.Teenagers }}</td>
</tr>
{{- end }}
{{ with .NumberChildren -}}
<tr>
<td>
<input id="children" type="number" required
name="{{ .Name }}" value="{{ .Val }}"
min="0"{{if not $guests.OverflowAllowed }} max="{{ $guests.MaxGuests | dec }}"{{ end }}
{{ template "error-attrs" . }}
>
</td>
<td>
<label for="children">{{( pgettext "Children from 2 to 10 years old" "input" )}}</label><br>
{{ template "error-message" . }}
</td>
<td class="numeric">{{ formatPrice $draft.Children }}</td>
</tr>
{{- end }}
{{ with .NumberDogs -}}
<tr>
<td>
<input id="dogs" type="number" required
name="{{ .Name }}" value="{{ .Val }}" min="0"
{{ template "error-attrs" . }}
>
</td>
<td>
<label for="dogs">{{( pgettext "Dogs" "input" )}}</label><br>
{{ template "error-message" . }}
</td>
<td class="numeric">{{ formatPrice $draft.Dogs }}</td>
</tr>
{{- end }}
{{ with $.Options -}}
{{ range .Options -}}
<tr>
<td>
<input id="{{ .Input.Name }}" type="number" required
name="{{ .Input.Name }}" value="{{ .Input.Val }}"
min="{{ .Min }}" max="{{ .Max }}"
{{ template "error-attrs" .Input }}
>
</td>
<td>
<label for="{{ .Input.Name }}">{{ .Label }}</label><br>
{{ template "error-message" .Input }}
</td>
<td class="numeric">{{ formatPrice .Subtotal }}</td>
</tr>
{{- end }}
{{- end }}
<tr>
<td>{{ $draft.NumAdults }}</td>
<td>{{( pgettext "Tourist tax" "cart" )}}</td>
<td class="numeric">{{ formatPrice $draft.TouristTax }}</td>
</tr>
</tbody>
<tfoot>
<tr>
<th scope="row" colspan="2" class="numeric">{{( pgettext "Total" "header" )}}</th>
<td class="numeric">{{ formatPrice $draft.Total }}</td>
</tr>
</tfoot>
</table>
{{ if not .NumberDogs -}}
<small>{{( gettext "Note: This accommodation does <strong>not</strong> allow dogs.") | raw }}</small>
{{- end }}
{{ if .Error -}}
<p class="error">{{ .Error }}</p>
{{- end }}
</fieldset>
{{- end }}
{{ with .Customer -}}
<fieldset class="customer-details">
<legend>{{( pgettext "Customer Details" "title" )}}</legend>
{{ with .FullName -}}
<label>
{{( pgettext "Full name" "input" )}}<br>
<input type="text" required minlength="2"
name="{{ .Name }}" value="{{ .Val }}" {{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Country -}}
<label>
{{( pgettext "Country" "input" )}}<br>
<select name="{{ .Name }}"
required
{{ template "error-attrs" . }}
>
<option>{{( gettext "Choose a country" )}}</option>
{{ template "list-options" . }}
</select><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Address -}}
<label class="colspan">
{{( pgettext "Address" "input" )}}<br>
<input type="text" required
name="{{ .Name }}" value="{{ .Val }}" {{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .PostalCode -}}
<label>
{{( pgettext "Postcode" "input" )}}<br>
<input type="text" required
name="{{ .Name }}" value="{{ .Val }}" {{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .City -}}
<label>
{{( pgettext "Town or village" "input" )}}<br>
<input type="text"
required
name="{{ .Name }}" value="{{ .Val }}" {{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Email -}}
<label>
{{( pgettext "Email" "input" )}}<br>
<input type="email" required
name="{{ .Name }}" value="{{ .Val }}" {{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with .Phone -}}
<label>
{{( pgettext "Phone" "input" )}}<br>
<input type="tel" required
name="{{ .Name }}" value="{{ .Val }}" {{ template "error-attrs" . }}
><br>
{{ template "error-message" . }}
</label>
{{- end }}
{{ with $.Guests.ACSICard -}}
<label class="colspan" data-hx-get="/admin/bookings/new" data-hx-trigger="change">
<input type="checkbox" name="{{ .Name }}" {{ if .Checked}}checked{{ end }}
{{ template "error-attrs" . }}
> {{( pgettext "ACSI card? (optional)" "input" )}}<br>
{{ template "error-message" . }}
</label>
{{- end }}
</fieldset>
{{- end }}
{{ if .Campsites -}}
<h3>{{( pgettext "Campsites" "title" )}}</h3>
{{ template "grid.gohtml" . }}
{{- end }}
</fieldset>
<footer>
<button type="submit">
{{- if .ID -}}
{{( pgettext "Update" "action" )}}
{{- else -}}
{{( pgettext "Add" "action" )}}
{{- end -}}
</button>
</footer>
{{ define "campsite-heading" -}}
<label><input type="checkbox"> {{ .Label }}</label>
{{- end }}