HOTFIX facture group and simple
This commit is contained in:
parent
25b27a7f32
commit
a0d17190bf
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\Gestion\Controller;
|
||||
|
||||
use OCA\Gestion\Constants\BddConstant;
|
||||
@ -43,9 +44,7 @@ class InvoiceController extends Controller
|
||||
IMailer $mailer,
|
||||
MailerService $mailerService,
|
||||
IUserSession $userSession
|
||||
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->currentUserIdNextcloud = $UserId;
|
||||
$this->invoicePdfService = $invoicePdfService;
|
||||
$this->rootFolder = $rootFolder;
|
||||
@ -68,10 +67,10 @@ class InvoiceController extends Controller
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
|
||||
public function getInvoicePdfContent($factureId){
|
||||
$facture = $this->gestionRepository->getFactureByFactureId($factureId);
|
||||
if($facture == null)
|
||||
public function getInvoicePdfContent($factureId)
|
||||
{
|
||||
$facture = $this->gestionRepository->getFactureByFactureId($factureId);
|
||||
if($facture == null) {
|
||||
return new DataResponse("La facture n'existe pas", 404, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
$factureGeneratedResponse = $this->invoicePdfService->generateFacturePdfByFactureId($factureId, $this->currentUserIdNextcloud);
|
||||
@ -91,8 +90,7 @@ class InvoiceController extends Controller
|
||||
public function sendInvoicePdfViaMail($factureId, $email = '')
|
||||
{
|
||||
$facture = $this->gestionRepository->getFactureByFactureId($factureId);
|
||||
if($facture == null)
|
||||
{
|
||||
if($facture == null) {
|
||||
return new DataResponse("La facture n'existe pas", 404, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
$factureGeneratedResponse = $this->invoicePdfService->generateFacturePdfByFactureId($factureId, $this->currentUserIdNextcloud);
|
||||
@ -109,7 +107,8 @@ class InvoiceController extends Controller
|
||||
$message->attach($content);
|
||||
$message->setSubject("Facture");
|
||||
|
||||
$signature = $this->mailerService->getFooterContent();
|
||||
$signature = $this->mailerService->getFooterContent($this->getUserNameForEmailSignature());
|
||||
|
||||
|
||||
$message->setHtmlBody(
|
||||
"<p>Bonjour.</p>".
|
||||
@ -128,4 +127,11 @@ class InvoiceController extends Controller
|
||||
}
|
||||
return new DataResponse("E-mail envoyé avec succès à ".$email.".", 200, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
|
||||
public function getUserNameForEmailSignature()
|
||||
{
|
||||
$configs = json_decode($this->gestionRepository->getConfiguration(BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD));
|
||||
$currentConfig = $configs[0];
|
||||
return $currentConfig->nom . " " . $currentConfig->prenom;
|
||||
}
|
||||
}
|
||||
@ -3352,6 +3352,7 @@ class Bdd
|
||||
if($factureData == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$products = $this->getDevisProduits($factureData["devis_id"]);
|
||||
$isDevisNegative = $this->isDevisNegative($factureData['devis_id'], $factureData['client_id']);
|
||||
$factureData = $this->setDevisStartAndEndTime($factureData);
|
||||
@ -3359,6 +3360,11 @@ class Bdd
|
||||
$factureData["products"] = $products;
|
||||
$factureData["configuration"] = $configuration;
|
||||
|
||||
// Récupération des informations client et gestion TVA
|
||||
$client = $this->getClientById($factureData['client_id']);
|
||||
$hasTva = ($client && isset($client['tva'])) ? ($client['tva'] == 1) : true;
|
||||
$groupClient = $this->getTvaItracomuIdClient($factureData['client_id']);
|
||||
|
||||
$isClientInsideGroup = $factureData["group_id"] != null;
|
||||
if($isClientInsideGroup) {
|
||||
$factureData["client_real_adress"] = $factureData["group_address"];
|
||||
@ -3371,11 +3377,15 @@ class Bdd
|
||||
$factureData["client_real_adress"] = $clientAdresses["address"];
|
||||
$factureData["client_adress_city"] = $clientAdresses["city"];
|
||||
}
|
||||
|
||||
$factureData['is_negative'] = $isDevisNegative;
|
||||
$factureData["is_tva"] = $hasTva;
|
||||
$factureData["client_tva_intracommu"] = $groupClient["tva_intracommu"];
|
||||
|
||||
$configurationAdresses = FileExportHelpers::GetAddressAndCityFromAddress($configuration->adresse);
|
||||
$factureData["configuration_adresse"] = $configurationAdresses["address"];
|
||||
$factureData["configuration_adresse_city"] = $configurationAdresses["city"];
|
||||
|
||||
return $factureData;
|
||||
}
|
||||
|
||||
|
||||
@ -29,8 +29,8 @@ namespace OCA\Gestion\Service;
|
||||
use OCA\Gestion\Constants\BddConstant;
|
||||
use OCP\Files\IRootFolder;
|
||||
|
||||
class MailerService {
|
||||
|
||||
class MailerService
|
||||
{
|
||||
private $adminStorage;
|
||||
|
||||
public function __construct(
|
||||
@ -38,15 +38,18 @@ class MailerService {
|
||||
) {
|
||||
$this->adminStorage = $rootFolder->getUserFolder(BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD);
|
||||
}
|
||||
public function getFooterContent ($userName = "Johann"){
|
||||
public function getFooterContent($userName = "DEKINDT Vanessa")
|
||||
{
|
||||
$wish = "<p>Vous en souhaitant bonne réception. </p>";
|
||||
$cordialement = "<p> Cordialement,</p>";
|
||||
$userName = "<p> {$userName} </p>" ;
|
||||
$signatureImage = $this->getSignatureHtmlEmailContent();
|
||||
return $wish . $cordialement .$userName . $signatureImage ;
|
||||
// $signatureImage = $this->getSignatureHtmlEmailContent();
|
||||
// return $wish . $cordialement .$userName . $signatureImage ;
|
||||
return $wish . $cordialement .$userName ;
|
||||
}
|
||||
|
||||
private function getSignatureHtmlEmailContent (){
|
||||
private function getSignatureHtmlEmailContent()
|
||||
{
|
||||
$signatureImage = $this->getSignatureContent();
|
||||
if (!$signatureImage) {
|
||||
return "";
|
||||
@ -54,14 +57,15 @@ class MailerService {
|
||||
return "<img width='170' height='80' style= 'width: 170;height: 80px;display:block;' src='data:image/jpeg;base64,".base64_encode($signatureImage)."'>" ;
|
||||
}
|
||||
|
||||
private function getSignatureContent(){
|
||||
private function getSignatureContent()
|
||||
{
|
||||
try {
|
||||
if(isset($this->adminStorage)) {
|
||||
$file = $this->adminStorage->get('/.gestion/sign.jpg');
|
||||
return $file->getContent();
|
||||
}
|
||||
} catch(\OCP\Files\NotFoundException $e) {
|
||||
}
|
||||
catch(\OCP\Files\NotFoundException $e) {}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user