Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4845230429 | ||
| 0b0ca60af7 | |||
|
|
fe6a0e8fc9 | ||
| c10c774ac8 | |||
| 4b847eb1a2 |
2
.env
2
.env
@@ -46,4 +46,6 @@ JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
|
|||||||
JWT_PASSPHRASE=9efb9a2ec48439c723621d0c6393d04da5516c8fa00ecdba1660717b4f996867
|
JWT_PASSPHRASE=9efb9a2ec48439c723621d0c6393d04da5516c8fa00ecdba1660717b4f996867
|
||||||
JWT_COOKIE_SECURE=0
|
JWT_COOKIE_SECURE=0
|
||||||
JWT_COOKIE_SAMESITE=lax
|
JWT_COOKIE_SAMESITE=lax
|
||||||
|
JWT_TOKEN_TTL=86400
|
||||||
|
JWT_COOKIE_TTL=86400
|
||||||
###< lexik/jwt-authentication-bundle ###
|
###< lexik/jwt-authentication-bundle ###
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ lexik_jwt_authentication:
|
|||||||
secret_key: '%env(resolve:JWT_SECRET_KEY)%'
|
secret_key: '%env(resolve:JWT_SECRET_KEY)%'
|
||||||
public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
|
public_key: '%env(resolve:JWT_PUBLIC_KEY)%'
|
||||||
pass_phrase: '%env(JWT_PASSPHRASE)%'
|
pass_phrase: '%env(JWT_PASSPHRASE)%'
|
||||||
|
token_ttl: '%env(int:JWT_TOKEN_TTL)%'
|
||||||
remove_token_from_body_when_cookies_used: true
|
remove_token_from_body_when_cookies_used: true
|
||||||
token_extractors:
|
token_extractors:
|
||||||
authorization_header:
|
authorization_header:
|
||||||
@@ -13,7 +14,7 @@ lexik_jwt_authentication:
|
|||||||
enabled: false
|
enabled: false
|
||||||
set_cookies:
|
set_cookies:
|
||||||
BEARER:
|
BEARER:
|
||||||
lifetime: 86400
|
lifetime: '%env(int:JWT_COOKIE_TTL)%'
|
||||||
samesite: lax
|
samesite: lax
|
||||||
path: /
|
path: /
|
||||||
secure: '%env(bool:JWT_COOKIE_SECURE)%'
|
secure: '%env(bool:JWT_COOKIE_SECURE)%'
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
parameters:
|
parameters:
|
||||||
app.version: '0.1.4'
|
app.version: '0.1.6'
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="max-h-[80vh] overflow-auto rounded-lg border border-neutral-200 bg-white">
|
<div class="h-full min-h-0 overflow-auto rounded-lg border border-neutral-200 bg-white">
|
||||||
<div class="min-w-[900px]">
|
<div class="min-w-[900px]">
|
||||||
<div class="grid" :style="gridStyle">
|
<div class="grid" :style="gridStyle">
|
||||||
<div
|
<div
|
||||||
class="sticky left-0 z-20 border-b border-neutral-200 bg-tertiary-500 px-4 py-3 text-md font-semibold text-neutral-700"
|
class="sticky left-0 top-0 z-30 border-b border-neutral-200 bg-tertiary-500 px-4 py-3 text-md font-semibold text-neutral-700"
|
||||||
>
|
>
|
||||||
Employés
|
Employés
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-for="day in daysInMonth"
|
v-for="day in daysInMonth"
|
||||||
:key="day.date"
|
:key="day.date"
|
||||||
class="border-b border-neutral-200 bg-tertiary-500 px-2 py-3 text-center text-xs font-semibold text-neutral-700"
|
class="sticky top-0 z-20 border-b border-neutral-200 bg-tertiary-500 px-2 py-3 text-center text-xs font-semibold text-neutral-700"
|
||||||
>
|
>
|
||||||
<div>{{ day.label }}</div>
|
<div>{{ day.label }}</div>
|
||||||
<div class="text-[10px] text-neutral-500">{{ day.weekday }}</div>
|
<div class="text-[10px] text-neutral-500">{{ day.weekday }}</div>
|
||||||
@@ -18,8 +18,12 @@
|
|||||||
|
|
||||||
<template v-for="employee in visibleEmployees" :key="employee.id">
|
<template v-for="employee in visibleEmployees" :key="employee.id">
|
||||||
<div
|
<div
|
||||||
class="sticky left-0 z-10 border-b border-neutral-100 px-4 py-3 text-md font-semibold text-black"
|
class="sticky left-0 z-10 border-b border-neutral-100 px-4 py-3 text-md font-semibold text-black cursor-pointer"
|
||||||
:style="{ backgroundColor: employee.site?.color ?? '#304998' }"
|
:style="{ backgroundColor: employee.site?.color ?? '#304998' }"
|
||||||
|
draggable="true"
|
||||||
|
@dragstart="handleDragStart($event, employee)"
|
||||||
|
@dragover="handleDragOver"
|
||||||
|
@drop="handleDrop($event, employee)"
|
||||||
>
|
>
|
||||||
{{ formatEmployeeName(employee) }}
|
{{ formatEmployeeName(employee) }}
|
||||||
</div>
|
</div>
|
||||||
@@ -97,9 +101,27 @@ defineProps<{
|
|||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(event: 'cell-click', employee: Employee, date: string): void
|
(event: 'cell-click', employee: Employee, date: string): void
|
||||||
|
(event: 'reorder', payload: { dragId: number; dropId: number }): void
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const handleCellClick = (employee: Employee, date: string) => {
|
const handleCellClick = (employee: Employee, date: string) => {
|
||||||
emit('cell-click', employee, date)
|
emit('cell-click', employee, date)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleDragStart = (event: DragEvent, employee: Employee) => {
|
||||||
|
if (!event.dataTransfer) return
|
||||||
|
event.dataTransfer.effectAllowed = 'move'
|
||||||
|
event.dataTransfer.setData('text/plain', String(employee.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDragOver = (event: DragEvent) => {
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDrop = (event: DragEvent, employee: Employee) => {
|
||||||
|
event.preventDefault()
|
||||||
|
const dragId = Number(event.dataTransfer?.getData('text/plain'))
|
||||||
|
if (!dragId || dragId === employee.id) return
|
||||||
|
emit('reorder', { dragId, dropId: employee.id })
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,68 +1,81 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="h-full flex flex-col overflow-hidden">
|
||||||
<div class="flex flex-wrap items-center justify-between gap-4">
|
<div class="flex flex-wrap items-center justify-between gap-4">
|
||||||
<h1 class="text-4xl font-bold text-primary-500">Calendrier des absences</h1>
|
<h1 class="text-4xl font-bold text-primary-500">Calendrier des absences</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center justify-between py-6">
|
<div class="py-6">
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex items-center justify-between gap-4">
|
||||||
<div class="flex flex-wrap items-center gap-4 rounded-md border border-neutral-300 px-3 py-2">
|
<div class="flex items-center gap-4">
|
||||||
<div v-for="site in sites" :key="site.id" class="flex items-center gap-2">
|
<div class="flex flex-wrap items-center gap-4 rounded-md border border-neutral-300 px-3 py-2">
|
||||||
<div :style="{ backgroundColor: site.color }" class="h-4 w-4 rounded"></div>
|
<div v-for="site in sites" :key="site.id" class="flex items-center gap-2">
|
||||||
<label class="text-md" :for="`site-${site.id}`">{{ site.name }}</label>
|
<div :style="{ backgroundColor: site.color }" class="h-4 w-4 rounded"></div>
|
||||||
<input
|
<label class="text-md" :for="`site-${site.id}`">{{ site.name }}</label>
|
||||||
:id="`site-${site.id}`"
|
<input
|
||||||
v-model="selectedSiteIds"
|
:id="`site-${site.id}`"
|
||||||
:value="site.id"
|
v-model="selectedSiteIds"
|
||||||
type="checkbox"
|
:value="site.id"
|
||||||
class="h-4 w-4"
|
type="checkbox"
|
||||||
/>
|
class="h-4 w-4"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<select
|
||||||
|
v-model="selectedMonth"
|
||||||
|
class="h-10 rounded-md border border-neutral-300 bg-white px-3 text-md text-neutral-900"
|
||||||
|
>
|
||||||
|
<option v-for="month in months" :key="month.value" :value="month.value">
|
||||||
|
{{ month.label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<select
|
||||||
|
v-model="selectedYear"
|
||||||
|
class="h-10 rounded-md border border-neutral-300 bg-white px-3 text-md text-neutral-900"
|
||||||
|
>
|
||||||
|
<option v-for="year in years" :key="year" :value="year">
|
||||||
|
{{ year }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="flex gap-4">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="h-10 rounded-lg bg-primary-500 px-4 text-md font-semibold text-white hover:bg-secondary-500"
|
||||||
|
@click="openCreateFromToday"
|
||||||
|
>
|
||||||
|
Ajouter une absence
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="h-10 rounded-lg bg-primary-500 px-4 text-md font-semibold text-white hover:bg-secondary-500"
|
||||||
|
@click="openPrint"
|
||||||
|
>
|
||||||
|
Imprimer
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<select
|
|
||||||
v-model="selectedMonth"
|
|
||||||
class="h-10 rounded-md border border-neutral-300 bg-white px-3 text-md text-neutral-900"
|
|
||||||
>
|
|
||||||
<option v-for="month in months" :key="month.value" :value="month.value">
|
|
||||||
{{ month.label }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<select
|
|
||||||
v-model="selectedYear"
|
|
||||||
class="h-10 rounded-md border border-neutral-300 bg-white px-3 text-md text-neutral-900"
|
|
||||||
>
|
|
||||||
<option v-for="year in years" :key="year" :value="year">
|
|
||||||
{{ year }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-4">
|
<div class="mt-3 flex items-center gap-4">
|
||||||
<button
|
<input
|
||||||
type="button"
|
v-model="employeeFilter"
|
||||||
class="h-10 rounded-lg bg-primary-500 px-4 text-md font-semibold text-white hover:bg-secondary-500"
|
type="text"
|
||||||
@click="openCreateFromToday"
|
placeholder="Chercher un employé (nom ou prénom)"
|
||||||
>
|
class="h-10 w-full max-w-md rounded-md border border-neutral-300 bg-white px-3 text-md text-neutral-900"
|
||||||
Ajouter une absence
|
/>
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="h-10 rounded-lg bg-primary-500 px-4 text-md font-semibold text-white hover:bg-secondary-500"
|
|
||||||
@click="openPrint"
|
|
||||||
>
|
|
||||||
Imprimer
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CalendarGrid
|
<div class="flex-1 min-h-0">
|
||||||
:days-in-month="daysInMonth"
|
<CalendarGrid
|
||||||
:visible-employees="visibleEmployees"
|
:days-in-month="daysInMonth"
|
||||||
:grid-style="gridStyle"
|
:visible-employees="visibleEmployees"
|
||||||
:get-cell-style="getCellStyle"
|
:grid-style="gridStyle"
|
||||||
:get-cell-info="getCellInfo"
|
:get-cell-style="getCellStyle"
|
||||||
:format-employee-name="formatEmployeeName"
|
:get-cell-info="getCellInfo"
|
||||||
:is-holiday-date="isHolidayDate"
|
:format-employee-name="formatEmployeeName"
|
||||||
@cell-click="openCreate"
|
:is-holiday-date="isHolidayDate"
|
||||||
/>
|
@cell-click="openCreate"
|
||||||
|
@reorder="handleReorder"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<AbsenceFormDrawer
|
<AbsenceFormDrawer
|
||||||
v-model="isDrawerOpen"
|
v-model="isDrawerOpen"
|
||||||
@@ -92,7 +105,7 @@ import type {AbsenceType} from '~/services/dto/absence-type'
|
|||||||
import type {Absence} from '~/services/dto/absence'
|
import type {Absence} from '~/services/dto/absence'
|
||||||
import type {HalfDay} from '~/services/dto/half-day'
|
import type {HalfDay} from '~/services/dto/half-day'
|
||||||
import {HALF_DAYS} from '~/services/dto/half-day'
|
import {HALF_DAYS} from '~/services/dto/half-day'
|
||||||
import {listEmployees} from '~/services/employees'
|
import {listEmployees, updateEmployeeOrder} from '~/services/employees'
|
||||||
import {listAbsenceTypes} from '~/services/absence-types'
|
import {listAbsenceTypes} from '~/services/absence-types'
|
||||||
import {createAbsence, deleteAbsence, listAbsences, updateAbsence} from '~/services/absences'
|
import {createAbsence, deleteAbsence, listAbsences, updateAbsence} from '~/services/absences'
|
||||||
import {listPublicHolidays} from '~/services/public-holidays'
|
import {listPublicHolidays} from '~/services/public-holidays'
|
||||||
@@ -129,20 +142,31 @@ const sortedEmployees = computed(() => {
|
|||||||
const siteNameA = employeeA.site?.name ?? ''
|
const siteNameA = employeeA.site?.name ?? ''
|
||||||
const siteNameB = employeeB.site?.name ?? ''
|
const siteNameB = employeeB.site?.name ?? ''
|
||||||
if (siteNameA !== siteNameB) return siteNameA.localeCompare(siteNameB, 'fr')
|
if (siteNameA !== siteNameB) return siteNameA.localeCompare(siteNameB, 'fr')
|
||||||
const lastNameA = employeeA.lastName ?? ''
|
const orderA = employeeA.displayOrder ?? 0
|
||||||
const lastNameB = employeeB.lastName ?? ''
|
const orderB = employeeB.displayOrder ?? 0
|
||||||
if (lastNameA !== lastNameB) return lastNameA.localeCompare(lastNameB, 'fr')
|
if (orderA !== orderB) return orderA - orderB
|
||||||
const firstNameA = employeeA.firstName ?? ''
|
const lastNameA = employeeA.lastName ?? ''
|
||||||
const firstNameB = employeeB.firstName ?? ''
|
const lastNameB = employeeB.lastName ?? ''
|
||||||
|
if (lastNameA !== lastNameB) return lastNameA.localeCompare(lastNameB, 'fr')
|
||||||
|
const firstNameA = employeeA.firstName ?? ''
|
||||||
|
const firstNameB = employeeB.firstName ?? ''
|
||||||
return firstNameA.localeCompare(firstNameB, 'fr')
|
return firstNameA.localeCompare(firstNameB, 'fr')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Employés visibles selon le filtre de sites.
|
// Employés visibles selon le filtre de sites.
|
||||||
|
const employeeFilter = ref('')
|
||||||
|
|
||||||
const visibleEmployees = computed(() => {
|
const visibleEmployees = computed(() => {
|
||||||
if (selectedSiteIds.value.length === 0) return []
|
if (selectedSiteIds.value.length === 0) return []
|
||||||
|
const filter = employeeFilter.value.trim().toLowerCase()
|
||||||
return sortedEmployees.value.filter((employee) => {
|
return sortedEmployees.value.filter((employee) => {
|
||||||
return employee.site?.id && selectedSiteIds.value.includes(employee.site.id)
|
const siteOk = employee.site?.id && selectedSiteIds.value.includes(employee.site.id)
|
||||||
|
if (!siteOk) return false
|
||||||
|
if (!filter) return true
|
||||||
|
const first = employee.firstName?.toLowerCase() ?? ''
|
||||||
|
const last = employee.lastName?.toLowerCase() ?? ''
|
||||||
|
return first.includes(filter) || last.includes(filter)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// Données de référence et absences du mois affiché.
|
// Données de référence et absences du mois affiché.
|
||||||
@@ -650,4 +674,46 @@ const handlePrint = async () => {
|
|||||||
await printPdf(`/absences/print?${params.toString()}`)
|
await printPdf(`/absences/print?${params.toString()}`)
|
||||||
isPrintOpen.value = false
|
isPrintOpen.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleReorder = async (payload: { dragId: number; dropId: number }) => {
|
||||||
|
const dragEmployee = employees.value.find((employee) => employee.id === payload.dragId)
|
||||||
|
const dropEmployee = employees.value.find((employee) => employee.id === payload.dropId)
|
||||||
|
if (!dragEmployee || !dropEmployee) return
|
||||||
|
const dragSiteId = dragEmployee.site?.id
|
||||||
|
const dropSiteId = dropEmployee.site?.id
|
||||||
|
if (!dragSiteId || !dropSiteId || dragSiteId !== dropSiteId) return
|
||||||
|
|
||||||
|
const siteEmployees = [...employees.value]
|
||||||
|
.filter((employee) => employee.site?.id === dragSiteId)
|
||||||
|
.sort((employeeA, employeeB) => {
|
||||||
|
const orderA = employeeA.displayOrder ?? 0
|
||||||
|
const orderB = employeeB.displayOrder ?? 0
|
||||||
|
if (orderA !== orderB) return orderA - orderB
|
||||||
|
const lastNameA = employeeA.lastName ?? ''
|
||||||
|
const lastNameB = employeeB.lastName ?? ''
|
||||||
|
if (lastNameA !== lastNameB) return lastNameA.localeCompare(lastNameB, 'fr')
|
||||||
|
const firstNameA = employeeA.firstName ?? ''
|
||||||
|
const firstNameB = employeeB.firstName ?? ''
|
||||||
|
return firstNameA.localeCompare(firstNameB, 'fr')
|
||||||
|
})
|
||||||
|
|
||||||
|
const fromIndex = siteEmployees.findIndex((employee) => employee.id === dragEmployee.id)
|
||||||
|
const toIndex = siteEmployees.findIndex((employee) => employee.id === dropEmployee.id)
|
||||||
|
if (fromIndex < 0 || toIndex < 0 || fromIndex === toIndex) return
|
||||||
|
|
||||||
|
const [moved] = siteEmployees.splice(fromIndex, 1)
|
||||||
|
siteEmployees.splice(toIndex, 0, moved)
|
||||||
|
|
||||||
|
const updates: Array<{ id: number; displayOrder: number }> = []
|
||||||
|
siteEmployees.forEach((employee, index) => {
|
||||||
|
const nextOrder = index + 1
|
||||||
|
if ((employee.displayOrder ?? 0) !== nextOrder) {
|
||||||
|
updates.push({ id: employee.id, displayOrder: nextOrder })
|
||||||
|
}
|
||||||
|
employee.displayOrder = nextOrder
|
||||||
|
})
|
||||||
|
|
||||||
|
if (updates.length === 0) return
|
||||||
|
await Promise.all(updates.map((update) => updateEmployeeOrder(update.id, update.displayOrder)))
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ export type Employee = {
|
|||||||
firstName: string
|
firstName: string
|
||||||
lastName: string
|
lastName: string
|
||||||
site: Site
|
site: Site
|
||||||
|
displayOrder?: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,19 +33,33 @@ export const updateEmployee = async (
|
|||||||
firstName: string
|
firstName: string
|
||||||
lastName: string
|
lastName: string
|
||||||
siteId?: number | null
|
siteId?: number | null
|
||||||
|
displayOrder?: number
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
return api.patch<Employee>(`/employees/${id}`, {
|
return api.patch<Employee>(`/employees/${id}`, {
|
||||||
firstName: payload.firstName,
|
firstName: payload.firstName,
|
||||||
lastName: payload.lastName,
|
lastName: payload.lastName,
|
||||||
site: payload.siteId ? `/api/sites/${payload.siteId}` : null
|
site: payload.siteId ? `/api/sites/${payload.siteId}` : null,
|
||||||
|
displayOrder: payload.displayOrder
|
||||||
}, {
|
}, {
|
||||||
toastSuccessKey: 'success.employee.update',
|
toastSuccessKey: 'success.employee.update',
|
||||||
toastErrorKey: 'errors.employee.update'
|
toastErrorKey: 'errors.employee.update'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const updateEmployeeOrder = async (
|
||||||
|
id: number,
|
||||||
|
displayOrder: number
|
||||||
|
) => {
|
||||||
|
const api = useApi()
|
||||||
|
return api.patch<Employee>(`/employees/${id}`, {
|
||||||
|
displayOrder
|
||||||
|
}, {
|
||||||
|
toast: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const deleteEmployee = async (id: number) => {
|
export const deleteEmployee = async (id: number) => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
return api.delete(`/employees/${id}`, {}, {
|
return api.delete(`/employees/${id}`, {}, {
|
||||||
|
|||||||
26
migrations/Version20260210121500.php
Normal file
26
migrations/Version20260210121500.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 Version20260210121500 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Add display_order to employees';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE employees ADD display_order INT NOT NULL DEFAULT 0');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE employees DROP COLUMN display_order');
|
||||||
|
}
|
||||||
|
}
|
||||||
39
migrations/Version20260210123000.php
Normal file
39
migrations/Version20260210123000.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class Version20260210123000 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Backfill employee display_order per site';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// Initialise display_order par site selon le tri nom/prénom/id.
|
||||||
|
$this->addSql('
|
||||||
|
UPDATE employees e
|
||||||
|
SET display_order = ranked.rn
|
||||||
|
FROM (
|
||||||
|
SELECT id,
|
||||||
|
ROW_NUMBER() OVER (
|
||||||
|
PARTITION BY site_id
|
||||||
|
ORDER BY last_name ASC, first_name ASC, id ASC
|
||||||
|
) AS rn
|
||||||
|
FROM employees
|
||||||
|
) ranked
|
||||||
|
WHERE ranked.id = e.id
|
||||||
|
');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// Pas de rollback pertinent.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,10 @@ class Employee
|
|||||||
#[Groups(['employee:read', 'employee:write'])]
|
#[Groups(['employee:read', 'employee:write'])]
|
||||||
private ?Site $site = null;
|
private ?Site $site = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'integer', options: ['default' => 0])]
|
||||||
|
#[Groups(['employee:read', 'employee:write'])]
|
||||||
|
private int $displayOrder = 0;
|
||||||
|
|
||||||
#[ORM\Column(type: 'datetime_immutable')]
|
#[ORM\Column(type: 'datetime_immutable')]
|
||||||
private DateTimeImmutable $createdAt;
|
private DateTimeImmutable $createdAt;
|
||||||
|
|
||||||
@@ -90,4 +94,16 @@ class Employee
|
|||||||
{
|
{
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDisplayOrder(): int
|
||||||
|
{
|
||||||
|
return $this->displayOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDisplayOrder(int $displayOrder): self
|
||||||
|
{
|
||||||
|
$this->displayOrder = $displayOrder;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ class AbsencePrintProvider implements ProviderInterface
|
|||||||
->leftJoin('e.site', 's')
|
->leftJoin('e.site', 's')
|
||||||
->addSelect('s')
|
->addSelect('s')
|
||||||
->orderBy('s.name', 'ASC')
|
->orderBy('s.name', 'ASC')
|
||||||
|
->addOrderBy('e.displayOrder', 'ASC')
|
||||||
->addOrderBy('e.lastName', 'ASC')
|
->addOrderBy('e.lastName', 'ASC')
|
||||||
->addOrderBy('e.firstName', 'ASC')
|
->addOrderBy('e.firstName', 'ASC')
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user