@@ -23,6 +23,7 @@ class AdminController extends EasyAdminController | |||
public function persistEntity($entity) | |||
{ | |||
if (method_exists($entity, 'setCreatedAt')) { | |||
$entity->setCreatedAt(new \DateTime()); | |||
} | |||
@@ -31,12 +32,21 @@ class AdminController extends EasyAdminController | |||
$entity->setCreatedBy($this->security->getUser()); | |||
} | |||
if (method_exists($entity, 'getAddress') | |||
&& method_exists($entity->getAddress(), 'setCreatedBy')) { | |||
$entity->getAddress()->setCreatedBy($this->security->getUser()); | |||
} | |||
$this->setUpdated($entity) ; | |||
if (method_exists($entity, 'setPosition')) { | |||
$entity->setPosition(0) ; | |||
} | |||
if (method_exists($entity, 'setStatus')) { | |||
$entity->setStatus(1) ; | |||
} | |||
parent::persistEntity($entity); | |||
} | |||
@@ -49,6 +59,12 @@ class AdminController extends EasyAdminController | |||
if (method_exists($entity, 'setUpdatedAt')) { | |||
$entity->setUpdatedBy($this->security->getUser()); | |||
} | |||
if (method_exists($entity, 'getAddress') | |||
&& method_exists($entity->getAddress(), 'setUpdatedBy')) { | |||
$entity->getAddress()->setUpdatedBy($this->security->getUser()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,69 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Form; | |||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; | |||
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 AddressType extends AbstractType | |||
{ | |||
protected $em; | |||
protected $security; | |||
public function __construct(EntityManagerInterface $entityManager, Security $security) | |||
{ | |||
$this->em = $entityManager; | |||
$this->security = $security ; | |||
} | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder | |||
->add('title', TextType::class, ['label' => 'Titre']) | |||
->add('type', ChoiceType::class, [ | |||
'label' => 'Type', | |||
'choices' => [ | |||
'--' => '', | |||
'Particulier' => 'individual', | |||
'Personne morale' => 'legal-person', | |||
] | |||
]) | |||
->add('civility', ChoiceType::class, [ | |||
'label' => 'Civilité', | |||
'required' => false, | |||
'choices' => [ | |||
'--' => '', | |||
'Femme' => 1, | |||
'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]); | |||
} | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'label' => false, | |||
'data_class' => $this->em->getClassMetadata(AddressInterface::class)->getName(), | |||
'createdBy' => $this->security->getUser(), | |||
'updatedBy' => $this->security->getUser(), | |||
]); | |||
} | |||
} |
@@ -2,28 +2,39 @@ | |||
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 | |||
{ | |||
public function buildForm(FormBuilderInterface $builder, array $options) | |||
{ | |||
$builder | |||
->add('active') | |||
->add('limitAmount') | |||
->add('limitReminder') | |||
->add('behavior') | |||
->add('processOrderCheckedDefault') | |||
; | |||
} | |||
protected $em; | |||
public function configureOptions(OptionsResolver $resolver) | |||
{ | |||
$resolver->setDefaults([ | |||
'data_class' => CreditConfigInterface::class, | |||
]); | |||
} | |||
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(), | |||
]); | |||
} | |||
} |
@@ -9,88 +9,93 @@ use Doctrine\ORM\Mapping as ORM; | |||
*/ | |||
abstract class CreditConfig | |||
{ | |||
/** | |||
* @ORM\Column(type="boolean") | |||
*/ | |||
protected $active; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $limitAmount; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $limitReminder; | |||
/** | |||
* @ORM\Column(type="string", length=31, nullable=true) | |||
*/ | |||
protected $behavior; | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
*/ | |||
protected $processOrderCheckedDefault; | |||
public function getActive(): ?bool | |||
{ | |||
return $this->active; | |||
} | |||
public function setActive(bool $active): self | |||
{ | |||
$this->active = $active; | |||
return $this; | |||
} | |||
public function getLimitAmount(): ?float | |||
{ | |||
return $this->limitAmount; | |||
} | |||
public function setLimitAmount(?float $limitAmount): self | |||
{ | |||
$this->limitAmount = $limitAmount; | |||
return $this; | |||
} | |||
public function getLimitReminder(): ?float | |||
{ | |||
return $this->limitReminder; | |||
} | |||
public function setLimitReminder(?float $limitReminder): self | |||
{ | |||
$this->limitReminder = $limitReminder; | |||
return $this; | |||
} | |||
public function getBehavior(): ?string | |||
{ | |||
return $this->behavior; | |||
} | |||
public function setBehavior(?string $behavior): self | |||
{ | |||
$this->behavior = $behavior; | |||
return $this; | |||
} | |||
public function getProcessOrderCheckedDefault(): ?bool | |||
{ | |||
return $this->processOrderCheckedDefault; | |||
} | |||
public function setProcessOrderCheckedDefault(?bool $processOrderCheckedDefault): self | |||
{ | |||
$this->processOrderCheckedDefault = $processOrderCheckedDefault; | |||
return $this; | |||
} | |||
/** | |||
* @ORM\Column(type="boolean") | |||
*/ | |||
protected $active; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $limitAmount; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $limitReminder; | |||
/** | |||
* @ORM\Column(type="string", length=31, nullable=true) | |||
*/ | |||
protected $behavior; | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
*/ | |||
protected $processOrderCheckedDefault; | |||
public function __toString() | |||
{ | |||
return '' ; | |||
} | |||
public function getActive(): ?bool | |||
{ | |||
return $this->active; | |||
} | |||
public function setActive(bool $active): self | |||
{ | |||
$this->active = $active; | |||
return $this; | |||
} | |||
public function getLimitAmount(): ?float | |||
{ | |||
return $this->limitAmount; | |||
} | |||
public function setLimitAmount(?float $limitAmount): self | |||
{ | |||
$this->limitAmount = $limitAmount; | |||
return $this; | |||
} | |||
public function getLimitReminder(): ?float | |||
{ | |||
return $this->limitReminder; | |||
} | |||
public function setLimitReminder(?float $limitReminder): self | |||
{ | |||
$this->limitReminder = $limitReminder; | |||
return $this; | |||
} | |||
public function getBehavior(): ?string | |||
{ | |||
return $this->behavior; | |||
} | |||
public function setBehavior(?string $behavior): self | |||
{ | |||
$this->behavior = $behavior; | |||
return $this; | |||
} | |||
public function getProcessOrderCheckedDefault(): ?bool | |||
{ | |||
return $this->processOrderCheckedDefault; | |||
} | |||
public function setProcessOrderCheckedDefault(?bool $processOrderCheckedDefault): self | |||
{ | |||
$this->processOrderCheckedDefault = $processOrderCheckedDefault; | |||
return $this; | |||
} | |||
} |
@@ -13,7 +13,7 @@ abstract class Merchant extends AbstractDocumentEntity | |||
{ | |||
/** | |||
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\CreditConfigInterface", cascade={"persist", "remove"}) | |||
* @ORM\JoinColumn(nullable=false) | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $creditConfig; | |||
@@ -40,7 +40,7 @@ abstract class Merchant extends AbstractDocumentEntity | |||
/** | |||
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\AddressInterface", inversedBy="merchant", cascade={"persist", "remove"}) | |||
* @ORM\JoinColumn(nullable=false) | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $address; | |||
@@ -21,6 +21,11 @@ abstract class TaxRate extends AbstractEntity | |||
protected $value; | |||
public function __toString() | |||
{ | |||
return $this->getTitle() ; | |||
} | |||
public function getTitle(): ?string | |||
{ | |||
return $this->title; |