feat carte modification HFC at calendar

This commit is contained in:
Tolotsoa 2025-09-11 16:53:30 +03:00
parent ce18ebdb9a
commit 4957a67ba5
33 changed files with 452 additions and 245 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,8 +26,8 @@
:class="{ 'property-title__input--readonly': isReadOnly }"> :class="{ 'property-title__input--readonly': isReadOnly }">
<input v-if="!isReadOnly" <input v-if="!isReadOnly"
v-focus v-focus
type="text" :type="type"
:placeholder="t('calendar', 'Nom et prénom du défunt')" :placeholder="computedPlaceholder"
:value="value" :value="value"
@input.prevent.stop="changeValue"> @input.prevent.stop="changeValue">
<!-- eslint-disable-next-line vue/singleline-html-element-content-newline --> <!-- eslint-disable-next-line vue/singleline-html-element-content-newline -->
@ -53,6 +53,19 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
type: {
type: String,
default: 'text',
},
placeholder: {
type: String,
default: '',
},
},
computed: {
computedPlaceholder() {
return this.placeholder || this.t('calendar', 'Nom et prénom du défunt')
},
}, },
methods: { methods: {
changeValue(event) { changeValue(event) {

View File

@ -118,6 +118,14 @@ export default {
return this.calendarObjectInstance?.embalmer ?? null return this.calendarObjectInstance?.embalmer ?? null
}, },
lieuDeces() {
return this.calendarObjectInstance?.lieuDeces ?? null
},
dateNaissance() {
return this.calendarObjectInstance?.dateNaissance ?? null
},
/** /**
* Returns the isleave property * Returns the isleave property
* *
@ -155,7 +163,6 @@ export default {
return this.calendarObjectInstance?.isPrivate ?? false return this.calendarObjectInstance?.isPrivate ?? false
}, },
/** /**
* Returns the description or null if the event is still loading * Returns the description or null if the event is still loading
* *
@ -449,23 +456,23 @@ export default {
return false return false
}, },
/** /**
* Returns the absence type * Returns the absence type
* *
* @return {string|null} * @return {string|null}
*/ */
absenceType() { absenceType() {
const isleave = this.calendarObjectInstance?.isLeave ?? false const isleave = this.calendarObjectInstance?.isLeave ?? false
const absenceType = this.calendarObjectInstance?.absenceType ?? null const absenceType = this.calendarObjectInstance?.absenceType ?? null
if (absenceType) { if (absenceType) {
return this.calendarObjectInstance?.absenceType return this.calendarObjectInstance?.absenceType
} }
if (isleave && !absenceType ) { if (isleave && !absenceType) {
return 'LEAVE' return 'LEAVE'
} }
return ''; return ''
}, },
}, },
methods: { methods: {
@ -583,7 +590,7 @@ export default {
this.isLoading = true this.isLoading = true
this.isSaving = true this.isSaving = true
try { try {
this.setPendingCalendar(false); this.setPendingCalendar(false)
await this.$store.dispatch('saveCalendarObjectInstance', { await this.$store.dispatch('saveCalendarObjectInstance', {
thisAndAllFuture, thisAndAllFuture,
calendarId: this.calendarId, calendarId: this.calendarId,
@ -601,8 +608,6 @@ export default {
setPendingCalendar(isPending = true) { setPendingCalendar(isPending = true) {
this.calendarObjectInstance.eventComponent.isCalendarPending = isPending this.calendarObjectInstance.eventComponent.isCalendarPending = isPending
this.calendarObjectInstance.isCalendarPending = isPending this.calendarObjectInstance.isCalendarPending = isPending
}, },
async savePendingCalendar(thisAndAllFuture = false) { async savePendingCalendar(thisAndAllFuture = false) {
if (!this.calendarObject) { if (!this.calendarObject) {
@ -620,7 +625,7 @@ export default {
this.isSaving = true this.isSaving = true
try { try {
this.setPendingCalendar(); this.setPendingCalendar();
await this.$store.dispatch('saveCalendarObjectInstance', { await this.$store.dispatch('saveCalendarObjectInstance', {
thisAndAllFuture, thisAndAllFuture,
calendarId: this.calendarId, calendarId: this.calendarId,
}) })
@ -761,7 +766,6 @@ export default {
embalmer, embalmer,
}) })
}, },
/** /**
* Updates the start date of this event * Updates the start date of this event
@ -827,7 +831,7 @@ export default {
toggleIsPrivate(isPrivate) { toggleIsPrivate(isPrivate) {
this.$store.commit('toggleIsPrivate', { this.$store.commit('toggleIsPrivate', {
calendarObjectInstance: this.calendarObjectInstance, calendarObjectInstance: this.calendarObjectInstance,
isPrivate isPrivate,
}) })
}, },
@ -835,23 +839,23 @@ export default {
// * Toggles the event between all-day and timed // * Toggles the event between all-day and timed
// */ // */
// toggleIsLeave(isLeave) { // toggleIsLeave(isLeave) {
// this.$store.commit('toggleIsLeave', { // this.$store.commit('toggleIsLeave', {
// calendarObjectInstance: this.calendarObjectInstance, // calendarObjectInstance: this.calendarObjectInstance,
// isLeave // isLeave
// }) // })
// }, // },
/** /**
* Toggles the event pending * Toggles the event pending
* @param isCalendarPending
*/ */
toggleIsCalendarPending(isCalendarPending) { toggleIsCalendarPending(isCalendarPending) {
this.$store.commit('toggleIsCalendarPending', { this.$store.commit('toggleIsCalendarPending', {
calendarObjectInstance: this.calendarObjectInstance, calendarObjectInstance: this.calendarObjectInstance,
isCalendarPending isCalendarPending,
}) })
}, },
/** /**
* Resets the internal state after changing the viewed calendar-object * Resets the internal state after changing the viewed calendar-object
*/ */
@ -895,7 +899,31 @@ export default {
calendarObjectInstance: this.calendarObjectInstance, calendarObjectInstance: this.calendarObjectInstance,
absenceType, absenceType,
}) })
} },
/**
* Updates the lieu de décès of this event
*
* @param {string} lieuDeces New lieu de décès
*/
updateLieuDeces(lieuDeces) {
this.$store.commit('changeLieuDeces', {
calendarObjectInstance: this.calendarObjectInstance,
lieuDeces,
})
},
/**
* Updates the date de naissance of this event
*
* @param {string} dateNaissance New date de naissance
*/
updateDateNaissance(dateNaissance) {
this.$store.commit('changeDateNaissance', {
calendarObjectInstance: this.calendarObjectInstance,
dateNaissance,
})
},
}, },
/** /**
* This is executed before entering the Editor routes * This is executed before entering the Editor routes

View File

@ -21,7 +21,7 @@
*/ */
import { getDateFromDateTimeValue } from '../utils/date.js' import { getDateFromDateTimeValue } from '../utils/date.js'
import { DurationValue, DateTimeValue } from '@nextcloud/calendar-js' import { DurationValue, DateTimeValue, Property } from '@nextcloud/calendar-js'
import { getHexForColorName, getClosestCSS3ColorNameForHex } from '../utils/color.js' import { getHexForColorName, getClosestCSS3ColorNameForHex } from '../utils/color.js'
import { mapAlarmComponentToAlarmObject } from './alarm.js' import { mapAlarmComponentToAlarmObject } from './alarm.js'
import { mapAttendeePropertyToAttendeeObject } from './attendee.js' import { mapAttendeePropertyToAttendeeObject } from './attendee.js'
@ -52,24 +52,28 @@ const getDefaultEventObject = (props = {}) => Object.assign({}, {
endTimezoneId: null, endTimezoneId: null,
// Indicator whether or not event is all-day // Indicator whether or not event is all-day
isAllDay: false, isAllDay: false,
//leave // leave
isLeave: false, isLeave: false,
//calendarPending // calendarPending
isCalendarPending: false, isCalendarPending: false,
// Whether or not the user is allowed to toggle the all-day checkbox // Whether or not the user is allowed to toggle the all-day checkbox
canModifyAllDay: true, canModifyAllDay: true,
// Location that the event takes places in // Location that the event takes places in
location: null, location: null,
//client of the event // client of the event
client : null, client: null,
//embalmer(Thanato) of the event // embalmer(Thanato) of the event
embalmer : null, embalmer: null,
//absenceType // lieu de décès
absenceType : null, lieuDeces: null,
//Private // date de naissance
dateNaissance: null,
// absenceType
absenceType: null,
// Private
isPrivate: false, isPrivate: false,
//comment of the event // comment of the event
comment : null, comment: null,
// description of the event // description of the event
description: null, description: null,
// Access class of the event (PUBLIC, PRIVATE, CONFIDENTIAL) // Access class of the event (PUBLIC, PRIVATE, CONFIDENTIAL)
@ -118,10 +122,12 @@ const mapEventComponentToEventObject = (eventComponent) => {
isCalendarPending: false, isCalendarPending: false,
canModifyAllDay: eventComponent.canModifyAllDay(), canModifyAllDay: eventComponent.canModifyAllDay(),
location: eventComponent.location, location: eventComponent.location,
client : "CLIENT", client: 'CLIENT',
embalmer : "TEST", embalmer: 'TEST',
absenceType : "", lieuDeces: null,
comment : "", dateNaissance: null,
absenceType: '',
comment: '',
description: eventComponent.description, description: eventComponent.description,
accessClass: eventComponent.accessClass, accessClass: eventComponent.accessClass,
status: eventComponent.status, status: eventComponent.status,
@ -207,39 +213,46 @@ const mapEventComponentToEventObject = (eventComponent) => {
} }
} }
if(eventComponent.hasProperty('CLIENT')){ if (eventComponent.hasProperty('CLIENT')) {
eventObject.client = eventComponent.getFirstPropertyFirstValue('CLIENT'); eventObject.client = eventComponent.getFirstPropertyFirstValue('CLIENT')
} }
if(eventComponent.hasProperty('EMBALMER')){ if (eventComponent.hasProperty('EMBALMER')) {
eventObject.embalmer = eventComponent.getFirstPropertyFirstValue('EMBALMER'); eventObject.embalmer = eventComponent.getFirstPropertyFirstValue('EMBALMER')
} }
if(eventComponent.hasProperty('COMMENT')){ if (eventComponent.hasProperty('COMMENT')) {
eventObject.comment = eventComponent.getFirstPropertyFirstValue('COMMENT'); eventObject.comment = eventComponent.getFirstPropertyFirstValue('COMMENT')
} }
if(eventComponent.hasProperty('ISPRIVATE')){ if (eventComponent.hasProperty('ISPRIVATE')) {
eventObject.isPrivate = eventComponent.getFirstPropertyFirstValue('ISPRIVATE') === '1' ? true : false; eventObject.isPrivate = eventComponent.getFirstPropertyFirstValue('ISPRIVATE') === '1'
} }
if (eventComponent.hasProperty('ABSENCETYPE')) {
if(eventComponent.hasProperty('ABSENCETYPE')){ eventObject.absenceType = eventComponent.getFirstPropertyFirstValue('ABSENCETYPE')
eventObject.absenceType = eventComponent.getFirstPropertyFirstValue('ABSENCETYPE');
} else {
}else{ if (eventComponent.hasProperty('ISLEAVE')) {
if(eventComponent.hasProperty('ISLEAVE')){ if (eventComponent.getFirstPropertyFirstValue('ISLEAVE') === '1') {
if( eventComponent.getFirstPropertyFirstValue('ISLEAVE') === '1'){ eventObject.absenceType = 'LEAVE'
eventObject.absenceType = 'LEAVE';
} }
} }
} }
if(eventComponent.hasProperty('ISCALENDARPENDING')){ if (eventComponent.hasProperty('ISCALENDARPENDING')) {
eventObject.isCalendarPending = eventComponent.getFirstPropertyFirstValue('ISCALENDARPENDING') === '1' ? true : false; eventObject.isCalendarPending = eventComponent.getFirstPropertyFirstValue('ISCALENDARPENDING') === '1'
} }
return eventObject; if (eventComponent.hasProperty('LIEUDECES')) {
eventObject.lieuDeces = eventComponent.getFirstPropertyFirstValue('LIEUDECES')
}
if (eventComponent.hasProperty('DATENAISSANCE')) {
eventObject.dateNaissance = eventComponent.getFirstPropertyFirstValue('DATENAISSANCE')
}
return eventObject
} }
/** /**
@ -253,6 +266,20 @@ const copyCalendarObjectInstanceIntoEventComponent = (eventObject, eventComponen
eventComponent.location = eventObject.location eventComponent.location = eventObject.location
eventComponent.client = eventObject.client eventComponent.client = eventObject.client
eventComponent.embalmer = eventObject.embalmer eventComponent.embalmer = eventObject.embalmer
if (eventObject.lieuDeces) {
eventComponent.deleteAllProperties('LIEUDECES')
const lieuDecesProperty = new Property('LIEUDECES', eventObject.lieuDeces)
eventComponent.addProperty(lieuDecesProperty)
}
// Gérer dateNaissance comme une propriété ICS personnalisée
if (eventObject.dateNaissance) {
eventComponent.deleteAllProperties('DATENAISSANCE')
const dateNaissanceProperty = new Property('DATENAISSANCE', eventObject.dateNaissance)
eventComponent.addProperty(dateNaissanceProperty)
}
eventComponent.isPrivate = eventObject.isPrivate eventComponent.isPrivate = eventObject.isPrivate
eventComponent.isCalendarPending = eventObject.isCalendarPending eventComponent.isCalendarPending = eventObject.isCalendarPending
eventComponent.comment = eventObject.comment eventComponent.comment = eventObject.comment

View File

@ -22,7 +22,6 @@
import { translate as t } from '@nextcloud/l10n' import { translate as t } from '@nextcloud/l10n'
import { getDefaultCategories } from '../defaults/defaultCategories.js' import { getDefaultCategories } from '../defaults/defaultCategories.js'
/** /**
* Gets all supported RFC properties * Gets all supported RFC properties
* *
@ -146,7 +145,7 @@ const getRFCProperties = () => {
readableName: t('calendar', 'Type d\'absence'), readableName: t('calendar', 'Type d\'absence'),
placeholder: t('calendar', 'Type d\'absence'), placeholder: t('calendar', 'Type d\'absence'),
}, },
embalmers: { embalmers: {
readableName: t('calendar', 'Embalmers'), readableName: t('calendar', 'Embalmers'),
icon: 'Human', icon: 'Human',
@ -157,7 +156,6 @@ const getRFCProperties = () => {
tagPlaceholder: t('calendar', 'Choose thanatopracteur'), tagPlaceholder: t('calendar', 'Choose thanatopracteur'),
options: [], options: [],
}, },
embalmer: { embalmer: {
readableName: t('calendar', 'Embalmer'), readableName: t('calendar', 'Embalmer'),
@ -183,7 +181,21 @@ const getRFCProperties = () => {
placeholder: t('calendar', 'Commentaires'), placeholder: t('calendar', 'Commentaires'),
tagPlaceholder: t('calendar', 'Commentaires'), tagPlaceholder: t('calendar', 'Commentaires'),
options: [], options: [],
defaultNumberOfRows: 4 defaultNumberOfRows: 4,
},
lieuDeces: {
readableName: t('calendar', 'Lieu du décès'),
placeholder: t('calendar', 'Lieu du décès'),
icon: 'MapMarker',
type: 'text',
},
dateNaissance: {
readableName: t('calendar', 'Date de naissance'),
placeholder: t('calendar', 'Date de naissance'),
icon: 'Tag',
type: 'date',
}, },
} }
} }

View File

@ -285,13 +285,14 @@ const mutations = {
calendarObjectInstance.eventComponent.endDate.addDuration(DurationValue.fromSeconds(60 * 60 * 24)) calendarObjectInstance.eventComponent.endDate.addDuration(DurationValue.fromSeconds(60 * 60 * 24))
} }
}, },
/** /**
* Is private * Is private
* *
* @param {object} state The Vuex state * @param {object} state The Vuex state
* @param {object} data The destructuring object * @param {object} data The destructuring object
* @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.calendarObjectInstance The calendarObjectInstance object
* @param data.isPrivate
*/ */
toggleIsPrivate(state, { calendarObjectInstance, isPrivate }) { toggleIsPrivate(state, { calendarObjectInstance, isPrivate }) {
calendarObjectInstance.eventComponent.isPrivate = isPrivate calendarObjectInstance.eventComponent.isPrivate = isPrivate
@ -403,6 +404,40 @@ const mutations = {
calendarObjectInstance.embalmer = embalmer calendarObjectInstance.embalmer = embalmer
}, },
/**
* Change the lieu de décès of an event
*
* @param {object} state The Vuex state
* @param {object} data The destructuring object
* @param {object} data.calendarObjectInstance The calendarObjectInstance object
* @param {string} data.lieuDeces New lieu de décès to set
*/
changeLieuDeces(state, { calendarObjectInstance, lieuDeces }) {
calendarObjectInstance.eventComponent.deleteAllProperties('LIEUDECES')
if (lieuDeces && lieuDeces.trim() !== '') {
const lieuDecesProperty = new Property('LIEUDECES', lieuDeces)
calendarObjectInstance.eventComponent.addProperty(lieuDecesProperty)
}
calendarObjectInstance.lieuDeces = lieuDeces
},
/**
* Change the date de naissance of an event
*
* @param {object} state The Vuex state
* @param {object} data The destructuring object
* @param {object} data.calendarObjectInstance The calendarObjectInstance object
* @param {string} data.dateNaissance New date de naissance to set
*/
changeDateNaissance(state, { calendarObjectInstance, dateNaissance }) {
calendarObjectInstance.eventComponent.deleteAllProperties('DATENAISSANCE')
if (dateNaissance && dateNaissance.trim() !== '') {
const dateNaissanceProperty = new Property('DATENAISSANCE', dateNaissance)
calendarObjectInstance.eventComponent.addProperty(dateNaissanceProperty)
}
calendarObjectInstance.dateNaissance = dateNaissance
},
/** /**
* Change the absence type of an event * Change the absence type of an event
* *
@ -410,6 +445,7 @@ const mutations = {
* @param {object} data The destructuring object * @param {object} data The destructuring object
* @param {object} data.calendarObjectInstance The calendarObjectInstance object * @param {object} data.calendarObjectInstance The calendarObjectInstance object
* @param {string} data.embalmer New embalmer to set * @param {string} data.embalmer New embalmer to set
* @param data.absenceType
*/ */
changeAbsenceType(state, { calendarObjectInstance, absenceType }) { changeAbsenceType(state, { calendarObjectInstance, absenceType }) {
calendarObjectInstance.eventComponent.absenceType = absenceType ?? null calendarObjectInstance.eventComponent.absenceType = absenceType ?? null
@ -1786,12 +1822,14 @@ const actions = {
let client = eventComponent.client; let client = eventComponent.client;
let additionalFieldWasUpdated = let additionalFieldWasUpdated =
eventComponent.client != null || eventComponent.client != null ||
eventComponent.isPrivate != null || eventComponent.isPrivate != null ||
eventComponent.comment != null || eventComponent.comment != null ||
eventComponent.isLeave != null || eventComponent.isLeave != null ||
eventComponent.absenceType || eventComponent.absenceType ||
eventComponent.isCalendarPending != null; eventComponent.isCalendarPending != null ||
state.calendarObjectInstance.lieuDeces != null ||
state.calendarObjectInstance.dateNaissance != null;
if (eventComponent.isDirty() || additionalFieldWasUpdated) { if (eventComponent.isDirty() || additionalFieldWasUpdated) {
const isForkedItem = eventComponent.primaryItem !== null const isForkedItem = eventComponent.primaryItem !== null
let original = null let original = null

View File

@ -22,15 +22,13 @@
--> -->
<template> <template>
<Popover <Popover ref="popover"
ref="popover"
:shown="showPopover" :shown="showPopover"
:auto-hide="false" :auto-hide="false"
:placement="placement" :placement="placement"
:boundary="boundaryElement" :boundary="boundaryElement"
popover-base-class="event-popover" popover-base-class="event-popover"
:triggers="[]" :triggers="[]">
>
<div class="event-popover__inner"> <div class="event-popover__inner">
<template v-if="isLoading && !isSaving"> <template v-if="isLoading && !isSaving">
<PopoverLoadingIndicator /> <PopoverLoadingIndicator />
@ -48,10 +46,8 @@
</Actions> </Actions>
</div> </div>
<EmptyContent <EmptyContent :name="$t('calendar', 'Event does not exist')"
:name="$t('calendar', 'Event does not exist')" :description="error">
:description="error"
>
<template #icon> <template #icon>
<CalendarBlank :size="20" decorative /> <CalendarBlank :size="20" decorative />
</template> </template>
@ -61,28 +57,22 @@
<template v-else> <template v-else>
<div class="event-popover__top-right-actions"> <div class="event-popover__top-right-actions">
<Actions v-if="!isLoading && !isError && !isNew" :force-menu="true"> <Actions v-if="!isLoading && !isError && !isNew" :force-menu="true">
<ActionLink <ActionLink v-if="!hideEventExport && hasDownloadURL"
v-if="!hideEventExport && hasDownloadURL" :href="downloadURL">
:href="downloadURL"
>
<template #icon> <template #icon>
<Download :size="20" decorative /> <Download :size="20" decorative />
</template> </template>
{{ $t("calendar", "Export") }} {{ $t("calendar", "Export") }}
</ActionLink> </ActionLink>
<ActionButton <ActionButton v-if="!canCreateRecurrenceException && !isReadOnly"
v-if="!canCreateRecurrenceException && !isReadOnly" @click="duplicateEvent()">
@click="duplicateEvent()"
>
<template #icon> <template #icon>
<ContentDuplicate :size="20" decorative /> <ContentDuplicate :size="20" decorative />
</template> </template>
{{ $t("calendar", "Duplicate") }} {{ $t("calendar", "Duplicate") }}
</ActionButton> </ActionButton>
<ActionButton <ActionButton v-if="canDelete && !canCreateRecurrenceException"
v-if="canDelete && !canCreateRecurrenceException" @click="deleteAndLeave(false)">
@click="deleteAndLeave(false)"
>
<template #icon> <template #icon>
<Delete :size="20" decorative /> <Delete :size="20" decorative />
</template> </template>
@ -117,21 +107,16 @@
</Actions> </Actions>
</div> </div>
<CalendarPickerHeader <CalendarPickerHeader :value="selectedCalendar"
:value="selectedCalendar"
:calendars="calendars" :calendars="calendars"
:is-read-only="isReadOnlyOrViewing || !canModifyCalendar" :is-read-only="isReadOnlyOrViewing || !canModifyCalendar"
@update:value="changeCalendar" @update:value="changeCalendar" />
/>
<PropertyTitle <PropertyTitle :value="titleOrPlaceholder"
:value="titleOrPlaceholder"
:is-read-only="isReadOnlyOrViewing" :is-read-only="isReadOnlyOrViewing"
@update:value="updateTitle" @update:value="updateTitle" />
/>
<PropertyTitleTimePicker <PropertyTitleTimePicker :start-date="startDate"
:start-date="startDate"
:start-timezone="startTimezone" :start-timezone="startTimezone"
:end-date="endDate" :end-date="endDate"
:end-timezone="endTimezone" :end-timezone="endTimezone"
@ -143,8 +128,24 @@
@update-start-timezone="updateStartTimezone" @update-start-timezone="updateStartTimezone"
@update-end-date="updateEndDate" @update-end-date="updateEndDate"
@update-end-timezone="updateEndTimezone" @update-end-timezone="updateEndTimezone"
@toggle-all-day="toggleAllDay" @toggle-all-day="toggleAllDay" />
/>
<PropertyTitle class="property-lieu-deces"
:is-read-only="isReadOnly"
:prop-model="rfcProps.lieuDeces"
:value="lieuDeces"
:placeholder="'Lieu du décès'"
type="text"
@update:value="updateLieuDeces" />
<PropertyTitle class="property-date-naissance"
:is-read-only="isReadOnly"
:prop-model="rfcProps.dateNaissance"
:value="dateNaissance"
:placeholder="'Date de naissance'"
type="date"
title="Saisissez la date de naissance du défunt"
@update:value="updateDateNaissance" />
<div style='display:flex ;margin-left: 7%;'> <div style='display:flex ;margin-left: 7%;'>
<div style='width:70%'> <div style='width:70%'>
@ -162,7 +163,6 @@
:is-private="isPrivate" :is-private="isPrivate"
@toggle-is-private="toggleIsPrivate"/> @toggle-is-private="toggleIsPrivate"/>
</div> --> </div> -->
</div> </div>
<!-- <PropertyIsLeave <!-- <PropertyIsLeave
@ -297,7 +297,7 @@ import InvitationResponseButtons from "../components/Editor/InvitationResponseBu
import CalendarPickerHeader from "../components/Editor/CalendarPickerHeader.vue"; import CalendarPickerHeader from "../components/Editor/CalendarPickerHeader.vue";
import InviteesList from "../components/Editor/Invitees/InviteesList.vue"; import InviteesList from "../components/Editor/Invitees/InviteesList.vue";
import CalendarBlank from "vue-material-design-icons/CalendarBlank.vue"; import CalendarBlank from 'vue-material-design-icons/CalendarBlank.vue';
import Close from "vue-material-design-icons/Close.vue"; import Close from "vue-material-design-icons/Close.vue";
import Delete from "vue-material-design-icons/Delete.vue"; import Delete from "vue-material-design-icons/Delete.vue";
import Download from "vue-material-design-icons/Download.vue"; import Download from "vue-material-design-icons/Download.vue";
@ -361,7 +361,7 @@ export default {
boundaryElement: null, boundaryElement: null,
isVisible: true, isVisible: true,
isViewing: true, isViewing: true,
defuntUrl: undefined, defuntUrl: undefined
}; };
}, },
computed: { computed: {
@ -607,7 +607,7 @@ export default {
}, },
viewDefunt() { viewDefunt() {
window.open(this.defuntUrl, "_blank"); window.open(this.defuntUrl, "_blank");
}, }
}, },
}; };
</script> </script>

View File

@ -1144,19 +1144,39 @@ class Bdd
/** /**
* Insert Defunt * Insert Defunt
*/ */
public function insertDefuntByName($name) public function insertDefuntByName($name, $lieuDeces = null, $dateNaissance = null)
{ {
// Gérer la date de naissance par défaut si null ou vide
if (empty($dateNaissance) || trim($dateNaissance) === '') {
$dateNaissance = '1973-11-11';
}
// Gérer le lieu de décès (peut être null)
$lieuDecesValue = !empty($lieuDeces) ? trim($lieuDeces) : null;
$sql = "INSERT INTO `".$this->tableprefix."defunt` ( $sql = "INSERT INTO `".$this->tableprefix."defunt` (
`id_nextcloud`, `nom`, `sexe`, `date_naissance`, `ref_pacemaker`, `date`, `id_nextcloud`, `nom`, `sexe`, `date_naissance`, `ref_pacemaker`, `date`,
`corpulence`, `observations_corps`, `observations_generales` `corpulence`, `observations_corps`, `observations_generales`, `lieu_deces`
) VALUES (?,?,?,?,?,NOW(),?,?,?);"; ) VALUES (?,?,?,?,?,NOW(),?,?,?,?);";
$this->execSQLNoData($sql, array('admin',$name, 'm', '1973-11-11', '', '', '', ''));
$this->execSQLNoData($sql, array(
'admin',
$name,
'm',
$dateNaissance,
'',
'',
'',
'',
$lieuDecesValue
));
return true; return true;
} }
public function insertDefuntByNameAndReturnId($name) public function insertDefuntByNameAndReturnId($name, $lieuDeces = null, $dateNaissance = null)
{ {
$this->insertDefuntByName($name); $this->insertDefuntByName($name, $lieuDeces, $dateNaissance);
return $this->getLastDefuntIdByName($name); return $this->getLastDefuntIdByName($name);
} }
@ -4109,12 +4129,13 @@ class Bdd
return null; return null;
} }
private function getDefuntById($defuntId) public function getDefuntById($defuntId)
{ {
$sql = "SELECT $sql = "SELECT
defunt.id as id, defunt.id as id,
defunt.nom as defunt_nom, defunt.nom as defunt_nom,
defunt.lieu_deces as lieu_deces, defunt.lieu_deces as lieu_deces,
defunt.date_naissance as date_naissance,
devis.id as devis_id devis.id as devis_id
FROM ".$this->tableprefix."defunt as defunt FROM ".$this->tableprefix."defunt as defunt
LEFT JOIN ".$this->tableprefix."devis as devis on defunt.id = devis.id_defunt LEFT JOIN ".$this->tableprefix."devis as devis on defunt.id = devis.id_defunt
@ -4457,23 +4478,60 @@ COMMENTAIRES: ".$comment;
$this->execSQLNoData($sql, [DevisMentionConstant::CANCELED,$devisId]); $this->execSQLNoData($sql, [DevisMentionConstant::CANCELED,$devisId]);
} }
private function updateDefuntByName($defuntId, $requestedDefuntName) /**
* Met à jour un défunt avec tous ses détails
*/
public function updateDefuntByNameAndDetails($defuntId, $name, $lieuDeces = null, $dateNaissance = null)
{ {
$sql = "UPDATE ".$this->tableprefix."defunt as defunt // Gérer la date de naissance par défaut si null ou vide
SET defunt.nom = ? if (empty($dateNaissance) || trim($dateNaissance) === '') {
WHERE defunt.id = ?"; $dateNaissance = '1973-11-11';
$this->execSQLNoData($sql, [$requestedDefuntName,$defuntId]); }
// Gérer le lieu de décès (peut être null)
$lieuDecesValue = !empty($lieuDeces) ? trim($lieuDeces) : null;
$sql = "UPDATE `".$this->tableprefix."defunt` SET
`nom` = ?,
`lieu_deces` = ?,
`date_naissance` = ?
WHERE `id` = ?";
$this->execSQLNoData($sql, array(
$name,
$lieuDecesValue,
$dateNaissance,
$defuntId
));
return true;
} }
public function createOrUpdateDefuntByNameAndReturnDefuntId($defuntId, $currentDefuntName, $requestedDefuntName) /**
* Version simplifiée pour rétrocompatibilité
*/
public function updateDefuntByName($defuntId, $name)
{ {
if($defuntId != null) { return $this->updateDefuntByNameAndDetails($defuntId, $name);
}
public function createOrUpdateDefuntByNameAndReturnDefuntId($defuntId, $currentDefuntName, $requestedDefuntName, $lieuDeces = null, $dateNaissance = null)
{
if ($defuntId != null) {
// Récupérer les données actuelles du défunt pour comparaison
$currentDefunt = $this->getDefuntById($defuntId);
$defuntNameIsUpdated = $currentDefuntName != $requestedDefuntName; $defuntNameIsUpdated = $currentDefuntName != $requestedDefuntName;
if($defuntNameIsUpdated) { $lieuDecesIsUpdated = ($currentDefunt['lieu_deces'] ?? null) != $lieuDeces;
$this->updateDefuntByName($defuntId, $requestedDefuntName); $dateNaissanceIsUpdated = ($currentDefunt['date_naissance'] ?? null) != $dateNaissance;
// Mettre à jour si au moins un champ a changé
if ($defuntNameIsUpdated || $lieuDecesIsUpdated || $dateNaissanceIsUpdated) {
$this->updateDefuntByNameAndDetails($defuntId, $requestedDefuntName, $lieuDeces, $dateNaissance);
} }
} else { } else {
$this->insertDefuntByName($requestedDefuntName); // Créer un nouveau défunt
$this->insertDefuntByName($requestedDefuntName, $lieuDeces, $dateNaissance);
$defunt = $this->getLastDefuntIdByName($requestedDefuntName); $defunt = $this->getLastDefuntIdByName($requestedDefuntName);
$defuntId = $defunt['id']; $defuntId = $defunt['id'];
} }
@ -5225,21 +5283,22 @@ COMMENTAIRES: ".$comment;
return $devisList; return $devisList;
} }
public function getDevisIdsGroupByFactureId($factureId,$mentionFilters = []){ public function getDevisIdsGroupByFactureId($factureId, $mentionFilters = [])
{
$sql = "SELECT devis.id $sql = "SELECT devis.id
FROM ".$this->tableprefix."devis as devis FROM ".$this->tableprefix."devis as devis
WHERE devis.fk_facture_id = ? "; WHERE devis.fk_facture_id = ? ";
$conditions = [$factureId]; $conditions = [$factureId];
if(!empty($mentionFilters)){ if(!empty($mentionFilters)) {
$mentionsFilterPlaceholders = implode(',', array_fill(0, count($mentionFilters), '?')); $mentionsFilterPlaceholders = implode(',', array_fill(0, count($mentionFilters), '?'));
$sql .= " AND devis.mentions IN ($mentionsFilterPlaceholders)"; $sql .= " AND devis.mentions IN ($mentionsFilterPlaceholders)";
$conditions = array_merge($conditions, $mentionFilters); $conditions = array_merge($conditions, $mentionFilters);
} }
$sql.= ";"; $sql .= ";";
$devisList = $this->execSQLNoJsonReturn($sql,$conditions); $devisList = $this->execSQLNoJsonReturn($sql, $conditions);
$devisIds = []; $devisIds = [];
foreach($devisList as $devis){ foreach($devisList as $devis) {
$devisIds[] = $devis['id']; $devisIds[] = $devis['id'];
} }
return $devisIds; return $devisIds;
@ -5686,7 +5745,7 @@ COMMENTAIRES: ".$comment;
private function getProductsTotalPrices($products) private function getProductsTotalPrices($products)
{ {
$configs = json_decode($this->getConfiguration(BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD)); $configs = json_decode($this->getConfiguration(BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD));
$currentConfig = $configs[0]; $currentConfig = $configs[0];
$totalHt = 0; $totalHt = 0;
$totalTtc = 0; $totalTtc = 0;
foreach ($products as $product) { foreach ($products as $product) {
@ -5702,11 +5761,12 @@ COMMENTAIRES: ".$comment;
]; ];
} }
private function getDevisIdsListByFactureId($factureId){ private function getDevisIdsListByFactureId($factureId)
{
$factureData = $this->getFactureByFactureId(factureId: $factureId); $factureData = $this->getFactureByFactureId(factureId: $factureId);
$isFactureGroupOfDevis = $factureData["facture_type"] == FactureTypeConstant::TYPE_GROUP; $isFactureGroupOfDevis = $factureData["facture_type"] == FactureTypeConstant::TYPE_GROUP;
$factureDevisIdsList = []; $factureDevisIdsList = [];
if($isFactureGroupOfDevis){ if($isFactureGroupOfDevis) {
$isFactureForSingleClient = $factureData['fk_client_id'] != null && $factureData['fk_client_id'] != 0; $isFactureForSingleClient = $factureData['fk_client_id'] != null && $factureData['fk_client_id'] != 0;
$devisMentionFilters = [ $devisMentionFilters = [
DevisMentionConstant::FACTURED_FORMATTED, DevisMentionConstant::FACTURED_FORMATTED,
@ -5715,24 +5775,25 @@ COMMENTAIRES: ".$comment;
$devis = $this->getDevisByFkFactureId($factureId); $devis = $this->getDevisByFkFactureId($factureId);
$factureGroupIsRelatedToAnyDevis = $devis != null; $factureGroupIsRelatedToAnyDevis = $devis != null;
if (!$factureGroupIsRelatedToAnyDevis) { if (!$factureGroupIsRelatedToAnyDevis) {
if($isFactureForSingleClient){ if($isFactureForSingleClient) {
$factureDevisIdsList = $this->getDevisIdsByClientIdAndMonthYear( $factureDevisIdsList = $this->getDevisIdsByClientIdAndMonthYear(
$factureData['fk_client_id'], $factureData['fk_client_id'],
$factureData['month'], $factureData['month'],
$factureData['year'],$devisMentionFilters $factureData['year'],
$devisMentionFilters
); );
}else{ } else {
$factureDevisIdsList = $this->getDevisIdsByClientGroupFacturationIdAndMonthYear( $factureDevisIdsList = $this->getDevisIdsByClientGroupFacturationIdAndMonthYear(
$factureData['fk_client_group_facturation_id'], $factureData['fk_client_group_facturation_id'],
$factureData['month'], $factureData['month'],
$factureData['year'],$devisMentionFilters $factureData['year'],
); $devisMentionFilters
);
} }
}else{ } else {
$factureDevisIdsList = $this->getDevisIdsGroupByFactureId($factureId, $devisMentionFilters ); $factureDevisIdsList = $this->getDevisIdsGroupByFactureId($factureId, $devisMentionFilters);
} }
} } else {
else{
$factureDevisIdsList = $factureData['id_devis'] ? [$factureData['id_devis']] : []; $factureDevisIdsList = $factureData['id_devis'] ? [$factureData['id_devis']] : [];
} }
return $factureDevisIdsList; return $factureDevisIdsList;
@ -5744,7 +5805,7 @@ COMMENTAIRES: ".$comment;
$totalHt = 0; $totalHt = 0;
$totalTtc = 0; $totalTtc = 0;
$tva = 0; $tva = 0;
foreach($factureDevisIds as $devisId){ foreach($factureDevisIds as $devisId) {
$products = $this->getDevisProduits($devisId); $products = $this->getDevisProduits($devisId);
$totalPrices = $this->getProductsTotalPrices($products); $totalPrices = $this->getProductsTotalPrices($products);
$totalHt += $totalPrices["total_ht"]; $totalHt += $totalPrices["total_ht"];

View File

@ -34,35 +34,33 @@ use Psr\Log\LoggerInterface;
class CalendarObjectCreatedListener implements IEventListener class CalendarObjectCreatedListener implements IEventListener
{ {
/** @var LoggerInterface */
private $logger;
/** @var LoggerInterface */ /** @var GestionService */
private $logger; private $gestionService;
/** @var GestionService */ public function __construct(
private $gestionService; LoggerInterface $logger,
GestionService $gestionService
public function __construct( ) {
LoggerInterface $logger, $this->logger = $logger;
GestionService $gestionService $this->gestionService = $gestionService;
) { }
$this->logger = $logger;
$this->gestionService = $gestionService;
}
public function handle(Event $event): void
{
if (!($event instanceof CalendarObjectCreatedEvent)) {
return;
}
$calendarData = $event->getObjectData();
try {
$vCalendarString = $calendarData["calendardata"];
$this->gestionService->HandleCreatedCalendarObject($vCalendarString);
} catch (\OC\OCS\Exception $e) {
$this->logger->debug("Error while handling created calendar object: " . $e->getMessage());
} catch (\Throwable $e) {
$this->logger->debug("Error while handling created calendar object: " . $e->getMessage());
}
}
public function handle(Event $event): void
{
if (!($event instanceof CalendarObjectCreatedEvent)) {
return;
}
$calendarData = $event->getObjectData();
try {
$vCalendarString = $calendarData["calendardata"];
$this->gestionService->HandleCreatedCalendarObject($vCalendarString);
} catch (\OC\OCS\Exception $e) {
$this->logger->debug("Error while handling created calendar object: " . $e->getMessage());
} catch (\Throwable $e) {
$this->logger->debug("Error while handling created calendar object: " . $e->getMessage());
}
}
} }

View File

@ -35,35 +35,34 @@ use Psr\Log\LoggerInterface;
class CalendarObjectUpdatedListener implements IEventListener class CalendarObjectUpdatedListener implements IEventListener
{ {
/** @var LoggerInterface */
private $logger;
/** @var LoggerInterface */ /** @var GestionService */
private $logger; private $gestionService;
/** @var GestionService */ public function __construct(
private $gestionService; LoggerInterface $logger,
GestionService $gestionService
) {
$this->logger = $logger;
$this->gestionService = $gestionService;
}
public function __construct( public function handle(Event $event): void
LoggerInterface $logger, {
GestionService $gestionService if (!($event instanceof CalendarObjectUpdatedEvent)) {
) { return;
$this->logger = $logger; }
$this->gestionService = $gestionService; $calendarData = $event->getObjectData();
} try {
$vCalendarString = $calendarData["calendardata"];
public function handle(Event $event): void $this->gestionService->HandleUpdatedCalendarObject($vCalendarString);
{ } catch (\OC\OCS\Exception $e) {
if (!($event instanceof CalendarObjectUpdatedEvent)) { $this->logger->debug("Error while handling updated calendar object: " . $e->getMessage());
return; } catch (\Throwable $e) {
} $this->logger->debug("Error while handling updated calendar object: " . $e->getMessage());
$calendarData = $event->getObjectData(); }
try { }
$vCalendarString = $calendarData["calendardata"];
$this->gestionService->HandleUpdatedCalendarObject($vCalendarString);
} catch (\OC\OCS\Exception $e) {
$this->logger->debug("Error while handling updated calendar object: " . $e->getMessage());
} catch (\Throwable $e) {
$this->logger->debug("Error while handling updated calendar object: " . $e->getMessage());
}
}
} }

View File

@ -50,7 +50,7 @@ class GestionService
private $userConnectedUuid; private $userConnectedUuid;
/** @var DevisPdfService */ /** @var DevisPdfService */
private $devisPdfService; private $devisPdfService;
public function __construct( public function __construct(
Bdd $gestionBdd, Bdd $gestionBdd,
@ -58,12 +58,11 @@ class GestionService
TalkService $talkService, TalkService $talkService,
IUserSession $userSession, IUserSession $userSession,
DevisPdfService $devisPdfService DevisPdfService $devisPdfService
) { ) {
$this->logger = $logger; $this->logger = $logger;
$this->gestionBdd = $gestionBdd; $this->gestionBdd = $gestionBdd;
$this->talkService = $talkService; $this->talkService = $talkService;
$this->devisPdfService = $devisPdfService; $this->devisPdfService = $devisPdfService;
try { try {
$this->userConnectedUuid = $userSession->getUser()->getUID(); $this->userConnectedUuid = $userSession->getUser()->getUID();
@ -163,9 +162,10 @@ class GestionService
return $calendarStartDate; return $calendarStartDate;
} }
private function GetIsPivateFromVCalendarString(string $vCalendarString): bool{ private function GetIsPivateFromVCalendarString(string $vCalendarString): bool
{
$isPrivateValue = VCalendarHelpers::GetValueFromKeyInVCalendarString(VCalendarPropertyConstant::PROPERTY_IS_PRIVATE, $vCalendarString); $isPrivateValue = VCalendarHelpers::GetValueFromKeyInVCalendarString(VCalendarPropertyConstant::PROPERTY_IS_PRIVATE, $vCalendarString);
return $isPrivateValue === "1" ? true : false; return $isPrivateValue === "1" ? true : false;
} }
@ -182,7 +182,16 @@ class GestionService
private function UpdateDevisDataByVCalendarString($devis, $vCalendarString) private function UpdateDevisDataByVCalendarString($devis, $vCalendarString)
{ {
$requestedDefuntName = $this->GetCalendarSummaryFromVCalendarString($vCalendarString); $requestedDefuntName = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
$defuntId = $this->gestionBdd->createOrUpdateDefuntByNameAndReturnDefuntId($devis['defunt_id'], $devis['defunt_nom'], $requestedDefuntName);
$lieuDeces = $this->getLieuDecesFromVCalendarString($vCalendarString);
$dateNaissance = $this->getDateNaissanceFromVCalendarString($vCalendarString);
$defuntId = $this->gestionBdd->createOrUpdateDefuntByNameAndReturnDefuntId($devis['defunt_id'], $devis['defunt_nom'], $requestedDefuntName, $lieuDeces, $dateNaissance);
file_put_contents(
'/var/www/html/data/nextcloud_calendar_debug.log',
date('Y-m-d H:i:s') . " - defuntId: " . $defuntId . "\n",
FILE_APPEND
);
$this->gestionBdd->updateDevisDefunt($devis['id'], $defuntId, $devis['defunt_id']); $this->gestionBdd->updateDevisDefunt($devis['id'], $defuntId, $devis['defunt_id']);
$requestedClientId = $this->GetClientIdFromVCalendarString($vCalendarString); $requestedClientId = $this->GetClientIdFromVCalendarString($vCalendarString);
@ -206,6 +215,11 @@ class GestionService
private function CheckIfDevisIsAlreadyUpdated($devis, $vCalendarString) private function CheckIfDevisIsAlreadyUpdated($devis, $vCalendarString)
{ {
$requestedDefuntName = $this->GetCalendarSummaryFromVCalendarString($vCalendarString); $requestedDefuntName = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
$requestedLieuDeces = $this->getLieuDecesFromVCalendarString($vCalendarString);
$requestedDateNaissance = $this->getDateNaissanceFromVCalendarString($vCalendarString);
$currentDefunt = $this->gestionBdd->getDefuntById($devis['defunt_id']);
$requestedClientId = $this->GetClientIdFromVCalendarString($vCalendarString); $requestedClientId = $this->GetClientIdFromVCalendarString($vCalendarString);
$requestLocationId = $this->GetLocationIdFromVCalendarString($vCalendarString); $requestLocationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
$requestedDevisComment = $this->GetDevisCommentFromVCalendarString($vCalendarString); $requestedDevisComment = $this->GetDevisCommentFromVCalendarString($vCalendarString);
@ -226,15 +240,17 @@ class GestionService
$devis['lieu_id'] == $requestLocationId && $devis['lieu_id'] == $requestLocationId &&
$devis['comment'] == $requestedDevisComment && $devis['comment'] == $requestedDevisComment &&
$requestedArticleIds == $articleDevisIds && $requestedArticleIds == $articleDevisIds &&
$devis['date'] == $requestedDevisDate; $devis['date'] == $requestedDevisDate &&
($currentDefunt['lieu_deces'] ?? null) == $requestedLieuDeces &&
($currentDefunt['date_naissance'] ?? null) == $requestedDateNaissance;
} }
public function HandleUpdatedCalendarObject(string $vCalendarString) public function HandleUpdatedCalendarObject(string $vCalendarString)
{ {
try { try {
$isPrivate = $this->GetIsPivateFromVCalendarString($vCalendarString); $isPrivate = $this->GetIsPivateFromVCalendarString($vCalendarString);
$absenceType = VCalendarHelpers::GetValueFromKeyInVCalendarString('ABSENCETYPE',$vCalendarString); $absenceType = VCalendarHelpers::GetValueFromKeyInVCalendarString('ABSENCETYPE', $vCalendarString);
if ($isPrivate || $absenceType ) { if ($isPrivate || $absenceType) {
//from devis calendar to leave calendar //from devis calendar to leave calendar
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString); $calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid); $devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
@ -296,10 +312,10 @@ class GestionService
$month, $month,
$year $year
); );
if($oldThanatoTrajet != null){ if($oldThanatoTrajet != null) {
$thereIsThanatoDevisRattachedToLigneTrajetForADate = $this->gestionBdd->thereIsThanatoDevisRattachedToLigneTrajetForADate($devis['date'], $oldThanatoTrajet['id'] ); $thereIsThanatoDevisRattachedToLigneTrajetForADate = $this->gestionBdd->thereIsThanatoDevisRattachedToLigneTrajetForADate($devis['date'], $oldThanatoTrajet['id']);
if(!$thereIsThanatoDevisRattachedToLigneTrajetForADate){ if(!$thereIsThanatoDevisRattachedToLigneTrajetForADate) {
$this->gestionBdd->deleteThanatoLigneTrajetForADateByIdTrajet($devis['date'], $oldThanatoTrajet['id'] ); $this->gestionBdd->deleteThanatoLigneTrajetForADateByIdTrajet($devis['date'], $oldThanatoTrajet['id']);
} }
} }
$this->gestionBdd->updateDevisThanato($devis['id'], $thanato['id']); $this->gestionBdd->updateDevisThanato($devis['id'], $thanato['id']);
@ -319,10 +335,10 @@ class GestionService
public function HandleCreatedCalendarObject(string $vCalendarString) public function HandleCreatedCalendarObject(string $vCalendarString)
{ {
try { try {
$isPrivate = $this->GetIsPivateFromVCalendarString($vCalendarString); $isPrivate = $this->GetIsPivateFromVCalendarString($vCalendarString);
$absenceType = VCalendarHelpers::GetValueFromKeyInVCalendarString('ABSENCETYPE',$vCalendarString); $absenceType = VCalendarHelpers::GetValueFromKeyInVCalendarString('ABSENCETYPE', $vCalendarString);
if($isPrivate || $absenceType){ if($isPrivate || $absenceType) {
//Nothing to do manage fo a private calendar //Nothing to do manage fo a private calendar
return; return;
} }
@ -336,11 +352,15 @@ class GestionService
$thanatoId = $this->GetThanatoIdFromVCalendarString($vCalendarString); $thanatoId = $this->GetThanatoIdFromVCalendarString($vCalendarString);
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString); $calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$userName = $this->GetThanatoNameFromVCalendarString($vCalendarString); $userName = $this->GetThanatoNameFromVCalendarString($vCalendarString);
$lieuDeces = $this->getLieuDecesFromVCalendarString($vCalendarString);
$dateNaissance = $this->getDateNaissanceFromVCalendarString($vCalendarString);
$devisAlreadyCreated = $this->IsDevisAlreadyCreated($clientId, $locationId, $thanatoId, $calendarSummary, $calendarUuid); $devisAlreadyCreated = $this->IsDevisAlreadyCreated($clientId, $locationId, $thanatoId, $calendarSummary, $calendarUuid);
if ($devisAlreadyCreated) { if ($devisAlreadyCreated) {
return; return;
} }
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary); $defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary, $lieuDeces, $dateNaissance);
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString); $calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
$devisComment = $this->GetDevisCommentFromVCalendarString($vCalendarString); $devisComment = $this->GetDevisCommentFromVCalendarString($vCalendarString);
$devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId, $clientId, $locationId, $defuntId, $calendarUuid, $calendarStartDate, $devisComment); $devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId, $clientId, $locationId, $defuntId, $calendarUuid, $calendarStartDate, $devisComment);
@ -352,14 +372,13 @@ class GestionService
$devisTalkMessage = $this->gestionBdd->getDevisTalkRoomMessage($devisId, $userName); $devisTalkMessage = $this->gestionBdd->getDevisTalkRoomMessage($devisId, $userName);
$this->talkService->sendDevisTalkNotifications($devisTalkMessage, $userName, $this->userConnectedUuid); $this->talkService->sendDevisTalkNotifications($devisTalkMessage, $userName, $this->userConnectedUuid);
$this->gestionBdd->createDevisTrajetFromVCalendar($devisId, $userName); $this->gestionBdd->createDevisTrajetFromVCalendar($devisId, $userName);
$this->devisPdfService->generateDevisPdfByDevisId($devisId , $this->userConnectedUuid); $this->devisPdfService->generateDevisPdfByDevisId($devisId, $this->userConnectedUuid);
} catch (\OC\OCS\Exception $e) { } catch (\OC\OCS\Exception $e) {
$this->logger->debug("Error while handling created calendar object: " . $e->getMessage()); $this->logger->debug("Error while handling created calendar object: " . $e->getMessage());
} catch (\Throwable $e) { } catch (\Throwable $e) {
$this->logger->debug("Error while handling created calendar object: " . $e->getMessage()); $this->logger->debug("Error while handling created calendar object: " . $e->getMessage());
} }
} }
private function GetThanatoNameFromVCalendarString($vCalendarString) private function GetThanatoNameFromVCalendarString($vCalendarString)
{ {
@ -393,4 +412,16 @@ class GestionService
$mapped = array_map('trim', $articles); $mapped = array_map('trim', $articles);
return $mapped; return $mapped;
} }
private function getLieuDecesFromVCalendarString(string $vCalendarString): ?string
{
$lieuDecesValue = VCalendarHelpers::GetValueFromKeyInVCalendarString("LIEUDECES", $vCalendarString);
return !empty($lieuDecesValue) ? trim($lieuDecesValue) : null;
}
private function getDateNaissanceFromVCalendarString(string $vCalendarString): ?string
{
$dateNaissanceValue = VCalendarHelpers::GetValueFromKeyInVCalendarString("DATENAISSANCE", $vCalendarString);
return !empty($dateNaissanceValue) ? trim($dateNaissanceValue) : null;
}
} }