finish commande from devis, wip prevent user from update commande when type devis, wip commande purchase
This commit is contained in:
parent
262bdb7676
commit
b92bd79946
9
gestion/lib/Constants/OrderTypeConstant.php
Normal file
9
gestion/lib/Constants/OrderTypeConstant.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace OCA\Gestion\Constants;
|
||||||
|
abstract class OrderTypeConstant
|
||||||
|
{
|
||||||
|
const ORDER_TYPE_DEVIS = "DEVIS";
|
||||||
|
const ORDER_TYPE_PURCHASE = "PURCHASE";
|
||||||
|
}
|
||||||
@ -2330,6 +2330,30 @@ class Bdd {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDevisProduitsReferences($devisId){
|
||||||
|
$sql = "SELECT
|
||||||
|
produit_devis.id,
|
||||||
|
produit_devis.devis_id,
|
||||||
|
produit_devis.produit_id,
|
||||||
|
produit.reference as produit_reference
|
||||||
|
FROM ".$this->tableprefix ."produit_devis as produit_devis
|
||||||
|
LEFT JOIN ".$this->tableprefix."produit as produit on produit_devis.produit_id = produit.id
|
||||||
|
WHERE produit_devis.devis_id = ?;";
|
||||||
|
|
||||||
|
$produitList = $this->execSQLNoJsonReturn(
|
||||||
|
$sql,
|
||||||
|
[$devisId]);
|
||||||
|
|
||||||
|
$produitReferences = [];
|
||||||
|
foreach($produitList as $produit){
|
||||||
|
if($produit["produit_reference"] != null){
|
||||||
|
$produitReferences[] = $produit["produit_reference"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$produitReferences = array_unique($produitReferences);
|
||||||
|
return $produitReferences;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDevisProduits($devisId){
|
public function getDevisProduits($devisId){
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
produit_devis.id,
|
produit_devis.id,
|
||||||
@ -2341,10 +2365,13 @@ class Bdd {
|
|||||||
produit.reference as produit_reference,
|
produit.reference as produit_reference,
|
||||||
produit.description as produit_description,
|
produit.description as produit_description,
|
||||||
produit.vat as produit_vat,
|
produit.vat as produit_vat,
|
||||||
devis.id_client as devis_client_id
|
devis.id_client as devis_client_id,
|
||||||
|
thanato.id as fk_thanato_id,
|
||||||
|
thanato.fk_thanato_type_key as fk_thanato_type_key
|
||||||
FROM ".$this->tableprefix ."produit_devis as produit_devis
|
FROM ".$this->tableprefix ."produit_devis as produit_devis
|
||||||
LEFT JOIN ".$this->tableprefix."produit as produit on produit_devis.produit_id = produit.id
|
LEFT JOIN ".$this->tableprefix."produit as produit on produit_devis.produit_id = produit.id
|
||||||
LEFT JOIN ".$this->tableprefix."devis as devis on produit_devis.devis_id = devis.id
|
LEFT JOIN ".$this->tableprefix."devis as devis on produit_devis.devis_id = devis.id
|
||||||
|
LEFT JOIN ".$this->tableprefix."thanato as thanato on devis.id_thanato = thanato.id
|
||||||
WHERE produit_devis.devis_id = ?;";
|
WHERE produit_devis.devis_id = ?;";
|
||||||
|
|
||||||
$produitList = $this->execSQLNoJsonReturn(
|
$produitList = $this->execSQLNoJsonReturn(
|
||||||
@ -2352,11 +2379,24 @@ class Bdd {
|
|||||||
[$devisId]);
|
[$devisId]);
|
||||||
|
|
||||||
if(!empty($produitList)){
|
if(!empty($produitList)){
|
||||||
$clientId = $produitList[0]["devis_client_id"];
|
$thanatoTypeKey = $produitList[0]["thanato_type_key"];
|
||||||
$client = $this->getClientById($clientId);
|
$thanatoId = $produitList[0]["fk_thanato_id"];
|
||||||
foreach($produitList as &$produit){
|
$needToApplyThanatoFee = $thanatoTypeKey == ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
|
||||||
$productPrice = $this->getProductPriceByClientGroupId($client['fk_client_group_id'],$produit['produit_id']);
|
if($needToApplyThanatoFee && $thanatoId != null){
|
||||||
$produit['produit_price'] = $productPrice ?? $produit['produit_price'];
|
foreach($produitList as &$produit){
|
||||||
|
$productPrice = $this->getProductPriceByThanatoId($thanatoId,$produit['id']);
|
||||||
|
$productPrice = $productPrice ?? $produit['produit_price'];
|
||||||
|
$produit['produit_price'] = $productPrice * $produit["quantite"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$clientId = $produitList[0]["devis_client_id"];
|
||||||
|
$client = $this->getClientById($clientId);
|
||||||
|
foreach($produitList as &$produit){
|
||||||
|
$productPrice = $this->getProductPriceByClientGroupId($client['fk_client_group_id'],$produit['produit_id']);
|
||||||
|
$productPrice = $productPrice ?? $produit['produit_price'];
|
||||||
|
$produit['produit_price'] = $productPrice * $produit["quantite"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2509,7 +2549,7 @@ class Bdd {
|
|||||||
}
|
}
|
||||||
return $invoices;
|
return $invoices;
|
||||||
}
|
}
|
||||||
public function getDevisPdfDataByDevisId($devisId){
|
public function getDevisByDevisId($devisId){
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
devis.id as devis_id,
|
devis.id as devis_id,
|
||||||
devis.date as devis_date,
|
devis.date as devis_date,
|
||||||
@ -3008,4 +3048,19 @@ class Bdd {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getProductPriceByThanatoId($thanatoId,$productId){
|
||||||
|
$sql = "SELECT *
|
||||||
|
FROM ".$this->tableprefix ."thanato_product_discount as thanato_product_discount
|
||||||
|
WHERE thanato_product_discount.fk_thanato_id = ? AND
|
||||||
|
thanato_product_discount.fk_product_id = ?;
|
||||||
|
";
|
||||||
|
$thanatoProductDiscount = $this->execSQLNoJsonReturn(
|
||||||
|
$sql,
|
||||||
|
[$thanatoId,$productId]);
|
||||||
|
if(!empty($thanatoProductDiscount)){
|
||||||
|
return $thanatoProductDiscount[0]['ht_price'];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
namespace OCA\Gestion\Db;
|
namespace OCA\Gestion\Db;
|
||||||
|
|
||||||
use OCA\Gestion\Constants\OrderStatusConstant;
|
use OCA\Gestion\Constants\OrderStatusConstant;
|
||||||
|
use OCA\Gestion\Constants\OrderTypeConstant;
|
||||||
use OCA\Gestion\Constants\ThanatoTypeConstant;
|
use OCA\Gestion\Constants\ThanatoTypeConstant;
|
||||||
use OCA\Gestion\Helpers\OrderHelpers;
|
use OCA\Gestion\Helpers\OrderHelpers;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
@ -162,6 +163,51 @@ class OrderBdd {
|
|||||||
|
|
||||||
$this->execSQLNoData($sql,[$statusKey,$orderId]);
|
$this->execSQLNoData($sql,[$statusKey,$orderId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOrderItemsReferenceByOrderId($orderId){
|
||||||
|
$sql = "SELECT
|
||||||
|
order_item.id as order_item_id,
|
||||||
|
order_product.reference as order_product_reference,
|
||||||
|
FROM ".$this->orderTablePrefix."order_item as order_item
|
||||||
|
LEFT JOIN ".$this->orderTablePrefix."order_product as order_product on order_item.fk_order_item_id = order_product.id
|
||||||
|
WHERE order_item.fk_order_id = ?
|
||||||
|
GROUP BY order_product.reference;";
|
||||||
|
$itemList = $this->execSQLNoJsonReturn(
|
||||||
|
$sql,
|
||||||
|
[$orderId]);
|
||||||
|
|
||||||
|
$itemReferences = [];
|
||||||
|
foreach($itemList as &$item){
|
||||||
|
if($item['order_product_reference'] != null){
|
||||||
|
$itemReferences[] = $item['order_product_reference'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $itemReferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOrderItemsByOrderId($orderId){
|
||||||
|
$sql = "SELECT
|
||||||
|
order_item.id as order_item_id,
|
||||||
|
order_item.quantity as order_item_quantity,
|
||||||
|
order_product.id as order_product_id,
|
||||||
|
order_product.reference as order_product_reference,
|
||||||
|
order_product.description as order_product_description,
|
||||||
|
order_product.prix_unitaire as order_product_ht_price
|
||||||
|
FROM ".$this->orderTablePrefix."order_item as order_item
|
||||||
|
LEFT JOIN ".$this->orderTablePrefix."order_product as order_product on order_item.fk_order_item_id = order_product.id
|
||||||
|
WHERE order_item.fk_order_id = ?;";
|
||||||
|
$itemList = $this->execSQLNoJsonReturn(
|
||||||
|
$sql,
|
||||||
|
[$orderId]);
|
||||||
|
|
||||||
|
$finalItemList = [];
|
||||||
|
foreach($itemList as &$item){
|
||||||
|
if($item['order_product_id'] != null){
|
||||||
|
$finalItemList[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $finalItemList;
|
||||||
|
}
|
||||||
public function getOrderProductsByOrderId($orderId){
|
public function getOrderProductsByOrderId($orderId){
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
order_product.id as order_product_id,
|
order_product.id as order_product_id,
|
||||||
@ -202,10 +248,12 @@ class OrderBdd {
|
|||||||
orders.order_number,
|
orders.order_number,
|
||||||
orders.order_full_number,
|
orders.order_full_number,
|
||||||
orders.order_comment,
|
orders.order_comment,
|
||||||
orders.fk_defunt_id,
|
orders.fk_order_type_key,
|
||||||
orders.fk_lieu_id,
|
orders.fk_devis_id,
|
||||||
orders.fk_client_id,
|
devis.id_defunt as fk_defunt_id,
|
||||||
orders.fk_thanato_id,
|
devis.id_lieu as fk_lieu_id,
|
||||||
|
devis.id_client as fk_client_id,
|
||||||
|
devis.id_thanato as fk_thanato_id,
|
||||||
orders.fk_order_status_key,
|
orders.fk_order_status_key,
|
||||||
orders.fk_provider_id,
|
orders.fk_provider_id,
|
||||||
thanato.id as thanato_id,
|
thanato.id as thanato_id,
|
||||||
@ -226,12 +274,14 @@ class OrderBdd {
|
|||||||
provider.provider_company_name as provider_company_name
|
provider.provider_company_name as provider_company_name
|
||||||
FROM "
|
FROM "
|
||||||
.$this->orderTablePrefix."orders as orders
|
.$this->orderTablePrefix."orders as orders
|
||||||
LEFT JOIN ".$this->orderTablePrefix."thanato as thanato on orders.fk_thanato_id = thanato.id
|
LEFT JOIN ".$this->orderTablePrefix."devis as devis on orders.fk_devis_id = devis.id
|
||||||
LEFT JOIN ".$this->orderTablePrefix."client as client on orders.fk_client_id = client.id
|
LEFT JOIN ".$this->orderTablePrefix."thanato as thanato on devis.id_thanato = thanato.id
|
||||||
LEFT JOIN ".$this->orderTablePrefix."defunt as defunt on orders.fk_defunt_id = defunt.id
|
LEFT JOIN ".$this->orderTablePrefix."client as client on devis.id_client = client.id
|
||||||
LEFT JOIN ".$this->orderTablePrefix."lieu as lieu on orders.fk_lieu_id = lieu.id
|
LEFT JOIN ".$this->orderTablePrefix."defunt as defunt on devis.id_defunt = defunt.id
|
||||||
|
LEFT JOIN ".$this->orderTablePrefix."lieu as lieu on devis.id_lieu = lieu.id
|
||||||
LEFT JOIN ".$this->orderTablePrefix."provider as provider on orders.fk_provider_id = provider.id
|
LEFT JOIN ".$this->orderTablePrefix."provider as provider on orders.fk_provider_id = provider.id
|
||||||
LEFT JOIN ".$this->orderTablePrefix."order_status as order_status on orders.fk_order_status_key = order_status.status_key
|
LEFT JOIN ".$this->orderTablePrefix."order_status as order_status on orders.fk_order_status_key = order_status.status_key
|
||||||
|
LEFT JOIN ".$this->orderTablePrefix."order_type as order_type on orders.fk_order_type_key = order_type.order_type_key
|
||||||
ORDER BY orders.id DESC;
|
ORDER BY orders.id DESC;
|
||||||
"
|
"
|
||||||
;
|
;
|
||||||
@ -387,4 +437,30 @@ class OrderBdd {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createOrderFromDevisIdAndDate(int $devisId,Datetime $devisDate,string $idNextCloud = BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD){
|
||||||
|
$lastOrderNumber = $this->getLastOrderNumber();
|
||||||
|
$currentOrderNumber = $lastOrderNumber + 1;
|
||||||
|
$currentOrderFullNumber = OrderHelpers::GetFullOrderNumberByDateAndOrderNumber($devisDate,$currentOrderNumber);
|
||||||
|
$orderDate = $devisDate->format("Y-m-d");
|
||||||
|
$sql = "INSERT INTO `".$this->orderTablePrefix."orders` (
|
||||||
|
`order_date`,
|
||||||
|
`order_number`,
|
||||||
|
`order_full_number`,
|
||||||
|
`fk_order_status_key`,
|
||||||
|
`id_nextcloud`,
|
||||||
|
`fk_devis_id`,
|
||||||
|
`fk_order_type_key`
|
||||||
|
)
|
||||||
|
VALUES (?,?,?,?,?,?,?);";
|
||||||
|
$this->execSQLNoData($sql, array(
|
||||||
|
$orderDate,
|
||||||
|
$currentOrderNumber,
|
||||||
|
$currentOrderFullNumber,
|
||||||
|
OrderStatusConstant::ORDERED_KEY,
|
||||||
|
$idNextCloud,
|
||||||
|
$devisId,
|
||||||
|
OrderTypeConstant::ORDER_TYPE_DEVIS
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -107,7 +107,7 @@ class DevisPdfService {
|
|||||||
$configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_H2F_ADMIN));
|
$configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_H2F_ADMIN));
|
||||||
$currentConfig = $configs[0];
|
$currentConfig = $configs[0];
|
||||||
$logo = $this->getLogo();
|
$logo = $this->getLogo();
|
||||||
$devisPdfData = $this->gestionBdd->getDevisPdfDataByDevisId($devisId);
|
$devisPdfData = $this->gestionBdd->getDevisByDevisId($devisId);
|
||||||
if($devisPdfData == null){
|
if($devisPdfData == null){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -142,52 +142,13 @@ class GestionService {
|
|||||||
|
|
||||||
private function GetCalendarDateFromVCalendarString(string $vCalendarString){
|
private function GetCalendarDateFromVCalendarString(string $vCalendarString){
|
||||||
$calendarStartDate = VCalendarHelpers::GetDateStartOrDateEndFromVCalendarString('DTSTART',$vCalendarString);
|
$calendarStartDate = VCalendarHelpers::GetDateStartOrDateEndFromVCalendarString('DTSTART',$vCalendarString);
|
||||||
$calendarStartDate = $calendarStartDate->format('Y-m-d');
|
|
||||||
return $calendarStartDate;
|
return $calendarStartDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function IsOrderAlreadyCreated($calendarUuid){
|
|
||||||
$order = $this->orderBdd->getOrderByCalendarUuid($calendarUuid);
|
|
||||||
return $order != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function CreateOrderFromVCalendarString($vCalendarString,$thanatoId){
|
|
||||||
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
|
|
||||||
$orderAlreadyCreated = $this->IsOrderAlreadyCreated($calendarUuid);
|
|
||||||
if($orderAlreadyCreated){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$nextcloudUser = $this->GetThanatoNameFromVCalendarString($vCalendarString);
|
|
||||||
$calendarSummary = $this->GetCalendarSummaryFromVCalendarString($vCalendarString);
|
|
||||||
$clientId = $this->GetClientIdFromVCalendarString($vCalendarString);
|
|
||||||
$locationId = $this->GetLocationIdFromVCalendarString($vCalendarString);
|
|
||||||
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
|
|
||||||
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary);
|
|
||||||
$orderId = $this->orderBdd->insertOrderFromVCalendarPropertyAndReturnId(
|
|
||||||
$thanatoId,
|
|
||||||
$clientId,
|
|
||||||
$locationId,
|
|
||||||
$defuntId,
|
|
||||||
$calendarUuid,
|
|
||||||
$calendarStartDate,
|
|
||||||
$nextcloudUser);
|
|
||||||
$productsValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
|
|
||||||
if(!empty($productsValue)){
|
|
||||||
$productIds = $this->gestionBdd->getArticleIdsByArticleReferences($productsValue);
|
|
||||||
$this->orderBdd->insertOrderProductsByProductIds($orderId, $productIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function HandleCreatedCalendarObject(string $vCalendarString){
|
public function HandleCreatedCalendarObject(string $vCalendarString){
|
||||||
$thanato = $this->GetThanatoFromVCalendarString($vCalendarString);
|
$thanato = $this->GetThanatoFromVCalendarString($vCalendarString);
|
||||||
if($thanato != null){
|
if($thanato != null){
|
||||||
$thanatoId = $thanato["id"];
|
$thanatoId = $thanato["id"];
|
||||||
$thanatoIsSubcontractor = $thanato["fk_thanato_type_key"] === ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
|
|
||||||
if($thanatoIsSubcontractor){
|
|
||||||
$this->CreateOrderFromVCalendarString($vCalendarString,$thanatoId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$thanatoId = 0;
|
$thanatoId = 0;
|
||||||
@ -203,7 +164,12 @@ class GestionService {
|
|||||||
}
|
}
|
||||||
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary);
|
$defuntId = $this->gestionBdd->insertDefuntByNameAndReturnId($calendarSummary);
|
||||||
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
|
$calendarStartDate = $this->GetCalendarDateFromVCalendarString($vCalendarString);
|
||||||
$devisId = $this->gestionBdd->insertDevisFromVCalendarAndReturnId($thanatoId,$clientId,$locationId,$defuntId,$calendarUuid,$calendarStartDate,$userName);
|
$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);
|
$articlesValue = $this->GetArticlesNameFromVCalendarString($vCalendarString);
|
||||||
if(!empty($articlesValue)){
|
if(!empty($articlesValue)){
|
||||||
$articleIds = $this->gestionBdd->getArticleIdsByArticleReferences($articlesValue);
|
$articleIds = $this->gestionBdd->getArticleIdsByArticleReferences($articlesValue);
|
||||||
|
|||||||
@ -26,6 +26,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace OCA\Gestion\Service\Order;
|
namespace OCA\Gestion\Service\Order;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use OCA\Gestion\Constants\BddConstant;
|
||||||
|
use OCA\Gestion\Constants\OrderTypeConstant;
|
||||||
|
use OCA\Gestion\Db\Bdd;
|
||||||
use OCA\Gestion\Db\OrderBdd;
|
use OCA\Gestion\Db\OrderBdd;
|
||||||
use OCA\Gestion\Helpers\FileExportHelpers;
|
use OCA\Gestion\Helpers\FileExportHelpers;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
@ -33,30 +37,40 @@ use Psr\Log\LoggerInterface;
|
|||||||
class OrderService {
|
class OrderService {
|
||||||
/** @var \OCA\Gestion\Db\OrderBdd */
|
/** @var \OCA\Gestion\Db\OrderBdd */
|
||||||
private $orderBdd;
|
private $orderBdd;
|
||||||
|
private $gestionBdd;
|
||||||
|
|
||||||
/** @var LoggerInterface */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
OrderBdd $orderBdd,
|
OrderBdd $orderBdd,
|
||||||
LoggerInterface $logger) {
|
LoggerInterface $logger,
|
||||||
|
Bdd $gestionBdd) {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->orderBdd = $orderBdd;
|
$this->orderBdd = $orderBdd;
|
||||||
|
$this->gestionBdd = $gestionBdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrdersWithDetailsAsArray(){
|
public function getOrdersWithDetailsAsArray(){
|
||||||
$orders = $this->orderBdd->getOrdersWithDetails();
|
$orders = $this->orderBdd->getOrdersWithDetails();
|
||||||
foreach($orders as &$order){
|
foreach($orders as &$order){
|
||||||
$currentOrderProductsReferenceAsString = "";
|
$currentOrderProductsReferenceAsString = "";
|
||||||
$currentOrderProductsReferences = [];
|
if($order["fk_order_type_key"] == OrderTypeConstant::ORDER_TYPE_DEVIS){
|
||||||
$currentOrderProducts = $this->orderBdd->getOrderProductsByOrderId($order['id']);
|
if($order["fk_devis_id"] != null){
|
||||||
foreach($currentOrderProducts as $currentProduct){
|
$produitReferences = $this->gestionBdd->getDevisProduitsReferences($order["fk_devis_id"]);
|
||||||
$currentOrderProductsReferences[] = $currentProduct["produit_reference"];
|
}
|
||||||
|
if(!empty($produitReferences)){
|
||||||
|
$currentOrderProductsReferenceAsString = implode('-',$produitReferences);
|
||||||
|
}
|
||||||
|
$order["product_references"] = $currentOrderProductsReferenceAsString;
|
||||||
}
|
}
|
||||||
if(!empty($currentOrderProductsReferences)){
|
else{
|
||||||
$currentOrderProductsReferenceAsString = implode('-',$currentOrderProductsReferences);
|
$orderItemReferences = $this->orderBdd->getOrderItemsReferenceByOrderId($order['id']);
|
||||||
|
if(!empty($orderItemReferences)){
|
||||||
|
$currentOrderProductsReferenceAsString = implode('-',$orderItemReferences);
|
||||||
|
}
|
||||||
|
$order["product_references"] = $currentOrderProductsReferenceAsString;
|
||||||
}
|
}
|
||||||
$order["product_references"] = $currentOrderProductsReferenceAsString;
|
|
||||||
}
|
}
|
||||||
return $orders;
|
return $orders;
|
||||||
}
|
}
|
||||||
@ -109,4 +123,8 @@ class OrderService {
|
|||||||
$orderDetails["client_adress_city"] = $clientAdresses["city"];
|
$orderDetails["client_adress_city"] = $clientAdresses["city"];
|
||||||
return $orderDetails;
|
return $orderDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createOrderFromDevisIdAndDate(int $devisId,Datetime $devisDate,string $idNextCloud = BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD ){
|
||||||
|
$this->orderBdd->createOrderFromDevisIdAndDate($devisId,$devisDate,$idNextCloud);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user