mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
exports avg_accompanying_course_duration with closingdate parameter
This commit is contained in:
parent
903ac2ff69
commit
34923df43c
@ -11,29 +11,46 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Export\Export;
|
namespace Chill\PersonBundle\Export\Export;
|
||||||
|
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
use Chill\MainBundle\Export\ExportInterface;
|
||||||
|
use Chill\MainBundle\Export\FormatterInterface;
|
||||||
use Chill\MainBundle\Export\GroupedExportInterface;
|
use Chill\MainBundle\Export\GroupedExportInterface;
|
||||||
use Chill\MainBundle\Export\ListInterface;
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
|
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|
||||||
|
|
||||||
class StatAccompanyingCourseDuration implements ListInterface, ExportElementValidatedInterface, GroupedExportInterface
|
class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private AccompanyingPeriodRepository $periodRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @param AccompanyingPeriodRepository $periodRepository
|
||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function __construct(
|
||||||
{
|
AccompanyingPeriodRepository $periodRepository
|
||||||
// TODO: Implement buildForm() method.
|
) {
|
||||||
|
$this->periodRepository = $periodRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getTitle()
|
public function buildForm(FormBuilderInterface $builder): void
|
||||||
|
{
|
||||||
|
$builder->add('closingdate', ChillDateType::class, [
|
||||||
|
'label' => 'Closingdate to apply',
|
||||||
|
'data' => new \DateTime('now'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle(): string
|
||||||
{
|
{
|
||||||
return 'Accompanying courses duration';
|
return 'Accompanying courses duration';
|
||||||
}
|
}
|
||||||
@ -41,15 +58,15 @@ class StatAccompanyingCourseDuration implements ListInterface, ExportElementVali
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getAllowedFormattersTypes()
|
public function getAllowedFormattersTypes(): array
|
||||||
{
|
{
|
||||||
// TODO: Implement getAllowedFormattersTypes() method.
|
return [FormatterInterface::TYPE_TABULAR];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getDescription()
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'Create an average of accompanying courses duration according to various filters';
|
return 'Create an average of accompanying courses duration according to various filters';
|
||||||
}
|
}
|
||||||
@ -59,39 +76,67 @@ class StatAccompanyingCourseDuration implements ListInterface, ExportElementVali
|
|||||||
*/
|
*/
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
{
|
{
|
||||||
// TODO: Implement getLabels() method.
|
if ('export_result' !== $key) {
|
||||||
|
throw new LogicException("the key {$key} is not used by this export");
|
||||||
|
}
|
||||||
|
|
||||||
|
$labels = array_combine($values, $values);
|
||||||
|
$labels['_header'] = $this->getTitle();
|
||||||
|
|
||||||
|
return static function ($value) use ($labels) {
|
||||||
|
return $labels[$value];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getQueryKeys($data)
|
public function getQueryKeys($data): array
|
||||||
{
|
{
|
||||||
// TODO: Implement getQueryKeys() method.
|
return ['export_result'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getResult($query, $data)
|
public function getResult($qb, $data)
|
||||||
{
|
{
|
||||||
// TODO: Implement getResult() method.
|
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getType()
|
public function getType(): string
|
||||||
{
|
{
|
||||||
// TODO: Implement getType() method.
|
return 'accompanying_course';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
|
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
|
||||||
{
|
{
|
||||||
// TODO: Implement initiateQuery() method.
|
$qb = $this->periodRepository->createQueryBuilder('acp');
|
||||||
|
$expr = $qb->expr();
|
||||||
|
|
||||||
|
$force_closingdate = $data['closingdate']; // parameter from buildForm
|
||||||
|
|
||||||
|
$qb
|
||||||
|
->select('AVG(
|
||||||
|
( CASE
|
||||||
|
WHEN acp.closingDate IS NOT NULL
|
||||||
|
THEN acp.closingDate
|
||||||
|
ELSE :force_closingDate
|
||||||
|
END ) - acp.openingDate
|
||||||
|
) AS export_result')
|
||||||
|
->where($expr->neq(
|
||||||
|
'acp.step', $expr->literal('DRAFT')
|
||||||
|
))
|
||||||
|
->setParameter('force_closingDate', $force_closingdate)
|
||||||
|
;
|
||||||
|
|
||||||
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,14 +150,9 @@ class StatAccompanyingCourseDuration implements ListInterface, ExportElementVali
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function supportsModifiers()
|
public function supportsModifiers(): array
|
||||||
{
|
{
|
||||||
// TODO: Implement supportsModifiers() method.
|
return [];
|
||||||
}
|
|
||||||
|
|
||||||
public function validateForm($data, ExecutionContextInterface $context)
|
|
||||||
{
|
|
||||||
// TODO: Implement validateForm() method.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGroup(): string
|
public function getGroup(): string
|
||||||
|
@ -33,11 +33,12 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export, alias: count_accompanying_course }
|
- { name: chill.export, alias: count_accompanying_course }
|
||||||
|
|
||||||
chill.person.export.sum_accompanying_course_duration:
|
chill.person.export.avg_accompanying_course_duration:
|
||||||
class: Chill\PersonBundle\Export\Export\StatAccompanyingCourseDuration
|
class: Chill\PersonBundle\Export\Export\StatAccompanyingCourseDuration
|
||||||
arguments:
|
arguments:
|
||||||
|
- '@Chill\PersonBundle\Repository\AccompanyingPeriodRepository'
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export, alias: sum_accompanying_course_duration }
|
- { name: chill.export, alias: avg_accompanying_course_duration }
|
||||||
|
|
||||||
chill.person.export.filter_gender:
|
chill.person.export.filter_gender:
|
||||||
class: Chill\PersonBundle\Export\Filter\GenderFilter
|
class: Chill\PersonBundle\Export\Filter\GenderFilter
|
||||||
|
@ -337,11 +337,13 @@ Fields to include in export: Champs à inclure dans l'export
|
|||||||
Address valid at this date: Addresse valide à cette date
|
Address valid at this date: Addresse valide à cette date
|
||||||
List duplicates: Liste des doublons
|
List duplicates: Liste des doublons
|
||||||
Create a list of duplicate people: Créer la liste des personnes détectées comme doublons.
|
Create a list of duplicate people: Créer la liste des personnes détectées comme doublons.
|
||||||
|
|
||||||
Exports of accompanying courses: Exports des parcours d'accompagnement
|
Exports of accompanying courses: Exports des parcours d'accompagnement
|
||||||
Count accompanying courses: Nombre de parcours
|
Count accompanying courses: Nombre de parcours
|
||||||
Count accompanying courses by various parameters: Compte le nombre de parcours en fonction de différents filtres.
|
Count accompanying courses by various parameters: Compte le nombre de parcours en fonction de différents filtres.
|
||||||
Accompanying courses duration: Durée des parcours
|
Accompanying courses duration: Durée moyenne des parcours
|
||||||
Create an average of accompanying courses duration according to various filters: Moyenne de la durée des parcours selon différents filtres.
|
Create an average of accompanying courses duration according to various filters: Moyenne de la durée des parcours en jours, selon différents filtres.
|
||||||
|
Closingdate to apply: Date de fin à prendre en compte lorsque le parcours n'est pas clotûré
|
||||||
|
|
||||||
## filters
|
## filters
|
||||||
Filter by person gender: Filtrer par genre de la personne
|
Filter by person gender: Filtrer par genre de la personne
|
||||||
|
Loading…
x
Reference in New Issue
Block a user