Compare commits

...

24 Commits

Author SHA1 Message Date
Tiavina
b1fabe9804 Merge branch 'staging' into releases/release-hytha-prod 2025-03-27 08:51:59 +03:00
Tiavina
26260359b6 Merge branch 'hytha/hotfixes/error-on-saving-calendar' into staging 2025-03-27 08:51:19 +03:00
Tiavina
f7cee028e6 refactor event listener classes to improve error handling and code formatting 2025-03-27 08:50:42 +03:00
Tiavina
2bbfe390eb Merge branch 'staging' into releases/release-hytha-prod 2025-03-26 19:55:15 +03:00
Tiavina
b1bd756640 Merge branch 'hytha/hotfixes/error-on-saving-calendar' into staging 2025-03-26 19:54:48 +03:00
Tiavina
51890b88e9 refactor logging in calendar object listeners to use debug level 2025-03-26 19:54:26 +03:00
Tiavina
19ae45d96e Merge branch 'hytha/hotfixes/error-on-saving-calendar' into staging 2025-03-26 19:51:33 +03:00
Tiavina
6ac8fc9ecc add error handling for calendar object moved events in GestionService 2025-03-26 19:50:54 +03:00
Tiavina
12a751c1c3 Merge branch 'staging' into releases/release-hytha-prod 2025-03-26 19:43:51 +03:00
Tiavina
41c6e074b0 Merge branch 'hytha/hotfixes/error-on-saving-calendar' into staging 2025-03-26 19:42:51 +03:00
Tiavina
b34c0ff13a add error handling for calendar object creation and update processes 2025-03-26 19:41:01 +03:00
Tiavina
0276655040 Merge branch 'features/feature-devis-group' into releases/release-hytha-prod 2025-03-26 13:06:50 +03:00
Tiavina
5ab91d4be7 Merge branch 'staging' into releases/release-hytha-prod 2025-03-25 13:34:15 +03:00
Tiavina
91c67452c2 Merge branch 'staging' into releases/release-hytha-prod 2025-03-21 09:29:13 +03:00
Tiavina
31633b04d9 Merge branch 'hotfixes/hotfix-update-client' into releases/release-hytha-prod 2025-03-19 11:38:00 +03:00
Tiavina
dc3da8d425 Merge branch 'hotfixes/hotfix-update-client' into releases/release-hytha-prod 2025-03-19 10:50:02 +03:00
Tiavina
ea119f5c73 Merge branch 'hotfixes/hotfix-update-client' into releases/release-hytha-prod 2025-03-19 10:43:24 +03:00
Tiavina
4bd86ae762 Merge branch 'hotfixes/hotfix-update-client' into releases/release-hytha-prod 2025-03-19 10:30:55 +03:00
Tiavina
2c1e771472 Merge branch 'hotfixes/hotfix-update-client' into releases/release-hytha-prod 2025-03-19 10:13:45 +03:00
Tiavina
c07c4aaf88 Merge branch 'staging' into releases/release-hytha-prod 2025-03-18 10:19:21 +03:00
Tiavina
95be6e4827 Merge branch 'staging' into releases/release-hytha-prod 2025-03-17 16:16:16 +03:00
Tiavina
e7c51a4d73 Merge branch 'fixes/fix-rapport-bijoux-text' into releases/release-hytha-prod 2025-03-13 12:06:47 +03:00
Tiavina
f509f5e988 Merge branch 'staging' into releases/release-hytha-prod 2025-03-13 10:53:37 +03:00
Tiavina
f8ff4c6b3e Merge branch 'hotfixes/hotfixe-show-facture-case-and-order-number' into releases/release-hytha-prod 2025-03-07 13:17:00 +03:00
11 changed files with 227 additions and 159 deletions

View File

@ -8,7 +8,7 @@ abstract class BddConstant
const DEFAULT_TABLE_PREFIX = "*PREFIX*";
const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
const DEFAULT_ADMIN_ID_NEXTCLOUD = 'admin';
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "admin";
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "Johann";
const ISLEAVEPROPERTYONVCALENDAR = "ISLEAVE";

View File

