generate pdf when creating agenda

This commit is contained in:
Tiavina 2025-02-24 17:40:20 +03:00
parent 3228e93efe
commit 6b7a99879e
4 changed files with 21 additions and 6 deletions

View File

@ -482,6 +482,7 @@ class OrderBdd {
OrderTypeConstant::ORDER_TYPE_DEVIS
)
);
return true;
}
public function getOrderProducts(){

View File

@ -26,11 +26,13 @@ declare(strict_types=1);
namespace OCA\Gestion\Service;
use OCA\Gestion\Constants\BddConstant;
use OCA\Gestion\Constants\DevisMentionConstant;
use OCA\Gestion\Constants\OrderStatusConstant;
use OCA\Gestion\Constants\ThanatoTypeConstant;
use OCA\Gestion\Db\Bdd;
use OCA\Gestion\Db\OrderBdd;
use OCA\Gestion\Service\Order\OrderPdfService;
use Psr\Log\LoggerInterface;
use OCA\Gestion\Helpers\VCalendarHelpers;
@ -44,13 +46,17 @@ class GestionService {
/** @var \OCA\Gestion\Db\OrderBdd */
private $orderBdd;
private $orderPdfService;
public function __construct(
Bdd $gestionBdd,
OrderBdd $orderBdd,
LoggerInterface $logger) {
LoggerInterface $logger,
OrderPdfService $orderPdfService) {
$this->orderBdd = $orderBdd;
$this->logger = $logger;
$this->gestionBdd = $gestionBdd;
$this->orderPdfService = $orderPdfService;
}
private function GetCalendarSummaryFromVCalendarString(string $vCalendarString): string
@ -166,15 +172,23 @@ class GestionService {
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
$devisDate = $calendarStartDate->format('Y-m-d');
$devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId,$clientId,$locationId,$defuntId,$calendarUuid,$devisDate,$userName);
$thanatoIsSubcontractor = $thanato["fk_thanato_type_key"] === ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
if($thanatoIsSubcontractor){
$this->orderBdd->createOrderFromDevisIdAndDate($devisId,$calendarStartDate,$userName);
}
$articlesValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
if(!empty($articlesValue)){
$articleIds = $this->gestionBdd->getArticleIdsByArticleReferences($articlesValue);
$this->gestionBdd->insertDevisArticleFromDevisIdAndArticlesIdArray($devisId, $articleIds);
}
$thanatoIsSubcontractor = $thanato["fk_thanato_type_key"] === ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
if($thanatoIsSubcontractor){
$orderCreated = $this->orderBdd->createOrderFromDevisIdAndDate($devisId,$calendarStartDate,$userName);
if($orderCreated){
$order = $this->orderBdd->getOrderByDevisId($devisId);
$this->logger->debug(json_encode($order));
if($order != null){
$this->orderPdfService->generateOrderPdfByOrderId($order['id'],BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
// $this->orderPdfService->generateOrderPdfByOrderId($order['id'],BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD);
}
}
}
$this->gestionBdd->createDevisTrajetFromVCalendar($devisId,$userName);
}

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
*/
namespace OCA\Gestion\Service\Order;
require_once __DIR__ . '/../../../vendor/autoload.php';
use DateTime;
use OCA\Gestion\Constants\BddConstant;

View File

@ -151,7 +151,6 @@ class OrderService {
$orderDetails["devis_date"] = $orderDetails["order_date"];
}
$orderDetails["products"] = $orderProducts;
var_dump($orderDetails);
return $orderDetails;
}