浏览代码

Merge branch 'develop'

master
Guillaume 4 年前
父节点
当前提交
c9d3b2fb61
共有 100 个文件被更改,包括 4293 次插入900 次删除
  1. +1
    -0
      ShopBundle/.gitignore
  2. +1
    -1
      ShopBundle/Context/DocumentInterface.php
  3. +8
    -0
      ShopBundle/Context/OrderPaymentInterface.php
  4. +7
    -0
      ShopBundle/Context/OrderPayoffInterface.php
  5. +7
    -0
      ShopBundle/Context/OrderProductRefundInterface.php
  6. +8
    -0
      ShopBundle/Context/OrderReductionCartInterface.php
  7. +1
    -1
      ShopBundle/Context/OrderReductionCreditInterface.php
  8. +7
    -0
      ShopBundle/Context/OrderRefundInterface.php
  9. +8
    -0
      ShopBundle/Context/OrderShopPriceUtilsInterface.php
  10. +1
    -1
      ShopBundle/Context/OrderStatusInterface.php
  11. +7
    -0
      ShopBundle/Context/PayoffInterface.php
  12. +4
    -0
      ShopBundle/Context/ReductionCartInterface.php
  13. +7
    -0
      ShopBundle/Context/ReductionCartPropertyInterface.php
  14. +7
    -0
      ShopBundle/Context/ReductionCreditInterface.php
  15. +1
    -1
      ShopBundle/Context/ReductionPropertyInterface.php
  16. +7
    -0
      ShopBundle/Context/ReminderInterface.php
  17. +3
    -1
      ShopBundle/Context/SeoInterface.php
  18. +8
    -0
      ShopBundle/Context/TicketInterface.php
  19. +8
    -0
      ShopBundle/Context/TicketMessageInterface.php
  20. +1
    -1
      ShopBundle/Context/UserMerchantInterface.php
  21. +2
    -2
      ShopBundle/Controller/ApiController.php
  22. +84
    -32
      ShopBundle/Controller/Backend/AdminController.php
  23. +46
    -0
      ShopBundle/Controller/Backend/DocumentController.php
  24. +1
    -0
      ShopBundle/Controller/Backend/MerchantController.php
  25. +373
    -113
      ShopBundle/Controller/Backend/OrderController.php
  26. +76
    -39
      ShopBundle/Controller/Backend/ProductFamilyController.php
  27. +56
    -0
      ShopBundle/Controller/Backend/ReminderController.php
  28. +86
    -0
      ShopBundle/Controller/Backend/TicketController.php
  29. +5
    -0
      ShopBundle/Controller/Backend/UserController.php
  30. +173
    -0
      ShopBundle/Controller/Backend/UserMerchantController.php
  31. +6
    -5
      ShopBundle/Controller/CitiesController.php
  32. +123
    -4
      ShopBundle/Controller/Frontend/CartController.php
  33. +1
    -1
      ShopBundle/Form/Backend/Common/AbstractEditPositionType.php
  34. +25
    -15
      ShopBundle/Form/Backend/Common/AddressType.php
  35. +59
    -0
      ShopBundle/Form/Backend/Common/ReductionCatalogType.php
  36. +71
    -0
      ShopBundle/Form/Backend/Common/ReminderType.php
  37. +3
    -1
      ShopBundle/Form/Backend/Merchant/MerchantConfigType.php
  38. +68
    -0
      ShopBundle/Form/Backend/Merchant/MerchantConfigsType.php
  39. +59
    -0
      ShopBundle/Form/Backend/Order/AddOrderReductionCartType.php
  40. +65
    -0
      ShopBundle/Form/Backend/Order/AddOrderReductionCreditType.php
  41. +4
    -4
      ShopBundle/Form/Backend/Order/AddPoductToOrderType.php
  42. +59
    -0
      ShopBundle/Form/Backend/Order/AddRedeliveryOrderProductType.php
  43. +60
    -0
      ShopBundle/Form/Backend/Order/AddReductionCreditType.php
  44. +43
    -0
      ShopBundle/Form/Backend/Order/DeleteOrderPaymentType.php
  45. +43
    -0
      ShopBundle/Form/Backend/Order/DeleteOrderReductionCartType.php
  46. +43
    -0
      ShopBundle/Form/Backend/Order/DeleteOrderReductionCreditType.php
  47. +1
    -1
      ShopBundle/Form/Backend/Order/OrderDeliveryAddressType.php
  48. +4
    -4
      ShopBundle/Form/Backend/Order/OrderInvoiceAddressType.php
  49. +73
    -0
      ShopBundle/Form/Backend/Order/OrderPaymentType.php
  50. +1
    -1
      ShopBundle/Form/Backend/Order/OrderProductType.php
  51. +44
    -0
      ShopBundle/Form/Backend/Order/OrderProductsActionType.php
  52. +1
    -1
      ShopBundle/Form/Backend/Order/OrderProductsType.php
  53. +50
    -0
      ShopBundle/Form/Backend/Order/OrderSendPaymentLink.php
  54. +57
    -0
      ShopBundle/Form/Backend/Order/OrderStatusType.php
  55. +1
    -1
      ShopBundle/Form/Backend/ProductFamily/ProductFamilyCategoriesType.php
  56. +7
    -1
      ShopBundle/Form/Backend/ProductFamily/ProductType.php
  57. +57
    -0
      ShopBundle/Form/Backend/ReductionCart/AppliedToType.php
  58. +58
    -0
      ShopBundle/Form/Backend/ReductionCart/PointSalesFilterType.php
  59. +57
    -0
      ShopBundle/Form/Backend/ReductionCart/UncombinableTypesType.php
  60. +53
    -0
      ShopBundle/Form/Backend/ReductionCart/UncombinablesType.php
  61. +55
    -0
      ShopBundle/Form/Backend/ReductionCatalog/ProductCategoriesFilterType.php
  62. +46
    -0
      ShopBundle/Form/Backend/ReductionCommon/BehaviorTaxRateType.php
  63. +42
    -0
      ShopBundle/Form/Backend/ReductionCommon/DateEndType.php
  64. +42
    -0
      ShopBundle/Form/Backend/ReductionCommon/DateStartType.php
  65. +58
    -0
      ShopBundle/Form/Backend/ReductionCommon/GroupUsersFilterType.php
  66. +45
    -0
      ShopBundle/Form/Backend/ReductionCommon/PermanentType.php
  67. +47
    -0
      ShopBundle/Form/Backend/ReductionCommon/UnitType.php
  68. +65
    -0
      ShopBundle/Form/Backend/ReductionCommon/UsersFilterType.php
  69. +40
    -0
      ShopBundle/Form/Backend/ReductionCommon/ValueType.php
  70. +65
    -0
      ShopBundle/Form/Backend/Ticket/TicketMessageType.php
  71. +66
    -0
      ShopBundle/Form/Backend/Ticket/TicketStatusType.php
  72. +87
    -0
      ShopBundle/Form/Backend/UserMerchant/CreditHistoryType.php
  73. +0
    -40
      ShopBundle/Form/CreditConfigType.php
  74. +64
    -0
      ShopBundle/Form/Frontend/CookieConsentTypeExtension.php
  75. +26
    -0
      ShopBundle/Form/Frontend/ReductionCartType.php
  76. +5
    -1
      ShopBundle/Form/Frontend/RegistrationType.php
  77. +44
    -0
      ShopBundle/Form/Frontend/TicketMessageType.php
  78. +99
    -0
      ShopBundle/Form/Frontend/TicketType.php
  79. +0
    -142
      ShopBundle/Form/ReductionCatalogType.php
  80. +8
    -3
      ShopBundle/Model/AbstractDocumentEntity.php
  81. +1
    -0
      ShopBundle/Model/AbstractEntity.php
  82. +17
    -6
      ShopBundle/Model/Address.php
  83. +0
    -64
      ShopBundle/Model/Cart.php
  84. +0
    -135
      ShopBundle/Model/CartProduct.php
  85. +82
    -46
      ShopBundle/Model/CreditHistory.php
  86. +271
    -0
      ShopBundle/Model/Document.php
  87. +0
    -55
      ShopBundle/Model/DocumentDeliveryNote.php
  88. +0
    -56
      ShopBundle/Model/DocumentInvoice.php
  89. +0
    -73
      ShopBundle/Model/DocumentQuotation.php
  90. +1
    -1
      ShopBundle/Model/OrderAmountMin.php
  91. +17
    -0
      ShopBundle/Model/OrderPayment.php
  92. +61
    -0
      ShopBundle/Model/OrderPayoffTrait.php
  93. +22
    -1
      ShopBundle/Model/OrderProduct.php
  94. +87
    -0
      ShopBundle/Model/OrderProductRefund.php
  95. +77
    -0
      ShopBundle/Model/OrderReductionCart.php
  96. +73
    -0
      ShopBundle/Model/OrderReductionCredit.php
  97. +52
    -0
      ShopBundle/Model/OrderRefund.php
  98. +264
    -43
      ShopBundle/Model/OrderShop.php
  99. +140
    -0
      ShopBundle/Model/OrderStatus.php
  100. +24
    -3
      ShopBundle/Model/OrderStatusHistory.php

+ 1
- 0
ShopBundle/.gitignore 查看文件

@@ -0,0 +1 @@
Resources/public/.sass-cache/

ShopBundle/Context/CartProductInterface.php → ShopBundle/Context/DocumentInterface.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\ShopBundle\Context;

interface CartProductInterface
interface DocumentInterface
{

}

+ 8
- 0
ShopBundle/Context/OrderPaymentInterface.php 查看文件

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

namespace Lc\ShopBundle\Context ;

interface OrderPaymentInterface
{

}

+ 7
- 0
ShopBundle/Context/OrderPayoffInterface.php 查看文件

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

namespace Lc\ShopBundle\Context;

interface OrderPayoffInterface
{
}

+ 7
- 0
ShopBundle/Context/OrderProductRefundInterface.php 查看文件

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

namespace Lc\ShopBundle\Context;

interface OrderProductRefundInterface
{
}

+ 8
- 0
ShopBundle/Context/OrderReductionCartInterface.php 查看文件

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

namespace Lc\ShopBundle\Context;

interface OrderReductionCartInterface
{

}

ShopBundle/Context/DocumentDeliveryNoteInterface.php → ShopBundle/Context/OrderReductionCreditInterface.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\ShopBundle\Context;

interface DocumentDeliveryNoteInterface
interface OrderReductionCreditInterface
{

}

+ 7
- 0
ShopBundle/Context/OrderRefundInterface.php 查看文件

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

namespace Lc\ShopBundle\Context;

interface OrderRefundInterface
{
}

+ 8
- 0
ShopBundle/Context/OrderShopPriceUtilsInterface.php 查看文件

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

namespace Lc\ShopBundle\Context ;

interface OrderShopPriceUtilsInterface
{

}

ShopBundle/Context/PointSaleUtilsInterface.php → ShopBundle/Context/OrderStatusInterface.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\ShopBundle\Context;

interface PointSaleUtilsInterface
interface OrderStatusInterface
{

}

+ 7
- 0
ShopBundle/Context/PayoffInterface.php 查看文件

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

namespace Lc\ShopBundle\Context;

interface PayoffInterface
{
}

+ 4
- 0
ShopBundle/Context/ReductionCartInterface.php 查看文件

@@ -2,6 +2,10 @@

namespace Lc\ShopBundle\Context;

use Doctrine\Common\Collections\Collection;
use Lc\ShopBundle\Model\PointSale;

interface ReductionCartInterface
{

}

+ 7
- 0
ShopBundle/Context/ReductionCartPropertyInterface.php 查看文件

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

namespace Lc\ShopBundle\Context;

interface ReductionCartPropertyInterface
{
}

+ 7
- 0
ShopBundle/Context/ReductionCreditInterface.php 查看文件

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

namespace Lc\ShopBundle\Context;

interface ReductionCreditInterface
{
}

ShopBundle/Context/DocumentQuotationInterface.php → ShopBundle/Context/ReductionPropertyInterface.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\ShopBundle\Context;

interface DocumentQuotationInterface
interface ReductionPropertyInterface
{

}

+ 7
- 0
ShopBundle/Context/ReminderInterface.php 查看文件

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

namespace Lc\ShopBundle\Context;

interface ReminderInterface
{
}

ShopBundle/Context/CartInterface.php → ShopBundle/Context/SeoInterface.php 查看文件

@@ -2,7 +2,9 @@

namespace Lc\ShopBundle\Context;

interface CartInterface
interface SeoInterface
{



}

+ 8
- 0
ShopBundle/Context/TicketInterface.php 查看文件

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

namespace Lc\ShopBundle\Context ;

interface TicketInterface
{

}

+ 8
- 0
ShopBundle/Context/TicketMessageInterface.php 查看文件

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

namespace Lc\ShopBundle\Context ;

interface TicketMessageInterface
{

}

ShopBundle/Context/DocumentInvoiceInterface.php → ShopBundle/Context/UserMerchantInterface.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\ShopBundle\Context;

interface DocumentInvoiceInterface
interface UserMerchantInterface
{

}

+ 2
- 2
ShopBundle/Controller/ApiController.php 查看文件

@@ -4,9 +4,9 @@ namespace Lc\ShopBundle\Controller;

use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\PriceUtilsInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Services\PriceUtils;
use Lc\ShopBundle\Services\ProductFamilyUtils;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -22,7 +22,7 @@ class ApiController extends AbstractController
protected $priceUtils ;
protected $productFamilyUtils;

public function __construct(EntityManagerInterface $entityManager, PriceUtils $priceUtils, ProductFamilyUtils $productFamilyUtils)
public function __construct(EntityManagerInterface $entityManager, PriceUtilsInterface $priceUtils, ProductFamilyUtils $productFamilyUtils)
{
$this->em = $entityManager;
$this->priceUtils = $priceUtils;

+ 84
- 32
ShopBundle/Controller/Backend/AdminController.php 查看文件

@@ -11,17 +11,23 @@ use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
use Lc\ShopBundle\Context\MerchantInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ReminderInterface;
use Lc\ShopBundle\Context\SeoInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Context\TreeInterface;
use Lc\ShopBundle\Form\AbstractEditPositionType;
use Lc\ShopBundle\Form\Backend\Common\AbstractEditPositionType;
use Lc\ShopBundle\Services\Utils;
use Lc\ShopBundle\Services\UtilsManager;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;

class AdminController extends EasyAdminController
{
@@ -29,26 +35,43 @@ class AdminController extends EasyAdminController
protected $userManager;
protected $em;
protected $utils;
protected $merchantUtils ;
protected $mailjetTransport ;
protected $orderUtils ;
protected $merchantUtils;
protected $mailjetTransport;
protected $orderUtils;
protected $translator;

public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils,
MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils)
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em,
MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator)
{
$this->security = $security;
$this->userManager = $userManager;
$this->em = $em;
$this->utils = $utils;
$this->merchantUtils = $merchantUtils ;
$this->mailjetTransport = $mailjetTransport ;
$this->orderUtils = $orderUtils ;
$this->mailjetTransport = $mailjetTransport;
$this->utils = $utilsManager->getUtils();
$this->merchantUtils = $utilsManager->getMerchantUtils();
$this->orderUtils = $utilsManager->getOrderUtils() ;;
$this->translator = $translator;
}

public function createCustomForm($class, $action, $parameters, $data = true)
{

$options = array();
if ($data) $options['data'] = $parameters['entity'];
$options['action'] = $this->generateUrl('easyadmin', array(
'action' => $action,
'entity' => $this->entity['name'],
'id' => $parameters['entity']->getId()
));

return $this->createForm($class, null, $options);
}


/**
* Réécriture de show action pr rediriger vers l'édition
*/
public function showAction()
/* public function showAction()
{
$id = $this->request->query->get('id');
$entity = $this->request->query->get('entity');
@@ -58,7 +81,7 @@ class AdminController extends EasyAdminController
'entity' => $entity,
'id' => $id
]);
}
}*/


/**
@@ -119,9 +142,18 @@ class AdminController extends EasyAdminController
public function renderTemplate($actionName, $templatePath, array $parameters = [])
{

$reminderRepo = $this->em->getRepository(ReminderInterface::class);
$easyadmin = $this->request->attributes->get('easyadmin');
$entityName = $easyadmin['entity']['name'];
$id=null;
if($easyadmin['item'])$id = $easyadmin['item']->getId();

$reminders = array('reminders' => $reminderRepo->findByEasyAdminConfig($actionName, $entityName, $id ));

$parameters = array_merge(
$parameters,
$this->getTwigExtraParameters()
$this->getTwigExtraParameters(),
$reminders
);

return parent::renderTemplate($actionName, $templatePath, $parameters);
@@ -141,7 +173,6 @@ class AdminController extends EasyAdminController
}



public function listChildrenAction()
{
$this->dispatch(EasyAdminEvents::PRE_LIST);
@@ -248,23 +279,43 @@ class AdminController extends EasyAdminController

$formBuilder = parent::createEntityFormBuilder($entity, $view);

if($override)$formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view);
if ($override) $formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view);

return $formBuilder;
}

public function overrideFormBuilder($formBuilder, $entity, $view){
public function overrideFormBuilder($formBuilder, $entity, $view)
{
$id = (null !== $entity->getId()) ? $entity->getId() : 0;

if ($entity instanceof SeoInterface) {
$formBuilder->add('metaTitle', TextType::class, array(
'required' => false,
'translation_domain' => 'lcshop'
)
);
$formBuilder->add('metaDescription', TextareaType::class, array(
'required' => false,
'translation_domain' => 'lcshop'
)
);
/*$formBuilder->add('oldUrls', TextareaType::class, array(
'required' => false,
'translation_domain' => 'lcshop'
)
);*/
}


if ($entity instanceof StatusInterface) {
$formBuilder->add('status', ChoiceType::class, array(
'choices' =>array(
'choices' => array(
'field.default.statusOptions.offline' => '0',
'field.default.statusOptions.online' => '1'
),
'expanded' => true,
'required' => true,
'translation_domain'=> 'lcshop'
'translation_domain' => 'lcshop'
)
);
}
@@ -292,7 +343,8 @@ class AdminController extends EasyAdminController
return $formBuilder;
}

