浏览代码

Relivraison de produits

feature/export_comptable
Fab 4 年前
父节点
当前提交
d0677ff3de
共有 5 个文件被更改,包括 24 次插入112 次删除
  1. +1
    -0
      ShopBundle/Controller/Backend/OrderController.php
  2. +0
    -58
      ShopBundle/Form/Backend/Common/ProductType.php
  3. +0
    -52
      ShopBundle/Form/Backend/Common/UserType.php
  4. +9
    -2
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +14
    -0
      ShopBundle/Services/Order/OrderUtilsCartTrait.php

+ 1
- 0
ShopBundle/Controller/Backend/OrderController.php 查看文件

@@ -511,6 +511,7 @@ class OrderController extends AdminController

if (!$user instanceof UserInterface) return $user;
else {
//TODO Utiliser getCartByUserOrCreateIt ds OrderUtils
$orderShopUser = $this->em->getRepository(OrderShopInterface::class)->findCartCurrent(['user' => $user]);
if ($orderShopUser) {
$this->utils->addFlash('info', 'error.order.otherOrderAlreadyExist');

+ 0
- 58
ShopBundle/Form/Backend/Common/ProductType.php 查看文件

@@ -1,58 +0,0 @@
<?php

namespace Lc\ShopBundle\Form\Backend\Common;

use Doctrine\ORM\EntityManagerInterface;

use Doctrine\ORM\EntityRepository;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ProductType extends AbstractType
{
protected $em;
protected $merchantUtils;

public function __construct(EntityManagerInterface $entityManager, MerchantUtilsInterface $merchantUtils)
{
$this->em = $entityManager;
$this->merchantUtils = $merchantUtils;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$productClass = $this->em->getClassMetadata(ProductInterface::class);
$currentMerchant = $this->merchantUtils->getMerchantUser();

$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($productClass, $options, $currentMerchant) {
$builder = $event->getForm()->getParent();

$builder->add('product', EntityType::class, array_merge($options,[
'class' => $productClass->name,
'query_builder' => function (EntityRepository $er) use ($currentMerchant) {
return $er->createQueryBuilder('p')
->join('p.productFamily', 'pFamily')
->where('pFamily.merchant = :currentMerchant')
->andWhere('pFamily.status = 1')
->setParameter('currentMerchant', $currentMerchant);
},
'choice_label' => function ($product) {
return $product->getProductFamily()->getTitle() . ' - ' . $product->getTitle();
}
]));
});
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'translation_domain' => 'lcshop',
]);
}
}

+ 0
- 52
ShopBundle/Form/Backend/Common/UserType.php 查看文件

@@ -1,52 +0,0 @@
<?php

namespace Lc\ShopBundle\Form\Backend\Common;

use Doctrine\ORM\EntityManagerInterface;

use Doctrine\ORM\EntityRepository;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Repository\GroupUserRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class UserType extends AbstractType
{
protected $em;

public function __construct(EntityManagerInterface $entityManager)
{
$this->em = $entityManager;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$userClass = $this->em->getClassMetadata(UserInterface::class);
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($userClass, $options) {
$builder = $event->getForm()->getParent();

$builder->add('user', EntityType::class, array_merge($options,[
'class' => $userClass->name,
'query_builder'=> function (EntityRepository $er) {
$query = $er->findByMerchantQuery();
return $query;
},
'expanded' => false,
'translation_domain'=>'lcshop',
]));
});
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'translation_domain' => 'lcshop',
]);
}
}

+ 9
- 2
ShopBundle/Resources/translations/lcshop.fr.yaml 查看文件

@@ -52,6 +52,7 @@ group:
conditions: Conditions d'applications
actions: Actions
OrderShop:
redelivery: Relivraison
resume: Résumé de commande
addProduct: Ajout de produit à la commande
orderPayment: Ajouter un règlement
@@ -375,6 +376,10 @@ field:
typeOptions:
individual: Particulier
legal-person: Professionnel
OrderProductRedelivery:
quantityOrder: Quantité commandé
quantityProduct: Quantité (en rapport à l'unité)
unit: Unité
OrderShop:
save: Sauvegarder
reference: Référence
@@ -390,8 +395,10 @@ field:
quantityOrder: Quantité commandé
quantityProduct: Quantité (en rapport à l'unité)
unit: Unité
redeliverySupplier: Erreur producteur
redeliverySupplierOrder: A recommander au producteur
redeliverySupplierShort: Erreur producteur
redeliverySupplier: Erreur producteur (Aura un prix à 0€ dans le prohain bon de commande producteur - vous devez cocher à recommander)
redeliverySupplierOrderShort: À recommander au producteur
redeliverySupplierOrder: À recommander au producteur (Sera affiché dans le prohain bon de commande producteur)
deliveryType: Type de livraison
deliveryTypeOptions:
point-sale: En ambassade

+ 14
- 0
ShopBundle/Services/Order/OrderUtilsCartTrait.php 查看文件

@@ -3,10 +3,24 @@
namespace Lc\ShopBundle\Services\Order;


use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Model\OrderStatus;

trait OrderUtilsCartTrait
{
public function getCartByUserOrCreateIt($user){
$newOrderShop= $this->em->getRepository(OrderShopInterface::class)->findCartCurrent(['user' => $user]);
if ($newOrderShop === null) {
$newOrderShop = $this->createOrderShop(array(
'user' => $user,
'merchant' => $this->merchantUtils->getMerchantUser()
));
}

return $newOrderShop;
}


public function getCartCurrent()
{
$paramsSearchOrderShop = [];

正在加载...
取消
保存