Fabien Normand преди 3 години
родител
ревизия
6e93358ae0
променени са 6 файла, в които са добавени 93 реда и са изтрити 37 реда
  1. +2
    -1
      Definition/Field/Order/OrderShopFieldDefinition.php
  2. +66
    -36
      Definition/Field/User/UserFieldDefinition.php
  3. +4
    -0
      Resources/translations/admin.fr.yaml
  4. +1
    -0
      Resources/views/admin/order/field/delivery_type.html.twig
  5. +12
    -0
      Resources/views/admin/user/field/count_order.html.twig
  6. +8
    -0
      Resources/views/admin/user/field/total_spent.html.twig

+ 2
- 1
Definition/Field/Order/OrderShopFieldDefinition.php Целия файл

@@ -71,7 +71,8 @@ class OrderShopFieldDefinition extends AbstractFieldDefinition
->setCustomOption('filter_on', 'cycleNumber'),
'cycleDeliveryId' => IntegerField::new('cycleDeliveryId')->setSortable(true),
'cycleId' => IntegerField::new('cycleId')->setSortable(true),
'deliveryType' => Field::new('deliveryType')->setSortable(true)
'deliveryType' => TextField::new('deliveryType')->setSortable(true)
->setTemplatePath('@LcCaracole/admin/order/field/delivery_type.html.twig')
->setCustomOption('filter_fqcn', OrderShopOrderDeliveryTypeFilter::class),
//->setTemplatePath('@LcShop/backend/default/field/options_translatable.html.twig'),
'reference' => TextField::new('reference')->setSortable(true),

+ 66
- 36
Definition/Field/User/UserFieldDefinition.php Целия файл

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

use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Field\AssociationField;
use Lc\CaracoleBundle\Repository\Newsletter\NewsletterStore;
@@ -22,27 +23,46 @@ class UserFieldDefinition extends SovUserFieldDefinition
protected GroupUserStore $groupUserStore;
protected NewsletterStore $newsletterStore;

public function __construct(TranslatorAdmin $translatorAdmin, RolesDefinition $rolesDefinition, GroupUserStore $groupUserStore, NewsletterStore $newsletterStore)
{
public function __construct(
TranslatorAdmin $translatorAdmin,
RolesDefinition $rolesDefinition,
GroupUserStore $groupUserStore,
NewsletterStore $newsletterStore
) {
parent::__construct($translatorAdmin, $rolesDefinition);

$this->groupUserStore = $groupUserStore;
$this->newsletterStore = $newsletterStore;
}

public function configureIndex(): array
{
return [
'id',
'gender',
'lastname',
'firstname',
'email',
'groupUsers',
'birthdate',
'countOrder',
'totalSpent',
];
}

public function configureForm(): array
{
return [
'gender',
'lastname',
'firstname',
'email',
'phone',
'birthdate',
'groupUsers',
'isSaleAlwaysOpen',
'newsletters',
'ticketTypesNotification'
'gender',
'lastname',
'firstname',
'email',
'phone',
'birthdate',
'groupUsers',
'isSaleAlwaysOpen',
'newsletters',
'ticketTypesNotification',
];
}

@@ -51,30 +71,40 @@ class UserFieldDefinition extends SovUserFieldDefinition
$groupUsers = $this->groupUserStore->setMerchant($this->merchant)->getAll();
$newsletters = $this->newsletterStore->getAll();

return array_merge(parent::configureFields(),[
'isSaleAlwaysOpen' => BooleanField::new('isSaleAlwaysOpen'),
'newsletters' => AssociationField::new('newsletters')
->setFormTypeOption('choices', $newsletters)
->setFormTypeOption('choice_label', function ($choice) {
return $choice->getTitle(). '['.$choice->getSection()->getMerchant().']';
})
->setSortable(true),
'groupUsers' => AssociationField::new('groupUsers')
->setFormTypeOption('choices', $groupUsers)
->setFormTypeOption('choice_label', function ($choice) {
return $choice->getTitle(). '['.$choice->getMerchant().']';
})
->setSortable(true),
'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification')
->setSortable(true)
->setFormTypeOption('expanded', false)
->setFormTypeOption('multiple', true)
->setChoices($this->translatorAdmin->transChoices(
TicketSolver::getTypeChoices(),
'Ticket',
'type'
)),

return array_merge(parent::configureFields(), [
'isSaleAlwaysOpen' => BooleanField::new('isSaleAlwaysOpen'),
'newsletters' => AssociationField::new('newsletters')
->setFormTypeOption('choices', $newsletters)
->setFormTypeOption('choice_label', function ($choice) {
return $choice->getTitle() . '[' . $choice->getSection()->getMerchant() . ']';
})
->setSortable(true),
'groupUsers' => AssociationField::new('groupUsers')
->setFormTypeOption('choices', $groupUsers)
->setTemplatePath('@LcSov/adminlte/crud/field/association_many.html.twig')
->setFormTypeOption('choice_label', function ($choice) {
return $choice->getTitle() . '[' . $choice->getMerchant() . ']';
})
->setSortable(true),
'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification')
->setSortable(true)
->setFormTypeOption('expanded', false)
->setFormTypeOption('multiple', true)
->setChoices(
$this->translatorAdmin->transChoices(
TicketSolver::getTypeChoices(),
'Ticket',
'type'
)
),
'countOrder' => NumberField::new('countOrder')
->setFormTypeOption('mapped', false)
->setCustomOption('filter', false)
->setTemplatePath('@LcCaracole/admin/user/field/count_order.html.twig'),
'totalSpent' => NumberField::new('totalSpent')
->setFormTypeOption('mapped', false)
->setCustomOption('filter', false)
->setTemplatePath('@LcCaracole/admin/user/field/total_spent.html.twig'),
]);
}


+ 4
- 0
Resources/translations/admin.fr.yaml Целия файл

@@ -28,6 +28,7 @@ action:
editProductFamily: Éditer le produit
history: Historique
credit: Voir l'historique de crédit
switchUser: Prendre la main

setting_definition:
merchant:
@@ -127,6 +128,9 @@ entity:
fields:
isSaleAlwaysOpen: Vente toujours ouverte
newsletters: Newsletter
countOrder: Commandes
totalSpent: Ventes
lastLogin: Dernière connexion
CreditHistory:
label: Historique de compte prépayé
label_plurial: Historiques de compte prépayé

+ 1
- 0
Resources/views/admin/order/field/delivery_type.html.twig Целия файл

@@ -0,0 +1 @@
{{ field.value|sov_trans_admin_choice('deliveryType', 'OrderShop') }}

+ 12
- 0
Resources/views/admin/user/field/count_order.html.twig Целия файл

@@ -0,0 +1,12 @@
{% set order_store = order_shop_container.store.setSection(section_current()).setMerchant(merchant_current()) %}
{% set totalOrder = order_store.countValidByUserAllMerchant(entity.instance) %}
{% if totalOrder > 0 %}
<span class="badge badge-success">
{{ totalOrder }} commandes
</span>
{% else %}
<span class="badge badge-secondary">
0 commandes
</span>
{% endif %}


+ 8
- 0
Resources/views/admin/user/field/total_spent.html.twig Целия файл

@@ -0,0 +1,8 @@
{% set order_store = order_shop_container.store.setSection(section_current()).setMerchant(merchant_current()) %}
{% set totalSpent = order_store.getTotalSpentByUser(entity.instance) %}
{# {% set totalSpent = orderUtils.getTotalSpentByUser(entity.instance) %} #}
{% if totalSpent > 0 %}
<span class="badge badge-primary"> {{ totalSpent|format_price(false) }}</span>
{% else %}
<span class="badge badge-secondary"> {{ totalSpent|format_price(false) }}</span>
{% endif %}

Loading…
Отказ
Запис