Compare commits
1 Commits
v0.1.90
...
ccd8e66dcd
| Author | SHA1 | Date | |
|---|---|---|---|
| ccd8e66dcd |
@@ -30,7 +30,6 @@
|
||||
- Contracts: `trackingMode` (TIME=hours, PRESENCE=half-days), `weeklyHours`
|
||||
- Contract types: FORFAIT, THIRTY_FIVE_HOURS, THIRTY_NINE_HOURS, INTERIM, CUSTOM
|
||||
- Contract nature (per period): CDI, CDD, INTERIM
|
||||
- **Agence d'intérim** (`InterimAgency` entity, table `interim_agencies`): optionnelle sur `EmployeeContractPeriod` quand nature = INTERIM. Pas de CRUD UI — gérée en BDD. API lecture seule `GET /interim_agencies`. Affichée "Intérim (NomAgence)" sur la liste employés et l'historique contrat.
|
||||
- Employee contract history: `employee_contract_periods`, resolved by `EmployeeContractResolver`
|
||||
- **Planning jours travaillés** (`EmployeeContractPeriod.workDaysHours` : JSON `{iso_day: minutes}`) : obligatoire pour tout contrat TIME **hors 35h/39h/INTERIM** (ex. 4h, 25h, 28h). Somme = `weeklyHours × 60`. Utilisé par `HolidayVirtualHoursResolver` (crédit férié) et `WorkedHoursCreditPolicy` (crédit absence) pour ne créditer que les jours effectivement travaillés. Validation : `EmployeeContractPeriodValidator::assertWorkDaysHours`.
|
||||
- Absences: stored per day (auto-split), AM/PM/full day, clear corresponding hour slots
|
||||
@@ -45,6 +44,12 @@
|
||||
- Saisie d'heures (ou de jours de présence) autorisée sur un férié
|
||||
- **Crédit automatique des heures contractuelles** sur un férié Lun-Ven pour tout contrat hors Forfait, **uniquement en l'absence d'absence déclarée** : le total journalier = `max(saisie + credited_absence, référence_contractuelle)`. Référence : 35h→7h, 39h→8h Lun-Jeu/7h Ven, CUSTOM→weeklyHours/5, INTERIM→idem 35h/39h/custom selon weeklyHours. Aucune ligne BDD créée (crédit virtuel). Drivers : crédité en `dayHoursMinutes`. Impacte directement le total hebdo RTT (tranches 25%/50%). Dès qu'une absence est posée sur le férié, le crédit virtuel saute — c'est le `countAsWorkedHours` du type d'absence qui pilote. Services : `App\Service\WorkHours\HolidayVirtualHoursResolver` + `DailyReferenceMinutesResolver`. Doc complète : `doc/holiday-virtual-hours.md`.
|
||||
|
||||
## Commentaires de semaine
|
||||
- Entité `EmployeeWeekComment` : commentaire libre par employé et semaine ISO (unique `(employee_id, week_start_date)`). `week_start_date` = lundi.
|
||||
- CRUD `/employee_week_comments` `ROLE_ADMIN`. Write processor audite via `AuditLogger`.
|
||||
- Picto bulle vue semaine (HoursWeekView + DriverHoursWeekView) : fond bleu/rouge. Intégré dans `WeeklySummaryRow.comment/commentId`.
|
||||
- Doc : `doc/week-comments.md`.
|
||||
|
||||
## Validation Rules
|
||||
- `isValid` (RH): locks line for everyone (admin can only untoggle validation)
|
||||
- `isSiteValid` (site manager): locks for non-admin, admin can still edit
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
parameters:
|
||||
app.version: '0.1.90'
|
||||
app.version: '0.1.88'
|
||||
|
||||
@@ -130,7 +130,6 @@ Documents complementaires:
|
||||
- pas de bonus 25%
|
||||
- pas de bonus 50%
|
||||
- pas de total récup
|
||||
- agence d'intérim optionnelle (table `interim_agencies`): affichée sur la fiche employé et le détail contrat sous la forme "Intérim (NomAgence)"
|
||||
|
||||
## 6bis) Heures Conducteurs
|
||||
|
||||
@@ -167,7 +166,7 @@ Documents complementaires:
|
||||
- Onglet congés: jours fériés affichés sur le calendrier avec fond `rgb(179, 229, 252)` et nom au survol
|
||||
- Écran Heures et Heures Conducteurs (vue jour): le nom du férié est affiché dans la colonne Absence sous forme de pill (fond `#b3e5fc`, icône `mdi:calendar-star`), distinct du pill absence
|
||||
- Règle courante:
|
||||
- absences autorisées sur jour férié (création/édition depuis l'écran Heures et le Calendrier). Quand une absence est posée, le crédit virtuel férié est désactivé — c'est le `countAsWorkedHours` du type d'absence qui pilote
|
||||
- absences bloquées sur jour férié (création/édition) — bouton "Modifier" masqué comme pour les formations
|
||||
- saisie d'heures ou de jours de présence autorisée — les heures saisies comptent normalement dans le total hebdo et le calcul RTT
|
||||
- la référence hebdomadaire n'est pas réduite par un férié: un salarié qui ne saisit rien sur un férié est en déficit de la journée correspondante
|
||||
|
||||
|
||||
@@ -45,9 +45,9 @@
|
||||
<button
|
||||
type="button"
|
||||
class="relative flex h-8 w-full items-center justify-center overflow-hidden rounded-md border border-neutral-200 text-[11px] font-semibold text-neutral-800"
|
||||
:class="getCellInfo(employee.id, day.date)?.hasFormation ? 'cursor-not-allowed opacity-80' : ''"
|
||||
:class="isHolidayDate(day.date) || getCellInfo(employee.id, day.date)?.hasFormation ? 'cursor-not-allowed opacity-80' : ''"
|
||||
:style="getCellStyle(employee.id, day.date)"
|
||||
:disabled="getCellInfo(employee.id, day.date)?.hasFormation"
|
||||
:disabled="isHolidayDate(day.date) || getCellInfo(employee.id, day.date)?.hasFormation"
|
||||
@click="handleCellClick(employee, day.date)"
|
||||
>
|
||||
<span v-if="!getCellInfo(employee.id, day.date)?.halfLabel">
|
||||
@@ -80,7 +80,9 @@
|
||||
<button
|
||||
type="button"
|
||||
class="relative flex h-8 w-full items-center justify-center rounded-md border border-neutral-200 text-[11px] font-semibold text-neutral-800 bg-white"
|
||||
:class="isHolidayDate(day.date) ? 'cursor-not-allowed opacity-80' : ''"
|
||||
:style="getCellStyle(employee.id, day.date)"
|
||||
:disabled="isHolidayDate(day.date)"
|
||||
@click="handleCellClick(employee, day.date)"
|
||||
>
|
||||
<span></span>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
:style="{ gridTemplateColumns: dayGridCols }"
|
||||
>
|
||||
<span>Nom</span>
|
||||
<span class="pl-2">Statut</span>
|
||||
<span class="pl-2">Absence</span>
|
||||
<span class="pl-4">Heure de jour</span>
|
||||
<span class="pl-2">Heure de nuit</span>
|
||||
<span class="pl-2">Heure atelier</span>
|
||||
|
||||
@@ -33,8 +33,11 @@
|
||||
{{ row.firstName }} {{ row.lastName }}
|
||||
<span class="font-normal text-neutral-600">({{ row.contractName ?? '-' }})</span>
|
||||
</p>
|
||||
<p class="text-[11px] text-neutral-500 truncate">
|
||||
{{ row.siteName ?? 'Sans site' }}<span v-if="row.contractNature"> — {{ contractNatureLabel(row.contractNature) }}</span>
|
||||
<p class="text-[11px] text-neutral-500 truncate inline-flex items-center gap-2">
|
||||
<span>{{ row.siteName ?? 'Sans site' }}<span v-if="row.contractNature"> — {{ contractNatureLabel(row.contractNature) }}</span></span>
|
||||
<button v-if="isAdmin" type="button" class="inline-flex items-center justify-center rounded-md p-1 text-white transition-colors" :class="row.comment ? 'bg-red-500 hover:bg-red-600' : 'bg-primary-500 hover:bg-secondary-500'" :title="row.comment ?? 'Ajouter un commentaire'" @click="$emit('open-comment', row)">
|
||||
<Icon name="mdi:comment-text-outline" size="12"/>
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -103,9 +106,12 @@ const getDailyCellStyle = (daily: {
|
||||
|
||||
defineProps<{
|
||||
isWeekLoading: boolean
|
||||
isAdmin: boolean
|
||||
weekGridCols: string
|
||||
weeklySummary: WeeklyWorkHourSummary | null
|
||||
weekDayHeaders: Array<{ date: string; weekday: string; dayDate: string }>
|
||||
formatMinutes: (minutes: number) => string
|
||||
}>()
|
||||
|
||||
defineEmits<{ (e: 'open-comment', row: WeeklyWorkHourSummary['rows'][number]): void }>()
|
||||
</script>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
:key="`${item.startDate}-${item.endDate ?? 'open'}-${item.contractId ?? item.contractName}`"
|
||||
class="grid grid-cols-4 border-b border-primary-500 px-6 py-3 text-md font-bold text-primary-500 last:border-b-0 hover:bg-tertiary-500"
|
||||
>
|
||||
<p>{{ item.interimAgencyName ? `${contractNatureLabel(item.contractNature)} (${item.interimAgencyName})` : contractNatureLabel(item.contractNature) }}</p>
|
||||
<p>{{ contractNatureLabel(item.contractNature) }}</p>
|
||||
<p>{{ contractHistoryLabel(item) }}</p>
|
||||
<p>{{ formatDate(item.startDate) }}</p>
|
||||
<p>{{ formatDate(item.endDate) }}</p>
|
||||
@@ -221,22 +221,6 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div v-if="createContractForm.contractNature === 'INTERIM'">
|
||||
<label class="text-md font-semibold text-neutral-700" for="create-interim-agency">
|
||||
Agence d'intérim
|
||||
</label>
|
||||
<select
|
||||
id="create-interim-agency"
|
||||
v-model="createContractForm.interimAgencyId"
|
||||
class="mt-2 w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-md text-neutral-900"
|
||||
>
|
||||
<option value="">Aucune</option>
|
||||
<option v-for="agency in interimAgencies" :key="agency.id" :value="agency.id">
|
||||
{{ agency.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="text-md font-semibold text-neutral-700" for="create-contract-id">
|
||||
Temps de travail <span class="text-red-600">*</span>
|
||||
@@ -298,7 +282,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { Contract } from '~/services/dto/contract'
|
||||
import type { ContractHistoryItem } from '~/services/dto/employee'
|
||||
import type { InterimAgency } from '~/services/interim-agencies'
|
||||
import WorkDaysHoursInput from '~/components/employees/WorkDaysHoursInput.vue'
|
||||
|
||||
type SuspensionForm = {
|
||||
@@ -327,7 +310,6 @@ type CreateContractForm = {
|
||||
endDate: string
|
||||
isDriver: boolean
|
||||
workDaysHours: Record<number, number> | null
|
||||
interimAgencyId: number | ''
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -369,7 +351,6 @@ const props = defineProps<{
|
||||
onSubmitSuspension: (index: number) => void
|
||||
onAddSuspensionForm: () => void
|
||||
currentContractPeriodId?: number | null
|
||||
interimAgencies: InterimAgency[]
|
||||
}>()
|
||||
|
||||
const drawerTab = ref<'close' | 'suspend'>('close')
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
:style="{ gridTemplateColumns: dayGridCols }"
|
||||
>
|
||||
<span>Nom</span>
|
||||
<span class="pl-2">Statut</span>
|
||||
<span class="pl-2">Absence</span>
|
||||
<span class="pl-4">Début matin</span>
|
||||
<span class="pr-2">Fin matin</span>
|
||||
<span class="pl-2">Début après-midi</span>
|
||||
|
||||
@@ -29,8 +29,11 @@
|
||||
{{ row.firstName }} {{ row.lastName }}
|
||||
<span class="font-normal text-neutral-600">({{ row.contractName ?? '-' }})</span>
|
||||
</p>
|
||||
<p class="text-[11px] text-neutral-500 truncate">
|
||||
{{ row.siteName ?? 'Sans site' }}<span v-if="row.contractNature"> — {{ contractNatureLabel(row.contractNature) }}</span>
|
||||
<p class="text-[11px] text-neutral-500 truncate inline-flex items-center gap-2">
|
||||
<span>{{ row.siteName ?? 'Sans site' }}<span v-if="row.contractNature"> — {{ contractNatureLabel(row.contractNature) }}</span></span>
|
||||
<button v-if="isAdmin" type="button" class="inline-flex items-center justify-center rounded-md p-1 text-white transition-colors" :class="row.comment ? 'bg-red-500 hover:bg-red-600' : 'bg-primary-500 hover:bg-secondary-500'" :title="row.comment ?? 'Ajouter un commentaire'" @click="$emit('open-comment', row)">
|
||||
<Icon name="mdi:comment-text-outline" size="12"/>
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -99,9 +102,12 @@ const getDailyCellStyle = (daily: {
|
||||
|
||||
defineProps<{
|
||||
isWeekLoading: boolean
|
||||
isAdmin: boolean
|
||||
weekGridCols: string
|
||||
weeklySummary: WeeklyWorkHourSummary | null
|
||||
weekDayHeaders: Array<{ date: string; label: string }>
|
||||
formatMinutes: (minutes: number) => string
|
||||
}>()
|
||||
|
||||
defineEmits<{ (e: 'open-comment', row: WeeklyWorkHourSummary['rows'][number]): void }>()
|
||||
</script>
|
||||
|
||||
67
frontend/components/hours/WeekCommentDrawer.vue
Normal file
67
frontend/components/hours/WeekCommentDrawer.vue
Normal file
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<AppDrawer v-model="drawerOpen" :title="`Commentaire — ${formatWeekRange}`">
|
||||
<form class="space-y-4" @submit.prevent="onSave">
|
||||
<div v-if="employeeLabel" class="text-md font-semibold text-neutral-700">{{ employeeLabel }}</div>
|
||||
<div>
|
||||
<label class="text-md font-semibold text-neutral-700" for="week-comment-content">Commentaire</label>
|
||||
<textarea id="week-comment-content" v-model="content" rows="8" maxlength="5000" class="mt-2 w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-base text-neutral-900 focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-secondary-500/20" placeholder="Ex. Arrêt maladie lundi, reprise jeudi..." />
|
||||
<p class="mt-1 text-xs text-neutral-400">{{ content.length }} / 5000</p>
|
||||
</div>
|
||||
<div class="sticky bottom-0 -mx-[20px] bg-white px-[20px] py-3 flex justify-between gap-3">
|
||||
<button v-if="commentId" type="button" class="rounded-lg bg-red-500 px-4 py-2 text-md font-semibold text-white hover:bg-red-600 disabled:opacity-50" :disabled="isSubmitting" @click="onDelete">Supprimer</button>
|
||||
<div class="flex gap-3 ml-auto">
|
||||
<button type="button" class="rounded-lg border border-neutral-200 px-4 py-2 text-md font-semibold text-neutral-700 hover:bg-neutral-100" @click="drawerOpen = false">Annuler</button>
|
||||
<button type="submit" class="rounded-lg bg-primary-500 px-4 py-2 text-md font-semibold text-white hover:bg-secondary-500 disabled:opacity-50" :disabled="isSubmitting || !canSubmit">Enregistrer</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import AppDrawer from '~/components/AppDrawer.vue'
|
||||
import { createWeekComment, deleteWeekComment, updateWeekComment } from '~/services/employee-week-comments'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
employeeId: number | null
|
||||
weekStart: string
|
||||
weekEnd: string
|
||||
initialContent: string
|
||||
commentId: number | null
|
||||
employeeLabel?: string
|
||||
}>()
|
||||
const emit = defineEmits<{ (e: 'update:modelValue', v: boolean): void; (e: 'saved'): void }>()
|
||||
|
||||
const drawerOpen = computed({ get: () => props.modelValue, set: (v) => emit('update:modelValue', v) })
|
||||
const content = ref('')
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
watch(() => [props.modelValue, props.initialContent] as const, ([open, init]) => { if (open) content.value = init ?? '' }, { immediate: true })
|
||||
|
||||
const formatWeekRange = computed(() => {
|
||||
const fmt = (ymd: string) => { const p = ymd.split('-'); return p.length === 3 ? `${p[2]}/${p[1]}/${p[0]}` : ymd }
|
||||
return `${fmt(props.weekStart)} → ${fmt(props.weekEnd)}`
|
||||
})
|
||||
|
||||
const canSubmit = computed(() => content.value.trim().length > 0 || props.commentId !== null)
|
||||
|
||||
const onSave = async () => {
|
||||
if (!props.employeeId || isSubmitting.value) return
|
||||
const trimmed = content.value.trim()
|
||||
isSubmitting.value = true
|
||||
try {
|
||||
if (trimmed === '' && props.commentId) await deleteWeekComment(props.commentId)
|
||||
else if (trimmed !== '' && props.commentId) await updateWeekComment(props.commentId, trimmed)
|
||||
else if (trimmed !== '') await createWeekComment({ employeeId: props.employeeId, weekStartDate: props.weekStart, content: trimmed })
|
||||
emit('saved'); drawerOpen.value = false
|
||||
} finally { isSubmitting.value = false }
|
||||
}
|
||||
|
||||
const onDelete = async () => {
|
||||
if (!props.commentId || isSubmitting.value) return
|
||||
isSubmitting.value = true
|
||||
try { await deleteWeekComment(props.commentId); emit('saved'); drawerOpen.value = false } finally { isSubmitting.value = false }
|
||||
}
|
||||
</script>
|
||||
@@ -922,6 +922,15 @@ export const useDriverHoursPage = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const isWeekCommentDrawerOpen = ref(false)
|
||||
const weekCommentContext = ref<{ employeeId: number; employeeLabel: string; weekStart: string; weekEnd: string; content: string; commentId: number | null } | null>(null)
|
||||
const openWeekCommentDrawer = (row: { employeeId: number; firstName: string; lastName: string; comment?: string | null; commentId?: number | null }) => {
|
||||
if (!weeklySummary.value) return
|
||||
weekCommentContext.value = { employeeId: row.employeeId, employeeLabel: `${row.firstName} ${row.lastName}`.trim(), weekStart: weeklySummary.value.weekStart, weekEnd: weeklySummary.value.weekEnd, content: row.comment ?? '', commentId: row.commentId ?? null }
|
||||
isWeekCommentDrawerOpen.value = true
|
||||
}
|
||||
const reloadWeeklySummary = async () => { await loadWeeklySummary() }
|
||||
|
||||
return {
|
||||
isAdmin,
|
||||
isSelfUser,
|
||||
@@ -988,6 +997,10 @@ export const useDriverHoursPage = () => {
|
||||
deleteAbsenceFromDrawer,
|
||||
closeAbsenceDrawer,
|
||||
formatMinutes,
|
||||
handleSave
|
||||
handleSave,
|
||||
isWeekCommentDrawerOpen,
|
||||
weekCommentContext,
|
||||
openWeekCommentDrawer,
|
||||
reloadWeeklySummary
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import type { ContractHistoryItem, Employee } from '~/services/dto/employee'
|
||||
import { listContracts } from '~/services/contracts'
|
||||
import { updateEmployee } from '~/services/employees'
|
||||
import { createSuspension, updateSuspension } from '~/services/contractSuspensions'
|
||||
import { listInterimAgencies, type InterimAgency } from '~/services/interim-agencies'
|
||||
import { formatNullableYmdToFr, getTodayYmd, shiftYmd } from '~/utils/date'
|
||||
import { contractNatureLabel, formatWorkDaysHoursSummary, isContractNature, requiresContractEndDate, requiresWorkDaysHours, showsContractEndDate } from '~/utils/contract'
|
||||
|
||||
@@ -18,7 +17,6 @@ type SuspensionForm = {
|
||||
export const useEmployeeContract = (employee: Ref<Employee | null>, reloadEmployee: () => Promise<void>) => {
|
||||
const toast = useToast()
|
||||
const contracts = ref<Contract[]>([])
|
||||
const interimAgencies = ref<InterimAgency[]>([])
|
||||
const isContractDrawerOpen = ref(false)
|
||||
const isContractSubmitting = ref(false)
|
||||
const isCreateContractDrawerOpen = ref(false)
|
||||
@@ -48,8 +46,7 @@ export const useEmployeeContract = (employee: Ref<Employee | null>, reloadEmploy
|
||||
startDate: '',
|
||||
endDate: '',
|
||||
isDriver: false,
|
||||
workDaysHours: null as Record<number, number> | null,
|
||||
interimAgencyId: '' as number | ''
|
||||
workDaysHours: null as Record<number, number> | null
|
||||
})
|
||||
|
||||
const createValidationTouched = reactive({
|
||||
@@ -210,7 +207,6 @@ export const useEmployeeContract = (employee: Ref<Employee | null>, reloadEmploy
|
||||
createContractForm.endDate = ''
|
||||
createContractForm.isDriver = false
|
||||
createContractForm.workDaysHours = null
|
||||
createContractForm.interimAgencyId = ''
|
||||
createContractForm.startDate = editableContractPeriod.value?.endDate
|
||||
? (shiftYmd(editableContractPeriod.value.endDate, 1) ?? editableContractPeriod.value.endDate)
|
||||
: getTodayYmd()
|
||||
@@ -287,8 +283,7 @@ export const useEmployeeContract = (employee: Ref<Employee | null>, reloadEmploy
|
||||
contractStartDate: createContractForm.startDate,
|
||||
contractEndDate: createContractForm.endDate || null,
|
||||
isDriverInput: createContractForm.isDriver,
|
||||
workDaysHoursInput: requiresCreateWorkDaysHours.value ? createContractForm.workDaysHours : null,
|
||||
interimAgencyId: createContractForm.contractNature === 'INTERIM' && createContractForm.interimAgencyId !== '' ? Number(createContractForm.interimAgencyId) : null
|
||||
workDaysHoursInput: requiresCreateWorkDaysHours.value ? createContractForm.workDaysHours : null
|
||||
})
|
||||
isCreateContractDrawerOpen.value = false
|
||||
await reloadEmployee()
|
||||
@@ -340,16 +335,6 @@ export const useEmployeeContract = (employee: Ref<Employee | null>, reloadEmploy
|
||||
contracts.value = await listContracts()
|
||||
}
|
||||
|
||||
const loadInterimAgencies = async () => {
|
||||
interimAgencies.value = await listInterimAgencies()
|
||||
}
|
||||
|
||||
watch(() => createContractForm.contractNature, (nature) => {
|
||||
if (nature !== 'INTERIM') {
|
||||
createContractForm.interimAgencyId = ''
|
||||
}
|
||||
})
|
||||
|
||||
watch(showsCreateContractEndDate, (shows) => {
|
||||
if (!shows) {
|
||||
createContractForm.endDate = ''
|
||||
@@ -401,8 +386,6 @@ export const useEmployeeContract = (employee: Ref<Employee | null>, reloadEmploy
|
||||
submitSuspension,
|
||||
addSuspensionForm,
|
||||
currentActiveContractPeriodId,
|
||||
interimAgencies,
|
||||
loadContracts,
|
||||
loadInterimAgencies
|
||||
loadContracts
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ export const useEmployeeDetailPage = () => {
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
await Promise.all([contract.loadContracts(), contract.loadInterimAgencies()])
|
||||
await contract.loadContracts()
|
||||
await loadEmployee()
|
||||
})
|
||||
|
||||
|
||||
@@ -1108,6 +1108,15 @@ export const useHoursPage = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const isWeekCommentDrawerOpen = ref(false)
|
||||
const weekCommentContext = ref<{ employeeId: number; employeeLabel: string; weekStart: string; weekEnd: string; content: string; commentId: number | null } | null>(null)
|
||||
const openWeekCommentDrawer = (row: { employeeId: number; firstName: string; lastName: string; comment?: string | null; commentId?: number | null }) => {
|
||||
if (!weeklySummary.value) return
|
||||
weekCommentContext.value = { employeeId: row.employeeId, employeeLabel: `${row.firstName} ${row.lastName}`.trim(), weekStart: weeklySummary.value.weekStart, weekEnd: weeklySummary.value.weekEnd, content: row.comment ?? '', commentId: row.commentId ?? null }
|
||||
isWeekCommentDrawerOpen.value = true
|
||||
}
|
||||
const reloadWeeklySummary = async () => { await loadWeeklySummary() }
|
||||
|
||||
return {
|
||||
isAdmin,
|
||||
isSelfUser,
|
||||
@@ -1181,6 +1190,10 @@ export const useHoursPage = () => {
|
||||
deleteAbsenceFromDrawer,
|
||||
closeAbsenceDrawer,
|
||||
formatMinutes,
|
||||
handleSave
|
||||
handleSave,
|
||||
isWeekCommentDrawerOpen,
|
||||
weekCommentContext,
|
||||
openWeekCommentDrawer,
|
||||
reloadWeeklySummary
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,16 @@ export const documentationSections: DocSection[] = [
|
||||
{ type: 'list', content: 'Jour : total des heures dans la plage 06:00–21:00\nNuit : total des heures dans les plages 00:00–06:00 et 21:00–24:00\nTotal : somme des heures de jour et de nuit' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'commentaire-semaine',
|
||||
title: 'Commentaires de semaine (admin)',
|
||||
requiredLevel: 'admin',
|
||||
blocks: [
|
||||
{ type: 'paragraph', content: 'Sur la vue semaine, un picto bulle permet d\'attacher un commentaire libre sur la semaine d\'un employé.' },
|
||||
{ type: 'list', content: 'Bulle bleue : pas de commentaire\nBulle rouge : un commentaire existe\nClic : ouvre le drawer avec textarea' },
|
||||
{ type: 'note', content: 'Les commentaires n\'affectent aucun calcul. Pour supprimer, videz la textarea puis Enregistrer, ou bouton Supprimer.' },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -207,10 +217,10 @@ export const documentationSections: DocSection[] = [
|
||||
},
|
||||
{
|
||||
id: 'gestion-types-absence',
|
||||
title: 'Gestion des types de statut',
|
||||
title: 'Gestion des types d\'absence',
|
||||
requiredLevel: 'admin',
|
||||
blocks: [
|
||||
{ type: 'paragraph', content: 'Les types de statut définissent les catégories disponibles lors de la pose d\'une absence.' },
|
||||
{ type: 'paragraph', content: 'Les types d\'absence définissent les catégories disponibles lors de la pose d\'une absence.' },
|
||||
{ type: 'list', content: 'Code : identifiant court (max 10 caractères), ex: C, M, AT\nLibellé : nom affiché, ex: Congé, Maladie, Accident du travail\nCouleur : code couleur pour le calendrier et la vue jour\nOption "Compté comme travaillé" : si activé, l\'absence crédite des heures en mode TIME' },
|
||||
{ type: 'note', content: 'L\'option "Compté comme travaillé" impacte le calcul des heures supplémentaires. En mode TIME, les minutes sont créditées selon le contrat. En mode PRESENCE, aucun crédit n\'est appliqué.' },
|
||||
],
|
||||
@@ -258,7 +268,7 @@ export const documentationSections: DocSection[] = [
|
||||
requiredLevel: 'admin',
|
||||
blocks: [
|
||||
{ type: 'paragraph', content: 'La création d\'un employé se fait via le drawer d\'ajout.' },
|
||||
{ type: 'list', content: 'Champs : prénom, nom, site\nNature du contrat : CDI, CDD ou INTERIM\nAgence d\'intérim (visible uniquement pour INTERIM, optionnel)\nType de contrat / temps de travail (Forfait, 35h, 39h, etc.)\nDate de début (obligatoire)\nDate de fin (obligatoire pour CDD et INTERIM)' },
|
||||
{ type: 'list', content: 'Champs : prénom, nom, site\nNature du contrat : CDI, CDD ou INTERIM\nType de contrat / temps de travail (Forfait, 35h, 39h, etc.)\nDate de début (obligatoire)\nDate de fin (obligatoire pour CDD et INTERIM)' },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -387,8 +397,7 @@ export const documentationSections: DocSection[] = [
|
||||
requiredLevel: 'admin',
|
||||
blocks: [
|
||||
{ type: 'paragraph', content: 'Le calendrier offre une vue d\'ensemble mensuelle des absences de tous les employés.' },
|
||||
{ type: 'list', content: 'Code couleur par type d\'absence\nDemi-journée : affichage en dégradé diagonal\nJournée complète : fond plein\nJours fériés : fond bleu clair (cliquable pour créer une absence)\nFiltres par site et par employé\nNavigation par mois (précédent / suivant)' },
|
||||
{ type: 'note', content: 'Les absences peuvent être créées sur les jours fériés. Quand une absence est posée sur un férié, elle remplace l\'affichage « Férié » dans la cellule.' },
|
||||
{ type: 'list', content: 'Code couleur par type d\'absence\nDemi-journée : affichage en dégradé diagonal\nJournée complète : fond plein\nJours fériés : fond bleu clair\nFiltres par site et par employé\nNavigation par mois (précédent / suivant)' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
: ''"
|
||||
>
|
||||
<Icon name="mdi:umbrella-beach-outline" size="24"/>
|
||||
<p>Types de statut</p>
|
||||
<p>Types d'absence</p>
|
||||
</NuxtLink>
|
||||
<NuxtLink
|
||||
to="/users"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="h-full flex flex-col overflow-hidden">
|
||||
<div class="flex items-center justify-between pb-6">
|
||||
<h1 class="text-4xl font-bold text-primary-500">Types de statut</h1>
|
||||
<h1 class="text-4xl font-bold text-primary-500">Types d'absence</h1>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-primary-500 px-4 py-2 text-md font-semibold text-white hover:bg-secondary-500"
|
||||
@@ -164,7 +164,7 @@ import type { AbsenceType } from '~/services/dto/absence-type'
|
||||
import { createAbsenceType, deleteAbsenceType, listAbsenceTypes, updateAbsenceType } from '~/services/absence-types'
|
||||
|
||||
useHead({
|
||||
title: 'Types de statut'
|
||||
title: 'Types d\'absences'
|
||||
})
|
||||
|
||||
const isDrawerOpen = ref(false)
|
||||
|
||||
@@ -490,15 +490,14 @@ const hasFormationOn = (employeeId: number, date: string): boolean => {
|
||||
return cellFormationMap.value.has(`${employeeId}-${date}`)
|
||||
}
|
||||
|
||||
// Jours fériés.
|
||||
// Jours fériés (interdit pour la création).
|
||||
const isHolidayDate = (date: string) => {
|
||||
return Boolean(publicHolidays.value[date])
|
||||
}
|
||||
|
||||
// Renvoie l'absence effective pour une cellule (ou un "Férié" si pas d'absence).
|
||||
// Renvoie l'absence effective pour une cellule (ou un "Férié").
|
||||
const getCellAbsence = (employeeId: number, date: string) => {
|
||||
const absence = cellAbsenceMap.value.get(`${employeeId}-${date}`)
|
||||
if (!absence && isHolidayDate(date)) {
|
||||
if (isHolidayDate(date)) {
|
||||
return {
|
||||
id: 0,
|
||||
code: 'Férié',
|
||||
@@ -506,6 +505,7 @@ const getCellAbsence = (employeeId: number, date: string) => {
|
||||
textColor: '#0f172a'
|
||||
}
|
||||
}
|
||||
const absence = cellAbsenceMap.value.get(`${employeeId}-${date}`)
|
||||
if (absence) return { ...absence, hasFormation: hasFormationOn(employeeId, date) }
|
||||
if (hasFormationOn(employeeId, date)) {
|
||||
return {
|
||||
@@ -549,6 +549,11 @@ const getCellInfo = (employeeId: number, date: string) => {
|
||||
|
||||
// Ouverture du drawer depuis une cellule.
|
||||
const openCreate = (employee: Employee, date: string) => {
|
||||
if (isHolidayDate(date)) {
|
||||
window.alert("Impossible de creer une absence un jour ferie.")
|
||||
return
|
||||
}
|
||||
|
||||
const existing = absences.value.find((absence) => {
|
||||
const start = normalizeDate(absence.startDate)
|
||||
const end = normalizeDate(absence.endDate)
|
||||
@@ -585,6 +590,10 @@ const openCreateFromToday = () => {
|
||||
form.typeId = ''
|
||||
const now = new Date()
|
||||
const today = toYmd(now.getFullYear(), now.getMonth(), now.getDate())
|
||||
if (isHolidayDate(today)) {
|
||||
window.alert("Impossible de creer une absence un jour ferie.")
|
||||
return
|
||||
}
|
||||
form.startDate = today
|
||||
form.endDate = today
|
||||
form.startHalf = 'AM'
|
||||
|
||||
@@ -73,11 +73,13 @@
|
||||
<DriverHoursWeekView
|
||||
v-else-if="isAdmin && viewMode === 'week'"
|
||||
:is-week-loading="isWeekLoading"
|
||||
:is-admin="isAdmin"
|
||||
:week-grid-cols="weekGridCols"
|
||||
:weekly-summary="filteredWeeklySummary"
|
||||
:week-day-headers="weekDayHeaders"
|
||||
:format-minutes="formatMinutes"
|
||||
class="max-h-[calc(100vh-300px)]"
|
||||
@open-comment="openWeekCommentDrawer"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -109,6 +111,17 @@
|
||||
@cancel="closeAbsenceDrawer"
|
||||
/>
|
||||
|
||||
<HoursWeekCommentDrawer
|
||||
v-if="weekCommentContext"
|
||||
v-model="isWeekCommentDrawerOpen"
|
||||
:employee-id="weekCommentContext.employeeId"
|
||||
:employee-label="weekCommentContext.employeeLabel"
|
||||
:week-start="weekCommentContext.weekStart"
|
||||
:week-end="weekCommentContext.weekEnd"
|
||||
:initial-content="weekCommentContext.content"
|
||||
:comment-id="weekCommentContext.commentId"
|
||||
@saved="reloadWeeklySummary"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -177,7 +190,11 @@ const {
|
||||
formatMinutes,
|
||||
isSelectedDateHoliday,
|
||||
selectedHolidayLabel,
|
||||
handleSave
|
||||
handleSave,
|
||||
isWeekCommentDrawerOpen,
|
||||
weekCommentContext,
|
||||
openWeekCommentDrawer,
|
||||
reloadWeeklySummary
|
||||
} = useDriverHoursPage()
|
||||
|
||||
useHead({
|
||||
|
||||
@@ -148,7 +148,6 @@
|
||||
:on-submit-suspension="submitSuspension"
|
||||
:on-add-suspension-form="addSuspensionForm"
|
||||
:current-contract-period-id="currentActiveContractPeriodId"
|
||||
:interim-agencies="interimAgencies"
|
||||
/>
|
||||
<div v-else-if="showLeaveTab && activeTab === 'leave'" class="h-full">
|
||||
<div v-if="isLeaveLoading" class="mt-6 rounded-lg border border-neutral-200 bg-white p-6 text-md text-neutral-600">
|
||||
@@ -296,7 +295,6 @@ const {
|
||||
submitSuspension,
|
||||
addSuspensionForm,
|
||||
currentActiveContractPeriodId,
|
||||
interimAgencies,
|
||||
isLeaveLoading,
|
||||
isRttLoading,
|
||||
mileageAllowances,
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
class="absolute inset-0 flex items-center justify-center bg-primary-500 p-4 text-white opacity-0 transition-opacity duration-200 group-hover:opacity-100">
|
||||
<div class="w-full rounded-md bg-white/15 p-4 text-sm">
|
||||
<p class="text-base font-semibold">{{ employee.lastName }} {{ employee.firstName }}</p>
|
||||
<p><strong>Type:</strong> {{ employee.currentInterimAgencyName ? `${contractNatureLabel(employee.currentContractNature)} (${employee.currentInterimAgencyName})` : contractNatureLabel(employee.currentContractNature) }}</p>
|
||||
<p><strong>Type:</strong> {{ contractNatureLabel(employee.currentContractNature) }}</p>
|
||||
<p><strong>Temps de travail:</strong> {{ employee.contract?.name ?? '-' }}</p>
|
||||
<p><strong>Site:</strong> {{ employee.site?.name ?? '-' }}</p>
|
||||
<p><strong>Date d'entrée :</strong> {{ employee.entryDate ? employee.entryDate.split('-').reverse().join('/') : '-' }}</p>
|
||||
@@ -147,21 +147,6 @@
|
||||
Le type de contrat est obligatoire.
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="form.contractNature === 'INTERIM'">
|
||||
<label class="text-md font-semibold text-neutral-700" for="interim-agency">
|
||||
Agence d'intérim
|
||||
</label>
|
||||
<select
|
||||
id="interim-agency"
|
||||
v-model="form.interimAgencyId"
|
||||
class="mt-2 w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-md text-neutral-900"
|
||||
>
|
||||
<option value="">Aucune</option>
|
||||
<option v-for="agency in interimAgencies" :key="agency.id" :value="agency.id">
|
||||
{{ agency.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-md font-semibold text-neutral-700" for="contract">
|
||||
Temps de travail <span class="text-red-600">*</span>
|
||||
@@ -206,7 +191,7 @@
|
||||
:class="contractEndDateFieldClass"
|
||||
/>
|
||||
<p v-if="showContractEndDateError" class="mt-1 text-sm text-red-600">
|
||||
La date de fin est obligatoire pour un CDD ou un Intérim.
|
||||
La date de fin est obligatoire pour un CDD.
|
||||
</p>
|
||||
</div>
|
||||
<div class="rounded-md border border-neutral-200 bg-neutral-50 p-3">
|
||||
@@ -261,7 +246,6 @@ import type {Site} from '~/services/dto/site'
|
||||
import {listContracts} from '~/services/contracts'
|
||||
import {createEmployee, deleteEmployee, listEmployees, updateEmployee} from '~/services/employees'
|
||||
import {listSites} from '~/services/sites'
|
||||
import {listInterimAgencies, type InterimAgency} from '~/services/interim-agencies'
|
||||
import SiteFilterSelector from '~/components/SiteFilterSelector.vue'
|
||||
import SalaryRecapDrawer from '~/components/SalaryRecapDrawer.vue'
|
||||
import {contractNatureLabel, isContractNature, requiresContractEndDate, showsContractEndDate} from '~/utils/contract'
|
||||
@@ -285,7 +269,6 @@ const drawerTitle = computed(() =>
|
||||
const employees = ref<Employee[]>([])
|
||||
const sites = ref<Site[]>([])
|
||||
const contracts = ref<Contract[]>([])
|
||||
const interimAgencies = ref<InterimAgency[]>([])
|
||||
const employeeFilter = ref('')
|
||||
const contractStatusFilter = ref<'active' | 'inactive' | 'all'>('active')
|
||||
const selectedSiteIds = ref<number[]>([])
|
||||
@@ -317,8 +300,7 @@ const form = reactive({
|
||||
contractStartDate: '',
|
||||
contractEndDate: '',
|
||||
isDriver: false,
|
||||
workDaysHours: null as Record<number, number> | null,
|
||||
interimAgencyId: '' as number | ''
|
||||
workDaysHours: null as Record<number, number> | null
|
||||
})
|
||||
|
||||
const validationTouched = reactive({
|
||||
@@ -469,12 +451,8 @@ const loadContracts = async () => {
|
||||
contracts.value = await listContracts()
|
||||
}
|
||||
|
||||
const loadInterimAgencies = async () => {
|
||||
interimAgencies.value = await listInterimAgencies()
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await Promise.all([loadEmployees(), loadSites(), loadContracts(), loadInterimAgencies()])
|
||||
await Promise.all([loadEmployees(), loadSites(), loadContracts()])
|
||||
if (form.contractStartDate === '') {
|
||||
form.contractStartDate = new Date().toISOString().slice(0, 10)
|
||||
}
|
||||
@@ -525,8 +503,7 @@ const handleSubmit = async () => {
|
||||
contractStartDate: form.contractStartDate,
|
||||
contractEndDate: form.contractEndDate || null,
|
||||
isDriverInput: form.isDriver,
|
||||
workDaysHoursInput: requiresSchedule.value ? form.workDaysHours : null,
|
||||
interimAgencyId: form.contractNature === 'INTERIM' && form.interimAgencyId !== '' ? Number(form.interimAgencyId) : null
|
||||
workDaysHoursInput: requiresSchedule.value ? form.workDaysHours : null
|
||||
})
|
||||
}
|
||||
|
||||
@@ -539,7 +516,6 @@ const handleSubmit = async () => {
|
||||
form.contractEndDate = ''
|
||||
form.isDriver = false
|
||||
form.workDaysHours = null
|
||||
form.interimAgencyId = ''
|
||||
editingEmployee.value = null
|
||||
isDrawerOpen.value = false
|
||||
await loadEmployees()
|
||||
@@ -566,12 +542,6 @@ watch(showsContractEndDateComputed, (shows) => {
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => form.contractNature, (nature) => {
|
||||
if (nature !== 'INTERIM') {
|
||||
form.interimAgencyId = ''
|
||||
}
|
||||
})
|
||||
|
||||
watch(requiresSchedule, (required) => {
|
||||
if (!required) {
|
||||
form.workDaysHours = null
|
||||
@@ -597,7 +567,6 @@ const openCreate = () => {
|
||||
form.contractEndDate = ''
|
||||
form.isDriver = false
|
||||
form.workDaysHours = null
|
||||
form.interimAgencyId = ''
|
||||
isDrawerOpen.value = true
|
||||
}
|
||||
|
||||
|
||||
@@ -80,11 +80,13 @@
|
||||
<HoursWeekView
|
||||
v-else-if="isAdmin && viewMode === 'week'"
|
||||
:is-week-loading="isWeekLoading"
|
||||
:is-admin="isAdmin"
|
||||
:week-grid-cols="weekGridCols"
|
||||
:weekly-summary="filteredWeeklySummary"
|
||||
:week-day-headers="weekDayHeaders"
|
||||
:format-minutes="formatMinutes"
|
||||
class="max-h-[calc(100vh-300px)]"
|
||||
@open-comment="openWeekCommentDrawer"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -116,6 +118,17 @@
|
||||
@cancel="closeAbsenceDrawer"
|
||||
/>
|
||||
|
||||
<HoursWeekCommentDrawer
|
||||
v-if="weekCommentContext"
|
||||
v-model="isWeekCommentDrawerOpen"
|
||||
:employee-id="weekCommentContext.employeeId"
|
||||
:employee-label="weekCommentContext.employeeLabel"
|
||||
:week-start="weekCommentContext.weekStart"
|
||||
:week-end="weekCommentContext.weekEnd"
|
||||
:initial-content="weekCommentContext.content"
|
||||
:comment-id="weekCommentContext.commentId"
|
||||
@saved="reloadWeeklySummary"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -191,7 +204,11 @@ const {
|
||||
deleteAbsenceFromDrawer,
|
||||
closeAbsenceDrawer,
|
||||
formatMinutes,
|
||||
handleSave
|
||||
handleSave,
|
||||
isWeekCommentDrawerOpen,
|
||||
weekCommentContext,
|
||||
openWeekCommentDrawer,
|
||||
reloadWeeklySummary
|
||||
} = useHoursPage()
|
||||
|
||||
useHead({
|
||||
|
||||
@@ -20,8 +20,6 @@ export type ContractHistoryItem = {
|
||||
suspensions?: ContractSuspension[]
|
||||
isDriver?: boolean
|
||||
workDaysHours?: Record<number, number> | null
|
||||
interimAgencyId?: number | null
|
||||
interimAgencyName?: string | null
|
||||
}
|
||||
|
||||
export type Employee = {
|
||||
@@ -39,6 +37,4 @@ export type Employee = {
|
||||
displayOrder?: number
|
||||
entryDate?: string | null
|
||||
currentSuspensions?: ContractSuspension[]
|
||||
currentInterimAgencyId?: number | null
|
||||
currentInterimAgencyName?: string | null
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ export type WeeklyWorkHourRowSummary = {
|
||||
weeklyOvernightCount?: number
|
||||
hasContractForWeek?: boolean
|
||||
contractNature?: 'CDI' | 'CDD' | 'INTERIM' | null
|
||||
comment?: string | null
|
||||
commentId?: number | null
|
||||
}
|
||||
|
||||
export type WeeklyWorkHourSummary = {
|
||||
|
||||
24
frontend/services/employee-week-comments.ts
Normal file
24
frontend/services/employee-week-comments.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export type EmployeeWeekComment = {
|
||||
id: number
|
||||
weekStartDate: string
|
||||
content: string
|
||||
}
|
||||
|
||||
export const createWeekComment = async (payload: { employeeId: number; weekStartDate: string; content: string }) => {
|
||||
const api = useApi()
|
||||
return api.post<EmployeeWeekComment>('/employee_week_comments', {
|
||||
employee: `/api/employees/${payload.employeeId}`,
|
||||
weekStartDate: payload.weekStartDate,
|
||||
content: payload.content
|
||||
}, { toastSuccessKey: 'success.week-comment.save', toastErrorKey: 'errors.week-comment.save' })
|
||||
}
|
||||
|
||||
export const updateWeekComment = async (id: number, content: string) => {
|
||||
const api = useApi()
|
||||
return api.patch<EmployeeWeekComment>(`/employee_week_comments/${id}`, { content }, { toastSuccessKey: 'success.week-comment.save', toastErrorKey: 'errors.week-comment.save' })
|
||||
}
|
||||
|
||||
export const deleteWeekComment = async (id: number) => {
|
||||
const api = useApi()
|
||||
await api.delete(`/employee_week_comments/${id}`, {}, { toastSuccessKey: 'success.week-comment.delete', toastErrorKey: 'errors.week-comment.delete' })
|
||||
}
|
||||
@@ -36,7 +36,6 @@ export const createEmployee = async (payload: {
|
||||
contractEndDate?: string | null
|
||||
isDriverInput?: boolean
|
||||
workDaysHoursInput?: Record<number, number> | null
|
||||
interimAgencyId?: number | null
|
||||
}) => {
|
||||
const api = useApi()
|
||||
return api.post<Employee>('/employees', {
|
||||
@@ -48,8 +47,7 @@ export const createEmployee = async (payload: {
|
||||
contractStartDate: payload.contractStartDate,
|
||||
contractEndDate: payload.contractEndDate ?? null,
|
||||
isDriverInput: payload.isDriverInput ?? false,
|
||||
workDaysHoursInput: payload.workDaysHoursInput ?? null,
|
||||
interimAgencyId: payload.interimAgencyId ?? null
|
||||
workDaysHoursInput: payload.workDaysHoursInput ?? null
|
||||
}, {
|
||||
toastSuccessKey: 'success.employee.create',
|
||||
toastErrorKey: 'errors.employee.create'
|
||||
@@ -71,7 +69,6 @@ export const updateEmployee = async (
|
||||
displayOrder?: number
|
||||
isDriverInput?: boolean
|
||||
workDaysHoursInput?: Record<number, number> | null
|
||||
interimAgencyId?: number | null
|
||||
}
|
||||
) => {
|
||||
const api = useApi()
|
||||
@@ -106,9 +103,6 @@ export const updateEmployee = async (
|
||||
if (payload.workDaysHoursInput !== undefined) {
|
||||
body.workDaysHoursInput = payload.workDaysHoursInput
|
||||
}
|
||||
if (payload.interimAgencyId !== undefined) {
|
||||
body.interimAgencyId = payload.interimAgencyId
|
||||
}
|
||||
|
||||
return api.patch<Employee>(`/employees/${id}`, body, {
|
||||
toastSuccessKey: 'success.employee.update',
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { extractItems } from '~/utils/api'
|
||||
|
||||
export type InterimAgency = {
|
||||
id: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export const listInterimAgencies = async (): Promise<InterimAgency[]> => {
|
||||
const api = useApi()
|
||||
const data = await api.get<InterimAgency[] | { 'hydra:member'?: InterimAgency[] }>(
|
||||
'/interim_agencies',
|
||||
{},
|
||||
{ toast: false }
|
||||
)
|
||||
return extractItems<InterimAgency>(data)
|
||||
}
|
||||
@@ -13,7 +13,7 @@ export const showsContractEndDate = (nature: ContractNature) => {
|
||||
}
|
||||
|
||||
export const requiresContractEndDate = (nature: ContractNature) => {
|
||||
return nature === 'CDD' || nature === 'INTERIM'
|
||||
return nature === 'CDD'
|
||||
}
|
||||
|
||||
export const isContractNature = (value: string): value is ContractNature => {
|
||||
|
||||
29
migrations/Version20260417100000.php
Normal file
29
migrations/Version20260417100000.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260417100000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Create employee_week_comments table for per-week admin annotations on the hours weekly view';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE employee_week_comments (id SERIAL NOT NULL, employee_id INT NOT NULL, week_start_date DATE NOT NULL, content TEXT NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE UNIQUE INDEX uniq_employee_week_comment ON employee_week_comments (employee_id, week_start_date)');
|
||||
$this->addSql('CREATE INDEX idx_ewc_week_start ON employee_week_comments (week_start_date)');
|
||||
$this->addSql('ALTER TABLE employee_week_comments ADD CONSTRAINT fk_ewc_employee FOREIGN KEY (employee_id) REFERENCES employees(id) ON DELETE CASCADE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('DROP TABLE employee_week_comments');
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260417120000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Create interim_agencies table and add interim_agency_id to employee_contract_periods';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('CREATE TABLE interim_agencies (id SERIAL PRIMARY KEY, name VARCHAR(150) NOT NULL UNIQUE)');
|
||||
$this->addSql('ALTER TABLE employee_contract_periods ADD interim_agency_id INT DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE employee_contract_periods ADD CONSTRAINT fk_ecp_interim_agency FOREIGN KEY (interim_agency_id) REFERENCES interim_agencies (id) ON DELETE SET NULL');
|
||||
$this->addSql('CREATE INDEX idx_ecp_interim_agency ON employee_contract_periods (interim_agency_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE employee_contract_periods DROP CONSTRAINT IF EXISTS fk_ecp_interim_agency');
|
||||
$this->addSql('DROP INDEX IF EXISTS idx_ecp_interim_agency');
|
||||
$this->addSql('ALTER TABLE employee_contract_periods DROP COLUMN interim_agency_id');
|
||||
$this->addSql('DROP TABLE interim_agencies');
|
||||
}
|
||||
}
|
||||
@@ -34,9 +34,5 @@ final class ContractHistoryItem
|
||||
*/
|
||||
#[Groups(['employee:read'])]
|
||||
public ?array $workDaysHours = null,
|
||||
#[Groups(['employee:read'])]
|
||||
public ?int $interimAgencyId = null,
|
||||
#[Groups(['employee:read'])]
|
||||
public ?string $interimAgencyName = null,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -35,5 +35,7 @@ final class WeeklySummaryRow
|
||||
public int $weeklyOvernightCount = 0,
|
||||
public bool $hasContractForWeek = true,
|
||||
public ?string $contractNature = null,
|
||||
public ?string $comment = null,
|
||||
public ?int $commentId = null,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -98,9 +98,6 @@ class Employee
|
||||
#[Groups(['employee:write'])]
|
||||
private ?array $workDaysHoursInput = null;
|
||||
|
||||
#[Groups(['employee:write'])]
|
||||
private ?int $interimAgencyId = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new DateTimeImmutable();
|
||||
@@ -298,30 +295,6 @@ class Employee
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getInterimAgencyId(): ?int
|
||||
{
|
||||
return $this->interimAgencyId;
|
||||
}
|
||||
|
||||
public function setInterimAgencyId(?int $interimAgencyId): self
|
||||
{
|
||||
$this->interimAgencyId = $interimAgencyId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Groups(['employee:read'])]
|
||||
public function getCurrentInterimAgencyId(): ?int
|
||||
{
|
||||
return $this->resolveCurrentContractPeriod()?->getInterimAgency()?->getId();
|
||||
}
|
||||
|
||||
#[Groups(['employee:read'])]
|
||||
public function getCurrentInterimAgencyName(): ?string
|
||||
{
|
||||
return $this->resolveCurrentContractPeriod()?->getInterimAgency()?->getName();
|
||||
}
|
||||
|
||||
#[Groups(['employee:read'])]
|
||||
public function getHasActiveContract(): bool
|
||||
{
|
||||
@@ -420,8 +393,6 @@ class Employee
|
||||
suspensions: $suspensionData,
|
||||
isDriver: $period->getIsDriver(),
|
||||
workDaysHours: $period->getWorkDaysHours(),
|
||||
interimAgencyId: $period->getInterimAgency()?->getId(),
|
||||
interimAgencyName: $period->getInterimAgency()?->getName(),
|
||||
);
|
||||
},
|
||||
$periods
|
||||
|
||||
@@ -55,10 +55,6 @@ class EmployeeContractPeriod
|
||||
#[ORM\Column(type: 'json', nullable: true)]
|
||||
private ?array $workDaysHours = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: InterimAgency::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?InterimAgency $interimAgency = null;
|
||||
|
||||
#[ORM\Column(type: 'text', nullable: true)]
|
||||
private ?string $comment = null;
|
||||
|
||||
@@ -208,18 +204,6 @@ class EmployeeContractPeriod
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getInterimAgency(): ?InterimAgency
|
||||
{
|
||||
return $this->interimAgency;
|
||||
}
|
||||
|
||||
public function setInterimAgency(?InterimAgency $interimAgency): self
|
||||
{
|
||||
$this->interimAgency = $interimAgency;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, ContractSuspension>
|
||||
*/
|
||||
|
||||
136
src/Entity/EmployeeWeekComment.php
Normal file
136
src/Entity/EmployeeWeekComment.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
|
||||
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Metadata\ApiFilter;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Delete;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use ApiPlatform\Metadata\Patch;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use App\Repository\EmployeeWeekCommentRepository;
|
||||
use App\State\EmployeeWeekCommentWriteProcessor;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(security: "is_granted('ROLE_ADMIN')"),
|
||||
new GetCollection(security: "is_granted('ROLE_ADMIN')"),
|
||||
new Post(security: "is_granted('ROLE_ADMIN')", processor: EmployeeWeekCommentWriteProcessor::class),
|
||||
new Patch(security: "is_granted('ROLE_ADMIN')", processor: EmployeeWeekCommentWriteProcessor::class),
|
||||
new Delete(security: "is_granted('ROLE_ADMIN')", processor: EmployeeWeekCommentWriteProcessor::class),
|
||||
],
|
||||
normalizationContext: ['groups' => ['week_comment:read'], 'datetime_format' => 'Y-m-d'],
|
||||
denormalizationContext: ['groups' => ['week_comment:write'], 'datetime_format' => 'Y-m-d'],
|
||||
order: ['weekStartDate' => 'DESC'],
|
||||
paginationEnabled: false,
|
||||
)]
|
||||
#[ApiFilter(DateFilter::class, properties: ['weekStartDate'])]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['employee' => 'exact'])]
|
||||
#[ORM\Entity(repositoryClass: EmployeeWeekCommentRepository::class)]
|
||||
#[ORM\Table(name: 'employee_week_comments')]
|
||||
#[ORM\UniqueConstraint(name: 'uniq_employee_week_comment', columns: ['employee_id', 'week_start_date'])]
|
||||
class EmployeeWeekComment
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
#[Groups(['week_comment:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Employee::class)]
|
||||
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
|
||||
#[Groups(['week_comment:read', 'week_comment:write'])]
|
||||
#[Assert\NotNull]
|
||||
private ?Employee $employee = null;
|
||||
|
||||
#[ORM\Column(type: 'date_immutable')]
|
||||
#[Groups(['week_comment:read', 'week_comment:write'])]
|
||||
#[Assert\NotNull]
|
||||
private ?DateTimeImmutable $weekStartDate = null;
|
||||
|
||||
#[ORM\Column(type: 'text')]
|
||||
#[Groups(['week_comment:read', 'week_comment:write'])]
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Length(max: 5000)]
|
||||
private string $content = '';
|
||||
|
||||
#[ORM\Column(type: 'datetime_immutable')]
|
||||
#[Groups(['week_comment:read'])]
|
||||
private DateTimeImmutable $createdAt;
|
||||
|
||||
#[ORM\Column(type: 'datetime_immutable')]
|
||||
#[Groups(['week_comment:read'])]
|
||||
private DateTimeImmutable $updatedAt;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$now = new DateTimeImmutable();
|
||||
$this->createdAt = $now;
|
||||
$this->updatedAt = $now;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getEmployee(): ?Employee
|
||||
{
|
||||
return $this->employee;
|
||||
}
|
||||
|
||||
public function setEmployee(?Employee $employee): self
|
||||
{
|
||||
$this->employee = $employee;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWeekStartDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->weekStartDate;
|
||||
}
|
||||
|
||||
public function setWeekStartDate(?DateTimeImmutable $weekStartDate): self
|
||||
{
|
||||
$this->weekStartDate = $weekStartDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContent(): string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setContent(string $content): self
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
public function getUpdatedAt(): DateTimeImmutable
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
public function touchUpdatedAt(): void
|
||||
{
|
||||
$this->updatedAt = new DateTimeImmutable();
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(),
|
||||
],
|
||||
normalizationContext: ['groups' => ['interim_agency:read']],
|
||||
paginationEnabled: false,
|
||||
security: "is_granted('ROLE_USER')",
|
||||
order: ['name' => 'ASC'],
|
||||
)]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'interim_agencies')]
|
||||
class InterimAgency
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
#[Groups(['interim_agency:read', 'employee:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 150, unique: true)]
|
||||
#[Groups(['interim_agency:read', 'employee: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;
|
||||
}
|
||||
}
|
||||
58
src/Repository/EmployeeWeekCommentRepository.php
Normal file
58
src/Repository/EmployeeWeekCommentRepository.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Employee;
|
||||
use App\Entity\EmployeeWeekComment;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<EmployeeWeekComment>
|
||||
*/
|
||||
class EmployeeWeekCommentRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, EmployeeWeekComment::class);
|
||||
}
|
||||
|
||||
public function findOneByEmployeeAndWeek(Employee $employee, DateTimeImmutable $weekStart): ?EmployeeWeekComment
|
||||
{
|
||||
return $this->findOneBy(['employee' => $employee, 'weekStartDate' => $weekStart]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Employee> $employees
|
||||
*
|
||||
* @return array<int, EmployeeWeekComment> employee_id → comment
|
||||
*/
|
||||
public function findByWeekAndEmployees(DateTimeImmutable $weekStart, array $employees): array
|
||||
{
|
||||
if ([] === $employees) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rows = $this->createQueryBuilder('c')
|
||||
->andWhere('c.weekStartDate = :weekStart')
|
||||
->andWhere('c.employee IN (:employees)')
|
||||
->setParameter('weekStart', $weekStart)
|
||||
->setParameter('employees', $employees)
|
||||
->innerJoin('c.employee', 'e')->addSelect('e')
|
||||
->getQuery()->getResult()
|
||||
;
|
||||
|
||||
$map = [];
|
||||
foreach ($rows as $row) {
|
||||
$eid = $row->getEmployee()?->getId();
|
||||
if (null !== $eid) {
|
||||
$map[$eid] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ final readonly class EmployeeContractChangeRequest
|
||||
public ?string $contractComment,
|
||||
public ?bool $isDriver = null,
|
||||
public ?array $workDaysHours = null,
|
||||
public ?int $interimAgencyId = null,
|
||||
) {}
|
||||
|
||||
public function hasPeriodChangeRequest(): bool
|
||||
|
||||
@@ -21,7 +21,6 @@ final class EmployeeContractChangeRequestFactory
|
||||
contractComment: $employee->getContractComment(),
|
||||
isDriver: $employee->getIsDriverInput(),
|
||||
workDaysHours: $employee->getWorkDaysHoursInput(),
|
||||
interimAgencyId: $employee->getInterimAgencyId(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace App\Service\Contracts;
|
||||
use App\Entity\Contract;
|
||||
use App\Entity\Employee;
|
||||
use App\Entity\EmployeeContractPeriod;
|
||||
use App\Entity\InterimAgency;
|
||||
use App\Enum\ContractNature;
|
||||
use DateTimeImmutable;
|
||||
|
||||
@@ -24,7 +23,6 @@ final class EmployeeContractPeriodBuilder
|
||||
ContractNature $nature,
|
||||
bool $isDriver = false,
|
||||
?array $workDaysHours = null,
|
||||
?InterimAgency $interimAgency = null,
|
||||
): EmployeeContractPeriod {
|
||||
return new EmployeeContractPeriod()
|
||||
->setEmployee($employee)
|
||||
@@ -34,7 +32,6 @@ final class EmployeeContractPeriodBuilder
|
||||
->setContractNature($nature)
|
||||
->setIsDriver($isDriver)
|
||||
->setWorkDaysHours($workDaysHours)
|
||||
->setInterimAgency($interimAgency)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace App\Service\Contracts;
|
||||
use App\Entity\Contract;
|
||||
use App\Entity\Employee;
|
||||
use App\Entity\EmployeeContractPeriod;
|
||||
use App\Entity\InterimAgency;
|
||||
use App\Enum\ContractNature;
|
||||
use App\Repository\EmployeeContractPeriodRepository;
|
||||
use DateTimeImmutable;
|
||||
@@ -31,7 +30,6 @@ final readonly class EmployeeContractPeriodManager implements EmployeeContractPe
|
||||
ContractNature $nature,
|
||||
bool $isDriver = false,
|
||||
?array $workDaysHours = null,
|
||||
?int $interimAgencyId = null,
|
||||
): void {
|
||||
$this->periodValidator->assertPeriodDates($startDate, $endDate, $nature);
|
||||
$this->periodValidator->assertWorkDaysHours($contract, $nature, $workDaysHours);
|
||||
@@ -41,8 +39,7 @@ final readonly class EmployeeContractPeriodManager implements EmployeeContractPe
|
||||
return;
|
||||
}
|
||||
|
||||
$interimAgency = $this->resolveInterimAgency($interimAgencyId);
|
||||
$this->persistNewPeriod($employee, $contract, $startDate, $endDate, $nature, $isDriver, $workDaysHours, $interimAgency);
|
||||
$this->persistNewPeriod($employee, $contract, $startDate, $endDate, $nature, $isDriver, $workDaysHours);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
@@ -81,7 +78,6 @@ final readonly class EmployeeContractPeriodManager implements EmployeeContractPe
|
||||
?EmployeeContractPeriod $todayPeriod,
|
||||
bool $isDriver = false,
|
||||
?array $workDaysHours = null,
|
||||
?int $interimAgencyId = null,
|
||||
): void {
|
||||
$this->periodValidator->assertPeriodDates($startDate, $endDate, $nature);
|
||||
$this->periodValidator->assertWorkDaysHours($contract, $nature, $workDaysHours);
|
||||
@@ -94,8 +90,7 @@ final readonly class EmployeeContractPeriodManager implements EmployeeContractPe
|
||||
}
|
||||
}
|
||||
|
||||
$interimAgency = $this->resolveInterimAgency($interimAgencyId);
|
||||
$this->persistNewPeriod($employee, $contract, $startDate, $endDate, $nature, $isDriver, $workDaysHours, $interimAgency);
|
||||
$this->persistNewPeriod($employee, $contract, $startDate, $endDate, $nature, $isDriver, $workDaysHours);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
@@ -110,23 +105,8 @@ final readonly class EmployeeContractPeriodManager implements EmployeeContractPe
|
||||
ContractNature $nature,
|
||||
bool $isDriver = false,
|
||||
?array $workDaysHours = null,
|
||||
?InterimAgency $interimAgency = null,
|
||||
): void {
|
||||
$period = $this->periodBuilder->build($employee, $contract, $startDate, $endDate, $nature, $isDriver, $workDaysHours, $interimAgency);
|
||||
$period = $this->periodBuilder->build($employee, $contract, $startDate, $endDate, $nature, $isDriver, $workDaysHours);
|
||||
$this->entityManager->persist($period);
|
||||
}
|
||||
|
||||
private function resolveInterimAgency(?int $id): ?InterimAgency
|
||||
{
|
||||
if (null === $id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$agency = $this->entityManager->find(InterimAgency::class, $id);
|
||||
if (null === $agency) {
|
||||
throw new UnprocessableEntityHttpException(sprintf('Interim agency with id %d not found.', $id));
|
||||
}
|
||||
|
||||
return $agency;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ interface EmployeeContractPeriodManagerInterface
|
||||
ContractNature $nature,
|
||||
bool $isDriver = false,
|
||||
?array $workDaysHours = null,
|
||||
?int $interimAgencyId = null,
|
||||
): void;
|
||||
|
||||
public function closeCurrentPeriod(
|
||||
@@ -46,6 +45,5 @@ interface EmployeeContractPeriodManagerInterface
|
||||
?EmployeeContractPeriod $todayPeriod,
|
||||
bool $isDriver = false,
|
||||
?array $workDaysHours = null,
|
||||
?int $interimAgencyId = null,
|
||||
): void;
|
||||
}
|
||||
|
||||
80
src/State/EmployeeWeekCommentWriteProcessor.php
Normal file
80
src/State/EmployeeWeekCommentWriteProcessor.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
|
||||
use ApiPlatform\Metadata\DeleteOperationInterface;
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
use App\Entity\Employee;
|
||||
use App\Entity\EmployeeWeekComment;
|
||||
use App\Service\AuditLogger;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
|
||||
final readonly class EmployeeWeekCommentWriteProcessor implements ProcessorInterface
|
||||
{
|
||||
public function __construct(
|
||||
#[Autowire(service: 'api_platform.doctrine.orm.state.persist_processor')]
|
||||
private ProcessorInterface $persistProcessor,
|
||||
#[Autowire(service: 'api_platform.doctrine.orm.state.remove_processor')]
|
||||
private ProcessorInterface $removeProcessor,
|
||||
private EntityManagerInterface $entityManager,
|
||||
private AuditLogger $auditLogger,
|
||||
) {}
|
||||
|
||||
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): mixed
|
||||
{
|
||||
if (!$data instanceof EmployeeWeekComment) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$employee = $data->getEmployee();
|
||||
|
||||
if ($operation instanceof DeleteOperationInterface) {
|
||||
$this->auditLogger->log(
|
||||
$employee,
|
||||
'delete',
|
||||
'week_comment',
|
||||
$data->getId(),
|
||||
sprintf('Commentaire semaine supprimé pour %s (semaine du %s)', $this->label($employee), $data->getWeekStartDate()?->format('d/m/Y') ?? '?'),
|
||||
['old' => ['content' => $data->getContent()]],
|
||||
$data->getWeekStartDate(),
|
||||
);
|
||||
$result = $this->removeProcessor->process($data, $operation, $uriVariables, $context);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
$weekStart = $data->getWeekStartDate();
|
||||
if (null === $weekStart || '1' !== $weekStart->format('N')) {
|
||||
throw new UnprocessableEntityHttpException('weekStartDate must be a Monday (ISO weekday 1).');
|
||||
}
|
||||
|
||||
$prev = null;
|
||||
if (null !== $data->getId()) {
|
||||
$prev = $this->entityManager->getUnitOfWork()->getOriginalEntityData($data)['content'] ?? null;
|
||||
$data->touchUpdatedAt();
|
||||
}
|
||||
|
||||
$result = $this->persistProcessor->process($data, $operation, $uriVariables, $context);
|
||||
|
||||
if (null === $prev) {
|
||||
$this->auditLogger->log($employee, 'create', 'week_comment', $data->getId(), sprintf('Commentaire semaine créé pour %s (semaine du %s)', $this->label($employee), $weekStart->format('d/m/Y')), ['new' => ['content' => $data->getContent()]], $weekStart);
|
||||
} elseif ($prev !== $data->getContent()) {
|
||||
$this->auditLogger->log($employee, 'update', 'week_comment', $data->getId(), sprintf('Commentaire semaine modifié pour %s (semaine du %s)', $this->label($employee), $weekStart->format('d/m/Y')), ['old' => ['content' => $prev], 'new' => ['content' => $data->getContent()]], $weekStart);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function label(mixed $e): string
|
||||
{
|
||||
return $e instanceof Employee ? trim(($e->getLastName() ?? '').' '.($e->getFirstName() ?? '')) : '?';
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,6 @@ final readonly class EmployeeWriteProcessor implements ProcessorInterface
|
||||
nature: $nature,
|
||||
isDriver: $changeRequest->isDriver ?? false,
|
||||
workDaysHours: $changeRequest->workDaysHours,
|
||||
interimAgencyId: $changeRequest->interimAgencyId,
|
||||
);
|
||||
|
||||
$data->setEntryDate($startDate);
|
||||
@@ -141,7 +140,6 @@ final readonly class EmployeeWriteProcessor implements ProcessorInterface
|
||||
todayPeriod: $effectivePeriod,
|
||||
isDriver: $changeRequest->isDriver ?? false,
|
||||
workDaysHours: $changeRequest->workDaysHours,
|
||||
interimAgencyId: $changeRequest->interimAgencyId,
|
||||
);
|
||||
|
||||
return $result;
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Dto\WorkHours\WorkMetrics;
|
||||
use App\Entity\Absence;
|
||||
use App\Entity\Contract;
|
||||
use App\Entity\Employee;
|
||||
use App\Entity\EmployeeWeekComment;
|
||||
use App\Entity\User;
|
||||
use App\Entity\WorkHour;
|
||||
use App\Enum\ContractNature;
|
||||
@@ -21,6 +22,7 @@ use App\Enum\TrackingMode;
|
||||
use App\Repository\Contract\AbsenceReadRepositoryInterface;
|
||||
use App\Repository\Contract\EmployeeScopedRepositoryInterface;
|
||||
use App\Repository\Contract\WorkHourReadRepositoryInterface;
|
||||
use App\Repository\EmployeeWeekCommentRepository;
|
||||
use App\Service\Contracts\EmployeeContractResolver;
|
||||
use App\Service\WorkHours\AbsenceSegmentsResolver;
|
||||
use App\Service\WorkHours\DailyReferenceMinutesResolver;
|
||||
@@ -45,6 +47,7 @@ final readonly class WorkHourWeeklySummaryProvider implements ProviderInterface
|
||||
private EmployeeContractResolver $contractResolver,
|
||||
private DailyReferenceMinutesResolver $dailyReferenceResolver,
|
||||
private HolidayVirtualHoursResolver $holidayVirtualHoursResolver,
|
||||
private EmployeeWeekCommentRepository $weekCommentRepository,
|
||||
) {}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): WorkHourWeeklySummary
|
||||
@@ -62,11 +65,13 @@ final readonly class WorkHourWeeklySummaryProvider implements ProviderInterface
|
||||
$workHours = $this->workHourRepository->findByDateRangeAndEmployees($weekStart, $weekEnd, $employees);
|
||||
$absences = $this->absenceRepository->findForPrint($weekStart, $weekEnd, $employees);
|
||||
|
||||
$weekComments = $this->weekCommentRepository->findByWeekAndEmployees($weekStart, $employees);
|
||||
|
||||
$summary = new WorkHourWeeklySummary();
|
||||
$summary->weekStart = $weekStart->format('Y-m-d');
|
||||
$summary->weekEnd = $weekEnd->format('Y-m-d');
|
||||
$summary->days = $days;
|
||||
$summary->rows = $this->buildRows($employees, $workHours, $absences, $days, $anchorDate->format('Y-m-d'));
|
||||
$summary->rows = $this->buildRows($employees, $workHours, $absences, $days, $anchorDate->format('Y-m-d'), $weekComments);
|
||||
|
||||
return $summary;
|
||||
}
|
||||
@@ -109,14 +114,15 @@ final readonly class WorkHourWeeklySummaryProvider implements ProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Employee> $employees
|
||||
* @param list<WorkHour> $workHours
|
||||
* @param list<Absence> $absences
|
||||
* @param list<string> $days
|
||||
* @param list<Employee> $employees
|
||||
* @param list<WorkHour> $workHours
|
||||
* @param list<Absence> $absences
|
||||
* @param list<string> $days
|
||||
* @param array<int, EmployeeWeekComment> $weekComments
|
||||
*
|
||||
* @return list<WeeklySummaryRow>
|
||||
*/
|
||||
private function buildRows(array $employees, array $workHours, array $absences, array $days, string $anchorDateYmd): array
|
||||
private function buildRows(array $employees, array $workHours, array $absences, array $days, string $anchorDateYmd, array $weekComments = []): array
|
||||
{
|
||||
$contractsByEmployeeDate = $this->contractResolver->resolveForEmployeesAndDays($employees, $days);
|
||||
$contractNaturesByEmployeeDate = $this->contractResolver->resolveNaturesForEmployeesAndDays($employees, $days);
|
||||
@@ -370,6 +376,8 @@ final readonly class WorkHourWeeklySummaryProvider implements ProviderInterface
|
||||
weeklyOvernightCount: $weeklyOvernightCount,
|
||||
hasContractForWeek: $hasContractForWeek,
|
||||
contractNature: $weekAnchorContractNature->value,
|
||||
comment: ($weekComments[$employeeId] ?? null)?->getContent(),
|
||||
commentId: ($weekComments[$employeeId] ?? null)?->getId(),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
76
tests/State/EmployeeWeekCommentWriteProcessorTest.php
Normal file
76
tests/State/EmployeeWeekCommentWriteProcessorTest.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\State;
|
||||
|
||||
use ApiPlatform\Metadata\Delete;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
use App\Entity\Employee;
|
||||
use App\Entity\EmployeeWeekComment;
|
||||
use App\Service\AuditLogger;
|
||||
use App\State\EmployeeWeekCommentWriteProcessor;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\UnitOfWork;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class EmployeeWeekCommentWriteProcessorTest extends TestCase
|
||||
{
|
||||
public function testRejectsNonMondayWeekStart(): void
|
||||
{
|
||||
$processor = new EmployeeWeekCommentWriteProcessor(
|
||||
$this->createStub(ProcessorInterface::class),
|
||||
$this->createStub(ProcessorInterface::class),
|
||||
$this->createStub(EntityManagerInterface::class),
|
||||
$this->createStub(AuditLogger::class),
|
||||
);
|
||||
|
||||
$comment = new EmployeeWeekComment()
|
||||
->setEmployee(new Employee()->setFirstName('A')->setLastName('B'))
|
||||
->setWeekStartDate(new DateTimeImmutable('2026-04-14'))
|
||||
->setContent('test')
|
||||
;
|
||||
|
||||
$this->expectException(UnprocessableEntityHttpException::class);
|
||||
$processor->process($comment, new Post());
|
||||
}
|
||||
|
||||
public function testAcceptsMondayAndAuditsCreate(): void
|
||||
{
|
||||
$persist = $this->createMock(ProcessorInterface::class);
|
||||
$persist->expects(self::once())->method('process');
|
||||
$em = $this->createMock(EntityManagerInterface::class);
|
||||
$em->method('getUnitOfWork')->willReturn($this->createStub(UnitOfWork::class));
|
||||
$em->expects(self::once())->method('flush');
|
||||
$auditor = $this->createMock(AuditLogger::class);
|
||||
$auditor->expects(self::once())->method('log')->with(self::anything(), 'create', 'week_comment');
|
||||
|
||||
$processor = new EmployeeWeekCommentWriteProcessor($persist, $this->createStub(ProcessorInterface::class), $em, $auditor);
|
||||
$processor->process(
|
||||
new EmployeeWeekComment()->setEmployee(new Employee()->setFirstName('A')->setLastName('B'))->setWeekStartDate(new DateTimeImmutable('2026-04-13'))->setContent('x'),
|
||||
new Post()
|
||||
);
|
||||
}
|
||||
|
||||
public function testDeleteAudits(): void
|
||||
{
|
||||
$remove = $this->createMock(ProcessorInterface::class);
|
||||
$remove->expects(self::once())->method('process');
|
||||
$em = $this->createMock(EntityManagerInterface::class);
|
||||
$em->expects(self::once())->method('flush');
|
||||
$auditor = $this->createMock(AuditLogger::class);
|
||||
$auditor->expects(self::once())->method('log')->with(self::anything(), 'delete', 'week_comment');
|
||||
|
||||
$processor = new EmployeeWeekCommentWriteProcessor($this->createStub(ProcessorInterface::class), $remove, $em, $auditor);
|
||||
$processor->process(
|
||||
new EmployeeWeekComment()->setEmployee(new Employee()->setFirstName('A')->setLastName('B'))->setWeekStartDate(new DateTimeImmutable('2026-04-13'))->setContent('x'),
|
||||
new Delete()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ use App\Enum\HalfDay;
|
||||
use App\Repository\Contract\AbsenceReadRepositoryInterface;
|
||||
use App\Repository\Contract\EmployeeScopedRepositoryInterface;
|
||||
use App\Repository\Contract\WorkHourReadRepositoryInterface;
|
||||
use App\Repository\EmployeeWeekCommentRepository;
|
||||
use App\Service\Contracts\EmployeeContractResolver;
|
||||
use App\Service\PublicHolidayServiceInterface;
|
||||
use App\Service\WorkHours\AbsenceSegmentsResolver;
|
||||
@@ -66,6 +67,7 @@ final class WorkHourWeeklySummaryProviderTest extends TestCase
|
||||
$this->buildResolverStub(),
|
||||
new DailyReferenceMinutesResolver(),
|
||||
$this->buildHolidayResolver(),
|
||||
$this->buildWeekCommentRepoStub(),
|
||||
);
|
||||
|
||||
$this->expectException(AccessDeniedHttpException::class);
|
||||
@@ -128,6 +130,7 @@ final class WorkHourWeeklySummaryProviderTest extends TestCase
|
||||
$this->buildWeeklyResolverStub($employees),
|
||||
new DailyReferenceMinutesResolver(),
|
||||
$this->buildHolidayResolver(),
|
||||
$this->buildWeekCommentRepoStub(),
|
||||
);
|
||||
|
||||
$result = $provider->provide(new Get());
|
||||
@@ -178,6 +181,14 @@ final class WorkHourWeeklySummaryProviderTest extends TestCase
|
||||
$property->setValue($entity, $id);
|
||||
}
|
||||
|
||||
private function buildWeekCommentRepoStub(): EmployeeWeekCommentRepository
|
||||
{
|
||||
$r = $this->createStub(EmployeeWeekCommentRepository::class);
|
||||
$r->method('findByWeekAndEmployees')->willReturn([]);
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
private function buildHolidayResolver(array $holidayMap = []): HolidayVirtualHoursResolver
|
||||
{
|
||||
$service = $this->createStub(PublicHolidayServiceInterface::class);
|
||||
|
||||
Reference in New Issue
Block a user