generate devis pdf when creating or updating agenda
This commit is contained in:
parent
9247f2dd4d
commit
6597688b17
@ -32,7 +32,9 @@ use OCA\Gestion\Constants\OrderStatusConstant;
|
|||||||
use OCA\Gestion\Constants\ThanatoTypeConstant;
|
use OCA\Gestion\Constants\ThanatoTypeConstant;
|
||||||
use OCA\Gestion\Db\Bdd;
|
use OCA\Gestion\Db\Bdd;
|
||||||
use OCA\Gestion\Db\OrderBdd;
|
use OCA\Gestion\Db\OrderBdd;
|
||||||
|
use OCA\Gestion\Service\Devis\Pdf\DevisPdfService;
|
||||||
use OCA\Gestion\Service\Order\OrderPdfService;
|
use OCA\Gestion\Service\Order\OrderPdfService;
|
||||||
|
use OCP\DB\Exception;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use OCA\Gestion\Helpers\VCalendarHelpers;
|
use OCA\Gestion\Helpers\VCalendarHelpers;
|
||||||
|
|
||||||
@ -47,16 +49,19 @@ class GestionService {
|
|||||||
private $orderBdd;
|
private $orderBdd;
|
||||||
|
|
||||||
private $orderPdfService;
|
private $orderPdfService;
|
||||||
|
private $devisPdfService;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Bdd $gestionBdd,
|
Bdd $gestionBdd,
|
||||||
OrderBdd $orderBdd,
|
OrderBdd $orderBdd,
|
||||||
LoggerInterface $logger,
|
LoggerInterface $logger,
|
||||||
OrderPdfService $orderPdfService) {
|
OrderPdfService $orderPdfService,
|
||||||
|
DevisPdfService $devisPdfService) {
|
||||||
$this->orderBdd = $orderBdd;
|
$this->orderBdd = $orderBdd;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->gestionBdd = $gestionBdd;
|
$this->gestionBdd = $gestionBdd;
|
||||||
$this->orderPdfService = $orderPdfService;
|
$this->orderPdfService = $orderPdfService;
|
||||||
|
$this->devisPdfService = $devisPdfService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function GetCalendarSummaryFromVCalendarString(string $vCalendarString): string
|
private function GetCalendarSummaryFromVCalendarString(string $vCalendarString): string
|
||||||
@ -152,44 +157,51 @@ class GestionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function HandleCreatedCalendarObject(string $vCalendarString){
|
public function HandleCreatedCalendarObject(string $vCalendarString){
|
||||||
$thanato = $this->GetThanatoFromVCalendarString($vCalendarString);
|
try{
|
||||||
if($thanato != null){
|
$thanato = $this->GetThanatoFromVCalendarString($vCalendarString);
|
||||||
$thanatoId = $thanato["id"];
|
if($thanato != null){
|
||||||
}
|
$thanatoId = $thanato["id"];
|
||||||
else{
|
}
|
||||||
$thanatoId = 0;
|
else{
|
||||||
}
|
$thanatoId = 0;
|
||||||
$calendarSummary = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
|
}
|
||||||
$clientId = $this->GetClientIdFromVCalendarString($vCalendarString);
|
$calendarSummary = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
|
||||||
$locationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
|
$clientId = $this->GetClientIdFromVCalendarString($vCalendarString);
|
||||||
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
|
$locationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
|
||||||
$userName = $this->GetThanatoNameFromVCalendarString($vCalendarString);
|
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
|
||||||
$devisAlreadyCreated = $this->IsDevisAlreadyCreated($clientId,$locationId,$thanatoId,$calendarSummary,$calendarUuid);
|
$userName = $this->GetThanatoNameFromVCalendarString($vCalendarString);
|
||||||
if($devisAlreadyCreated){
|
$devisAlreadyCreated = $this->IsDevisAlreadyCreated($clientId,$locationId,$thanatoId,$calendarSummary,$calendarUuid);
|
||||||
return;
|
if($devisAlreadyCreated){
|
||||||
}
|
return;
|
||||||
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary);
|
}
|
||||||
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
|
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary);
|
||||||
$devisDate = $calendarStartDate->format('Y-m-d');
|
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
|
||||||
$devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId,$clientId,$locationId,$defuntId,$calendarUuid,$devisDate,$userName);
|
$devisDate = $calendarStartDate->format('Y-m-d');
|
||||||
$articlesValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
|
$devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId,$clientId,$locationId,$defuntId,$calendarUuid,$devisDate,$userName);
|
||||||
if(!empty($articlesValue)){
|
$articlesValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
|
||||||
$articleIds = $this->gestionBdd->getArticleIdsByArticleReferences($articlesValue);
|
if(!empty($articlesValue)){
|
||||||
$this->gestionBdd->insertDevisArticleFromDevisIdAndArticlesIdArray($devisId, $articleIds);
|
$articleIds = $this->gestionBdd->getArticleIdsByArticleReferences($articlesValue);
|
||||||
}
|
$this->gestionBdd->insertDevisArticleFromDevisIdAndArticlesIdArray($devisId, $articleIds);
|
||||||
$thanatoIsSubcontractor = $thanato["fk_thanato_type_key"] === ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
|
}
|
||||||
if($thanatoIsSubcontractor){
|
$thanatoIsSubcontractor = $thanato["fk_thanato_type_key"] === ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
|
||||||
$orderCreated = $this->orderBdd->createOrderFromDevisIdAndDate($devisId,$calendarStartDate,$userName);
|
if($thanatoIsSubcontractor){
|
||||||
if($orderCreated){
|
$orderCreated = $this->orderBdd->createOrderFromDevisIdAndDate($devisId,$calendarStartDate,$userName);
|
||||||
$order = $this->orderBdd->getOrderByDevisId($devisId);
|
if($orderCreated){
|
||||||
$this->logger->debug(json_encode($order));
|
$order = $this->orderBdd->getOrderByDevisId($devisId);
|
||||||
if($order != null){
|
$this->logger->debug(json_encode($order));
|
||||||
$this->orderPdfService->generateOrderPdfByOrderId($order['id'],BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
|
if($order != null){
|
||||||
$this->orderPdfService->generateOrderPdfByOrderId($order['id'],BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD);
|
$this->orderPdfService->generateOrderPdfByOrderId($order['id'],BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
|
||||||
|
$this->orderPdfService->generateOrderPdfByOrderId($order['id'],BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->devisPdfService->generateDevisPdfByDevisId($devisId,BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
|
||||||
|
$this->devisPdfService->generateDevisPdfByDevisId($devisId,BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD);
|
||||||
|
$this->gestionBdd->createDevisTrajetFromVCalendar($devisId,$userName);
|
||||||
|
}
|
||||||
|
catch(Exception $e){
|
||||||
|
$this->logger->debug("error creating devis");
|
||||||
}
|
}
|
||||||
$this->gestionBdd->createDevisTrajetFromVCalendar($devisId,$userName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function GetThanatoNameFromVCalendarString($vCalendarString){
|
private function GetThanatoNameFromVCalendarString($vCalendarString){
|
||||||
@ -291,16 +303,23 @@ class GestionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function HandleUpdatedCalendarObject(string $vCalendarString){
|
public function HandleUpdatedCalendarObject(string $vCalendarString){
|
||||||
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
|
try{
|
||||||
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
|
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
|
||||||
if($devis != null){
|
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
|
||||||
$this->gestionBdd->updateDevisMention($devis['id'],DevisMentionConstant::NEW);
|
if($devis != null){
|
||||||
$isDevisAlreadyUpdated = $this->CheckIfDevisIsAlreadyUpdated($devis,$vCalendarString);
|
$this->gestionBdd->updateDevisMention($devis['id'],DevisMentionConstant::NEW);
|
||||||
if($isDevisAlreadyUpdated){
|
$isDevisAlreadyUpdated = $this->CheckIfDevisIsAlreadyUpdated($devis,$vCalendarString);
|
||||||
return true;
|
if($isDevisAlreadyUpdated){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$this->UpdateDevisDataByVCalendarString($devis,$vCalendarString);
|
||||||
}
|
}
|
||||||
$this->UpdateDevisDataByVCalendarString($devis,$vCalendarString);
|
$this->devisPdfService->generateDevisPdfByDevisId($devis['id'],BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
|
||||||
|
$this->devisPdfService->generateDevisPdfByDevisId($devis['id'],BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(Exception $e){
|
||||||
|
$this->logger->debug("error creating devis");
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user