private function loopFormField($form, $childrens){
private function loopFormField($form, $childrens)
{
foreach ($childrens as $child) {
$statusInterface = false;
$treeInterface = false;
@@ -301,8 +353,8 @@ class AdminController extends EasyAdminController
$passedOptions = $child->getConfig()->getOptions();
$classImplements = class_implements($passedOptions['class']);

$isFilterMerchantInterface = in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements) ;
$isFilterMultipleMerchantsInterface = in_array('Lc\ShopBundle\Context\FilterMultipleMerchantsInterface', $classImplements) ;
$isFilterMerchantInterface = in_array('Lc\ShopBundle\Context\FilterMerchantInterface', $classImplements);
$isFilterMultipleMerchantsInterface = in_array('Lc\ShopBundle\Context\FilterMultipleMerchantsInterface', $classImplements);

if ($isFilterMerchantInterface || $isFilterMultipleMerchantsInterface) {

@@ -314,16 +366,15 @@ class AdminController extends EasyAdminController
$treeInterface = true;
}
$propertyMerchant = 'merchant';
if($isFilterMultipleMerchantsInterface) {
$propertyMerchant .= 's' ;
if ($isFilterMultipleMerchantsInterface) {
$propertyMerchant .= 's';
}

$form->add($child->getName(), EntityType::class, array(
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(),
'label' => $passedOptions['label'],
'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false,
'placeholder' => '--',
'translation_domain'=> 'lcshop',
'translation_domain' => 'lcshop',
'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant, $statusInterface, $treeInterface, $child) {
$queryBuilder = $repo->createQueryBuilder('e');
$propertyMerchant = 'e.' . $propertyMerchant;
@@ -334,30 +385,31 @@ class AdminController extends EasyAdminController
$queryBuilder->where($propertyMerchant . ' = :currentMerchant');
}

if($statusInterface){
if ($statusInterface) {
$queryBuilder->andWhere('e.status >= 0');
}
if($treeInterface && $child->getName() =='parent'){
if ($treeInterface && $child->getName() == 'parent') {
$queryBuilder->andWhere('e.parent is null');
}
$queryBuilder->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId());

return $queryBuilder;
},
'choice_label' => function($choice) {
if($choice instanceof StatusInterface && $choice->getStatus() == 0){
return $choice.' [hors ligne]';
'choice_label' => function ($choice) {
if ($choice instanceof StatusInterface && $choice->getStatus() == 0) {
return $choice . ' [hors ligne]';
}
return $choice;

},
'required' => $passedOptions['required'],
'choice_attr' => $passedOptions['choice_attr'],
)
);
}
}else{
} else {
$subChildrens = $child->all();
if(count($subChildrens)){
if (count($subChildrens)) {
$this->loopFormField($child, $subChildrens);
}
}

+ 46
- 0
ShopBundle/Controller/Backend/DocumentController.php 查看文件

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

namespace Lc\ShopBundle\Controller\Backend;

use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\DocumentInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Services\Utils;
use Lc\ShopBundle\Services\UtilsManager;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;

class DocumentController extends AdminController
{
protected $documentRepository ;

public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator)
{
parent::__construct($security, $userManager, $em, $mailjetTransport, $utilsManager, $translator);
$this->documentRepository = $this->em->getRepository($this->em->getClassMetadata(DocumentInterface::class)->getName()) ;
}

public function downloadInvoiceAction()
{
$idDocument = $this->request->get('id') ;
$document = $this->documentRepository->find($idDocument) ;

$orderShop = null ;
if($document) {
$orderShops = $document->getOrderShops() ;
$orderShop = (isset($orderShops[0])) ? $orderShops[0] : null ;
}

if($document && $orderShop) {
$this->orderUtils->generateDocumentInvoiceOrderShop($orderShop, 'download') ;
}
else {
throw new NotFoundHttpException('Document introuvable') ;
}
}

}

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

@@ -71,6 +71,7 @@ class MerchantController extends AdminController
$response = parent::editAction() ;

if ($response instanceof RedirectResponse) {

$referer = $this->request->headers->get('referer');
return new RedirectResponse($referer);
}

+ 373
- 113
ShopBundle/Controller/Backend/OrderController.php 查看文件

@@ -2,31 +2,80 @@

namespace Lc\ShopBundle\Controller\Backend;

use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use Lc\ShopBundle\Context\AddressInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderReductionCreditInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Form\Order\AddPoductToOrderType;
use Lc\ShopBundle\Form\Order\OrderAddressType;
use Lc\ShopBundle\Form\Order\OrderDeliveryAddressType;
use Lc\ShopBundle\Form\Order\OrderInvoiceAddressType;
use Lc\ShopBundle\Form\Order\OrderProductsType;
use Lc\ShopBundle\Form\OrderProductType;
use Lc\ShopBundle\Form\Backend\Order\AddPoductToOrderType;
use Lc\ShopBundle\Form\Backend\Order\AddRedeliveryOrderProductType;
use Lc\ShopBundle\Form\Backend\Order\DeleteOrderPaymentType;
use Lc\ShopBundle\Form\Backend\Order\DeleteOrderReductionCartType;
use Lc\ShopBundle\Form\Backend\Order\DeleteOrderReductionCreditType;
use Lc\ShopBundle\Form\Backend\Order\OrderDeliveryAddressType;
use Lc\ShopBundle\Form\Backend\Order\OrderInvoiceAddressType;
use Lc\ShopBundle\Form\Backend\Order\OrderPaymentType;
use Lc\ShopBundle\Form\Backend\Order\OrderProductsType;
use Lc\ShopBundle\Form\Backend\Order\AddOrderReductionCartType;
use Lc\ShopBundle\Form\Backend\Order\AddOrderReductionCreditType;
use Lc\ShopBundle\Form\Backend\Order\OrderSendPaymentLink;
use Lc\ShopBundle\Form\Backend\Order\OrderStatusType;
use Lc\ShopBundle\Model\CreditHistory;
use Lc\ShopBundle\Model\OrderStatus;
use Lc\ShopBundle\Services\MailUtils;
use Lc\ShopBundle\Services\Utils;
use Lc\ShopBundle\Services\UtilsManager;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;


class OrderController extends AdminController
{
/*protected $orderUtils;
protected $creditUtils;
protected $mailUtils;

public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils)
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator)
{
$this->orderUtils = $orderUtils;
parent::__construct($security, $userManager, $em, $utils, $merchantUtils, $mailjetTransport);
}*/
$this->creditUtils = $utilsManager->getCreditUtils();
$this->mailUtils = $utilsManager->getMailUtils();
parent::__construct($security, $userManager, $em, $mailjetTransport, $utilsManager, $translator);
}

protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null)
{
$filterIsOrderStatus = false;
$filterNotOrderStatus = false;

if (isset($dqlFilter['isOrderStatus'])) $filterIsOrderStatus = $dqlFilter['isOrderStatus'];
if (isset($dqlFilter['notOrderStatus'])) $filterNotOrderStatus = $dqlFilter['notOrderStatus'];
$dqlFilter = $dqlFilter['filter'];

$queryBuilder = parent::createListQueryBuilder($entityClass, $sortDirection, $sortField, $dqlFilter);

$queryBuilder->leftJoin('entity.orderStatus', 'orderStatus');

if ($filterIsOrderStatus) {
$queryBuilder->andWhere('orderStatus.alias IN (:status)');
$queryBuilder->setParameter('status', $filterIsOrderStatus);
}

if ($filterNotOrderStatus) {
$queryBuilder->andWhere('orderStatus.alias NOT IN (:status)');
$queryBuilder->setParameter('status', $filterNotOrderStatus);
}

return $queryBuilder;
}


public function updateEntity($entity)
{
@@ -74,7 +123,6 @@ class OrderController extends AdminController
}



public function getUserViaFirstStepForm($entity)
{
$userClass = $this->em->getClassMetadata(UserInterface::class);
@@ -102,147 +150,342 @@ class OrderController extends AdminController

public function addProductToOrderAction()
{

$id = $this->request->query->get('id');
$easyadmin = $this->request->attributes->get('easyadmin');
$orderShop = $easyadmin['item'];

$orderShop = $this->getOrderShopEntity();
$orderProductClass = $this->em->getClassMetadata(OrderProductInterface::class);
$formAddProductToOrder = $this->createForm(AddPoductToOrderType::class);

$formAddProductToOrder->handleRequest($this->request);
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) {
$response['status'] = 'error';
$response['message'] = 'Vous devez entrer une quantité';

} else if ($formAddProductToOrder->isSubmitted() && $formAddProductToOrder->isValid()) {


if ($formAddProductToOrder->isSubmitted() && $formAddProductToOrder->isValid()) {
$orderProduct = new $orderProductClass->name;

$orderProduct->setQuantityOrder($formAddProductToOrder->get('quantity')->getData());
$orderProduct->setProduct($formAddProductToOrder->get('product')->getData());
if ($this->orderUtils->isProductAvailable($formAddProductToOrder->get('product')->getData(), $formAddProductToOrder->get('quantity')->getData())) {
$orderProduct->setQuantityOrder($formAddProductToOrder->get('quantity')->getData());
$orderProduct->setProduct($formAddProductToOrder->get('product')->getData());

$this->orderUtils->addOrderProduct($orderShop, $orderProduct);
$this->orderUtils->addOrderProduct($orderShop, $orderProduct);

$response['status'] = 'success';
$response['message'] = 'Le produit a bien été ajouté à la commande';
$this->utils->addFlash('success', 'success.order.addProduct');
} else {
$this->utils->addFlash('error', 'error.order.productUnavailable');
}
} else {
$response['status'] = 'error';
$response['message'] = 'Une erreur est survenue';
$this->utils->addFlash('error', 'error.form.submitted');
}
$response['data'] = $this->orderUtils->getOrderAsJsonObject($orderShop);;

return new Response(json_encode($response));
return $this->createOrderAjaxReponse($orderShop);
}


public function orderInvoiceAddressAction()
{

$id = $this->request->query->get('id');
$easyadmin = $this->request->attributes->get('easyadmin');
$orderShop = $easyadmin['item'];

$orderShop = $this->getOrderShopEntity();
$formOrderInvoiceAddress = $this->createForm(OrderInvoiceAddressType::class, $orderShop);

$formOrderInvoiceAddress->handleRequest($this->request);

if ($formOrderInvoiceAddress->isSubmitted() && $formOrderInvoiceAddress->isValid()) {
//TODO si la commande est valide on hydrate le champ invoiceAddresText et on vide invoiceAddres
$this->em->persist($orderShop);
$this->em->flush();
$response['status'] = 'success';
$response['message'] = 'La commande a bien été modifié';
$this->utils->addFlash('success', 'success.order.changeInvoiceAddress');
} else {
$response['status'] = 'error';
$response['message'] = 'Une erreur est survenue';
$this->utils->addFlash('error', 'error.form.submitted');
}
$response['data'] = $this->orderUtils->getOrderAsJsonObject($orderShop);;
return new Response(json_encode($response));
return $this->createOrderAjaxReponse($orderShop);
}

public function orderStatusAction()
{
$orderShop = $this->getOrderShopEntity();
$formOrderStatus = $this->createForm(OrderStatusType::class, $orderShop);
$formOrderStatus->handleRequest($this->request);

if ($formOrderStatus->isSubmitted() && $formOrderStatus->isValid()) {
$oldStatus = $orderShop->getOrderStatus();

$orderShop = $this->orderUtils->changeOrderStatus($formOrderStatus->get('orderStatus')->getData(), $orderShop, true);
if ($oldStatus !== $orderShop->getOrderStatus()) {
$this->utils->addFlash('success', 'success.order.changeStatus');
}
} else {
$this->utils->addFlash('success', 'error.form.submitted');
}

return $this->redirectToRoute('easyadmin', [
'action' => 'show',
'entity' => $this->request->query->get('entity'),
'id' => $orderShop->getId()
]);

}


public function orderProductsAction()
public function orderPaymentAction()
{
$orderShop = $this->getOrderShopEntity();

$id = $this->request->query->get('id');
$easyadmin = $this->request->attributes->get('easyadmin');
$orderShop = $easyadmin['item'];

$formOrderProducts = $this->createForm(OrderProductsType::class, $orderShop);
//TODO si édition despayment existant on vérifie qu'il est lié à nla commabde courante
$orderPaymentPost = $this->request->request->get('order_payment');
if ($orderPaymentPost['id']) {
$orderPayment = $this->em->getRepository(OrderPaymentInterface::class)->find($orderPaymentPost['id']);
} else {
$orderPaymentClass = $this->em->getClassMetadata(OrderPaymentInterface::class);
$orderPayment = new $orderPaymentClass->name;
}


$formOrderProducts->handleRequest($this->request);
$formOrderPayment = $this->createForm(OrderPaymentType::class, $orderPayment);

$formOrderPayment->handleRequest($this->request);

if ($formOrderProducts->isSubmitted() && $formOrderProducts->isValid()) {
// dump($formOrderProducts->get('orderProducts')->getData());
foreach ($orderShop->getOrderProducts() as $orderProduct) {

if ($formOrderPayment->isSubmitted() && $formOrderPayment->isValid()) {

if ($orderProduct->getQuantityOrder() <= 0) {
$response['niche'] = $orderProduct->getQuantityOrder();
$this->em->remove($orderProduct);
$orderPayment->setOrderShop($orderShop);
if ($orderPayment->getMeanPayment() === Utils::MEAN_PAYMENT_CREDIT) {
$orderPayment->setEditable(false);
$params['orderPayment'] = $orderPayment;
$creditHistory = $this->creditUtils->initCreditHistory(CreditHistory::TYPE_DEBIT, $orderShop->getUser(), $params);
if ($this->creditUtils->isCreditSufficientToPay($creditHistory->getUserMerchant(), $creditHistory->getAmountInherited())) {
if ($this->creditUtils->saveCreditHistory($creditHistory)) {
$this->em->persist($orderPayment);
$this->em->flush();
$this->utils->addFlash('success', 'success.credit.debited');
$this->utils->addFlash('success', 'success.order.addPayment');
}
} else {
$this->em->persist($orderProduct);
$this->utils->addFlash('error', 'error.credit.notEnoughCredit');
}

} else {
$orderPayment->setEditable(true);
$this->em->persist($orderPayment);
$this->em->flush();
$this->utils->addFlash('success', 'success.order.addPayment');
}


} else {
$this->utils->addFlash('error', $formOrderPayment->getErrors());
}
return $this->createOrderAjaxReponse($orderShop);
}

public function deleteOrderPaymentAction()
{
$orderShop = $this->getOrderShopEntity();
$formDeleteOrderPayment = $this->createForm(DeleteOrderPaymentType::class);
$formDeleteOrderPayment->handleRequest($this->request);

if ($formDeleteOrderPayment->isSubmitted() && $formDeleteOrderPayment->isValid()) {
$orderPayment = $this->em->getRepository(OrderPaymentInterface::class)->find($formDeleteOrderPayment->get('id')->getData());
if ($orderPayment && $orderShop->getOrderPayments()->contains($orderPayment) && $orderPayment->getEditable()) {
$orderShop->removeOrderPayment($orderPayment);
$this->em->remove($orderPayment);
$this->em->flush();

$this->utils->addFlash('success', 'success.order.removeOrderPayement');
}

} else {
$this->utils->addFlash('error', $formDeleteOrderPayment->getErrors());
}
return $this->createOrderAjaxReponse($orderShop);
}

public function addOrderReductionCartAction()
{
$orderShop = $this->getOrderShopEntity();
$formAddOrderReductionCart = $this->createForm(AddOrderReductionCartType::class, $orderShop);
$formAddOrderReductionCart->handleRequest($this->request);

if ($formAddOrderReductionCart->isSubmitted() && $formAddOrderReductionCart->isValid()) {

$reductionCart = $formAddOrderReductionCart->get('reductionCart')->getData();
$orderShop->reductionError = array();
if ($this->orderUtils->isReductionCartAllowAddToOrder($orderShop, $reductionCart)) {
$orderReductionCart = $this->orderUtils->createOrderReductionCart($orderShop, $reductionCart);
$this->em->persist($orderReductionCart);
$this->em->flush();

$this->utils->addFlash('success', 'success.order.addReductionCart');
}
} else {
$this->utils->addFlash('error', $formAddOrderReductionCart->getErrors());
}
return $this->createOrderAjaxReponse($orderShop);
}

public function addOrderReductionCreditAction()
{
$orderShop = $this->getOrderShopEntity();
$formAddOrderReductionCredit = $this->createForm(AddOrderReductionCreditType::class, $orderShop);
$formAddOrderReductionCredit->handleRequest($this->request);

if ($formAddOrderReductionCredit->isSubmitted() && $formAddOrderReductionCredit->isValid()) {
$reductionCredit = $formAddOrderReductionCredit->get('reductionCredit')->getData();
if ($this->orderUtils->isReductionCreditAllowAddToOrder($orderShop, $reductionCredit)) {

$orderReductionCredit = $this->orderUtils->createOrderReductionCredit($orderShop, $reductionCredit);
$this->em->persist($orderReductionCredit);
$this->em->flush();

$this->utils->addFlash('success', 'success.order.addReductionCredit');
}

} else {
$this->utils->addFlash('error', $formAddOrderReductionCredit->getErrors());
}
return $this->createOrderAjaxReponse($orderShop);
}


public function addRedeliveryOrderProductAction()
{
$orderShop = $this->getOrderShopEntity();
$formAddOrderReductionCredit = $this->createForm(AddRedeliveryOrderProductType::class, $orderShop);
//TODO 0 écrire
}



public function deleteOrderReductionCartAction()
{
$orderShop = $this->getOrderShopEntity();
$formDeleteOrderReductionCart = $this->createForm(DeleteOrderReductionCartType::class);
$formDeleteOrderReductionCart->handleRequest($this->request);

if ($formDeleteOrderReductionCart->isSubmitted() && $formDeleteOrderReductionCart->isValid()) {
$orderReductionCart = $this->em->getRepository(OrderReductionCartInterface::class)->find($formDeleteOrderReductionCart->get('id')->getData());

if ($orderReductionCart && $orderShop->getOrderReductionCarts()->contains($orderReductionCart)) {
$orderShop->removeOrderReductionCart($orderReductionCart);
$this->em->remove($orderReductionCart);
$this->em->flush();

$this->utils->addFlash('warning', 'success.order.removeReductionCart');
}

} else {
$this->utils->addFlash('error', $formDeleteOrderReductionCart->getErrors());
}
return $this->createOrderAjaxReponse($orderShop);
}

public function deleteOrderReductionCreditAction()
{
$orderShop = $this->getOrderShopEntity();
$formDeleteOrderReductionCredit = $this->createForm(DeleteOrderReductionCreditType::class);
$formDeleteOrderReductionCredit->handleRequest($this->request);

if ($formDeleteOrderReductionCredit->isSubmitted() && $formDeleteOrderReductionCredit->isValid()) {
$orderReductionCredit = $this->em->getRepository(OrderReductionCreditInterface::class)->find($formDeleteOrderReductionCredit->get('id')->getData());
if ($formDeleteOrderReductionCredit && $orderShop->getOrderReductionCredits()->contains($orderReductionCredit)) {
$orderShop->removeOrderReductionCredit($orderReductionCredit);
$this->em->remove($orderReductionCredit);
$this->em->flush();

$this->utils->addFlash('warning', 'success.order.removeReductionCredit');
}

} else {
$this->utils->addFlash('error', $formDeleteOrderReductionCredit->getErrors());
}
return $this->createOrderAjaxReponse($orderShop);
}

public function orderSendPaymentLinkAction(){
$orderShop = $this->getOrderShopEntity();
$formOrderSendPaymentLink = $this->createForm(OrderSendPaymentLink::class);
$formOrderSendPaymentLink->handleRequest($this->request);


if ($formOrderSendPaymentLink->isSubmitted() && $formOrderSendPaymentLink->isValid()) {
$orderShop->setOrderAllowByAdmin(true);
$this->em->persist($orderShop);
$this->em->flush();
$response['status'] = 'success';
$response['message'] = 'La commande a bien été modifié';
$this->mailUtils->send([
MailUtils::SUBJECT => 'Régler votre commande',
MailUtils::TO_EMAIL => $orderShop->getUser()->getEmail(),
MailUtils::TO_NAME => $orderShop->getUser()->getName(),
MailUtils::CONTENT_TEMPLATE => 'mail/order-payment-link',
MailUtils::CONTENT_DATA => [
'order_shop' => $orderShop,
'link' => $this->generateUrl('frontend_order_payment',array(),UrlGeneratorInterface::ABSOLUTE_URL)
],
]);

$this->utils->addFlash('success', 'success.order.removeReductionCredit');
} else {
$response['status'] = 'error';
$response['message'] = 'Une erreur est survenue';
$this->utils->addFlash('error', $formOrderSendPaymentLink->getErrors());
}
$response['data'] = $this->orderUtils->getOrderAsJsonObject($orderShop);;
return $this->createOrderAjaxReponse($orderShop);
}

protected function createOrderAjaxReponse(OrderShopInterface $order)
{
$response['flashMessages'] = $this->utils->getFlashMessages();
$response['data'] = $this->orderUtils->getOrderAsJsonObject($order);
return new Response(json_encode($response));
}


public function renderOrderShopTemplate($actionName, $templatePath, array $parameters = [])
{

if ($actionName == 'show') {
$formAddProductToOrder = $this->createForm(AddPoductToOrderType::class, null, array(
'action' => $this->generateUrl('easyadmin', [
'action' => 'addProductToOrder',
'entity' => $this->entity['name'],
'id' => $parameters['entity']->getId()
])
));
$formOrderProducts = $this->createForm(OrderProductsType::class, null, array(
'action' => $this->generateUrl('easyadmin', [
'action' => 'orderProducts',
'entity' => $this->entity['name'],
'id' => $parameters['entity']->getId()
])
));

$formOrderInvoiceAddress = $this->createForm(OrderInvoiceAddressType::class, null, array(
'data' => $parameters['entity'],
'action' => $this->generateUrl('easyadmin', [
'action' => 'orderInvoiceAddress',
'entity' => $this->entity['name'],
'id' => $parameters['entity']->getId()
])
));
if(!isset($parameters['form_order_delivery_address'])) {
$formOrderDeliveryAddress = $this->createForm(OrderDeliveryAddressType::class, null, array(
'data' => $parameters['entity'],
'action' => $this->generateUrl('easyadmin', [
'action' => 'orderDeliveryAddress',
'entity' => $this->entity['name'],
'id' => $parameters['entity']->getId()
])
));
$parameters['form_order_delivery_address'] = $formOrderDeliveryAddress->createView();

$orderShop = $this->getOrderShopEntity();

switch ($orderShop->getOrderStatus()->getAlias()) {
case OrderStatus::ALIAS_CART :
if (!isset($parameters['form_order_delivery_address'])) {
$parameters['form_order_delivery_address'] = $this->createCustomForm(OrderDeliveryAddressType::class, 'orderDeliveryAddress', $parameters)->createView();
}
$parameters['form_add_order_reduction_credit'] = $this->createCustomForm(AddOrderReductionCreditType::class, 'addOrderReductionCredit', $parameters)->createView();
$parameters['form_add_order_reduction_cart'] = $this->createCustomForm(AddOrderReductionCartType::class, 'addOrderReductionCart', $parameters)->createView();
$parameters['form_delete_order_reduction_cart'] = $this->createCustomForm(DeleteOrderReductionCartType::class, 'deleteOrderReductionCart', $parameters)->createView();
$parameters['form_delete_order_reduction_credit'] = $this->createCustomForm(DeleteOrderReductionCreditType::class, 'deleteOrderReductionCredit', $parameters)->createView();
$parameters['form_add_product_to_order'] = $this->createCustomForm(AddPoductToOrderType::class, 'addProductToOrder', $parameters)->createView();
$parameters['form_order_products'] = $this->createCustomForm(OrderProductsType::class, 'orderProducts', $parameters)->createView();
$parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView();
$parameters['form_order_invoice_address'] = $this->createCustomForm(OrderInvoiceAddressType::class, 'orderInvoiceAddress', $parameters)->createView();
$parameters['form_order_send_payment_link'] = $this->createCustomForm(OrderSendPaymentLink::class, 'orderSendPaymentLink', $parameters)->createView();
break;
case OrderStatus::ALIAS_ERROR_PAYMENT_ONLINE :
case OrderStatus::ALIAS_WAITING_PAYMENT_CREDIT :
case OrderStatus::ALIAS_WAITING_PAYMENT_ONLINE :
$parameters['form_order_send_payment_link'] = $this->createCustomForm(OrderSendPaymentLink::class, 'orderSendPaymentLink', $parameters)->createView();
$parameters['form_order_payment'] = $this->createCustomForm(OrderPaymentType::class, 'orderPayment', $parameters, false)->createView();
$parameters['form_delete_order_payment'] = $this->createCustomForm(DeleteOrderPaymentType::class, 'deleteOrderPayment', $parameters)->createView();
$parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView();
$parameters['form_order_invoice_address'] = $this->createCustomForm(OrderInvoiceAddressType::class, 'orderInvoiceAddress', $parameters)->createView();
break;
case OrderStatus::ALIAS_PAID_BY_CREDIT :
case OrderStatus::ALIAS_PAID_ONLINE :
case OrderStatus::ALIAS_WAITING_DELIVERY :
$parameters['form_order_payment'] = $this->createCustomForm(OrderPaymentType::class, 'orderPayment', $parameters, false)->createView();
$parameters['form_order_status'] = $this->createCustomForm(OrderStatusType::class, 'orderStatus', $parameters)->createView();
$parameters['form_delete_order_payment'] = $this->createCustomForm(DeleteOrderPaymentType::class, 'deleteOrderPayment', $parameters)->createView();
break;

}

if($orderShop->isValid()){
$templatePath = "@LcShop/backend/order/show-order.html.twig";
}else{
$templatePath = "@LcShop/backend/order/show-cart.html.twig";
}
$parameters['form_add_product_to_order'] = $formAddProductToOrder->createView();
$parameters['form_order_products'] = $formOrderProducts->createView();
$parameters['form_order_invoice_address'] = $formOrderInvoiceAddress->createView();
}


return parent::renderTemplate($actionName, $templatePath, $parameters);
}


protected function newAction()
{
$this->dispatch(EasyAdminEvents::PRE_NEW);
@@ -268,17 +511,28 @@ class OrderController extends AdminController

if (!$user instanceof UserInterface) return $user;
else {
$orderShopUser = $this->em->getRepository(OrderShopInterface::class)->findCartCurrent(['user' => $user]);
if ($orderShopUser) {
$this->utils->addFlash('info', 'error.order.otherOrderAlreadyExist');
return $this->redirectToRoute('easyadmin', [
'action' => 'edit',
'entity' => $this->entity['name'],
'id' => $orderShopUser->getId()
]);
} else {

$orderShop = $this->orderUtils->createOrderShop(array(
'user' => $user,
'merchant' => $this->merchantUtils->getMerchantUser()
));

return $this->redirectToRoute('easyadmin', [
'action' => 'edit',
'entity' => $this->entity['name'],
'id' => $orderShop->getId()
]);
$orderShop = $this->orderUtils->createOrderShop(array(
'user' => $user,
'merchant' => $this->merchantUtils->getMerchantUser()
));

return $this->redirectToRoute('easyadmin', [
'action' => 'edit',
'entity' => $this->entity['name'],
'id' => $orderShop->getId()
]);
}
}
}

@@ -312,7 +566,7 @@ class OrderController extends AdminController

];

return $this->executeDynamicMethod('render<EntityName>Template', ['show', $this->entity['templates']['show'], $parameters]);
return $this->executeDynamicMethod('renderOrderShopTemplate', ['show', $this->entity['templates']['show'], $parameters]);
}

/**
@@ -329,4 +583,10 @@ class OrderController extends AdminController
]);
}

}
protected function getOrderShopEntity()
{
$easyadmin = $this->request->attributes->get('easyadmin');
return $easyadmin['item'];
}

}

+ 76
- 39
ShopBundle/Controller/Backend/ProductFamilyController.php 查看文件

@@ -3,27 +3,19 @@
namespace Lc\ShopBundle\Controller\Backend;

use App\Entity\Product;
use App\Entity\ReductionCatalog;
use Doctrine\DBAL\Types\FloatType;
use Doctrine\ORM\EntityRepository;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\ShopBundle\Context\UnitInterface;
use Lc\ShopBundle\Form\ProductFamilyCategoriesType;
use Lc\ShopBundle\Form\ProductType;
use Lc\ShopBundle\Form\ReductionCatalogType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Lc\ShopBundle\Form\Backend\Common\ReductionCatalogType;
use Lc\ShopBundle\Form\Backend\ProductFamily\ProductType;
use Lc\ShopBundle\Model\ProductFamily;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Response;

class ProductFamilyController extends AdminController
@@ -40,7 +32,7 @@ class ProductFamilyController extends AdminController
$class = $this->em->getClassMetadata(ProductCategoryInterface::class);
$this->taxRateClass = $this->em->getClassMetadata(TaxRateInterface::class);

$formBuilder->add('productCategories', ProductFamilyCategoriesType::class);
//$formBuilder->add('productCategories', ProductFamilyCategoriesType::class);


$reductionCatalogRepo = $this->em->getRepository(ReductionCatalogInterface::class);
@@ -57,10 +49,10 @@ class ProductFamilyController extends AdminController

$formBuilder->add('warningMessageType', ChoiceType::class, array(
'choices' => array(
'field.default.warningMessageTypeOptions.success' => 'success',
'field.default.warningMessageTypeOptions.error' => 'error',
'field.default.warningMessageTypeOptions.warning' => 'warning',
'field.default.warningMessageTypeOptions.info' => 'info'
'field.default.warningMessageTypeOptions.'.ProductFamily::WARNING_MESSAGE_TYPE_SUCCESS => ProductFamily::WARNING_MESSAGE_TYPE_SUCCESS,
'field.default.warningMessageTypeOptions.'.ProductFamily::WARNING_MESSAGE_TYPE_ERROR => ProductFamily::WARNING_MESSAGE_TYPE_ERROR,
'field.default.warningMessageTypeOptions.'.ProductFamily::WARNING_MESSAGE_TYPE_WARNING => ProductFamily::WARNING_MESSAGE_TYPE_WARNING,
'field.default.warningMessageTypeOptions.'.ProductFamily::WARNING_MESSAGE_TYPE_INFO => ProductFamily::WARNING_MESSAGE_TYPE_INFO
),
'translation_domain' => 'lcshop',
'multiple' => false,
@@ -69,11 +61,12 @@ class ProductFamilyController extends AdminController
));

$formBuilder->add('behaviorCountStock', ChoiceType::class, array(
'empty_data' => 'by-product-family',
'empty_data' => ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY,
'choices' => array(
'field.ProductFamily.behaviorCountStockOptions.byQuantity' => 'by-quantity',
'field.ProductFamily.behaviorCountStockOptions.byProductFamily' => 'by-product-family',
'field.ProductFamily.behaviorCountStockOptions.byProduct' => 'by-product'
'field.ProductFamily.behaviorCountStockOptions.' . ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE => ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE,
'field.ProductFamily.behaviorCountStockOptions.' . ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY => ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY,
'field.ProductFamily.behaviorCountStockOptions.' . ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT => ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT,
'field.ProductFamily.behaviorCountStockOptions.' . ProductFamily::BEHAVIOR_COUNT_STOCK_UNLIMITED => ProductFamily::BEHAVIOR_COUNT_STOCK_UNLIMITED
),
'translation_domain' => 'lcshop',
'multiple' => false,
@@ -83,8 +76,8 @@ class ProductFamilyController extends AdminController
$formBuilder->add('behaviorAddToCart', ChoiceType::class, array(
'data' => $entity->getBehaviorAddToCart() ? $entity->getBehaviorAddToCart() : 'simple',
'choices' => array(
'field.ProductFamily.behaviorAddToCartOptions.simple' => 'simple',
'field.ProductFamily.behaviorAddToCartOptions.multiple' => 'multiple'
'field.ProductFamily.behaviorAddToCartOptions.'.ProductFamily::BEHAVIOR_ADD_TO_CART_SIMPLE => ProductFamily::BEHAVIOR_ADD_TO_CART_SIMPLE,
'field.ProductFamily.behaviorAddToCartOptions.'.ProductFamily::BEHAVIOR_ADD_TO_CART_MULTIPLE => ProductFamily::BEHAVIOR_ADD_TO_CART_MULTIPLE
),
'translation_domain' => 'lcshop',
'multiple' => false,
@@ -94,8 +87,8 @@ class ProductFamilyController extends AdminController
$formBuilder->add('behaviorPrice', ChoiceType::class, array(
'empty_data' => 'by-piece',
'choices' => array(
'field.ProductFamily.behaviorPriceOptions.byPiece' => 'by-piece',
'field.ProductFamily.behaviorPriceOptions.byRefUnit' => 'by-reference-unit'
'field.ProductFamily.behaviorPriceOptions.'.ProductFamily::BEHAVIOR_PRICE_BY_PIECE => ProductFamily::BEHAVIOR_PRICE_BY_PIECE,
'field.ProductFamily.behaviorPriceOptions.'.ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT => ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT
),
'translation_domain' => 'lcshop',
'multiple' => false,
@@ -109,9 +102,9 @@ class ProductFamilyController extends AdminController

$formBuilder->add('propertyOrganicLabel', ChoiceType::class, array(
'choices' => array(
'field.ProductFamily.organicLabelOptions.ab' => 'ab',
'field.ProductFamily.organicLabelOptions.natureProgres' => 'nature-progres',
'field.ProductFamily.organicLabelOptions.hVE' => 'hve'
'field.ProductFamily.organicLabelOptions.'.ProductFamily::PROPERTY_ORGANIC_LABEL_AB => ProductFamily::PROPERTY_ORGANIC_LABEL_AB,
'field.ProductFamily.organicLabelOptions.'.ProductFamily::PROPERTY_ORGANIC_LABEL_NP => ProductFamily::PROPERTY_ORGANIC_LABEL_NP,
'field.ProductFamily.organicLabelOptions.'.ProductFamily::PROPERTY_ORGANIC_LABEL_HVE => ProductFamily::PROPERTY_ORGANIC_LABEL_HVE
),
'translation_domain' => 'lcshop',
'multiple' => false,
@@ -121,9 +114,9 @@ class ProductFamilyController extends AdminController

$formBuilder->add('typeExpirationDate', ChoiceType::class, array(
'choices' => array(
'field.default.dlc' => 'dlc',
'field.default.ddm' => 'ddm',
'field.default.dluo' => 'dluo'
'field.default.'.ProductFamily::TYPE_EXPIRATION_DATE_DLC => ProductFamily::TYPE_EXPIRATION_DATE_DLC,
'field.default.'.ProductFamily::TYPE_EXPIRATION_DATE_DDM => ProductFamily::TYPE_EXPIRATION_DATE_DDM,
'field.default.'.ProductFamily::TYPE_EXPIRATION_DATE_DLUO => ProductFamily::TYPE_EXPIRATION_DATE_DLUO
),
'translation_domain' => 'lcshop',
'multiple' => false,
@@ -131,10 +124,22 @@ class ProductFamilyController extends AdminController
'required'=>false
));

$formBuilder->add('behaviorStockWeek', ChoiceType::class, array(
'choices' => array(
'field.ProductFamily.behaviorStockWeekOptions.'.ProductFamily::BEHAVIOR_STOCK_WEEK_RENEWABLE => ProductFamily::BEHAVIOR_STOCK_WEEK_RENEWABLE,
'field.ProductFamily.behaviorStockWeekOptions.'.ProductFamily::BEHAVIOR_STOCK_WEEK_RENEWABLE_VALIDATION => ProductFamily::BEHAVIOR_STOCK_WEEK_RENEWABLE_VALIDATION,
'field.ProductFamily.behaviorStockWeekOptions.'.ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE => ProductFamily::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE
),
'translation_domain' => 'lcshop',
'multiple' => false,
'expanded' => true,
'required'=>true
));

$formBuilder->add('behaviorExpirationDate', ChoiceType::class, array(
'choices' => array(
'field.ProductFamily.behaviorExpirationDateOptions.productFamily' => 'by-product-family',
'field.ProductFamily.behaviorExpirationDateOptions.product' => 'by-product'
'field.ProductFamily.behaviorExpirationDateOptions.'.ProductFamily::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY => ProductFamily::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY,
'field.ProductFamily.behaviorExpirationDateOptions.'.ProductFamily::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT => ProductFamily::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT
),
'translation_domain' => 'lcshop',
'multiple' => false,
@@ -249,6 +254,25 @@ class ProductFamilyController extends AdminController
$easyadmin = $this->request->attributes->get('easyadmin');
$entity = $easyadmin['item'];




$orderShopRepo = $this->em->getRepository(OrderShopInterface::class);

$totalProductOrdered = array();
foreach ($entity->getProducts() as $product) {
$currentWeekNumber = $this->orderUtils->getWeekNumberCurrent();
//Les commandes sont ouvertes ont récupèrent les commandes en cours et celle de la semaine dernière
if($this->orderUtils->isOpenSale()) {
$totalProductOrdered[$product->getId()][$currentWeekNumber] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId());
$totalProductOrdered[$product->getId()][$currentWeekNumber - 1] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber - 1, $product->getId());
}else{
$totalProductOrdered[$product->getId()][$currentWeekNumber] = $orderShopRepo->countValidOrderProductsOfWeekByProduct($currentWeekNumber, $product->getId());
}
}



if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) {
$newValue = 'true' === mb_strtolower($this->request->query->get('newValue'));
$fieldsMetadata = $this->entity['list']['fields'];
@@ -275,7 +299,12 @@ class ProductFamilyController extends AdminController
ksort($sortableProductsField);

$editForm->handleRequest($this->request);
if ($editForm->isSubmitted() && $editForm->isValid()) {

if( $editForm->isSubmitted() && count($entity->getProductCategories()) == 0){
$editForm->get('productCategories')->addError(new FormError('Vous devez choisir au moins une catégorie'));
}

if ($editForm->isSubmitted() && $editForm->isValid() && count($entity->getProductCategories())>0) {

$this->processUploadedFiles($editForm);

@@ -283,7 +312,8 @@ class ProductFamilyController extends AdminController
$this->executeDynamicMethod('update<EntityName>Entity', [$entity, $editForm]);
$this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]);

return $this->redirectToReferrer();
$this->utils->addFlash('success', 'Produit sauvegardé') ;
return $this->redirectToRoute('easyadmin', ['entity' => 'ProductFamily', 'action' => 'edit', 'id' => $id]) ;
}

$this->dispatch(EasyAdminEvents::POST_EDIT);
@@ -293,7 +323,8 @@ class ProductFamilyController extends AdminController
'entity_fields' => $fields,
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
'sortableProductsField' => $sortableProductsField
'sortableProductsField' => $sortableProductsField,
'totalProductOrdered' => $totalProductOrdered
];

return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]);
@@ -315,7 +346,12 @@ class ProductFamilyController extends AdminController

$newForm->handleRequest($this->request);

if ($newForm->isSubmitted() && $newForm->isValid()) {

if( $newForm->isSubmitted() && array_search(true, $newForm->get('productCategories')->getData()->toArray())===false){
$newForm->get('productCategories')->addError(new FormError('Vous devez choisir au moins une catégorie'));
}

if ($newForm->isSubmitted() && $newForm->isValid() && array_search(true, $newForm->get('productCategories')->getData()->toArray())!==false) {
$this->processUploadedFiles($newForm);

$this->dispatch(EasyAdminEvents::PRE_PERSIST, ['entity' => $entity]);
@@ -339,7 +375,8 @@ class ProductFamilyController extends AdminController
'entity_fields' => $fields,
'entity' => $entity,
'categories' => $categories,
'sortableProductsField' => array()
'sortableProductsField' => array(),
'totalProductOrdered' => array()
];

return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]);

+ 56
- 0
ShopBundle/Controller/Backend/ReminderController.php 查看文件

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

namespace Lc\ShopBundle\Controller\Backend;

use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use Lc\ShopBundle\Form\Backend\Common\ReminderType;
use Symfony\Component\HttpFoundation\Response;

class ReminderController extends AdminController
{

public function renderTemplate($actionName, $templatePath, array $parameters = [])
{
if($this->request->isXmlHttpRequest() && ($actionName == 'new' || $actionName == 'edit')) {
$response['flashMessages'] = $this->utils->getFlashMessages();

$response['data'] = $this->render('@LcShop/backend/default/modal/edit_reminder.twig', $parameters)->getContent();
return new Response(json_encode($response));
}else{
return parent::renderTemplate($actionName, $templatePath, $parameters);
}

}


protected function redirectToReferrer(){
$action = $this->request->query->get('action');

if($action == 'new'){
$this->utils->addFlash('success', 'success.reminder.add');
}elseif($action == 'edit'){
$this->utils->addFlash('success', 'success.reminder.edit');
}elseif($action == ' setReminderDone'){
$this->utils->addFlash('success', 'success.reminder.done');
}

if($this->request->isXmlHttpRequest()) {
$response['flashMessages'] = $this->utils->getFlashMessages();
return new Response(json_encode($response));
}
}

public function setReminderDoneAction(){
$id = $this->request->query->get('id');
$done = $this->request->query->get('done');

$easyadmin = $this->request->attributes->get('easyadmin');
$reminder = $easyadmin['item'];

$reminder->setDone($done);
$this->em->persist($reminder);
$this->em->flush();
return $this->redirectToReferrer();
}

}

+ 86
- 0
ShopBundle/Controller/Backend/TicketController.php 查看文件

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

namespace Lc\ShopBundle\Controller\Backend;

use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Form\Backend\Ticket\TicketMessageType;
use Lc\ShopBundle\Form\Backend\Ticket\TicketStatusType;
use Lc\ShopBundle\Services\UtilsManager;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;

class TicketController extends AdminController
{
protected $ticketUtils;
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator)
{
$this->ticketUtils = $utilsManager->getTicketUtils();
parent::__construct($security, $userManager, $em, $mailjetTransport, $utilsManager, $translator);

}

/**
* The method that is executed when the user performs a 'show' action on an entity.
*
* @return Response
*/
public function renderTicketTemplate($actionName, $templatePath, array $parameters = [])
{
if ($actionName == 'show') {
$parameters['form_add_ticket_message'] = $this->createCustomForm(TicketMessageType::class, 'newMessageTicket', $parameters, false)->createView();
$parameters['form_ticket_status'] = $this->createCustomForm(TicketStatusType::class, 'ticketStatus', $parameters)->createView();
}
return parent::renderTemplate($actionName, $templatePath, $parameters);

}


public function ticketStatusAction(){
$easyadmin = $this->request->attributes->get('easyadmin');
$ticket = $easyadmin['item'];

$formTicketStatusForm = $this->createForm(TicketStatusType::class, $ticket);
$formTicketStatusForm->handleRequest($this->request);

if ($formTicketStatusForm->isSubmitted() && $formTicketStatusForm->isValid()) {
$this->em->persist($ticket);
$this->em->flush();

$this->utils->addFlash('success', 'success.ticket.statusChange');
} else {
$this->utils->addFlash('error', $formTicketStatusForm->getErrors());
}
$response['flashMessages'] = $this->utils->getFlashMessages();

return new Response(json_encode($response));
}

public function newMessageTicketAction(){
$easyadmin = $this->request->attributes->get('easyadmin');
$ticket = $easyadmin['item'];

$formAddTicketMessage = $this->createForm(TicketMessageType::class);
$formAddTicketMessage->handleRequest($this->request);

if ($formAddTicketMessage->isSubmitted() && $formAddTicketMessage->isValid()) {
$this->ticketUtils->createTicketMessage(array(
'ticket'=>$ticket,
'message'=> $formAddTicketMessage->get('message')->getData(),
'answerByAdmin'=>true
));

$this->utils->addFlash('success', 'success.ticket.addMessage');
} else {
$this->utils->addFlash('error', $formAddTicketMessage->getErrors());
}

return $this->redirectToRoute('easyadmin', [
'action' => 'show',
'entity' => 'Ticket',
'id' => $ticket->getId()
]);
}
}

+ 5
- 0
ShopBundle/Controller/Backend/UserController.php 查看文件

@@ -2,8 +2,11 @@

namespace Lc\ShopBundle\Controller\Backend;

use App\Form\Backend\Common\AddressType;
use FOS\UserBundle\Doctrine\UserManager;
use FOS\UserBundle\Model\UserManagerInterface ;
use Lc\ShopBundle\Context\AddressInterface;
use Lc\ShopBundle\Model\Address;

class UserController extends AdminController
{
@@ -24,4 +27,6 @@ class UserController extends AdminController
$this->userManager->updateUser($user, false);
parent::updateEntity($user);
}


}

+ 173
- 0
ShopBundle/Controller/Backend/UserMerchantController.php 查看文件

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

namespace Lc\ShopBundle\Controller\Backend;

use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents;
use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\CreditHistoryInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Form\Backend\UserMerchant\CreditHistoryType;
use Lc\ShopBundle\Services\CreditUtils;
use Lc\ShopBundle\Services\Utils;
use Lc\ShopBundle\Services\UtilsManager;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;

class UserMerchantController extends AdminController
{
protected $creditUtils;

public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator)
{
parent::__construct($security, $userManager, $em, $mailjetTransport, $utilsManager, $translator);
$this->creditUtils = $utilsManager->getCreditUtils();
}

public function addCreditHistoryAction(){
$easyadmin = $this->request->attributes->get('easyadmin');
$userMerchant = $easyadmin['item'];

$creditHistoryClass = $this->em->getClassMetadata(CreditHistoryInterface::class);
$creditHistory = new $creditHistoryClass->name;

$addCreditHistoryForm = $this->createForm(CreditHistoryType::class, $creditHistory);
$addCreditHistoryForm->handleRequest($this->request);
if ($addCreditHistoryForm->isSubmitted() && $addCreditHistoryForm->isValid()) {
$creditHistory->setUserMerchant($userMerchant);
if($this->creditUtils->saveCreditHistory($creditHistory)){

//TODo envoyer un email à l'utilisateur
$this->utils->addFlash('success', 'success.credit.added');
}else{
$this->utils->addFlash('error', 'error.credit.notAdded');
}

} else {
$this->utils->addFlash('error', $addCreditHistoryForm->getErrors());
}
return $this->redirectToRoute('easyadmin', [
'action' => 'show',
'entity' => $this->request->query->get('entity'),
'id' => $userMerchant->getId()
]);
}
protected function newAction()
{
$this->dispatch(EasyAdminEvents::PRE_NEW);

$entity = $this->executeDynamicMethod('createNew<EntityName>Entity');

$easyadmin = $this->request->attributes->get('easyadmin');
$easyadmin['item'] = $entity;
$this->request->attributes->set('easyadmin', $easyadmin);

$fields = $this->entity['new']['fields'];

$newForm = $this->executeDynamicMethod('create<EntityName>NewForm', [$entity, $fields]);

$newForm->handleRequest($this->request);

//ETAPE 1 Choix de l'utilisateur
$user = $newForm->get('user')->getData();

if ($user == null) {
$user = $this->getUserViaFirstStepForm($entity);
}

if (!$user instanceof UserInterface) return $user;
else {

$userMerchant = $this->creditUtils->activeCredit($user);

return $this->redirectToRoute('easyadmin', [
'action' => 'edit',
'entity' => $this->entity['name'],
'id' => $userMerchant->getId()
]);
}
}

public function getUserViaFirstStepForm($entity)
{
$userClass = $this->em->getClassMetadata(UserInterface::class);

$userChoiceForm = $this->createFormBuilder($entity)
->add('user', EntityType::class, array(
'class' => $userClass->name
))
->add('nextStep', SubmitType::class)
->getForm();
$userChoiceForm->handleRequest($this->request);
if ($userChoiceForm->isSubmitted() && $userChoiceForm->isValid()) {
return $userChoiceForm->get('user')->getData();
}

$parameters = [
'form' => $userChoiceForm->createView(),
'formView' => 'default',
'entity' => $entity,
];

return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]);
}