@ -25,13 +25,15 @@ declare(strict_types=1);
namespace OCA\Gestion\Listener;
use Exception;
use OCA\DAV\Events\CalendarObjectCreatedEvent;
use OCA\Gestion\Service\GestionService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use Psr\Log\LoggerInterface;
class CalendarObjectCreatedListener implements IEventListener {
class CalendarObjectCreatedListener implements IEventListener
{
/** @var LoggerInterface */
private $logger;
@ -40,18 +42,27 @@ class CalendarObjectCreatedListener implements IEventListener {
private $gestionService;
public function __construct(
LoggerInterface $logger,GestionService $gestionService) {
LoggerInterface $logger,
GestionService $gestionService
) {
$this->logger = $logger;
$this->gestionService = $gestionService;
}
public function handle(Event $event): void {
public function handle(Event $event): void
{
if (!($event instanceof CalendarObjectCreatedEvent)) {
return;
}
$calendarData = $event->getObjectData();
$vCalendarString = $calendarData["calendardata"];
$this->gestionService->HandleCreatedCalendarObject($vCalendarString);
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

@ -25,13 +25,15 @@ declare(strict_types=1);
namespace OCA\Gestion\Listener;
use Exception;
use OCA\DAV\Events\CalendarObjectMovedEvent;
use OCA\Gestion\Service\GestionService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use Psr\Log\LoggerInterface;
class CalendarObjectMovedListener implements IEventListener {
class CalendarObjectMovedListener implements IEventListener
{
/** @var LoggerInterface */
private $logger;
@ -40,19 +42,28 @@ class CalendarObjectMovedListener implements IEventListener {
private $gestionService;
public function __construct(
LoggerInterface $logger,GestionService $gestionService) {
LoggerInterface $logger,
GestionService $gestionService
) {
$this->logger = $logger;
$this->gestionService = $gestionService;
}
public function handle(Event $event): void {
public function handle(Event $event): void
{
if (!($event instanceof CalendarObjectMovedEvent)) {
return;
}
$calendarData = $event->getObjectData();
$targetCalendarId = $event->getTargetCalendarId();
$vCalendarString = $calendarData["calendardata"];
$this->gestionService->HandleCalendarObjectMoved($vCalendarString,$targetCalendarId);
try {
$targetCalendarId = $event->getTargetCalendarId();
$vCalendarString = $calendarData["calendardata"];
$this->gestionService->HandleCalendarObjectMoved($vCalendarString, $targetCalendarId);
} catch (\OC\OCS\Exception $e) {
$this->logger->debug("Error while handling calendar object moved event: " . $e->getMessage());
} catch (\Throwable $e) {
$this->logger->debug("Error while handling calendar object moved event: " . $e->getMessage());
}
}
}

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
namespace OCA\Gestion\Listener;
use Exception;
use OCA\DAV\Events\CalendarObjectCreatedEvent;
use OCA\DAV\Events\CalendarObjectUpdatedEvent;
use OCA\Gestion\Service\GestionService;
@ -32,7 +33,8 @@ use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use Psr\Log\LoggerInterface;
class CalendarObjectUpdatedListener implements IEventListener {
class CalendarObjectUpdatedListener implements IEventListener
{
/** @var LoggerInterface */
private $logger;
@ -41,18 +43,27 @@ class CalendarObjectUpdatedListener implements IEventListener {
private $gestionService;
public function __construct(
LoggerInterface $logger,GestionService $gestionService) {
LoggerInterface $logger,
GestionService $gestionService
) {
$this->logger = $logger;
$this->gestionService = $gestionService;
}
public function handle(Event $event): void {
public function handle(Event $event): void
{
if (!($event instanceof CalendarObjectUpdatedEvent)) {
return;
}
$calendarData = $event->getObjectData();
$vCalendarString = $calendarData["calendardata"];
$this->gestionService->HandleUpdatedCalendarObject($vCalendarString);
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

@ -42,7 +42,7 @@ class CareCertificatePdfHandler extends FPDF {
function Header()
{
if($this->logo != "nothing"){
$this->Image($this->imagePath."logo.png", 10, 10,50,35);
$this->Image($this->imagePath."logo.png", 10, 10, 75, 25);
}
else{
$this->Cell(55,30,'');

View File

@ -42,7 +42,7 @@ class PacemakerCertificatePdfHandler extends FPDF {
function Header()
{
if($this->logo != "nothing"){
$this->Image($this->imagePath."logo.png", 10, 10, 50,35);
$this->Image($this->imagePath."logo.png", 10, 10, 75, 25);
}
else{
$this->Cell(55,30,'');

View File

@ -40,7 +40,7 @@ class DevisPdfHandler extends FPDF {
function Header()
{
if($this->logo != "nothing"){
$this->Image($this->logoPath."logo.png", 2, 2, 50,35);
$this->Image($this->logoPath."logo.png", 10, 10, 75, 25);
}
else{
$this->Cell(55,30,'');

View File

@ -26,6 +26,7 @@ declare(strict_types=1);
namespace OCA\Gestion\Service;
use Exception;
use OCA\Gestion\Constants\BddConstant;
use OCA\Gestion\Constants\DevisMentionConstant;
use OCA\Gestion\Constants\VCalendarPropertyConstant;
@ -34,76 +35,80 @@ use OCP\IUserSession;
use Psr\Log\LoggerInterface;
use OCA\Gestion\Helpers\VCalendarHelpers;
class GestionService {
/** @var Bdd */
private $gestionBdd;
class GestionService
{
/** @var Bdd */
private $gestionBdd;
/** @var LoggerInterface */
private $logger;
/** @var LoggerInterface */
private $logger;
/** @var TalkService */
private $talkService;
private $talkService;
private $userConnectedUuid;
public function __construct(
Bdd $gestionBdd,
LoggerInterface $logger,
public function __construct(
Bdd $gestionBdd,
LoggerInterface $logger,
TalkService $talkService,
IUserSession $userSession) {
$this->logger = $logger;
$this->gestionBdd = $gestionBdd;
IUserSession $userSession
) {
$this->logger = $logger;
$this->gestionBdd = $gestionBdd;
$this->talkService = $talkService;
try{
try {
$this->userConnectedUuid = $userSession->getUser()->getUID();
}
catch(Exception){
} catch (Exception) {
$this->userConnectedUuid = BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD;
}
}
}
private function GetIsCalendarPendingFromVCalendarString(string $vCalendarString): bool{
private function GetIsCalendarPendingFromVCalendarString(string $vCalendarString): bool
{
$isCalendarPending = false;
$isCalendarPendingValue = VCalendarHelpers::GetValueFromKeyInVCalendarString(VCalendarPropertyConstant::PROPERTY_IS_CALENDAR_PENDING, $vCalendarString);
if($isCalendarPendingValue == "1"){
if ($isCalendarPendingValue == "1") {
$isCalendarPending = true;
}
return $isCalendarPending;
}
private function GetIsLeaveFromVCalendarString(string $vCalendarString): bool{
private function GetIsLeaveFromVCalendarString(string $vCalendarString): bool
{
$isLeave = false;
$isLeaveValue = VCalendarHelpers::GetValueFromKeyInVCalendarString(VCalendarPropertyConstant::PROPERTY_IS_LEAVE, $vCalendarString);
if($isLeaveValue == "1"){
if ($isLeaveValue == "1") {
$isLeave = true;
}
return $isLeave;
}
private function GetCalendarSummaryFromVCalendarString(string $vCalendarString): string
{
$summaryValue = "Nom du défunt";
$value = VCalendarHelpers::GetValueFromKeyInVCalendarString("SUMMARY", $vCalendarString);
if($value !== ""){
private function GetCalendarSummaryFromVCalendarString(string $vCalendarString): string
{
$summaryValue = "Nom du défunt";
$value = VCalendarHelpers::GetValueFromKeyInVCalendarString("SUMMARY", $vCalendarString);
if ($value !== "") {
$summaryValue = trim($value);
}
return $summaryValue;
}
}
private function GetThanatoIdFromVCalendarString(string $vCalendarString)
{
$thanatoId = 0;
$organizerName = $this->getPrincipalUsernameFromVCalendarString($vCalendarString);
if($organizerName != null){
if ($organizerName != null) {
$thanatoIdFromDb = $this->gestionBdd->getThanatoIdByUserUuid($organizerName);
if($thanatoIdFromDb != null){
$thanatoId = $thanatoIdFromDb;
if ($thanatoIdFromDb != null) {
$thanatoId = $thanatoIdFromDb;
}
}
return $thanatoId;
}
private function getPrincipalUsernameFromVCalendarString(string $vCalendarString){
private function getPrincipalUsernameFromVCalendarString(string $vCalendarString)
{
$calendarUuid = VCalendarHelpers::GetValueFromKeyInVCalendarString("UID", $vCalendarString);
$principalUsername = $this->gestionBdd->getCalendarOrganizerNameByCalendarObjectUuid($calendarUuid);
return $principalUsername;
@ -118,15 +123,17 @@ class GestionService {
return $names;
}
private function IsDevisAlreadyCreated($clientId,$locationId,$thanatoId,$defuntName,$calendarUuid="not-related"){
private function IsDevisAlreadyCreated($clientId, $locationId, $thanatoId, $defuntName, $calendarUuid = "not-related")
{
$defuntId = $this->gestionBdd->getLastDefuntIdByName($defuntName);
$devisId = $this->gestionBdd->getLastDevisIdFromVCalendarProperty($thanatoId,$clientId,$locationId,$defuntId,$calendarUuid);
$devisId = $this->gestionBdd->getLastDevisIdFromVCalendarProperty($thanatoId, $clientId, $locationId, $defuntId, $calendarUuid);
return $devisId != null;
}
private function GetDevisCommentFromVCalendarString(string $vCalendarString){
private function GetDevisCommentFromVCalendarString(string $vCalendarString)
{
$commentValue = VCalendarHelpers::GetValueFromKeyInVCalendarString("COMMENT", $vCalendarString);
if($commentValue == ""){
if ($commentValue == "") {
$commentValue = "Commentaire";
}
return $commentValue;
@ -135,51 +142,55 @@ class GestionService {
private function GetCalendarUuidFromVCalendarString(string $vCalendarString): string
{
$calendarUuid = VCalendarHelpers::GetValueFromKeyInVCalendarString("UID", $vCalendarString);
if($calendarUuid == ""){
if ($calendarUuid == "") {
$calendarUuid = $this->gestionBdd::DEFAULT_CALENDAR_UUID_FOR_DEVIS;
}
return $calendarUuid;
}
private function GetCalendarDateFromVCalendarString(string $vCalendarString){
$calendarStartDate = VCalendarHelpers::GetDateStartOrDateEndFromVCalendarString('DTSTART',$vCalendarString);
private function GetCalendarDateFromVCalendarString(string $vCalendarString)
{
$calendarStartDate = VCalendarHelpers::GetDateStartOrDateEndFromVCalendarString('DTSTART', $vCalendarString);
$calendarStartDate = $calendarStartDate->format('Y-m-d');
return $calendarStartDate;
}
public function HandleCalendarObjectMovedToTrash(string $vCalendarString){
public function HandleCalendarObjectMovedToTrash(string $vCalendarString)
{
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
if($devis != null){
if ($devis != null) {
$this->gestionBdd->updateDevisMentionToCanceled($devis['id']);
}
return true;
}
private function UpdateDevisDataByVCalendarString($devis,$vCalendarString){
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']);
$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']);
$this->gestionBdd->updateDevisClient($devis['id'], $requestedClientId, $devis['client_id']);
$requestLocationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
$this->gestionBdd->updateDevisLieu($devis['id'],$requestLocationId,$devis['lieu_id']);
$this->gestionBdd->updateDevisLieu($devis['id'], $requestLocationId, $devis['lieu_id']);
$requestedDevisComment = $this->GetDevisCommentFromVCalendarString($vCalendarString);
$this->gestionBdd->updateDevisComment($devis['id'],$requestedDevisComment,$devis['comment']);
$this->gestionBdd->updateDevisComment($devis['id'], $requestedDevisComment, $devis['comment']);
$requestedDevisDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
$this->gestionBdd->updateDevisDate($devis['id'],$requestedDevisDate);
$this->gestionBdd->updateDevisDate($devis['id'], $requestedDevisDate);
$articlesValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
if(!empty($articlesValue)){
if (!empty($articlesValue)) {
$articleIds = $this->gestionBdd->getArticleIdsByArticleReferences($articlesValue);
$this->gestionBdd->updateDevisArticles($devis['id'],$articleIds);
$this->gestionBdd->updateDevisArticles($devis['id'], $articleIds);
}
}
private function CheckIfDevisIsAlreadyUpdated($devis,$vCalendarString){
private function CheckIfDevisIsAlreadyUpdated($devis, $vCalendarString)
{
$requestedDefuntName = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
$requestedClientId = $this->GetClientIdFromVCalendarString($vCalendarString);
$requestLocationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
@ -189,131 +200,155 @@ class GestionService {
$requestedDevisDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
$articleDevis = $this->gestionBdd->getProduitDevisByDevisId($devis['id']);
$articleDevisIds = [];
foreach($articleDevis as $currentArticleDevis){
foreach ($articleDevis as $currentArticleDevis) {
$articleDevisIds[] = $currentArticleDevis['produit_id'];
}
sort($requestedArticleIds);
sort($articleDevisIds);
return
$devis['defunt_nom'] == $requestedDefuntName &&
$devis['client_id'] == $requestedClientId &&
$devis['lieu_id'] == $requestLocationId &&
return
$devis['defunt_nom'] == $requestedDefuntName &&
$devis['client_id'] == $requestedClientId &&
$devis['lieu_id'] == $requestLocationId &&
$devis['comment'] == $requestedDevisComment &&
$requestedArticleIds == $articleDevisIds &&
$devis['date'] == $requestedDevisDate;
$devis['date'] == $requestedDevisDate;
}
public function HandleUpdatedCalendarObject(string $vCalendarString){
$isCalendarForLeave = $this->GetIsLeaveFromVCalendarString($vCalendarString);
if($isCalendarForLeave){
//from devis calendar to leave calendar
public function HandleUpdatedCalendarObject(string $vCalendarString)
{
try {
$isCalendarForLeave = $this->GetIsLeaveFromVCalendarString($vCalendarString);
if ($isCalendarForLeave) {
//from devis calendar to leave calendar
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
if ($devis != null) {
$this->gestionBdd->updateDevisMentionToCanceled($devis['id']);
}
return;
}
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
if($devis != null){
$this->gestionBdd->updateDevisMentionToCanceled($devis['id']);
if ($devis != null) {
$isDevisAlreadyUpdated = $this->CheckIfDevisIsAlreadyUpdated($devis, $vCalendarString);
if ($isDevisAlreadyUpdated) {
return true;
}
$devisIsAlreadyFactured = $devis['mentions'] == DevisMentionConstant::FACTURED || $devis['mentions'] == DevisMentionConstant::FACTURED_FORMATTED;
$this->UpdateDevisDataByVCalendarString($devis, $vCalendarString);
if ($devisIsAlreadyFactured == false) {
$userName = $this->GetThanatoNameFromVCalendarString($vCalendarString);
$devisTalkMessage = $this->gestionBdd->getDevisTalkRoomMessage($devis['id'], $userName);
$this->talkService->sendDevisTalkNotifications($devisTalkMessage, $userName, $this->userConnectedUuid);
}
} else {
//update from calendar leave or calendar pending to calendar devis
$this->HandleCreatedCalendarObject($vCalendarString);
}
return;
}
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
if($devis != null){
$isDevisAlreadyUpdated = $this->CheckIfDevisIsAlreadyUpdated($devis,$vCalendarString);
if($isDevisAlreadyUpdated){
return true;
}
$devisIsAlreadyFactured = $devis['mentions'] == DevisMentionConstant::FACTURED || $devis['mentions'] == DevisMentionConstant::FACTURED_FORMATTED;
$this->UpdateDevisDataByVCalendarString($devis,$vCalendarString);
if($devisIsAlreadyFactured == false){
$userName = $this->GetThanatoNameFromVCalendarString($vCalendarString);
$devisTalkMessage = $this->gestionBdd->getDevisTalkRoomMessage($devis['id'],$userName);
$this->talkService->sendDevisTalkNotifications($devisTalkMessage,$userName,$this->userConnectedUuid);
}
}
else{
//update from calendar leave or calendar pending to calendar devis
$this->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());
}
return true;
}
public function HandleCalendarObjectMoved(string $vCalendarString,$targetCalendarId){
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$isCalendarForLeave = $this->GetIsLeaveFromVCalendarString($vCalendarString);
$isCalendarDevis = $isCalendarForLeave == false;
if($isCalendarDevis){
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
if($devis != null){
$userPrincipalName = $this->gestionBdd->getCalendarPrincipalNameByCalendarId($targetCalendarId);
if($userPrincipalName != null){
$thanatoId = $this->gestionBdd->getThanatoIdByUserUuid($userPrincipalName);
if($thanatoId != null){
$thanatoHasBeenChanged = $thanatoId != $devis["id_thanato"];
if($thanatoHasBeenChanged){
$this->gestionBdd->updateDevisThanato($devis['id'],$thanatoId);
public function HandleCalendarObjectMoved(string $vCalendarString, $targetCalendarId)
{
try {
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$isCalendarForLeave = $this->GetIsLeaveFromVCalendarString($vCalendarString);
$isCalendarDevis = $isCalendarForLeave == false;
if ($isCalendarDevis) {
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
if ($devis != null) {
$userPrincipalName = $this->gestionBdd->getCalendarPrincipalNameByCalendarId($targetCalendarId);
if ($userPrincipalName != null) {
$thanatoId = $this->gestionBdd->getThanatoIdByUserUuid($userPrincipalName);
if ($thanatoId != null) {
$thanatoHasBeenChanged = $thanatoId != $devis["id_thanato"];
if ($thanatoHasBeenChanged) {
$this->gestionBdd->updateDevisThanato($devis['id'], $thanatoId);
}
}
}
}
}
} catch (\OC\OCS\Exception $e) {
$this->logger->debug("Error while handling calendar object moved event: " . $e->getMessage());
} catch (\Throwable $e) {
$this->logger->debug("Error while handling calendar object moved event: " . $e->getMessage());
}
}
public function HandleCreatedCalendarObject(string $vCalendarString){
$isCalendarForLeave = $this->GetIsLeaveFromVCalendarString($vCalendarString);
if($isCalendarForLeave){
return;
public function HandleCreatedCalendarObject(string $vCalendarString)
{
try {
$isCalendarForLeave = $this->GetIsLeaveFromVCalendarString($vCalendarString);
if ($isCalendarForLeave) {
return;
}
$isCalendarPending = $this->GetIsCalendarPendingFromVCalendarString($vCalendarString);
if ($isCalendarPending) {
return;
}
$calendarSummary = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
$clientId = $this->GetClientIdFromVCalendarString($vCalendarString);
$locationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
$thanatoId = $this->GetThanatoIdFromVCalendarString($vCalendarString);
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$userName = $this->GetThanatoNameFromVCalendarString($vCalendarString);
$devisAlreadyCreated = $this->IsDevisAlreadyCreated($clientId, $locationId, $thanatoId, $calendarSummary, $calendarUuid);
if ($devisAlreadyCreated) {
return;
}
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary);
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
$devisComment = $this->GetDevisCommentFromVCalendarString($vCalendarString);
$devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId, $clientId, $locationId, $defuntId, $calendarUuid, $calendarStartDate, $devisComment);
$articlesValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
if (!empty($articlesValue)) {
$articleIds = $this->gestionBdd->getArticleIdsByArticleReferences($articlesValue);
$this->gestionBdd->insertDevisArticleFromDevisIdAndArticlesIdArray($devisId, $articleIds);
}
$devisTalkMessage = $this->gestionBdd->getDevisTalkRoomMessage($devisId, $userName);
$this->talkService->sendDevisTalkNotifications($devisTalkMessage, $userName, $this->userConnectedUuid);
$this->gestionBdd->createDevisTrajetFromVCalendar($devisId, $userName);
} 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());
}
$isCalendarPending = $this->GetIsCalendarPendingFromVCalendarString($vCalendarString);
if($isCalendarPending){
return;
}
$calendarSummary = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
$clientId = $this->GetClientIdFromVCalendarString($vCalendarString);
$locationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
$thanatoId = $this->GetThanatoIdFromVCalendarString($vCalendarString);
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
$userName = $this->GetThanatoNameFromVCalendarString($vCalendarString);
$devisAlreadyCreated = $this->IsDevisAlreadyCreated($clientId,$locationId,$thanatoId,$calendarSummary,$calendarUuid);
if($devisAlreadyCreated){
return;
}
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary);
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
$devisComment = $this->GetDevisCommentFromVCalendarString($vCalendarString);
$devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId,$clientId,$locationId,$defuntId,$calendarUuid,$calendarStartDate,$devisComment);
$articlesValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
if(!empty($articlesValue)){
$articleIds = $this->gestionBdd->getArticleIdsByArticleReferences($articlesValue);
$this->gestionBdd->insertDevisArticleFromDevisIdAndArticlesIdArray($devisId, $articleIds);
}
$devisTalkMessage = $this->gestionBdd->getDevisTalkRoomMessage($devisId,$userName);
$this->talkService->sendDevisTalkNotifications($devisTalkMessage,$userName,$this->userConnectedUuid);
$this->gestionBdd->createDevisTrajetFromVCalendar($devisId,$userName);
}
private function GetThanatoNameFromVCalendarString($vCalendarString){
private function GetThanatoNameFromVCalendarString($vCalendarString)
{
$thanatoName = $this->getPrincipalUsernameFromVCalendarString($vCalendarString);
return $thanatoName ?? BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD;
}
private function GetClientIdFromVCalendarString(string $vCalendarString){
private function GetClientIdFromVCalendarString(string $vCalendarString)
{
$this->logger->debug($vCalendarString);
$clientValue = VCalendarHelpers::GetValueFromKeyInVCalendarString("CLIENT", $vCalendarString);
if($clientValue == null || $clientValue == ""){
if ($clientValue == null || $clientValue == "") {
$clientValue = 0;
}
return (int)$clientValue;
return (int) $clientValue;
}
private function GetLocationIdFromVCalendarString(string $vCalendarString){
private function GetLocationIdFromVCalendarString(string $vCalendarString)
{
$locationValue = VCalendarHelpers::GetValueFromKeyInVCalendarString("LOCATION", $vCalendarString);
if($locationValue == null || $locationValue == ""){
if ($locationValue == null || $locationValue == "") {
$locationValue = 0;
}
return (int)$locationValue;
return (int) $locationValue;
}
private function GetArticlesNameFromVCalendarString(string $vCalendarString): array {
private function GetArticlesNameFromVCalendarString(string $vCalendarString): array
{
$devisArticleValue = VCalendarHelpers::GetValueFromKeyInVCalendarString("DESCRIPTION", $vCalendarString);
$articles = explode('\;', $devisArticleValue);
$mapped = array_map('trim', $articles);

View File

@ -54,7 +54,7 @@ class InvoiceGroupPdfHandler extends FPDF {
function Header()
{
if($this->logo != "nothing"){
$this->Image($this->logoPath."logo.png", 2, 2, 50,35);
$this->Image($this->logoPath."logo.png", 2, 2, 75, 25);
}
else{
$this->Cell(55,30,'');

View File

@ -45,7 +45,7 @@ class InvoicePdfHandler extends FPDF {
function Header()
{
if($this->logo != "nothing"){
$this->Image($this->logoPath."logo.png", 2, 2, 50,35);
$this->Image($this->logoPath."logo.png", 10, 10, 75, 25);
}
else{
$this->Cell(55,30,'');

View File

@ -171,7 +171,7 @@ class InvoiceRecapService {
// logo : 80 de largeur et 55 de hauteur
if($doesLogoExist){
$pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35);
$pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25);
}
//adresse de mon entreprise
@ -276,7 +276,7 @@ class InvoiceRecapService {
$pdf->SetMargins(0,0,10);
if($doesLogoExist){
$pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35);
$pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25);
}
//adresse de mon entreprise
@ -588,7 +588,7 @@ class InvoiceRecapService {
// logo : 80 de largeur et 55 de hauteur
if($doesLogoExist){
$pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35);
$pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25);
}
//adresse de mon entreprise
@ -691,7 +691,7 @@ class InvoiceRecapService {
$pdf->SetAutoPagebreak(False);
$pdf->SetMargins(0,0,10);
if($doesLogoExist){
$pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35);
$pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25);
}
//adresse de mon entreprise