8313c759c6
Auto Tag Develop / tag (push) Successful in 9s
## Migration modular monolith DDD — Lesstime (0.1 → 3.3) Cette MR regroupe l'intégralité de la refonte en monolithe modulaire (strangler progressif, additif). Elle remplace les MR stackées de Phase 1 (#12–#16), désormais incluses ici. **Ne pas merger avant validation fonctionnelle** : branche destinée à être testée telle quelle. ### Périmètre — 9 modules sous `src/Module/` | Phase | Module | Contenu | |------|--------|---------| | 0.1 | (socle) | infrastructure modulaire, `ModuleInterface`, mapping Doctrine par module | | 0.2 | (socle front) | auto-détection des layers Nuxt sous `frontend/modules/*` | | 1.1 | **Core** | Identité (User/Auth), Notifications, Notifier | | 1.2 | Core | RBAC fin (permissions `module.resource.action`, sidebar gated) | | 1.3 | Core | Audit log (`#[Auditable]`, listener, provider DBAL) | | 2.1 | **TimeTracking** | TimeEntry + MCP + export | | 2.2 | **ProjectManagement** | cœur métier Projets/Tâches + 38 MCP tools | | 2.3 | **Absence** | demandes, soldes, policies, justificatifs | | 2.4 | **Directory** | Clients (migrés) + **Prospects** (nouveau, conversion → Client) | | 2.5 | **Mail** | intégration IMAP OVH + liens tâches | | 2.6 | **Integration** | Gitea / BookStack / Zimbra / Share | | 3.1 | **Reporting** | rapports transverses (DBAL read-only, 0 import inter-module) | | 3.2 | **ClientPortal** | portail client (ROLE_CLIENT cloisonné, tickets, notifications) | | 3.3 | (finition) | nettoyage legacy — `src/Entity` vide, app 100% modulaire | ### Architecture - Découplage inter-modules par **contrats** (`UserInterface`, `ProjectInterface`, `TaskInterface`, `TaskTagInterface`, `ClientInterface`, `ClientTicketInterface`, `LeaveProfileInterface`) + `resolve_target_entities` 100% modulaire (aucune cible legacy). - Repositories : interface `Domain/Repository` + implémentation `Infrastructure/Doctrine`, bindées. - Reporting en DBAL read-only pur (aucun import d'entité d'un autre module). - Chaque migration de module : déplacement à comportement préservé (API publique et noms d'outils MCP inchangés), migrations **additives** uniquement (zéro destructif). ### Sécurité - ROLE_CLIENT cloisonné : un utilisateur client n'accède qu'à `/portal` et à ses propres tickets (filtrés par `allowedProjects`), interdit sur toute l'API interne. - Correctif : interdiction pour un client de créer un lien vers le partage SMB (upload uniquement). ### QA non-régression (branche reconstruite from scratch) - Migrations from scratch + fixtures : OK. - Compilation dev + prod : OK. - **180 tests PHPUnit verts**, php-cs-fixer clean, ~96 routes, **66 outils MCP** tous sous `App\Module\*`. - Smoke test runtime multi-rôles (admin / ROLE_USER / ROLE_CLIENT) : 44 vérifications HTTP, **0 écart**, cloisonnement client étanche. - Build Nuxt OK, 9 layers, 0 import legacy résiduel. ### Points à arbitrer (hors périmètre de cette migration) - Durcissement MCP/IDOR pré-existant (`userId` explicite sans scoping sur certains tools TimeTracking/Absence/TaskDocument) — ticket dédié recommandé. - Validation fonctionnelle de **Prospect** et **ClientPortal** (conçus depuis les specs disque). - **Harmonisation visuelle Malio finale** (3.3) — finition esthétique inter-modules laissée au PO. --- ## ⚠️ Déploiement / migration des données — à ne pas oublier ### 1. Resynchroniser les séquences PostgreSQL après tout import/restore de dump Si la prod (ou tout environnement) est **montée depuis un dump** (`pg_restore` / `COPY`), les lignes sont chargées avec leurs `id` explicites **sans avancer les séquences** → au premier `INSERT` : `duplicate key value violates unique constraint "..._pkey"` (constaté en local sur `notification`, `task`, `time_entry`…). À lancer **juste après chaque restore/import** : ```sql DO $$ DECLARE r RECORD; maxid BIGINT; seq TEXT; BEGIN FOR r IN SELECT table_name, column_name FROM information_schema.columns WHERE table_schema='public' LOOP seq := pg_get_serial_sequence(quote_ident(r.table_name), r.column_name); IF seq IS NOT NULL THEN EXECUTE format('SELECT COALESCE(MAX(%I),0) FROM %I', r.column_name, r.table_name) INTO maxid; PERFORM setval(seq, GREATEST(maxid,1), maxid > 0); END IF; END LOOP; END $$; ``` > Ne concerne **pas** une prod qui tourne déjà (séquences avancées organiquement) — uniquement le cas restore/import. Idempotent, sans risque. ### 2. Fix dénormalisation des collections typées-contrat (code, inclus dans la branche) Les relations **to-many** typées par une interface `Shared\Domain\Contract\*` (`TimeEntry::tags` → `TaskTagInterface`, `Task::collaborators` → `UserInterface`) étaient **indénormalisables par API Platform** (mono-valué OK via IRI, collection KO) → **tout POST/PATCH portant une telle collection renvoyait 400/500**. Corrigé par un dénormaliseur générique `ContractRelationDenormalizer` (réutilise `resolve_target_entities`, zéro couplage par-entité) + test fonctionnel de non-régression. --------- Co-authored-by: Matthieu <contact@malio.fr> Reviewed-on: #17
389 lines
15 KiB
Vue
389 lines
15 KiB
Vue
<template>
|
|
<div>
|
|
<div class="sticky top-8 z-20 bg-white pb-4 sm:top-12">
|
|
<h1 class="text-xl font-bold text-primary-500 sm:text-2xl">
|
|
{{ $t('reporting.title') }}
|
|
</h1>
|
|
|
|
<!-- Filters -->
|
|
<div class="mt-4 flex flex-wrap items-end gap-3">
|
|
<MalioSelect
|
|
v-model="selectedPeriod"
|
|
:options="periodOptions"
|
|
:label="$t('reporting.filters.period')"
|
|
group-class="!w-48"
|
|
text-field="text-sm"
|
|
text-value="text-sm"
|
|
/>
|
|
<div class="w-40">
|
|
<label class="mb-1 block text-sm font-medium text-neutral-700">
|
|
{{ $t('reporting.filters.from') }}
|
|
</label>
|
|
<MalioDate
|
|
v-model="customFrom"
|
|
:disabled="selectedPeriod !== 'custom'"
|
|
group-class="w-full"
|
|
/>
|
|
</div>
|
|
<div class="w-40">
|
|
<label class="mb-1 block text-sm font-medium text-neutral-700">
|
|
{{ $t('reporting.filters.to') }}
|
|
</label>
|
|
<MalioDate
|
|
v-model="customTo"
|
|
:disabled="selectedPeriod !== 'custom'"
|
|
group-class="w-full"
|
|
/>
|
|
</div>
|
|
<MalioSelect
|
|
v-model="selectedProjectId"
|
|
:options="projectOptions"
|
|
:label="$t('reporting.filters.project')"
|
|
:empty-option-label="$t('reporting.filters.allProjects')"
|
|
group-class="!w-44"
|
|
text-field="text-sm"
|
|
text-value="text-sm"
|
|
/>
|
|
<MalioSelect
|
|
v-model="selectedUserId"
|
|
:options="userOptions"
|
|
:label="$t('reporting.filters.user')"
|
|
:empty-option-label="$t('reporting.filters.allUsers')"
|
|
group-class="!w-44"
|
|
text-field="text-sm"
|
|
text-value="text-sm"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Loading -->
|
|
<div v-if="isLoading" class="mt-12 flex items-center justify-center">
|
|
<p class="text-neutral-400">{{ $t('common.loading') }}</p>
|
|
</div>
|
|
|
|
<template v-else>
|
|
<!-- Section 1 : Time per project -->
|
|
<section class="mt-8 rounded-xl border border-neutral-100 bg-neutral-50 p-5">
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-sm font-semibold text-neutral-700">
|
|
{{ $t('reporting.sections.timePerProject') }}
|
|
</h2>
|
|
<MalioButton
|
|
icon-name="mdi:download"
|
|
icon-position="left"
|
|
button-class="w-auto px-3 py-1.5 text-sm"
|
|
:label="$t('reporting.export')"
|
|
:disabled="timePerProject.length === 0"
|
|
@click="exportTimePerProject"
|
|
/>
|
|
</div>
|
|
<div class="mt-4 grid gap-6 lg:grid-cols-2">
|
|
<DataTable
|
|
:columns="projectColumns"
|
|
:items="timePerProject"
|
|
:empty-message="$t('reporting.empty')"
|
|
>
|
|
<template #cell-hours="{ item }">
|
|
{{ formatHours((item as TimePerProject).hours) }}
|
|
</template>
|
|
</DataTable>
|
|
<ReportingDoughnut
|
|
:labels="timePerProject.map(r => r.projectName)"
|
|
:values="timePerProject.map(r => round(r.hours))"
|
|
/>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- Section 2 : Time per user -->
|
|
<section class="mt-6 rounded-xl border border-neutral-100 bg-neutral-50 p-5">
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-sm font-semibold text-neutral-700">
|
|
{{ $t('reporting.sections.timePerUser') }}
|
|
</h2>
|
|
<MalioButton
|
|
icon-name="mdi:download"
|
|
icon-position="left"
|
|
button-class="w-auto px-3 py-1.5 text-sm"
|
|
:label="$t('reporting.export')"
|
|
:disabled="timePerUser.length === 0"
|
|
@click="exportTimePerUser"
|
|
/>
|
|
</div>
|
|
<div class="mt-4 grid gap-6 lg:grid-cols-2">
|
|
<DataTable
|
|
:columns="userColumns"
|
|
:items="timePerUser"
|
|
:empty-message="$t('reporting.empty')"
|
|
>
|
|
<template #cell-hours="{ item }">
|
|
{{ formatHours((item as TimePerUser).hours) }}
|
|
</template>
|
|
</DataTable>
|
|
<ReportingBarChart
|
|
:labels="timePerUser.map(r => r.fullName || r.username)"
|
|
:values="timePerUser.map(r => round(r.hours))"
|
|
color="#10b981"
|
|
/>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- Section 3 : Tasks by status -->
|
|
<section class="mt-6 rounded-xl border border-neutral-100 bg-neutral-50 p-5">
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-sm font-semibold text-neutral-700">
|
|
{{ $t('reporting.sections.tasksByStatus') }}
|
|
</h2>
|
|
<MalioButton
|
|
icon-name="mdi:download"
|
|
icon-position="left"
|
|
button-class="w-auto px-3 py-1.5 text-sm"
|
|
:label="$t('reporting.export')"
|
|
:disabled="tasksByStatus.length === 0"
|
|
@click="exportTasksByStatus"
|
|
/>
|
|
</div>
|
|
<div class="mt-4 grid gap-6 lg:grid-cols-2">
|
|
<DataTable
|
|
:columns="statusColumns"
|
|
:items="tasksByStatus"
|
|
:empty-message="$t('reporting.empty')"
|
|
/>
|
|
<ReportingDoughnut
|
|
:labels="tasksByStatus.map(r => r.statusLabel)"
|
|
:values="tasksByStatus.map(r => r.count)"
|
|
/>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- Section 4 : Absences by type -->
|
|
<section class="mt-6 rounded-xl border border-neutral-100 bg-neutral-50 p-5">
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-sm font-semibold text-neutral-700">
|
|
{{ $t('reporting.sections.absencesByType') }}
|
|
</h2>
|
|
<MalioButton
|
|
icon-name="mdi:download"
|
|
icon-position="left"
|
|
button-class="w-auto px-3 py-1.5 text-sm"
|
|
:label="$t('reporting.export')"
|
|
:disabled="absencesByType.length === 0"
|
|
@click="exportAbsencesByType"
|
|
/>
|
|
</div>
|
|
<div class="mt-4 grid gap-6 lg:grid-cols-2">
|
|
<DataTable
|
|
:columns="absenceColumns"
|
|
:items="absenceRows"
|
|
:empty-message="$t('reporting.empty')"
|
|
/>
|
|
<ReportingBarChart
|
|
:labels="absencesByType.map(r => absenceTypeLabel(r.type))"
|
|
:values="absencesByType.map(r => r.totalDays)"
|
|
color="#f59e0b"
|
|
/>
|
|
</div>
|
|
</section>
|
|
</template>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import type { DataTableColumn } from '~/components/ui/DataTable.vue'
|
|
import type {
|
|
AbsencesByType,
|
|
ReportFilters,
|
|
TasksByStatus,
|
|
TimePerProject,
|
|
TimePerUser,
|
|
} from '~/modules/reporting/services/dto/reporting'
|
|
import { useReportingService } from '~/modules/reporting/services/reporting'
|
|
import {
|
|
useReportingFilters,
|
|
type ReportPeriodKey,
|
|
} from '~/modules/reporting/composables/useReportingFilters'
|
|
import { useCsvExport } from '~/modules/reporting/composables/useCsvExport'
|
|
import type { Project } from '~/modules/project-management/services/dto/project'
|
|
import type { UserData } from '~/services/dto/user-data'
|
|
import { useProjectService } from '~/modules/project-management/services/projects'
|
|
import { useUserService } from '~/services/users'
|
|
|
|
definePageMeta({ middleware: ['admin'] })
|
|
|
|
const { t } = useI18n()
|
|
useHead({ title: t('reporting.title') })
|
|
|
|
const reportingService = useReportingService()
|
|
const projectService = useProjectService()
|
|
const userService = useUserService()
|
|
const { rangeForPreset, thisMonth } = useReportingFilters()
|
|
const { downloadCsv } = useCsvExport()
|
|
|
|
// --- Filters state ---
|
|
const selectedPeriod = ref<ReportPeriodKey>('thisMonth')
|
|
const initialRange = thisMonth()
|
|
const customFrom = ref<string | null>(initialRange.from)
|
|
const customTo = ref<string | null>(initialRange.to)
|
|
const selectedProjectId = ref<number | null>(null)
|
|
const selectedUserId = ref<number | null>(null)
|
|
|
|
const periodOptions = computed(() => [
|
|
{ label: t('reporting.periods.thisMonth'), value: 'thisMonth' },
|
|
{ label: t('reporting.periods.lastMonth'), value: 'lastMonth' },
|
|
{ label: t('reporting.periods.custom'), value: 'custom' },
|
|
])
|
|
|
|
const projects = ref<Project[]>([])
|
|
const users = ref<UserData[]>([])
|
|
|
|
const projectOptions = computed(() =>
|
|
projects.value.map(p => ({ label: p.name, value: p.id })),
|
|
)
|
|
const userOptions = computed(() =>
|
|
users.value.map(u => ({
|
|
label: [u.firstName, u.lastName].filter(Boolean).join(' ') || u.username,
|
|
value: u.id,
|
|
})),
|
|
)
|
|
|
|
// --- Effective range (preset → concrete dates) ---
|
|
const activeFilters = computed<ReportFilters>(() => ({
|
|
from: customFrom.value ?? initialRange.from,
|
|
to: customTo.value ?? initialRange.to,
|
|
projectId: selectedProjectId.value,
|
|
userId: selectedUserId.value,
|
|
}))
|
|
|
|
// When a non-custom preset is picked, sync the date pickers.
|
|
watch(selectedPeriod, (key) => {
|
|
if (key !== 'custom') {
|
|
const range = rangeForPreset(key, {
|
|
from: customFrom.value ?? initialRange.from,
|
|
to: customTo.value ?? initialRange.to,
|
|
})
|
|
customFrom.value = range.from
|
|
customTo.value = range.to
|
|
}
|
|
})
|
|
|
|
// --- Report data ---
|
|
const timePerProject = ref<TimePerProject[]>([])
|
|
const timePerUser = ref<TimePerUser[]>([])
|
|
const tasksByStatus = ref<TasksByStatus[]>([])
|
|
const absencesByType = ref<AbsencesByType[]>([])
|
|
const isLoading = ref(true)
|
|
|
|
const absenceRows = computed(() =>
|
|
absencesByType.value.map(r => ({ ...r, typeLabel: absenceTypeLabel(r.type) })),
|
|
)
|
|
|
|
// --- Columns ---
|
|
const projectColumns: DataTableColumn[] = [
|
|
{ key: 'projectName', label: t('reporting.columns.project'), primary: true },
|
|
{ key: 'hours', label: t('reporting.columns.hours') },
|
|
{ key: 'entryCount', label: t('reporting.columns.entries') },
|
|
]
|
|
const userColumns: DataTableColumn[] = [
|
|
{ key: 'fullName', label: t('reporting.columns.user'), primary: true },
|
|
{ key: 'hours', label: t('reporting.columns.hours') },
|
|
{ key: 'entryCount', label: t('reporting.columns.entries') },
|
|
]
|
|
const statusColumns: DataTableColumn[] = [
|
|
{ key: 'statusLabel', label: t('reporting.columns.status'), primary: true },
|
|
{ key: 'count', label: t('reporting.columns.count') },
|
|
]
|
|
const absenceColumns: DataTableColumn[] = [
|
|
{ key: 'typeLabel', label: t('reporting.columns.type'), primary: true },
|
|
{ key: 'count', label: t('reporting.columns.count') },
|
|
{ key: 'totalDays', label: t('reporting.columns.days') },
|
|
]
|
|
|
|
// --- Helpers ---
|
|
function round(value: number): number {
|
|
return Math.round(value * 100) / 100
|
|
}
|
|
|
|
function formatHours(h: number): string {
|
|
const hours = Math.floor(h)
|
|
const mins = Math.round((h - hours) * 60)
|
|
return mins > 0 ? `${hours}h${String(mins).padStart(2, '0')}` : `${hours}h`
|
|
}
|
|
|
|
function absenceTypeLabel(type: string): string {
|
|
const key = `reporting.absenceTypes.${type}`
|
|
const label = t(key)
|
|
return label === key ? type : label
|
|
}
|
|
|
|
// --- Loading ---
|
|
async function loadReferenceData() {
|
|
const [proj, usr] = await Promise.all([
|
|
projectService.getAll(),
|
|
userService.getAll(),
|
|
])
|
|
projects.value = proj
|
|
users.value = usr
|
|
}
|
|
|
|
async function loadReports() {
|
|
isLoading.value = true
|
|
try {
|
|
const filters = activeFilters.value
|
|
const [tpp, tpu, tbs, abt] = await Promise.all([
|
|
reportingService.timePerProject(filters),
|
|
reportingService.timePerUser(filters),
|
|
reportingService.tasksByStatus(filters),
|
|
reportingService.absencesByType(filters),
|
|
])
|
|
timePerProject.value = tpp
|
|
timePerUser.value = tpu
|
|
tasksByStatus.value = tbs
|
|
absencesByType.value = abt
|
|
} finally {
|
|
isLoading.value = false
|
|
}
|
|
}
|
|
|
|
// Reload reports whenever the effective filters change.
|
|
watch(activeFilters, () => {
|
|
loadReports()
|
|
}, { deep: true })
|
|
|
|
onMounted(async () => {
|
|
await loadReferenceData()
|
|
await loadReports()
|
|
})
|
|
|
|
// --- CSV export ---
|
|
function exportTimePerProject() {
|
|
downloadCsv('rapport-temps-par-projet', timePerProject.value, [
|
|
{ header: t('reporting.columns.project'), value: r => r.projectName },
|
|
{ header: t('reporting.columns.code'), value: r => r.projectCode },
|
|
{ header: t('reporting.columns.hours'), value: r => round(r.hours) },
|
|
{ header: t('reporting.columns.entries'), value: r => r.entryCount },
|
|
])
|
|
}
|
|
|
|
function exportTimePerUser() {
|
|
downloadCsv('rapport-temps-par-utilisateur', timePerUser.value, [
|
|
{ header: t('reporting.columns.user'), value: r => r.fullName || r.username },
|
|
{ header: t('reporting.columns.hours'), value: r => round(r.hours) },
|
|
{ header: t('reporting.columns.entries'), value: r => r.entryCount },
|
|
])
|
|
}
|
|
|
|
function exportTasksByStatus() {
|
|
downloadCsv('rapport-taches-par-statut', tasksByStatus.value, [
|
|
{ header: t('reporting.columns.status'), value: r => r.statusLabel },
|
|
{ header: t('reporting.columns.count'), value: r => r.count },
|
|
])
|
|
}
|
|
|
|
function exportAbsencesByType() {
|
|
downloadCsv('rapport-absences-par-type', absencesByType.value, [
|
|
{ header: t('reporting.columns.type'), value: r => absenceTypeLabel(r.type) },
|
|
{ header: t('reporting.columns.count'), value: r => r.count },
|
|
{ header: t('reporting.columns.days'), value: r => r.totalDays },
|
|
])
|
|
}
|
|
</script>
|