/**
* The method that is executed when the user performs a 'show' action on an entity.
*
* @return Response
*/
public function showAction()
{
$this->dispatch(EasyAdminEvents::PRE_SHOW);

$id = $this->request->query->get('id');
$easyadmin = $this->request->attributes->get('easyadmin');
$entity = $easyadmin['item'];

$fields = $this->entity['show']['fields'];


$this->dispatch(EasyAdminEvents::POST_SHOW, [
//'deleteForm' => $deleteForm,
'fields' => $fields,
'entity' => $entity,
]);

$parameters = [
'entity' => $entity,
'fields' => $fields
];

return $this->executeDynamicMethod('render<EntityName>Template', ['show', $this->entity['templates']['show'], $parameters]);
}

public function renderUserMerchantTemplate($actionName, $templatePath, array $parameters = []){
if ($actionName == 'show') {
$parameters['add_credit_history_form'] = $this->createCustomForm(CreditHistoryType::class, 'addCreditHistory', $parameters, false)->createView();
}

return parent::renderTemplate($actionName, $templatePath, $parameters);

}

/**
* Réécriture de edit action pr rediriger vers le show */
public function editAction()
{
$id = $this->request->query->get('id');
$entity = $this->request->query->get('entity');

return $this->redirectToRoute('easyadmin', [
'action' => 'show',
'entity' => $entity,
'id' => $id
]);
}

}

