set send mail cc to app admin in BddConstant
This commit is contained in:
parent
569607233a
commit
0c9fcc8cbe
@ -8,7 +8,7 @@ abstract class BddConstant
|
|||||||
const DEFAULT_TABLE_PREFIX = "*PREFIX*";
|
const DEFAULT_TABLE_PREFIX = "*PREFIX*";
|
||||||
const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
|
const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
|
||||||
const DEFAULT_ADMIN_ID_NEXTCLOUD = 'admin';
|
const DEFAULT_ADMIN_ID_NEXTCLOUD = 'admin';
|
||||||
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "admin";
|
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "Johann";
|
||||||
|
|
||||||
const ISLEAVEPROPERTYONVCALENDAR = "ISLEAVE";
|
const ISLEAVEPROPERTYONVCALENDAR = "ISLEAVE";
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace OCA\Gestion\Controller;
|
namespace OCA\Gestion\Controller;
|
||||||
|
|
||||||
|
use OCA\Gestion\Constants\BddConstant;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
use OCP\DB\Exception;
|
use OCP\DB\Exception;
|
||||||
@ -94,10 +95,6 @@ class InvoiceController extends Controller
|
|||||||
{
|
{
|
||||||
return new DataResponse("La facture n'existe pas", 404, ['Content-Type' => 'application/json']);
|
return new DataResponse("La facture n'existe pas", 404, ['Content-Type' => 'application/json']);
|
||||||
}
|
}
|
||||||
$factureClientMail = $this->gestionRepository->getFactureClientMailByFactureId($factureId);
|
|
||||||
if($factureClientMail == null){
|
|
||||||
return new DataResponse("Le mail de la facture n'existe pas", 404, ['Content-Type' => 'application/json']);
|
|
||||||
}
|
|
||||||
$factureGeneratedResponse = $this->invoicePdfService->generateFacturePdfByFactureId($factureId,$this->currentUserIdNextcloud);
|
$factureGeneratedResponse = $this->invoicePdfService->generateFacturePdfByFactureId($factureId,$this->currentUserIdNextcloud);
|
||||||
if($factureGeneratedResponse == null){
|
if($factureGeneratedResponse == null){
|
||||||
return new DataResponse("La facture n'a pas été générée correctement", 404, ['Content-Type' => 'application/json']);
|
return new DataResponse("La facture n'a pas été générée correctement", 404, ['Content-Type' => 'application/json']);
|
||||||
@ -119,9 +116,9 @@ class InvoiceController extends Controller
|
|||||||
"<p> Vous trouverez en pièce jointe la facture des soins de « " . $factureDate . " » .</p>".
|
"<p> Vous trouverez en pièce jointe la facture des soins de « " . $factureDate . " » .</p>".
|
||||||
$signature
|
$signature
|
||||||
);
|
);
|
||||||
$authUserEmail = $this->user->getEMailAddress();
|
$appAdminEmail = $this->gestionRepository->getUserEmailByNextcloudId(BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
|
||||||
if ($authUserEmail) {
|
if ($appAdminEmail) {
|
||||||
$message->setCc([$authUserEmail]);
|
$message->setCc([$appAdminEmail]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->mailer->send($message);
|
$this->mailer->send($message);
|
||||||
|
|||||||
@ -1619,9 +1619,9 @@ class PageController extends Controller {
|
|||||||
$signature
|
$signature
|
||||||
);
|
);
|
||||||
|
|
||||||
$authUserEmail = $this->user->getEMailAddress();
|
$appAdminEmail = $this->myDb->getUserEmailByNextcloudId(BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
|
||||||
if ($authUserEmail) {
|
if ($appAdminEmail) {
|
||||||
$message->setCc([$authUserEmail]);
|
$message->setCc([$appAdminEmail]);
|
||||||
}
|
}
|
||||||
$this->mailer->send($message);
|
$this->mailer->send($message);
|
||||||
return new DataResponse("", 200, ['Content-Type' => 'application/json']);
|
return new DataResponse("", 200, ['Content-Type' => 'application/json']);
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
namespace OCA\Gestion\Db;
|
namespace OCA\Gestion\Db;
|
||||||
|
|
||||||
use \Datetime;
|
use \Datetime;
|
||||||
|
use OCA\Gestion\Helpers\MailHelpers;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
@ -5147,4 +5148,24 @@ COMMENTAIRES: ".$comment;
|
|||||||
|
|
||||||
return $mail;
|
return $mail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getUserAccountDataByNextcloudId($nextcloudId)
|
||||||
|
{
|
||||||
|
$sql = "SELECT * FROM " . self::DEFAULT_TABLE_PREFIX . "accounts as user_account WHERE user_account.uid = ? LIMIT 1;";
|
||||||
|
$result = $this->execSQLNoJsonReturn($sql, [$nextcloudId]);
|
||||||
|
if (!empty($result)) {
|
||||||
|
return $result[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUserEmailByNextcloudId($nextcloudId)
|
||||||
|
{
|
||||||
|
$userAccount = $this->getUserAccountDataByNextcloudId($nextcloudId);
|
||||||
|
if ($userAccount != null) {
|
||||||
|
$userEmail = MailHelpers::getUserMailFromUserAccountData($userAccount['data']);
|
||||||
|
return $userEmail;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
gestion/lib/Helpers/MailHelpers.php
Normal file
18
gestion/lib/Helpers/MailHelpers.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace OCA\Gestion\Helpers;
|
||||||
|
|
||||||
|
|
||||||
|
class MailHelpers
|
||||||
|
{
|
||||||
|
public static function getUserMailFromUserAccountData(string $userAccountData): string|null
|
||||||
|
{
|
||||||
|
$userAccountData = json_decode($userAccountData, true);
|
||||||
|
if (isset($userAccountData['email']) && isset($userAccountData['email']['value'])) {
|
||||||
|
return $userAccountData['email']['value'];
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user