Commit 81227837 by Damien Moulard

Choix d'utiliser ou non payzen dans la config

parent 7d6d9e20
......@@ -631,6 +631,10 @@ App\Entity\GlobalParameter:
name: "MAP_ZOOM"
value: '9'
mandatory: 1
gp14:
name: "USE_PAYZEN"
value: 'true'
mandatory: 1
App\Entity\Siege:
siege_1:
......
......@@ -27,6 +27,7 @@ class GlobalParameter
const RECONVERSION_PRESTATAIRE = 'RECONVERSION_PRESTATAIRE';
const MAP_CENTER = 'MAP_CENTER';
const MAP_ZOOM = 'MAP_ZOOM';
const USE_PAYZEN = 'USE_PAYZEN';
/**
* @ORM\Id()
......@@ -92,7 +93,7 @@ class GlobalParameter
{
return $this->mandatory;
}
/**
* Set mandatory
* @return $this
......
......@@ -54,6 +54,8 @@ class CotiserFormType extends AbstractType
$canPayWithMlc = ($this->session->get('_prestagere')->getEcompte() >= $montant);
}
$canPayWithCB = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_PAYZEN) === 'true' ? true : false;
$builder
->add('operateur', HiddenType::class, array(
'entity_class' => User::class,
......@@ -94,8 +96,10 @@ class CotiserFormType extends AbstractType
if ($canPayWithMlc) {
$builder->add('payMLC', SubmitType::class, ['label' => "Payer en eMLC"]);
}
$builder->add('payCB', SubmitType::class, ['label' => "Payer en CB"]);
if ($canPayWithCB) {
$builder->add('payCB', SubmitType::class, ['label' => "Payer en CB"]);
}
if ($this->security->getUser()->isGranted('ROLE_ADHERENT')) {
$builder
->add('expediteur', HiddenType::class, array(
......
......@@ -118,6 +118,16 @@ class GlobalConfigurationFormType extends AbstractType
],
'help' => ''
))
->add('usepayzen', GlobalParameterType::class, array(
'label' => "Utiliser le paiement par CB avec Payzen :",
'name_param' => GlobalParameter::USE_PAYZEN,
'required' => true,
'_placeholder' => 'false',
'constraints_param' => [
new RegexConstraint(['pattern' => '/^true$|^false$/', 'message' => 'La valeur doit être "true" ou "false"'])
],
'help' => 'Si cette option est activée (true), les utilisateurs pourront cotiser et acheter de la monnaie locale par CB sur l\'application.'
))
;
}
......
......@@ -11,6 +11,7 @@ use App\Entity\Prestataire;
use App\Entity\Rubrique;
use App\Entity\Siege;
use App\Entity\User;
use App\Entity\GlobalParameter;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -61,10 +62,16 @@ class AppExtension extends AbstractExtension
new \Twig_SimpleFunction('getWordpressApiKey', array($this, 'getWordpressApiKey')),
new \Twig_SimpleFunction('parameter', function ($name) {
return $this->container->getParameter($name);
})
}),
new \Twig_SimpleFunction('isPayzenEnabled', array($this, 'isPayzenEnabled'))
];
}
public function isPayzenEnabled()
{
return $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::USE_PAYZEN) === 'true' ? true : false;
}
public function getFilters()
{
return array(
......@@ -105,7 +112,7 @@ class AppExtension extends AbstractExtension
}
return $this->em->getRepository(Comptoir::class)->findOneById($this->session->get('_comptoirgere')->getId());
}
public function getCurrentGroupe()
{
if (!$this->session->has('_groupegere')) {
......@@ -113,7 +120,7 @@ class AppExtension extends AbstractExtension
}
return $this->em->getRepository(Groupe::class)->findOneById($this->session->get('_groupegere')->getId());
}
public function getCurrentPrestataire()
{
if (!$this->session->has('_prestagere')) {
......
......@@ -155,7 +155,9 @@
{% include 'block/cotisations.html.twig' %}
{% include 'groupepresta/block/inscription.html.twig' %}
{% endif %}
{% include 'presta/block/achat_monnaie.html.twig' %}
{% if isPayzenEnabled() %}
{% include 'presta/block/achat_monnaie.html.twig' %}
{% endif %}
{% include 'presta/block/transaction_presta.html.twig' %}
{% include 'presta/block/transaction_adherent.html.twig' %}
{% if getCurrentPrestataire().mlc == false and getCurrentPrestataire().ecompte > 0 %}
......@@ -170,7 +172,9 @@
{% include 'block/userpassword.html.twig' %}
{% include 'block/cotisations.html.twig' %}
{% include 'block/transactions.html.twig' %}
{% include 'adherent/block/achat_monnaie.html.twig' %}
{% if isPayzenEnabled() %}
{% include 'adherent/block/achat_monnaie.html.twig' %}
{% endif %}
{% include 'adherent/block/transaction_presta.html.twig' %}
{% include 'adherent/block/transaction_adherent.html.twig' %}
......
......@@ -26,8 +26,15 @@
{% else %}
<div class='col-12'>
{% endif %}
{% if form.payCB is defined %}
<div class='col-6'>
{{ form_widget(form.payCB) }}
</div>
<div class='col-6'>
{% else %}
<div class='col-12'>
{% endif %}
</div>
</div>
{{ form_end(form) }}
</div>
......
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