+ 6
- 5
ShopBundle/Controller/CitiesController.php 查看文件

@@ -3,17 +3,18 @@
namespace Lc\ShopBundle\Controller ;

use Lc\ShopBundle\Services\CityUtils;
use Lc\ShopBundle\Services\Utils;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class CitiesController extends AbstractController
{
protected $cities ;
protected $utils ;

public function __construct(CityUtils $cities)
public function __construct(Utils $utils)
{
$this->cities = $cities ;
$this->utils = $utils ;
}

public function index(Request $request) : JsonResponse
@@ -32,8 +33,8 @@ class CitiesController extends AbstractController
}

$result = array_merge(
json_decode($this->cities->callApi('get', 'communes', array_merge($data, ['codeRegion' => 27]))),
json_decode($this->cities->callApi('get', 'communes', array_merge($data, ['codeRegion' => 44])))
json_decode($this->utils->callCitiesApi('get', 'communes', array_merge($data, ['codeRegion' => 27]))),
json_decode($this->utils->callCitiesApi('get', 'communes', array_merge($data, ['codeRegion' => 44])))
);

$return = [] ;

+ 123
- 4
ShopBundle/Controller/Frontend/CartController.php 查看文件

@@ -2,19 +2,32 @@

namespace Lc\ShopBundle\Controller\Frontend ;

use App\Entity\ReductionCredit;
use App\Form\Frontend\OrderProductsType;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderReductionCreditInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Model\OrderReductionCart;
use Lc\ShopBundle\Model\ProductFamily;
use Lc\ShopBundle\Services\UserUtils;
use Lc\ShopBundle\Services\UtilsManager;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Security;

class CartController extends BaseController
{
protected $orderUtils ;
protected $userUtils ;
protected $priceUtils ;
protected $router ;
protected $productFamilyRepository ;
protected $orderProductRepository ;

@@ -22,21 +35,36 @@ class CartController extends BaseController
protected $orderProducts = [] ;


public function __construct(EntityManagerInterface $em, Security $security, MerchantUtilsInterface $merchantUtils, OrderUtilsInterface $orderUtils)
public function __construct(EntityManagerInterface $em, Security $security, MerchantUtilsInterface $merchantUtils,
UrlGeneratorInterface $router, UtilsManager $utilsManager)
{
parent::__construct($em, $security, $merchantUtils);
$this->orderUtils = $orderUtils ;
$this->orderUtils = $utilsManager->getOrderUtils() ;
$this->userUtils = $utilsManager->getUserUtils() ;
$this->priceUtils = $utilsManager->getPriceUtils() ;
$this->router = $router ;
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetaData(ProductFamilyInterface::class)->getName()) ;
$this->orderProductRepository = $this->em->getRepository($this->em->getClassMetaData(OrderProductInterface::class)->getName()) ;
}

public function addProductFamily(Request $request)
{
$user = $this->security->getUser() ;
$visitor = $this->userUtils->getVisitorCurrent() ;

$return = [] ;
$data = $request->request->all() ;

if(isset($data['order_products']['id_product_family'])) {
$idProductFamily = $data['order_products']['id_product_family'] ;
$this->productFamily = $this->productFamilyRepository->find($idProductFamily) ;

// alerte si cookies non acceptés
if (!$user && !$visitor) {
$this->addFlash('error', 'Vous devez <a href="'.$this->router->generate('frontend_page', ['devAlias' => 'politique-de-confidentialite']).'">accepter les cookies</a> ou vous <a href="'.$this->router->generate('fos_user_security_login').'">connecter</a> pour ajouter un produit.');
return false ;
}

if($this->productFamily) {
$form = $this->createForm(OrderProductsType::class, ['id_product_family' => $this->productFamily->getId()]);
$form->handleRequest($request);
@@ -46,8 +74,8 @@ class CartController extends BaseController
$data = $form->getData() ;
foreach($data as $orderProduct) {
if($orderProduct instanceof OrderProductInterface) {
$this->orderUtils->addOrderProduct($orderShop, $orderProduct) ;
if($orderProduct->getQuantityOrder() > 0) {
$addOrderProduct = $this->orderUtils->addOrderProduct($orderShop, $orderProduct) ;
if($addOrderProduct && $orderProduct->getQuantityOrder() > 0) {
$this->orderProducts[] = $orderProduct ;
}
}
@@ -59,4 +87,95 @@ class CartController extends BaseController
return new JsonResponse($return) ;
}

public function redirectToReferer($request) {
$referer = $request->headers->get('referer');

if($referer) {
return $this->redirect($referer);
}
else {
return $this->redirectToRoute('frontend_order_cart');
}
}

public function deleteReductionCart(Request $request)
{
$id = $request->get('id') ;

$orderReductionCartRepository = $this->em->getRepository($this->em->getClassMetadata(OrderReductionCartInterface::class)->getName()) ;
$orderReductionCart = $orderReductionCartRepository->findOneById((int) $id) ;

$orderShop = $this->orderUtils->getCartCurrent() ;

if($orderReductionCart && $orderShop->getOrderReductionCarts() && $orderShop->getOrderReductionCarts()->contains($orderReductionCart)) {
$this->em->remove($orderReductionCart) ;
$this->em->flush() ;

$this->addFlash('success', 'La réduction a bien été supprimée de votre panier.') ;
}
else {
$this->addFlash('error', 'Une erreur est survenue lors de la suppression de la réduction. ') ;
}

return $this->redirectToReferer($request) ;
}

public function addReductionCredit(Request $request)
{
$id = $request->get('id') ;
$orderShop = $this->orderUtils->getCartCurrent() ;
$user = $this->security->getUser() ;

$reductionCreditRepository = $this->em->getRepository(ReductionCredit::class) ;
$reductionCredit = $reductionCreditRepository->find($id) ;

if($orderShop && $user && $reductionCredit
&& $this->orderUtils->isReductionCreditAllowAddToOrder($orderShop, $reductionCredit)
&& !$this->orderUtils->isReductionCreditAddedToOrder($orderShop, $reductionCredit)) {

$return = $this->orderUtils->createOrderReductionCredit($orderShop, $reductionCredit) ;

if($return) {
$this->addFlash('success', 'Votre avoir a bien été ajouté à votre panier.') ;
}
else {
$this->addFlash('error', 'Vous ne pouvez pas effectuer cette action. Le montant de la commande est insuffisant.') ;
}
}
else {
$this->addFlash('error', "Impossible d'effectuer cette action");
}

return $this->redirectToReferer($request) ;
}

public function deleteReductionCredit(Request $request)
{
$id = $request->get('id') ;

$orderReductionCreditRepository = $this->em->getRepository($this->em->getClassMetadata(OrderReductionCreditInterface::class)->getName()) ;
$orderReductionCredit = $orderReductionCreditRepository->findOneById((int) $id) ;

$orderShop = $this->orderUtils->getCartCurrent() ;

if($orderReductionCredit && $orderShop->getOrderReductionCredits() && $orderShop->getOrderReductionCredits()->contains($orderReductionCredit)) {
$this->em->remove($orderReductionCredit) ;
$this->em->flush() ;

$this->addFlash('success', 'Votre avoir a bien été supprimé de votre panier.') ;
}
else {
$this->addFlash('error', 'Une erreur est survenue lors de la suppression de votre avoir. ') ;
}

$referer = $request->headers->get('referer');

if($referer) {
return $this->redirect($referer);
}
else {
return $this->redirectToRoute('frontend_order_cart');
}
}

}

ShopBundle/Form/AbstractEditPositionType.php → ShopBundle/Form/Backend/Common/AbstractEditPositionType.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Form;
namespace Lc\ShopBundle\Form\Backend\Common;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;

ShopBundle/Form/AddressType.php → ShopBundle/Form/Backend/Common/AddressType.php 查看文件

@@ -1,8 +1,10 @@
<?php

namespace Lc\ShopBundle\Form;
namespace Lc\ShopBundle\Form\Backend\Common;

use Lc\ShopBundle\Model\Address;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Doctrine\ORM\EntityManagerInterface;
@@ -24,14 +26,14 @@ class AddressType extends AbstractType

public function buildForm(FormBuilderInterface $builder, array $options)
{
dump($options);
$builder
->add('title', TextType::class, ['label' => 'Titre'])
->add('type', ChoiceType::class, [
'label' => 'Type',
'choices' => [
'--' => '',
'Particulier' => 'individual',
'Personne morale' => 'legal-person',
'field.Address.typeOptions.' . Address::TYPE_INDIVIDUAL => Address::TYPE_INDIVIDUAL,
'field.Address.typeOptions.' . Address::TYPE_LEGAL_PERSON => Address::TYPE_LEGAL_PERSON
]
])
->add('civility', ChoiceType::class, [
@@ -43,23 +45,31 @@ class AddressType extends AbstractType
'Homme' => 0,
],
])
->add('lastname', TextType::class, ['label' => 'Nom', 'required' => false])
->add('firstname', TextType::class, ['label' => 'Prénom', 'required' => false])
->add('address', TextareaType::class, ['label' => 'Adresse'])
->add('zip', TextType::class, ['label' => 'Code postale'])
->add('city', TextType::class, ['label' => 'Ville'])
->add('country', TextType::class, ['label' => 'Pays'])
->add('phone', TextType::class, ['label' => 'Téléphone', 'required' => false])
->add('company', TextType::class, ['label' => 'Entreprise', 'required' => false])
->add('siret', TextType::class, ['label' => 'SIRET', 'required' => false])
->add('tva', TextType::class, ['label' => 'Numéro TVA', 'required' => false]);
->add('lastname', TextType::class, ['required' => false])
->add('firstname', TextType::class, ['required' => false])
->add('address', TextareaType::class)
->add('zip', TextType::class)
->add('city', TextType::class)
->add('phone', CollectionType::class, [
'allow_add'=>true,
'allow_delete'=>true,
'entry_options' => [
'label'=>false,
],
'required' => false
])
->add('company', TextType::class, ['required' => false])
->add('siret', TextType::class, ['required' => false])
->add('tva', TextType::class, ['required' => false]);

}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'label' => false,
'data_class' => $this->em->getClassMetadata(AddressInterface::class)->getName()
'data_class' => $this->em->getClassMetadata(AddressInterface::class)->getName(),
'translation_domain' => 'lcshop'
]);
}
}

+ 59
- 0
ShopBundle/Form/Backend/Common/ReductionCatalogType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Common;

use Lc\ShopBundle\Context\GroupUserInterface;
use Lc\ShopBundle\Form\Backend\ReductionCommon\BehaviorTaxRateType;
use Lc\ShopBundle\Form\Backend\ReductionCommon\DateEndType;
use Lc\ShopBundle\Form\Backend\ReductionCommon\DateStartType;
use Lc\ShopBundle\Form\Backend\ReductionCommon\GroupUsersFilterType;
use Lc\ShopBundle\Form\Backend\ReductionCommon\PermanentType;
use Lc\ShopBundle\Form\Backend\ReductionCommon\UnitType;
use Lc\ShopBundle\Form\Backend\ReductionCommon\UsersFilterType;
use Lc\ShopBundle\Form\Backend\ReductionCommon\ValueType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;


class ReductionCatalogType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TextType::class, [
'label' => 'Titre',
'required' => false,
])
->add('behaviorTaxRate', BehaviorTaxRateType::class)
->add('unit', UnitType::class)
->add('value', ValueType::class)
->add('permanent', PermanentType::class)
->add('dateStart', DateStartType::class)
->add('dateEnd', DateEndType::class)
->add('users', UsersFilterType::class)
->add('groupUsers', GroupUsersFilterType::class);
}

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

+ 71
- 0
ShopBundle/Form/Backend/Common/ReminderType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Common;

use Lc\ShopBundle\Context\ReminderInterface;
use Lc\ShopBundle\Context\UserInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Lc\ShopBundle\Context\AddressInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\NotBlank;

class ReminderType 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);
$userRepo= $this->em->getRepository(UserInterface::class);
$builder
->add('title', TextType::class, ['label' => 'Titre'])
->add('description', TextareaType::class, array(
'required' => false
))
->add('entityName', HiddenType::class, array(
'required' => false
))
->add('entityId', HiddenType::class, array(
'required' => false
))
->add('entityAction', HiddenType::class, array(
'required' => false
))
->add('users', EntityType::class, array(
'class'=> $userClass->name,
'choices'=> $userRepo->findByRole('ROLE_ADMIN'),
'required' => false,
'multiple'=>true
))
->add('dateReminder', DateType::class, array(
'required'=>false,
'widget'=>'single_text',
));


}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'label' => false,
'data_class' => $this->em->getClassMetadata(ReminderInterface::class)->getName()
]);
}
}

ShopBundle/Form/MerchantConfigType.php → ShopBundle/Form/Backend/Merchant/MerchantConfigType.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Form;
namespace Lc\ShopBundle\Form\Backend\Merchant;

use CKSource\Bundle\CKFinderBundle\Form\Type\CKFinderFileChooserType;
use Lc\ShopBundle\Context\MerchantConfigInterface;
@@ -30,7 +30,9 @@ class MerchantConfigType extends AbstractType
{

$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {

$form = $event->getForm();

$merchantConfig = $event->getData();

if ($merchantConfig) {

+ 68
- 0
ShopBundle/Form/Backend/Merchant/MerchantConfigsType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Merchant;

use App\Entity\MerchantConfig;
use CKSource\Bundle\CKFinderBundle\Form\Type\CKFinderFileChooserType;
use Doctrine\Common\Collections\ArrayCollection;
use Lc\ShopBundle\Context\MerchantConfigInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Doctrine\ORM\EntityManagerInterface;
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;
use Symfony\Component\Security\Core\Security;
use Vich\UploaderBundle\Form\Type\VichImageType;

class MerchantConfigsType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{

$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {

$builder = $event->getForm()->getParent();

// Reindex collection using id
$indexedCollection = new ArrayCollection();
foreach ($event->getData() as $collectionItem) {
$indexedCollection->set($collectionItem->getName(), $collectionItem);
}


$builder->add('merchantConfigs', CollectionType::class, [
'translation_domain' => 'lcshop',
'entry_type'=> MerchantConfigType::class,
'data'=>$indexedCollection,
'required' => false,
'allow_add'=> false,
'allow_delete'=>false,
'by_reference'=>false
]);


});

}

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


+ 59
- 0
ShopBundle/Form/Backend/Order/AddOrderReductionCartType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class AddOrderReductionCartType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$entity = $options['data'];

$reductionCartClass = $this->em->getClassMetadata(ReductionCartInterface::class);
$reductionCartRepo = $this->em->getRepository(ReductionCartInterface::class);;

$builder
->add('reductionCart', EntityType::class, array(
'class' => $reductionCartClass->getName(),
'choices' => $reductionCartRepo->getEligibleReductionCart($entity),
'required' => true,
'mapped'=>false
));
$builder->add('add', ButtonType::class, array(
'label' => 'action.add'
));


}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(),
'translation_domain'=> 'lcshop'
]);
}
}

+ 65
- 0
ShopBundle/Form/Backend/Order/AddOrderReductionCreditType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class AddOrderReductionCreditType extends AbstractType
{
protected $em;
protected $orderUtils;

public function __construct(EntityManagerInterface $em, OrderUtilsInterface $orderUtils)
{
$this->em = $em;
$this->orderUtils = $orderUtils;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$entity = $options['data'];

$reductionCreditClass = $this->em->getClassMetadata(ReductionCreditInterface::class);
$reductionCreditRepo = $this->em->getRepository(ReductionCreditInterface::class);;

$builder
->add('reductionCredit', EntityType::class, array(
'class' => $reductionCreditClass->getName(),
'choices' => $reductionCreditRepo->findReductionCreditsByUser($entity->getUser()),
//'choices' => $this->orderUtils->getReductionCreditsAvailable($entity),

'required' => true,
'mapped'=>false
));
$builder->add('add', ButtonType::class, array(
'label' => 'action.add'
));


}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(),
'translation_domain'=> 'lcshop'
]);
}
}

ShopBundle/Form/Order/AddPoductToOrderType.php → ShopBundle/Form/Backend/Order/AddPoductToOrderType.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Form\Order;
namespace Lc\ShopBundle\Form\Backend\Order;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
@@ -49,8 +49,8 @@ class AddPoductToOrderType extends AbstractType
->add('quantity', IntegerType::class, array(
'mapped' => false
))
->add('addProductToOrder', ButtonType::class, array(
'label'=> 'field.OrderShop.addOrderToProduct'
->add('add', ButtonType::class, array(
'label'=> 'action.add'
));
}

@@ -60,4 +60,4 @@ class AddPoductToOrderType extends AbstractType
'translation_domain'=>'lcshop'
]);
}
}
}

+ 59
- 0
ShopBundle/Form/Backend/Order/AddRedeliveryOrderProductType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class AddRedeliveryOrderProductType extends AbstractType
{
protected $em;
protected $orderUtils;

public function __construct(EntityManagerInterface $em, OrderUtilsInterface $orderUtils)
{
$this->em = $em;
$this->orderUtils = $orderUtils;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{

// TODO ce form n'a pas été testé !!!!! voir exemple sur PDL

$builder->add('title', TextType::class);
$builder->add('unit');
$builder->add('quantityProduct', NumberType::class);
$builder->add('quantityOrder', NumberType::class);
$builder->add('add', ButtonType::class, array(
'label' => 'action.add'
));


}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderProductInterface::class)->getName(),
'translation_domain'=> 'lcshop'
]);
}
}

+ 60
- 0
ShopBundle/Form/Backend/Order/AddReductionCreditType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class AddReductionCreditType extends AbstractType
{
protected $em;
protected $orderUtils;

public function __construct(EntityManagerInterface $em, OrderUtilsInterface $orderUtils)
{
$this->em = $em;
$this->orderUtils = $orderUtils;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{

// TODO ce form n'a pas été testé !!!!! voir exemple sur PDL

$entity = $options['data'];

$reductionCreditClass = $this->em->getClassMetadata(ReductionCreditInterface::class);
$reductionCreditRepo = $this->em->getRepository(ReductionCreditInterface::class);;


$builder->add('add', ButtonType::class, array(
'label' => 'action.add'
));


}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(ReductionCreditInterface::class)->getName(),
'translation_domain'=> 'lcshop'
]);
}
}

+ 43
- 0
ShopBundle/Form/Backend/Order/DeleteOrderPaymentType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DeleteOrderPaymentType extends AbstractType
{
protected $em ;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id', HiddenType::class)
->add('delete', ButtonType::class);

/* ->add('id', HiddenType::class);*/
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderReductionCartInterface::class)->getName(),
]);*/
}
}

+ 43
- 0
ShopBundle/Form/Backend/Order/DeleteOrderReductionCartType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DeleteOrderReductionCartType extends AbstractType
{
protected $em ;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id', HiddenType::class)
->add('delete', ButtonType::class);

/* ->add('id', HiddenType::class);*/
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderReductionCartInterface::class)->getName(),
]);*/
}
}

+ 43
- 0
ShopBundle/Form/Backend/Order/DeleteOrderReductionCreditType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DeleteOrderReductionCreditType extends AbstractType
{
protected $em ;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id', HiddenType::class)
->add('delete', ButtonType::class);

/* ->add('id', HiddenType::class);*/
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderReductionCartInterface::class)->getName(),
]);*/
}
}

ShopBundle/Form/Order/OrderDeliveryAddressType.php → ShopBundle/Form/Backend/Order/OrderDeliveryAddressType.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Form\Order;
namespace Lc\ShopBundle\Form\Backend\Order;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;

ShopBundle/Form/Order/OrderInvoiceAddressType.php → ShopBundle/Form/Backend/Order/OrderInvoiceAddressType.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Form\Order;
namespace Lc\ShopBundle\Form\Backend\Order;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
@@ -40,8 +40,8 @@ class OrderInvoiceAddressType extends AbstractType
->setParameter('user', $entity->getUser());
},
))
->add('saveInvoiceAddress', ButtonType::class, array(
'label' => 'field.OrderShop.saveInvoiceAddress'
->add('save', ButtonType::class, array(
'label' => 'action.save'
));

}
@@ -54,4 +54,4 @@ class OrderInvoiceAddressType extends AbstractType

]);
}
}
}

+ 73
- 0
ShopBundle/Form/Backend/Order/OrderPaymentType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;


use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Model\OrderPayment;
use Lc\ShopBundle\Services\Utils;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class OrderPaymentType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id', HiddenType::class, array(
'mapped'=>false,
))
->add('meanPayment', ChoiceType::class, array(
'choices' => array(
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_CHEQUE => Utils::MEAN_PAYMENT_CHEQUE,
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_CREDIT_CARD => Utils::MEAN_PAYMENT_CREDIT_CARD,
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_CREDIT => Utils::MEAN_PAYMENT_CREDIT,
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_TRANSFER => Utils::MEAN_PAYMENT_TRANSFER,
'field.default.meanPaymentOptions.' . Utils::MEAN_PAYMENT_CASH => Utils::MEAN_PAYMENT_CASH
),
'required' => true
))
->add('paidAt', DateType::class, array(
'widget' => 'single_text',
'required' => true
))
->add('amount', MoneyType::class, array(
))
->add('reference', TextType::class, array(
'required' => false
))
->add('comment', TextareaType::class, array(
'required' => false
))
->add('add', ButtonType::class, array(
'label' => 'action.add'
));


}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderPaymentInterface::class)->getName(),
'translation_domain' => 'lcshop'
]);
}
}

ShopBundle/Form/Order/OrderProductType.php → ShopBundle/Form/Backend/Order/OrderProductType.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Form\Order;
namespace Lc\ShopBundle\Form\Backend\Order;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;

+ 44
- 0
ShopBundle/Form/Backend/Order/OrderProductsActionType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

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

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

public function buildForm(FormBuilderInterface $builder, array $options)
{

$builder->add('orderProducts', CollectionType::class, array(
'label' => false,
'mapped'=>false,
'entry_type' => CheckboxType::class,
'entry_options' => ['label' => false],
'allow_add' => true,
'allow_delete' => true
)
);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
]);
}
}

ShopBundle/Form/Order/OrderProductsType.php → ShopBundle/Form/Backend/Order/OrderProductsType.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Form\Order;
namespace Lc\ShopBundle\Form\Backend\Order;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;

+ 50
- 0
ShopBundle/Form/Backend/Order/OrderSendPaymentLink.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;


use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Model\OrderPayment;
use Lc\ShopBundle\Services\Utils;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class OrderSendPaymentLink extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder

->add('send', ButtonType::class, array(
'label' => 'action.send'
));


}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(),
'translation_domain' => 'lcshop'
]);
}
}

+ 57
- 0
ShopBundle/Form/Backend/Order/OrderStatusType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Order;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Lc\ShopBundle\Context\AddressInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderStatusInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\UserInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class OrderStatusType extends AbstractType
{
protected $em;
protected $orderUtils;

public function __construct(EntityManagerInterface $em, OrderUtilsInterface $orderUtils)
{
$this->em = $em;
$this->orderUtils = $orderUtils;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$entity = $options['data'];
$orderStatusClass = $this->em->getClassMetadata(OrderStatusInterface::class);
$builder->add('orderStatus', EntityType::class, array(
'class'=> $orderStatusClass->name,
'choices'=> $entity->getOrderStatus()->getNextStatusAllowed(),
'required' => false,
'mapped'=>false
))

->add('change', SubmitType::class, array(
'label' => 'action.change'
));

}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(OrderShopInterface::class)->getName(),
'translation_domain'=> 'lcshop'
]);
}
}

ShopBundle/Form/ProductFamilyCategoriesType.php → ShopBundle/Form/Backend/ProductFamily/ProductFamilyCategoriesType.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Form;
namespace Lc\ShopBundle\Form\Backend\ProductFamily;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;

ShopBundle/Form/ProductType.php → ShopBundle/Form/Backend/ProductFamily/ProductType.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Form;
namespace Lc\ShopBundle\Form\Backend\ProductFamily;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\ProductInterface;
@@ -120,6 +120,12 @@ class ProductType extends AbstractType
));

$builder->add('position', HiddenType::class);
$builder->add('exportTitle', TextType::class, array(
'required' =>false
));
$builder->add('exportNote', TextType::class, array(
'required' =>false
));

}


+ 57
- 0
ShopBundle/Form/Backend/ReductionCart/AppliedToType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCart;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\PointSaleInterface;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Model\ReductionCart;
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\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class AppliedToType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$class = $this->em->getClassMetadata(PointSaleInterface::class);

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

$builder->add('appliedTo', ChoiceType::class, array(
'label' => 'field.Reduction.pointSalesActive',
'choices' => array(
'field.ReductionCart.appliedToOptions.' . ReductionCart::APPLIED_TO_ORDER_PRODUCTS => ReductionCart::APPLIED_TO_ORDER_PRODUCTS,
//'field.ReductionCart.appliedToOptions.' . ReductionCart::APPLIED_TO_DELIVERY => ReductionCart::APPLIED_TO_DELIVERY
),
'translation_domain' => 'lcshop',
'multiple' => false,
'expanded' => false
));

});
}

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

+ 58
- 0
ShopBundle/Form/Backend/ReductionCart/PointSalesFilterType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCart;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\PointSaleInterface;
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 PointSalesFilterType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$class = $this->em->getClassMetadata(PointSaleInterface::class);

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

$builder->add('pointSalesActive', CheckboxType::class, array(
'label' => 'field.Reduction.pointSalesActive',
'mapped' => false,
'translation_domain'=>'lcshop',
'required'=>false,
'attr' => ['class' => 'big']
));
$builder->add('pointSales', EntityType::class, [
'class' => $class->name,
'required' => false,
'expanded' => false,
'multiple' => true,
'translation_domain'=>'lcshop'
]);
});
}

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

+ 57
- 0
ShopBundle/Form/Backend/ReductionCart/UncombinableTypesType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCart;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\ReductionCartInterface;
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\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class UncombinableTypesType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$reductionCartRepo = $this->em->getRepository(ReductionCartInterface::class);
$types = array();
foreach ($reductionCartRepo->getValuesOfFieldType() as $type){
$types['field.ReductionCart.typeOptions.'.$type['type']] = $type['type'];
}


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

$builder->add('uncombinableTypes', ChoiceType::class, [
'choices'=> $types,
'translation_domain'=> 'lcshop',
'required' => false,
'expanded' => false,
'multiple' => true
]);
});
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
]);*/
}
}

+ 53
- 0
ShopBundle/Form/Backend/ReductionCart/UncombinablesType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCart;

use Doctrine\ORM\EntityManagerInterface;

use Doctrine\ORM\EntityRepository;
use Lc\ShopBundle\Context\ReductionCartInterface;
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 UncombinablesType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$reductionCartClass = $this->em->getClassMetadata(ReductionCartInterface::class);

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

$builder->add('uncombinables', EntityType::class, array(
'class' => $reductionCartClass->name,
'required' => false,
'multiple'=>true,
'choice_attr' => function ($choice, $key, $value) {
return ['data-type' => $choice->getType()];
}
));
});
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
]);*/
}
}

+ 55
- 0
ShopBundle/Form/Backend/ReductionCatalog/ProductCategoriesFilterType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCatalog;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\ProductCategoryInterface;
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 ProductCategoriesFilterType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$class = $this->em->getClassMetadata(ProductCategoryInterface::class);

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

$builder->add('productCategoriesActive', CheckboxType::class, array(
'label' => 'field.Reduction.productCategoriesActive',
'translation_domain'=>'lcshop',
'mapped' => false,
'required'=>false,
'attr' => ['class' => 'big']
));
$builder->add('productCategories', EntityType::class, [
'class' => $class->name,
'required' => false,
'expanded' => false,
'multiple' => true,
'translation_domain'=>'lcshop',
]);
});
}

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

+ 46
- 0
ShopBundle/Form/Backend/ReductionCommon/BehaviorTaxRateType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCommon;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\ReductionCartInterface;
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\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class BehaviorTaxRateType extends AbstractType
{

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$builder = $event->getForm()->getParent();

$builder->add('behaviorTaxRate', ChoiceType::class, [
'translation_domain' => 'lcshop',
'required' => false,
'empty_data' => 'tax-included',
'choices' => [
'field.default.taxIncluded' => 'tax-included',
'field.default.taxExcluded' => 'tax-excluded'
]
]);
});
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
]);*/
}
}

+ 42
- 0
ShopBundle/Form/Backend/ReductionCommon/DateEndType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCommon;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\ReductionCartInterface;
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\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DateEndType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$builder = $event->getForm()->getParent();

$builder->add('dateEnd', DateTimeType::class, array(
'widget' => 'single_text',
'required' => false,
));

});
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
]);*/
}
}

+ 42
- 0
ShopBundle/Form/Backend/ReductionCommon/DateStartType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCommon;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\ReductionCartInterface;
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\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class DateStartType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$builder = $event->getForm()->getParent();

$builder->add('dateStart', DateTimeType::class, array(
'widget' => 'single_text',
'required' => false,
));

});
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
]);*/
}
}

+ 58
- 0
ShopBundle/Form/Backend/ReductionCommon/GroupUsersFilterType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCommon;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\GroupUserInterface;
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 GroupUsersFilterType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$class = $this->em->getClassMetadata(GroupUserInterface::class);

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

$builder->add('groupUsersActive', CheckboxType::class, array(
'label' => 'field.Reduction.groupUsersActive',
'mapped' => false,
'required'=>false,
'translation_domain'=>'lcshop',
'attr' => ['class' => 'big']
));
$builder->add('groupUsers', EntityType::class, [
'class' => $class->name,
'required' => false,
'expanded' => false,
'multiple' => true,
'translation_domain'=>'lcshop',
]);
});
}

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

+ 45
- 0
ShopBundle/Form/Backend/ReductionCommon/PermanentType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCommon;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\ReductionCartInterface;
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\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class PermanentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$builder = $event->getForm()->getParent();

$builder->add('permanent', CheckboxType::class, array(
'required' => false,
'translation_domain' => 'lcshop',
'label' => 'field.ReductionCatalog.permanent',
'label_attr' => [
'class' => 'big'
]
));

});
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
]);*/
}
}

+ 47
- 0
ShopBundle/Form/Backend/ReductionCommon/UnitType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCommon;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\ReductionCartInterface;
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\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class UnitType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{

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

$builder->add('unit', ChoiceType::class, [
'required' => true,
'translation_domain'=>'lcshop',
'expanded'=>true,
'data'=> isset($options['data']) ? $options['data'] : '',
'choices' => [
'field.default.percent' => 'percent',
'field.default.amount' => 'amount'
]
]);
});
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
]);*/
}
}

+ 65
- 0
ShopBundle/Form/Backend/ReductionCommon/UsersFilterType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCommon;

use Doctrine\ORM\EntityManagerInterface;

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 UsersFilterType 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) {
$builder = $event->getForm()->getParent();

$builder->add('usersActive', CheckboxType::class, array(
'label' => 'field.Reduction.usersActive',
'mapped' => false,
'translation_domain'=>'lcshop',

'required'=>false,
'attr' => ['class' => 'big']
));
$builder->add('users', EntityType::class, [
'class' => $userClass->name,
'required' => false,
'expanded' => false,
'multiple' => true,
'translation_domain'=>'lcshop',
'choice_attr' => function ($choice, $key, $value) {
$data = array();
foreach ($choice->getGroupUsers() as $groupUser) {
$data[] = '_'.$groupUser->getId().'_';
}
return ['data-group-users' => json_encode($data)];
}
]);
});
}

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

+ 40
- 0
ShopBundle/Form/Backend/ReductionCommon/ValueType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\ReductionCommon;

use Doctrine\ORM\EntityManagerInterface;

use Lc\ShopBundle\Context\ReductionCartInterface;
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\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ValueType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$builder = $event->getForm()->getParent();

$builder->add('value', NumberType::class, [
'required' => false
]);
});
}

public function configureOptions(OptionsResolver $resolver)
{
/*$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
]);*/
}
}

+ 65
- 0
ShopBundle/Form/Backend/Ticket/TicketMessageType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Ticket;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\CreditHistoryInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Context\TicketMessageInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Lc\ShopBundle\Model\CreditHistory;
use Lc\ShopBundle\Services\Utils;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TicketMessageType extends AbstractType
{
protected $em;


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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('message', TextareaType::class, array(
'required' => true
))
->add('add', SubmitType::class, array(
'label' => 'action.send',
'attr'=>array(
'class' => 'btn btn-primary float-right'
)
));


}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(TicketMessageInterface::class)->getName(),
'translation_domain' => 'lcshop'
]);
}
}

+ 66
- 0
ShopBundle/Form/Backend/Ticket/TicketStatusType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\Ticket;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\CreditHistoryInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Context\TicketInterface;
use Lc\ShopBundle\Context\TicketMessageInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Lc\ShopBundle\Model\CreditHistory;
use Lc\ShopBundle\Model\Ticket;
use Lc\ShopBundle\Services\Utils;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TicketStatusType extends AbstractType
{
protected $em;


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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('status', ChoiceType::class, array(
'choices'=>array(
'field.Ticket.statusOptions.'.Ticket::TICKET_STATUS_OPEN => Ticket::TICKET_STATUS_OPEN,
'field.Ticket.statusOptions.'.Ticket::TICKET_STATUS_BEING_PROCESSED => Ticket::TICKET_STATUS_BEING_PROCESSED,
'field.Ticket.statusOptions.'.Ticket::TICKET_STATUS_CLOSED => Ticket::TICKET_STATUS_CLOSED,
),
'required'=>true,
'expanded'=>true
));

}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(TicketInterface::class)->getName(),
'translation_domain' => 'lcshop'
]);
}
}

+ 87
- 0
ShopBundle/Form/Backend/UserMerchant/CreditHistoryType.php 查看文件

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

namespace Lc\ShopBundle\Form\Backend\UserMerchant;

use App\Entity\Product;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\CreditHistoryInterface;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderReductionCartInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ReductionCartInterface;
use Lc\ShopBundle\Context\ReductionCreditInterface;
use Lc\ShopBundle\Form\DataTransformer\ProductToIdTransformer;
use Lc\ShopBundle\Model\CreditHistory;
use Lc\ShopBundle\Services\Utils;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class CreditHistoryType extends AbstractType
{
protected $em;


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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('type', ChoiceType::class, array(
'choices' => array(
'field.CreditHistory.typeOptions.'.CreditHistory::TYPE_CREDIT => CreditHistory::TYPE_CREDIT,
'field.CreditHistory.typeOptions.'.CreditHistory::TYPE_DEBIT => CreditHistory::TYPE_DEBIT
),
'required' => true
))
->add('amount', MoneyType::class)
->add('meanPayment', ChoiceType::class, array(
'choices' => array(
'field.default.meanPaymentOptions.'.Utils::MEAN_PAYMENT_CASH => Utils::MEAN_PAYMENT_CASH,
'field.default.meanPaymentOptions.'.Utils::MEAN_PAYMENT_CHEQUE => Utils::MEAN_PAYMENT_CHEQUE,
'field.default.meanPaymentOptions.'.Utils::MEAN_PAYMENT_CREDIT => Utils::MEAN_PAYMENT_CREDIT,
'field.default.meanPaymentOptions.'.Utils::MEAN_PAYMENT_CREDIT_CARD => Utils::MEAN_PAYMENT_CREDIT_CARD,
'field.default.meanPaymentOptions.'.Utils::MEAN_PAYMENT_TRANSFER => Utils::MEAN_PAYMENT_TRANSFER
),
'required' => true
))
->add('paidAt', DateType::class, array(
'widget' => 'single_text',
'required' => true
))
->add('reference', TextType::class, array(
'required'=>false
))

->add('comment', TextareaType::class, array(
'required'=>false
))
->add('add', SubmitType::class, array(
'label' => 'action.add'
));


}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(CreditHistoryInterface::class)->getName(),
'translation_domain'=>'lcshop'
]);
}
}

+ 0
- 40
ShopBundle/Form/CreditConfigType.php 查看文件

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

namespace Lc\ShopBundle\Form;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\CreditConfigInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class CreditConfigType extends AbstractType
{
protected $em;

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

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('active', CheckboxType::class, [
'label' => 'Activé'
])
->add('limitAmount')
->add('limitReminder')
->add('behavior')
->add('processOrderCheckedDefault');
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => $this->em->getClassMetadata(CreditConfigInterface::class)->getName(),
]);
}
}

+ 64
- 0
ShopBundle/Form/Frontend/CookieConsentTypeExtension.php 查看文件

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

namespace Lc\ShopBundle\Form\Frontend;

use ConnectHolland\CookieConsentBundle\Cookie\CookieChecker;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use ConnectHolland\CookieConsentBundle\Form\CookieConsentType as BaseCookieConsentType ;

class CookieConsentTypeExtension extends AbstractTypeExtension
{
/**
* @var CookieChecker
*/
protected $cookieChecker;

/**
* @var array
*/
protected $cookieCategories;

/**
* @var bool
*/
protected $cookieConsentSimplified;

public function __construct(CookieChecker $cookieChecker, array $cookieCategories = [], bool $cookieConsentSimplified = false)
{
$this->cookieChecker = $cookieChecker;
$this->cookieCategories = $cookieCategories;
$this->cookieConsentSimplified = $cookieConsentSimplified;
}

public function buildForm(FormBuilderInterface $builder, array $options): void
{
foreach ($this->cookieCategories as $category) {
$builder->remove($category) ;

$data = 'true' ;
if($this->cookieChecker->isCookieConsentSavedByUser() && !$this->cookieChecker->isCategoryAllowedByUser($category)) {
$data = 'false' ;
}

$builder->add($category, ChoiceType::class, [
'expanded' => true,
'multiple' => false,
'data' => $data,
'choices' => [
['ch_cookie_consent.yes' => 'true'],
['ch_cookie_consent.no' => 'false'],
],
]);
}
}

public static function getExtendedTypes(): iterable
{
return [BaseCookieConsentType::class];
}
}

+ 26
- 0
ShopBundle/Form/Frontend/ReductionCartType.php 查看文件

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

namespace Lc\ShopBundle\Form\Frontend;

use Lc\ShopBundle\Validator\Constraints\UniqueEmailValidator;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ReductionCartType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('code', TextType::class, [
'label' => 'Bon de réduction :'
]);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([

]);
}
}

ShopBundle/Form/RegistrationType.php → ShopBundle/Form/Frontend/RegistrationType.php 查看文件

@@ -1,6 +1,6 @@
<?php

namespace Lc\ShopBundle\Form;
namespace Lc\ShopBundle\Form\Frontend;

use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType;
use Symfony\Component\Form\AbstractType;
@@ -37,6 +37,10 @@ class RegistrationType extends AbstractType
'label' => 'field.default.lastname',
'translation_domain' => 'lcshop',
])
->add('phone', TextType::class, [
'label' => 'field.default.phone',
'translation_domain' => 'lcshop',
])
->add('subscribeNewsletter', CheckboxType::class, [
'label' => 'field.default.subscribeNewsletter',
'required' => false,

+ 44
- 0
ShopBundle/Form/Frontend/TicketMessageType.php 查看文件

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

namespace Lc\ShopBundle\Form\Frontend;

use App\Entity\Address;
use App\Entity\OrderShop;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Model\Ticket;
use Lc\ShopBundle\Services\UtilsManager;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;

class TicketMessageType extends AbstractType
{

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('message', TextareaType::class, [
'label' => 'field.Ticket.yourAnswer',
'translation_domain' => 'lcshop',
])
->add('closeTicket', CheckboxType::class, [
'label' => 'field.Ticket.closeTicket',
'translation_domain' => 'lcshop',
'required' => false,
]);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}

+ 99
- 0
ShopBundle/Form/Frontend/TicketType.php 查看文件

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

namespace Lc\ShopBundle\Form\Frontend;

use App\Entity\Address;
use App\Entity\OrderShop;
use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Model\Ticket;
use Lc\ShopBundle\Services\UtilsManager;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;

class TicketType extends AbstractType
{
protected $orderShopRepository ;
protected $security ;
protected $em ;
protected $priceUtils ;

public function __construct(Security $security, EntityManagerInterface $em, UtilsManager $utilsManager)
{
$this->security = $security ;
$this->em = $em ;
$this->orderShopRepository = $this->em->getRepository(OrderShop::class) ;
$this->priceUtils = $utilsManager->getPriceUtils() ;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$isConnected = $this->security->getUser() ;

if(!$isConnected) {
$builder->add('visitorFirstname', TextType::class, [
'label' => 'Prénom'
])
->add('visitorLastname', TextType::class, [
'label' => 'Nom'
])
->add('visitorEmail', EmailType::class, [
'label' => 'Email'
]) ;
}

$builder
->add('type', ChoiceType::class, [
'label' => 'field.Ticket.type',
'multiple' => false,
'expanded' => false,
'choices' => [
'field.Ticket.typeOptions.'.Ticket::TYPE_GENERAL_QUESTION => Ticket::TYPE_GENERAL_QUESTION,
'field.Ticket.typeOptions.'.Ticket::TYPE_PRODUCT_UNAVAILABLE => Ticket::TYPE_PRODUCT_UNAVAILABLE,
'field.Ticket.typeOptions.'.Ticket::TYPE_PRODUCT_ERROR => Ticket::TYPE_PRODUCT_ERROR,
'field.Ticket.typeOptions.'.Ticket::TYPE_TECHNICAL_PROBLEM => Ticket::TYPE_TECHNICAL_PROBLEM,
],
'translation_domain' => 'lcshop',
]) ;


if($isConnected) {
$builder->add('orderShop', EntityType::class, [
'class' => $this->em->getClassMetadata(OrderShop::class)->getName(),
'multiple' => false,
'expanded' => false,
'choices' => $this->orderShopRepository->findAllBy([
'user' => $this->security->getUser(),
'isValid' => true
]),
'label' => 'field.default.order',
'placeholder' => '-- Choisissez une commande --',
'required' => false,
'choice_label' => function ($orderShop, $key, $value) {
return 'Commande du '.$orderShop->getValidationDate()->format('d/m/Y').' ('.number_format($this->priceUtils->getTotalWithTax($orderShop), 2).' €)' ;
},
'translation_domain' => 'lcshop',
]) ;
}

$builder->add('subject', TextType::class, [
'label' => 'Sujet'
])
->add('message', TextareaType::class, [
'label' => 'Message'
]);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
// Configure your form options here
]);
}
}

+ 0
- 142
ShopBundle/Form/ReductionCatalogType.php 查看文件

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

namespace Lc\ShopBundle\Form;

use App\Entity\Supplier;
use Lc\ShopBundle\Context\GroupUserInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\UserInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;


class ReductionCatalogType 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);
$groupUserClass = $this->em->getClassMetadata(GroupUserInterface::class);
$supplierClass = Supplier::class;
$productFamilyClass = $this->em->getClassMetadata(ProductFamilyInterface::class);
$productCategoryClass = $this->em->getClassMetadata(ProductCategoryInterface::class);


$builder
->add('title', TextType::class, [
'label' => 'Titre',
'required' => false,
])
->add('behaviorTaxRate', ChoiceType::class, [
'required' => false,
'choices' => [
'field.default.taxIncluded' => 'tax-included',
'field.default.taxExcluded' => 'tax-excluded'
]
])
->add('unit', ChoiceType::class, [
'required' => false,
'choices' => [
'field.default.percent' => 'percent',
'field.default.amount' => 'amount'
]
])
->add('value', NumberType::class, [
'required' => false
])
->add('permanent', CheckboxType::class, array(
'required'=>false
))
->add('dateStart', DateTimeType::class,
['widget' => 'single_text',
'required'=>false,
])
->add('dateEnd', DateTimeType::class, [
'widget' => 'single_text',
'required'=>false,
])
->add('usersActive', CheckboxType::class, array(
'label' => 'field.ReductionCatalog.usersActive',
'mapped' => false,
'required'=>false,
'attr' => ['class' => 'big']
))
->add('users', EntityType::class, array(
'class' => $userClass->name,
'required'=>false,
'multiple'=>true
))
->add('groupUsersActive', CheckboxType::class, array(
'label' => 'field.ReductionCatalog.groupUsersActive',
'mapped' => false,
'required'=>false,
'attr' => ['class' => 'big']
))
->add('groupUsers', EntityType::class, array(
'class' => $groupUserClass->name,
'required'=>false,
'multiple'=>true

));
/* ->add('productFamiliesActive', CheckboxType::class, array(
'label' => 'field.ReductionCatalog.productFamiliesActive',
'mapped' => false,
'required'=>false,
'attr' => ['class' => 'big']
))
->add('productFamilies', EntityType::class, array(
'class' => $productFamilyClass->name,
'required'=>false,
'multiple'=>true
))
->add('productCategoriesActive', CheckboxType::class, array(
'label' => 'field.ReductionCatalog.productCategoriesActive',
'mapped' => false,
'required'=>false,
'attr' => ['class' => 'big']
))
->add('productCategories', EntityType::class, array(
'class' => $productCategoryClass->name,
'required'=>false,
'multiple'=>true
))
->add('suppliersActive', CheckboxType::class, array(
'label' => 'field.ReductionCatalog.suppliersActive',
'mapped' => false,
'required'=>false,
'attr' => ['class' => 'big']
))
->add('suppliers', EntityType::class, array(
'class' => $supplierClass,
'required'=>false,
'multiple'=>true
));*/

}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'label' => false,
//'data_class' => $this->em->getClassMetadata(ReductionCatalogInterface::class)->getName(),
'translation_domain'=> 'lcshop'
]);
}
}

+ 8
- 3
ShopBundle/Model/AbstractDocumentEntity.php 查看文件

