Commit d86a16e4 by Yvon

add review qcm action in presta admin

parent 54ca3a9e
......@@ -335,6 +335,12 @@ form[name="formEncaissement"] label {
border-radius:10px;
border: 5px solid powderblue;
}
.review-container {
background-color:#CBC3E3;
border-radius:10px;
border: 5px solid #CBC3E3;
}
/**
* END Success check animation.
*/
\ No newline at end of file
......@@ -610,4 +610,27 @@ $(function() {
// showButtonPanel: true
// });
/*
* Improve lisibility when reviewing prestataire questionnaire.
*/
// Get all radio inputs of prestataire questionnaire forms when on review mode (disabled)
var radioInputs = document.querySelectorAll(
'form[name$="SelfEvalPrestaQuiz"] input[type="radio"]:disabled'
);
radioInputs.forEach(function(radioInput) {
if (!radioInput.checked) {
//get the colored icon
icon = radioInput.labels[0].querySelector('i');
var classList = Array.from(icon.classList);
// Filter out classes starting with "text-"
var textClasses = classList.filter(function(className) {
return className.startsWith('text-');
});
// Remove all classes starting with "text-"
textClasses.forEach(function(textClass) {
icon.classList.remove(textClass);
});
}
});
});
......@@ -670,6 +670,11 @@ class PrestataireAdmin extends AbstractAdmin
],
],
];
if ($this->getConfigurationPool()->getContainer()->getParameter('presta_self_init_and_eval')) {
$actions['reviewPrestaQuiz'] = [
'template' => '@kohinos/tav/reviewprestaquiz.html.twig'
];
}
if (null != $this->security->getUser() && ($this->security->isGranted('ROLE_SUPER_ADMIN') || $this->security->isGranted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_ALL') || $this->security->isGranted('ROLE_ADMIN_PRESTATAIRE_COTISATIONS_CREATE'))) {
$actions['addfreecotisationpresta'] = [
'template' => '@kohinos/bundles/SonataAdminBundle/CRUD/list__action_addfreecotisationpresta.html.twig',
......@@ -765,6 +770,7 @@ class PrestataireAdmin extends AbstractAdmin
$collection
->add('addfreecotisationpresta', $this->getRouterIdParameter() . '/addfreecotisationpresta')
->add('addfreecotisationadh', $this->getRouterIdParameter() . '/addfreecotisationadh')
->add('reviewprestaquiz', $this->getRouterIdParameter() . '/reviewprestaquiz')
;
}
......
......@@ -6,10 +6,13 @@ use App\Entity\CotisationAdherent;
use App\Entity\CotisationPrestataire;
use App\Entity\Prestataire;
use App\Enum\MoyenEnum;
use App\Form\Type\DistributorSelfEvalPrestaQuizType;
use App\Form\Type\ProducerSelfEvalPrestaQuizType;
use App\Utils\CustomEntityManager;
use DateTime;
use Sonata\AdminBundle\Controller\CRUDController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Security;
......@@ -115,4 +118,43 @@ class PrestataireAdminController extends CRUDController
$this->admin->generateUrl('list', ['filter' => $this->admin->getFilterParameters()])
);
}
/**
* Visualisation et complétion de la partie réservée à l'admin sur un questionnaire prestataire
*
* @param Request $request
* @param Uuid $id Id du prestataire
*
* @return Response
*/
public function reviewprestaquizAction(Request $request, $id): Response
{
$prestataire = $this->admin->getSubject();
if (!$prestataire) {
throw new NotFoundHttpException(sprintf('Impossible de trouver le prestataire avec l\'id: %s', $id));
}
$quiz = $prestataire->getSelfEvalPrestaQuiz();
$formClass = Prestataire::DISTRIBUTOR === $prestataire->getMarketChannelFunction() ?
DistributorSelfEvalPrestaQuizType::class : ProducerSelfEvalPrestaQuizType::class;
$form = $this->createForm($formClass, $quiz, ["review" => true]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->em->flush();
return new RedirectResponse(
$this->admin->generateUrl('list', ['filter' => $this->admin->getFilterParameters()])
);
}
$tmpl = Prestataire::DISTRIBUTOR === $prestataire->getMarketChannelFunction() ?
'@kohinos/tav/distributor_selfeval_prestaquiz.html.twig'
: '@kohinos/tav/producer_selfeval_prestaquiz.html.twig';
return $this->render($tmpl, [
'form' => $form->createView(),
]);
}
}
......@@ -328,4 +328,70 @@ class SelfEvalPrestaQuiz
*/
public $localite_global_comment;
/**
* @var int|null
* @ORM\Column(type="integer", nullable=true)
*/
public $review_accessib_global;
/**
* @var string|null
* @ORM\Column(type="text", nullable=true)
*/
public $review_accessib_global_comment;
/**
* @var int|null
* @ORM\Column(type="integer", nullable=true)
*/
public $review_bienetre_global;
/**
* @var string|null
* @ORM\Column(type="text", nullable=true)
*/
public $review_bienetre_global_comment;
/**
* @var int|null
* @ORM\Column(type="integer", nullable=true)
*/
public $review_transpar_global;
/**
* @var string|null
* @ORM\Column(type="text", nullable=true)
*/
public $review_transpar_global_comment;
/**
* @var int|null
* @ORM\Column(type="integer", nullable=true)
*/
public $review_disagdur_global;
/**
* @var string|null
* @ORM\Column(type="text", nullable=true)
*/
public $review_disagdur_global_comment;
/**
* @var int|null
* @ORM\Column(type="integer", nullable=true)
*/
public $review_proagdur_global;
/**
* @var string|null
* @ORM\Column(type="text", nullable=true)
*/
public $review_proagdur_global_comment;
/**
* @var int|null
* @ORM\Column(type="integer", nullable=true)
*/
public $review_localite_global;
/**
* @var string|null
* @ORM\Column(type="text", nullable=true)
*/
public $review_localite_global_comment;
}
......@@ -9,12 +9,13 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
class DistributorSelfEvalPrestaQuizType extends SelfEvalPrestaQuizType
{
public function __construct()
public function __construct(Security $security, array $options = [])
{
parent::__construct();
parent::__construct($security, $options);
}
public function buildForm(FormBuilderInterface $builder, array $options)
......@@ -66,7 +67,7 @@ class DistributorSelfEvalPrestaQuizType extends SelfEvalPrestaQuizType
de pratiques agricoles durables ?";
$this->opts['choices'] = [
$this->frown . " non" => 0,
$this->meh . " oui pas des échanges avec le producteur ou le revendeur qui connaît les pratiques agricoles du secteur" => 1,
$this->meh . " oui par des échanges avec le producteur ou le revendeur qui connaît les pratiques agricoles du secteur" => 1,
$this->smile . " oui" => 2,
];
$builder->add('disagdur_condur', ChoiceType::class, $this->opts);
......@@ -97,16 +98,24 @@ class DistributorSelfEvalPrestaQuizType extends SelfEvalPrestaQuizType
$this->opts['choices'] = $this->stdGlobalChoices;
$builder->add('localite_global', ChoiceType::class, $this->opts);
$builder->add('localite_global_comment', TextareaType::class, $this->cmtOpts);
}
/**
*
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => SelfEvalPrestaQuiz::class,
]);
//Review
if($options['review']) {
$this->reviewOpts['label'] = "Transparence et juste rémunération : " . $this->reviewLabel;
$this->reviewOpts['choices'] = $this->stdGlobalChoices;
$builder->add('review_transpar_global', ChoiceType::class, $this->reviewOpts);
$builder->add('review_transpar_global_comment', TextareaType::class, $this->reviewCmtOpts);
$this->reviewOpts['label'] = "Pratiques agricoles durables : " . $this->reviewLabel;
$this->reviewOpts['choices'] = $this->stdGlobalChoices;
$builder->add('review_disagdur_global', ChoiceType::class, $this->reviewOpts);
$builder->add('review_disagdur_global_comment', TextareaType::class, $this->reviewCmtOpts);
$this->reviewOpts['label'] = "Localité des produits : " . $this->reviewLabel;
$this->reviewOpts['choices'] = $this->stdGlobalChoices;
$builder->add('review_localite_global', ChoiceType::class, $this->reviewOpts);
$builder->add('review_localite_global_comment', TextareaType::class, $this->reviewCmtOpts);
}
}
public function getBlockPrefix(): string
......
......@@ -9,12 +9,13 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
class ProducerSelfEvalPrestaQuizType extends SelfEvalPrestaQuizType
{
public function __construct()
public function __construct(Security $security, array $options = [])
{
parent::__construct();
parent::__construct($security, $options);
}
public function buildForm(FormBuilderInterface $builder, array $options)
......@@ -56,16 +57,14 @@ class ProducerSelfEvalPrestaQuizType extends SelfEvalPrestaQuizType
$this->opts['choices'] = $this->stdGlobalChoices;
$builder->add('proagdur_global', ChoiceType::class, $this->opts);
$builder->add('proagdur_global_comment', TextareaType::class, $this->cmtOpts);
}
/**
*
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => SelfEvalPrestaQuiz::class,
]);
//Review
if($options['review']) {
$this->reviewOpts['label'] = "Pratiques agricoles durables : " . $this->reviewLabel;
$this->reviewOpts['choices'] = $this->stdGlobalChoices;
$builder->add('review_proagdur_global', ChoiceType::class, $this->reviewOpts);
$builder->add('review_proagdur_global_comment', TextareaType::class, $this->reviewCmtOpts);
}
}
public function getBlockPrefix(): string
......
......@@ -9,6 +9,7 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\NotNull;
/**
......@@ -19,16 +20,23 @@ use Symfony\Component\Validator\Constraints\NotNull;
*/
class SelfEvalPrestaQuizType extends AbstractType
{
protected $security;
protected array $stdChoices;
protected array $opts;
protected array $reviewOpts;
protected array $cmtOpts;
protected array $reviewCmtOpts;
protected string $labelEvalGlob;
protected string $reviewLabel;
protected string $frown;
protected string $meh;
protected string $smile;
public function __construct()
public function __construct(Security $security, array $options = [])
{
$this->security = $security;
$this->frown = '<i class="fas fa-frown text-danger"></i>';
$this->meh = '<i class="fas fa-meh text-warning"></i>';
$this->smile = '<i class="fas fa-smile text-success"></i>';
......@@ -43,23 +51,33 @@ class SelfEvalPrestaQuizType extends AbstractType
$this->meh => 1,
$this->smile => 2,
];
$this->opts = [
$this->labelEvalGlob = "évaluation globale";
$this->reviewLabel = "évaluation du gestionnaire";
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
//options are moved to buildForm as 'review' option is required to set them up
$this->reviewOpts = [
'label' => '',
'choices' => $this->stdChoices,
'expanded' => true,
"multiple" => false,
'constraints' => [new NotNull()],
'constraints' => [new NotNull()]
];
$this->cmtOpts = [
'attr' => ['placeholder' => 'Commentaires'],
$this->opts = $this->reviewOpts;
$this->opts['disabled'] = $options['review'];
$this->reviewCmtOpts = [
'attr' => [
'placeholder' => 'Commentaires'
],
'label' => false,
'required' => false,
'required' => false
];
$this->labelEvalGlob = "évaluation globale";
}
$this->cmtOpts = $this->reviewCmtOpts;
$this->cmtOpts['disabled'] = $options['review'];
$this->cmtOpts['attr']['placeholder'] = $options['review'] ? '' : 'Commentaires';
public function buildForm(FormBuilderInterface $builder, array $options)
{
/* PARTIE 1 : ACCESSIBILITE ET INCLUSIVITE */
$this->opts['label'] = "Géographique et physique : le lieu est-il accessible par différents modes de transport ?";
$this->opts['choices'] = [
......@@ -117,8 +135,20 @@ class SelfEvalPrestaQuizType extends AbstractType
$builder->add('bienetre_global', ChoiceType::class, $this->opts);
$builder->add('bienetre_global_comment', TextareaType::class, $this->cmtOpts);
$builder->add('save', SubmitType::class, ['label' => 'Envoyer'])
;
//Review
if($options['review']) {
$this->reviewOpts['label'] = "Accessibilité et inclusivité : " . $this->reviewLabel;
$this->reviewOpts['choices'] = $this->stdGlobalChoices;
$builder->add('review_accessib_global', ChoiceType::class, $this->reviewOpts);
$builder->add('review_accessib_global_comment', TextareaType::class, $this->reviewCmtOpts);
$this->reviewOpts['label'] = "Bien-être au travail : " . $this->reviewLabel;
$this->reviewOpts['choices'] = $this->stdGlobalChoices;
$builder->add('review_bienetre_global', ChoiceType::class, $this->reviewOpts);
$builder->add('review_bienetre_global_comment', TextareaType::class, $this->reviewCmtOpts);
}
$builder->add('save', SubmitType::class, ['label' => $options['review'] ? 'Enregistrer' : 'Envoyer']);
}
/**
......@@ -128,6 +158,7 @@ class SelfEvalPrestaQuizType extends AbstractType
{
$resolver->setDefaults([
'data_class' => SelfEvalPrestaQuiz::class,
'review' => false //decide if prestataire is filling the form or if an admin is reviewing
]);
}
......
<?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 Version20240215192514 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 prestataire CHANGE iban iban LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:personal_data)\'');
$this->addSql('ALTER TABLE selfevalprestaquiz ADD review_accessib_global INT DEFAULT NULL, ADD review_accessib_global_comment LONGTEXT DEFAULT NULL, ADD review_bienetre_global INT DEFAULT NULL, ADD review_bienetre_global_comment LONGTEXT DEFAULT NULL, ADD review_transpar_global INT DEFAULT NULL, ADD review_transpar_global_comment LONGTEXT DEFAULT NULL, ADD review_disagdur_global INT DEFAULT NULL, ADD review_disagdur_global_comment LONGTEXT DEFAULT NULL, ADD review_proagdur_global INT DEFAULT NULL, ADD review_proagdur_global_comment LONGTEXT DEFAULT NULL, ADD review_localite_global INT DEFAULT NULL, ADD review_localite_global_comment LONGTEXT DEFAULT NULL');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE prestataire CHANGE iban iban LONGTEXT CHARACTER SET utf8 DEFAULT NULL COLLATE `utf8_general_ci` COMMENT \'(DC2Type:personal_data)\'');
$this->addSql('ALTER TABLE selfevalprestaquiz DROP review_accessib_global, DROP review_accessib_global_comment, DROP review_bienetre_global, DROP review_bienetre_global_comment, DROP review_transpar_global, DROP review_transpar_global_comment, DROP review_disagdur_global, DROP review_disagdur_global_comment, DROP review_proagdur_global, DROP review_proagdur_global_comment, DROP review_localite_global, DROP review_localite_global_comment');
}
}
......@@ -40,11 +40,20 @@
</div>
<div class="container global-evaluation-container">
<div class="row">
{{ form_label(form.accessib_global) }}
{{ form_label(form.transpar_global) }}
<div class="col">{{ form_widget(form.transpar_global) }}</div>
<div class="col">{{ form_row(form.transpar_global_comment) }}</div>
</div>
</div>
{% if form.review_transpar_global is defined %}
<div class="container review-container">
<div class="row">
{{ form_label(form.review_transpar_global) }}
<div class="col">{{ form_widget(form.review_transpar_global) }}</div>
<div class="col">{{ form_row(form.review_transpar_global_comment) }}</div>
</div>
</div>
{% endif %}
<br/>
<br/>
......@@ -72,6 +81,15 @@
<div class="col">{{ form_row(form.disagdur_global_comment) }}</div>
</div>
</div>
{% if form.review_disagdur_global is defined %}
<div class="container review-container">
<div class="row">
{{ form_label(form.review_disagdur_global) }}
<div class="col">{{ form_widget(form.review_disagdur_global) }}</div>
<div class="col">{{ form_row(form.review_disagdur_global_comment) }}</div>
</div>
</div>
{% endif %}
<br/>
<br/>
......@@ -99,6 +117,15 @@
<div class="col">{{ form_row(form.localite_global_comment) }}</div>
</div>
</div>
{% if form.review_localite_global is defined %}
<div class="container review-container">
<div class="row">
{{ form_label(form.review_localite_global) }}
<div class="col">{{ form_widget(form.review_localite_global) }}</div>
<div class="col">{{ form_row(form.review_localite_global_comment) }}</div>
</div>
</div>
{% endif %}
<br/>
<br/>
......
......@@ -72,6 +72,15 @@
<div class="col">{{ form_row(form.proagdur_global_comment) }}</div>
</div>
</div>
{% if form.review_proagdur_global is defined %}
<div class="container review-container">
<div class="row">
{{ form_label(form.review_proagdur_global) }}
<div class="col">{{ form_widget(form.review_proagdur_global) }}</div>
<div class="col">{{ form_row(form.review_proagdur_global_comment) }}</div>
</div>
</div>
{% endif %}
<br/>
<br/>
......
{% if object.selfevalprestaquiz %}
<a class="btn btn-sm btn-default" href="{{ admin.generateObjectUrl('reviewprestaquiz', object) }}">
Revue QCM
</a>
{% endif %}
......@@ -46,7 +46,15 @@
<div class="col">{{ form_row(form.accessib_global_comment) }}</div>
</div>
</div>
{% if form.review_accessib_global is defined %}
<div class="container review-container">
<div class="row">
{{ form_label(form.review_accessib_global) }}
<div class="col">{{ form_widget(form.review_accessib_global) }}</div>
<div class="col">{{ form_row(form.review_accessib_global_comment) }}</div>
</div>
</div>
{% endif %}
<br/>
<br/>
<br/>
......@@ -87,4 +95,13 @@
<div class="col">{{ form_row(form.bienetre_global_comment) }}</div>
</div>
</div>
{% if form.review_bienetre_global is defined %}
<div class="container review-container">
<div class="row">
{{ form_label(form.review_bienetre_global) }}
<div class="col">{{ form_widget(form.review_bienetre_global) }}</div>
<div class="col">{{ form_row(form.review_bienetre_global_comment) }}</div>
</div>
</div>
{% endif %}
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