Browse Source

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

feature/export_comptable
Guillaume 4 years ago
parent
commit
c6292ff14d
6 changed files with 66 additions and 4 deletions
  1. +57
    -0
      ShopBundle/Form/Backend/ReductionCart/AppliedToType.php
  2. +3
    -1
      ShopBundle/Form/Backend/ReductionCommon/UnitType.php
  3. +2
    -0
      ShopBundle/Model/ReductionCredit.php
  4. +2
    -2
      ShopBundle/Resources/translations/lcshop.fr.yaml
  5. +1
    -1
      ShopBundle/Resources/views/backend/reductioncart/panel_actions.html.twig
  6. +1
    -0
      ShopBundle/Services/Price/OrderShopPriceUtils.php

+ 57
- 0
ShopBundle/Form/Backend/ReductionCart/AppliedToType.php View File

<?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',
]);
}
}

+ 3
- 1
ShopBundle/Form/Backend/ReductionCommon/UnitType.php View File

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


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

+ 2
- 0
ShopBundle/Model/ReductionCredit.php View File

protected $merchant; protected $merchant;





public function __construct() public function __construct()
{ {
$this->users = new ArrayCollection(); $this->users = new ArrayCollection();
$this->unit = 'amount';
} }


public function __toString() public function __toString()

+ 2
- 2
ShopBundle/Resources/translations/lcshop.fr.yaml View File

appliedTo: Appliquer aux appliedTo: Appliquer aux
freeShipping: Frais de livraisons offert freeShipping: Frais de livraisons offert
appliedToOptions: appliedToOptions:
order: Montant de la commandes
shipping: Frais de livraisons
order-products: Montant de la commande
delivery: Frais de livraisons
unit: Unité unit: Unité
Address: Address:
city: Commune city: Commune

+ 1
- 1
ShopBundle/Resources/views/backend/reductioncart/panel_actions.html.twig View File

<div class="col-12"> <div class="col-12">
{{ form_row(form.appliedTo, {"attr" :{"v-model" : 'reductionAppliedTo'}}) }} {{ form_row(form.appliedTo, {"attr" :{"v-model" : 'reductionAppliedTo'}}) }}
</div> </div>
<div class="col-12" v-show="reductionAppliedTo != 'shipping'">
<div class="col-12" v-show="reductionAppliedTo != 'delivery'">
{{ form_row(form.freeShipping) }} {{ form_row(form.freeShipping) }}
</div> </div>
{{ macros.fieldReductionUnit(form) }} {{ macros.fieldReductionUnit(form) }}

+ 1
- 0
ShopBundle/Services/Price/OrderShopPriceUtils.php View File

{ {
$amount =0; $amount =0;
if($orderReductionCart->getAppliedTo() === ReductionCart::APPLIED_TO_ORDER_PRODUCTS) { if($orderReductionCart->getAppliedTo() === ReductionCart::APPLIED_TO_ORDER_PRODUCTS) {

if ($orderReductionCart->getUnit() == 'percent') { if ($orderReductionCart->getUnit() == 'percent') {
$amount = $this->amountReductionByPercentValue( $amount = $this->amountReductionByPercentValue(
$this->getTotalOrderProducts($order), $this->getTotalOrderProducts($order),

Loading…
Cancel
Save