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
1
Merge Requests
1
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
55b9e57b
Commit
55b9e57b
authored
Mar 01, 2024
by
Yvon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow presta to edit questionnaire from vitrine
parent
95e2b8dd
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
11 deletions
+72
-11
IndexController.php
src/Controller/IndexController.php
+51
-2
SelfEvalPrestaQuizType.php
src/Form/Type/SelfEvalPrestaQuizType.php
+9
-6
show.html.twig
templates/themes/kohinos/presta/show.html.twig
+6
-1
distributor.html.twig
...lates/themes/kohinos/tav/prestaquiz/distributor.html.twig
+3
-1
producer.html.twig
templates/themes/kohinos/tav/prestaquiz/producer.html.twig
+3
-1
No files found.
src/Controller/IndexController.php
View file @
55b9e57b
...
...
@@ -18,6 +18,7 @@ use App\Entity\User;
use
App\Entity\Usergroup
;
use
App\Enum\CurrencyEnum
;
use
App\Form\Type\DistributorSelfEvalPrestaQuizType
;
use
App\Form\Type\SelfEvalPrestaQuizType
;
use
App\Form\Type\InfosPrestaQuizType
;
use
App\Form\Type\InstallFormType
;
use
App\Form\Type\ProducerSelfEvalPrestaQuizType
;
...
...
@@ -41,8 +42,8 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
use
Symfony\Component\Routing\Annotation\Route
;
use
Symfony\Component\Routing\RouterInterface
;
use
Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
;
use
Symfony\Component\Security\Core\Security
;
use
Symfony\Component\Security\Core\Security
as
Secur
;
use
Sensio\Bundle\FrameworkExtraBundle\Configuration\Security
;
use
Symfony\Component\Security\Csrf\CsrfTokenManagerInterface
;
use
Symfony\Component\Security\Guard\GuardAuthenticatorHandler
;
use
Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken
;
...
...
@@ -71,7 +72,7 @@ class IndexController extends AbstractController
LoginAuthenticator
$authenticator
,
TokenStorageInterface
$tokenStorage
,
RouterInterface
$router
,
Secur
ity
$security
,
Secur
$security
,
\Swift_Mailer
$mailer
)
{
$this
->
eventDispatcher
=
$eventDispatcher
;
...
...
@@ -321,6 +322,54 @@ class IndexController extends AbstractController
]);
}
/**
* @Route("/quiz-presta-edit", name="quiz-presta-edit")
* @Security("is_granted('ROLE_PRESTATAIRE')")
*/
/* Late presta edit (after definitive submission) :
* As we are not in the somehow complex subscription tunnel context anymore,
* I found easier to create a new controller
* instead of reusing prestaQuizSelfEvalAction
*/
public
function
quizPrestaEditAction
(
Request
$request
)
:
Response
{
//Look for enabled prestataire with current user (fail if no enabled prestataire has been found)
$prestas
=
$this
->
em
->
getRepository
(
Prestataire
::
class
)
->
findByData
([
'user'
=>
$this
->
security
->
getUser
()]);
if
(
!
$prestas
)
{
throw
new
\Exception
(
'Vous n\'êtes pas autorisé à accèder à cette page.'
);
}
else
{
$presta
=
$prestas
[
0
];
}
/* @var Prestataire $presta */
$formClass
=
Prestataire
::
DISTRIBUTOR
===
$presta
->
getMarketChannelFunction
()
?
DistributorSelfEvalPrestaQuizType
::
class
:
ProducerSelfEvalPrestaQuizType
::
class
;
// Block if no quiz (e.g. user access this controleur in non presta_self_init_and_eval env) or
// if presta has been enabled while questionnaire has not been submitted yet (should not occur)
$quiz
=
$presta
->
getSelfEvalPrestaQuiz
();
if
(
null
==
$quiz
||
!
$quiz
->
isSubmitted
)
{
throw
new
\Exception
(
'Aucun questionnaire soumis trouvé.'
);
}
$form
=
$this
->
createForm
(
$formClass
,
$quiz
,
[
"mode"
=>
SelfEvalPrestaQuizType
::
PRESTA_EDIT_AFTER_DEFINITIVE_SUBMISSION
]);
$form
->
handleRequest
(
$request
);
if
(
$form
->
isSubmitted
()
&&
$form
->
isValid
())
{
$this
->
em
->
flush
();
return
$this
->
redirectToRoute
(
'show_prestataire'
,[
'slug'
=>
$presta
->
getRaison
()]);
}
$tmpl
=
Prestataire
::
DISTRIBUTOR
===
$presta
->
getMarketChannelFunction
()
?
'@kohinos/tav/prestaquiz/distributor.html.twig'
:
'@kohinos/tav/prestaquiz/producer.html.twig'
;
return
$this
->
render
(
$tmpl
,
[
'form'
=>
$form
->
createView
(),
]);
}
private
function
notifyGestionnaireAfterPrestaquizSent
(
Prestataire
$presta
)
{
$user
=
$this
->
security
->
getUser
();
...
...
src/Form/Type/SelfEvalPrestaQuizType.php
View file @
55b9e57b
...
...
@@ -23,6 +23,7 @@ class SelfEvalPrestaQuizType extends AbstractType
const
PRESTA_EDIT
=
'presta_edit'
;
const
ADMIN_EDIT
=
'admin_edit'
;
const
READONLY
=
'readonly'
;
const
PRESTA_EDIT_AFTER_DEFINITIVE_SUBMISSION
=
'presta_edit_after_definitive_submission'
;
protected
$security
;
...
...
@@ -68,26 +69,28 @@ class SelfEvalPrestaQuizType extends AbstractType
'choices'
=>
$this
->
stdChoices
,
'expanded'
=>
true
,
"multiple"
=>
false
,
'disabled'
=>
$options
[
'mode'
]
===
self
::
READONLY
'disabled'
=>
$options
[
'mode'
]
!==
self
::
ADMIN_EDIT
];
$this
->
opts
=
$this
->
reviewOpts
;
$this
->
opts
[
'disabled'
]
=
$options
[
'mode'
]
!==
self
::
PRESTA_EDIT
;
$this
->
opts
[
'disabled'
]
=
$options
[
'mode'
]
!==
self
::
PRESTA_EDIT
&&
$options
[
'mode'
]
!==
self
::
PRESTA_EDIT_AFTER_DEFINITIVE_SUBMISSION
;
$this
->
reviewCmtOpts
=
[
'attr'
=>
[
'placeholder'
=>
$options
[
'mode'
]
===
self
::
READONLY
?
''
:
'Commentaires'
'placeholder'
=>
$options
[
'mode'
]
!==
self
::
ADMIN_EDIT
?
''
:
'Commentaires'
],
'label'
=>
false
,
'required'
=>
false
,
'disabled'
=>
$options
[
'mode'
]
===
self
::
READONLY
'disabled'
=>
$options
[
'mode'
]
!==
self
::
ADMIN_EDIT
];
$this
->
cmtOpts
=
$this
->
reviewCmtOpts
;
$this
->
cmtOpts
[
'disabled'
]
=
$options
[
'mode'
]
!==
self
::
PRESTA_EDIT
;
$this
->
cmtOpts
[
'disabled'
]
=
$options
[
'mode'
]
!==
self
::
PRESTA_EDIT
&&
$options
[
'mode'
]
!==
self
::
PRESTA_EDIT_AFTER_DEFINITIVE_SUBMISSION
;
$this
->
cmtOpts
[
'attr'
][
'placeholder'
]
=
$options
[
'mode'
]
!==
self
::
PRESTA_EDIT
?
''
:
'Commentaires'
;
$this
->
globalCmtOpts
=
$this
->
cmtOpts
;
$this
->
globalCmtOpts
[
'required'
]
=
true
;
$this
->
globalCmtOpts
[
'attr'
][
'placeholder'
]
=
$options
[
'mode'
]
!==
self
::
PRESTA_EDIT
?
''
:
'Commentaires (obligatoire)'
;
$this
->
globalCmtOpts
[
'attr'
][
'placeholder'
]
=
$options
[
'mode'
]
!==
self
::
PRESTA_EDIT
&&
$options
[
'mode'
]
!==
self
::
PRESTA_EDIT_AFTER_DEFINITIVE_SUBMISSION
?
''
:
'Commentaires (obligatoire)'
;
$builder
->
add
(
$options
[
"mode"
],
HiddenType
::
class
,[
'mapped'
=>
false
]);
//ease conditionnal display in twig
/* PARTIE 1 : ACCESSIBILITE ET INCLUSIVITE */
$this
->
opts
[
'label'
]
=
"Géographique et physique : le lieu est-il accessible par différents modes de transport ?"
;
...
...
templates/themes/kohinos/presta/show.html.twig
View file @
55b9e57b
...
...
@@ -79,7 +79,12 @@
{%
endif
%}
{%
if
app.user
and
presta_self_init_and_eval
and
presta.selfEvalPrestaQuiz
%}
{%
set
prestataire
=
presta
%}
<div
class=
"card-header"
><h2>
Questionnaire
</h2></div>
<div
class=
"card-header"
>
<h2>
Questionnaire
</h2>
{%
if
app.user
in
prestataire.users
and
is_granted
(
"ROLE_PRESTATAIRE"
)
%}
<a
class=
'btn btn-primary float-right'
href=
"
{{
path
(
'quiz-presta-edit'
)
}}
"
>
Corriger
</a>
{%
endif
%}
</div>
<div
class=
"card-body"
>
{%
if
presta.marketChannelFunction
==
'distributor'
%}
{%
include
'@kohinos/tav/prestaquiz/distributor_core.html.twig'
%}
...
...
templates/themes/kohinos/tav/prestaquiz/distributor.html.twig
View file @
55b9e57b
...
...
@@ -2,8 +2,10 @@
{%
block
content
%}
{# Check if review mode to adapt title #}
{%
if
form.
review_transpar_global
is
defined
%}
{%
if
form.
admin_edit
is
defined
%}
<h1>
Revue auto-évaluation distributeur
{{
prestataire.raison
}}
</h1>
{%
elseif
form.presta_edit_after_definitive_submission
is
defined
%}
<h1>
Correction du questionnaire d'auto-évaluation
</h1>
{%
else
%}
<h1>
Inscription point de vente (2/2) : auto-évaluation
</h1>
{%
endif
%}
...
...
templates/themes/kohinos/tav/prestaquiz/producer.html.twig
View file @
55b9e57b
...
...
@@ -2,8 +2,10 @@
{%
block
content
%}
{# Check if review mode to adapt title #}
{%
if
form.
review_proagdur_global
is
defined
%}
{%
if
form.
admin_edit
is
defined
%}
<h1>
Revue auto-évaluation producteur
{{
prestataire.raison
}}
</h1>
{%
elseif
form.presta_edit_after_definitive_submission
is
defined
%}
<h1>
Correction du questionnaire d'auto-évaluation
</h1>
{%
else
%}
<h1>
Inscription point de vente (2/2) : auto-évaluation
</h1>
{%
endif
%}
...
...
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