Browse Source

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/LcShopBundle into develop

# Conflicts:
#	ShopBundle/Services/ProductFamilyUtils.php
feature/export_comptable
Guillaume 4 years ago
parent
commit
f2271c2e0c
14 changed files with 235 additions and 136 deletions
  1. +10
    -0
      ShopBundle/Context/SeoInterface.php
  2. +48
    -25
      ShopBundle/Controller/Backend/AdminController.php
  3. +3
    -0
      ShopBundle/Form/Backend/Common/AddressType.php
  4. +4
    -47
      ShopBundle/Model/AbstractDocumentEntity.php
  5. +3
    -3
      ShopBundle/Model/Address.php
  6. +1
    -1
      ShopBundle/Model/OrderShop.php
  7. +1
    -1
      ShopBundle/Model/ProductCategory.php
  8. +78
    -7
      ShopBundle/Model/ProductFamily.php
  9. +63
    -0
      ShopBundle/Model/SeoTrait.php
  10. +1
    -0
      ShopBundle/Repository/OrderShopRepository.php
  11. +11
    -0
      ShopBundle/Resources/views/backend/default/block/macros.html.twig
  12. +10
    -51
      ShopBundle/Resources/views/backend/productfamily/panel_property.html.twig
  13. +1
    -0
      ShopBundle/Services/OrderUtils.php
  14. +1
    -1
      ShopBundle/Services/ProductFamilyUtils.php

+ 10
- 0
ShopBundle/Context/SeoInterface.php View File

<?php

namespace Lc\ShopBundle\Context;

interface SeoInterface
{



}

+ 48
- 25
ShopBundle/Controller/Backend/AdminController.php View File

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\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 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;
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; protected $translator;


public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils,
$this->userManager = $userManager; $this->userManager = $userManager;
$this->em = $em; $this->em = $em;
$this->utils = $utils; $this->utils = $utils;
$this->merchantUtils = $merchantUtils ;
$this->mailjetTransport = $mailjetTransport ;
$this->orderUtils = $orderUtils ;
$this->merchantUtils = $merchantUtils;
$this->mailjetTransport = $mailjetTransport;
$this->orderUtils = $orderUtils;
$this->translator = $translator; $this->translator = $translator;
} }


} }





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;


) )
); );
} }
}else{
} else {
$subChildrens = $child->all(); $subChildrens = $child->all();
if(count($subChildrens)){
if (count($subChildrens)) {
$this->loopFormField($child, $subChildrens); $this->loopFormField($child, $subChildrens);
} }
} }

+ 3
- 0
ShopBundle/Form/Backend/Common/AddressType.php View File

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


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;
'Homme' => 0, 'Homme' => 0,
], ],
]) ])

->add('lastname', TextType::class, ['required' => false]) ->add('lastname', TextType::class, ['required' => false])
->add('firstname', TextType::class, ['required' => false]) ->add('firstname', TextType::class, ['required' => false])
->add('address', TextareaType::class) ->add('address', TextareaType::class)
->add('company', TextType::class, ['required' => false]) ->add('company', TextType::class, ['required' => false])
->add('siret', TextType::class, ['required' => false]) ->add('siret', TextType::class, ['required' => false])
->add('tva', TextType::class, ['required' => false]); ->add('tva', TextType::class, ['required' => false]);

} }


public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)

+ 4
- 47
ShopBundle/Model/AbstractDocumentEntity.php View File



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 $devAlias; protected $devAlias;


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


/**
* @var array
* @ORM\Column(name="old_url", type="array", nullable=true)
*/
private $oldUrl;




public function setImageFile(File $image = null) public function setImageFile(File $image = null)
} }




/**
* Set oldUrl
*
* @param array $oldUrl
*
* @return AbstractEntity
*/
public function setOldUrl($oldUrl)
{
$this->oldUrl = $oldUrl;

return $this;
}

/**
* Get oldUrl
*
* @return array
*/
public function getOldUrl()
{
return $this->oldUrl;
}


public function getMetaDescription(): ?string
{
return $this->metaDescription;
}

public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;

return $this;
}

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

+ 3
- 3
ShopBundle/Model/Address.php View File

protected $tva; protected $tva;


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


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;



+ 1
- 1
ShopBundle/Model/OrderShop.php View File

protected $visitor; protected $visitor;


/** /**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface", inversedBy="order")
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface")
*/ */
protected $invoiceAddress; protected $invoiceAddress;



+ 1
- 1
ShopBundle/Model/ProductCategory.php View File

protected $parent; protected $parent;


/** /**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", mappedBy="parent")
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", mappedBy="parent" , fetch="EAGER"))
*/ */
protected $childrens; protected $childrens;



+ 78
- 7
ShopBundle/Model/ProductFamily.php View File

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


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


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

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

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


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

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


