feat : finalisation de l'étape 1 "Réception" (formulaire)
This commit is contained in:
84
.idea/workspace.xml
generated
84
.idea/workspace.xml
generated
@@ -4,8 +4,24 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="7c107abe-5995-4428-8429-b146aaca8386" name="Changes" comment="fix : modification de la conf du bundle ednotif">
|
||||
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
|
||||
<list default="true" id="7c107abe-5995-4428-8429-b146aaca8386" name="Changes" comment="feat : update du CHANGELOG.md">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/config/reference.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/reference.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/components/reception/reception-form.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/components/reception/reception-form.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/components/reception/reception-weight.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/components/reception/reception-weight.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/components/ui/license-plate-input.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/components/ui/license-plate-input.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/composables/useWeighing.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/composables/useWeighing.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/i18n/locales/fr.json" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/i18n/locales/fr.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/layouts/default.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/layouts/default.vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/nuxt.config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/nuxt.config.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/pages/reception/[[id]].vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/pages/reception/[[id]].vue" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/services/dto/reception-data.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/services/dto/reception-data.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/services/dto/user-data.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/services/dto/user-data.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/services/reception.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/services/reception.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/stores/reception.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/stores/reception.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/frontend/tailwind.config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/tailwind.config.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Entity/Reception.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/Reception.php" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Entity/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/User.php" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -209,41 +225,41 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.MCP Project settings loaded": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||
"git-widget-placeholder": "feat/installation-soap-bundle",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.keymap",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.MCP Project settings loaded": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||
"git-widget-placeholder": "feat/finalisation-reception-marchandise",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.keymap",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
},
|
||||
"keyToStringList": {
|
||||
"DatabaseDriversLRU": [
|
||||
"postgresql"
|
||||
"keyToStringList": {
|
||||
"DatabaseDriversLRU": [
|
||||
"postgresql"
|
||||
],
|
||||
"com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
|
||||
"TEXT"
|
||||
"com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
|
||||
"TEXT"
|
||||
],
|
||||
"vue.recent.templates": [
|
||||
"Vue Composition API Component"
|
||||
"vue.recent.templates": [
|
||||
"Vue Composition API Component"
|
||||
]
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="\\wsl.localhost\Ubuntu-24.04\home\m-tristan\workspace\Ferme" />
|
||||
<recent name="\\wsl.localhost\Ubuntu-24.04\home\tristan\workspace\ferme\templates" />
|
||||
<recent name="C:\Users\autin\AppData\Roaming\JetBrains\PhpStorm2025.3\scratches" />
|
||||
<recent name="C:\Users\autin\AppData\Roaming\JetBrains\PhpStorm2025.3\scratches\Ferme_MCD\MCD_DOC" />
|
||||
<recent name="\\wsl.localhost\Ubuntu-24.04\home\tristan\workspace\ferme\frontend\pages\reception" />
|
||||
<recent name="\\wsl.localhost\Ubuntu-24.04\home\tristan\workspace\ferme\frontend\pages" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="SharedIndexes">
|
||||
@@ -268,7 +284,7 @@
|
||||
<workItem from="1768547023783" duration="11371000" />
|
||||
<workItem from="1768894030675" duration="83922000" />
|
||||
<workItem from="1769413136483" duration="58000" />
|
||||
<workItem from="1769413279223" duration="12282000" />
|
||||
<workItem from="1769413279223" duration="37300000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="feat : Ajout de pinia, création de la table weight et reception mise en place du système de step pour les receptions (WIP)">
|
||||
<option name="closed" value="true" />
|
||||
@@ -550,7 +566,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1769434793487</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="36" />
|
||||
<task id="LOCAL-00036" summary="feat : update du CHANGELOG.md">
|
||||
<option name="closed" value="true" />
|
||||
<created>1769435038236</created>
|
||||
<option name="number" value="00036" />
|
||||
<option name="presentableId" value="LOCAL-00036" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1769435038236</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="37" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -602,7 +626,6 @@
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="feat : ajout d'une gestion d'erreur au global côté front avec la lib toaster et I18n pour centraliser les messages d'erreur" />
|
||||
<MESSAGE value="feat : ajout de l'authentification avec lexik" />
|
||||
<MESSAGE value="feat : update du CHANGELOG.md" />
|
||||
<MESSAGE value="fix : correction de l'accès au swagger en mode dev qui n'était plus accessible" />
|
||||
<MESSAGE value="feat : ajout de la conf pour le déploiement en recette" />
|
||||
<MESSAGE value="fix : fix de la conf pour le déploiement en recette" />
|
||||
@@ -625,7 +648,8 @@
|
||||
<MESSAGE value="feat : ajout de la debug bar en mod dev" />
|
||||
<MESSAGE value="feat : ajout du bundle Malio ednotif pour l'utilisation des WS" />
|
||||
<MESSAGE value="fix : modification de la conf du bundle ednotif" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="fix : modification de la conf du bundle ednotif" />
|
||||
<MESSAGE value="feat : update du CHANGELOG.md" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="feat : update du CHANGELOG.md" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
||||
9
frontend/assets/css/main.css
Normal file
9
frontend/assets/css/main.css
Normal file
@@ -0,0 +1,9 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
@layer base {
|
||||
body {
|
||||
@apply font-sans;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,213 @@
|
||||
<template>
|
||||
<form @submit.prevent="validate">
|
||||
<div class="grid grid-cols-1 items-start gap-8 mb-16">
|
||||
<h1 class="font-bold text-5xl uppercase">Réception</h1>
|
||||
<div>
|
||||
<div class="grid grid-cols-2 items-start gap-y-8 gap-x-40 mb-16">
|
||||
<h1 class="font-bold text-5xl uppercase col-start-1 row-start-1">Réception</h1>
|
||||
<!-- Nom de l'utilisateur -->
|
||||
<div class="flex flex-col col-start-1 row-start-2">
|
||||
<label for="reception-user" class="font-bold uppercase text-xl mb-2">Nom de l'utilisateur</label>
|
||||
<select
|
||||
id="reception-user"
|
||||
v-model="form.userId"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] bg-transparent"
|
||||
:class="[
|
||||
form.userId ? 'text-black' : 'text-neutral-400',
|
||||
isLoadingUsers ? 'cursor-not-allowed' : 'cursor-pointer'
|
||||
]"
|
||||
:disabled="isLoadingUsers"
|
||||
>
|
||||
<option value="" disabled class="text-neutral-400">Sélectionner</option>
|
||||
<option
|
||||
v-for="user in users"
|
||||
:key="user.id"
|
||||
:value="String(user.id)"
|
||||
class="text-black"
|
||||
>
|
||||
{{ user.username }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Date de réception -->
|
||||
<div class="flex flex-col col-start-1 row-start-3">
|
||||
<label for="reception-date" class="font-bold uppercase text-xl mb-2">Date de réception</label>
|
||||
<input
|
||||
id="reception-date"
|
||||
v-model="form.receptionDate"
|
||||
type="date"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] uppercase cursor-pointer bg-transparent appearance-none h-[34px]"
|
||||
/>
|
||||
</div>
|
||||
<!-- Type de réception -->
|
||||
<div class="flex flex-col col-start-1 row-start-4">
|
||||
<label for="reception-type" class="font-bold uppercase text-xl mb-2">Type de réception</label>
|
||||
<select
|
||||
id="reception-type"
|
||||
v-model="form.receptionTypeId"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] bg-transparent cursor-pointer"
|
||||
:class="form.receptionTypeId ? 'text-black' : 'text-neutral-400'"
|
||||
>
|
||||
<option value="" disabled class="text-neutral-400">Sélectionner</option>
|
||||
<option
|
||||
v-for="type in receptionTypes"
|
||||
:key="type.id"
|
||||
:value="String(type.id)"
|
||||
class="text-black"
|
||||
>
|
||||
{{ type.label }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Fournisseur -->
|
||||
<div class="flex flex-col col-start-1 row-start-5">
|
||||
<label for="reception-supplier" class="font-bold uppercase text-xl mb-2">Fournisseur</label>
|
||||
<select
|
||||
id="reception-supplier"
|
||||
v-model="form.supplierId"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] bg-transparent"
|
||||
:class="[
|
||||
form.supplierId ? 'text-black' : 'text-neutral-400',
|
||||
isLoadingSuppliers ? 'cursor-not-allowed' : 'cursor-pointer'
|
||||
]"
|
||||
:disabled="isLoadingSuppliers"
|
||||
>
|
||||
<option value="" disabled class="text-neutral-400">Sélectionner</option>
|
||||
<option
|
||||
v-for="supplier in suppliers"
|
||||
:key="supplier.id"
|
||||
:value="String(supplier.id)"
|
||||
class="text-black"
|
||||
>
|
||||
{{ supplier.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Adresse fournisseur -->
|
||||
<div class="flex flex-col col-start-2 row-start-1">
|
||||
<label for="reception-address" class="font-bold uppercase text-xl mb-2">Adresse</label>
|
||||
<select
|
||||
id="reception-address"
|
||||
v-model="form.addressId"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] bg-transparent"
|
||||
:class="[
|
||||
form.addressId ? 'text-black' : 'text-neutral-400',
|
||||
isLoadingSuppliers || supplierAddresses.length === 0
|
||||
? 'cursor-not-allowed'
|
||||
: 'cursor-pointer'
|
||||
]"
|
||||
:disabled="isLoadingSuppliers || supplierAddresses.length === 0"
|
||||
>
|
||||
<option value="" disabled class="text-neutral-400">Sélectionner</option>
|
||||
<option
|
||||
v-for="address in supplierAddresses"
|
||||
:key="address.id"
|
||||
:value="String(address.id)"
|
||||
class="text-black"
|
||||
>
|
||||
{{ address.fullAddress }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Camion -->
|
||||
<div class="flex flex-col col-start-2 row-start-2">
|
||||
<label for="reception-truck" class="font-bold uppercase text-xl mb-2">Camion</label>
|
||||
<select
|
||||
id="reception-truck"
|
||||
v-model="form.truckId"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] bg-transparent"
|
||||
:class="[
|
||||
form.truckId ? 'text-black' : 'text-neutral-400',
|
||||
isLoadingTrucks ? 'cursor-not-allowed' : 'cursor-pointer'
|
||||
]"
|
||||
:disabled="isLoadingTrucks"
|
||||
>
|
||||
<option value="" disabled class="text-neutral-400">Sélectionner</option>
|
||||
<option
|
||||
v-for="truck in trucks"
|
||||
:key="truck.id"
|
||||
:value="String(truck.id)"
|
||||
class="text-black"
|
||||
>
|
||||
{{ truck.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Transporteur -->
|
||||
<div class="flex flex-col col-start-2 row-start-3">
|
||||
<label for="reception-carrier" class="font-bold uppercase text-xl mb-2">Transporteur</label>
|
||||
<select
|
||||
id="reception-carrier"
|
||||
v-model="form.carrierId"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] bg-transparent h-[34px]"
|
||||
:class="[
|
||||
form.carrierId ? 'text-black' : 'text-neutral-400',
|
||||
isLoadingCarriers ? 'cursor-not-allowed' : 'cursor-pointer'
|
||||
]"
|
||||
:disabled="isLoadingCarriers"
|
||||
>
|
||||
<option value="" disabled class="text-neutral-400">Sélectionner</option>
|
||||
<option
|
||||
v-for="carrier in carriers"
|
||||
:key="carrier.id"
|
||||
:value="String(carrier.id)"
|
||||
class="text-black"
|
||||
>
|
||||
{{ carrier.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Chauffeur (LIOT) -->
|
||||
<div class="flex flex-col col-start-2 row-start-4">
|
||||
<label for="reception-driver" class="font-bold uppercase text-xl mb-2">Nom du chauffeur si LIOT</label>
|
||||
<select
|
||||
id="reception-driver"
|
||||
v-model="form.driverId"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] bg-transparent"
|
||||
:class="[
|
||||
form.driverId ? 'text-black' : 'text-neutral-400',
|
||||
isLoadingDrivers ? 'cursor-not-allowed' : 'cursor-pointer'
|
||||
]"
|
||||
:disabled="isLoadingDrivers"
|
||||
>
|
||||
<option value="" disabled class="text-neutral-400">Sélectionner</option>
|
||||
<option
|
||||
v-for="driver in filteredDrivers"
|
||||
:key="driver.id"
|
||||
:value="String(driver.id)"
|
||||
class="text-black"
|
||||
>
|
||||
{{ driver.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Plaque d'immatriculation -->
|
||||
<div v-if="!isLiotCarrier" class="col-start-2 row-start-5">
|
||||
<UiLicensePlateInput
|
||||
v-model="form.licensePlate"
|
||||
v-model:allowAny="allowAnyLicensePlate"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<label for="reception-date" class="font-bold uppercase text-xl mb-4">Date de reception</label>
|
||||
<input
|
||||
id="reception-date"
|
||||
v-model="form.receptionDate"
|
||||
type="date"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] uppercase"
|
||||
/>
|
||||
<!-- Immatriculation (LIOT) -->
|
||||
<div v-if="isLiotCarrier" class="flex flex-col col-start-2 row-start-5">
|
||||
<label for="reception-vehicle" class="font-bold uppercase text-xl mb-2">Immatriculation</label>
|
||||
<select
|
||||
id="reception-vehicle"
|
||||
v-model="form.vehicleId"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] bg-transparent"
|
||||
:class="[
|
||||
form.vehicleId ? 'text-black' : 'text-neutral-400',
|
||||
isLoadingVehicles ? 'cursor-not-allowed' : 'cursor-pointer'
|
||||
]"
|
||||
:disabled="isLoadingVehicles || filteredVehicles.length === 0"
|
||||
>
|
||||
<option value="" disabled class="text-neutral-400">Sélectionner</option>
|
||||
<option
|
||||
v-for="vehicle in filteredVehicles"
|
||||
:key="vehicle.id"
|
||||
:value="String(vehicle.id)"
|
||||
class="text-black"
|
||||
>
|
||||
{{ vehicle.plate }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-center">
|
||||
@@ -30,38 +222,359 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useReceptionStore } from '~/stores/reception'
|
||||
import type { ReceptionTypeData } from '~/services/dto/reception-type-data'
|
||||
import { getReceptionTypeList } from '~/services/reception-type'
|
||||
import type { UserData } from '~/services/dto/user-data'
|
||||
import { getUsers } from '~/services/auth'
|
||||
import { useAuthStore } from '~/stores/auth'
|
||||
import type { SupplierData } from '~/services/dto/supplier-data'
|
||||
import { getSupplierList } from '~/services/supplier'
|
||||
import type { TruckData } from '~/services/dto/truck-data'
|
||||
import { getTruckList } from '~/services/truck'
|
||||
import type { CarrierData } from '~/services/dto/carrier-data'
|
||||
import { getCarrierList } from '~/services/carrier'
|
||||
import type { DriverData } from '~/services/dto/driver-data'
|
||||
import { getDriverList } from '~/services/driver'
|
||||
import type { VehicleData } from '~/services/dto/vehicle-data'
|
||||
import { getVehicleList } from '~/services/vehicle'
|
||||
|
||||
type ReceptionFormData = {
|
||||
licensePlate: string
|
||||
receptionDate: string
|
||||
receptionTypeId: string
|
||||
userId: string
|
||||
supplierId: string
|
||||
addressId: string
|
||||
truckId: string
|
||||
carrierId: string
|
||||
driverId: string
|
||||
vehicleId: string
|
||||
}
|
||||
|
||||
const router = useRouter()
|
||||
const receptionStore = useReceptionStore()
|
||||
const form = reactive<ReceptionFormData>({
|
||||
licensePlate: '',
|
||||
receptionDate: new Date().toISOString().slice(0, 10)
|
||||
receptionDate: new Date().toISOString().slice(0, 10),
|
||||
receptionTypeId: '',
|
||||
userId: '',
|
||||
supplierId: '',
|
||||
addressId: '',
|
||||
truckId: '',
|
||||
carrierId: '',
|
||||
driverId: '',
|
||||
vehicleId: ''
|
||||
})
|
||||
const allowAnyLicensePlate = ref(false)
|
||||
const receptionTypes = ref<ReceptionTypeData[]>([])
|
||||
const users = ref<UserData[]>([])
|
||||
const isLoadingUsers = ref(false)
|
||||
const suppliers = ref<SupplierData[]>([])
|
||||
const isLoadingSuppliers = ref(false)
|
||||
const trucks = ref<TruckData[]>([])
|
||||
const isLoadingTrucks = ref(false)
|
||||
const carriers = ref<CarrierData[]>([])
|
||||
const isLoadingCarriers = ref(false)
|
||||
const drivers = ref<DriverData[]>([])
|
||||
const isLoadingDrivers = ref(false)
|
||||
const vehicles = ref<VehicleData[]>([])
|
||||
const isLoadingVehicles = ref(false)
|
||||
const authStore = useAuthStore()
|
||||
const isHydrating = ref(false)
|
||||
const liotCode = 'LIOT'
|
||||
const selectedCarrier = computed(() =>
|
||||
carriers.value.find((carrier) => String(carrier.id) === form.carrierId) ?? null
|
||||
)
|
||||
const isLiotCarrier = computed(() => selectedCarrier.value?.code === liotCode)
|
||||
const supplierAddresses = computed(() => {
|
||||
const supplierId = Number(form.supplierId)
|
||||
if (!Number.isFinite(supplierId)) {
|
||||
return []
|
||||
}
|
||||
return suppliers.value.find((supplier) => supplier.id === supplierId)?.addresses ?? []
|
||||
})
|
||||
const filteredDrivers = computed(() => {
|
||||
if (!form.carrierId) {
|
||||
return []
|
||||
}
|
||||
return drivers.value.filter((driver) => String(driver.carrier?.id) === form.carrierId)
|
||||
})
|
||||
const filteredVehicles = computed(() => {
|
||||
if (!form.carrierId) {
|
||||
return []
|
||||
}
|
||||
return vehicles.value.filter(
|
||||
(vehicle) =>
|
||||
String(vehicle.carrier?.id) === form.carrierId &&
|
||||
(!form.truckId || String(vehicle.truck?.id) === form.truckId)
|
||||
)
|
||||
})
|
||||
|
||||
watch(
|
||||
() => receptionStore.current,
|
||||
(reception) => {
|
||||
isHydrating.value = true
|
||||
form.licensePlate = reception?.licensePlate ?? ''
|
||||
form.receptionDate = reception?.receptionDate ?? new Date().toISOString().slice(0, 10)
|
||||
form.receptionTypeId = reception?.receptionType?.id
|
||||
? String(reception.receptionType.id)
|
||||
: ''
|
||||
form.userId = reception?.user?.id
|
||||
? String(reception.user.id)
|
||||
: form.userId
|
||||
form.supplierId = reception?.supplier?.id
|
||||
? String(reception.supplier.id)
|
||||
: ''
|
||||
form.addressId = reception?.address?.id
|
||||
? String(reception.address.id)
|
||||
: ''
|
||||
form.truckId = reception?.truck?.id
|
||||
? String(reception.truck.id)
|
||||
: ''
|
||||
form.carrierId = reception?.carrier?.id
|
||||
? String(reception.carrier.id)
|
||||
: ''
|
||||
form.driverId = reception?.driver?.id
|
||||
? String(reception.driver.id)
|
||||
: ''
|
||||
isHydrating.value = false
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const loadUsers = async () => {
|
||||
isLoadingUsers.value = true
|
||||
try {
|
||||
users.value = await getUsers()
|
||||
} finally {
|
||||
isLoadingUsers.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadSuppliers = async () => {
|
||||
isLoadingSuppliers.value = true
|
||||
try {
|
||||
suppliers.value = await getSupplierList()
|
||||
} finally {
|
||||
isLoadingSuppliers.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadTrucks = async () => {
|
||||
isLoadingTrucks.value = true
|
||||
try {
|
||||
trucks.value = await getTruckList()
|
||||
} finally {
|
||||
isLoadingTrucks.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadCarriers = async () => {
|
||||
isLoadingCarriers.value = true
|
||||
try {
|
||||
carriers.value = await getCarrierList()
|
||||
} finally {
|
||||
isLoadingCarriers.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadDrivers = async () => {
|
||||
isLoadingDrivers.value = true
|
||||
try {
|
||||
drivers.value = await getDriverList()
|
||||
} finally {
|
||||
isLoadingDrivers.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadVehicles = async () => {
|
||||
isLoadingVehicles.value = true
|
||||
try {
|
||||
vehicles.value = await getVehicleList()
|
||||
} finally {
|
||||
isLoadingVehicles.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const setDefaultUser = () => {
|
||||
if (form.userId) {
|
||||
return
|
||||
}
|
||||
if (authStore.user?.id) {
|
||||
form.userId = String(authStore.user.id)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
receptionTypes.value = await getReceptionTypeList()
|
||||
await loadUsers()
|
||||
await loadSuppliers()
|
||||
await loadTrucks()
|
||||
await loadCarriers()
|
||||
await loadDrivers()
|
||||
await loadVehicles()
|
||||
await authStore.ensureSession()
|
||||
setDefaultUser()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => [form.supplierId, suppliers.value],
|
||||
() => {
|
||||
if (!form.supplierId) {
|
||||
form.addressId = ''
|
||||
return
|
||||
}
|
||||
if (!form.addressId && supplierAddresses.value.length === 1) {
|
||||
form.addressId = String(supplierAddresses.value[0].id)
|
||||
return
|
||||
}
|
||||
if (!form.addressId) {
|
||||
return
|
||||
}
|
||||
const matches = supplierAddresses.value.some(
|
||||
(address) => String(address.id) === form.addressId
|
||||
)
|
||||
if (!matches) {
|
||||
form.addressId = ''
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => form.carrierId,
|
||||
() => {
|
||||
if (isHydrating.value) {
|
||||
return
|
||||
}
|
||||
if (!form.carrierId) {
|
||||
form.driverId = ''
|
||||
form.vehicleId = ''
|
||||
return
|
||||
}
|
||||
if (!isLiotCarrier.value) {
|
||||
form.driverId = ''
|
||||
form.vehicleId = ''
|
||||
return
|
||||
}
|
||||
if (filteredDrivers.value.length === 1) {
|
||||
form.driverId = String(filteredDrivers.value[0].id)
|
||||
}
|
||||
if (filteredVehicles.value.length === 1) {
|
||||
form.vehicleId = String(filteredVehicles.value[0].id)
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => [form.truckId, form.carrierId, vehicles.value],
|
||||
() => {
|
||||
if (!isLiotCarrier.value) {
|
||||
return
|
||||
}
|
||||
if (filteredVehicles.value.length === 1) {
|
||||
form.vehicleId = String(filteredVehicles.value[0].id)
|
||||
return
|
||||
}
|
||||
if (!form.vehicleId) {
|
||||
return
|
||||
}
|
||||
const matches = filteredVehicles.value.some(
|
||||
(vehicle) => String(vehicle.id) === form.vehicleId
|
||||
)
|
||||
if (!matches) {
|
||||
form.vehicleId = ''
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => [form.vehicleId, form.carrierId, vehicles.value],
|
||||
() => {
|
||||
if (!isLiotCarrier.value) {
|
||||
return
|
||||
}
|
||||
const selected = filteredVehicles.value.find(
|
||||
(vehicle) => String(vehicle.id) === form.vehicleId
|
||||
)
|
||||
if (selected) {
|
||||
form.licensePlate = selected.plate
|
||||
allowAnyLicensePlate.value = false
|
||||
} else if (form.vehicleId === '') {
|
||||
form.licensePlate = ''
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => [form.licensePlate, form.carrierId, vehicles.value],
|
||||
() => {
|
||||
if (!isLiotCarrier.value || form.vehicleId) {
|
||||
return
|
||||
}
|
||||
const match = filteredVehicles.value.find(
|
||||
(vehicle) => vehicle.plate === form.licensePlate
|
||||
)
|
||||
if (match) {
|
||||
form.vehicleId = String(match.id)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
async function validate() {
|
||||
const normalizedLicensePlate = form.licensePlate.trim()
|
||||
const normalizedReceptionDate = form.receptionDate.trim()
|
||||
const normalizedReceptionTypeId = form.receptionTypeId.trim()
|
||||
const normalizedUserId = form.userId.trim()
|
||||
const normalizedSupplierId = form.supplierId.trim()
|
||||
const normalizedAddressId = form.addressId.trim()
|
||||
const normalizedTruckId = form.truckId.trim()
|
||||
const normalizedCarrierId = form.carrierId.trim()
|
||||
const normalizedDriverId = form.driverId.trim()
|
||||
const receptionTypeIri = normalizedReceptionTypeId
|
||||
? `/api/reception_types/${normalizedReceptionTypeId}`
|
||||
: null
|
||||
const userIri = normalizedUserId
|
||||
? `/api/users/${normalizedUserId}`
|
||||
: null
|
||||
const supplierIri = normalizedSupplierId
|
||||
? `/api/suppliers/${normalizedSupplierId}`
|
||||
: null
|
||||
const addressIri = normalizedAddressId
|
||||
? `/api/addresses/${normalizedAddressId}`
|
||||
: null
|
||||
const truckIri = normalizedTruckId
|
||||
? `/api/trucks/${normalizedTruckId}`
|
||||
: null
|
||||
const carrierIri = normalizedCarrierId
|
||||
? `/api/carriers/${normalizedCarrierId}`
|
||||
: null
|
||||
const driverIri = normalizedDriverId
|
||||
? `/api/drivers/${normalizedDriverId}`
|
||||
: null
|
||||
|
||||
const basePayload = {
|
||||
licensePlate: normalizedLicensePlate,
|
||||
receptionDate: normalizedReceptionDate,
|
||||
receptionType: receptionTypeIri,
|
||||
user: userIri,
|
||||
supplier: supplierIri,
|
||||
address: addressIri,
|
||||
truck: truckIri,
|
||||
carrier: carrierIri
|
||||
}
|
||||
|
||||
const payload = {
|
||||
...basePayload,
|
||||
...(isLiotCarrier.value && driverIri ? { driver: driverIri } : {})
|
||||
}
|
||||
|
||||
if (!receptionStore.current) {
|
||||
const created = await receptionStore.createReception({
|
||||
currentStep: 1,
|
||||
licensePlate: normalizedLicensePlate,
|
||||
receptionDate: normalizedReceptionDate
|
||||
...payload
|
||||
})
|
||||
if (created) {
|
||||
await router.push(`/reception/${created.id}`)
|
||||
@@ -72,8 +585,7 @@ async function validate() {
|
||||
const nextStep = receptionStore.current.currentStep + 1
|
||||
await receptionStore.updateReception(receptionStore.current.id, {
|
||||
currentStep: nextStep,
|
||||
licensePlate: normalizedLicensePlate,
|
||||
receptionDate: normalizedReceptionDate
|
||||
...payload
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
class="w-full flex flex-col items-center justify-center border border-black h-[90px] mt-12 mb-[25px] text-4xl">
|
||||
{{ displayWeight }} kg
|
||||
</div>
|
||||
<!-- <div class="grid grid-cols-2 border border-black text-center">-->
|
||||
<!-- <p class="border-r border-black py-3 text-4xl font-bold">DSD</p>-->
|
||||
<!-- <p class="py-3 text-4xl">{{ displayDsd }}</p>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="flex flex-col">
|
||||
<label :for="inputId" class="font-bold uppercase text-xl mb-4">{{ label }}</label>
|
||||
<label :for="inputId" class="font-bold uppercase text-xl mb-2">{{ label }}</label>
|
||||
<div class="flex items-end gap-8">
|
||||
<input
|
||||
:id="inputId"
|
||||
:value="modelValue"
|
||||
@@ -8,10 +9,10 @@
|
||||
type="text"
|
||||
:maxlength="maxLength"
|
||||
:placeholder="placeholderText"
|
||||
class="border-b border-black justify-self-start text-xl pb-[6px] uppercase"
|
||||
class="border-b border-black flex-1 min-w-0 text-xl uppercase h-[30px]"
|
||||
@input="handleInput"
|
||||
/>
|
||||
<label :for="checkboxId" class="mt-3 flex items-center gap-3 text-sm">
|
||||
<label :for="checkboxId" class="ml-auto flex items-center gap-3 whitespace-nowrap text-sm">
|
||||
<input
|
||||
:id="checkboxId"
|
||||
:checked="allowAny"
|
||||
@@ -22,6 +23,7 @@
|
||||
Autoriser un format libre
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
84
frontend/components/ui/stepper.vue
Normal file
84
frontend/components/ui/stepper.vue
Normal file
@@ -0,0 +1,84 @@
|
||||
<template>
|
||||
<div class="relative w-full">
|
||||
<div class="relative h-[18px] text-[16px] uppercase font-bold text-black mb-3">
|
||||
<div
|
||||
v-for="(label, index) in labels"
|
||||
:key="label"
|
||||
class="absolute top-0 whitespace-nowrap"
|
||||
:class="labelClass(index)"
|
||||
:style="positionStyle(index)"
|
||||
>
|
||||
{{ label }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="relative h-[22px]">
|
||||
<div class="absolute left-0 right-0 top-1/2 h-[2px] -translate-y-1/2 bg-black"></div>
|
||||
<div
|
||||
v-for="(_, index) in labels"
|
||||
:key="index"
|
||||
class="absolute top-1/2 h-[22px] w-[22px] -translate-y-1/2 rounded-full border border-black"
|
||||
:class="[
|
||||
dotClass(index),
|
||||
isActive(index) ? 'bg-black' : 'bg-white',
|
||||
isClickable(index) ? 'cursor-pointer' : 'cursor-not-allowed'
|
||||
]"
|
||||
:style="positionStyle(index)"
|
||||
@click="handleClick(index)"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
type Props = {
|
||||
labels: string[]
|
||||
currentStep: number
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<{
|
||||
(e: 'select', step: number): void
|
||||
}>()
|
||||
|
||||
const stepCount = computed(() => Math.max(props.labels.length, 1))
|
||||
|
||||
const positionStyle = (index: number) => {
|
||||
if (stepCount.value <= 1) {
|
||||
return { left: '0%' }
|
||||
}
|
||||
if (index === 0) {
|
||||
return { left: '0%' }
|
||||
}
|
||||
if (index === stepCount.value - 1) {
|
||||
return { right: '0%' }
|
||||
}
|
||||
const percent = (index / (stepCount.value - 1)) * 100
|
||||
return { left: `${percent}%` }
|
||||
}
|
||||
|
||||
const isMiddle = (index: number) => index > 0 && index < stepCount.value - 1
|
||||
const isLast = (index: number) => index === stepCount.value - 1
|
||||
|
||||
const dotClass = (index: number) => (isMiddle(index) ? '-translate-x-1/2' : '')
|
||||
|
||||
const labelClass = (index: number) => {
|
||||
if (isLast(index)) {
|
||||
return 'text-right'
|
||||
}
|
||||
if (isMiddle(index)) {
|
||||
return 'text-center -translate-x-1/2'
|
||||
}
|
||||
return 'text-left'
|
||||
}
|
||||
|
||||
const isActive = (index: number) => index === props.currentStep
|
||||
|
||||
const isClickable = (index: number) => index <= props.currentStep
|
||||
|
||||
const handleClick = (index: number) => {
|
||||
if (!isClickable(index)) {
|
||||
return
|
||||
}
|
||||
emit('select', index)
|
||||
}
|
||||
</script>
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {Ref} from 'vue'
|
||||
import {computed, ref} from 'vue'
|
||||
import type {ReceptionData, WeightEntryData} from '~/services/dto/reception-data'
|
||||
import type {ReceptionData, ReceptionPayload, WeightEntryData} from '~/services/dto/reception-data'
|
||||
import type {WeightData} from '~/services/dto/weight-data'
|
||||
import {getWeight} from '~/services/reception'
|
||||
import {createWeight, updateWeight} from '~/services/weight'
|
||||
@@ -10,7 +10,7 @@ export type WeighingMode = 'gross' | 'tare'
|
||||
type UseWeighingOptions = {
|
||||
mode: WeighingMode
|
||||
reception: Ref<ReceptionData | null>
|
||||
updateReception: (id: number, payload: Partial<ReceptionData>) => Promise<ReceptionData | null>
|
||||
updateReception: (id: number, payload: ReceptionPayload) => Promise<ReceptionData | null>
|
||||
loadReception?: (id: number) => Promise<ReceptionData | null>
|
||||
}
|
||||
|
||||
|
||||
13
frontend/constants/steps.ts
Normal file
13
frontend/constants/steps.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export enum StepLabel {
|
||||
Reception = 'Réception',
|
||||
GrossWeighing = 'Pesée à plein',
|
||||
Selection = 'Sélection réceptionnées',
|
||||
TareWeighing = 'Pesée à vide'
|
||||
}
|
||||
|
||||
export const RECEPTION_STEP_LABELS = [
|
||||
StepLabel.Reception,
|
||||
StepLabel.GrossWeighing,
|
||||
StepLabel.Selection,
|
||||
StepLabel.TareWeighing
|
||||
]
|
||||
@@ -14,6 +14,24 @@
|
||||
"update": "Impossible de mettre à jour la réception.",
|
||||
"weigh": "Impossible de récupérer la pesée."
|
||||
},
|
||||
"receptionType": {
|
||||
"list": "Impossible de récupérer la liste des types de réception."
|
||||
},
|
||||
"supplier": {
|
||||
"list": "Impossible de récupérer la liste des fournisseurs."
|
||||
},
|
||||
"truck": {
|
||||
"list": "Impossible de récupérer la liste des camions."
|
||||
},
|
||||
"carrier": {
|
||||
"list": "Impossible de récupérer la liste des transporteurs."
|
||||
},
|
||||
"driver": {
|
||||
"list": "Impossible de récupérer la liste des chauffeurs."
|
||||
},
|
||||
"vehicle": {
|
||||
"list": "Impossible de récupérer la liste des immatriculations."
|
||||
},
|
||||
"auth": {
|
||||
"login": "Identifiants invalides.",
|
||||
"users": "Impossible de récupérer les utilisateurs.",
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<main class="mx-auto w-full max-w-[1050px] px-6 pt-[90px] pb-0">
|
||||
<main class="mx-auto w-full max-w-[1280px] px-6 pt-[85px] pb-0">
|
||||
<slot/>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -11,7 +11,7 @@ export default defineNuxtConfig({
|
||||
'nuxt-toast',
|
||||
'@nuxtjs/i18n'
|
||||
],
|
||||
css: ['~/assets/css/toast.css'],
|
||||
css: ['~/assets/css/main.css', '~/assets/css/toast.css'],
|
||||
runtimeConfig: {
|
||||
public: {
|
||||
apiBase: process.env.NUXT_PUBLIC_API_BASE
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex justify-between h-[52px] mb-[90px]">
|
||||
<p class="self-center">Indicateur d’étapes</p>
|
||||
<div class="flex justify-between h-[52px] mb-[80px]">
|
||||
<div class="flex flex-1 mr-16">
|
||||
<UiStepper
|
||||
:labels="RECEPTION_STEP_LABELS"
|
||||
:current-step="storeReception?.currentStep ?? 0"
|
||||
@select="handleStepSelect"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex flex-col justify-center uppercase text-xl bg-black text-white h-[50px] w-[272px] text-center"
|
||||
@@ -18,6 +24,7 @@
|
||||
<script setup lang="ts">
|
||||
import {useReceptionStore} from '~/stores/reception'
|
||||
import {storeToRefs} from 'pinia'
|
||||
import {RECEPTION_STEP_LABELS} from '~/constants/steps'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -60,4 +67,19 @@ const saveAndHold = async () => {
|
||||
})
|
||||
await router.push('/')
|
||||
}
|
||||
|
||||
const handleStepSelect = async (step: number) => {
|
||||
if (!receptionStore.current) {
|
||||
return
|
||||
}
|
||||
|
||||
if (step === receptionStore.current.currentStep) {
|
||||
return
|
||||
}
|
||||
|
||||
await receptionStore.updateReception(receptionStore.current.id, {
|
||||
currentStep: step
|
||||
})
|
||||
await receptionStore.loadReception(receptionStore.current.id)
|
||||
}
|
||||
</script>
|
||||
|
||||
23
frontend/services/carrier.ts
Normal file
23
frontend/services/carrier.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { CarrierData } from '~/services/dto/carrier-data'
|
||||
|
||||
export type CarrierListResponse =
|
||||
| CarrierData[]
|
||||
| { 'hydra:member'?: CarrierData[] }
|
||||
|
||||
export async function getCarrierList(): Promise<CarrierData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<CarrierListResponse>('carriers', {}, {
|
||||
toastErrorKey: 'errors.carrier.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
23
frontend/services/driver.ts
Normal file
23
frontend/services/driver.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { DriverData } from '~/services/dto/driver-data'
|
||||
|
||||
export type DriverListResponse =
|
||||
| DriverData[]
|
||||
| { 'hydra:member'?: DriverData[] }
|
||||
|
||||
export async function getDriverList(): Promise<DriverData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<DriverListResponse>('drivers', {}, {
|
||||
toastErrorKey: 'errors.driver.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
9
frontend/services/dto/address-data.ts
Normal file
9
frontend/services/dto/address-data.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export interface AddressData {
|
||||
id: number
|
||||
label: string
|
||||
street: string
|
||||
postalCode: string
|
||||
city: string
|
||||
countryCode: string
|
||||
fullAddress?: string
|
||||
}
|
||||
5
frontend/services/dto/carrier-data.ts
Normal file
5
frontend/services/dto/carrier-data.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface CarrierData {
|
||||
id: number
|
||||
name: string
|
||||
code: string
|
||||
}
|
||||
7
frontend/services/dto/driver-data.ts
Normal file
7
frontend/services/dto/driver-data.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { CarrierData } from '~/services/dto/carrier-data'
|
||||
|
||||
export interface DriverData {
|
||||
id: number
|
||||
name: string
|
||||
carrier?: CarrierData | null
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
import type { ReceptionTypeData } from '~/services/dto/reception-type-data'
|
||||
import type { UserData } from '~/services/dto/user-data'
|
||||
import type { SupplierData } from '~/services/dto/supplier-data'
|
||||
import type { AddressData } from '~/services/dto/address-data'
|
||||
import type { TruckData } from '~/services/dto/truck-data'
|
||||
import type { CarrierData } from '~/services/dto/carrier-data'
|
||||
import type { DriverData } from '~/services/dto/driver-data'
|
||||
|
||||
export interface ReceptionData {
|
||||
id: number
|
||||
licensePlate: string | null
|
||||
@@ -5,6 +13,13 @@ export interface ReceptionData {
|
||||
receptionDate: string
|
||||
currentStep: number
|
||||
isValid: boolean
|
||||
receptionType?: ReceptionTypeData | null
|
||||
user?: UserData | null
|
||||
supplier?: SupplierData | null
|
||||
address?: AddressData | null
|
||||
truck?: TruckData | null
|
||||
carrier?: CarrierData | null
|
||||
driver?: DriverData | null
|
||||
}
|
||||
|
||||
export interface WeightEntryData {
|
||||
@@ -14,3 +29,17 @@ export interface WeightEntryData {
|
||||
weight: number | null
|
||||
weighedAt: string | null
|
||||
}
|
||||
|
||||
export type ReceptionPayload = {
|
||||
licensePlate?: string | null
|
||||
receptionDate?: string
|
||||
currentStep?: number
|
||||
isValid?: boolean
|
||||
receptionType?: string | null
|
||||
user?: string | null
|
||||
supplier?: string | null
|
||||
address?: string | null
|
||||
truck?: string | null
|
||||
carrier?: string | null
|
||||
driver?: string | null
|
||||
}
|
||||
|
||||
5
frontend/services/dto/reception-type-data.ts
Normal file
5
frontend/services/dto/reception-type-data.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface ReceptionTypeData {
|
||||
id: number
|
||||
label: string
|
||||
code: string
|
||||
}
|
||||
7
frontend/services/dto/supplier-data.ts
Normal file
7
frontend/services/dto/supplier-data.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { AddressData } from '~/services/dto/address-data'
|
||||
|
||||
export interface SupplierData {
|
||||
id: number
|
||||
name: string
|
||||
addresses?: AddressData[] | null
|
||||
}
|
||||
4
frontend/services/dto/truck-data.ts
Normal file
4
frontend/services/dto/truck-data.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export interface TruckData {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export interface UserData {
|
||||
id: number
|
||||
username: string
|
||||
}
|
||||
|
||||
9
frontend/services/dto/vehicle-data.ts
Normal file
9
frontend/services/dto/vehicle-data.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { CarrierData } from '~/services/dto/carrier-data'
|
||||
import type { TruckData } from '~/services/dto/truck-data'
|
||||
|
||||
export interface VehicleData {
|
||||
id: number
|
||||
plate: string
|
||||
carrier?: CarrierData | null
|
||||
truck?: TruckData | null
|
||||
}
|
||||
23
frontend/services/reception-type.ts
Normal file
23
frontend/services/reception-type.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { ReceptionTypeData } from '~/services/dto/reception-type-data'
|
||||
|
||||
export type ReceptionTypeListResponse =
|
||||
| ReceptionTypeData[]
|
||||
| { 'hydra:member'?: ReceptionTypeData[] }
|
||||
|
||||
export async function getReceptionTypeList(): Promise<ReceptionTypeData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<ReceptionTypeListResponse>('reception_types', {}, {
|
||||
toastErrorKey: 'errors.receptionType.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import {useApi} from '~/composables/useApi'
|
||||
import type {ReceptionData} from '~/services/dto/reception-data'
|
||||
import type {ReceptionData, ReceptionPayload} from '~/services/dto/reception-data'
|
||||
import type {WeightData} from '~/services/dto/weight-data'
|
||||
|
||||
export async function getReceptionList() {
|
||||
@@ -16,14 +16,14 @@ export async function getReception(id: number) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function createReception(payload: Partial<ReceptionData> = {}) {
|
||||
export async function createReception(payload: ReceptionPayload = {}) {
|
||||
const api = useApi()
|
||||
return api.post<ReceptionData>('receptions', payload, {
|
||||
toastErrorKey: 'errors.reception.create'
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateReception(id: number, payload: Partial<ReceptionData>) {
|
||||
export async function updateReception(id: number, payload: ReceptionPayload) {
|
||||
const api = useApi()
|
||||
return api.patch<ReceptionData>(`receptions/${id}`, payload, {
|
||||
toastErrorKey: 'errors.reception.update',
|
||||
|
||||
23
frontend/services/supplier.ts
Normal file
23
frontend/services/supplier.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { SupplierData } from '~/services/dto/supplier-data'
|
||||
|
||||
export type SupplierListResponse =
|
||||
| SupplierData[]
|
||||
| { 'hydra:member'?: SupplierData[] }
|
||||
|
||||
export async function getSupplierList(): Promise<SupplierData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<SupplierListResponse>('suppliers', {}, {
|
||||
toastErrorKey: 'errors.supplier.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
23
frontend/services/truck.ts
Normal file
23
frontend/services/truck.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { TruckData } from '~/services/dto/truck-data'
|
||||
|
||||
export type TruckListResponse =
|
||||
| TruckData[]
|
||||
| { 'hydra:member'?: TruckData[] }
|
||||
|
||||
export async function getTruckList(): Promise<TruckData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<TruckListResponse>('trucks', {}, {
|
||||
toastErrorKey: 'errors.truck.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
23
frontend/services/vehicle.ts
Normal file
23
frontend/services/vehicle.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { useApi } from '~/composables/useApi'
|
||||
import type { VehicleData } from '~/services/dto/vehicle-data'
|
||||
|
||||
export type VehicleListResponse =
|
||||
| VehicleData[]
|
||||
| { 'hydra:member'?: VehicleData[] }
|
||||
|
||||
export async function getVehicleList(): Promise<VehicleData[]> {
|
||||
const api = useApi()
|
||||
const response = await api.get<VehicleListResponse>('vehicles', {}, {
|
||||
toastErrorKey: 'errors.vehicle.list'
|
||||
})
|
||||
|
||||
if (Array.isArray(response)) {
|
||||
return response
|
||||
}
|
||||
|
||||
if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) {
|
||||
return response['hydra:member']
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import type { ReceptionData } from '~/services/dto/reception-data'
|
||||
import type { ReceptionData, ReceptionPayload } from '~/services/dto/reception-data'
|
||||
import { createReception, getReception, updateReception } from '~/services/reception'
|
||||
|
||||
const isReceptionData = (value: unknown): value is ReceptionData => {
|
||||
@@ -31,7 +31,7 @@ export const useReceptionStore = defineStore('reception', {
|
||||
this.current = result
|
||||
return result
|
||||
},
|
||||
async createReception(payload: Partial<ReceptionData> = {}) {
|
||||
async createReception(payload: ReceptionPayload = {}) {
|
||||
this.isLoading = true
|
||||
const result = await createReception(payload).finally(() => {
|
||||
this.isLoading = false
|
||||
@@ -43,7 +43,7 @@ export const useReceptionStore = defineStore('reception', {
|
||||
this.current = result
|
||||
return result
|
||||
},
|
||||
async updateReception(id: number, payload: Partial<ReceptionData>) {
|
||||
async updateReception(id: number, payload: ReceptionPayload) {
|
||||
this.isLoading = true
|
||||
const result = await updateReception(id, payload).finally(() => {
|
||||
this.isLoading = false
|
||||
|
||||
@@ -3,6 +3,9 @@ import type { Config } from 'tailwindcss'
|
||||
export default <Partial<Config>>{
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ['"Helvetica Neue"', 'Helvetica', 'Arial', 'sans-serif']
|
||||
},
|
||||
colors: {
|
||||
primary: {
|
||||
50: '#f6f9ea',
|
||||
|
||||
32
migrations/Version20260127000100.php
Normal file
32
migrations/Version20260127000100.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260127000100 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add reception types and link receptions to them';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE reception_type (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, label VARCHAR(120) NOT NULL, code VARCHAR(50) NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('ALTER TABLE reception ADD reception_type_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E37BD5B5D FOREIGN KEY (reception_type_id) REFERENCES reception_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_83DC02E37BD5B5D ON reception (reception_type_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E37BD5B5D');
|
||||
$this->addSql('DROP INDEX IDX_83DC02E37BD5B5D');
|
||||
$this->addSql('ALTER TABLE reception DROP reception_type_id');
|
||||
$this->addSql('DROP TABLE reception_type');
|
||||
}
|
||||
}
|
||||
30
migrations/Version20260127000200.php
Normal file
30
migrations/Version20260127000200.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260127000200 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Link receptions to a responsible user';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE reception ADD user_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E3A76ED395 FOREIGN KEY (user_id) REFERENCES "user" (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_83DC02E3A76ED395 ON reception (user_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E3A76ED395');
|
||||
$this->addSql('DROP INDEX IDX_83DC02E3A76ED395');
|
||||
$this->addSql('ALTER TABLE reception DROP user_id');
|
||||
}
|
||||
}
|
||||
42
migrations/Version20260127000300.php
Normal file
42
migrations/Version20260127000300.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260127000300 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add suppliers and addresses, link receptions to suppliers';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE address (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, label VARCHAR(120) NOT NULL, street VARCHAR(180) NOT NULL, postal_code VARCHAR(20) NOT NULL, city VARCHAR(120) NOT NULL, country_code VARCHAR(2) NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE TABLE supplier (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, name VARCHAR(180) NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE TABLE supplier_address (supplier_id INT NOT NULL, address_id INT NOT NULL, PRIMARY KEY(supplier_id, address_id))');
|
||||
$this->addSql('CREATE INDEX IDX_3DCE3C74F2C1D6A8 ON supplier_address (supplier_id)');
|
||||
$this->addSql('CREATE INDEX IDX_3DCE3C746F9B8A0 ON supplier_address (address_id)');
|
||||
$this->addSql('ALTER TABLE supplier_address ADD CONSTRAINT FK_3DCE3C74F2C1D6A8 FOREIGN KEY (supplier_id) REFERENCES supplier (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE supplier_address ADD CONSTRAINT FK_3DCE3C746F9B8A0 FOREIGN KEY (address_id) REFERENCES address (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE reception ADD supplier_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E32ADD6E01 FOREIGN KEY (supplier_id) REFERENCES supplier (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_83DC02E32ADD6E01 ON reception (supplier_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E32ADD6E01');
|
||||
$this->addSql('DROP INDEX IDX_83DC02E32ADD6E01');
|
||||
$this->addSql('ALTER TABLE reception DROP supplier_id');
|
||||
$this->addSql('ALTER TABLE supplier_address DROP CONSTRAINT FK_3DCE3C74F2C1D6A8');
|
||||
$this->addSql('ALTER TABLE supplier_address DROP CONSTRAINT FK_3DCE3C746F9B8A0');
|
||||
$this->addSql('DROP TABLE supplier_address');
|
||||
$this->addSql('DROP TABLE supplier');
|
||||
$this->addSql('DROP TABLE address');
|
||||
}
|
||||
}
|
||||
30
migrations/Version20260127000400.php
Normal file
30
migrations/Version20260127000400.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260127000400 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add address_id on reception';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE reception ADD address_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E3F5B7AF75 FOREIGN KEY (address_id) REFERENCES address (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_83DC02E3F5B7AF75 ON reception (address_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E3F5B7AF75');
|
||||
$this->addSql('DROP INDEX IDX_83DC02E3F5B7AF75');
|
||||
$this->addSql('ALTER TABLE reception DROP address_id');
|
||||
}
|
||||
}
|
||||
32
migrations/Version20260127000500.php
Normal file
32
migrations/Version20260127000500.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260127000500 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add trucks and link receptions to trucks';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE truck (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, name VARCHAR(180) NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('ALTER TABLE reception ADD truck_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E3F7D15B1A FOREIGN KEY (truck_id) REFERENCES truck (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE INDEX IDX_83DC02E3F7D15B1A ON reception (truck_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E3F7D15B1A');
|
||||
$this->addSql('DROP INDEX IDX_83DC02E3F7D15B1A');
|
||||
$this->addSql('ALTER TABLE reception DROP truck_id');
|
||||
$this->addSql('DROP TABLE truck');
|
||||
}
|
||||
}
|
||||
51
migrations/Version20260127000600.php
Normal file
51
migrations/Version20260127000600.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260127000600 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add carriers, drivers, vehicles and link receptions to carriers/drivers';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE carrier (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, name VARCHAR(180) NOT NULL, code VARCHAR(30) DEFAULT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE TABLE driver (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, carrier_id INT NOT NULL, name VARCHAR(180) NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_14B3BC5F4C3C5E0A ON driver (carrier_id)');
|
||||
$this->addSql('ALTER TABLE driver ADD CONSTRAINT FK_14B3BC5F4C3C5E0A FOREIGN KEY (carrier_id) REFERENCES carrier (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE TABLE vehicle (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, carrier_id INT NOT NULL, truck_id INT NOT NULL, plate VARCHAR(20) NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_1B80E4864C3C5E0A ON vehicle (carrier_id)');
|
||||
$this->addSql('CREATE INDEX IDX_1B80E4868BEBB4B ON vehicle (truck_id)');
|
||||
$this->addSql('ALTER TABLE vehicle ADD CONSTRAINT FK_1B80E4864C3C5E0A FOREIGN KEY (carrier_id) REFERENCES carrier (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE vehicle ADD CONSTRAINT FK_1B80E4868BEBB4B FOREIGN KEY (truck_id) REFERENCES truck (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE reception ADD carrier_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE reception ADD driver_id INT DEFAULT NULL');
|
||||
$this->addSql('CREATE INDEX IDX_83DC02E34C3C5E0A ON reception (carrier_id)');
|
||||
$this->addSql('CREATE INDEX IDX_83DC02E3F24C741B ON reception (driver_id)');
|
||||
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E34C3C5E0A FOREIGN KEY (carrier_id) REFERENCES carrier (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE reception ADD CONSTRAINT FK_83DC02E3F24C741B FOREIGN KEY (driver_id) REFERENCES driver (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E34C3C5E0A');
|
||||
$this->addSql('ALTER TABLE reception DROP CONSTRAINT FK_83DC02E3F24C741B');
|
||||
$this->addSql('DROP INDEX IDX_83DC02E34C3C5E0A');
|
||||
$this->addSql('DROP INDEX IDX_83DC02E3F24C741B');
|
||||
$this->addSql('ALTER TABLE reception DROP carrier_id');
|
||||
$this->addSql('ALTER TABLE reception DROP driver_id');
|
||||
$this->addSql('ALTER TABLE vehicle DROP CONSTRAINT FK_1B80E4864C3C5E0A');
|
||||
$this->addSql('ALTER TABLE vehicle DROP CONSTRAINT FK_1B80E4868BEBB4B');
|
||||
$this->addSql('DROP TABLE vehicle');
|
||||
$this->addSql('ALTER TABLE driver DROP CONSTRAINT FK_14B3BC5F4C3C5E0A');
|
||||
$this->addSql('DROP TABLE driver');
|
||||
$this->addSql('DROP TABLE carrier');
|
||||
}
|
||||
}
|
||||
26
migrations/Version20260127000700.php
Normal file
26
migrations/Version20260127000700.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260127000700 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Allow null carrier code';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE carrier ALTER code DROP NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE carrier ALTER code SET NOT NULL');
|
||||
}
|
||||
}
|
||||
152
src/Entity/Address.php
Normal file
152
src/Entity/Address.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'address')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['address:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['address:read']],
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
class Address
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['address:read', 'supplier:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 120)]
|
||||
#[Groups(['address:read', 'supplier:read'])]
|
||||
private string $label = '';
|
||||
|
||||
#[ORM\Column(length: 180)]
|
||||
#[Groups(['address:read', 'supplier:read'])]
|
||||
private string $street = '';
|
||||
|
||||
#[ORM\Column(name: 'postal_code', length: 20)]
|
||||
#[Groups(['address:read', 'supplier:read'])]
|
||||
private string $postalCode = '';
|
||||
|
||||
#[ORM\Column(length: 120)]
|
||||
#[Groups(['address:read', 'supplier:read'])]
|
||||
private string $city = '';
|
||||
|
||||
#[ORM\Column(name: 'country_code', length: 2)]
|
||||
#[Groups(['address:read', 'supplier:read'])]
|
||||
private string $countryCode = '';
|
||||
|
||||
/**
|
||||
* @var Collection<int, Supplier>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Supplier::class, mappedBy: 'addresses')]
|
||||
private Collection $suppliers;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->suppliers = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel(string $label): self
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStreet(): string
|
||||
{
|
||||
return $this->street;
|
||||
}
|
||||
|
||||
public function setStreet(string $street): self
|
||||
{
|
||||
$this->street = $street;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPostalCode(): string
|
||||
{
|
||||
return $this->postalCode;
|
||||
}
|
||||
|
||||
public function setPostalCode(string $postalCode): self
|
||||
{
|
||||
$this->postalCode = $postalCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCity(): string
|
||||
{
|
||||
return $this->city;
|
||||
}
|
||||
|
||||
public function setCity(string $city): self
|
||||
{
|
||||
$this->city = $city;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountryCode(): string
|
||||
{
|
||||
return $this->countryCode;
|
||||
}
|
||||
|
||||
public function setCountryCode(string $countryCode): self
|
||||
{
|
||||
$this->countryCode = $countryCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Groups(['address:read', 'supplier:read', 'reception:read'])]
|
||||
public function getFullAddress(): string
|
||||
{
|
||||
$parts = array_filter([
|
||||
$this->street,
|
||||
trim(sprintf('%s %s', $this->postalCode, $this->city)),
|
||||
$this->countryCode,
|
||||
]);
|
||||
|
||||
return implode(', ', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Supplier>
|
||||
*/
|
||||
public function getSuppliers(): Collection
|
||||
{
|
||||
return $this->suppliers;
|
||||
}
|
||||
}
|
||||
71
src/Entity/Carrier.php
Normal file
71
src/Entity/Carrier.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'carrier')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['carrier:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['carrier:read']],
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
class Carrier
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 180)]
|
||||
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read'])]
|
||||
private string $name = '';
|
||||
|
||||
#[ORM\Column(length: 30, nullable: true)]
|
||||
#[Groups(['carrier:read', 'driver:read', 'vehicle:read', 'reception:read'])]
|
||||
private ?string $code = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode(): ?string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode(?string $code): self
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
74
src/Entity/Driver.php
Normal file
74
src/Entity/Driver.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'driver')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['driver:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['driver:read']],
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
class Driver
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['driver:read', 'reception:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 180)]
|
||||
#[Groups(['driver:read', 'reception:read'])]
|
||||
private string $name = '';
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['driver:read'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Carrier $carrier = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCarrier(): ?Carrier
|
||||
{
|
||||
return $this->carrier;
|
||||
}
|
||||
|
||||
public function setCarrier(?Carrier $carrier): self
|
||||
{
|
||||
$this->carrier = $carrier;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
@@ -94,6 +95,48 @@ class Reception
|
||||
#[Groups(['reception:read'])]
|
||||
private Collection $weights;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'receptions')]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?ReceptionType $receptionType = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Supplier $supplier = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Address $address = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Truck $truck = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Carrier $carrier = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['reception:read', 'reception:write'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Driver $driver = null;
|
||||
|
||||
public function __construct(
|
||||
?DateTimeImmutable $receptionDate = null,
|
||||
) {
|
||||
@@ -166,6 +209,90 @@ class Reception
|
||||
return $this->weights;
|
||||
}
|
||||
|
||||
public function getReceptionType(): ?ReceptionType
|
||||
{
|
||||
return $this->receptionType;
|
||||
}
|
||||
|
||||
public function setReceptionType(?ReceptionType $receptionType): self
|
||||
{
|
||||
$this->receptionType = $receptionType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): self
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSupplier(): ?Supplier
|
||||
{
|
||||
return $this->supplier;
|
||||
}
|
||||
|
||||
public function setSupplier(?Supplier $supplier): self
|
||||
{
|
||||
$this->supplier = $supplier;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAddress(): ?Address
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
public function setAddress(?Address $address): self
|
||||
{
|
||||
$this->address = $address;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTruck(): ?Truck
|
||||
{
|
||||
return $this->truck;
|
||||
}
|
||||
|
||||
public function setTruck(?Truck $truck): self
|
||||
{
|
||||
$this->truck = $truck;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCarrier(): ?Carrier
|
||||
{
|
||||
return $this->carrier;
|
||||
}
|
||||
|
||||
public function setCarrier(?Carrier $carrier): self
|
||||
{
|
||||
$this->carrier = $carrier;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDriver(): ?Driver
|
||||
{
|
||||
return $this->driver;
|
||||
}
|
||||
|
||||
public function setDriver(?Driver $driver): self
|
||||
{
|
||||
$this->driver = $driver;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addWeight(Weight $weight): self
|
||||
{
|
||||
if (!$this->weights->contains($weight)) {
|
||||
|
||||
92
src/Entity/ReceptionType.php
Normal file
92
src/Entity/ReceptionType.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'reception_type')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['reception-type:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['reception-type:read']],
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
class ReceptionType
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['reception:read', 'reception-type:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(name: 'label', length: 120)]
|
||||
#[Groups(['reception:read', 'reception-type:read'])]
|
||||
private string $label = '';
|
||||
|
||||
#[ORM\Column(length: 50)]
|
||||
#[Groups(['reception:read', 'reception-type:read'])]
|
||||
private string $code = '';
|
||||
|
||||
/**
|
||||
* @var Collection<int, Reception>
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'receptionType', targetEntity: Reception::class)]
|
||||
private Collection $receptions;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->receptions = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel(string $label): self
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode(string $code): self
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Reception>
|
||||
*/
|
||||
public function getReceptions(): Collection
|
||||
{
|
||||
return $this->receptions;
|
||||
}
|
||||
}
|
||||
80
src/Entity/Supplier.php
Normal file
80
src/Entity/Supplier.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'supplier')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['supplier:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['supplier:read']],
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
class Supplier
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['supplier:read', 'reception:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 180)]
|
||||
#[Groups(['supplier:read', 'reception:read'])]
|
||||
private string $name = '';
|
||||
|
||||
/**
|
||||
* @var Collection<int, Address>
|
||||
*/
|
||||
#[ORM\ManyToMany(targetEntity: Address::class, inversedBy: 'suppliers')]
|
||||
#[ORM\JoinTable(name: 'supplier_address')]
|
||||
#[Groups(['supplier:read'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private Collection $addresses;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->addresses = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Address>
|
||||
*/
|
||||
public function getAddresses(): Collection
|
||||
{
|
||||
return $this->addresses;
|
||||
}
|
||||
}
|
||||
55
src/Entity/Truck.php
Normal file
55
src/Entity/Truck.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'truck')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['truck:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['truck:read']],
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
class Truck
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['truck:read', 'vehicle:read', 'reception:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 180)]
|
||||
#[Groups(['truck:read', 'vehicle:read', 'reception:read'])]
|
||||
private string $name = '';
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,11 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
security: "is_granted('ROLE_USER')",
|
||||
provider: MeProvider::class
|
||||
),
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['user:read']],
|
||||
security: "is_granted('ROLE_USER')"
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['user:read']],
|
||||
security: "is_granted('PUBLIC_ACCESS')"
|
||||
@@ -36,10 +41,11 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
#[Groups(['user:read', 'reception:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 180, unique: true)]
|
||||
#[Groups(['user:read'])]
|
||||
#[Groups(['user:read', 'reception:read'])]
|
||||
private string $username = '';
|
||||
|
||||
#[ORM\Column(type: 'json')]
|
||||
|
||||
92
src/Entity/Vehicle.php
Normal file
92
src/Entity/Vehicle.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'vehicle')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
requirements: ['id' => '\d+'],
|
||||
normalizationContext: ['groups' => ['vehicle:read']],
|
||||
),
|
||||
new GetCollection(
|
||||
normalizationContext: ['groups' => ['vehicle:read']],
|
||||
),
|
||||
],
|
||||
security: "is_granted('ROLE_USER')",
|
||||
)]
|
||||
class Vehicle
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
#[Groups(['vehicle:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 20)]
|
||||
#[Groups(['vehicle:read'])]
|
||||
private string $plate = '';
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['vehicle:read'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Carrier $carrier = null;
|
||||
|
||||
#[ORM\ManyToOne]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['vehicle:read'])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
private ?Truck $truck = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getPlate(): string
|
||||
{
|
||||
return $this->plate;
|
||||
}
|
||||
|
||||
public function setPlate(string $plate): self
|
||||
{
|
||||
$this->plate = $plate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCarrier(): ?Carrier
|
||||
{
|
||||
return $this->carrier;
|
||||
}
|
||||
|
||||
public function setCarrier(?Carrier $carrier): self
|
||||
{
|
||||
$this->carrier = $carrier;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTruck(): ?Truck
|
||||
{
|
||||
return $this->truck;
|
||||
}
|
||||
|
||||
public function setTruck(?Truck $truck): self
|
||||
{
|
||||
$this->truck = $truck;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user