use Lc\CaracoleBundle\Resolver\MerchantResolver; | use Lc\CaracoleBundle\Resolver\MerchantResolver; | ||||
use Lc\CaracoleBundle\Resolver\SectionResolver; | use Lc\CaracoleBundle\Resolver\SectionResolver; | ||||
use Lc\CaracoleBundle\Definition\SectionSettingDefinitionInterface; | use Lc\CaracoleBundle\Definition\SectionSettingDefinitionInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
protected $merchantSettingDefinition; | protected $merchantSettingDefinition; | ||||
protected $sectionResolver; | protected $sectionResolver; | ||||
protected $sectionSettingDefinition; | protected $sectionSettingDefinition; | ||||
protected $translatorAdmin; | |||||
public function __construct( | public function __construct( | ||||
EntityManagerInterface $em, | EntityManagerInterface $em, | ||||
MerchantResolver $merchantResolver, | MerchantResolver $merchantResolver, | ||||
SectionResolver $sectionResolver, | SectionResolver $sectionResolver, | ||||
MerchantSettingDefinitionInterface $merchantSettingDefinition, | MerchantSettingDefinitionInterface $merchantSettingDefinition, | ||||
SectionSettingDefinitionInterface $sectionSettingDefinition | |||||
SectionSettingDefinitionInterface $sectionSettingDefinition, | |||||
TranslatorAdmin $translatorAdmin | |||||
) { | ) { | ||||
$this->em = $em; | $this->em = $em; | ||||
$this->merchantResolver = $merchantResolver; | $this->merchantResolver = $merchantResolver; | ||||
$this->sectionResolver = $sectionResolver; | $this->sectionResolver = $sectionResolver; | ||||
$this->merchantSettingDefinition = $merchantSettingDefinition; | $this->merchantSettingDefinition = $merchantSettingDefinition; | ||||
$this->sectionSettingDefinition = $sectionSettingDefinition; | $this->sectionSettingDefinition = $sectionSettingDefinition; | ||||
$this->translatorAdmin = $translatorAdmin ; | |||||
} | } | ||||
public function manageMerchant(Request $request) | public function manageMerchant(Request $request) | ||||
$this->em->update($entity); | $this->em->update($entity); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
$this->addFlash('success', 'Paramètres mis à jour'); | |||||
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved')); | |||||
} | } | ||||
return $this->render( | return $this->render( |
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | use Symfony\Bridge\Doctrine\Form\Type\EntityType; | ||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | use Symfony\Component\Form\Extension\Core\Type\CollectionType; | ||||
class MerchantSettingsFormType extends AbstractType | class MerchantSettingsFormType extends AbstractType | ||||
{ | { | ||||
protected $em; | protected $em; | ||||
protected $translatorAdmin; | |||||
public function __construct(EntityManagerInterface $em) | |||||
public function __construct(EntityManagerInterface $em, TranslatorAdmin $translatorAdmin) | |||||
{ | { | ||||
$this->em = $em; | $this->em = $em; | ||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
'by_reference' => false | 'by_reference' => false | ||||
] | ] | ||||
); | ); | ||||
$builder->add('submit', SubmitType::class, [ | |||||
'label' => $this->translatorAdmin->transAction('save'), | |||||
'attr' => [ | |||||
'class' => 'btn btn-primary float-right' | |||||
] | |||||
]) ; | |||||
} | } | ||||
/** | /** |
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | use Symfony\Component\Form\Extension\Core\Type\CollectionType; | ||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | use Symfony\Component\Form\FormBuilderInterface; | ||||
use Symfony\Component\OptionsResolver\OptionsResolver; | use Symfony\Component\OptionsResolver\OptionsResolver; | ||||
class SectionSettingsFormType extends AbstractType | class SectionSettingsFormType extends AbstractType | ||||
{ | { | ||||
protected $em; | protected $em; | ||||
protected $translatorAdmin; | |||||
public function __construct(EntityManagerInterface $em) | |||||
public function __construct(EntityManagerInterface $em, TranslatorAdmin $translatorAdmin) | |||||
{ | { | ||||
$this->em = $em; | $this->em = $em; | ||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
'by_reference' => false | 'by_reference' => false | ||||
] | ] | ||||
); | ); | ||||
$builder->add('submit', SubmitType::class, [ | |||||
'label' => $this->translatorAdmin->transAction('save'), | |||||
'attr' => [ | |||||
'class' => 'btn btn-primary float-right' | |||||
] | |||||
]) ; | |||||
} | } | ||||
/** | /** |
return $this->date; | return $this->date; | ||||
} | } | ||||
public function setDate(\DateTimeInterface $date): self | |||||
public function setDate(?\DateTimeInterface $date): self | |||||
{ | { | ||||
$this->date = $date; | $this->date = $date; | ||||
admin_section: Sections | admin_section: Sections | ||||
admin_tva: TVA | admin_tva: TVA | ||||
flash_message: | |||||
settings_saved: Paramètres mis à jour | |||||
entity: | entity: | ||||
default: | default: | ||||
fields: | fields: |
<div class="card card-outline"> | |||||
<div class="card-header p-0 border-bottom-0"> | |||||
<ul id="nav-params" class="nav nav-pills" role="navigation"> | |||||
{% for index, category in setting_definition.getCategories() %} | |||||
<li class="nav-item"> | |||||
<a href="#panel-{{ category }} " class="nav-link {{ index == 0 ? 'active' }}" | |||||
data-toggle="tab" role="tab" | |||||
aria-controls="panel-{{ category }}"> | |||||
{{ ('setting_definition.'~trans_category~'.categories.'~category)|trans({}, 'admin') }} | |||||
<i class="fa fa-exclamation-circle invalid-form"></i> | |||||
</a> | |||||
</li> | |||||
{% endfor %} | |||||
</ul> | |||||
</div> | |||||
</div> | |||||
{% embed '@LcSov/adminlte/embed/tabs/tabs.html.twig' %} | |||||
{# items menu #} | |||||
{% import '@LcSov/adminlte/macro/tabs.html.twig' as mtabs %} | |||||
{% block menu_items %} | |||||
{% for index, category in setting_definition.getCategories() %} | |||||
{{ mtabs.menu_item(category, loop.first, ('setting_definition.'~trans_category~'.categories.'~category)|trans({}, 'admin')) }} | |||||
{% endfor %} | |||||
{% endblock %} | |||||
{% form_theme form '@LcSov/adminlte/crud/form_theme.html.twig' %} | |||||
{{ form_start(form) }} | |||||
<div class="tab-content"> | |||||
{% set childSettings = form.settings %} | |||||
{% for index, category in setting_definition.getCategories() %} | |||||
<div class="tab-pane {{ index == 0 ? 'active' }}" id="panel-{{ category }}"> | |||||
{% embed '@LcSov/adminlte/embed/card.html.twig' %} | |||||
{% block header_wrapper %}{% endblock %} | |||||
{% block body %} | |||||
{# content #} | |||||
{% block content %} | |||||
{% form_theme form '@LcSov/adminlte/crud/form_theme.html.twig' %} | |||||
{{ form_start(form) }} | |||||
{# panes #} | |||||
{% for index, category in setting_definition.getCategories() %} | |||||
{% embed '@LcSov/adminlte/embed/tabs/pane.html.twig' %} | |||||
{% block class %}{{ index == 0 ? 'active' }}{% endblock %} | |||||
{% block id %}{{ category }}{% endblock %} | |||||
{% block content %} | |||||
{% set count = 0 %} | {% set count = 0 %} | ||||
{% for name, setting in setting_definition.getSettingsByCategory(category) %} | {% for name, setting in setting_definition.getSettingsByCategory(category) %} | ||||
{% for child in childSettings %} | |||||
{% for child in form.settings %} | |||||
{% if child.children.name.vars.value == name %} | {% if child.children.name.vars.value == name %} | ||||
{{ form_widget(child) }} | {{ form_widget(child) }} | ||||
{% set count = count + 1 %} | {% set count = count + 1 %} | ||||
{% endif %} | {% endif %} | ||||
{% endfor %} | {% endfor %} | ||||
{% endfor %} | {% endfor %} | ||||
{% if count == 0 %} | {% if count == 0 %} | ||||
<div class="callout callout-warning"> | |||||
Aucun paramètre disponible dans cet onglet. | |||||
</div> | |||||
{% import '@LcSov/adminlte/macro/callout.html.twig' as mcallout %} | |||||
{{ mcallout.callout_warning('Aucun paramètre disponible dans cet onglet.') }} | |||||
{% endif %} | {% endif %} | ||||
{% endblock %} | {% endblock %} | ||||
{% block footer_wrapper %}{% endblock %} | |||||
{% endembed %} | {% endembed %} | ||||
</div> | |||||
{% endfor %} | |||||
</div> | |||||
{% endfor %} | |||||
{# form footer #} | |||||
{% embed '@LcSov/adminlte/embed/form_footer.html.twig' %} | |||||
{% block width %}12{% endblock %} | |||||
{% block content %} | |||||
{{ form_widget(form.submit) }} | |||||
{% endblock %} | |||||
{% endembed %} | |||||
<div class="form-footer"> | |||||
<div class="row"> | |||||
<div class="col-sm-12"> | |||||
<div class="btn-list"> | |||||
<button class="btn btn-info float-right" type="submit" name="submit" value="submit" | |||||
data-action-name="submit"> | |||||
<span class="btn-label">Sauvegarder</span> | |||||
</button> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
{{ form_end(form) }} | |||||
{{ form_end(form) }} | |||||
{% endblock %} | |||||
{% endembed %} |