/** /**
* @ORM\Column(type="string", length=255, nullable=true) * @ORM\Column(type="string", length=255, nullable=true)
} }




public function getPropertyWeightQuantity(): ?string
public function getPropertyWeight(): ?string
{ {
return $this->propertyWeightQuantity;
return $this->propertyWeight;
} }


public function setPropertyWeightQuantity(?string $propertyWeightQuantity): self
public function setPropertyWeight(?string $propertyWeight): self
{ {
$this->propertyWeightQuantity = $propertyWeightQuantity;
$this->propertyWeight = $propertyWeight;


return $this; return $this;
} }



public function getPropertyQuantity(): ?string
{
return $this->propertyQuantity;
}

public function setPropertyQuantity(?string $propertyQuantity): self
{
$this->propertyQuantity = $propertyQuantity;

return $this;
}

public function getPropertyVariety(): ?string
{
return $this->propertyVariety;
}

public function setPropertyVariety(?string $propertyVariety): self
{
$this->propertyQuantity = $propertyVariety;

return $this;
}

public function getPropertyFeature(): ?string
{
return $this->propertyFeature;
}

public function setPropertyFeature(?string $propertyFeature): self
{
$this->propertyFeature = $propertyFeature;

return $this;
}

public function getPropertyAlcoholLevel(): ?string
{
return $this->propertyAlcoholLevel;
}

public function setPropertyAlcoholLevel(?string $propertyAlcoholLevel): self
{
$this->propertyAlcoholLevel = $propertyAlcoholLevel;

return $this;
}


public function getPropertyPackaging(): ?string public function getPropertyPackaging(): ?string
{ {
return $this->propertyPackaging; return $this->propertyPackaging;

+ 63
- 0
ShopBundle/Model/SeoTrait.php View File

<?php

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;

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


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


/**
* @var array
* @ORM\Column(type="array", nullable=true)
*/
protected $oldUrls;


public function getMetaTitle(): ?string
{
return $this->metaTitle;
}

public function setMetaTitle(?string $metaTitle): self
{
$this->metaTitle = $metaTitle;

return $this;
}

public function getMetaDescription(): ?string
{
return $this->metaDescription;
}

public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;

return $this;
}

public function setOldUrls($oldUrls): self
{
$this->oldUrls = $oldUrls;

return $this;
}

public function getOldUrls(): ?array
{
return $this->oldUrls;
}
}

+ 1
- 0
ShopBundle/Repository/OrderShopRepository.php View File

} }




//TODO : AJOUTER un champ valid ds orderSTATUS
protected $statusAliasAsValid = array('paid-online', 'paid-by-credit', 'waiting-delivery', 'waiting-delivery-with-payment', 'delivered-without-payment', 'done'); protected $statusAliasAsValid = array('paid-online', 'paid-by-credit', 'waiting-delivery', 'waiting-delivery-with-payment', 'delivered-without-payment', 'done');





+ 11
- 0
ShopBundle/Resources/views/backend/default/block/macros.html.twig View File



{% endmacro %} {% endmacro %}


{% macro autoresizeField(field) %}
<tr>
<td>{{ form_label(field) }}</td>
<td>
<div class="autoresize">
{{ form_widget(field, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
{% endmacro autoresizeField %}

{% macro fieldReductionList(form, field, filterOn = false, filterType='string') %} {% macro fieldReductionList(form, field, filterOn = false, filterType='string') %}
<div class="col-12"> <div class="col-12">
<div class="form-group"> <div class="form-group">

+ 10
- 51
ShopBundle/Resources/views/backend/productfamily/panel_property.html.twig View File

<td>{{ form_widget(form.propertyExpirationDate, {'attr' : {'v-model' : 'propertyExpirationDate'}}) }}</td> <td>{{ form_widget(form.propertyExpirationDate, {'attr' : {'v-model' : 'propertyExpirationDate'}}) }}</td>
</tr> </tr>


<tr>
{#<td>
{{ form_widget(form.propertyAllergensActive, {"label" : false , "attr" : {'v-model' : 'propertyAllergensActive'}}) }}
</td>#}
<td>{{ form_label(form.propertyAllergens) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyAllergens, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>


<tr>
<td>{{ form_label(form.propertyComposition) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyComposition, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
{{ macros.autoresizeField(form.propertyAllergens) }}
{{ macros.autoresizeField(form.propertyComposition) }}
{{ macros.autoresizeField(form.propertyFragrances) }}
{{ macros.autoresizeField(form.propertyQuantity) }}
{{ macros.autoresizeField(form.propertyWeight) }}
{{ macros.autoresizeField(form.propertyCharacteristics) }}
{{ macros.autoresizeField(form.propertyPackaging) }}
{{ macros.autoresizeField(form.propertyAlcoholLevel) }}
{{ macros.autoresizeField(form.propertyVariety) }}
{{ macros.autoresizeField(form.propertyFeature) }}


<tr>
<td>{{ form_label(form.propertyFragrances) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyFragrances, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
<tr>
<td>{{ form_label(form.propertyWeightQuantity) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyWeightQuantity, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
<tr>
<td>{{ form_label(form.propertyCharacteristics) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyCharacteristics, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>
<tr>
<td>{{ form_label(form.propertyPackaging) }}</td>
<td>
<div class="autoresize">
{{ form_widget(form.propertyPackaging, {'attr' : {rows : '1'}}) }}
</div>
</td>
</tr>


</tbody> </tbody>
</table> </table>

+ 1
- 0
ShopBundle/Services/OrderUtils.php View File

} }


public function isReductionCreditAllowToBeAddToOrder($orderShop, $reductionCredit){ public function isReductionCreditAllowToBeAddToOrder($orderShop, $reductionCredit){

if($this->orderShopRepo->getValidOrderWithReductionCredit($reductionCredit, $orderShop->getUser())>0){ if($this->orderShopRepo->getValidOrderWithReductionCredit($reductionCredit, $orderShop->getUser())>0){
return false; return false;
}else{ }else{

+ 1
- 1
ShopBundle/Services/ProductFamilyUtils.php View File

} }
if ($returnSelfIfNotActiveProducts) { if ($returnSelfIfNotActiveProducts) {
return $productFamily; return $productFamily;
}
}
else { else {
return false; return false;
} }

Loading…
Cancel
Save