Kaynağa Gözat

Merge branch 'develop'

master
Fabien Normand 2 yıl önce
ebeveyn
işleme
b9eda84d64
15 değiştirilmiş dosya ile 164 ekleme ve 65 silme
  1. +3
    -3
      Builder/File/DocumentBuilder.php
  2. +10
    -1
      Builder/User/UserBuilder.php
  3. +10
    -1
      Container/File/DocumentContainer.php
  4. +1
    -1
      Controller/ControllerTrait.php
  5. +1
    -1
      Controller/Section/SwitchSectionAdminController.php
  6. +62
    -28
      Form/Section/SwitchSectionFormType.php
  7. +1
    -2
      Generator/DocumentReferenceGenerator.php
  8. +17
    -0
      Repository/File/DocumentRepositoryQuery.php
  9. +18
    -1
      Repository/File/DocumentStore.php
  10. +4
    -0
      Repository/Reduction/ReductionCatalogRepositoryQuery.php
  11. +10
    -0
      Resources/translations/admin.fr.yaml
  12. +5
    -3
      Resources/views/admin/order/field/order_payment.html.twig
  13. +14
    -16
      Resources/views/adminlte/layout.html.twig
  14. +6
    -5
      Transformer/Order/OrderShopTransformer.php
  15. +2
    -3
      Twig/FormTwigExtension.php

+ 3
- 3
Builder/File/DocumentBuilder.php Dosyayı Görüntüle

@@ -3,7 +3,6 @@
namespace Lc\CaracoleBundle\Builder\File;

use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Generator\DocumentReferenceGenerator;
use Lc\CaracoleBundle\Solver\Address\AddressSolver;
@@ -23,8 +22,9 @@ class DocumentBuilder
{
$merchantAddress = $orderShop->getSection()->getMerchant()->getAddress();
$buyerAddress = $orderShop->getInvoiceAddress();
//TODO a discuter, doit on garder le lien avec merchant pr la référence ou le mettre par section ? Est-ce que le nom de cette fonction est approprié. on fait une invoice et ça s'appele initFromOrderShop
$document->setReference($this->documentReferenceGenerator->buildReference($orderShop->getSection()->getMerchant(), $document->getType())) ;

// @TODO a discuter, doit on garder le lien avec merchant pr la référence ou le mettre par section ? Est-ce que le nom de cette fonction est approprié. on fait une invoice et ça s'appele initFromOrderShop
$document->setReference($this->documentReferenceGenerator->buildReference($orderShop->getSection()->getMerchant(), $document->getType(), $orderShop)) ;

$document->setMerchantAddress($merchantAddress);
$document->setBuyerAddress($buyerAddress);

+ 10
- 1
Builder/User/UserBuilder.php Dosyayı Görüntüle

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Builder\User;

use Lc\CaracoleBundle\Factory\User\UserPointSaleFactory;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Builder\User\UserBuilder as SovUserBuilder;
@@ -11,7 +12,7 @@ class UserBuilder extends SovUserBuilder
{

// linkUserToPointSale
public function linkToPointSale(UserInterface $user, PointSaleInterface $pointSale):bool
public function linkToPointSale(UserInterface $user, PointSaleInterface $pointSale): bool
{
if (!$this->userSolver->isLinkedToPointSale($user, $pointSale)) {
$userPointSaleFactory = new UserPointSaleFactory();
@@ -25,5 +26,13 @@ class UserBuilder extends SovUserBuilder

return false;
}

public function setFavoriteMerchant(UserInterface $user, MerchantInterface $merchant)
{
$user->setFavoriteMerchant($merchant);
$this->entityManager->update($user);
$this->entityManager->flush();
return true;
}
}


+ 10
- 1
Container/File/DocumentContainer.php Dosyayı Görüntüle

@@ -3,6 +3,7 @@
namespace Lc\CaracoleBundle\Container\File;

use Lc\CaracoleBundle\Factory\File\DocumentFactory;
use Lc\CaracoleBundle\Generator\DocumentReferenceGenerator;
use Lc\CaracoleBundle\Repository\File\DocumentRepositoryQuery;
use Lc\CaracoleBundle\Repository\File\DocumentStore;

@@ -11,15 +12,18 @@ class DocumentContainer
protected DocumentFactory $factory;
protected DocumentRepositoryQuery $repositoryQuery;
protected DocumentStore $store;
protected DocumentReferenceGenerator $referenceGenerator;

public function __construct(
DocumentFactory $factory,
DocumentRepositoryQuery $repositoryQuery,
DocumentStore $store
DocumentStore $store,
DocumentReferenceGenerator $referenceGenerator
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->referenceGenerator = $referenceGenerator;
}

public function getFactory(): DocumentFactory
@@ -38,4 +42,9 @@ class DocumentContainer

return $this->store;
}

public function getReferenceGenerator(): DocumentReferenceGenerator
{
return $this->referenceGenerator;
}
}

+ 1
- 1
Controller/ControllerTrait.php Dosyayı Görüntüle

@@ -51,7 +51,7 @@ use Symfony\Component\Security\Core\Security;

trait ControllerTrait
{
public static function getSubscribedServices()
public static function getSubscribedServices() :array
{
return array_merge(
parent::getSubscribedServices(),

+ 1
- 1
Controller/Section/SwitchSectionAdminController.php Dosyayı Görüntüle

@@ -30,7 +30,7 @@ class SwitchSectionAdminController extends AbstractController

// valeur par défaut de $section : Tout afficher
$section = null;
$idSection = $form->get('id_section')->getData();
$idSection = $form->getClickedButton()->getConfig()->getOptions()['attr']['value'];
$userMerchant = $merchantResolver->getUserMerchant();

if($userMerchant) {

+ 62
- 28
Form/Section/SwitchSectionFormType.php Dosyayı Görüntüle

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

namespace Lc\CaracoleBundle\Form\Section;

use App\Repository\Section\SectionStore;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
@@ -20,53 +21,86 @@ use Symfony\Component\OptionsResolver\OptionsResolver;

class SwitchSectionFormType extends AbstractType
{
protected EntityManager $em;
protected TranslatorAdmin $translatorAdmin;
protected SectionStore $sectionStore;
protected SectionResolver $sectionResolver;
protected MerchantResolver $merchantResolver;
protected SectionSolver $sectionSolver;

public function __construct(
EntityManager $em,
TranslatorAdmin $translatorAdmin,
SectionResolver $sectionResolver,
SectionSolver $sectionSolver
) {
$this->em = $em;
TranslatorAdmin $translatorAdmin,
SectionStore $sectionStore,
SectionResolver $sectionResolver,
MerchantResolver $merchantResolver,
SectionSolver $sectionSolver
)
{
$this->translatorAdmin = $translatorAdmin;
$this->sectionResolver = $sectionResolver;
$this->sectionStore = $sectionStore;
$this->merchantResolver = $merchantResolver;
$this->sectionSolver = $sectionSolver;
}

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



// $builder->add(
// 'id_section',
// HiddenType::class,
// [
// 'data' => $section ? $section->getId() : null
// ]
// );




$currentSection = $this->sectionResolver->getCurrent();
$sections = $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOnline();

$styleButton = '';
$classButton = 'btn-section';
if (null == $currentSection) {
$classButton .= ' btn-section-current ' . $this->sectionSolver->getHtmlClass($currentSection);
}
//TOUT afficher
$builder->add(
'id_section',
HiddenType::class,
[
'data' => $section ? $section->getId() : null
'switch_all',
SubmitType::class,
[
'label' => 'Tout afficher',
'attr' => [
'class' => $classButton,
'style' => $styleButton,
'value' => null,
]
]
);

$styleButton = '';
$classButton = 'btn-section';
if ($section == $currentSection) {
$classButton .= ' btn-section-current '.$this->sectionSolver->getHtmlClass($currentSection);
}

$builder->add(
'submit',
foreach ($sections as $section) {
$styleButton = '';
$classButton = 'btn-section';
if ($section == $currentSection) {
$classButton .= ' btn-section-current ' . $this->sectionSolver->getHtmlClass($currentSection);
}

$builder->add(
'switch_'.$section->getSlug(),
SubmitType::class,
[
'label' => $section ? $section->getTitle() : 'Tout afficher',
'attr' => [
'class' => $classButton,
'style' => $styleButton,
]
'label' => $section->getTitle(),
'attr' => [
'class' => $classButton,
'style' => $styleButton,
'value' => $section->getId(),
]
]
);
);
}
}

/**
@@ -75,9 +109,9 @@ class SwitchSectionFormType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'section' => null,
]
[
'section' => null,
]
);
}


+ 1
- 2
Generator/DocumentReferenceGenerator.php Dosyayı Görüntüle

@@ -11,7 +11,6 @@ use Lc\CaracoleBundle\Repository\File\DocumentStore;

class DocumentReferenceGenerator
{

protected DocumentStore $documentStore;

public function __construct(DocumentStore $documentStore)
@@ -19,7 +18,7 @@ class DocumentReferenceGenerator
$this->documentStore = $documentStore;
}

public function buildReference(MerchantInterface $merchant, string $documentType)
public function buildReference(MerchantInterface $merchant, string $documentType, OrderShopInterface $orderShop = null)
{
$prefix = '';
if ($documentType == DocumentModel::TYPE_DELIVERY_NOTE) {

+ 17
- 0
Repository/File/DocumentRepositoryQuery.php Dosyayı Görüntüle

@@ -28,4 +28,21 @@ class DocumentRepositoryQuery extends AbstractRepositoryQuery
->andWhere('.buyerAddress = :buyerAddress')
->setParameter('buyerAddress', $buyerAddress);
}

public function filterByReference(string $reference = null)
{
if(is_null($reference)) {
return $this->andWhere('.reference IS NULL');
}
else {
return $this
->andWhere('.reference LIKE :reference')
->setParameter('reference', $reference);
}
}

public function filterIsReferenceNotNull()
{
return $this->andWhere('.reference IS NOT NULL');
}
}

+ 18
- 1
Repository/File/DocumentStore.php Dosyayı Görüntüle

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Repository\File;

use App\Entity\Address\Address;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\CaracoleBundle\Repository\AbstractStore;
@@ -22,7 +23,6 @@ class DocumentStore extends AbstractStore

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->orderBy('id');
return $query;
}

@@ -43,12 +43,29 @@ class DocumentStore extends AbstractStore
return $query;
}

public function getOneByReference(string $reference = null, string $type = null, $query = null)
{
$query = $this->createDefaultQuery($query);

$query
->filterByReference($reference)
->orderBy('createdAt', 'ASC')
->innerJoin('.orderShops', 'orderShops')
;

if(!is_null($type)) {
$query->filterByType($type);
}

return $query->findOne();
}

public function getOneLatestByType(string $documentType, $query = null): DocumentInterface
{
$query = $this->createDefaultQuery($query);

$query
->filterIsReferenceNotNull()
->filterByType($documentType)
->orderBy('createdAt', 'DESC');


+ 4
- 0
Repository/Reduction/ReductionCatalogRepositoryQuery.php Dosyayı Görüntüle

@@ -158,5 +158,9 @@ class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery
->setParameter('productCategory', $productCategories);
}

public function filterIsNotLinkToProductFamily()
{
return $this->andWhere('.productFamily is null');
}

}

+ 10
- 0
Resources/translations/admin.fr.yaml Dosyayı Görüntüle

@@ -172,6 +172,16 @@ entity:
error:
saveCreditHistory: Une erreur est survenue à l'ajout de crédit/débit
OrderShop:
modals:
sendPaymentLink: Envoyer le lien de paiement
changeOrderStatus: Modifier le statut de commande
invoiceAddress: Modifier l'adresse de facturation
deliveryAddress: Modifier l'adresse de livraison
addOrderProduct: Ajouter un produit
addReductionCart: Ajouter une réduction panier
addReductionCredit: Ajouter un avoir
orderPayment: Ajouter un paiement
orderStatusHistories: Historique des changements de statuts
fields:
deliveryInfos: |
Merci de nous laisser le maximum d'informations pour faciliter notre arrivée : digicode,

+ 5
- 3
Resources/views/admin/order/field/order_payment.html.twig Dosyayı Görüntüle

@@ -1,9 +1,11 @@
{% set value = field.value %}
{% set item = entity.instance %}
{% for val in value %}
<span class="badge badge-success">
{{ val.meanPayment|sov_trans_admin_choice('meanPayment', 'OrderPayment') }}
</span>
{% if val.meanPayment %}
<span class="badge badge-success">
{{ val.meanPayment|sov_trans_admin_choice('meanPayment', 'OrderPayment') }}
</span>
{% endif %}
{% endfor %}

{% set is_paid = order_shop_container.resolver.isPaid(item) %}

+ 14
- 16
Resources/views/adminlte/layout.html.twig Dosyayı Görüntüle

@@ -8,18 +8,10 @@

<nav class="carac navbar navbar-expand navbar-light main-header{% if is_display_switch_section %} display-section-switch {{ section_container.solver.getHtmlClass(section_current()) }}{% endif %}">

{% if is_display_switch_section %}
<ul class="navbar-nav left">
<li class="nav-item d-none d-sm-inline-block">
{{ _self.form_switch_section(null) }}
</li>
{% for section in carac_sections() %}
<li class="nav-item d-none d-sm-inline-block">
{{ _self.form_switch_section(section) }}
</li>
{% endfor %}
</ul>
{% endif %}
{% if is_display_switch_section %}
{{ _self.form_switch_section() }}
{% endif %}

<ul class="navbar-nav ml-auto right">
<li class="nav-item nav-switch-merchant">
<i class="fa fa-store"></i>
@@ -47,14 +39,20 @@

{% if(user.favoriteMerchant != merchant_current) %}
{# modal affichée uniquement si la sessionStorage.visit_merchant n'est pas défini (js) #}
{% include '@LcCaracole/admin/merchant/modal/switch_merchant.html.twig' %}
{% include '@LcCaracole/admin/merchant/modal/switch_merchant.html.twig' %}
{% endif %}
{% endblock %}

{% macro form_switch_section(section) %}
{% set form_switch_section = carac_form_switch_section(section) %}
{% macro form_switch_section() %}
{% set form_switch_section = carac_form_switch_section() %}
{% form_theme form_switch_section '@LcSov/adminlte/crud/form_theme.html.twig' %}
{{ form_start(form_switch_section) }}
{{ form(form_switch_section) }}
<ul class="navbar-nav left">
{% for field in form_switch_section %}
<li class="nav-item d-none d-sm-inline-block">
{{ form_row(field) }}
</li>
{% endfor %}
</ul>
{{ form_end(form_switch_section) }}
{% endmacro %}

+ 6
- 5
Transformer/Order/OrderShopTransformer.php Dosyayı Görüntüle

@@ -112,11 +112,12 @@ class OrderShopTransformer
'orderReference' => $order->getReference(),
'comment' => $orderPayment->getComment(),
'meanPayment' => $orderPayment->getMeanPayment(),
'meanPaymentText' => $this->translatorAdmin->transChoice(
'OrderPayment',
'meanPayment',
$orderPayment->getMeanPayment()
),
'meanPaymentText' => $orderPayment->getMeanPayment() ?
$this->translatorAdmin->transChoice(
'OrderPayment',
'meanPayment',
$orderPayment->getMeanPayment()
) : '',
'paidAtText' => $orderPayment->getPaidAt()->format('d/m/Y'),
'paidAt' => $orderPayment->getPaidAt()->format('Y-m-d'),
'amount' => $orderPayment->getAmount(),

+ 2
- 3
Twig/FormTwigExtension.php Dosyayı Görüntüle

@@ -45,15 +45,14 @@ class FormTwigExtension extends AbstractExtension
return $form->createView();
}

public function getFormSwitchSection($section)
public function getFormSwitchSection()
{
$form = $this->formFactory->create(
SwitchSectionFormType::class,
null,
[
'action' => $this->urlGenerator->generate('admin_section_switch'),
'attr' => ['class' => 'switch-section'],
'section' => $section,
'attr' => ['class' => 'switch-section']
]
);
return $form->createView();

Yükleniyor…
İptal
Kaydet