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

View File

@ -118,6 +118,14 @@ export default {
return this.calendarObjectInstance?.embalmer ?? null
},
lieuDeces() {
return this.calendarObjectInstance?.lieuDeces ?? null
},
dateNaissance() {
return this.calendarObjectInstance?.dateNaissance ?? null
},
/**
* Returns the isleave property
*
@ -155,7 +163,6 @@ export default {
return this.calendarObjectInstance?.isPrivate ?? false
},
/**
* Returns the description or null if the event is still loading
*
@ -461,11 +468,11 @@ export default {
if (absenceType) {
return this.calendarObjectInstance?.absenceType
}
if (isleave && !absenceType ) {
if (isleave && !absenceType) {
return 'LEAVE'
}
return '';
return ''
},
},
methods: {
@ -583,7 +590,7 @@ export default {
this.isLoading = true
this.isSaving = true
try {
this.setPendingCalendar(false);
this.setPendingCalendar(false)
await this.$store.dispatch('saveCalendarObjectInstance', {
thisAndAllFuture,
calendarId: this.calendarId,
@ -601,8 +608,6 @@ export default {
setPendingCalendar(isPending = true) {
this.calendarObjectInstance.eventComponent.isCalendarPending = isPending
this.calendarObjectInstance.isCalendarPending = isPending
},
async savePendingCalendar(thisAndAllFuture = false) {
if (!this.calendarObject) {
@ -762,7 +767,6 @@ export default {
})
},
/**
* Updates the start date of this event
*
@ -827,7 +831,7 @@ export default {
toggleIsPrivate(isPrivate) {
this.$store.commit('toggleIsPrivate', {
calendarObjectInstance: this.calendarObjectInstance,
isPrivate
isPrivate,
})
},
@ -843,15 +847,15 @@ export default {
/**
* Toggles the event pending
* @param isCalendarPending
*/
toggleIsCalendarPending(isCalendarPending) {
this.$store.commit('toggleIsCalendarPending', {
calendarObjectInstance: this.calendarObjectInstance,
isCalendarPending
isCalendarPending,
})
},
/**
* Resets the internal state after changing the viewed calendar-object
*/
@ -895,7 +899,31 @@ export default {
calendarObjectInstance: this.calendarObjectInstance,
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

View File

@ -21,7 +21,7 @@
*/
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 { mapAlarmComponentToAlarmObject } from './alarm.js'
import { mapAttendeePropertyToAttendeeObject } from './attendee.js'
@ -52,24 +52,28 @@ const getDefaultEventObject = (props = {}) => Object.assign({}, {
endTimezoneId: null,
// Indicator whether or not event is all-day
isAllDay: false,
//leave
// leave
isLeave: false,
//calendarPending
// calendarPending
isCalendarPending: false,
// Whether or not the user is allowed to toggle the all-day checkbox
canModifyAllDay: true,
// Location that the event takes places in
location: null,
//client of the event
client : null,
//embalmer(Thanato) of the event
embalmer : null,
//absenceType
absenceType : null,
//Private
// client of the event
client: null,
// embalmer(Thanato) of the event
embalmer: null,
// lieu de décès
lieuDeces: null,
// date de naissance
dateNaissance: null,
// absenceType
absenceType: null,
// Private
isPrivate: false,
//comment of the event
comment : null,
// comment of the event
comment: null,
// description of the event
description: null,
// Access class of the event (PUBLIC, PRIVATE, CONFIDENTIAL)
@ -118,10 +122,12 @@ const mapEventComponentToEventObject = (eventComponent) => {
isCalendarPending: false,
canModifyAllDay: eventComponent.canModifyAllDay(),
location: eventComponent.location,
client : "CLIENT",
embalmer : "TEST",
absenceType : "",
comment : "",
client: 'CLIENT',
embalmer: 'TEST',
lieuDeces: null,
dateNaissance: null,
absenceType: '',
comment: '',
description: eventComponent.description,
accessClass: eventComponent.accessClass,
status: eventComponent.status,
@ -207,39 +213,46 @@ const mapEventComponentToEventObject = (eventComponent) => {
}
}
if(eventComponent.hasProperty('CLIENT')){
eventObject.client = eventComponent.getFirstPropertyFirstValue('CLIENT');
if (eventComponent.hasProperty('CLIENT')) {
eventObject.client = eventComponent.getFirstPropertyFirstValue('CLIENT')
}
if(eventComponent.hasProperty('EMBALMER')){
eventObject.embalmer = eventComponent.getFirstPropertyFirstValue('EMBALMER');
if (eventComponent.hasProperty('EMBALMER')) {
eventObject.embalmer = eventComponent.getFirstPropertyFirstValue('EMBALMER')
}
if(eventComponent.hasProperty('COMMENT')){
eventObject.comment = eventComponent.getFirstPropertyFirstValue('COMMENT');
if (eventComponent.hasProperty('COMMENT')) {
eventObject.comment = eventComponent.getFirstPropertyFirstValue('COMMENT')
}
if(eventComponent.hasProperty('ISPRIVATE')){
eventObject.isPrivate = eventComponent.getFirstPropertyFirstValue('ISPRIVATE') === '1' ? true : false;
if (eventComponent.hasProperty('ISPRIVATE')) {
eventObject.isPrivate = eventComponent.getFirstPropertyFirstValue('ISPRIVATE') === '1'
}
if (eventComponent.hasProperty('ABSENCETYPE')) {
eventObject.absenceType = eventComponent.getFirstPropertyFirstValue('ABSENCETYPE')
if(eventComponent.hasProperty('ABSENCETYPE')){
eventObject.absenceType = eventComponent.getFirstPropertyFirstValue('ABSENCETYPE');
}else{
if(eventComponent.hasProperty('ISLEAVE')){
if( eventComponent.getFirstPropertyFirstValue('ISLEAVE') === '1'){
eventObject.absenceType = 'LEAVE';
} else {
if (eventComponent.hasProperty('ISLEAVE')) {
if (eventComponent.getFirstPropertyFirstValue('ISLEAVE') === '1') {
eventObject.absenceType = 'LEAVE'
}
}
}
if(eventComponent.hasProperty('ISCALENDARPENDING')){
eventObject.isCalendarPending = eventComponent.getFirstPropertyFirstValue('ISCALENDARPENDING') === '1' ? true : false;
if (eventComponent.hasProperty('ISCALENDARPENDING')) {
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.client = eventObject.client
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.isCalendarPending = eventObject.isCalendarPending
eventComponent.comment = eventObject.comment

View File

@ -22,7 +22,6 @@
import { translate as t } from '@nextcloud/l10n'
import { getDefaultCategories } from '../defaults/defaultCategories.js'
/**
* Gets all supported RFC properties
*
@ -158,7 +157,6 @@ const getRFCProperties = () => {
options: [],
},
embalmer: {
readableName: t('calendar', 'Embalmer'),
placeholder: t('calendar', 'Add a thanatopracteur'),
@ -183,7 +181,21 @@ const getRFCProperties = () => {
placeholder: t('calendar', 'Commentaires'),
tagPlaceholder: t('calendar', 'Commentaires'),
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

@ -292,6 +292,7 @@ const mutations = {
* @param {object} state The Vuex state
* @param {object} data The destructuring object
* @param {object} data.calendarObjectInstance The calendarObjectInstance object
* @param data.isPrivate
*/
toggleIsPrivate(state, { calendarObjectInstance, isPrivate }) {
calendarObjectInstance.eventComponent.isPrivate = isPrivate
@ -403,6 +404,40 @@ const mutations = {
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
*
@ -410,6 +445,7 @@ const mutations = {
* @param {object} data The destructuring object
* @param {object} data.calendarObjectInstance The calendarObjectInstance object
* @param {string} data.embalmer New embalmer to set
* @param data.absenceType
*/
changeAbsenceType(state, { calendarObjectInstance, absenceType }) {
calendarObjectInstance.eventComponent.absenceType = absenceType ?? null
@ -1791,7 +1827,9 @@ const actions = {
eventComponent.comment != null ||
eventComponent.isLeave != null ||
eventComponent.absenceType ||
eventComponent.isCalendarPending != null;
eventComponent.isCalendarPending != null ||
state.calendarObjectInstance.lieuDeces != null ||
state.calendarObjectInstance.dateNaissance != null;
if (eventComponent.isDirty() || additionalFieldWasUpdated) {
const isForkedItem = eventComponent.primaryItem !== null
let original = null

View File

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

View File

@ -1144,19 +1144,39 @@ class Bdd
/**
* 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` (
`id_nextcloud`, `nom`, `sexe`, `date_naissance`, `ref_pacemaker`, `date`,
`corpulence`, `observations_corps`, `observations_generales`
) VALUES (?,?,?,?,?,NOW(),?,?,?);";
$this->execSQLNoData($sql, array('admin',$name, 'm', '1973-11-11', '', '', '', ''));
`corpulence`, `observations_corps`, `observations_generales`, `lieu_deces`
) VALUES (?,?,?,?,?,NOW(),?,?,?,?);";
$this->execSQLNoData($sql, array(
'admin',
$name,
'm',
$dateNaissance,
'',
'',
'',
'',
$lieuDecesValue
));
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);
}
@ -4109,12 +4129,13 @@ class Bdd
return null;
}
private function getDefuntById($defuntId)
public function getDefuntById($defuntId)
{
$sql = "SELECT
defunt.id as id,
defunt.nom as defunt_nom,
defunt.lieu_deces as lieu_deces,
defunt.date_naissance as date_naissance,
devis.id as devis_id
FROM ".$this->tableprefix."defunt as 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]);
}
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
SET defunt.nom = ?
WHERE defunt.id = ?";
$this->execSQLNoData($sql, [$requestedDefuntName,$defuntId]);
// Gérer la date de naissance par défaut si null ou vide
if (empty($dateNaissance) || trim($dateNaissance) === '') {
$dateNaissance = '1973-11-11';
}
public function createOrUpdateDefuntByNameAndReturnDefuntId($defuntId, $currentDefuntName, $requestedDefuntName)
// 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;
}
/**
* 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;
if($defuntNameIsUpdated) {
$this->updateDefuntByName($defuntId, $requestedDefuntName);
$lieuDecesIsUpdated = ($currentDefunt['lieu_deces'] ?? null) != $lieuDeces;
$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 {
$this->insertDefuntByName($requestedDefuntName);
// Créer un nouveau défunt
$this->insertDefuntByName($requestedDefuntName, $lieuDeces, $dateNaissance);
$defunt = $this->getLastDefuntIdByName($requestedDefuntName);
$defuntId = $defunt['id'];
}
@ -5225,21 +5283,22 @@ COMMENTAIRES: ".$comment;
return $devisList;
}
public function getDevisIdsGroupByFactureId($factureId,$mentionFilters = []){
public function getDevisIdsGroupByFactureId($factureId, $mentionFilters = [])
{
$sql = "SELECT devis.id
FROM ".$this->tableprefix."devis as devis
WHERE devis.fk_facture_id = ? ";
$conditions = [$factureId];
if(!empty($mentionFilters)){
if(!empty($mentionFilters)) {
$mentionsFilterPlaceholders = implode(',', array_fill(0, count($mentionFilters), '?'));
$sql .= " AND devis.mentions IN ($mentionsFilterPlaceholders)";
$conditions = array_merge($conditions, $mentionFilters);
}
$sql.= ";";
$devisList = $this->execSQLNoJsonReturn($sql,$conditions);
$sql .= ";";
$devisList = $this->execSQLNoJsonReturn($sql, $conditions);
$devisIds = [];
foreach($devisList as $devis){
foreach($devisList as $devis) {
$devisIds[] = $devis['id'];
}
return $devisIds;
@ -5702,11 +5761,12 @@ COMMENTAIRES: ".$comment;
];
}
private function getDevisIdsListByFactureId($factureId){
private function getDevisIdsListByFactureId($factureId)
{
$factureData = $this->getFactureByFactureId(factureId: $factureId);
$isFactureGroupOfDevis = $factureData["facture_type"] == FactureTypeConstant::TYPE_GROUP;
$factureDevisIdsList = [];
if($isFactureGroupOfDevis){
if($isFactureGroupOfDevis) {
$isFactureForSingleClient = $factureData['fk_client_id'] != null && $factureData['fk_client_id'] != 0;
$devisMentionFilters = [
DevisMentionConstant::FACTURED_FORMATTED,
@ -5715,24 +5775,25 @@ COMMENTAIRES: ".$comment;
$devis = $this->getDevisByFkFactureId($factureId);
$factureGroupIsRelatedToAnyDevis = $devis != null;
if (!$factureGroupIsRelatedToAnyDevis) {
if($isFactureForSingleClient){
if($isFactureForSingleClient) {
$factureDevisIdsList = $this->getDevisIdsByClientIdAndMonthYear(
$factureData['fk_client_id'],
$factureData['month'],
$factureData['year'],$devisMentionFilters
$factureData['year'],
$devisMentionFilters
);
}else{
} else {
$factureDevisIdsList = $this->getDevisIdsByClientGroupFacturationIdAndMonthYear(
$factureData['fk_client_group_facturation_id'],
$factureData['month'],
$factureData['year'],$devisMentionFilters
$factureData['year'],
$devisMentionFilters
);
}
}else{
$factureDevisIdsList = $this->getDevisIdsGroupByFactureId($factureId, $devisMentionFilters );
} else {
$factureDevisIdsList = $this->getDevisIdsGroupByFactureId($factureId, $devisMentionFilters);
}
}
else{
} else {
$factureDevisIdsList = $factureData['id_devis'] ? [$factureData['id_devis']] : [];
}
return $factureDevisIdsList;
@ -5744,7 +5805,7 @@ COMMENTAIRES: ".$comment;
$totalHt = 0;
$totalTtc = 0;
$tva = 0;
foreach($factureDevisIds as $devisId){
foreach($factureDevisIds as $devisId) {
$products = $this->getDevisProduits($devisId);
$totalPrices = $this->getProductsTotalPrices($products);
$totalHt += $totalPrices["total_ht"];

View File

@ -34,7 +34,6 @@ use Psr\Log\LoggerInterface;
class CalendarObjectCreatedListener implements IEventListener
{
/** @var LoggerInterface */
private $logger;
@ -64,5 +63,4 @@ class CalendarObjectCreatedListener implements IEventListener
$this->logger->debug("Error while handling created calendar object: " . $e->getMessage());
}
}
}

View File

@ -35,7 +35,6 @@ use Psr\Log\LoggerInterface;
class CalendarObjectUpdatedListener implements IEventListener
{
/** @var LoggerInterface */
private $logger;

View File

@ -58,7 +58,6 @@ class GestionService
TalkService $talkService,
IUserSession $userSession,
DevisPdfService $devisPdfService
) {
$this->logger = $logger;
$this->gestionBdd = $gestionBdd;
@ -163,7 +162,8 @@ class GestionService
return $calendarStartDate;
}
private function GetIsPivateFromVCalendarString(string $vCalendarString): bool{
private function GetIsPivateFromVCalendarString(string $vCalendarString): bool
{
$isPrivateValue = VCalendarHelpers::GetValueFromKeyInVCalendarString(VCalendarPropertyConstant::PROPERTY_IS_PRIVATE, $vCalendarString);
return $isPrivateValue === "1" ? true : false;
}
@ -182,7 +182,16 @@ class GestionService
private function UpdateDevisDataByVCalendarString($devis, $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']);
$requestedClientId = $this->GetClientIdFromVCalendarString($vCalendarString);
@ -206,6 +215,11 @@ class GestionService
private function CheckIfDevisIsAlreadyUpdated($devis, $vCalendarString)
{
$requestedDefuntName = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
$requestedLieuDeces = $this->getLieuDecesFromVCalendarString($vCalendarString);
$requestedDateNaissance = $this->getDateNaissanceFromVCalendarString($vCalendarString);
$currentDefunt = $this->gestionBdd->getDefuntById($devis['defunt_id']);
$requestedClientId = $this->GetClientIdFromVCalendarString($vCalendarString);
$requestLocationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
$requestedDevisComment = $this->GetDevisCommentFromVCalendarString($vCalendarString);
@ -226,15 +240,17 @@ class GestionService
$devis['lieu_id'] == $requestLocationId &&
$devis['comment'] == $requestedDevisComment &&
$requestedArticleIds == $articleDevisIds &&
$devis['date'] == $requestedDevisDate;
$devis['date'] == $requestedDevisDate &&
($currentDefunt['lieu_deces'] ?? null) == $requestedLieuDeces &&
($currentDefunt['date_naissance'] ?? null) == $requestedDateNaissance;
}
public function HandleUpdatedCalendarObject(string $vCalendarString)
{
try {
$isPrivate = $this->GetIsPivateFromVCalendarString($vCalendarString);
$absenceType = VCalendarHelpers::GetValueFromKeyInVCalendarString('ABSENCETYPE',$vCalendarString);
if ($isPrivate || $absenceType ) {
$absenceType = VCalendarHelpers::GetValueFromKeyInVCalendarString('ABSENCETYPE', $vCalendarString);
if ($isPrivate || $absenceType) {
//from devis calendar to leave calendar
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
@ -296,10 +312,10 @@ class GestionService
$month,
$year
);
if($oldThanatoTrajet != null){
$thereIsThanatoDevisRattachedToLigneTrajetForADate = $this->gestionBdd->thereIsThanatoDevisRattachedToLigneTrajetForADate($devis['date'], $oldThanatoTrajet['id'] );
if(!$thereIsThanatoDevisRattachedToLigneTrajetForADate){
$this->gestionBdd->deleteThanatoLigneTrajetForADateByIdTrajet($devis['date'], $oldThanatoTrajet['id'] );
if($oldThanatoTrajet != null) {
$thereIsThanatoDevisRattachedToLigneTrajetForADate = $this->gestionBdd->thereIsThanatoDevisRattachedToLigneTrajetForADate($devis['date'], $oldThanatoTrajet['id']);
if(!$thereIsThanatoDevisRattachedToLigneTrajetForADate) {
$this->gestionBdd->deleteThanatoLigneTrajetForADateByIdTrajet($devis['date'], $oldThanatoTrajet['id']);
}
}
$this->gestionBdd->updateDevisThanato($devis['id'], $thanato['id']);
@ -321,8 +337,8 @@ class GestionService
try {
$isPrivate = $this->GetIsPivateFromVCalendarString($vCalendarString);
$absenceType = VCalendarHelpers::GetValueFromKeyInVCalendarString('ABSENCETYPE',$vCalendarString);
if($isPrivate || $absenceType){
$absenceType = VCalendarHelpers::GetValueFromKeyInVCalendarString('ABSENCETYPE', $vCalendarString);
if($isPrivate || $absenceType) {
//Nothing to do manage fo a private calendar
return;
}
@ -336,11 +352,15 @@ class GestionService
$thanatoId = $this->GetThanatoIdFromVCalendarString($vCalendarString);
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$userName = $this->GetThanatoNameFromVCalendarString($vCalendarString);
$lieuDeces = $this->getLieuDecesFromVCalendarString($vCalendarString);
$dateNaissance = $this->getDateNaissanceFromVCalendarString($vCalendarString);
$devisAlreadyCreated = $this->IsDevisAlreadyCreated($clientId, $locationId, $thanatoId, $calendarSummary, $calendarUuid);
if ($devisAlreadyCreated) {
return;
}
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary);
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary, $lieuDeces, $dateNaissance);
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
$devisComment = $this->GetDevisCommentFromVCalendarString($vCalendarString);
$devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId, $clientId, $locationId, $defuntId, $calendarUuid, $calendarStartDate, $devisComment);
@ -352,7 +372,7 @@ class GestionService
$devisTalkMessage = $this->gestionBdd->getDevisTalkRoomMessage($devisId, $userName);
$this->talkService->sendDevisTalkNotifications($devisTalkMessage, $userName, $this->userConnectedUuid);
$this->gestionBdd->createDevisTrajetFromVCalendar($devisId, $userName);
$this->devisPdfService->generateDevisPdfByDevisId($devisId , $this->userConnectedUuid);
$this->devisPdfService->generateDevisPdfByDevisId($devisId, $this->userConnectedUuid);
} catch (\OC\OCS\Exception $e) {
$this->logger->debug("Error while handling created calendar object: " . $e->getMessage());
} catch (\Throwable $e) {
@ -360,7 +380,6 @@ class GestionService
}
}
private function GetThanatoNameFromVCalendarString($vCalendarString)
{
$thanatoName = $this->getPrincipalUsernameFromVCalendarString($vCalendarString);
@ -393,4 +412,16 @@ class GestionService
$mapped = array_map('trim', $articles);
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;
}
}