Resources/public/.sass-cache/ |
namespace Lc\ShopBundle\Context; | namespace Lc\ShopBundle\Context; | ||||
interface CartProductInterface | |||||
interface DocumentInterface | |||||
{ | { | ||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Context ; | |||||
interface OrderPaymentInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface OrderPayoffInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface OrderProductRefundInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface OrderReductionCartInterface | |||||
{ | |||||
} |
namespace Lc\ShopBundle\Context; | namespace Lc\ShopBundle\Context; | ||||
interface DocumentDeliveryNoteInterface | |||||
interface OrderReductionCreditInterface | |||||
{ | { | ||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface OrderRefundInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Context ; | |||||
interface OrderShopPriceUtilsInterface | |||||
{ | |||||
} |
namespace Lc\ShopBundle\Context; | namespace Lc\ShopBundle\Context; | ||||
interface PointSaleUtilsInterface | |||||
interface OrderStatusInterface | |||||
{ | { | ||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface PayoffInterface | |||||
{ | |||||
} |
namespace Lc\ShopBundle\Context; | namespace Lc\ShopBundle\Context; | ||||
use Doctrine\Common\Collections\Collection; | |||||
use Lc\ShopBundle\Model\PointSale; | |||||
interface ReductionCartInterface | interface ReductionCartInterface | ||||
{ | { | ||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface ReductionCartPropertyInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface ReductionCreditInterface | |||||
{ | |||||
} |
namespace Lc\ShopBundle\Context; | namespace Lc\ShopBundle\Context; | ||||
interface DocumentQuotationInterface | |||||
interface ReductionPropertyInterface | |||||
{ | { | ||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface ReminderInterface | |||||
{ | |||||
} |
namespace Lc\ShopBundle\Context; | namespace Lc\ShopBundle\Context; | ||||
interface CartInterface | |||||
interface SeoInterface | |||||
{ | { | ||||
} | } |
<?php | |||||
namespace Lc\ShopBundle\Context ; | |||||
interface TicketInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Context ; | |||||
interface TicketMessageInterface | |||||
{ | |||||
} |
namespace Lc\ShopBundle\Context; | namespace Lc\ShopBundle\Context; | ||||
interface DocumentInvoiceInterface | |||||
interface UserMerchantInterface | |||||
{ | { | ||||
} | } |
use Doctrine\ORM\EntityManager; | use Doctrine\ORM\EntityManager; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\ShopBundle\Context\PriceUtilsInterface; | |||||
use Lc\ShopBundle\Context\ProductCategoryInterface; | use Lc\ShopBundle\Context\ProductCategoryInterface; | ||||
use Lc\ShopBundle\Context\ProductInterface; | use Lc\ShopBundle\Context\ProductInterface; | ||||
use Lc\ShopBundle\Services\PriceUtils; | |||||
use Lc\ShopBundle\Services\ProductFamilyUtils; | use Lc\ShopBundle\Services\ProductFamilyUtils; | ||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
use Symfony\Component\HttpFoundation\JsonResponse; | use Symfony\Component\HttpFoundation\JsonResponse; | ||||
protected $priceUtils ; | protected $priceUtils ; | ||||
protected $productFamilyUtils; | protected $productFamilyUtils; | ||||
public function __construct(EntityManagerInterface $entityManager, PriceUtils $priceUtils, ProductFamilyUtils $productFamilyUtils) | |||||
public function __construct(EntityManagerInterface $entityManager, PriceUtilsInterface $priceUtils, ProductFamilyUtils $productFamilyUtils) | |||||
{ | { | ||||
$this->em = $entityManager; | $this->em = $entityManager; | ||||
$this->priceUtils = $priceUtils; | $this->priceUtils = $priceUtils; |
use Lc\ShopBundle\Context\MerchantInterface; | use Lc\ShopBundle\Context\MerchantInterface; | ||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | use Lc\ShopBundle\Context\MerchantUtilsInterface; | ||||
use Lc\ShopBundle\Context\OrderUtilsInterface; | use Lc\ShopBundle\Context\OrderUtilsInterface; | ||||
use Lc\ShopBundle\Context\ReminderInterface; | |||||
use Lc\ShopBundle\Context\SeoInterface; | |||||
use Lc\ShopBundle\Context\StatusInterface; | use Lc\ShopBundle\Context\StatusInterface; | ||||
use Lc\ShopBundle\Context\TreeInterface; | 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\Utils; | ||||
use Lc\ShopBundle\Services\UtilsManager; | |||||
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | ||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | ||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | 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\FormEvent; | ||||
use Symfony\Component\Form\FormEvents; | use Symfony\Component\Form\FormEvents; | ||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
use Symfony\Contracts\Translation\TranslatorInterface; | |||||
class AdminController extends EasyAdminController | class AdminController extends EasyAdminController | ||||
{ | { | ||||
protected $userManager; | protected $userManager; | ||||
protected $em; | protected $em; | ||||
protected $utils; | 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->security = $security; | ||||
$this->userManager = $userManager; | $this->userManager = $userManager; | ||||
$this->em = $em; | $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 | * Réécriture de show action pr rediriger vers l'édition | ||||
*/ | */ | ||||
public function showAction() | |||||
/* public function showAction() | |||||
{ | { | ||||
$id = $this->request->query->get('id'); | $id = $this->request->query->get('id'); | ||||
$entity = $this->request->query->get('entity'); | $entity = $this->request->query->get('entity'); | ||||
'entity' => $entity, | 'entity' => $entity, | ||||
'id' => $id | 'id' => $id | ||||
]); | ]); | ||||
} | |||||
}*/ | |||||
/** | /** | ||||
public function renderTemplate($actionName, $templatePath, array $parameters = []) | 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 = array_merge( | ||||
$parameters, | $parameters, | ||||
$this->getTwigExtraParameters() | |||||
$this->getTwigExtraParameters(), | |||||
$reminders | |||||
); | ); | ||||
return parent::renderTemplate($actionName, $templatePath, $parameters); | return parent::renderTemplate($actionName, $templatePath, $parameters); | ||||
} | } | ||||
public function listChildrenAction() | public function listChildrenAction() | ||||
{ | { | ||||
$this->dispatch(EasyAdminEvents::PRE_LIST); | $this->dispatch(EasyAdminEvents::PRE_LIST); | ||||
$formBuilder = parent::createEntityFormBuilder($entity, $view); | $formBuilder = parent::createEntityFormBuilder($entity, $view); | ||||
if($override)$formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view); | |||||
if ($override) $formBuilder = $this->overrideFormBuilder($formBuilder, $entity, $view); | |||||
return $formBuilder; | return $formBuilder; | ||||
} | } | ||||
public function overrideFormBuilder($formBuilder, $entity, $view){ | |||||
public function overrideFormBuilder($formBuilder, $entity, $view) | |||||
{ | |||||
$id = (null !== $entity->getId()) ? $entity->getId() : 0; | $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) { | if ($entity instanceof StatusInterface) { | ||||
$formBuilder->add('status', ChoiceType::class, array( | $formBuilder->add('status', ChoiceType::class, array( | ||||
'choices' =>array( | |||||
'choices' => array( | |||||
'field.default.statusOptions.offline' => '0', | 'field.default.statusOptions.offline' => '0', | ||||
'field.default.statusOptions.online' => '1' | 'field.default.statusOptions.online' => '1' | ||||
), | ), | ||||
'expanded' => true, | 'expanded' => true, | ||||
'required' => true, | 'required' => true, | ||||
'translation_domain'=> 'lcshop' | |||||
'translation_domain' => 'lcshop' | |||||
) | ) | ||||
); | ); | ||||
} | } | ||||
return $formBuilder; | return $formBuilder; | ||||
} | } | ||||
private function loopFormField($form, $childrens){ | |||||
private function loopFormField($form, $childrens) | |||||
{ | |||||
foreach ($childrens as $child) { | foreach ($childrens as $child) { | ||||
$statusInterface = false; | $statusInterface = false; | ||||
$treeInterface = false; | $treeInterface = false; | ||||
$passedOptions = $child->getConfig()->getOptions(); | $passedOptions = $child->getConfig()->getOptions(); | ||||
$classImplements = class_implements($passedOptions['class']); | $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) { | if ($isFilterMerchantInterface || $isFilterMultipleMerchantsInterface) { | ||||
$treeInterface = true; | $treeInterface = true; | ||||
} | } | ||||
$propertyMerchant = 'merchant'; | $propertyMerchant = 'merchant'; | ||||
if($isFilterMultipleMerchantsInterface) { | |||||
$propertyMerchant .= 's' ; | |||||
if ($isFilterMultipleMerchantsInterface) { | |||||
$propertyMerchant .= 's'; | |||||
} | } | ||||
$form->add($child->getName(), EntityType::class, array( | $form->add($child->getName(), EntityType::class, array( | ||||
'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(), | 'class' => $this->em->getClassMetadata($passedOptions['class'])->getName(), | ||||
'label' => $passedOptions['label'], | 'label' => $passedOptions['label'], | ||||
'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false, | 'multiple' => isset($passedOptions['multiple']) ? $passedOptions['multiple'] : false, | ||||
'placeholder' => '--', | 'placeholder' => '--', | ||||
'translation_domain'=> 'lcshop', | |||||
'translation_domain' => 'lcshop', | |||||
'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant, $statusInterface, $treeInterface, $child) { | 'query_builder' => function (EntityRepository $repo) use ($passedOptions, $propertyMerchant, $statusInterface, $treeInterface, $child) { | ||||
$queryBuilder = $repo->createQueryBuilder('e'); | $queryBuilder = $repo->createQueryBuilder('e'); | ||||
$propertyMerchant = 'e.' . $propertyMerchant; | $propertyMerchant = 'e.' . $propertyMerchant; | ||||
$queryBuilder->where($propertyMerchant . ' = :currentMerchant'); | $queryBuilder->where($propertyMerchant . ' = :currentMerchant'); | ||||
} | } | ||||
if($statusInterface){ | |||||
if ($statusInterface) { | |||||
$queryBuilder->andWhere('e.status >= 0'); | $queryBuilder->andWhere('e.status >= 0'); | ||||
} | } | ||||
if($treeInterface && $child->getName() =='parent'){ | |||||
if ($treeInterface && $child->getName() == 'parent') { | |||||
$queryBuilder->andWhere('e.parent is null'); | $queryBuilder->andWhere('e.parent is null'); | ||||
} | } | ||||
$queryBuilder->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId()); | $queryBuilder->setParameter(':currentMerchant', $this->getUser()->getMerchant()->getId()); | ||||
return $queryBuilder; | 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; | return $choice; | ||||
}, | }, | ||||
'required' => $passedOptions['required'], | 'required' => $passedOptions['required'], | ||||
'choice_attr' => $passedOptions['choice_attr'], | |||||
) | ) | ||||
); | ); | ||||
} | } | ||||
}else{ | |||||
} else { | |||||
$subChildrens = $child->all(); | $subChildrens = $child->all(); | ||||
if(count($subChildrens)){ | |||||
if (count($subChildrens)) { | |||||
$this->loopFormField($child, $subChildrens); | $this->loopFormField($child, $subChildrens); | ||||
} | } | ||||
} | } |
<?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') ; | |||||
} | |||||
} | |||||
} |
$response = parent::editAction() ; | $response = parent::editAction() ; | ||||
if ($response instanceof RedirectResponse) { | if ($response instanceof RedirectResponse) { | ||||
$referer = $this->request->headers->get('referer'); | $referer = $this->request->headers->get('referer'); | ||||
return new RedirectResponse($referer); | return new RedirectResponse($referer); | ||||
} | } |
namespace Lc\ShopBundle\Controller\Backend; | namespace Lc\ShopBundle\Controller\Backend; | ||||
use Doctrine\ORM\EntityRepository; | |||||
use Doctrine\ORM\EntityManagerInterface; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | 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\OrderProductInterface; | ||||
use Lc\ShopBundle\Context\OrderReductionCartInterface; | |||||
use Lc\ShopBundle\Context\OrderReductionCreditInterface; | |||||
use Lc\ShopBundle\Context\OrderShopInterface; | |||||
use Lc\ShopBundle\Context\UserInterface; | 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\Bridge\Doctrine\Form\Type\EntityType; | ||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||||
use Symfony\Component\HttpFoundation\Response; | 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 | 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) | public function updateEntity($entity) | ||||
{ | { | ||||
} | } | ||||
public function getUserViaFirstStepForm($entity) | public function getUserViaFirstStepForm($entity) | ||||
{ | { | ||||
$userClass = $this->em->getClassMetadata(UserInterface::class); | $userClass = $this->em->getClassMetadata(UserInterface::class); | ||||
public function addProductToOrderAction() | 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); | $orderProductClass = $this->em->getClassMetadata(OrderProductInterface::class); | ||||
$formAddProductToOrder = $this->createForm(AddPoductToOrderType::class); | $formAddProductToOrder = $this->createForm(AddPoductToOrderType::class); | ||||
$formAddProductToOrder->handleRequest($this->request); | $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 = 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 { | } 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() | 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 = $this->createForm(OrderInvoiceAddressType::class, $orderShop); | ||||
$formOrderInvoiceAddress->handleRequest($this->request); | $formOrderInvoiceAddress->handleRequest($this->request); | ||||
if ($formOrderInvoiceAddress->isSubmitted() && $formOrderInvoiceAddress->isValid()) { | 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->persist($orderShop); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
$response['status'] = 'success'; | |||||
$response['message'] = 'La commande a bien été modifié'; | |||||
$this->utils->addFlash('success', 'success.order.changeInvoiceAddress'); | |||||
} else { | } 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 { | } 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(); | $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 { | } 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)); | return new Response(json_encode($response)); | ||||
} | } | ||||
public function renderOrderShopTemplate($actionName, $templatePath, array $parameters = []) | public function renderOrderShopTemplate($actionName, $templatePath, array $parameters = []) | ||||
{ | { | ||||
if ($actionName == 'show') { | 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); | return parent::renderTemplate($actionName, $templatePath, $parameters); | ||||
} | } | ||||
protected function newAction() | protected function newAction() | ||||
{ | { | ||||
$this->dispatch(EasyAdminEvents::PRE_NEW); | $this->dispatch(EasyAdminEvents::PRE_NEW); | ||||
if (!$user instanceof UserInterface) return $user; | if (!$user instanceof UserInterface) return $user; | ||||
else { | 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() | |||||
]); | |||||
} | |||||
} | } | ||||
} | } | ||||
]; | ]; | ||||
return $this->executeDynamicMethod('render<EntityName>Template', ['show', $this->entity['templates']['show'], $parameters]); | |||||
return $this->executeDynamicMethod('renderOrderShopTemplate', ['show', $this->entity['templates']['show'], $parameters]); | |||||
} | } | ||||
/** | /** | ||||
]); | ]); | ||||
} | } | ||||
} | |||||
protected function getOrderShopEntity() | |||||
{ | |||||
$easyadmin = $this->request->attributes->get('easyadmin'); | |||||
return $easyadmin['item']; | |||||
} | |||||
} |
namespace Lc\ShopBundle\Controller\Backend; | namespace Lc\ShopBundle\Controller\Backend; | ||||
use App\Entity\Product; | use App\Entity\Product; | ||||
use App\Entity\ReductionCatalog; | |||||
use Doctrine\DBAL\Types\FloatType; | |||||
use Doctrine\ORM\EntityRepository; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | use EasyCorp\Bundle\EasyAdminBundle\Event\EasyAdminEvents; | ||||
use Lc\ShopBundle\Context\OrderShopInterface; | |||||
use Lc\ShopBundle\Context\ProductCategoryInterface; | use Lc\ShopBundle\Context\ProductCategoryInterface; | ||||
use Lc\ShopBundle\Context\ProductFamilyInterface; | use Lc\ShopBundle\Context\ProductFamilyInterface; | ||||
use Lc\ShopBundle\Context\ProductInterface; | |||||
use Lc\ShopBundle\Context\ReductionCartInterface; | |||||
use Lc\ShopBundle\Context\ReductionCatalogInterface; | use Lc\ShopBundle\Context\ReductionCatalogInterface; | ||||
use Lc\ShopBundle\Context\TaxRateInterface; | 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\ChoiceType; | ||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | 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\Extension\Core\Type\NumberType; | ||||
use Symfony\Component\Form\FormError; | |||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
class ProductFamilyController extends AdminController | class ProductFamilyController extends AdminController | ||||
$class = $this->em->getClassMetadata(ProductCategoryInterface::class); | $class = $this->em->getClassMetadata(ProductCategoryInterface::class); | ||||
$this->taxRateClass = $this->em->getClassMetadata(TaxRateInterface::class); | $this->taxRateClass = $this->em->getClassMetadata(TaxRateInterface::class); | ||||
$formBuilder->add('productCategories', ProductFamilyCategoriesType::class); | |||||
//$formBuilder->add('productCategories', ProductFamilyCategoriesType::class); | |||||
$reductionCatalogRepo = $this->em->getRepository(ReductionCatalogInterface::class); | $reductionCatalogRepo = $this->em->getRepository(ReductionCatalogInterface::class); | ||||
$formBuilder->add('warningMessageType', ChoiceType::class, array( | $formBuilder->add('warningMessageType', ChoiceType::class, array( | ||||
'choices' => 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', | 'translation_domain' => 'lcshop', | ||||
'multiple' => false, | 'multiple' => false, | ||||
)); | )); | ||||
$formBuilder->add('behaviorCountStock', ChoiceType::class, array( | $formBuilder->add('behaviorCountStock', ChoiceType::class, array( | ||||
'empty_data' => 'by-product-family', | |||||
'empty_data' => ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY, | |||||
'choices' => array( | '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', | 'translation_domain' => 'lcshop', | ||||
'multiple' => false, | 'multiple' => false, | ||||
$formBuilder->add('behaviorAddToCart', ChoiceType::class, array( | $formBuilder->add('behaviorAddToCart', ChoiceType::class, array( | ||||
'data' => $entity->getBehaviorAddToCart() ? $entity->getBehaviorAddToCart() : 'simple', | 'data' => $entity->getBehaviorAddToCart() ? $entity->getBehaviorAddToCart() : 'simple', | ||||
'choices' => array( | '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', | 'translation_domain' => 'lcshop', | ||||
'multiple' => false, | 'multiple' => false, | ||||
$formBuilder->add('behaviorPrice', ChoiceType::class, array( | $formBuilder->add('behaviorPrice', ChoiceType::class, array( | ||||
'empty_data' => 'by-piece', | 'empty_data' => 'by-piece', | ||||
'choices' => array( | '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', | 'translation_domain' => 'lcshop', | ||||
'multiple' => false, | 'multiple' => false, | ||||
$formBuilder->add('propertyOrganicLabel', ChoiceType::class, array( | $formBuilder->add('propertyOrganicLabel', ChoiceType::class, array( | ||||
'choices' => 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', | 'translation_domain' => 'lcshop', | ||||
'multiple' => false, | 'multiple' => false, | ||||
$formBuilder->add('typeExpirationDate', ChoiceType::class, array( | $formBuilder->add('typeExpirationDate', ChoiceType::class, array( | ||||
'choices' => 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', | 'translation_domain' => 'lcshop', | ||||
'multiple' => false, | 'multiple' => false, | ||||
'required'=>false | '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( | $formBuilder->add('behaviorExpirationDate', ChoiceType::class, array( | ||||
'choices' => 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', | 'translation_domain' => 'lcshop', | ||||
'multiple' => false, | 'multiple' => false, | ||||
$easyadmin = $this->request->attributes->get('easyadmin'); | $easyadmin = $this->request->attributes->get('easyadmin'); | ||||
$entity = $easyadmin['item']; | $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')) { | if ($this->request->isXmlHttpRequest() && $property = $this->request->query->get('property')) { | ||||
$newValue = 'true' === mb_strtolower($this->request->query->get('newValue')); | $newValue = 'true' === mb_strtolower($this->request->query->get('newValue')); | ||||
$fieldsMetadata = $this->entity['list']['fields']; | $fieldsMetadata = $this->entity['list']['fields']; | ||||
ksort($sortableProductsField); | ksort($sortableProductsField); | ||||
$editForm->handleRequest($this->request); | $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); | $this->processUploadedFiles($editForm); | ||||
$this->executeDynamicMethod('update<EntityName>Entity', [$entity, $editForm]); | $this->executeDynamicMethod('update<EntityName>Entity', [$entity, $editForm]); | ||||
$this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]); | $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); | $this->dispatch(EasyAdminEvents::POST_EDIT); | ||||
'entity_fields' => $fields, | 'entity_fields' => $fields, | ||||
'entity' => $entity, | 'entity' => $entity, | ||||
'delete_form' => $deleteForm->createView(), | 'delete_form' => $deleteForm->createView(), | ||||
'sortableProductsField' => $sortableProductsField | |||||
'sortableProductsField' => $sortableProductsField, | |||||
'totalProductOrdered' => $totalProductOrdered | |||||
]; | ]; | ||||
return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]); | return $this->executeDynamicMethod('render<EntityName>Template', ['edit', $this->entity['templates']['edit'], $parameters]); | ||||
$newForm->handleRequest($this->request); | $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->processUploadedFiles($newForm); | ||||
$this->dispatch(EasyAdminEvents::PRE_PERSIST, ['entity' => $entity]); | $this->dispatch(EasyAdminEvents::PRE_PERSIST, ['entity' => $entity]); | ||||
'entity_fields' => $fields, | 'entity_fields' => $fields, | ||||
'entity' => $entity, | 'entity' => $entity, | ||||
'categories' => $categories, | 'categories' => $categories, | ||||
'sortableProductsField' => array() | |||||
'sortableProductsField' => array(), | |||||
'totalProductOrdered' => array() | |||||
]; | ]; | ||||
return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]); | return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]); |
<?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(); | |||||
} | |||||
} |
<?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() | |||||
]); | |||||
} | |||||
} |
namespace Lc\ShopBundle\Controller\Backend; | namespace Lc\ShopBundle\Controller\Backend; | ||||
use App\Form\Backend\Common\AddressType; | |||||
use FOS\UserBundle\Doctrine\UserManager; | use FOS\UserBundle\Doctrine\UserManager; | ||||
use FOS\UserBundle\Model\UserManagerInterface ; | use FOS\UserBundle\Model\UserManagerInterface ; | ||||
use Lc\ShopBundle\Context\AddressInterface; | |||||
use Lc\ShopBundle\Model\Address; | |||||
class UserController extends AdminController | class UserController extends AdminController | ||||
{ | { | ||||
$this->userManager->updateUser($user, false); | $this->userManager->updateUser($user, false); | ||||
parent::updateEntity($user); | parent::updateEntity($user); | ||||
} | } | ||||
} | } |
<?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 | |||||
]); | |||||
} | |||||
} |
namespace Lc\ShopBundle\Controller ; | namespace Lc\ShopBundle\Controller ; | ||||
use Lc\ShopBundle\Services\CityUtils; | use Lc\ShopBundle\Services\CityUtils; | ||||
use Lc\ShopBundle\Services\Utils; | |||||
use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
use Symfony\Component\HttpFoundation\JsonResponse; | use Symfony\Component\HttpFoundation\JsonResponse; | ||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
class CitiesController extends 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 | public function index(Request $request) : JsonResponse | ||||
} | } | ||||
$result = array_merge( | $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 = [] ; | $return = [] ; |
namespace Lc\ShopBundle\Controller\Frontend ; | namespace Lc\ShopBundle\Controller\Frontend ; | ||||
use App\Entity\ReductionCredit; | |||||
use App\Form\Frontend\OrderProductsType; | use App\Form\Frontend\OrderProductsType; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | use Lc\ShopBundle\Context\MerchantUtilsInterface; | ||||
use Lc\ShopBundle\Context\OrderProductInterface; | use Lc\ShopBundle\Context\OrderProductInterface; | ||||
use Lc\ShopBundle\Context\OrderReductionCartInterface; | |||||
use Lc\ShopBundle\Context\OrderReductionCreditInterface; | |||||
use Lc\ShopBundle\Context\OrderUtilsInterface; | use Lc\ShopBundle\Context\OrderUtilsInterface; | ||||
use Lc\ShopBundle\Context\ProductFamilyInterface; | 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\JsonResponse; | ||||
use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
use Symfony\Component\Routing\Generator\UrlGenerator; | |||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | |||||
use Symfony\Component\Security\Core\Security; | use Symfony\Component\Security\Core\Security; | ||||
class CartController extends BaseController | class CartController extends BaseController | ||||
{ | { | ||||
protected $orderUtils ; | protected $orderUtils ; | ||||
protected $userUtils ; | |||||
protected $priceUtils ; | |||||
protected $router ; | |||||
protected $productFamilyRepository ; | protected $productFamilyRepository ; | ||||
protected $orderProductRepository ; | protected $orderProductRepository ; | ||||
protected $orderProducts = [] ; | 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); | 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->productFamilyRepository = $this->em->getRepository($this->em->getClassMetaData(ProductFamilyInterface::class)->getName()) ; | ||||
$this->orderProductRepository = $this->em->getRepository($this->em->getClassMetaData(OrderProductInterface::class)->getName()) ; | $this->orderProductRepository = $this->em->getRepository($this->em->getClassMetaData(OrderProductInterface::class)->getName()) ; | ||||
} | } | ||||
public function addProductFamily(Request $request) | public function addProductFamily(Request $request) | ||||
{ | { | ||||
$user = $this->security->getUser() ; | |||||
$visitor = $this->userUtils->getVisitorCurrent() ; | |||||
$return = [] ; | $return = [] ; | ||||
$data = $request->request->all() ; | $data = $request->request->all() ; | ||||
if(isset($data['order_products']['id_product_family'])) { | if(isset($data['order_products']['id_product_family'])) { | ||||
$idProductFamily = $data['order_products']['id_product_family'] ; | $idProductFamily = $data['order_products']['id_product_family'] ; | ||||
$this->productFamily = $this->productFamilyRepository->find($idProductFamily) ; | $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) { | if($this->productFamily) { | ||||
$form = $this->createForm(OrderProductsType::class, ['id_product_family' => $this->productFamily->getId()]); | $form = $this->createForm(OrderProductsType::class, ['id_product_family' => $this->productFamily->getId()]); | ||||
$form->handleRequest($request); | $form->handleRequest($request); | ||||
$data = $form->getData() ; | $data = $form->getData() ; | ||||
foreach($data as $orderProduct) { | foreach($data as $orderProduct) { | ||||
if($orderProduct instanceof OrderProductInterface) { | 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 ; | $this->orderProducts[] = $orderProduct ; | ||||
} | } | ||||
} | } | ||||
return new JsonResponse($return) ; | 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'); | |||||
} | |||||
} | |||||
} | } |
<?php | <?php | ||||
namespace Lc\ShopBundle\Form; | |||||
namespace Lc\ShopBundle\Form\Backend\Common; | |||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; | use Symfony\Component\Form\Extension\Core\Type\HiddenType; |
<?php | <?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\ChoiceType; | ||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | |||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType; | use Symfony\Component\Form\Extension\Core\Type\TextareaType; | ||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
{ | { | ||||
dump($options); | |||||
$builder | $builder | ||||
->add('title', TextType::class, ['label' => 'Titre']) | ->add('title', TextType::class, ['label' => 'Titre']) | ||||
->add('type', ChoiceType::class, [ | ->add('type', ChoiceType::class, [ | ||||
'label' => 'Type', | 'label' => 'Type', | ||||
'choices' => [ | '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, [ | ->add('civility', ChoiceType::class, [ | ||||
'Homme' => 0, | '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) | public function configureOptions(OptionsResolver $resolver) | ||||
{ | { | ||||
$resolver->setDefaults([ | $resolver->setDefaults([ | ||||
'label' => false, | 'label' => false, | ||||
'data_class' => $this->em->getClassMetadata(AddressInterface::class)->getName() | |||||
'data_class' => $this->em->getClassMetadata(AddressInterface::class)->getName(), | |||||
'translation_domain' => 'lcshop' | |||||
]); | ]); | ||||
} | } | ||||
} | } |
<?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' | |||||
]); | |||||
} | |||||
} |
<?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() | |||||
]); | |||||
} | |||||
} |
<?php | <?php | ||||
namespace Lc\ShopBundle\Form; | |||||
namespace Lc\ShopBundle\Form\Backend\Merchant; | |||||
use CKSource\Bundle\CKFinderBundle\Form\Type\CKFinderFileChooserType; | use CKSource\Bundle\CKFinderBundle\Form\Type\CKFinderFileChooserType; | ||||
use Lc\ShopBundle\Context\MerchantConfigInterface; | use Lc\ShopBundle\Context\MerchantConfigInterface; | ||||
{ | { | ||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { | ||||
$form = $event->getForm(); | $form = $event->getForm(); | ||||
$merchantConfig = $event->getData(); | $merchantConfig = $event->getData(); | ||||
if ($merchantConfig) { | if ($merchantConfig) { |
<?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, | |||||
]); | |||||
} | |||||
} | |||||
<?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' | |||||
]); | |||||
} | |||||
} |
<?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' | |||||
]); | |||||
} | |||||
} |
<?php | <?php | ||||
namespace Lc\ShopBundle\Form\Order; | |||||
namespace Lc\ShopBundle\Form\Backend\Order; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Doctrine\ORM\EntityRepository; | use Doctrine\ORM\EntityRepository; | ||||
->add('quantity', IntegerType::class, array( | ->add('quantity', IntegerType::class, array( | ||||
'mapped' => false | 'mapped' => false | ||||
)) | )) | ||||
->add('addProductToOrder', ButtonType::class, array( | |||||
'label'=> 'field.OrderShop.addOrderToProduct' | |||||
->add('add', ButtonType::class, array( | |||||
'label'=> 'action.add' | |||||
)); | )); | ||||
} | } | ||||
'translation_domain'=>'lcshop' | 'translation_domain'=>'lcshop' | ||||
]); | ]); | ||||
} | } | ||||
} | |||||
} |
<?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' | |||||
]); | |||||
} | |||||
} |
<?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' | |||||
]); | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?php | <?php | ||||
namespace Lc\ShopBundle\Form\Order; | |||||
namespace Lc\ShopBundle\Form\Backend\Order; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Doctrine\ORM\EntityRepository; | use Doctrine\ORM\EntityRepository; |
<?php | <?php | ||||
namespace Lc\ShopBundle\Form\Order; | |||||
namespace Lc\ShopBundle\Form\Backend\Order; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Doctrine\ORM\EntityRepository; | use Doctrine\ORM\EntityRepository; | ||||
->setParameter('user', $entity->getUser()); | ->setParameter('user', $entity->getUser()); | ||||
}, | }, | ||||
)) | )) | ||||
->add('saveInvoiceAddress', ButtonType::class, array( | |||||
'label' => 'field.OrderShop.saveInvoiceAddress' | |||||
->add('save', ButtonType::class, array( | |||||
'label' => 'action.save' | |||||
)); | )); | ||||
} | } | ||||
]); | ]); | ||||
} | } | ||||
} | |||||
} |
<?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' | |||||
]); | |||||
} | |||||
} |
<?php | <?php | ||||
namespace Lc\ShopBundle\Form\Order; | |||||
namespace Lc\ShopBundle\Form\Backend\Order; | |||||
use App\Entity\Product; | use App\Entity\Product; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; |
<?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([ | |||||
]); | |||||
} | |||||
} |
<?php | <?php | ||||
namespace Lc\ShopBundle\Form\Order; | |||||
namespace Lc\ShopBundle\Form\Backend\Order; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | use Lc\ShopBundle\Context\MerchantUtilsInterface; |
<?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' | |||||
]); | |||||
} | |||||
} |
<?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' | |||||
]); | |||||
} | |||||
} |
<?php | <?php | ||||
namespace Lc\ShopBundle\Form; | |||||
namespace Lc\ShopBundle\Form\Backend\ProductFamily; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\ShopBundle\Context\ProductCategoryInterface; | use Lc\ShopBundle\Context\ProductCategoryInterface; |
<?php | <?php | ||||
namespace Lc\ShopBundle\Form; | |||||
namespace Lc\ShopBundle\Form\Backend\ProductFamily; | |||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\ShopBundle\Context\ProductInterface; | use Lc\ShopBundle\Context\ProductInterface; | ||||
)); | )); | ||||
$builder->add('position', HiddenType::class); | $builder->add('position', HiddenType::class); | ||||
$builder->add('exportTitle', TextType::class, array( | |||||
'required' =>false | |||||
)); | |||||
$builder->add('exportNote', TextType::class, array( | |||||
'required' =>false | |||||
)); | |||||
} | } | ||||
<?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', | |||||
]); | |||||
} | |||||
} |
<?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', | |||||
]); | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?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', | |||||
]); | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?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', | |||||
]); | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?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', | |||||
]); | |||||
} | |||||
} |
<?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(), | |||||
]);*/ | |||||
} | |||||
} |
<?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' | |||||
]); | |||||
} | |||||
} |
<?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' | |||||
]); | |||||
} | |||||
} |
<?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' | |||||
]); | |||||
} | |||||
} |
<?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(), | |||||
]); | |||||
} | |||||
} |
<?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]; | |||||
} | |||||
} |
<?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([ | |||||
]); | |||||
} | |||||
} |
<?php | <?php | ||||
namespace Lc\ShopBundle\Form; | |||||
namespace Lc\ShopBundle\Form\Frontend; | |||||
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType; | use FOS\UserBundle\Form\Type\RegistrationFormType as BaseRegistrationFormType; | ||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
'label' => 'field.default.lastname', | 'label' => 'field.default.lastname', | ||||
'translation_domain' => 'lcshop', | 'translation_domain' => 'lcshop', | ||||
]) | ]) | ||||
->add('phone', TextType::class, [ | |||||
'label' => 'field.default.phone', | |||||
'translation_domain' => 'lcshop', | |||||
]) | |||||
->add('subscribeNewsletter', CheckboxType::class, [ | ->add('subscribeNewsletter', CheckboxType::class, [ | ||||
'label' => 'field.default.subscribeNewsletter', | 'label' => 'field.default.subscribeNewsletter', | ||||
'required' => false, | 'required' => false, |
<?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 | |||||
]); | |||||
} | |||||
} |
<?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 | |||||
]); | |||||
} | |||||
} |
<?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' | |||||
]); | |||||
} | |||||
} |
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Gedmo\Mapping\Annotation as Gedmo; | use Gedmo\Mapping\Annotation as Gedmo; | ||||
use Lc\ShopBundle\Context\SeoInterface; | |||||
use Lc\ShopBundle\Context\SluggableInterface; | use Lc\ShopBundle\Context\SluggableInterface; | ||||
use Lc\ShopBundle\Context\SortableInterface; | use Lc\ShopBundle\Context\SortableInterface; | ||||
use Lc\ShopBundle\Context\StatusInterface; | use Lc\ShopBundle\Context\StatusInterface; | ||||
* @ORM\MappedSuperclass | * @ORM\MappedSuperclass | ||||
* @Vich\Uploadable | * @Vich\Uploadable | ||||
*/ | */ | ||||
abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface, SluggableInterface | |||||
abstract class AbstractDocumentEntity extends AbstractEntity implements StatusInterface, SortableInterface, SluggableInterface, SeoInterface | |||||
{ | { | ||||
use SortableTrait; | use SortableTrait; | ||||
use SluggableTrait; | use SluggableTrait; | ||||
use SeoTrait; | |||||
/** | /** | ||||
* @ORM\Column(type="string", length=255) | * @ORM\Column(type="string", length=255) | ||||
*/ | */ | ||||
protected $title; | protected $title; | ||||
/** | /** | ||||
* @ORM\Column(type="text", nullable=true) | * @ORM\Column(type="text", nullable=true) | ||||
*/ | */ | ||||
protected $devAlias; | protected $devAlias; | ||||
public function setImageFile(File $image = null) | public function setImageFile(File $image = null) | ||||
{ | { | ||||
$this->imageFile = $image; | $this->imageFile = $image; | ||||
{ | { | ||||
return $this->imageFile; | return $this->imageFile; | ||||
} | } | ||||
public function getTitle(): ?string | public function getTitle(): ?string | ||||
{ | { | ||||
return $this->title; | return $this->title; | ||||
} | } | ||||
public function getDescription(): ?string | public function getDescription(): ?string | ||||
{ | { | ||||
return $this->description; | return $this->description; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getImage(): ?string | public function getImage(): ?string | ||||
{ | { | ||||
return $this->image; | return $this->image; |
*/ | */ | ||||
protected $updatedBy; | protected $updatedBy; | ||||
public function getCreatedAt(): ?\DateTimeInterface | public function getCreatedAt(): ?\DateTimeInterface | ||||
{ | { | ||||
return $this->createdAt; | return $this->createdAt; |
*/ | */ | ||||
abstract class Address extends AbstractEntity | 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\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="addresses") | ||||
* @ORM\JoinColumn(nullable=true) | * @ORM\JoinColumn(nullable=true) | ||||
protected $tva; | protected $tva; | ||||
/** | /** | ||||
* @ORM\Column(type="string", length=127, nullable=true) | |||||
* @ORM\Column(type="array", nullable=true) | |||||
*/ | */ | ||||
protected $phone; | protected $phone; | ||||
*/ | */ | ||||
protected $deliveryInfos; | protected $deliveryInfos; | ||||
public function __construct() | |||||
{ | |||||
$this->phone = [] ; | |||||
} | |||||
public function __toString() | public function __toString() | ||||
{ | { | ||||
return $this->getTitle() . ' - ' . $this->getZip() . ' ' . $this->getCity(); | return $this->getTitle() . ' - ' . $this->getZip() . ' ' . $this->getCity(); | ||||
return $this->getAddress() . ' - ' . $this->getZip() . ' ' . $this->getCity(); | return $this->getAddress() . ' - ' . $this->getZip() . ' ' . $this->getCity(); | ||||
} | } | ||||
public function getSummary() | |||||
public function getSummary($withTitle = true) | |||||
{ | { | ||||
$html = ''; | $html = ''; | ||||
if ($this->getTitle()) { | |||||
if ($this->getTitle() && $withTitle) { | |||||
$html .= $this->getTitle() . '<br />'; | $html .= $this->getTitle() . '<br />'; | ||||
} | } | ||||
} | } | ||||
if ($this->getPhone()) { | if ($this->getPhone()) { | ||||
$html .= 'Tél. ' . $this->getPhone(); | |||||
foreach($this->getPhone() as $phone) { | |||||
$html .= 'Tél. ' . $phone.'<br />'; | |||||
} | |||||
} | } | ||||
return $html; | return $html; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getPhone(): ?string | |||||
public function getPhone(): ?array | |||||
{ | { | ||||
return $this->phone; | return $this->phone; | ||||
} | } | ||||
public function setPhone(?string $phone): self | |||||
public function setPhone(?array $phone): self | |||||
{ | { | ||||
$this->phone = $phone; | $this->phone = $phone; | ||||
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
namespace Lc\ShopBundle\Model; | 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 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() | * @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; | protected $amount; | ||||
protected $type; | 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; | 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 | public function getType(): ?string | ||||
return $this; | 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; | 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; | 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; | return $this; | ||||
} | } |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
return $this; | return $this; | ||||
} | } | ||||
} | |||||
} |
<?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; | |||||
} |
<?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; | |||||
} | |||||
} |
protected $orderShop; | protected $orderShop; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ProductInterface", inversedBy="orderProducts")) | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\ProductInterface")) | |||||
*/ | */ | ||||
protected $product; | protected $product; | ||||
*/ | */ | ||||
protected $orderProductReductionCatalog; | protected $orderProductReductionCatalog; | ||||
/** | |||||
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderProductRefundInterface", mappedBy="orderProduct", cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $orderProductRefund; | |||||
public function __toString() | public function __toString() | ||||
{ | { | ||||
if($this->getTitle()) { | if($this->getTitle()) { | ||||
return $this; | 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; | |||||
} | |||||
} | } |
<?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; | |||||
} | |||||
} | |||||
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} | |||||
namespace Lc\ShopBundle\Model; | namespace Lc\ShopBundle\Model; | ||||
use App\Entity\Visitor; | |||||
use App\Entity\OrderStatus; | |||||
use Doctrine\Common\Collections\ArrayCollection; | use Doctrine\Common\Collections\ArrayCollection; | ||||
use Doctrine\Common\Collections\Collection; | use Doctrine\Common\Collections\Collection; | ||||
use Gedmo\Mapping\Annotation as Gedmo; | |||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\ShopBundle\Context\DocumentInterface; | |||||
use Lc\ShopBundle\Context\FilterMerchantInterface; | use Lc\ShopBundle\Context\FilterMerchantInterface; | ||||
/** | /** | ||||
*/ | */ | ||||
abstract class OrderShop extends AbstractEntity implements FilterMerchantInterface | abstract class OrderShop extends AbstractEntity implements FilterMerchantInterface | ||||
{ | { | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies") | * @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="productFamilies") | ||||
* @ORM\JoinColumn(nullable=false) | * @ORM\JoinColumn(nullable=false) | ||||
protected $visitor; | protected $visitor; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface", inversedBy="order") | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface") | |||||
*/ | */ | ||||
protected $invoiceAddress; | protected $invoiceAddress; | ||||
/** | |||||
* @ORM\Column(type="text", nullable=true) | |||||
*/ | |||||
protected $invoiceAddressText; | |||||
/** | |||||
* @ORM\Column(type="datetime", nullable=true) | |||||
*/ | |||||
protected $validationDate; | |||||
/** | /** | ||||
* @ORM\Column(type="text", nullable=true) | * @ORM\Column(type="text", nullable=true) | ||||
*/ | */ | ||||
*/ | */ | ||||
protected $orderStatusHistories; | 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) | * @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", mappedBy="orderShop", cascade={"persist", "remove"}, orphanRemoval=true) | ||||
*/ | */ | ||||
protected $orderProducts; | 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() | public function __construct() | ||||
{ | { | ||||
$this->orderStatusHistories = new ArrayCollection(); | $this->orderStatusHistories = new ArrayCollection(); | ||||
$this->orderPayments = new ArrayCollection(); | |||||
$this->orderProducts = new ArrayCollection(); | $this->orderProducts = new ArrayCollection(); | ||||
$this->creditHistories = 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() | 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) | 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 | public function getMerchant(): ?Merchant | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getInvoiceAddressText(): ?string | |||||
{ | |||||
return $this->invoiceAddressText; | |||||
} | |||||
public function setInvoiceAddressText(string $invoiceAddressText): self | |||||
{ | |||||
$this->invoiceAddressText = $invoiceAddressText; | |||||
return $this; | |||||
} | |||||
public function getComment(): ?string | public function getComment(): ?string | ||||
{ | { | ||||
return $this->comment; | return $this->comment; | ||||
return $this; | 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[] | * @return Collection|OrderProduct[] | ||||
*/ | */ | ||||
return $this; | 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; | 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; | 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; | 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; | 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; | 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 ; | |||||
} | |||||
} | } |
<?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; | |||||
} | |||||
} |
namespace Lc\ShopBundle\Model; | namespace Lc\ShopBundle\Model; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Gedmo\Mapping\Annotation as Gedmo; | |||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
protected $orderShop; | protected $orderShop; | ||||
/** | /** | ||||
* @ORM\Column(type="string", length=31) | |||||
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderStatusInterface") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | */ | ||||
protected $orderStatus; | protected $orderStatus; | ||||
*/ | */ | ||||
protected $origin; | 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 | public function getOrderShop(): ?OrderShop | ||||
{ | { | ||||
return $this->orderShop; | return $this->orderShop; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getOrderStatus(): ?string | |||||
public function getOrderStatus(): ?OrderStatus | |||||
{ | { | ||||
return $this->orderStatus; | return $this->orderStatus; | ||||
} | } | ||||
public function setOrderStatus(string $orderStatus): self | |||||
public function setOrderStatus(?OrderStatus $orderStatus): self | |||||
{ | { | ||||
$this->orderStatus = $orderStatus; | $this->orderStatus = $orderStatus; | ||||