-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'import-2023' into preprod
- Loading branch information
Showing
12 changed files
with
323 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filter; | ||
|
||
use App\Form\Type\AgeFilterType; | ||
use Doctrine\DBAL\Query\QueryBuilder; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
/** | ||
* Filter on Age Min & max. | ||
*/ | ||
class AgeFilter implements FilterInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder) | ||
{ | ||
$builder->add('age', AgeFilterType::class, [ | ||
'label' => 'filter.age', | ||
]); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildQuery(QueryBuilder $queryBuilder, array $values = []) | ||
{ | ||
if (!\array_key_exists('age', $values)) { | ||
return; | ||
} | ||
|
||
// Switch min and max age if user has inverted the fields | ||
if (isset($values['age']['min']) | ||
&& isset($values['age']['max']) | ||
&& $values['age']['max'] < $values['age']['min'] | ||
) { | ||
list($values['age']['min'], $values['age']['max']) = | ||
[$values['age']['max'], $values['age']['min']]; | ||
} | ||
|
||
if (isset($values['age']['min'])) { | ||
$queryBuilder | ||
->andWhere('response.age >= :minAge') | ||
->setParameter('minAge', $values['age']['min']); | ||
} | ||
|
||
if (isset($values['age']['max'])) { | ||
$queryBuilder | ||
->andWhere('response.age <= :maxAge') | ||
->setParameter('maxAge', $values['age']['max']); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function convertValuesToLabels($value) | ||
{ | ||
// Switch min and max if user has inverted the fields | ||
if (isset($value['min']) && isset($value['max']) && $value['max'] < $value['min']) { | ||
list($value['max'], $value['min']) = [$value['min'], $value['max']]; | ||
} | ||
|
||
$labels = []; | ||
if (isset($value['min'])) { | ||
$labels['min'] = '>= '.$value['min'].' ans'; | ||
} | ||
|
||
if (isset($value['max'])) { | ||
$labels['max'] = '<= '.$value['max'].' ans'; | ||
} | ||
|
||
return $labels; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'age'; | ||
} | ||
|
||
/** | ||
* Filter weight. | ||
* | ||
* @return int | ||
*/ | ||
public function getWeight() | ||
{ | ||
return 11; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Form\Type; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\IntegerType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
/** | ||
* Age Filter Type. | ||
*/ | ||
class AgeFilterType extends AbstractType | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder | ||
->add('min', IntegerType::class, ['required' => false, 'attr' => ['placeholder' => 'filter.age.min']]) | ||
->add('max', IntegerType::class, ['required' => false, 'attr' => ['placeholder' => 'filter.age.max']]) | ||
; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getBlockPrefix(): string | ||
{ | ||
return 'age'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Report; | ||
|
||
class AgeReport extends AbstractReport | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function execute() | ||
{ | ||
$this->queryBuilder | ||
->select('response.age as age') | ||
->addSelect('COUNT(response.id) as nbResponse') | ||
->andWhere('response.age > 0') | ||
->addGroupBy('response.age'); | ||
|
||
$this->data = $this->queryBuilder->fetchAllAssociative(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'age'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Report; | ||
|
||
class RetrainingEvolutionReport extends AbstractDistributionEvolutionReport | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'retraining_evolution'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getFieldName() | ||
{ | ||
return 'retraining'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Report; | ||
|
||
class RetrainingReport extends AbstractReport | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function execute() | ||
{ | ||
$this->queryBuilder | ||
->select('response.retraining as retraining') | ||
->addSelect('COUNT(response.id) as nbResponse') | ||
->addGroupBy('response.retraining'); | ||
|
||
$this->data = $this->queryBuilder->fetchAllAssociative(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return 'retraining'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<table class="table table-striped highchart tablesorter" | ||
data-graph-container-before="1" | ||
data-graph-type="column" | ||
data-graph-legend-disabled="1"> | ||
<thead> | ||
<tr> | ||
<th>{{ 'report.view.age' | trans }}</th> | ||
<th>{{ "report.view.response_number" | trans }}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for row in results %} | ||
<tr> | ||
<td>{{ row.age }}</td> | ||
<td class="text-right">{{ row.nbResponse }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<table class="table table-striped highchart tablesorter" | ||
data-graph-container-before="1" | ||
data-graph-type="column" | ||
data-graph-legend-disabled="1"> | ||
<thead> | ||
<tr> | ||
<th>{{ "report.view.retraining" | trans }}</th> | ||
<th>{{ "report.view.response_number" | trans }}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for row in results %} | ||
<tr> | ||
<td> | ||
{{ row.retraining|enum_label('App\\Enums\\RetrainingEnums') }} | ||
</td> | ||
<td class="text-right">{{ row.nbResponse }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% set color = { | ||
(constant('App\\Enums\\RetrainingEnums::YES_SHORT')):'#3D96AE', | ||
(constant('App\\Enums\\RetrainingEnums::YES_LONG')):'#89A54E', | ||
(constant('App\\Enums\\RetrainingEnums::YES_WITHOUT_TRAINING')):'#80699B', | ||
(constant('App\\Enums\\RetrainingEnums::NO')):'#4C6EAF', | ||
} | ||
%} | ||
|
||
{% set fieldName = 'App\\Enums\\RetrainingEnums' %} | ||
{% set title = 'Année' %} | ||
|
||
{% block report_content %} | ||
{% include 'Report/_distribution_evolution_report.html.twig' with {'color': color, 'fieldName': fieldName} %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters