Commit 8ee4625b by Damien Moulard

Merge branch 'develop' into 3574-payment-from-presta-screen

parents ae07f76d db5e52e4
......@@ -79,7 +79,10 @@ Création des tables et des contraintes :
Charger les fixtures standards :
Pour une instance non TAV :
**$ php bin/console hautelook:fixtures:load --purge-with-truncate --env=pro**
Pour une instance TAV :
**$ php bin/console hautelook:fixtures:load --purge-with-truncate --env=tav**
Vous obtiendrez cette erreur ci dessous, c'est normal !
......@@ -88,7 +91,10 @@ There is no main category related to context: rubrique
**$ php bin/console sonata:media:fix-media-context**
Pour une instance non TAV :
**$ php bin/console hautelook:fixtures:load --append --env=pro**
Pour une instance TAV :
**$ php bin/console hautelook:fixtures:load --append --env=tav**
Supprimer le cache (si besoin)
......
......@@ -155,7 +155,7 @@ Prodigious\Sonata\MenuBundle\Entity\Menu:
Prodigious\Sonata\MenuBundle\Entity\MenuItem:
menuitem4:
menu: '@menu_main'
name: 'Professionnels'
name: 'Professionels'
url: '#'
position: 1
target: 0
......
......@@ -14,10 +14,12 @@ use App\Form\Type\AchatMonnaieAdherentFormType;
use App\Form\Type\AdherentInfosFormType;
use App\Form\Type\TransactionAdherentAdherentFormType;
use App\Form\Type\TransactionAdherentPrestataireFormType;
use App\Form\Type\SetPaymentCodeFormType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
class UserAdherentController extends FluxController
{
......@@ -156,4 +158,38 @@ class UserAdherentController extends FluxController
'datas' => $q,
]);
}
/**
* @Route("/adherent/set-payment-code", name="adherentSetPaymentCode")
* @IsGranted("ROLE_ADHERENT")
*/
public function setPaymentCodeAction(Request $request, UserPasswordEncoderInterface $encoder)
{
$adherent = $this->getUser()->getAdherent();
$form = $this->createForm(SetPaymentCodeFormType::class, $adherent);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$plainCode = $data->getPaymentCode();
if (is_numeric($plainCode) && strlen($plainCode) >= 4 && strlen($plainCode) <= 8) {
$encoded = $encoder->encodePassword($this->getUser(), $plainCode);
$adherent->setPaymentCode($encoded);
$this->em->flush();
$this->addFlash(
'success',
$this->translator->trans('Code de paiement modifié !')
);
} else {
$this->addFlash(
'error',
$this->translator->trans('Le code de paiement doit être composé de 4 à 8 chiffres.')
);
}
}
return $this->redirectToRoute('index');
}
}
......@@ -80,6 +80,11 @@ class Adherent extends AccountableObject implements AccountableInterface
*/
private $accounts;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $paymentCode;
public function __construct()
{
$this->accounts = new ArrayCollection();
......@@ -224,4 +229,16 @@ class Adherent extends AccountableObject implements AccountableInterface
return 'Adhérent xxx';
}
public function getPaymentCode(): ?string
{
return $this->paymentCode;
}
public function setPaymentCode(?string $paymentCode): self
{
$this->paymentCode = $paymentCode;
return $this;
}
}
......@@ -50,6 +50,7 @@ use App\Form\Type\TransfertSiegeGroupeFormType;
use App\Form\Type\UserInfosFormType;
use App\Form\Type\VenteEmlcAdherentFormType;
use App\Form\Type\VenteEmlcPrestataireFormType;
use App\Form\Type\SetPaymentCodeFormType;
use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Form\Type\ChangePasswordFormType;
use Symfony\Component\Form\FormFactoryInterface as FormF;
......@@ -433,4 +434,14 @@ class FormFactory
return $form->createView();
}
public function getSetPaymentCodeForm(User $user)
{
if (empty($user) || !$user->isGranted('ROLE_ADHERENT')) {
throw new \Exception('[FORM 23] Opération impossible !');
}
$form = $this->ff->create(SetPaymentCodeFormType::class, $user->getAdherent(), ['action' => $this->router->generate('adherentSetPaymentCode')]);
return $form->createView();
}
}
<?php
namespace App\Form\Type;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
class SetPaymentCodeFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('payment_code', PasswordType::class, [
'label' => 'Saisir mon nouveau code (4 à 8 chiffres)',
'required' => true,
])
->add('save', SubmitType::class, ['label' => 'Valider'])
;
}
public function getBlockPrefix()
{
return 'formSetPaymentCode';
}
}
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221121100031 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE adherent ADD payment_code VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:personal_data)\'');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE adherent DROP payment_code');
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT CHARACTER SET utf8mb3 DEFAULT NULL COLLATE `utf8mb3_general_ci` COMMENT \'(DC2Type:personal_data)\'');
}
}
......@@ -52,6 +52,7 @@ class FormExtension extends AbstractExtension
new \Twig_SimpleFunction('getAchatMonnaieAConfirmerPrestataireForm', [$this, 'getAchatMonnaieAConfirmerPrestataireForm']),
new \Twig_SimpleFunction('getTicketFixPrintForm', [$this, 'getTicketFixPrintForm']),
new \Twig_SimpleFunction('getTicketFixDestroyForm', [$this, 'getTicketFixDestroyForm']),
new \Twig_SimpleFunction('getSetPaymentCodeForm', [$this, 'getSetPaymentCodeForm']),
];
}
......@@ -199,4 +200,9 @@ class FormExtension extends AbstractExtension
{
return $this->container->get('app.formfactory')->getTicketFixDestroyForm($user);
}
public function getSetPaymentCodeForm(User $user)
{
return $this->container->get('app.formfactory')->getSetPaymentCodeForm($user);
}
}
......@@ -4,6 +4,10 @@
{% set esoldelabel = 'Solde e-mlc'|trans %}
{% include '@kohinos/block/solde.html.twig' with {'compte': app.user.adherent.emlcAccount.balance, 'soldelabel': esoldelabel, 'currency' : 'e'~(KOH_MLC_SYMBOL|default(''))} %}
{% if tav_env == 1 %}
{% include '@kohinos/tav/block/payment_code.html.twig' %}
{% endif %}
{% if KOH_USE_PAYZEN == 'true' or KOH_USE_HELLOASSO == 'true' %}
{% include '@kohinos/adherent/block/achat_monnaie.html.twig' %}
{% else %}
......
......@@ -9,24 +9,26 @@
{% endif %}
{# {% include '@kohinos/block/transactions.html.twig' %} #}
{% include '@kohinos/block/operations.html.twig' %}
{% if getCurrentPrestataire().mlc == true %}
{% include '@kohinos/block/operations.html.twig' with {'title' : 'Compte de fonctionnement €', 'operations': getLastOperations(app.request, app.user, constant('App\\Enum\\CurrencyEnum::CURRENCY_EURO'))} %}
{% elseif getCurrentPrestataire().solidoume == false %}
{% include '@kohinos/block/cotisations.html.twig' %}
{% set groupeprestataires = getAllGroupePrestataires() %}
{% if groupeprestataires|length > 0 %}
{% include '@kohinos/groupepresta/block/inscription.html.twig' %}
{% if not tav_env %}
{% if getCurrentPrestataire().mlc == true %}
{% include '@kohinos/block/operations.html.twig' with {'title' : 'Compte de fonctionnement €', 'operations': getLastOperations(app.request, app.user, constant('App\\Enum\\CurrencyEnum::CURRENCY_EURO'))} %}
{% elseif getCurrentPrestataire().solidoume == false %}
{% include '@kohinos/block/cotisations.html.twig' %}
{% set groupeprestataires = getAllGroupePrestataires() %}
{% if groupeprestataires|length > 0 %}
{% include '@kohinos/groupepresta/block/inscription.html.twig' %}
{% endif %}
{% endif %}
{% endif %}
{% if getCurrentPrestataire().solidoume == false %}
{% if KOH_USE_PAYZEN == 'true' or KOH_USE_HELLOASSO == 'true' %}
{% include '@kohinos/presta/block/achat_monnaie.html.twig' %}
{% else %}
{% include '@kohinos/presta/block/demande_achat_monnaie.html.twig' %}
{% if getCurrentPrestataire().solidoume == false %}
{% if KOH_USE_PAYZEN == 'true' or KOH_USE_HELLOASSO == 'true' %}
{% include '@kohinos/presta/block/achat_monnaie.html.twig' %}
{% else %}
{% include '@kohinos/presta/block/demande_achat_monnaie.html.twig' %}
{% endif %}
{% endif %}
{% include '@kohinos/presta/block/transaction_presta.html.twig' %}
{% include '@kohinos/presta/block/transaction_adherent.html.twig' %}
{% endif %}
{% include '@kohinos/presta/block/transaction_presta.html.twig' %}
{% include '@kohinos/presta/block/transaction_adherent.html.twig' %}
{% if getCurrentPrestataire().mlc == false and getCurrentPrestataire().solidoume == false and getCurrentPrestataire().emlcAccount.balance > 0 %}
{% include '@kohinos/presta/block/reconversion.html.twig' %}
{% endif %}
\ No newline at end of file
......@@ -8,26 +8,34 @@
<i class="fas fa-check"> </i> {{ showMlcStats('user') }} {{ 'utilisateurs'|trans }}<br>
</p>
<p>
<i class="fa fa-check"> </i> {{ showMlcStats('prestataire') }} <a href="{{ path('liste_prestataire') }}" title="{{ 'Nombre de prestataires'|trans }}">{{'prestataires'|trans}}</a> {{'et'|trans}} {{ showMlcStats('partenaire') }} <a href="{{ path('liste_partenaire') }}" title="{{'Nombre de partenaires'|trans}}">{{ 'partenaires'|trans }}</a>
{% if tav_env %}
<i class="fa fa-check"> </i> {{ showMlcStats('prestataire') }} <a href="{{ path('liste_prestataire') }}" title="{{ 'Nombre de prestataires'|trans }}">{{'Points de vente'|trans}}</a>
{% else %}
<i class="fa fa-check"> </i> {{ showMlcStats('prestataire') }} <a href="{{ path('liste_prestataire') }}" title="{{ 'Nombre de prestataires'|trans }}">{{'prestataires'|trans}}</a> {{'et'|trans}} {{ showMlcStats('partenaire') }} <a href="{{ path('liste_partenaire') }}" title="{{'Nombre de partenaires'|trans}}">{{ 'partenaires'|trans }}</a>
{% endif %}
</p>
{% if not tav_env %}
<p>
<i class="fa fa-check"> </i> {{ showMlcStats('groupe') }} {{ 'groupes locaux'|trans }}
</p>
{% endif %}
<p>
<i class="fa fa-check"> </i> {{ showMlcStats('groupe') }} {{ 'groupes locaux'|trans }}
</p>
<p>
<i class="fa fa-check"> </i> {{ showMlcStats('comptoir') }} <a href="{{ path('comptoirs_liste') }}" title="{{ 'Nombre de comptoirs'|trans }}">{{ 'comptoirs'|trans }}</a>
<i class="fa fa-check"> </i> {{ showMlcStats('comptoir') }} <a href="{{ path('comptoirs_liste') }}" title="{{ 'Nombre de comptoirs'|trans }}">{% if tav_env %}{{ 'Comptoirs des habitants'|trans }}{% else %}{{ 'comptoirs'|trans }}{% endif %}</a>
</p>
{# <p>
<i class="fa fa-exchange-alt"> </i> {{ getTotalMonnaieEmise() }} {{ KOH_MLC_NAME_SMALL|default('') }} émises
</p> #}
<p>
<i class="fa fa-exchange-alt"> </i> {{ getStatsMonnaie('mlc_nantie') }} {{ KOH_MLC_NAME_SMALL|default('') }} papier nantie
</p>
<p>
<i class="fa fa-exchange-alt"> </i> {{ getStatsMonnaie('emlc') }} {{ KOH_MLC_NAME_SMALL|default('') }} numérique nantie
</p>
<p>
<i class="fa fa-exchange-alt"> </i> {{ (getStatsMonnaie('emlc') + getStatsMonnaie('mlc_nantie')) }} {{ KOH_MLC_NAME_SMALL|default('') }} en circulation
</p>
{% if not tav_env %}
<p>
<i class="fa fa-exchange-alt"> </i> {{ getStatsMonnaie('mlc_nantie') }} {{ KOH_MLC_NAME_SMALL|default('') }} papier nantie
</p>
<p>
<i class="fa fa-exchange-alt"> </i> {{ getStatsMonnaie('emlc') }} {{ KOH_MLC_NAME_SMALL|default('') }} numérique nantie
</p>
<p>
<i class="fa fa-exchange-alt"> </i> {{ (getStatsMonnaie('emlc') + getStatsMonnaie('mlc_nantie')) }} {{ KOH_MLC_NAME_SMALL|default('') }} en circulation
</p>
{% endif %}
{# @TODO (pas prioritaire) : Statistiques avancées :
<p>
<i class="fa fa-check"> </i> 350304 {{ KOH_MLC_NAME_SMALL|default('') }} reconverties
......
......@@ -4,7 +4,7 @@
{# {% block blocktoggle %}{% if isCotisationValid(app.user) %}collapse{% endif %}{% endblock blocktoggle %} #}
{% block blocktitle %}
<i class="fa fa-external-link fa-external-link-alt mr-4"></i> {{ 'Reconversion'|trans }}
<i class="fa fa-external-link fa-external-link-alt mr-4"></i> {% if tav_env %}{{ 'Demander une reconversion en €'|trans }}{% else %}{{ 'Reconversion'|trans }}{% endif %}
{% endblock blocktitle %}
{% block blockcontent %}
{% if isCotisationValid(app.user) %}
......
{% extends '@kohinos/block/block_collapse.html.twig' %}
{% block blocktitle %}
<i class="fa fa-clipboard-list mr-4"></i> {{ 'Mon code de paiement'|trans }}
{% endblock blocktitle %}
{% block blockcontent %}
{% set form = getSetPaymentCodeForm(app.user) %}
{{ form_start(form) }}
{{ form_row(form.payment_code) }}
{{ form_end(form) }}
{% endblock blockcontent %}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment