|
|
@@ -25,13 +25,13 @@ use Symfony\Component\Security\Core\Security; |
|
|
|
|
|
|
|
class OrderController extends AdminController |
|
|
|
{ |
|
|
|
protected $orderUtils; |
|
|
|
/*protected $orderUtils; |
|
|
|
|
|
|
|
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils) |
|
|
|
{ |
|
|
|
$this->orderUtils = $orderUtils; |
|
|
|
parent::__construct($security, $userManager, $em, $utils, $merchantUtils, $mailjetTransport); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
public function updateEntity($entity) |
|
|
|
{ |
|
|
@@ -144,10 +144,10 @@ class OrderController extends AdminController |
|
|
|
$formAddProductToOrder = $this->createForm(AddPoductToOrderType::class); |
|
|
|
|
|
|
|
$formAddProductToOrder->handleRequest($this->request); |
|
|
|
if($formAddProductToOrder->get('product')->getData() == null) { |
|
|
|
if ($formAddProductToOrder->get('product')->getData() == null) { |
|
|
|
$response['status'] = 'error'; |
|
|
|
$response['message'] = 'Vous devez choisir un produit dans la liste'; |
|
|
|
}else if($formAddProductToOrder->get('quantity')->getData() == null){ |
|
|
|
} else if ($formAddProductToOrder->get('quantity')->getData() == null) { |
|
|
|
$response['status'] = 'error'; |
|
|
|
$response['message'] = 'Vous devez entrer une quantité'; |
|
|
|
|
|
|
@@ -161,7 +161,7 @@ class OrderController extends AdminController |
|
|
|
|
|
|
|
$response['status'] = 'success'; |
|
|
|
$response['message'] = 'Le produit a bien été ajouté à la commande'; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
$response['status'] = 'error'; |
|
|
|
$response['message'] = 'Une erreur est survenue'; |
|
|
|
} |
|
|
@@ -184,14 +184,14 @@ class OrderController extends AdminController |
|
|
|
|
|
|
|
|
|
|
|
if ($formOrderProducts->isSubmitted() && $formOrderProducts->isValid()) { |
|
|
|
// dump($formOrderProducts->get('orderProducts')->getData()); |
|
|
|
foreach($orderShop->getOrderProducts() as $orderProduct){ |
|
|
|
// dump($formOrderProducts->get('orderProducts')->getData()); |
|
|
|
foreach ($orderShop->getOrderProducts() as $orderProduct) { |
|
|
|
|
|
|
|
|
|
|
|
if($orderProduct->getQuantityOrder() <= 0) { |
|
|
|
$response['niche'] = $orderProduct->getQuantityOrder() ; |
|
|
|
if ($orderProduct->getQuantityOrder() <= 0) { |
|
|
|
$response['niche'] = $orderProduct->getQuantityOrder(); |
|
|
|
$this->em->remove($orderProduct); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
//dump($orderProduct); |
|
|
|
$this->em->persist($orderProduct); |
|
|
|
} |
|
|
@@ -200,7 +200,7 @@ class OrderController extends AdminController |
|
|
|
$this->em->flush(); |
|
|
|
$response['status'] = 'success'; |
|
|
|
$response['message'] = 'La commande a bien été modifié'; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
$response['status'] = 'error'; |
|
|
|
$response['message'] = 'Une erreur est survenue'; |
|
|
|
} |
|
|
@@ -210,8 +210,6 @@ class OrderController extends AdminController |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function renderOrderShopTemplate($actionName, $templatePath, array $parameters = []) |
|
|
|
{ |
|
|
|
if ($actionName == 'show') { |
|
|
@@ -300,7 +298,7 @@ class OrderController extends AdminController |
|
|
|
'entity' => $entity, |
|
|
|
'fields' => $fields, |
|
|
|
'delete_form' => $deleteForm->createView(), |
|
|
|
'order'=> $this->orderUtils->getOrderAsJsonObject($entity) |
|
|
|
'order' => $this->orderUtils->getOrderAsJsonObject($entity) |
|
|
|
|
|
|
|
]; |
|
|
|
|