Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
agplv3
kohinos-tav
Commits
d710982b
Commit
d710982b
authored
Nov 21, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set payment code from adherent homepage
parent
9a2d6212
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
159 additions
and
0 deletions
+159
-0
UserAdherentController.php
src/Controller/UserAdherentController.php
+36
-0
Adherent.php
src/Entity/Adherent.php
+17
-0
FormFactory.php
src/Factory/FormFactory.php
+11
-0
SetPaymentCodeFormType.php
src/Form/Type/SetPaymentCodeFormType.php
+39
-0
Version20221121100031.php
src/Migrations/Version20221121100031.php
+33
-0
FormExtension.php
src/Twig/FormExtension.php
+6
-0
admin_adherent.html.twig
templates/themes/kohinos/block/admin_adherent.html.twig
+4
-0
payment_code.html.twig
templates/themes/kohinos/tav/block/payment_code.html.twig
+13
-0
No files found.
src/Controller/UserAdherentController.php
View file @
d710982b
...
...
@@ -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'
);
}
}
src/Entity/Adherent.php
View file @
d710982b
...
...
@@ -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
;
}
}
src/Factory/FormFactory.php
View file @
d710982b
...
...
@@ -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
();
}
}
src/Form/Type/SetPaymentCodeFormType.php
0 → 100644
View file @
d710982b
<?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
;
use
Symfony\Component\OptionsResolver\OptionsResolver
;
use
App\Entity\Adherent
;
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
configureOptions
(
OptionsResolver
$resolver
)
{
$resolver
->
setDefaults
([
'data_class'
=>
Adherent
::
class
,
'cascade_validation'
=>
true
,
]);
}
public
function
getBlockPrefix
()
{
return
'formSetPaymentCode'
;
}
}
src/Migrations/Version20221121100031.php
0 → 100644
View file @
d710982b
<?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)\''
);
}
}
src/Twig/FormExtension.php
View file @
d710982b
...
...
@@ -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
);
}
}
templates/themes/kohinos/block/admin_adherent.html.twig
View file @
d710982b
...
...
@@ -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
%}
...
...
templates/themes/kohinos/tav/block/payment_code.html.twig
0 → 100644
View file @
d710982b
{%
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment