when updating agenda, update also the devis

This commit is contained in:
Tiavina 2025-01-15 14:07:01 +03:00
parent 3464679fbd
commit 4c29b5d861
41 changed files with 50989 additions and 45 deletions

View File

@ -1322,7 +1322,7 @@ function b(n) {
/******/ // This function allow to reference async chunks /******/ // This function allow to reference async chunks
/******/ __webpack_require__.u = (chunkId) => { /******/ __webpack_require__.u = (chunkId) => {
/******/ // return url for filenames based on template /******/ // return url for filenames based on template
/******/ return "calendar-" + chunkId + ".js?v=" + {"vendors-node_modules_nextcloud_capabilities_dist_index_js-node_modules_nextcloud_vue-select_d-877981":"31a7d4ece3cdde2d67f1","vendors-node_modules_vue_dist_vue_runtime_esm_js":"7e3171593bdc0f62040b","vendors-node_modules_nextcloud_cdav-library_dist_dist_js-node_modules_nextcloud_logger_dist_i-36c16b":"c3b3db23da041c717fc1","vendors-node_modules_webdav_dist_web_index_js":"454da8f908d41b47c607","vendors-node_modules_vue-material-design-icons_CalendarBlankOutline_vue-node_modules_nextclou-4adead":"702892edfb255629754c","vendors-node_modules_nextcloud_vue-dashboard_dist_vue-dashboard_js-node_modules_css-loader_di-9e6f3d":"bab844a8fb43e3701945","src_models_rfcProps_js-src_services_caldavService_js-src_services_talkService_js-src_services-8a2790":"7cf71b4f92d5bbc180b4","src_store_index_js":"0338b9a6ef0b356d96af","src_fullcalendar_eventSources_eventSourceFunction_js-src_utils_moment_js-data_image_svg_xml_3-b73258":"740a2859d1f364b508c1","dashboard-lazy":"a51e4becd0c10f90296c","vendors-node_modules_vue-material-design-icons_CalendarBlank_vue-node_modules_vue-material-de-e2c1f8":"1ec24b5ef07652c6dd39","vendors-node_modules_path-browserify_index_js-node_modules_nextcloud_dialogs_dist_chunks_Dial-e0595f":"7ec0cf6b65f5c745fa03","node_modules_nextcloud_dialogs_dist_legacy_mjs":"8be838e4c6e9aae56c87","vendors-node_modules_nextcloud_dialogs_dist_chunks_FilePicker-8ibBgPg__mjs":"ea54a36450de178d1141","vendors-node_modules_moment_locale_af_js-node_modules_moment_locale_ar-dz_js-node_modules_mom-582c96":"ce1bed825f57dd1d117a","node_modules_moment_locale_sync_recursive_":"4bc2c39c5e0ff182c2e3"}[chunkId] + ""; /******/ return "calendar-" + chunkId + ".js?v=" + {"vendors-node_modules_nextcloud_capabilities_dist_index_js-node_modules_nextcloud_vue-select_d-877981":"31a7d4ece3cdde2d67f1","vendors-node_modules_vue_dist_vue_runtime_esm_js":"7e3171593bdc0f62040b","vendors-node_modules_nextcloud_cdav-library_dist_dist_js-node_modules_nextcloud_logger_dist_i-36c16b":"c3b3db23da041c717fc1","vendors-node_modules_webdav_dist_web_index_js":"454da8f908d41b47c607","vendors-node_modules_vue-material-design-icons_CalendarBlankOutline_vue-node_modules_nextclou-4adead":"702892edfb255629754c","vendors-node_modules_nextcloud_vue-dashboard_dist_vue-dashboard_js-node_modules_css-loader_di-9e6f3d":"bab844a8fb43e3701945","src_models_rfcProps_js-src_services_caldavService_js-src_services_talkService_js-src_services-8a2790":"7cf71b4f92d5bbc180b4","src_store_index_js":"420e15dec2eb84cba206","src_fullcalendar_eventSources_eventSourceFunction_js-src_utils_moment_js-data_image_svg_xml_3-b73258":"740a2859d1f364b508c1","dashboard-lazy":"a51e4becd0c10f90296c","vendors-node_modules_vue-material-design-icons_CalendarBlank_vue-node_modules_vue-material-de-e2c1f8":"1ec24b5ef07652c6dd39","vendors-node_modules_path-browserify_index_js-node_modules_nextcloud_dialogs_dist_chunks_Dial-e0595f":"7ec0cf6b65f5c745fa03","node_modules_nextcloud_dialogs_dist_legacy_mjs":"8be838e4c6e9aae56c87","vendors-node_modules_nextcloud_dialogs_dist_chunks_FilePicker-8ibBgPg__mjs":"ea54a36450de178d1141","vendors-node_modules_moment_locale_af_js-node_modules_moment_locale_ar-dz_js-node_modules_mom-582c96":"ce1bed825f57dd1d117a","node_modules_moment_locale_sync_recursive_":"4bc2c39c5e0ff182c2e3"}[chunkId] + "";
/******/ }; /******/ };
/******/ })(); /******/ })();
/******/ /******/
@ -1580,4 +1580,4 @@ document.addEventListener('DOMContentLoaded', function () {
/******/ })() /******/ })()
; ;
//# sourceMappingURL=calendar-dashboard.js.map?v=0b87d468a835f9f596c4 //# sourceMappingURL=calendar-dashboard.js.map?v=cd85d9b21f2d310f9ed9

File diff suppressed because one or more lines are too long

View File

@ -32632,11 +32632,14 @@ const actions = {
thisAndAllFuture, thisAndAllFuture,
calendarId calendarId
} = _ref78; } = _ref78;
debugger;
const eventComponent = state.calendarObjectInstance.eventComponent; const eventComponent = state.calendarObjectInstance.eventComponent;
const calendarObject = state.calendarObject; const calendarObject = state.calendarObject;
(0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.updateAlarms)(eventComponent); (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.updateAlarms)(eventComponent);
(0,_services_talkService_js__WEBPACK_IMPORTED_MODULE_13__.updateTalkParticipants)(eventComponent); (0,_services_talkService_js__WEBPACK_IMPORTED_MODULE_13__.updateTalkParticipants)(eventComponent);
if (eventComponent.isDirty()) { let client = eventComponent.client;
let additionalFieldWasUpdated = eventComponent.client != null || eventComponent.comment != null;
if (eventComponent.isDirty() || additionalFieldWasUpdated) {
const isForkedItem = eventComponent.primaryItem !== null; const isForkedItem = eventComponent.primaryItem !== null;
let original = null; let original = null;
let fork = null; let fork = null;
@ -33536,9 +33539,21 @@ const actions = {
let { let {
calendarObject calendarObject
} = _ref8; } = _ref8;
debugger;
let eventComponent = calendarObject.calendarComponent.getFirstComponent('VEVENT'); let eventComponent = calendarObject.calendarComponent.getFirstComponent('VEVENT');
if (calendarObject.existsOnServer) { if (calendarObject.existsOnServer) {
calendarObject.dav.data = calendarObject.calendarComponent.toICS(); let icsValue = calendarObject.calendarComponent.toICS();
if (eventComponent != null) {
if (eventComponent.client != null) {
let newClientKeyValue = "CLIENT:" + eventComponent.client;
icsValue = icsValue.replace(/CLIENT:\d+/, newClientKeyValue);
}
if (eventComponent.comment != null) {
let newCommentKeyValue = "COMMENT:" + eventComponent.comment;
icsValue = icsValue.replace(/COMMENT:[^\s]+/, newCommentKeyValue);
}
}
calendarObject.dav.data = icsValue;
await calendarObject.dav.update(); await calendarObject.dav.update();
context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', { context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', {
calendarId: calendarObject.calendarId, calendarId: calendarObject.calendarId,
@ -310253,4 +310268,4 @@ appointmentsConfigsStore.addInitialConfigs((0,_nextcloud_initial_state__WEBPACK_
/******/ })() /******/ })()
; ;
//# sourceMappingURL=calendar-main.js.map?v=30e87e64d6ce046440b7 //# sourceMappingURL=calendar-main.js.map?v=85728a05c7dde1271392

File diff suppressed because one or more lines are too long

View File

@ -8865,7 +8865,7 @@ window._registerCustomPickerElement = _;
/******/ // This function allow to reference async chunks /******/ // This function allow to reference async chunks
/******/ __webpack_require__.u = (chunkId) => { /******/ __webpack_require__.u = (chunkId) => {
/******/ // return url for filenames based on template /******/ // return url for filenames based on template
/******/ return "calendar-" + chunkId + ".js?v=" + {"vendors-node_modules_vue_dist_vue_runtime_esm_js":"7e3171593bdc0f62040b","vendors-node_modules_nextcloud_capabilities_dist_index_js-node_modules_nextcloud_vue-select_d-877981":"31a7d4ece3cdde2d67f1","vendors-node_modules_nextcloud_cdav-library_dist_dist_js-node_modules_nextcloud_logger_dist_i-36c16b":"c3b3db23da041c717fc1","vendors-node_modules_vue-material-design-icons_CalendarBlank_vue-node_modules_vue-material-de-e2c1f8":"1ec24b5ef07652c6dd39","vendors-node_modules_vue-material-design-icons_CalendarBlankOutline_vue-node_modules_nextclou-4adead":"702892edfb255629754c","vendors-node_modules_autosize_dist_autosize_esm_js-node_modules_html-entities_lib_index_js-no-4072c5":"7212b31e059bc10c256e","src_models_rfcProps_js-src_services_caldavService_js-src_services_talkService_js-src_services-8a2790":"7cf71b4f92d5bbc180b4","src_fullcalendar_eventSources_eventSourceFunction_js-src_utils_moment_js-data_image_svg_xml_3-b73258":"740a2859d1f364b508c1","src_views_Calendar_vue-data_image_svg_xml_3csvg_20xmlns_27http_www_w3_org_2000_svg_27_20heigh-4a4254":"2cfe366ffc76e23c8b93","vendors-node_modules_webdav_dist_web_index_js":"454da8f908d41b47c607","src_store_index_js":"0338b9a6ef0b356d96af","vendors-node_modules_path-browserify_index_js-node_modules_nextcloud_dialogs_dist_chunks_Dial-e0595f":"7ec0cf6b65f5c745fa03","node_modules_nextcloud_dialogs_dist_legacy_mjs":"8be838e4c6e9aae56c87","vendors-node_modules_nextcloud_dialogs_dist_chunks_FilePicker-8ibBgPg__mjs":"ea54a36450de178d1141","public-calendar-subscription-picker":"2315e24e67ebf6e4b6db","vendors-node_modules_moment_locale_af_js-node_modules_moment_locale_ar-dz_js-node_modules_mom-582c96":"ce1bed825f57dd1d117a","node_modules_moment_locale_sync_recursive_":"4bc2c39c5e0ff182c2e3"}[chunkId] + ""; /******/ return "calendar-" + chunkId + ".js?v=" + {"vendors-node_modules_vue_dist_vue_runtime_esm_js":"7e3171593bdc0f62040b","vendors-node_modules_nextcloud_capabilities_dist_index_js-node_modules_nextcloud_vue-select_d-877981":"31a7d4ece3cdde2d67f1","vendors-node_modules_nextcloud_cdav-library_dist_dist_js-node_modules_nextcloud_logger_dist_i-36c16b":"c3b3db23da041c717fc1","vendors-node_modules_vue-material-design-icons_CalendarBlank_vue-node_modules_vue-material-de-e2c1f8":"1ec24b5ef07652c6dd39","vendors-node_modules_vue-material-design-icons_CalendarBlankOutline_vue-node_modules_nextclou-4adead":"702892edfb255629754c","vendors-node_modules_autosize_dist_autosize_esm_js-node_modules_html-entities_lib_index_js-no-4072c5":"7212b31e059bc10c256e","src_models_rfcProps_js-src_services_caldavService_js-src_services_talkService_js-src_services-8a2790":"7cf71b4f92d5bbc180b4","src_fullcalendar_eventSources_eventSourceFunction_js-src_utils_moment_js-data_image_svg_xml_3-b73258":"740a2859d1f364b508c1","src_views_Calendar_vue-data_image_svg_xml_3csvg_20xmlns_27http_www_w3_org_2000_svg_27_20heigh-4a4254":"2cfe366ffc76e23c8b93","vendors-node_modules_webdav_dist_web_index_js":"454da8f908d41b47c607","src_store_index_js":"420e15dec2eb84cba206","vendors-node_modules_path-browserify_index_js-node_modules_nextcloud_dialogs_dist_chunks_Dial-e0595f":"7ec0cf6b65f5c745fa03","node_modules_nextcloud_dialogs_dist_legacy_mjs":"8be838e4c6e9aae56c87","vendors-node_modules_nextcloud_dialogs_dist_chunks_FilePicker-8ibBgPg__mjs":"ea54a36450de178d1141","public-calendar-subscription-picker":"2315e24e67ebf6e4b6db","vendors-node_modules_moment_locale_af_js-node_modules_moment_locale_ar-dz_js-node_modules_mom-582c96":"ce1bed825f57dd1d117a","node_modules_moment_locale_sync_recursive_":"4bc2c39c5e0ff182c2e3"}[chunkId] + "";
/******/ }; /******/ };
/******/ })(); /******/ })();
/******/ /******/
@ -9115,4 +9115,4 @@ __webpack_require__.p = (0,_nextcloud_router__WEBPACK_IMPORTED_MODULE_1__.linkTo
/******/ })() /******/ })()
; ;
//# sourceMappingURL=calendar-reference.js.map?v=82be2390c842a6f2ecba //# sourceMappingURL=calendar-reference.js.map?v=136752ee65c3ce4bf4b0

