feat : ajout des demi-journées d'absence dans le calendrier et l'export pdf
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
This commit is contained in:
6
.idea/db-forest-config.xml
generated
Normal file
6
.idea/db-forest-config.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="db-tree-configuration">
|
||||||
|
<option name="data" value="---------------------------------------- 1:0:9cad43df-2147-4989-b7a4-443067034884 2:0:ae622167-c834-4e7b-87a5-c1721036f5dc 3:0:f407a514-c6b4-4b26-9555-445a85892502 " />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -39,24 +39,44 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-2 gap-4">
|
<div class="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="text-md font-semibold text-neutral-700" for="start-date">Date de début</label>
|
<label class="text-md font-semibold text-neutral-700" for="start-date">Début</label>
|
||||||
<input
|
<div class="mt-2 grid grid-cols-2 gap-2">
|
||||||
id="start-date"
|
<input
|
||||||
v-model="absenceForm.startDate"
|
id="start-date"
|
||||||
type="date"
|
v-model="absenceForm.startDate"
|
||||||
class="mt-2 w-full rounded-md border border-neutral-300 px-3 py-2 text-md text-neutral-900"
|
type="date"
|
||||||
/>
|
class="w-full rounded-md border border-neutral-300 px-3 py-2 text-md text-neutral-900"
|
||||||
|
/>
|
||||||
|
<select
|
||||||
|
v-model="absenceForm.startHalf"
|
||||||
|
class="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-md text-neutral-900"
|
||||||
|
>
|
||||||
|
<option v-for="half in HALF_DAYS" :key="half.value" :value="half.value">
|
||||||
|
{{ half.label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="text-md font-semibold text-neutral-700" for="end-date">Date de fin</label>
|
<label class="text-md font-semibold text-neutral-700" for="end-date">Fin</label>
|
||||||
<input
|
<div class="mt-2 grid grid-cols-2 gap-2">
|
||||||
id="end-date"
|
<input
|
||||||
v-model="absenceForm.endDate"
|
id="end-date"
|
||||||
type="date"
|
v-model="absenceForm.endDate"
|
||||||
class="mt-2 w-full rounded-md border border-neutral-300 px-3 py-2 text-md text-neutral-900"
|
type="date"
|
||||||
/>
|
class="w-full rounded-md border border-neutral-300 px-3 py-2 text-md text-neutral-900"
|
||||||
|
/>
|
||||||
|
<select
|
||||||
|
v-model="absenceForm.endHalf"
|
||||||
|
class="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-md text-neutral-900"
|
||||||
|
>
|
||||||
|
<option v-for="half in HALF_DAYS" :key="half.value" :value="half.value">
|
||||||
|
{{ half.label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -103,6 +123,8 @@ import { computed, reactive, toRef, watch } from 'vue'
|
|||||||
import type { Employee } from '~/services/dto/employee'
|
import type { Employee } from '~/services/dto/employee'
|
||||||
import type { AbsenceType } from '~/services/dto/absence-type'
|
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 { HALF_DAYS } from '~/services/dto/half-day'
|
||||||
import AppDrawer from '~/components/AppDrawer.vue'
|
import AppDrawer from '~/components/AppDrawer.vue'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -113,7 +135,9 @@ const props = defineProps<{
|
|||||||
employeeId: number | ''
|
employeeId: number | ''
|
||||||
typeId: number | ''
|
typeId: number | ''
|
||||||
startDate: string
|
startDate: string
|
||||||
|
startHalf: HalfDay
|
||||||
endDate: string
|
endDate: string
|
||||||
|
endHalf: HalfDay
|
||||||
comment: string
|
comment: string
|
||||||
}
|
}
|
||||||
editingAbsence: Absence | null
|
editingAbsence: Absence | null
|
||||||
|
|||||||
@@ -28,18 +28,46 @@
|
|||||||
:key="employee.id + '-' + day.date"
|
:key="employee.id + '-' + day.date"
|
||||||
class="border-b border-neutral-100 px-2 py-2 text-center text-xs text-neutral-800"
|
class="border-b border-neutral-100 px-2 py-2 text-center text-xs text-neutral-800"
|
||||||
>
|
>
|
||||||
<button
|
<template v-if="getCellInfo(employee.id, day.date)">
|
||||||
type="button"
|
<button
|
||||||
class="flex h-8 w-full items-center justify-center rounded-md border border-neutral-200 text-[11px] font-semibold text-neutral-800 hover:border-primary-500/40"
|
type="button"
|
||||||
:class="isHolidayDate(day.date) ? 'cursor-not-allowed opacity-80' : ''"
|
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 hover:border-primary-500/40"
|
||||||
:style="getCellStyle(employee.id, day.date)"
|
:class="isHolidayDate(day.date) ? 'cursor-not-allowed opacity-80' : ''"
|
||||||
:disabled="isHolidayDate(day.date)"
|
:style="getCellStyle(employee.id, day.date)"
|
||||||
@click="handleCellClick(employee, day.date)"
|
:disabled="isHolidayDate(day.date)"
|
||||||
>
|
@click="handleCellClick(employee, day.date)"
|
||||||
<span v-if="getCellCode(employee.id, day.date)">
|
>
|
||||||
{{ getCellCode(employee.id, day.date) }}
|
<span v-if="!getCellInfo(employee.id, day.date)?.halfLabel">
|
||||||
</span>
|
{{ getCellInfo(employee.id, day.date)?.code }}
|
||||||
</button>
|
</span>
|
||||||
|
<template v-else>
|
||||||
|
<span
|
||||||
|
v-if="getCellInfo(employee.id, day.date)?.halfLabel === 'AM'"
|
||||||
|
class="absolute top-0 left-0 flex h-1/2 w-full items-center justify-center text-[10px] font-semibold"
|
||||||
|
>
|
||||||
|
{{ getCellInfo(employee.id, day.date)?.code }}
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
v-else
|
||||||
|
class="absolute bottom-0 left-0 flex h-1/2 w-full items-center justify-center text-[10px] font-semibold"
|
||||||
|
>
|
||||||
|
{{ getCellInfo(employee.id, day.date)?.code }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<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 hover:border-primary-500/40"
|
||||||
|
: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>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,6 +77,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Employee } from '~/services/dto/employee'
|
import type { Employee } from '~/services/dto/employee'
|
||||||
|
import type { HalfDay } from '~/services/dto/half-day'
|
||||||
|
|
||||||
type DayInfo = {
|
type DayInfo = {
|
||||||
date: string
|
date: string
|
||||||
@@ -61,7 +90,7 @@ defineProps<{
|
|||||||
visibleEmployees: Employee[]
|
visibleEmployees: Employee[]
|
||||||
gridStyle: Record<string, string>
|
gridStyle: Record<string, string>
|
||||||
getCellStyle: (employeeId: number, date: string) => Record<string, string> | undefined
|
getCellStyle: (employeeId: number, date: string) => Record<string, string> | undefined
|
||||||
getCellCode: (employeeId: number, date: string) => string
|
getCellInfo: (employeeId: number, date: string) => { id: number; code: string; color: string; halfLabel?: HalfDay; textColor?: string } | null
|
||||||
formatEmployeeName: (employee: Employee) => string
|
formatEmployeeName: (employee: Employee) => string
|
||||||
isHolidayDate: (date: string) => boolean
|
isHolidayDate: (date: string) => boolean
|
||||||
}>()
|
}>()
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
:visible-employees="visibleEmployees"
|
:visible-employees="visibleEmployees"
|
||||||
:grid-style="gridStyle"
|
:grid-style="gridStyle"
|
||||||
:get-cell-style="getCellStyle"
|
:get-cell-style="getCellStyle"
|
||||||
:get-cell-code="getCellCode"
|
:get-cell-info="getCellInfo"
|
||||||
:format-employee-name="formatEmployeeName"
|
:format-employee-name="formatEmployeeName"
|
||||||
:is-holiday-date="isHolidayDate"
|
:is-holiday-date="isHolidayDate"
|
||||||
@cell-click="openCreate"
|
@cell-click="openCreate"
|
||||||
@@ -90,6 +90,8 @@
|
|||||||
import type {Employee} from '~/services/dto/employee'
|
import type {Employee} from '~/services/dto/employee'
|
||||||
import type {AbsenceType} from '~/services/dto/absence-type'
|
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 {HALF_DAYS} from '~/services/dto/half-day'
|
||||||
import {listEmployees} from '~/services/employees'
|
import {listEmployees} 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'
|
||||||
@@ -99,6 +101,7 @@ import CalendarGrid from '~/components/CalendarGrid.vue'
|
|||||||
import AbsenceFormDrawer from '~/components/AbsenceFormDrawer.vue'
|
import AbsenceFormDrawer from '~/components/AbsenceFormDrawer.vue'
|
||||||
import AbsencePrintDrawer from '~/components/AbsencePrintDrawer.vue'
|
import AbsencePrintDrawer from '~/components/AbsencePrintDrawer.vue'
|
||||||
|
|
||||||
|
// Données principales affichées dans la grille.
|
||||||
const employees = ref<Employee[]>([])
|
const employees = ref<Employee[]>([])
|
||||||
const sites = computed(() => {
|
const sites = computed(() => {
|
||||||
const siteMap = new Map<number, { id: number; name: string; color: string }>()
|
const siteMap = new Map<number, { id: number; name: string; color: string }>()
|
||||||
@@ -110,6 +113,7 @@ const sites = computed(() => {
|
|||||||
return Array.from(siteMap.values()).sort((siteA, siteB) => siteA.name.localeCompare(siteB.name, 'fr'))
|
return Array.from(siteMap.values()).sort((siteA, siteB) => siteA.name.localeCompare(siteB.name, 'fr'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Filtres de sites (par défaut: tous sélectionnés à l'init).
|
||||||
const selectedSiteIds = ref<number[]>([])
|
const selectedSiteIds = ref<number[]>([])
|
||||||
const sitesInitialized = ref(false)
|
const sitesInitialized = ref(false)
|
||||||
|
|
||||||
@@ -119,6 +123,7 @@ watch(sites, (next) => {
|
|||||||
sitesInitialized.value = true
|
sitesInitialized.value = true
|
||||||
}, { immediate: true })
|
}, { immediate: true })
|
||||||
|
|
||||||
|
// Tri stable: site -> nom -> prénom.
|
||||||
const sortedEmployees = computed(() => {
|
const sortedEmployees = computed(() => {
|
||||||
return [...employees.value].sort((employeeA, employeeB) => {
|
return [...employees.value].sort((employeeA, employeeB) => {
|
||||||
const siteNameA = employeeA.site?.name ?? ''
|
const siteNameA = employeeA.site?.name ?? ''
|
||||||
@@ -133,21 +138,25 @@ const sortedEmployees = computed(() => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Employés visibles selon le filtre de sites.
|
||||||
const visibleEmployees = computed(() => {
|
const visibleEmployees = computed(() => {
|
||||||
if (selectedSiteIds.value.length === 0) return []
|
if (selectedSiteIds.value.length === 0) return []
|
||||||
return sortedEmployees.value.filter((employee) => {
|
return sortedEmployees.value.filter((employee) => {
|
||||||
return employee.site?.id && selectedSiteIds.value.includes(employee.site.id)
|
return employee.site?.id && selectedSiteIds.value.includes(employee.site.id)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
// Données de référence et absences du mois affiché.
|
||||||
const absenceTypes = ref<AbsenceType[]>([])
|
const absenceTypes = ref<AbsenceType[]>([])
|
||||||
const absences = ref<Absence[]>([])
|
const absences = ref<Absence[]>([])
|
||||||
const publicHolidays = ref<Record<string, string>>({})
|
const publicHolidays = ref<Record<string, string>>({})
|
||||||
|
|
||||||
|
// États UI.
|
||||||
const isDrawerOpen = ref(false)
|
const isDrawerOpen = ref(false)
|
||||||
const isSubmitting = ref(false)
|
const isSubmitting = ref(false)
|
||||||
const editingAbsence = ref<Absence | null>(null)
|
const editingAbsence = ref<Absence | null>(null)
|
||||||
const isPrintOpen = ref(false)
|
const isPrintOpen = ref(false)
|
||||||
|
|
||||||
|
// Sélecteurs de période.
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const selectedMonth = ref(now.getMonth())
|
const selectedMonth = ref(now.getMonth())
|
||||||
const selectedYear = ref(now.getFullYear())
|
const selectedYear = ref(now.getFullYear())
|
||||||
@@ -170,43 +179,53 @@ const months = [
|
|||||||
const years = Array.from({length: 5}, (unusedValue, index) => now.getFullYear() - 2 + index)
|
const years = Array.from({length: 5}, (unusedValue, index) => now.getFullYear() - 2 + index)
|
||||||
|
|
||||||
|
|
||||||
|
// Infos de calendrier calculées.
|
||||||
const daysInMonth = computed(() => getDaysInMonth(selectedYear.value, selectedMonth.value))
|
const daysInMonth = computed(() => getDaysInMonth(selectedYear.value, selectedMonth.value))
|
||||||
const monthStartDate = computed(() => new Date(selectedYear.value, selectedMonth.value, 1))
|
const monthStartDate = computed(() => new Date(selectedYear.value, selectedMonth.value, 1))
|
||||||
const monthEndDate = computed(() => new Date(selectedYear.value, selectedMonth.value + 1, 0))
|
const monthEndDate = computed(() => new Date(selectedYear.value, selectedMonth.value + 1, 0))
|
||||||
|
|
||||||
|
// Largeur fixe de la colonne employés + une colonne par jour.
|
||||||
const gridStyle = computed(() => ({
|
const gridStyle = computed(() => ({
|
||||||
gridTemplateColumns: `160px repeat(${daysInMonth.value.length}, minmax(44px, 1fr))`
|
gridTemplateColumns: `160px repeat(${daysInMonth.value.length}, minmax(44px, 1fr))`
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// Formulaire d'absence (AM/PM par défaut = journée complète).
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
employeeId: '' as number | '',
|
employeeId: '' as number | '',
|
||||||
typeId: '' as number | '',
|
typeId: '' as number | '',
|
||||||
startDate: '',
|
startDate: '',
|
||||||
|
startHalf: 'AM' as HalfDay,
|
||||||
endDate: '',
|
endDate: '',
|
||||||
|
endHalf: 'PM' as HalfDay,
|
||||||
comment: ''
|
comment: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Formulaire d'impression (intervalle + sites).
|
||||||
const printForm = reactive({
|
const printForm = reactive({
|
||||||
from: '',
|
from: '',
|
||||||
to: '',
|
to: '',
|
||||||
siteIds: [] as number[]
|
siteIds: [] as number[]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Remet le formulaire à zéro.
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
form.employeeId = ''
|
form.employeeId = ''
|
||||||
form.typeId = ''
|
form.typeId = ''
|
||||||
form.startDate = ''
|
form.startDate = ''
|
||||||
|
form.startHalf = 'AM'
|
||||||
form.endDate = ''
|
form.endDate = ''
|
||||||
|
form.endHalf = 'PM'
|
||||||
form.comment = ''
|
form.comment = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ferme le drawer et nettoie l'état.
|
||||||
const closeDrawer = () => {
|
const closeDrawer = () => {
|
||||||
isDrawerOpen.value = false
|
isDrawerOpen.value = false
|
||||||
editingAbsence.value = null
|
editingAbsence.value = null
|
||||||
resetForm()
|
resetForm()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ouvre l'impression avec la période du mois courant.
|
||||||
const openPrint = () => {
|
const openPrint = () => {
|
||||||
const monthStart = toYmd(selectedYear.value, selectedMonth.value, 1)
|
const monthStart = toYmd(selectedYear.value, selectedMonth.value, 1)
|
||||||
const monthEnd = toYmd(selectedYear.value, selectedMonth.value + 1, 0)
|
const monthEnd = toYmd(selectedYear.value, selectedMonth.value + 1, 0)
|
||||||
@@ -220,12 +239,43 @@ const closePrint = () => {
|
|||||||
isPrintOpen.value = false
|
isPrintOpen.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse "YYYY-MM-DD" en Date (ou null).
|
||||||
const parseYmd = (value: string) => {
|
const parseYmd = (value: string) => {
|
||||||
const [year, month, day] = value.split('-').map(Number)
|
const [year, month, day] = value.split('-').map(Number)
|
||||||
if (!year || !month || !day) return null
|
if (!year || !month || !day) return null
|
||||||
return new Date(year, month - 1, day)
|
return new Date(year, month - 1, day)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Détermine si la journée est une demi-journée (AM/PM) ou complète.
|
||||||
|
const getHalfForDate = (
|
||||||
|
startDate: string,
|
||||||
|
endDate: string,
|
||||||
|
startHalf: HalfDay,
|
||||||
|
endHalf: HalfDay,
|
||||||
|
date: string
|
||||||
|
) => {
|
||||||
|
if (startDate === endDate) {
|
||||||
|
return startHalf === endHalf ? startHalf : null
|
||||||
|
}
|
||||||
|
if (date === startDate && startHalf === 'PM') return 'PM'
|
||||||
|
if (date === endDate && endHalf === 'AM') return 'AM'
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Renvoie les segments occupés pour une date donnée (AM/PM).
|
||||||
|
const getSegmentsForDate = (
|
||||||
|
startDate: string,
|
||||||
|
endDate: string,
|
||||||
|
startHalf: HalfDay,
|
||||||
|
endHalf: HalfDay,
|
||||||
|
date: string
|
||||||
|
) => {
|
||||||
|
const half = getHalfForDate(startDate, endDate, startHalf, endHalf, date)
|
||||||
|
if (!half) return HALF_DAYS.map((item) => item.value) as HalfDay[]
|
||||||
|
return [half] as HalfDay[]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajoute des mois tout en gardant un jour valide.
|
||||||
const addMonths = (date: Date, months: number) => {
|
const addMonths = (date: Date, months: number) => {
|
||||||
const next = new Date(date.getFullYear(), date.getMonth() + months, date.getDate())
|
const next = new Date(date.getFullYear(), date.getMonth() + months, date.getDate())
|
||||||
if (next.getMonth() !== (date.getMonth() + months) % 12) {
|
if (next.getMonth() !== (date.getMonth() + months) % 12) {
|
||||||
@@ -234,6 +284,7 @@ const addMonths = (date: Date, months: number) => {
|
|||||||
return next
|
return next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Limite l'intervalle d'impression à 2 mois max.
|
||||||
const enforcePrintRange = () => {
|
const enforcePrintRange = () => {
|
||||||
if (!printForm.from) return
|
if (!printForm.from) return
|
||||||
const start = parseYmd(printForm.from)
|
const start = parseYmd(printForm.from)
|
||||||
@@ -266,6 +317,7 @@ const enforcePrintRange = () => {
|
|||||||
watch(() => printForm.from, enforcePrintRange)
|
watch(() => printForm.from, enforcePrintRange)
|
||||||
watch(() => printForm.to, enforcePrintRange)
|
watch(() => printForm.to, enforcePrintRange)
|
||||||
|
|
||||||
|
// Chargements API.
|
||||||
const loadEmployees = async () => {
|
const loadEmployees = async () => {
|
||||||
employees.value = await listEmployees()
|
employees.value = await listEmployees()
|
||||||
}
|
}
|
||||||
@@ -302,15 +354,17 @@ watch(selectedYear, async () => {
|
|||||||
|
|
||||||
// Indexation des absences par cellule pour eviter un find() a chaque case.
|
// Indexation des absences par cellule pour eviter un find() a chaque case.
|
||||||
const cellAbsenceMap = computed(() => {
|
const cellAbsenceMap = computed(() => {
|
||||||
const map = new Map<string, { id: number; code: string; color: string; textColor?: string }>()
|
const map = new Map<string, { id: number; code: string; color: string; halfLabel?: HalfDay; textColor?: string }>()
|
||||||
const monthStart = monthStartDate.value
|
const monthStart = monthStartDate.value
|
||||||
const monthEnd = monthEndDate.value
|
const monthEnd = monthEndDate.value
|
||||||
|
|
||||||
for (const absence of absences.value) {
|
for (const absence of absences.value) {
|
||||||
const employeeId = absence.employee?.id
|
const employeeId = absence.employee?.id
|
||||||
if (!employeeId) continue
|
if (!employeeId) continue
|
||||||
const start = parseYmd(normalizeDate(absence.startDate))
|
const startDate = normalizeDate(absence.startDate)
|
||||||
const end = parseYmd(normalizeDate(absence.endDate))
|
const endDate = normalizeDate(absence.endDate)
|
||||||
|
const start = parseYmd(startDate)
|
||||||
|
const end = parseYmd(endDate)
|
||||||
if (!start || !end) continue
|
if (!start || !end) continue
|
||||||
|
|
||||||
const rangeStart = start < monthStart ? monthStart : start
|
const rangeStart = start < monthStart ? monthStart : start
|
||||||
@@ -322,11 +376,20 @@ const cellAbsenceMap = computed(() => {
|
|||||||
currentDate <= rangeEnd;
|
currentDate <= rangeEnd;
|
||||||
currentDate.setDate(currentDate.getDate() + 1)
|
currentDate.setDate(currentDate.getDate() + 1)
|
||||||
) {
|
) {
|
||||||
const key = `${employeeId}-${toYmd(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate())}`
|
const dateKey = toYmd(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate())
|
||||||
|
const key = `${employeeId}-${dateKey}`
|
||||||
|
const halfLabel = getHalfForDate(
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
absence.startHalf ?? 'AM',
|
||||||
|
absence.endHalf ?? 'PM',
|
||||||
|
dateKey
|
||||||
|
) ?? undefined
|
||||||
map.set(key, {
|
map.set(key, {
|
||||||
id: absence.id,
|
id: absence.id,
|
||||||
code: absence.type?.code ?? '',
|
code: absence.type?.code ?? '',
|
||||||
color: absence.type?.color ?? '#222783'
|
color: absence.type?.color ?? '#222783',
|
||||||
|
halfLabel
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,15 +397,17 @@ const cellAbsenceMap = computed(() => {
|
|||||||
return map
|
return map
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Jours fériés (interdit pour la création).
|
||||||
const isHolidayDate = (date: string) => {
|
const isHolidayDate = (date: string) => {
|
||||||
return Boolean(publicHolidays.value[date])
|
return Boolean(publicHolidays.value[date])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Renvoie l'absence effective pour une cellule (ou un "Férié").
|
||||||
const getCellAbsence = (employeeId: number, date: string) => {
|
const getCellAbsence = (employeeId: number, date: string) => {
|
||||||
if (isHolidayDate(date)) {
|
if (isHolidayDate(date)) {
|
||||||
return {
|
return {
|
||||||
id: 0,
|
id: 0,
|
||||||
code: 'F',
|
code: 'Férié',
|
||||||
color: '#b3e5fc',
|
color: '#b3e5fc',
|
||||||
textColor: '#0f172a'
|
textColor: '#0f172a'
|
||||||
}
|
}
|
||||||
@@ -352,20 +417,35 @@ const getCellAbsence = (employeeId: number, date: string) => {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Style de cellule (plein ou demi-journée).
|
||||||
const getCellStyle = (employeeId: number, date: string) => {
|
const getCellStyle = (employeeId: number, date: string) => {
|
||||||
const absence = getCellAbsence(employeeId, date)
|
const absence = getCellAbsence(employeeId, date)
|
||||||
if (!absence) return undefined
|
if (!absence) return undefined
|
||||||
|
|
||||||
|
if (absence.halfLabel) {
|
||||||
|
const color = absence.color
|
||||||
|
const textColor = absence.textColor ?? '#FFF'
|
||||||
|
const backgroundImage = absence.halfLabel === 'AM'
|
||||||
|
? `linear-gradient(180deg, ${color} 0 50%, transparent 50% 100%)`
|
||||||
|
: `linear-gradient(180deg, transparent 0 50%, ${color} 50% 100%)`
|
||||||
|
return {
|
||||||
|
backgroundImage,
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
color: textColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
backgroundColor: absence.color,
|
backgroundColor: absence.color,
|
||||||
color: absence.textColor ?? '#fff'
|
color: absence.textColor ?? '#fff'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCellCode = (employeeId: number, date: string) => {
|
const getCellInfo = (employeeId: number, date: string) => {
|
||||||
return getCellAbsence(employeeId, date)?.code ?? ''
|
return getCellAbsence(employeeId, date)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ouverture du drawer depuis une cellule.
|
||||||
const openCreate = (employee: Employee, date: string) => {
|
const openCreate = (employee: Employee, date: string) => {
|
||||||
if (isHolidayDate(date)) {
|
if (isHolidayDate(date)) {
|
||||||
window.alert("Impossible de creer une absence un jour ferie.")
|
window.alert("Impossible de creer une absence un jour ferie.")
|
||||||
@@ -384,12 +464,16 @@ const openCreate = (employee: Employee, date: string) => {
|
|||||||
form.typeId = existing.type.id
|
form.typeId = existing.type.id
|
||||||
form.startDate = normalizeDate(existing.startDate)
|
form.startDate = normalizeDate(existing.startDate)
|
||||||
form.endDate = normalizeDate(existing.endDate)
|
form.endDate = normalizeDate(existing.endDate)
|
||||||
|
form.startHalf = existing.startHalf ?? 'AM'
|
||||||
|
form.endHalf = existing.endHalf ?? 'PM'
|
||||||
form.comment = existing.comment ?? ''
|
form.comment = existing.comment ?? ''
|
||||||
} else {
|
} else {
|
||||||
editingAbsence.value = null
|
editingAbsence.value = null
|
||||||
form.employeeId = employee.id
|
form.employeeId = employee.id
|
||||||
form.startDate = date
|
form.startDate = date
|
||||||
form.endDate = date
|
form.endDate = date
|
||||||
|
form.startHalf = 'AM'
|
||||||
|
form.endHalf = 'PM'
|
||||||
form.typeId = ''
|
form.typeId = ''
|
||||||
form.comment = ''
|
form.comment = ''
|
||||||
}
|
}
|
||||||
@@ -397,6 +481,7 @@ const openCreate = (employee: Employee, date: string) => {
|
|||||||
isDrawerOpen.value = true
|
isDrawerOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ouverture du drawer depuis le bouton "Ajouter".
|
||||||
const openCreateFromToday = () => {
|
const openCreateFromToday = () => {
|
||||||
editingAbsence.value = null
|
editingAbsence.value = null
|
||||||
form.employeeId = ''
|
form.employeeId = ''
|
||||||
@@ -409,10 +494,13 @@ const openCreateFromToday = () => {
|
|||||||
}
|
}
|
||||||
form.startDate = today
|
form.startDate = today
|
||||||
form.endDate = today
|
form.endDate = today
|
||||||
|
form.startHalf = 'AM'
|
||||||
|
form.endHalf = 'PM'
|
||||||
form.comment = ''
|
form.comment = ''
|
||||||
isDrawerOpen.value = true
|
isDrawerOpen.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Vérifie la présence d'un férié dans l'intervalle.
|
||||||
const hasHolidayInRange = (startDate: string, endDate: string) => {
|
const hasHolidayInRange = (startDate: string, endDate: string) => {
|
||||||
const start = parseYmd(startDate)
|
const start = parseYmd(startDate)
|
||||||
const end = parseYmd(endDate)
|
const end = parseYmd(endDate)
|
||||||
@@ -430,6 +518,7 @@ const hasHolidayInRange = (startDate: string, endDate: string) => {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Soumission du formulaire: validations + chevauchement + save.
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (isSubmitting.value) return
|
if (isSubmitting.value) return
|
||||||
|
|
||||||
@@ -437,6 +526,14 @@ const handleSubmit = async () => {
|
|||||||
try {
|
try {
|
||||||
const start = normalizeDate(form.startDate)
|
const start = normalizeDate(form.startDate)
|
||||||
const end = normalizeDate(form.endDate)
|
const end = normalizeDate(form.endDate)
|
||||||
|
if (start > end) {
|
||||||
|
window.alert("La date de fin ne peut pas etre avant la date de debut.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (start === end && form.startHalf === 'PM' && form.endHalf === 'AM') {
|
||||||
|
window.alert("La demi-journee de fin ne peut pas etre avant la demi-journee de debut.")
|
||||||
|
return
|
||||||
|
}
|
||||||
if (hasHolidayInRange(start, end)) {
|
if (hasHolidayInRange(start, end)) {
|
||||||
window.alert("Impossible de creer une absence sur un jour ferie.")
|
window.alert("Impossible de creer une absence sur un jour ferie.")
|
||||||
return
|
return
|
||||||
@@ -446,7 +543,40 @@ const handleSubmit = async () => {
|
|||||||
if (editingAbsence.value && absence.id === editingAbsence.value.id) return false
|
if (editingAbsence.value && absence.id === editingAbsence.value.id) return false
|
||||||
const aStart = normalizeDate(absence.startDate)
|
const aStart = normalizeDate(absence.startDate)
|
||||||
const aEnd = normalizeDate(absence.endDate)
|
const aEnd = normalizeDate(absence.endDate)
|
||||||
return start <= aEnd && end >= aStart
|
if (start > aEnd || end < aStart) return false
|
||||||
|
|
||||||
|
const overlapStart = start > aStart ? start : aStart
|
||||||
|
const overlapEnd = end < aEnd ? end : aEnd
|
||||||
|
const overlapStartDate = parseYmd(overlapStart)
|
||||||
|
const overlapEndDate = parseYmd(overlapEnd)
|
||||||
|
if (!overlapStartDate || !overlapEndDate) return false
|
||||||
|
|
||||||
|
for (
|
||||||
|
let currentDate = new Date(overlapStartDate.getTime());
|
||||||
|
currentDate <= overlapEndDate;
|
||||||
|
currentDate.setDate(currentDate.getDate() + 1)
|
||||||
|
) {
|
||||||
|
const dateKey = toYmd(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate())
|
||||||
|
const existingSegments = getSegmentsForDate(
|
||||||
|
aStart,
|
||||||
|
aEnd,
|
||||||
|
absence.startHalf ?? 'AM',
|
||||||
|
absence.endHalf ?? 'PM',
|
||||||
|
dateKey
|
||||||
|
)
|
||||||
|
const newSegments = getSegmentsForDate(
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
form.startHalf,
|
||||||
|
form.endHalf,
|
||||||
|
dateKey
|
||||||
|
)
|
||||||
|
if (existingSegments.some((segment) => newSegments.includes(segment))) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
if (overlaps.length > 0) {
|
if (overlaps.length > 0) {
|
||||||
@@ -466,7 +596,9 @@ const handleSubmit = async () => {
|
|||||||
employeeId: Number(form.employeeId),
|
employeeId: Number(form.employeeId),
|
||||||
typeId: Number(form.typeId),
|
typeId: Number(form.typeId),
|
||||||
startDate: form.startDate,
|
startDate: form.startDate,
|
||||||
|
startHalf: form.startHalf,
|
||||||
endDate: form.endDate,
|
endDate: form.endDate,
|
||||||
|
endHalf: form.endHalf,
|
||||||
comment: form.comment
|
comment: form.comment
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -474,7 +606,9 @@ const handleSubmit = async () => {
|
|||||||
employeeId: Number(form.employeeId),
|
employeeId: Number(form.employeeId),
|
||||||
typeId: Number(form.typeId),
|
typeId: Number(form.typeId),
|
||||||
startDate: form.startDate,
|
startDate: form.startDate,
|
||||||
|
startHalf: form.startHalf,
|
||||||
endDate: form.endDate,
|
endDate: form.endDate,
|
||||||
|
endHalf: form.endHalf,
|
||||||
comment: form.comment
|
comment: form.comment
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -486,6 +620,7 @@ const handleSubmit = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Suppression de l'absence en cours d'édition.
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
if (!editingAbsence.value) return
|
if (!editingAbsence.value) return
|
||||||
|
|
||||||
@@ -497,11 +632,13 @@ const handleDelete = async () => {
|
|||||||
await loadAbsences()
|
await loadAbsences()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Affiche "Prénom N.".
|
||||||
const formatEmployeeName = (employee: Employee) => {
|
const formatEmployeeName = (employee: Employee) => {
|
||||||
const initial = employee.lastName ? `${employee.lastName[0].toUpperCase()}.` : ''
|
const initial = employee.lastName ? `${employee.lastName[0].toUpperCase()}.` : ''
|
||||||
return `${employee.firstName} ${initial}`.trim()
|
return `${employee.firstName} ${initial}`.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Impression PDF de l'intervalle sélectionné.
|
||||||
const { printPdf } = usePdfPrinter()
|
const { printPdf } = usePdfPrinter()
|
||||||
const handlePrint = async () => {
|
const handlePrint = async () => {
|
||||||
const params = new URLSearchParams()
|
const params = new URLSearchParams()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { Absence } from './dto/absence'
|
import type { Absence } from './dto/absence'
|
||||||
|
import type { HalfDay } from './dto/half-day'
|
||||||
import { extractItems } from '~/utils/api'
|
import { extractItems } from '~/utils/api'
|
||||||
|
|
||||||
type ListAbsencesFilters = {
|
type ListAbsencesFilters = {
|
||||||
@@ -31,7 +32,9 @@ export const createAbsence = async (payload: {
|
|||||||
employeeId: number
|
employeeId: number
|
||||||
typeId: number
|
typeId: number
|
||||||
startDate: string
|
startDate: string
|
||||||
|
startHalf: HalfDay
|
||||||
endDate: string
|
endDate: string
|
||||||
|
endHalf: HalfDay
|
||||||
comment?: string
|
comment?: string
|
||||||
}) => {
|
}) => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
@@ -39,7 +42,9 @@ export const createAbsence = async (payload: {
|
|||||||
employee: `/api/employees/${payload.employeeId}`,
|
employee: `/api/employees/${payload.employeeId}`,
|
||||||
type: `/api/absence_types/${payload.typeId}`,
|
type: `/api/absence_types/${payload.typeId}`,
|
||||||
startDate: payload.startDate,
|
startDate: payload.startDate,
|
||||||
|
startHalf: payload.startHalf,
|
||||||
endDate: payload.endDate,
|
endDate: payload.endDate,
|
||||||
|
endHalf: payload.endHalf,
|
||||||
comment: payload.comment
|
comment: payload.comment
|
||||||
}, {
|
}, {
|
||||||
toastSuccessKey: 'success.absence.create',
|
toastSuccessKey: 'success.absence.create',
|
||||||
@@ -52,7 +57,9 @@ export const updateAbsence = async (payload: {
|
|||||||
employeeId: number
|
employeeId: number
|
||||||
typeId: number
|
typeId: number
|
||||||
startDate: string
|
startDate: string
|
||||||
|
startHalf: HalfDay
|
||||||
endDate: string
|
endDate: string
|
||||||
|
endHalf: HalfDay
|
||||||
comment?: string
|
comment?: string
|
||||||
}) => {
|
}) => {
|
||||||
const api = useApi()
|
const api = useApi()
|
||||||
@@ -60,7 +67,9 @@ export const updateAbsence = async (payload: {
|
|||||||
employee: `/api/employees/${payload.employeeId}`,
|
employee: `/api/employees/${payload.employeeId}`,
|
||||||
type: `/api/absence_types/${payload.typeId}`,
|
type: `/api/absence_types/${payload.typeId}`,
|
||||||
startDate: payload.startDate,
|
startDate: payload.startDate,
|
||||||
|
startHalf: payload.startHalf,
|
||||||
endDate: payload.endDate,
|
endDate: payload.endDate,
|
||||||
|
endHalf: payload.endHalf,
|
||||||
comment: payload.comment
|
comment: payload.comment
|
||||||
}, {
|
}, {
|
||||||
toastSuccessKey: 'success.absence.update',
|
toastSuccessKey: 'success.absence.update',
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import type { Employee } from './employee'
|
import type { Employee } from './employee'
|
||||||
import type { AbsenceType } from './absence-type'
|
import type { AbsenceType } from './absence-type'
|
||||||
|
import type { HalfDay } from './half-day'
|
||||||
|
|
||||||
export type Absence = {
|
export type Absence = {
|
||||||
id: number
|
id: number
|
||||||
startDate: string
|
startDate: string
|
||||||
|
startHalf: HalfDay
|
||||||
endDate: string
|
endDate: string
|
||||||
|
endHalf: HalfDay
|
||||||
comment?: string | null
|
comment?: string | null
|
||||||
employee: Employee
|
employee: Employee
|
||||||
type: AbsenceType
|
type: AbsenceType
|
||||||
|
|||||||
6
frontend/services/dto/half-day.ts
Normal file
6
frontend/services/dto/half-day.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export type HalfDay = 'AM' | 'PM'
|
||||||
|
|
||||||
|
export const HALF_DAYS: { value: HalfDay; label: string }[] = [
|
||||||
|
{ value: 'AM', label: 'Matin' },
|
||||||
|
{ value: 'PM', label: 'Après-midi' }
|
||||||
|
]
|
||||||
28
migrations/Version20260210120000.php
Normal file
28
migrations/Version20260210120000.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
final class Version20260210120000 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Add start/end half-day fields to absences';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql("ALTER TABLE absences ADD start_half VARCHAR(2) NOT NULL DEFAULT 'AM'");
|
||||||
|
$this->addSql("ALTER TABLE absences ADD end_half VARCHAR(2) NOT NULL DEFAULT 'PM'");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE absences DROP COLUMN start_half');
|
||||||
|
$this->addSql('ALTER TABLE absences DROP COLUMN end_half');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,10 +50,18 @@ class Absence
|
|||||||
#[Groups(['absence:read'])]
|
#[Groups(['absence:read'])]
|
||||||
private DateTimeInterface $startDate;
|
private DateTimeInterface $startDate;
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'string', length: 2, options: ['default' => 'AM'])]
|
||||||
|
#[Groups(['absence:read'])]
|
||||||
|
private string $startHalf = 'AM';
|
||||||
|
|
||||||
#[ORM\Column(type: 'date')]
|
#[ORM\Column(type: 'date')]
|
||||||
#[Groups(['absence:read'])]
|
#[Groups(['absence:read'])]
|
||||||
private DateTimeInterface $endDate;
|
private DateTimeInterface $endDate;
|
||||||
|
|
||||||
|
#[ORM\Column(type: 'string', length: 2, options: ['default' => 'PM'])]
|
||||||
|
#[Groups(['absence:read'])]
|
||||||
|
private string $endHalf = 'PM';
|
||||||
|
|
||||||
#[ORM\Column(type: 'text', nullable: true)]
|
#[ORM\Column(type: 'text', nullable: true)]
|
||||||
#[Groups(['absence:read'])]
|
#[Groups(['absence:read'])]
|
||||||
private ?string $comment = null;
|
private ?string $comment = null;
|
||||||
@@ -111,6 +119,30 @@ class Absence
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getStartHalf(): string
|
||||||
|
{
|
||||||
|
return $this->startHalf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStartHalf(string $startHalf): self
|
||||||
|
{
|
||||||
|
$this->startHalf = $startHalf;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEndHalf(): string
|
||||||
|
{
|
||||||
|
return $this->endHalf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEndHalf(string $endHalf): self
|
||||||
|
{
|
||||||
|
$this->endHalf = $endHalf;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getComment(): ?string
|
public function getComment(): ?string
|
||||||
{
|
{
|
||||||
return $this->comment;
|
return $this->comment;
|
||||||
|
|||||||
@@ -184,17 +184,38 @@ class AbsencePrintProvider implements ProviderInterface
|
|||||||
|
|
||||||
$absenceStart = DateTimeImmutable::createFromInterface($absence->getStartDate());
|
$absenceStart = DateTimeImmutable::createFromInterface($absence->getStartDate());
|
||||||
$absenceEnd = DateTimeImmutable::createFromInterface($absence->getEndDate());
|
$absenceEnd = DateTimeImmutable::createFromInterface($absence->getEndDate());
|
||||||
|
$startHalf = $absence->getStartHalf();
|
||||||
|
$endHalf = $absence->getEndHalf();
|
||||||
|
|
||||||
$start = max($absenceStart, $from);
|
$start = max($absenceStart, $from);
|
||||||
$end = min($absenceEnd, $to);
|
$end = min($absenceEnd, $to);
|
||||||
|
|
||||||
$current = $start;
|
$current = $start;
|
||||||
while ($current <= $end) {
|
while ($current <= $end) {
|
||||||
$dateKey = $current->format('Y-m-d');
|
$dateKey = $current->format('Y-m-d');
|
||||||
|
$isSameDay = $absenceStart->format('Y-m-d') === $absenceEnd->format('Y-m-d');
|
||||||
|
$isStartDay = $current->format('Y-m-d') === $absenceStart->format('Y-m-d');
|
||||||
|
$isEndDay = $current->format('Y-m-d') === $absenceEnd->format('Y-m-d');
|
||||||
|
$halfLabel = null;
|
||||||
|
|
||||||
|
if ($isSameDay) {
|
||||||
|
if ($startHalf === $endHalf) {
|
||||||
|
$halfLabel = $startHalf;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($isStartDay && 'PM' === $startHalf) {
|
||||||
|
$halfLabel = 'PM';
|
||||||
|
}
|
||||||
|
if ($isEndDay && 'AM' === $endHalf) {
|
||||||
|
$halfLabel = 'AM';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$map[$employeeId][$dateKey] = [
|
$map[$employeeId][$dateKey] = [
|
||||||
'code' => (string) $type->getCode(),
|
'code' => (string) $type->getCode(),
|
||||||
'color' => (string) $type->getColor(),
|
'color' => (string) $type->getColor(),
|
||||||
|
'half' => null !== $halfLabel,
|
||||||
|
'halfLabel' => $halfLabel,
|
||||||
];
|
];
|
||||||
|
|
||||||
$current = $current->add(new DateInterval('P1D'));
|
$current = $current->add(new DateInterval('P1D'));
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
html, body {
|
html, body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 2mm;
|
padding: 4mm;
|
||||||
font-family: Helvetica, sans-serif;
|
font-family: Helvetica, sans-serif;
|
||||||
font-size: 8px;
|
font-size: 8px;
|
||||||
}
|
}
|
||||||
@@ -69,6 +69,11 @@
|
|||||||
font-size: 9px;
|
font-size: 9px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.holiday-code {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.month-separator {
|
.month-separator {
|
||||||
border-right: 4px solid #0a0a0a !important;
|
border-right: 4px solid #0a0a0a !important;
|
||||||
}
|
}
|
||||||
@@ -80,6 +85,49 @@
|
|||||||
.holiday {
|
.holiday {
|
||||||
background: #b3e5fc;
|
background: #b3e5fc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.body-cell {
|
||||||
|
height: 6mm;
|
||||||
|
padding: 0 !important;
|
||||||
|
vertical-align: middle;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.full-cell {
|
||||||
|
display: block;
|
||||||
|
height: 6mm;
|
||||||
|
line-height: 6mm;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.half-table {
|
||||||
|
width: 100%;
|
||||||
|
height: 6mm;
|
||||||
|
border-collapse: collapse;
|
||||||
|
table-layout: fixed;
|
||||||
|
border: 0;
|
||||||
|
border-spacing: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.half-td {
|
||||||
|
height: 3mm;
|
||||||
|
line-height: 3mm;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 7px;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.body-cell table,
|
||||||
|
td.body-cell td {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -198,11 +246,26 @@
|
|||||||
{% set info = absenceMap[employee.id][day.date] ?? null %}
|
{% set info = absenceMap[employee.id][day.date] ?? null %}
|
||||||
{% set isMonthEnd = (not loop.last) and (days[loop.index].date|date('n') != day.date|date('n')) %}
|
{% set isMonthEnd = (not loop.last) and (days[loop.index].date|date('n') != day.date|date('n')) %}
|
||||||
{% set isWeekend = day.date|date('N') in [6, 7] %}
|
{% set isWeekend = day.date|date('N') in [6, 7] %}
|
||||||
<td class="col-day{% if isMonthEnd %} month-separator{% endif %}{% if isWeekend %} weekend{% endif %}{% if isHoliday %} holiday{% endif %}" style="width: {{ dayColWidthMm }}mm;{% if info and not isHoliday %} background-color: {{ info.color }};{% endif %}">
|
<td class="col-day body-cell{% if isMonthEnd %} month-separator{% endif %}{% if isWeekend %} weekend{% endif %}{% if isHoliday %} holiday{% endif %}" style="width: {{ dayColWidthMm }}mm;{% if info and not isHoliday and not info.half %} background-color: {{ info.color }};{% endif %}">
|
||||||
{% if isHoliday %}
|
{% if isHoliday %}
|
||||||
<span class="code">F</span>
|
<span class="full-cell code">Férié</span>
|
||||||
{% elseif info %}
|
{% elseif info %}
|
||||||
<span class="code">{{ info.code }}</span>
|
{% if info.half %}
|
||||||
|
<table class="half-table">
|
||||||
|
<tr>
|
||||||
|
<td class="half-td" style="{% if info.halfLabel == 'AM' %}background-color: {{ info.color }};{% endif %}">
|
||||||
|
{% if info.halfLabel == 'AM' %}{{ info.code }}{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="half-td" style="{% if info.halfLabel == 'PM' %}background-color: {{ info.color }};{% endif %}">
|
||||||
|
{% if info.halfLabel == 'PM' %}{{ info.code }}{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<span class="full-cell code">{{ info.code }}</span>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
Reference in New Issue
Block a user