@@ -4,6 +4,7 @@ namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\ShopBundle\Context\SeoInterface;
use Lc\ShopBundle\Context\SluggableInterface;
use Lc\ShopBundle\Context\SortableInterface;
use Lc\ShopBundle\Context\StatusInterface;
@@ -14,7 +15,7 @@ use Vich\UploaderBundle\Mapping\Annotation as Vich;
* @ORM\MappedSuperclass
* @Vich\Uploadable
*/
abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface, SluggableInterface
abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface, SluggableInterface, SeoInterface
{
use SortableTrait;

@@ -22,12 +23,13 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn

use SluggableTrait;

use SeoTrait;

/**
* @ORM\Column(type="string", length=255)
*/
protected $title;


/**
* @ORM\Column(type="text", nullable=true)
*/
@@ -50,6 +52,8 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn
protected $devAlias;




public function setImageFile(File $image = null)
{
$this->imageFile = $image;
@@ -67,6 +71,7 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn
{
return $this->imageFile;
}

public function getTitle(): ?string
{
return $this->title;
@@ -80,7 +85,6 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn
}



public function getDescription(): ?string
{
return $this->description;
@@ -93,6 +97,7 @@ abstract class AbstractDocumentEntity extends AbstractEntity implements StatusIn
return $this;
}


public function getImage(): ?string
{
return $this->image;

+ 1
- 0
ShopBundle/Model/AbstractEntity.php 查看文件

@@ -38,6 +38,7 @@ abstract class AbstractEntity
*/
protected $updatedBy;


public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;

+ 17
- 6
ShopBundle/Model/Address.php 查看文件

@@ -9,6 +9,10 @@ use Doctrine\ORM\Mapping as ORM;
*/
abstract class Address extends AbstractEntity
{

const TYPE_INDIVIDUAL = 'individual';
const TYPE_LEGAL_PERSON = 'legal-person';

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="addresses")
* @ORM\JoinColumn(nullable=true)
@@ -76,7 +80,7 @@ abstract class Address extends AbstractEntity
protected $tva;

/**
* @ORM\Column(type="string", length=127, nullable=true)
* @ORM\Column(type="array", nullable=true)
*/
protected $phone;

@@ -100,6 +104,11 @@ abstract class Address extends AbstractEntity
*/
protected $deliveryInfos;

public function __construct()
{
$this->phone = [] ;
}

public function __toString()
{
return $this->getTitle() . ' - ' . $this->getZip() . ' ' . $this->getCity();
@@ -110,11 +119,11 @@ abstract class Address extends AbstractEntity
return $this->getAddress() . ' - ' . $this->getZip() . ' ' . $this->getCity();
}

public function getSummary()
public function getSummary($withTitle = true)
{
$html = '';

if ($this->getTitle()) {
if ($this->getTitle() && $withTitle) {
$html .= $this->getTitle() . '<br />';
}

@@ -131,7 +140,9 @@ abstract class Address extends AbstractEntity
}

if ($this->getPhone()) {
$html .= 'Tél. ' . $this->getPhone();
foreach($this->getPhone() as $phone) {
$html .= 'Tél. ' . $phone.'<br />';
}
}

return $html;
@@ -293,12 +304,12 @@ abstract class Address extends AbstractEntity
return $this;
}

public function getPhone(): ?string
public function getPhone(): ?array
{
return $this->phone;
}

public function setPhone(?string $phone): self
public function setPhone(?array $phone): self
{
$this->phone = $phone;


+ 0
- 64
ShopBundle/Model/Cart.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\MappedSuperclass()
*/
abstract class Cart extends AbstractEntity
{
/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\VisitorInterface", inversedBy="cart", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
protected $visitor;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="carts")
*/
protected $user;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
*/
protected $address;


public function getVisitor(): ?Visitor
{
return $this->visitor;
}

public function setVisitor(Visitor $visitor): self
{
$this->visitor = $visitor;

return $this;
}

public function getUser(): ?User
{
return $this->user;
}

public function setUser(?User $user): self
{
$this->user = $user;

return $this;
}

public function getAddress(): ?Address
{
return $this->address;
}

public function setAddress(?Address $address): self
{
$this->address = $address;

return $this;
}
}

+ 0
- 135
ShopBundle/Model/CartProduct.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\MappedSuperclass()
*/
abstract class CartProduct extends AbstractEntity
{

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\CartInterface", inversedBy="cartProducts")
* @ORM\JoinColumn(nullable=false)
*/
protected $cart;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ProductInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $product;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $taxRate;

/**
* @ORM\Column(type="float")
*/
protected $price;

/**
* @ORM\Column(type="string", length=31)
*/
protected $unit;

/**
* @ORM\Column(type="float")
*/
protected $quantity;

/**
* @ORM\Column(type="string", length=255)
*/
protected $title;


public function getCart(): ?Cart
{
return $this->cart;
}

public function setCart(?Cart $cart): self
{
$this->cart = $cart;

return $this;
}

public function getProduct(): ?Product
{
return $this->product;
}

public function setProduct(?Product $product): self
{
$this->product = $product;

return $this;
}

public function getTaxRate(): ?TaxRate
{
return $this->taxRate;
}

public function setTaxRate(?TaxRate $taxRate): self
{
$this->taxRate = $taxRate;

return $this;
}

public function getPrice(): ?float
{
return $this->price;
}

public function setPrice(float $price): self
{
$this->price = $price;

return $this;
}

public function getUnit(): ?string
{
return $this->unit;
}

public function setUnit(string $unit): self
{
$this->unit = $unit;

return $this;
}

public function getQuantity(): ?float
{
return $this->quantity;
}

public function setQuantity(float $quantity): self
{
$this->quantity = $quantity;

return $this;
}

public function getTitle(): ?string
{
return $this->title;
}

public function setTitle(string $title): self
{
$this->title = $title;

return $this;
}
}

+ 82
- 46
ShopBundle/Model/CreditHistory.php 查看文件

@@ -2,28 +2,27 @@

namespace Lc\ShopBundle\Model;

use App\Entity\OrderShop;
use App\Entity\OrderPayment;
use App\Entity\OrderRefund;
use App\Entity\UserMerchant;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\OrderRefundInterface;
use Lc\ShopBundle\Context\PayoffInterface;
use Lc\ShopBundle\Context\UserMerchantInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class CreditHistory extends AbstractEntity
abstract class CreditHistory extends AbstractEntity implements PayoffInterface
{
/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;
use PayoffTrait;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="creditHistories")
* @ORM\JoinColumn(nullable=false)
*/
protected $user;
const TYPE_CREDIT = 'credit';
const TYPE_DEBIT = 'debit';

/**
* @ORM\Column(type="float")
* @ORM\Column(type="float", nullable=true)
*/
protected $amount;

@@ -33,55 +32,92 @@ abstract class CreditHistory extends AbstractEntity
protected $type;

/**
* @ORM\Column(type="string", length=31)
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserMerchantInterface", inversedBy="creditHistories")
* @ORM\JoinColumn(nullable=false)
*/
protected $meanPayment;
protected $userMerchant;

/**
* @ORM\Column(type="text", nullable=true)
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderPaymentInterface", cascade={"persist", "remove"})
*/
protected $comment;
protected $orderPayment;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="creditHistories")
* @ORM\JoinColumn(nullable=false)
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", cascade={"persist", "remove"})
*/
protected $orderShop;
protected $orderRefund;

public function getMerchant(): ?Merchant

public function getAmount(): ?float
{
return $this->merchant;
return $this->amount;
}

public function setMerchant(?Merchant $merchant): self
public function setAmount(?float $amount): self
{
$this->merchant = $merchant;
$this->amount = $amount;

return $this;
}

public function getUser(): ?User
public function getAmountInherited(): float
{
return $this->user;
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getAmount();
} else if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getAmount();
} else {
return $this->getAmount();
}
}

public function setUser(?User $user): self
public function getMeanPaymentInherited(): string
{
$this->user = $user;
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getMeanPayment();
} else if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getMeanPayment();
} else {
return $this->getMeanPayment();
}
}

return $this;
public function getPaidAtInherited (): ?\DateTimeInterface
{
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getPaidAt();
} else if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getPaidAt();
} else {
return $this->getPaidAt();
}
}

public function getAmount(): ?float
public function getReferenceInherited (): ?string
{
return $this->amount;
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getReference();
} else if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getReference();
} else {
return $this->getReference();
}
}

public function setAmount(float $amount): self
public function getCommentInherited (): ?string
{
$this->amount = $amount;
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getComment();
} else if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getComment();
} else {
return $this->getComment();
}
}

return $this;
public function getMeanPaymentInheritedLabel(): string
{
return 'field.default.meanPaymentOptions.'.$this->getMeanPaymentInherited() ;
}

public function getType(): ?string
@@ -96,38 +132,38 @@ abstract class CreditHistory extends AbstractEntity
return $this;
}

public function getMeanPayment(): ?string
public function getUserMerchant(): ?UserMerchantInterface
{
return $this->meanPayment;
return $this->userMerchant;
}

public function setMeanPayment(string $meanPayment): self
public function setUserMerchant(?UserMerchantInterface $userMerchant): self
{
$this->meanPayment = $meanPayment;
$this->userMerchant = $userMerchant;

return $this;
}

public function getComment(): ?string
public function getOrderPayment(): ?OrderPaymentInterface
{
return $this->comment;
return $this->orderPayment;
}

public function setComment(string $comment): self
public function setOrderPayment(?OrderPaymentInterface $orderPayment): self
{
$this->comment = $comment;
$this->orderPayment = $orderPayment;

return $this;
}

public function getOrderShop(): ?OrderShop
public function getOrderRefund(): ?OrderRefundInterface
{
return $this->orderShop;
return $this->orderRefund;
}

public function setOrderShop(?OrderShop $orderShop): self
public function setOrderRefund(?OrderRefundInterface $orderRefund): self
{
$this->orderShop = $orderShop;
$this->orderRefund = $orderRefund;

return $this;
}

+ 271
- 0
ShopBundle/Model/Document.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\FilterMerchantInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class Document extends AbstractDocumentEntity implements FilterMerchantInterface
{
const TYPE_INVOICE = 'invoice';
const TYPE_QUOTATION = 'quotation';
const TYPE_PURCHASE_ORDER = 'purchase-order';
const TYPE_DELIVERY_NOTE = 'delivery-note';

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchant;

/**
* @ORM\Column(type="string", length=64)
*/
protected $type;

/**
* @ORM\Column(type="string", length=128, nullable=true)
*/
protected $reference;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $logo;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $merchantAddress;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $buyerAddress;

/**
* @ORM\Column(type="text")
*/
protected $merchantAddressText;

/**
* @ORM\Column(type="text",nullable=true)
*/
protected $buyerAddressText;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $deliveryAddressText;

/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $isSent;

/**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents")
*/
protected $orderShops;

/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"})
*/
protected $orderRefund;

public function __construct()
{
$this->orderShops = new ArrayCollection();
}

public function __toString()
{
return $this->getReference();
}

public function getMerchant(): ?Merchant
{
return $this->merchant;
}

public function setMerchant(?Merchant $merchant): self
{
$this->merchant = $merchant;

return $this;
}

public function getLabel()
{
if ($this->getType() == self::TYPE_INVOICE) {
return 'Facture';
} elseif ($this->getType() == self::TYPE_QUOTATION) {
return 'Devis';
} elseif ($this->getType() == self::TYPE_PURCHASE_ORDER) {
return 'Bon de commande';
} elseif ($this->getType() == self::TYPE_DELIVERY_NOTE) {
return 'Bon de livraison';
}
}

public function getType(): ?string
{
return $this->type;
}

public function setType(string $type): self
{
$this->type = $type;

return $this;
}

public function getReference(): ?string
{
return $this->reference;
}

public function setReference(?string $reference): self
{
$this->reference = $reference;

return $this;
}

public function getLogo(): ?string
{
return $this->logo;
}

public function setLogo(string $logo): self
{
$this->logo = $logo;

return $this;
}

public function getMerchantAddress(): ?Address
{
return $this->merchantAddress;
}

public function setMerchantAddress(?Address $merchantAddress): self
{
$this->merchantAddress = $merchantAddress;

return $this;
}

public function getBuyerAddress(): ?Address
{
return $this->buyerAddress;
}

public function setBuyerAddress(?Address $buyerAddress): self
{
$this->buyerAddress = $buyerAddress;

return $this;
}

public function getMerchantAddressText(): ?string
{
return $this->merchantAddressText;
}

public function setMerchantAddressText(string $merchantAddressText): self
{
$this->merchantAddressText = $merchantAddressText;

return $this;
}

public function getBuyerAddressText(): ?string
{
return $this->buyerAddressText;
}

public function setBuyerAddressText(?string $buyerAddressText): self
{
$this->buyerAddressText = $buyerAddressText;

return $this;
}

public function getDeliveryAddressText(): ?string
{
return $this->deliveryAddressText;
}

public function setDeliveryAddressText(?string $deliveryAddressText): self
{
$this->deliveryAddressText = $deliveryAddressText;

return $this;
}

public function getIsSent(): ?bool
{
return $this->isSent;
}

public function setIsSent(?bool $isSent): self
{
$this->isSent = $isSent;

return $this;
}

/**
* @return Collection|OrderShop[]
*/
public function getOrderShops(): Collection
{
return $this->orderShops;
}

public function addOrderShop(OrderShop $orderShop): self
{
if (!$this->orderShops->contains($orderShop)) {
$this->orderShops[] = $orderShop;
$orderShop->addDocument($this);
}

return $this;
}

public function removeOrderShop(OrderShop $orderShop): self
{
if ($this->orderShops->contains($orderShop)) {
$this->orderShops->removeElement($orderShop);
$orderShop->removeDocument($this);
}

return $this;
}


public function getOrderRefund(): ?OrderRefund
{
return $this->orderRefund;
}

public function setOrderRefund(OrderRefund $orderRefund): self
{
$this->orderRefund = $orderRefund;

// set the owning side of the relation if necessary
if ($orderRefund->getDocument() !== $this) {
$orderRefund->setDocument($this);
}

return $this;
}
}

+ 0
- 55
ShopBundle/Model/DocumentDeliveryNote.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Lc\ShopBundle\Model\OrderShop;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\MappedSuperclass()
*/
abstract class DocumentDeliveryNote extends AbstractDocumentOrder
{
/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documentDeliveryNote")
*/
protected $orderShops;

public function __construct()
{
$this->orderShops = new ArrayCollection();
}

/**
* @return Collection|OrderShop[]
*/
public function getOrderShops(): Collection
{
return $this->orderShops;
}

public function addOrderShop(OrderShop $orderShop): self
{
if (!$this->orderShops->contains($orderShop)) {
$this->orderShops[] = $orderShop;
$orderShop->setDocumentDeliveryNote($this);
}

return $this;
}

public function removeOrderShop(OrderShop $orderShop): self
{
if ($this->orderShops->contains($orderShop)) {
$this->orderShops->removeElement($orderShop);
// set the owning side to null (unless already changed)
if ($orderShop->getDocumentDeliveryNote() === $this) {
$orderShop->setDocumentDeliveryNote(null);
}
}

return $this;
}
}

+ 0
- 56
ShopBundle/Model/DocumentInvoice.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Lc\ShopBundle\Model\OrderShop;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\MappedSuperclass()
*/
abstract class DocumentInvoice extends AbstractDocumentOrder
{
/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documentInvoice")
*/
protected $orderShops;

public function __construct()
{
$this->orderShops = new ArrayCollection();
}

/**
* @return Collection|OrderShop[]
*/
public function getOrderShops(): Collection
{
return $this->orderShops;
}

public function addOrderShop(OrderShop $orderShop): self
{
if (!$this->orderShops->contains($orderShop)) {
$this->orderShops[] = $orderShop;
$orderShop->setDocumentInvoice($this);
}

return $this;
}

public function removeOrderShop(OrderShop $orderShop): self
{
if ($this->orderShops->contains($orderShop)) {
$this->orderShops->removeElement($orderShop);
// set the owning side to null (unless already changed)
if ($orderShop->getDocumentInvoice() === $this) {
$orderShop->setDocumentInvoice(null);
}
}

return $this;
}

}

+ 0
- 73
ShopBundle/Model/DocumentQuotation.php 查看文件

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

namespace Lc\ShopBundle\Model;

use App\Entity\OrderShop;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\MappedSuperclass()
*/
abstract class DocumentQuotation extends AbstractDocumentOrder
{

/**
* @ORM\Column(type="integer", nullable=true)
*/
protected $duration;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documentQuotation")
*/
protected $orderShops;

public function __construct()
{
$this->orderShops = new ArrayCollection();
}

public function getDuration(): ?int
{
return $this->duration;
}

public function setDuration(?int $duration): self
{
$this->duration = $duration;

return $this;
}

/**
* @return Collection|OrderShop[]
*/
public function getOrderShops(): Collection
{
return $this->orderShops;
}

public function addOrderShop(OrderShop $orderShop): self
{
if (!$this->orderShops->contains($orderShop)) {
$this->orderShops[] = $orderShop;
$orderShop->setDocumentQuotation($this);
}

return $this;
}

public function removeOrderShop(OrderShop $orderShop): self
{
if ($this->orderShops->contains($orderShop)) {
$this->orderShops->removeElement($orderShop);
// set the owning side to null (unless already changed)
if ($orderShop->getDocumentQuotation() === $this) {
$orderShop->setDocumentQuotation(null);
}
}

return $this;
}
}

+ 1
- 1
ShopBundle/Model/OrderAmountMin.php 查看文件

@@ -23,4 +23,4 @@ trait OrderAmountMin
return $this;
}

}
}

+ 17
- 0
ShopBundle/Model/OrderPayment.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\OrderPayoffInterface;
use Lc\ShopBundle\Context\ReductionInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderPayment extends AbstractEntity implements OrderPayoffInterface
{
use OrderPayoffTrait;

}

+ 61
- 0
ShopBundle/Model/OrderPayoffTrait.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\ReductionInterface;

/**
* @ORM\MappedSuperclass()
*/
trait OrderPayoffTrait
{

use PayoffTrait;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderPayments")
* @ORM\JoinColumn(nullable=false)
*/
protected $orderShop;

/**
* @ORM\Column(type="boolean")
*/
protected $editable;

public function __toString()
{
return $this->amount. ' le '.$this->getPaidAt()->format('d-m-y').' par '.$this->getMeanPayment();
}

public function getOrderShop(): ?OrderShop
{
return $this->orderShop;
}

public function setOrderShop(?OrderShop $orderShop): self
{
$this->orderShop = $orderShop;

return $this;
}

public function setEditable(bool $editable): self
{
$this->editable = $editable;

return $this;
}

public function getEditable(): ?bool
{
return $this->editable;
}

public function isEditable(): ?bool
{
return $this->editable;
}
}

+ 22
- 1
ShopBundle/Model/OrderProduct.php 查看文件

@@ -20,7 +20,7 @@ abstract class OrderProduct implements PriceInterface
protected $orderShop;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ProductInterface", inversedBy="orderProducts"))
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ProductInterface"))
*/
protected $product;