File diff suppressed because one or more lines are too long

View File

@ -3698,11 +3698,14 @@ const actions = {
thisAndAllFuture, thisAndAllFuture,
calendarId calendarId
} = _ref78; } = _ref78;
debugger;
const eventComponent = state.calendarObjectInstance.eventComponent; const eventComponent = state.calendarObjectInstance.eventComponent;
const calendarObject = state.calendarObject; const calendarObject = state.calendarObject;
(0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.updateAlarms)(eventComponent); (0,_utils_alarms_js__WEBPACK_IMPORTED_MODULE_5__.updateAlarms)(eventComponent);
(0,_services_talkService_js__WEBPACK_IMPORTED_MODULE_13__.updateTalkParticipants)(eventComponent); (0,_services_talkService_js__WEBPACK_IMPORTED_MODULE_13__.updateTalkParticipants)(eventComponent);
if (eventComponent.isDirty()) { let client = eventComponent.client;
let additionalFieldWasUpdated = eventComponent.client != null || eventComponent.comment != null;
if (eventComponent.isDirty() || additionalFieldWasUpdated) {
const isForkedItem = eventComponent.primaryItem !== null; const isForkedItem = eventComponent.primaryItem !== null;
let original = null; let original = null;
let fork = null; let fork = null;
@ -4601,9 +4604,21 @@ const actions = {
let { let {
calendarObject calendarObject
} = _ref8; } = _ref8;
debugger;
let eventComponent = calendarObject.calendarComponent.getFirstComponent('VEVENT'); let eventComponent = calendarObject.calendarComponent.getFirstComponent('VEVENT');
if (calendarObject.existsOnServer) { if (calendarObject.existsOnServer) {
calendarObject.dav.data = calendarObject.calendarComponent.toICS(); let icsValue = calendarObject.calendarComponent.toICS();
if (eventComponent != null) {
if (eventComponent.client != null) {
let newClientKeyValue = "CLIENT:" + eventComponent.client;
icsValue = icsValue.replace(/CLIENT:\d+/, newClientKeyValue);
}
if (eventComponent.comment != null) {
let newCommentKeyValue = "COMMENT:" + eventComponent.comment;
icsValue = icsValue.replace(/COMMENT:[^\s]+/, newCommentKeyValue);
}
}
calendarObject.dav.data = icsValue;
await calendarObject.dav.update(); await calendarObject.dav.update();
context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', { context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', {
calendarId: calendarObject.calendarId, calendarId: calendarObject.calendarId,
@ -8202,4 +8217,4 @@ function getLinkToConfig(key) {
/***/ }) /***/ })
}]); }]);
//# sourceMappingURL=calendar-src_store_index_js.js.map?v=0338b9a6ef0b356d96af //# sourceMappingURL=calendar-src_store_index_js.js.map?v=420e15dec2eb84cba206

