add times to vehicle reservation

This commit is contained in:
Arnaud Delcasse
2025-12-02 08:30:56 +01:00
parent bf15e114f3
commit 702cbf67f1
5 changed files with 67 additions and 271 deletions

View File

@@ -21,9 +21,8 @@
<div class="bg-white shadow sm:rounded-2xl">
<h2 id="timeline-title" class="text-lg font-medium text-gray-900 p-4 sm:px-6">Chercher un véhicule</h2>
<div class="border-t border-gray-200 px-4 py-5 sm:px-6">
<form method="GET">
<div x-data="{
<form method="GET" x-data="{
beneficiarySelected: {{if .ViewState.search}}true{{else}}false{{end}},
text: '{{if .ViewState.search}}{{.ViewState.search.beneficiary.Data.first_name}} {{.ViewState.search.beneficiary.Data.last_name}}{{end}}',
beneficiariesListOpen: false,
beneficiaries: {{json .ViewState.beneficiaries}},
@@ -37,13 +36,16 @@
beneficiaryid: {{if .ViewState.search}}'{{.ViewState.search.beneficiary.ID}}'{{else}}null{{end}},
},
selectbeneficiary(beneficiary) {
this.fields.beneficiaryid = beneficiary.id
this.fields.beneficiaryid = beneficiary.id
this.text = beneficiary.data.first_name + ' ' + beneficiary.data.last_name
this.beneficiariesListOpen = false
this.beneficiarySelected = true
},
}">
}" @submit="if(!beneficiarySelected) { $event.preventDefault(); alert('Veuillez sélectionner un bénéficiaire'); }">
<div>
<input type="hidden" name="beneficiaryid" x-model="fields.beneficiaryid">
<label for="combobox" class="block text-sm font-medium text-gray-700">Bénéficiaire</label>
<label for="combobox" class="block text-sm font-medium text-gray-700">Bénéficiaire <span class="text-red-600">*</span></label>
<div class="relative mt-1 mb-4">
<input autocomplete="off" @focus="beneficiariesListOpen = true" x-model="text" id="combobox" type="text" class="w-full rounded-2xl border border-gray-300 bg-white py-2 pl-3 pr-12 shadow-sm focus:border-co-blue focus:outline-none focus:ring-1 focus:ring-co-blue sm:text-sm" role="combobox" aria-controls="options" aria-expanded="false">
@@ -89,20 +91,36 @@
{{ template "address_autocomplete" dict "FieldName" $fieldName }} -->
<div class="py-4 grid grid-cols-2">
<div class="lg:col-span-1">
<label for="startdate" class="block text-sm font-medium text-gray-700">Du</label>
<label for="startdate" class="block text-sm font-medium text-gray-700">Du <span class="text-red-600">*</span></label>
<div class="mt-1">
<input type="date" id="startdate" name="startdate" value="{{.ViewState.search.startdate}}"
<input type="date" id="startdate" name="startdate" value="{{if .ViewState.search}}{{(timeFrom .ViewState.search.startdate).Format "2006-01-02"}}{{end}}" required
class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-l-2xl border-r-1">
</div>
</div>
<div class="lg:col-span-1">
<label for="enddate" class="block text-sm font-medium text-gray-700">Au</label>
<label for="enddate" class="block text-sm font-medium text-gray-700">Au <span class="text-red-600">*</span></label>
<div class="mt-1">
<input type="date" id="enddate" name="enddate" value="{{.ViewState.search.enddate}}"
<input type="date" id="enddate" name="enddate" value="{{if .ViewState.search}}{{(timeFrom .ViewState.search.enddate).Format "2006-01-02"}}{{end}}" required
class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-r-2xl border-l-0">
</div>
</div>
</div>
<div class="py-4 grid grid-cols-2 gap-4">
<div class="lg:col-span-1">
<label for="starttime" class="block text-sm font-medium text-gray-700">Prise en charge</label>
<div class="mt-1">
<input type="time" id="starttime" name="starttime" value="{{if .ViewState.search}}{{(timeFrom .ViewState.search.startdate).Format "15:04"}}{{else}}09:00{{end}}"
class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-2xl">
</div>
</div>
<div class="lg:col-span-1">
<label for="endtime" class="block text-sm font-medium text-gray-700">Restitution</label>
<div class="mt-1">
<input type="time" id="endtime" name="endtime" value="{{if .ViewState.search}}{{(timeFrom .ViewState.search.enddate).Format "15:04"}}{{else}}18:00{{end}}"
class="shadow-sm focus:ring-co-blue focus:border-co-blue block w-full sm:text-sm border-gray-300 rounded-2xl">
</div>
</div>
</div>
<div class="py-4"
x-data="{
@@ -147,20 +165,6 @@
<div class="lg:col-start-2 lg:col-span-2">
{{if .ViewState.searched}}
<div class="bg-white px-4 py-5 shadow sm:rounded-2xl sm:px-6">
<h2 id="timeline-title" class="text-lg font-medium text-gray-900">Documents demandés</h2>
<table>
<tbody>
{{range .ViewState.search.mandatory_documents}}
<tr>
<td class="whitespace-nowrap py-4 px-3 text-sm text-gray-500">
{{index $.ViewState.search.file_types_map .}}
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
<div class="bg-white mt-8 px-4 py-5 shadow sm:rounded-2xl sm:px-6">
<h2 id="timeline-title" class="text-lg font-medium text-gray-900">Véhicules disponibles</h2>
<div class="mt-8 flex flex-col">
<div class="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">
@@ -169,7 +173,6 @@
<thead>
<tr>
<th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 md:pl-0">Véhicule</th>
<th scope="col" class="py-3.5 px-3 text-left text-sm font-semibold text-gray-900">Numéro</th>
<th scope="col" class="py-3.5 px-3 text-left text-sm font-semibold text-gray-900">Gestionnaire</th>
<th scope="col" class="py-3.5 px-3 text-left text-sm font-semibold text-gray-900">Lieu</th>
<th scope="col" class="relative py-3.5 pl-3 pr-4 sm:pr-6 md:pr-0">
@@ -180,7 +183,7 @@
<tbody class="divide-y divide-gray-200">
{{range .ViewState.search.vehicles}}
<tr>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6 md:pl-0">
<td class="py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6 md:pl-0">
<div class="font-medium text-gray-900">{{.Data.name}}</div>
<div class="text-gray-500">
{{.Type}}
@@ -188,10 +191,12 @@
{{ if .Data.automatic}} (boite auto){{ end }}
{{end}}
</div>
{{if .Data.licence_plate}}
<div class="text-gray-500 text-xs mt-1">{{.Data.licence_plate}}</div>
{{end}}
</td>
<td class="whitespace-nowrap py-4 px-3 text-sm text-gray-500">{{.Data.licence_plate}}</td>
<td class="whitespace-nowrap py-4 px-3 text-sm text-gray-500">{{(index $.ViewState.search.admingroups (index .Administrators 0)).Data.name}}</td>
<td class="whitespace-nowrap py-4 px-3 text-sm text-gray-500">{{if .Data.address}}{{.Data.address.properties.label}}{{end}}</td>
<td class="py-4 px-3 text-sm text-gray-500">{{if .Data.address}}{{.Data.address.properties.label}}{{end}}</td>
<td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6 md:pr-0"
x-data="{
documentsdialog: false
@@ -216,7 +221,7 @@
</div>
</div>
</div>
<form enctype="multipart/form-data" method="POST" action="/app/vehicles/v/{{.ID}}/b/{{$.ViewState.search.beneficiary.ID}}?startdate={{$.ViewState.search.startdate}}&enddate={{$.ViewState.search.enddate}}">
<form enctype="multipart/form-data" method="POST" action="/app/vehicles/v/{{.ID}}/b/{{$.ViewState.search.beneficiary.ID}}?startdate={{(timeFrom $.ViewState.search.startdate).Format "2006-01-02"}}&enddate={{(timeFrom $.ViewState.search.enddate).Format "2006-01-02"}}&starttime={{(timeFrom $.ViewState.search.startdate).Format "15:04"}}&endtime={{(timeFrom $.ViewState.search.enddate).Format "15:04"}}">
{{range $.ViewState.search.mandatory_documents}}
{{$type := .}}
<div class="p-2"