@@ -44,6 +44,11 @@ abstract class OrderProduct implements PriceInterface
*/
protected $orderProductReductionCatalog;

/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderProductRefundInterface", mappedBy="orderProduct", cascade={"persist", "remove"})
*/
protected $orderProductRefund;

public function __toString()
{
if($this->getTitle()) {
@@ -177,5 +182,21 @@ abstract class OrderProduct implements PriceInterface

return $this;
}
public function getOrderProductRefund(): ?OrderProductRefund
{
return $this->orderProductRefund;
}

public function setOrderProductRefund(OrderProductRefund $orderProductRefund): self
{
$this->orderProductRefund = $orderProductRefund;

// set the owning side of the relation if necessary
if ($orderProductRefund->getOrderProduct() !== $this) {
$orderProductRefund->setOrderProduct($this);
}

return $this;
}

}

+ 87
- 0
ShopBundle/Model/OrderProductRefund.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;


/**
* @ORM\MappedSuperclass()
*/
abstract class OrderProductRefund
{
/**
* @ORM\Column(type="integer")
*/
protected $quantityRefund;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $title;

/**
* @ORM\Column(type="float")
*/
protected $price;

/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", inversedBy="orderProductRefund", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
protected $orderProduct;

public function getQuantityRefund(): ?int
{
return $this->quantityRefund;
}

public function setQuantityOrder(int $quantityRefund): self
{
$this->quantityRefund = $quantityRefund;

return $this;
}

public function getPrice(): ?float
{
return $this->getPrice() ;
}

public function setPrice(?float $price): self
{
$this->price = $price;

return $this;
}

public function getTitleInherited(): ?string
{
return $this->title;
}

public function getTitle(): ?string
{
return $this->title;
}

public function setTitle(string $title): self
{
$this->title = $title;

return $this;
}

public function getOrderProduct(): ?OrderProduct
{
return $this->orderProduct;
}

public function setOrderProduct(OrderProduct $orderProduct): self
{
$this->orderProduct = $orderProduct;

return $this;
}
}


+ 77
- 0
ShopBundle/Model/OrderReductionCart.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\ReductionCartPropertyInterface;
use Lc\ShopBundle\Context\ReductionInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderReductionCart implements ReductionInterface, ReductionCartPropertyInterface
{
use ReductionTrait;
use ReductionCartPropertyTrait;

/**
* @ORM\Column(type="string", length=255)
*/
protected $title;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderReductionCarts")
* @ORM\JoinColumn(nullable=false)
*/
protected $orderShop;


/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ReductionCartInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $reductionCart;

public function __toString()
{
return $this->title;
}

public function getTitle(): ?string
{
return $this->title;
}

public function setTitle(string $title): self
{
$this->title = $title;

return $this;
}

public function getOrderShop(): ?OrderShop
{
return $this->orderShop;
}

public function setOrderShop(?OrderShop $orderShop): self
{
$this->orderShop = $orderShop;

return $this;
}

public function getReductionCart(): ?ReductionCart
{
return $this->reductionCart;
}

public function setReductionCart(?ReductionCart $reductionCart): self
{
$this->reductionCart = $reductionCart;

return $this;
}


}

+ 73
- 0
ShopBundle/Model/OrderReductionCredit.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\ReductionInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderReductionCredit implements ReductionInterface
{
use ReductionTrait ;

/**
* @ORM\Column(type="string", length=255)
*/
protected $title;


/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderReductionCredits")
* @ORM\JoinColumn(nullable=false)
*/
protected $orderShop;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ReductionCreditInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $reductionCredit;

public function __toString()
{
return $this->title;
}

public function getTitle(): ?string
{
return $this->title;
}

public function setTitle(string $title): self
{
$this->title = $title;

return $this;
}

public function getOrderShop(): ?OrderShop
{
return $this->orderShop;
}

public function setOrderShop(?OrderShop $orderShop): self
{
$this->orderShop = $orderShop;

return $this;
}

public function getReductionCredit(): ?ReductionCredit
{
return $this->reductionCredit;
}

public function setReductionCredit(?ReductionCredit $reductionCredit): self
{
$this->reductionCredit = $reductionCredit;

return $this;
}
}

+ 52
- 0
ShopBundle/Model/OrderRefund.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\OrderPayoffInterface;
use Lc\ShopBundle\Context\ReductionInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderRefund extends AbstractEntity implements OrderPayoffInterface
{
use OrderPayoffTrait;

/**
* @ORM\Column(type="float", nullable=true)
*/
protected $deliveryRefundAmount;

/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\DocumentInterface", inversedBy="orderRefund", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
protected $document;

public function getDeliveryRefundAmount(): ?float
{
return $this->deliveryRefundAmount;
}

public function setDeliveryRefundAmount(?float $deliveryRefundAmount): self
{
$this->deliveryRefundAmount = $deliveryRefundAmount;

return $this;
}

public function getDocument(): ?Document
{
return $this->document;
}

public function setDocument(Document $document): self
{
$this->document = $document;

return $this;
}
}


+ 264
- 43
ShopBundle/Model/OrderShop.php 查看文件

@@ -2,10 +2,12 @@

namespace Lc\ShopBundle\Model;

use App\Entity\Visitor;
use App\Entity\OrderStatus;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\DocumentInterface;
use Lc\ShopBundle\Context\FilterMerchantInterface;

/**
@@ -13,7 +15,6 @@ use Lc\ShopBundle\Context\FilterMerchantInterface;
*/
abstract class OrderShop extends AbstractEntity implements FilterMerchantInterface
{

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies")
* @ORM\JoinColumn(nullable=false)
@@ -31,10 +32,20 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
protected $visitor;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface", inversedBy="order")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
*/
protected $invoiceAddress;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $invoiceAddressText;

/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $validationDate;

/**
* @ORM\Column(type="text", nullable=true)
*/
@@ -55,65 +66,117 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
*/
protected $orderStatusHistories;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderPaymentInterface", mappedBy="orderShop", orphanRemoval=true)
*/
protected $orderPayments;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", mappedBy="orderShop", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $orderProducts;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\CreditHistoryInterface", mappedBy="orderShop", orphanRemoval=true)
* @ORM\Column(type="text", nullable=true)
*/
protected $creditHistories;
protected $deliveryInfos;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\DocumentInvoiceInterface", inversedBy="orderShops")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $documentInvoice;
protected $orderStatus;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\DocumentQuotationInterface", inversedBy="orderShops")
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderReductionCartInterface", mappedBy="orderShop", orphanRemoval=true)
*/
protected $documentQuotation;
protected $orderReductionCarts;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\DocumentDeliveryNoteInterface", inversedBy="orderShops")
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderReductionCreditInterface", mappedBy="orderShop", orphanRemoval=true)
*/
protected $documentDeliveryNote;
protected $orderReductionCredits;

/**
* @ORM\Column(type="text", nullable=true)
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\DocumentInterface", inversedBy="orderShops")
*/
protected $deliveryInfos;
protected $documents;

/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $updatedBy;


/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\TicketInterface", mappedBy="orderShop")
*/
protected $tickets;

public function __construct()
{
$this->orderStatusHistories = new ArrayCollection();
$this->orderPayments = new ArrayCollection();
$this->orderProducts = new ArrayCollection();
$this->creditHistories = new ArrayCollection();
$this->orderReductionCarts = new ArrayCollection();
$this->orderReductionCredits = new ArrayCollection();
$this->documents = new ArrayCollection();
}

public function __toString()
{
if($this->getValidationDate()) {
return 'Commande du '.$this->getValidationDate()->format('d/m/Y') ;
}
else {
return 'Commande #'.$this->getId() ;
}
}

public function getValidationDate(): ?\DateTimeInterface
{
return $this->validationDate;
}

public function setValidationDate(\DateTimeInterface $validationDate): self
{
$this->validationDate = $validationDate;

return $this;
}

public function getDateCreated()
{
$orderStatusHistory = $this->getOrderStatusHistory('new') ;
if($orderStatusHistory) {
return $orderStatusHistory->getCreatedAt() ;
$orderStatusHistory = $this->getOrderStatusHistory('new');
if ($orderStatusHistory) {
return $orderStatusHistory->getCreatedAt();
}

return null ;
return null;
}

public function getOrderStatusHistory($status)
{
$orderStatusHistories = $this->getOrderStatusHistories() ;
if(count($orderStatusHistories) > 0) {
foreach($orderStatusHistories as $orderStatusHistory) {
if($orderStatusHistory->getOrderStatus() == $status) {
return $orderStatusHistory ;
$orderStatusHistories = $this->getOrderStatusHistories();
if (count($orderStatusHistories) > 0) {
foreach ($orderStatusHistories as $orderStatusHistory) {
if ($orderStatusHistory->getOrderStatus() == $status) {
return $orderStatusHistory;
}
}
}

return null ;
return null;
}

public function getMerchant(): ?Merchant
@@ -152,6 +215,18 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
return $this;
}

public function getInvoiceAddressText(): ?string
{
return $this->invoiceAddressText;
}

public function setInvoiceAddressText(string $invoiceAddressText): self
{
$this->invoiceAddressText = $invoiceAddressText;

return $this;
}

public function getComment(): ?string
{
return $this->comment;
@@ -219,6 +294,37 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
return $this;
}

/**
* @return Collection|OrderPayment[]
*/
public function getOrderPayments(): Collection
{
return $this->orderPayments;
}

public function addOrderPayment(OrderPayment $orderPayment): self
{
if (!$this->orderPayments->contains($orderPayment)) {
$this->orderPayments[] = $orderPayment;
$orderPayment->setOrderShop($this);
}

return $this;
}

public function removeOrderPayment(OrderPayment $orderPayment): self
{
if ($this->orderPayments->contains($orderPayment)) {
$this->orderPayments->removeElement($orderPayment);
// set the owning side to null (unless already changed)
if ($orderPayment->getOrderShop() === $this) {
$orderPayment->setOrderShop(null);
}
}

return $this;
}

/**
* @return Collection|OrderProduct[]
*/
@@ -281,63 +387,178 @@ abstract class OrderShop extends AbstractEntity implements FilterMerchantInterfa
return $this;
}

public function getDocumentInvoice(): ?DocumentInvoice
public function getVisitor(): ?Visitor
{
return $this->documentInvoice;
return $this->visitor;
}

public function setDocumentInvoice(?DocumentInvoice $documentInvoice): self
public function setVisitor(?Visitor $visitor): self
{
$this->documentInvoice = $documentInvoice;
$this->visitor = $visitor;

return $this;
}

public function getDocumentQuotation(): ?DocumentQuotation
public function getDeliveryInfos(): ?string
{
return $this->documentQuotation;
return $this->deliveryInfos;
}

public function setDocumentQuotation(?DocumentQuotation $documentQuotation): self
public function setDeliveryInfos(?string $deliveryInfos): self
{
$this->documentQuotation = $documentQuotation;
$this->deliveryInfos = $deliveryInfos;

return $this;
}

public function getDocumentDeliveryNote(): ?DocumentDeliveryNote

public function getOrderStatus(): ?OrderStatus
{
return $this->documentDeliveryNote;
return $this->orderStatus;
}

public function setDocumentDeliveryNote(?DocumentDeliveryNote $documentDeliveryNote): self
public function setOrderStatusProtected(?OrderStatus $orderStatus): self
{
$this->documentDeliveryNote = $documentDeliveryNote;
$this->orderStatus = $orderStatus;

return $this;
}

public function getVisitor(): ?Visitor

/**
* @return Collection|OrderReductionCart[]
*/
public function getOrderReductionCarts(): Collection
{
return $this->visitor;
return $this->orderReductionCarts;
}

public function setVisitor(?Visitor $visitor): self
public function addOrderReductionCart(OrderReductionCart $orderReductionCart): self
{
$this->visitor = $visitor;
if (!$this->orderReductionCarts->contains($orderReductionCart)) {
$this->orderReductionCarts[] = $orderReductionCart;
$orderReductionCart->setOrderShop($this);
}

return $this;
}

public function getDeliveryInfos(): ?string
public function removeOrderReductionCart(OrderReductionCart $orderReductionCart): self
{
return $this->deliveryInfos;
if ($this->orderReductionCarts->contains($orderReductionCart)) {
$this->orderReductionCarts->removeElement($orderReductionCart);
// set the owning side to null (unless already changed)
if ($orderReductionCart->getOrderShop() === $this) {
$orderReductionCart->setOrderShop(null);
}
}

return $this;
}

public function setDeliveryInfos(?string $deliveryInfos): self
/**
* @return Collection|OrderReductionCart[]
*/
public function getOrderReductionCredits(): Collection
{
$this->deliveryInfos = $deliveryInfos;
return $this->orderReductionCredits;
}

public function addOrderReductionCredit(OrderReductionCredit $orderReductionCredit): self
{
if (!$this->orderReductionCredits->contains($orderReductionCredit)) {
$this->orderReductionCredits[] = $orderReductionCredit;
$orderReductionCredit->setOrderShop($this);
}

return $this;
}

public function removeOrderReductionCredit(OrderReductionCredit $orderReductionCredit): self
{
if ($this->orderReductionCredits->contains($orderReductionCredit)) {
$this->orderReductionCredits->removeElement($orderReductionCredit);
// set the owning side to null (unless already changed)
if ($orderReductionCredit->getOrderShop() === $this) {
$orderReductionCredit->setOrderShop(null);
}
}

return $this;
}

/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}

public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
}

return $this;
}

public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
}

return $this;
}


/**
* @return Collection|Ticket[]
*/
public function getTickets(): Collection
{
return $this->tickets;
}

public function addTicket(Ticket $ticket): self
{
if (!$this->tickets->contains($ticket)) {
$this->tickets[] = $ticket;
$ticket->setOrderShop($this);
}

return $this;
}

public function removeTicket(Ticket $ticket): self
{
if ($this->tickets->contains($ticket)) {
$this->tickets->removeElement($ticket);
// set the owning side to null (unless already changed)
if ($ticket->getOrderShop() === $this) {
$ticket->setOrderShop(null);
}
}

return $this;
}

public function isValid() {
if($this->getOrderStatus() && in_array($this->getOrderStatus()->getAlias(), OrderStatus::$statusAliasAsValid) > 0) {
return true ;
}

return false ;
}

public function isCart() {
if($this->getOrderStatus() && in_array($this->getOrderStatus()->getAlias(), OrderStatus::$statusAliasAsCart) > 0) {
return true ;
}

return false ;
}

}

+ 140
- 0
ShopBundle/Model/OrderStatus.php 查看文件

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderStatus
{
const ALIAS_CART = 'cart' ;
const ALIAS_CART_CANCELED = 'cart-canceled' ;
const ALIAS_WAITING_PAYMENT_ONLINE = 'waiting-payment-online' ;
const ALIAS_WAITING_PAYMENT_CREDIT = 'waiting-payment-credit' ;
const ALIAS_PAID_ONLINE = 'paid-online' ;
const ALIAS_ERROR_PAYMENT_ONLINE = 'error-payment-online' ;
const ALIAS_PAID_BY_CREDIT = 'paid-by-credit' ;
const ALIAS_WAITING_DELIVERY = 'waiting-delivery' ;
const ALIAS_WAITING_DELIVERY_WITH_PAYMENT = 'waiting-delivery-with-payment' ;
const ALIAS_DELIVERED_WITHOUT_PAYMENT = 'delivered-without-payment' ;
const ALIAS_DONE = 'done' ;
const ALIAS_CANCELED = 'canceled' ;
const ALIAS_CANCELED_WAITING_REFUND = 'canceled-waiting-refund' ;
const ALIAS_REFUND = 'refund' ;


//TODO : AJOUTER un champ valid ds orderSTATUS
static $statusAliasAsValid = [
self::ALIAS_PAID_ONLINE,
self::ALIAS_PAID_BY_CREDIT,
self::ALIAS_WAITING_DELIVERY,
self::ALIAS_WAITING_DELIVERY_WITH_PAYMENT,
self::ALIAS_DELIVERED_WITHOUT_PAYMENT,
self::ALIAS_DONE
] ;

static $statusAliasAsCart = [
self::ALIAS_CART,
self::ALIAS_WAITING_PAYMENT_ONLINE,
self::ALIAS_WAITING_PAYMENT_CREDIT,
self::ALIAS_ERROR_PAYMENT_ONLINE
];

/**
* @ORM\Column(type="string", length=255)
*/
protected $title;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $description;

/**
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface")
*/
protected $nextStatusAllowed;

/**
* @ORM\Column(type="string", length=255)
*/
protected $alias;

public function __toString()
{
return $this->title. ' ['.$this->alias.']';
}

public function __construct()
{
$this->nextStatusAllowed = new ArrayCollection();
}

public function getTitle(): ?string
{
return $this->title;
}

public function setTitle(string $title): self
{
$this->title = $title;

return $this;
}

public function getDescription(): ?string
{
return $this->description;
}

public function setDescription(?string $description): self
{
$this->description = $description;

return $this;
}

/**
* @return Collection|self[]
*/
public function getNextStatusAllowed(): Collection
{
return $this->nextStatusAllowed;
}

public function addNextStatusAllowed(self $nextStatusAllowed): self
{
if (!$this->nextStatusAllowed->contains($nextStatusAllowed)) {
$this->nextStatusAllowed[] = $nextStatusAllowed;
}

return $this;
}

public function removeNextStatusAllowed(self $nextStatusAllowed): self
{
if ($this->nextStatusAllowed->contains($nextStatusAllowed)) {
$this->nextStatusAllowed->removeElement($nextStatusAllowed);
}

return $this;
}

public function getAlias(): ?string
{
return $this->alias;
}

public function setAlias(string $alias): self
{
$this->alias = $alias;

return $this;
}


}

+ 24
- 3
ShopBundle/Model/OrderStatusHistory.php 查看文件

@@ -3,6 +3,8 @@
namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;


/**
* @ORM\MappedSuperclass()
@@ -16,7 +18,8 @@ abstract class OrderStatusHistory extends AbstractEntity
protected $orderShop;

/**
* @ORM\Column(type="string", length=31)
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $orderStatus;

@@ -25,6 +28,24 @@ abstract class OrderStatusHistory extends AbstractEntity
*/
protected $origin;

/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $updatedBy;
public function __toString()
{
return $this->getOrderStatus()->getAlias(). ' le : '.$this->getCreatedAt()->format('d-m-Y H:i').'('.$this->getOrigin().')';
}

public function getOrderShop(): ?OrderShop
{
return $this->orderShop;
@@ -37,12 +58,12 @@ abstract class OrderStatusHistory extends AbstractEntity
return $this;
}

public function getOrderStatus(): ?string
public function getOrderStatus(): ?OrderStatus
{
return $this->orderStatus;
}

public function setOrderStatus(string $orderStatus): self
public function setOrderStatus(?OrderStatus $orderStatus): self
{
$this->orderStatus = $orderStatus;


部分文件因为文件数量过多而无法显示

正在加载...
取消
保存