wip send client when creating calendar object
This commit is contained in:
parent
a9e5a3441b
commit
72bb3360f9
@ -28,11 +28,13 @@ use OCA\Calendar\Dashboard\CalendarWidget;
|
||||
use OCA\Calendar\Dashboard\CalendarWidgetV2;
|
||||
use OCA\Calendar\Events\BeforeAppointmentBookedEvent;
|
||||
use OCA\Calendar\Listener\AppointmentBookedListener;
|
||||
use OCA\Calendar\Listener\CalendarObjectCreatedListener;
|
||||
use OCA\Calendar\Listener\CalendarReferenceListener;
|
||||
use OCA\Calendar\Listener\UserDeletedListener;
|
||||
use OCA\Calendar\Notification\Notifier;
|
||||
use OCA\Calendar\Profile\AppointmentsAction;
|
||||
use OCA\Calendar\Reference\ReferenceProvider;
|
||||
use OCA\DAV\Events\CalendarObjectCreatedEvent;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
@ -73,7 +75,7 @@ class Application extends App implements IBootstrap {
|
||||
$context->registerEventListener(BeforeAppointmentBookedEvent::class, AppointmentBookedListener::class);
|
||||
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
|
||||
$context->registerEventListener(RenderReferenceEvent::class, CalendarReferenceListener::class);
|
||||
|
||||
$context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarObjectCreatedListener::class);
|
||||
$context->registerNotifierService(Notifier::class);
|
||||
}
|
||||
|
||||
|
||||
59
calendar/lib/Listener/CalendarObjectCreatedListener.php
Normal file
59
calendar/lib/Listener/CalendarObjectCreatedListener.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?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\Calendar\Listener;
|
||||
|
||||
use OCA\Calendar\Service\Appointments\BookingService;
|
||||
use OCA\Calendar\Service\Calendar\CalendarService;
|
||||
use OCA\DAV\Events\CalendarObjectCreatedEvent;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class CalendarObjectCreatedListener implements IEventListener {
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
/** @var \OCA\Calendar\Service\Calendar\CalendarService* */
|
||||
private $calendarService;
|
||||
|
||||
public function __construct(
|
||||
LoggerInterface $logger,CalendarService $calendarService) {
|
||||
$this->logger = $logger;
|
||||
$this->calendarService = $calendarService;
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
if (!($event instanceof CalendarObjectCreatedEvent)) {
|
||||
return;
|
||||
}
|
||||
$calendarData = $event->getObjectData();
|
||||
$vCalendarString = $calendarData["calendardata"];
|
||||
$calendarSummary = $this->calendarService->GetCalendarSummaryFromVCalendarString($vCalendarString);
|
||||
$this->calendarService->createDefuntFromCalendarSummary($calendarSummary);
|
||||
}
|
||||
|
||||
}
|
||||
59
calendar/lib/Service/Calendar/CalendarService.php
Normal file
59
calendar/lib/Service/Calendar/CalendarService.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* @author Anna Larch <anna.larch@gmx.net>
|
||||
* @author Richard Steinmetz <richard@steinmetz.cloud>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library 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 library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Calendar\Service\Calendar;
|
||||
|
||||
use OCA\Gestion\Db\Bdd;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class CalendarService {
|
||||
/** @var Bdd */
|
||||
private $gestionMapper;
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
public function __construct(
|
||||
Bdd $gestionMapper,
|
||||
LoggerInterface $logger) {
|
||||
$this->logger = $logger;
|
||||
$this->gestionMapper = $gestionMapper;
|
||||
}
|
||||
|
||||
public function createDefuntFromCalendarSummary($calendarSummary): bool{
|
||||
return $this->gestionMapper->insertDefuntByName($calendarSummary);
|
||||
}
|
||||
|
||||
public function GetCalendarSummaryFromVCalendarString(string $vCalendarString): string
|
||||
{
|
||||
$summaryValue = "Nom du défunt";
|
||||
preg_match('/SUMMARY:(.*)\r\n/', $vCalendarString, $matches);
|
||||
if (isset($matches[1])) {
|
||||
$summaryValue = trim($matches[1]);
|
||||
}
|
||||
return $summaryValue;
|
||||
}
|
||||
}
|
||||
@ -99,6 +99,17 @@ export default {
|
||||
location() {
|
||||
return this.calendarObjectInstance?.location ?? null
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the client or null if the event is still loading
|
||||
*
|
||||
* @return {string|null}
|
||||
*/
|
||||
client() {
|
||||
return this.calendarObjectInstance?.client ?? null
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Returns the description or null if the event is still loading
|
||||
*
|
||||
@ -322,7 +333,7 @@ export default {
|
||||
* Returns an object with properties from RFCs including
|
||||
* their displayName, a description, options, etc.
|
||||
*
|
||||
* @return {{geo, color, timeTransparency, description, resources, location, categories, accessClass, priority, status, locations, articles}}
|
||||
* @return {{geo, color, timeTransparency, description, resources, location, client, categories, accessClass, priority, status, locations, articles, clients}}
|
||||
*/
|
||||
rfcProps() {
|
||||
return getRFCProperties()
|
||||
@ -476,6 +487,7 @@ export default {
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async save(thisAndAllFuture = false) {
|
||||
console.log("MIDITRA ATO NY SAVE",this.calendarObject);
|
||||
if (!this.calendarObject) {
|
||||
logger.error('Calendar-object not found')
|
||||
return
|
||||
@ -594,6 +606,19 @@ export default {
|
||||
location,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the client of the event
|
||||
*
|
||||
* @param {string} client New client
|
||||
*/
|
||||
updateClient(client) {
|
||||
this.$store.commit('changeClient', {
|
||||
calendarObjectInstance: this.calendarObjectInstance,
|
||||
client,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the start date of this event
|
||||
*
|
||||
|
||||
@ -106,6 +106,7 @@ const mapCDavObjectToCalendarObject = (dav, calendarId) => {
|
||||
* @return {object}
|
||||
*/
|
||||
const mapCalendarJsToCalendarObject = (calendarComponent, calendarId = null) => {
|
||||
console.log("Ary ato mapCalendarJsToCalendarObject");
|
||||
const vObjectIterator = calendarComponent.getVObjectIterator()
|
||||
const firstVObject = vObjectIterator.next().value
|
||||
if (!firstVObject) {
|
||||
|
||||
@ -56,6 +56,8 @@ const getDefaultEventObject = (props = {}) => Object.assign({}, {
|
||||
canModifyAllDay: true,
|
||||
// Location that the event takes places in
|
||||
location: null,
|
||||
//client of the event
|
||||
client : null,
|
||||
// description of the event
|
||||
description: null,
|
||||
// Access class of the event (PUBLIC, PRIVATE, CONFIDENTIAL)
|
||||
@ -102,6 +104,7 @@ const mapEventComponentToEventObject = (eventComponent) => {
|
||||
isAllDay: eventComponent.isAllDay(),
|
||||
canModifyAllDay: eventComponent.canModifyAllDay(),
|
||||
location: eventComponent.location,
|
||||
client : eventComponent.client,
|
||||
description: eventComponent.description,
|
||||
accessClass: eventComponent.accessClass,
|
||||
status: eventComponent.status,
|
||||
@ -199,6 +202,7 @@ const mapEventComponentToEventObject = (eventComponent) => {
|
||||
const copyCalendarObjectInstanceIntoEventComponent = (eventObject, eventComponent) => {
|
||||
eventComponent.title = eventObject.title
|
||||
eventComponent.location = eventObject.location
|
||||
eventComponent.client = eventObject.client
|
||||
eventComponent.description = eventObject.description
|
||||
eventComponent.accessClass = eventObject.accessClass
|
||||
eventComponent.status = eventObject.status
|
||||
|
||||
@ -125,6 +125,23 @@ const getRFCProperties = () => {
|
||||
options: [],
|
||||
},
|
||||
|
||||
clients: {
|
||||
readableName: t('calendar', 'Clients'),
|
||||
icon: 'Tag',
|
||||
searchable: true,
|
||||
multiple: false,
|
||||
info: t('calendar', 'Client from Gestion'),
|
||||
placeholder: t('calendar', 'Add client'),
|
||||
tagPlaceholder: t('calendar', 'Add client'),
|
||||
options: [],
|
||||
},
|
||||
|
||||
client: {
|
||||
readableName: t('calendar', 'client'),
|
||||
placeholder: t('calendar', 'Add a client'),
|
||||
icon: 'MapMarker',
|
||||
},
|
||||
|
||||
articles: {
|
||||
readableName: t('calendar', 'Articles'),
|
||||
icon: 'TextBoxOutline',
|
||||
|
||||
@ -321,6 +321,12 @@ const mutations = {
|
||||
calendarObjectInstance.location = location
|
||||
},
|
||||
|
||||
changeClient(state, { calendarObjectInstance, client }) {
|
||||
console.log("CHANGE CLIENT STORE", client);
|
||||
calendarObjectInstance.eventComponent.client = client
|
||||
calendarObjectInstance.client = client
|
||||
},
|
||||
|
||||
/**
|
||||
* Change the description of an event
|
||||
*
|
||||
@ -1656,6 +1662,10 @@ const actions = {
|
||||
async saveCalendarObjectInstance({ state, dispatch, commit }, { thisAndAllFuture, calendarId }) {
|
||||
const eventComponent = state.calendarObjectInstance.eventComponent
|
||||
const calendarObject = state.calendarObject
|
||||
debugger
|
||||
console.log("EVENNNNNNNTTT COMPONENTTTTT", eventComponent);
|
||||
|
||||
console.log("CALEEEEENNNDDDARRRR OBJEEEEEEEECCCCC TTTTTTT",calendarObject);
|
||||
|
||||
updateAlarms(eventComponent)
|
||||
updateTalkParticipants(eventComponent)
|
||||
@ -1683,6 +1693,7 @@ const actions = {
|
||||
}
|
||||
|
||||
if (calendarId !== state.calendarObject.calendarId) {
|
||||
console.log("MIDITRA ATO AMIN NY MOVE CALENDAR");
|
||||
await dispatch('moveCalendarObject', {
|
||||
calendarObject,
|
||||
newCalendarId: calendarId,
|
||||
|
||||
@ -505,6 +505,7 @@ const actions = {
|
||||
'SUMMARY',
|
||||
'LOCATION',
|
||||
'DESCRIPTION',
|
||||
'CLIENT'
|
||||
])
|
||||
},
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
<EmptyCalendar v-else />
|
||||
|
||||
<EditSimple v-if="showWidgetEventDetails" :is-widget="true" :locations="locations" />
|
||||
<EditSimple v-if="showWidgetEventDetails" :is-widget="true" :clients="clients" />
|
||||
</div>
|
||||
|
||||
<NcContent v-else app-name="calendar calendar-custom" :class="classNames">
|
||||
|
||||
@ -103,6 +103,14 @@
|
||||
@update-end-timezone="updateEndTimezone"
|
||||
@toggle-all-day="toggleAllDay" />
|
||||
|
||||
<PropertySelectAjax class="property-location"
|
||||
url="/apps/gestion/ajaxGetClientsName"
|
||||
:is-read-only="isReadOnly"
|
||||
:prop-model="rfcProps.clients"
|
||||
:value="client"
|
||||
:linkify-links="true"
|
||||
@update:value="updateClient" />
|
||||
|
||||
<PropertySelectAjax class="property-location"
|
||||
url="/apps/gestion/ajaxGetLieux"
|
||||
:is-read-only="isReadOnly"
|
||||
|
||||
@ -121,6 +121,14 @@
|
||||
@update-end-timezone="updateEndTimezone"
|
||||
@toggle-all-day="toggleAllDay" />
|
||||
|
||||
<PropertySelectAjax class="property-location"
|
||||
url="/apps/gestion/ajaxGetClientsName"
|
||||
:is-read-only="isReadOnly"
|
||||
:prop-model="rfcProps.clients"
|
||||
:value="client"
|
||||
:linkify-links="true"
|
||||
@update:value="updateClient" />
|
||||
|
||||
<PropertySelectAjax class="property-location"
|
||||
url="/apps/gestion/ajaxGetLieux"
|
||||
:is-read-only="isReadOnly"
|
||||
|
||||
@ -49,6 +49,7 @@ return [
|
||||
['name' => 'page#ajaxGetLieux', 'url' => '/ajaxGetLieux', 'verb' => 'GET'],
|
||||
['name' => 'page#ajaxGetArticles', 'url' => '/ajaxGetArticles', 'verb' => 'GET'],
|
||||
['name' => 'page#ajaxGetProduits', 'url' => '/ajaxGetProduits', 'verb' => 'GET'],
|
||||
['name' => 'page#ajaxGetClientsName', 'url' => '/ajaxGetClientsName', 'verb' => 'GET'],
|
||||
|
||||
['name' => 'page#getLieux', 'url' => '/getLieux', 'verb' => 'PROPFIND'],
|
||||
['name' => 'page#insertLieu', 'url' => '/lieu/insert', 'verb' => 'POST'],
|
||||
|
||||
@ -1257,6 +1257,14 @@ class PageController extends Controller {
|
||||
return $this->myDb->getLieux($this->idNextcloud);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function ajaxGetClientsName() {
|
||||
return $this->myDb->getClientsName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
|
||||
@ -53,6 +53,13 @@ class Bdd {
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
|
||||
public function getClientsName(){
|
||||
$sql = "SELECT client.nom, client.prenom, client.id
|
||||
FROM ".$this->tableprefix."client as client
|
||||
ORDER BY client.id DESC";
|
||||
return $this->execSQL($sql, array());
|
||||
}
|
||||
|
||||
public function getClient($id,$idNextcloud){
|
||||
$sql = "SELECT * FROM ".$this->tableprefix."client WHERE id = ?";
|
||||
return $this->execSQL($sql, array($id));
|
||||
@ -653,6 +660,18 @@ class Bdd {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert Defunt
|
||||
*/
|
||||
public function insertDefuntByName($name) {
|
||||
$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', 'Référence pacemaker', '', '', ''));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert lieu
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user