File diff suppressed because one or more lines are too long

View File

@ -1695,13 +1695,17 @@ const actions = {
* @return {Promise<void>} * @return {Promise<void>}
*/ */
async saveCalendarObjectInstance({ state, dispatch, commit }, { thisAndAllFuture, calendarId }) { async saveCalendarObjectInstance({ state, dispatch, commit }, { thisAndAllFuture, calendarId }) {
debugger;
const eventComponent = state.calendarObjectInstance.eventComponent const eventComponent = state.calendarObjectInstance.eventComponent
const calendarObject = state.calendarObject const calendarObject = state.calendarObject
updateAlarms(eventComponent) updateAlarms(eventComponent)
updateTalkParticipants(eventComponent) updateTalkParticipants(eventComponent)
let client = eventComponent.client;
if (eventComponent.isDirty()) { let additionalFieldWasUpdated =
eventComponent.client != null ||
eventComponent.comment != null;
if (eventComponent.isDirty() || additionalFieldWasUpdated) {
const isForkedItem = eventComponent.primaryItem !== null const isForkedItem = eventComponent.primaryItem !== null
let original = null let original = null
let fork = null let fork = null

View File

@ -224,9 +224,21 @@ const actions = {
* @return {Promise<void>} * @return {Promise<void>}
*/ */
async updateCalendarObject(context, { calendarObject }) { async updateCalendarObject(context, { calendarObject }) {
debugger;
let eventComponent = calendarObject.calendarComponent.getFirstComponent('VEVENT'); let eventComponent = calendarObject.calendarComponent.getFirstComponent('VEVENT');
if (calendarObject.existsOnServer) { if (calendarObject.existsOnServer) {
calendarObject.dav.data = calendarObject.calendarComponent.toICS() let icsValue = calendarObject.calendarComponent.toICS();
if(eventComponent != null){
if(eventComponent.client != null){
let newClientKeyValue = "CLIENT:"+eventComponent.client;
icsValue = icsValue.replace(/CLIENT:\d+/, newClientKeyValue);
}
if(eventComponent.comment != null){
let newCommentKeyValue = "COMMENT:"+eventComponent.comment;
icsValue = icsValue.replace(/COMMENT:[^\s]+/, newCommentKeyValue);
}
}
calendarObject.dav.data = icsValue;
await calendarObject.dav.update() await calendarObject.dav.update()
context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', { context.commit('addCalendarObjectIdToAllTimeRangesOfCalendar', {
calendarId: calendarObject.calendarId, calendarId: calendarObject.calendarId,

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

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

@ -5,10 +5,11 @@
namespace OCA\Gestion\AppInfo; namespace OCA\Gestion\AppInfo;
use OCA\DAV\Events\CalendarObjectCreatedEvent; use OCA\DAV\Events\CalendarObjectCreatedEvent;
use OCA\DAV\Events\CalendarObjectDeletedEvent;
use OCA\DAV\Events\CalendarObjectMovedToTrashEvent; use OCA\DAV\Events\CalendarObjectMovedToTrashEvent;
use OCA\DAV\Events\CalendarObjectUpdatedEvent;
use OCA\Gestion\Listener\CalendarObjectCreatedListener; use OCA\Gestion\Listener\CalendarObjectCreatedListener;
use OCA\Gestion\Listener\CalendarObjectMovedToTrashListener; use OCA\Gestion\Listener\CalendarObjectMovedToTrashListener;
use OCA\Gestion\Listener\CalendarObjectUpdatedListener;
use OCP\AppFramework\App; use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Bootstrap\IRegistrationContext;
@ -25,6 +26,7 @@ class Application extends App implements IBootstrap {
public function register(IRegistrationContext $context): void { public function register(IRegistrationContext $context): void {
$context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarObjectCreatedListener::class); $context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarObjectCreatedListener::class);
$context->registerEventListener(CalendarObjectMovedToTrashEvent::class, CalendarObjectMovedToTrashListener::class); $context->registerEventListener(CalendarObjectMovedToTrashEvent::class, CalendarObjectMovedToTrashListener::class);
$context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarObjectUpdatedListener::class);
} }
public function boot(IBootContext $context): void { public function boot(IBootContext $context): void {

View File

@ -5,6 +5,7 @@ use OCA\Gestion\Helpers\DateHelpers;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\IL10N; use OCP\IL10N;
use \Datetime; use \Datetime;
use OCA\Gestion\Constants\BddConstant;
use OCA\Gestion\Constants\DevisMentionConstant; use OCA\Gestion\Constants\DevisMentionConstant;
use OCA\Gestion\Constants\ProductConstant; use OCA\Gestion\Constants\ProductConstant;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
@ -2223,6 +2224,7 @@ class Bdd {
produit_devis.produit_id, produit_devis.produit_id,
produit_devis.quantite, produit_devis.quantite,
produit_devis.discount, produit_devis.discount,
produit_devis.devis_id,
produit.prix_unitaire as produit_price, produit.prix_unitaire as produit_price,
produit.reference as produit_reference, produit.reference as produit_reference,
produit.description as produit_description, produit.description as produit_description,
@ -3041,9 +3043,14 @@ class Bdd {
$sql = "SELECT $sql = "SELECT
devis.id, devis.id,
devis.id_thanato, devis.id_thanato,
devis.id_defunt, devis.id_defunt as defunt_id,
devis.num devis.num,
devis.comment,
devis.id_lieu as lieu_id,
devis.id_client as client_id,
defunt.nom as defunt_nom
FROM ".$this->tableprefix."devis as devis FROM ".$this->tableprefix."devis as devis
LEFT JOIN ".$this->tableprefix."defunt as defunt on devis.id_defunt = defunt.id
WHERE devis.num = ? ;"; WHERE devis.num = ? ;";
$devis = $this->execSQLNoJsonReturn($sql, array($calendarUuid)); $devis = $this->execSQLNoJsonReturn($sql, array($calendarUuid));
@ -3061,4 +3068,94 @@ class Bdd {
$this->execSQLNoData($sql,[DevisMentionConstant::CANCELED,$devisId]); $this->execSQLNoData($sql,[DevisMentionConstant::CANCELED,$devisId]);
} }
} private function updateDefuntByName($defuntId,$requestedDefuntName){
$sql= "UPDATE ".$this->tableprefix."defunt as defunt
SET defunt.nom = ?
WHERE defunt.id = ?";
$this->execSQLNoData($sql,[$requestedDefuntName,$defuntId]);
}
public function createOrUpdateDefuntByNameAndReturnDefuntId($defuntId,$currentDefuntName,$requestedDefuntName){
if($defuntId != null){
$defuntNameIsUpdated = $currentDefuntName != $requestedDefuntName;
if($defuntNameIsUpdated){
$this->updateDefuntByName($defuntId,$requestedDefuntName);
}
}
else{
$this->insertDefuntByName($requestedDefuntName);
$defunt = $this->getLastDefuntIdByName($requestedDefuntName);
$defuntId = $defunt['id'];
}
return $defuntId;
}
public function updateDevisDefunt($devisId,$requestedDefuntId,$currentDefuntId = null){
$defuntIsUpdated = $currentDefuntId != $requestedDefuntId;
if($defuntIsUpdated){
$sql= "UPDATE ".$this->tableprefix."devis as devis
SET devis.id_defunt = ?
WHERE devis.id = ?";
$this->execSQLNoData($sql,[$requestedDefuntId,$devisId]);
}
}
public function updateDevisClient($devisId,$requestedClientId,$currentClientId = null){
$clientIsUpdated = $currentClientId != $requestedClientId;
if($clientIsUpdated){
$sql= "UPDATE ".$this->tableprefix."devis as devis
SET devis.id_client = ?
WHERE devis.id = ?";
$this->execSQLNoData($sql,[$requestedClientId,$devisId]);
}
}
public function updateDevisLieu($devisId,$requestedLieuId,$currentLieuId = null){
$lieuIsUpdated = $currentLieuId != $requestedLieuId;
if($lieuIsUpdated){
$sql= "UPDATE ".$this->tableprefix."devis as devis
SET devis.id_lieu = ?
WHERE devis.id = ?";
$this->execSQLNoData($sql,[$requestedLieuId,$devisId]);
}
}
public function updateDevisComment($devisId,$requestedComment,$currentComment = null){
$commentIsUpdated = $currentComment != $requestedComment;
if($commentIsUpdated){
$sql= "UPDATE ".$this->tableprefix."devis as devis
SET devis.comment = ?
WHERE devis.id = ?";
$this->execSQLNoData($sql,[$requestedComment,$devisId]);
}
}
public function deleteDevisProduit($devisProductId){
$sql = "DELETE FROM ".$this->tableprefix."produit_devis WHERE id = ?;";
$this->execSQLNoData($sql, array($devisProductId));
}
public function updateDevisArticles($devisId,$requestedArticlesIds){
$currentDevisProducts = $this->getDevisProduits($devisId);
$currentDevisProduitIds = [];
//delete old product
foreach($currentDevisProducts as $devisProduct){
$currentDevisProduitIds[] = $devisProduct['produit_id'];
$currentProductIsNotPartOfRequestedDevisProduct = !in_array($devisProduct['produit_id'],$requestedArticlesIds);
if($currentProductIsNotPartOfRequestedDevisProduct){
$this->deleteDevisProduit($devisProduct['id']);
}
}
//add new requested product
foreach($requestedArticlesIds as $requestedArticleId){
$currentRequestedArticleIsNewArticleForDevis = !in_array($requestedArticleId,$currentDevisProduitIds);
if($currentRequestedArticleIsNewArticleForDevis){
$this->insertDevisArticle(devisId: $devisId, articleId: $requestedArticleId,idNextcloud: BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD);
}
}
}
}

View File

@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
/*
* @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCA\Gestion\Listener;
use OCA\DAV\Events\CalendarObjectCreatedEvent;
use OCA\DAV\Events\CalendarObjectUpdatedEvent;
use OCA\Gestion\Service\GestionService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use Psr\Log\LoggerInterface;
class CalendarObjectUpdatedListener implements IEventListener {
/** @var LoggerInterface */
private $logger;
/** @var GestionService */
private $gestionService;
public function __construct(
LoggerInterface $logger,GestionService $gestionService) {
$this->logger = $logger;
$this->gestionService = $gestionService;
}
public function handle(Event $event): void {
if (!($event instanceof CalendarObjectUpdatedEvent)) {
return;
}
$calendarData = $event->getObjectData();
$vCalendarString = $calendarData["calendardata"];
$this->gestionService->HandleUpdatedCalendarObject($vCalendarString);
}
}

View File

@ -129,7 +129,6 @@ class GestionService {
public function HandleCalendarObjectMovedToTrash(string $vCalendarString){ public function HandleCalendarObjectMovedToTrash(string $vCalendarString){
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString); $calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$this->logger->debug($calendarUuid);
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid); $devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
if($devis != null){ if($devis != null){
$this->gestionBdd->updateDevisMentionToCanceled($devis['id']); $this->gestionBdd->updateDevisMentionToCanceled($devis['id']);
@ -137,6 +136,36 @@ class GestionService {
return true; return true;
} }
private function UpdateDevisDataByVCalendarString($devis,$vCalendarString){
$requestedDefuntName = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
$defuntId = $this->gestionBdd->createOrUpdateDefuntByNameAndReturnDefuntId($devis['defunt_id'],$devis['defunt_nom'],$requestedDefuntName);
$this->gestionBdd->updateDevisDefunt($devis['id'],$defuntId,$devis['defunt_id']);
$requestedClientId = $this->GetClientIdFromVCalendarString($vCalendarString);
$this->gestionBdd->updateDevisClient($devis['id'],$requestedClientId,$devis['client_id']);
$requestLocationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
$this->gestionBdd->updateDevisLieu($devis['id'],$requestLocationId,$devis['lieu_id']);
$requestedDevisComment = $this->GetDevisCommentFromVCalendarString($vCalendarString);
$this->gestionBdd->updateDevisComment($devis['id'],$requestedDevisComment,$devis['comment']);
$articlesValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
if(!empty($articlesValue)){
$articleIds = $this->gestionBdd->getArticleIdsByArticleReferences($articlesValue);
$this->gestionBdd->updateDevisArticles($devis['id'],$articleIds);
}
}
public function HandleUpdatedCalendarObject(string $vCalendarString){
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
if($devis != null){
$this->UpdateDevisDataByVCalendarString($devis,$vCalendarString);
}
return true;
}
public function HandleCreatedCalendarObject(string $vCalendarString){ public function HandleCreatedCalendarObject(string $vCalendarString){
$calendarSummary = $this->GetCalendarSummaryFromVCalendarString($vCalendarString); $calendarSummary = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
$clientId = $this->GetClientIdFromVCalendarString($vCalendarString); $clientId = $this->GetClientIdFromVCalendarString($vCalendarString);