diff --git a/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php b/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php
index 21189f55e..1a0287a71 100644
--- a/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php
+++ b/src/Bundle/ChillDocStoreBundle/GenericDoc/Manager.php
@@ -73,7 +73,7 @@ class Manager
): iterable {
['sql' => $sql, 'params' => $params, 'types' => $types] = $this->buildUnionQuery($accompanyingPeriod, $startDate, $endDate, $content, $origin);
- $runSql = "{$sql} LIMIT ? OFFSET ?";
+ $runSql = "{$sql} ORDER BY doc_date DESC LIMIT ? OFFSET ?";
$runParams = [...$params, ...[$limit, $offset]];
$runTypes = [...$types, ...[Types::INTEGER, Types::INTEGER]];
diff --git a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php
index ee9978735..8c6bd524d 100644
--- a/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php
+++ b/src/Bundle/ChillDocStoreBundle/Tests/GenericDoc/Providers/AccompanyingCourseDocumentProviderTest.php
@@ -63,9 +63,10 @@ class AccompanyingCourseDocumentProviderTest extends KernelTestCase
['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query);
- $this->entityManager->getConnection()->executeQuery($sql, $params, $types);
+ $nb = $this->entityManager->getConnection()->executeQuery('SELECT COUNT(*) FROM ('.$sql.') AS sq', $params, $types)
+ ->fetchOne();
- self::assertTrue(true, "test that no errors occurs");
+ self::assertIsInt($nb);
}
public function provideSearchArguments(): iterable
diff --git a/src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig
new file mode 100644
index 000000000..255139bb4
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Resources/views/GenericDoc/evaluation_document.html.twig
@@ -0,0 +1,75 @@
+{% import "@ChillDocStore/Macro/macro.html.twig" as m %}
+{% import "@ChillDocStore/Macro/macro_mimeicon.html.twig" as mm %}
+{% import '@ChillPerson/Macro/updatedBy.html.twig' as mmm %}
+
+{% set w = document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork %}
+
+
+
+
+ {% if document.storedObject.isPending %}
+
{{ 'docgen.Doc generation is pending'|trans }}
+ {% elseif document.storedObject.isFailure %}
+
{{ 'docgen.Doc generation failed'|trans }}
+ {% endif %}
+
+ {{ document.title }}
+
+ {% if document.storedObject.type is not empty %}
+
+ {{ mm.mimeIcon(document.storedObject.type) }}
+
+ {% endif %}
+ {% if document.storedObject.hasTemplate %}
+
+
{{ document.storedObject.template.name|localize_translatable_string }}
+
+ {% endif %}
+
+
+
+
+
+ {{ document.storedObject.createdAt|format_date('short') }}
+
+
+
+
+
+
+
+
+
+ {{ w.socialAction|chill_entity_render_string }} > {{ document.accompanyingPeriodWorkEvaluation.evaluation.title|localize_translatable_string }}
+
+
+
+
+
+
+
+ {{ mmm.createdBy(document) }}
+
+
+ -
+ {{ chill_entity_workflow_list('Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', document.id) }}
+
+ {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_EVALUATION_DOCUMENT_SHOW', document) %}
+ -
+ {{ document.storedObject|chill_document_button_group(document.title, is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', document.accompanyingPeriodWorkEvaluation.accompanyingPeriodWork)) }}
+
+ {% endif %}
+ {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_SEE', w)%}
+ -
+
+
+ {% endif %}
+ {% if is_granted('CHILL_MAIN_ACCOMPANYING_PERIOD_WORK_UPDATE', w) %}
+ -
+
+
+ {% endif %}
+
+
+
+
diff --git a/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php
new file mode 100644
index 000000000..834375bfc
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProvider.php
@@ -0,0 +1,105 @@
+entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument::class);
+ $storedObjectMetadata = $this->entityManager->getClassMetadata(StoredObject::class);
+ $evaluationMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWorkEvaluation::class);
+ $accompanyingPeriodWorkMetadata = $this->entityManager->getClassMetadata(AccompanyingPeriod\AccompanyingPeriodWork::class);
+
+ $query = new FetchQuery(
+ self::KEY,
+ sprintf("jsonb_build_object('id', apwed.%s)", $classMetadata->getColumnName('id')),
+ sprintf('apwed.'.$storedObjectMetadata->getColumnName('createdAt')),
+ $classMetadata->getTableName().' AS apwed'
+ );
+ $query->addJoinClause(sprintf(
+ 'JOIN %s doc_store ON doc_store.%s = apwed.%s',
+ $storedObjectMetadata->getSchemaName().'.'.$storedObjectMetadata->getTableName(),
+ $storedObjectMetadata->getColumnName('id'),
+ $classMetadata->getSingleAssociationJoinColumnName('storedObject')
+ ));
+ $query->addJoinClause(sprintf(
+ 'JOIN %s evaluation ON apwed.%s = evaluation.%s',
+ $evaluationMetadata->getTableName(),
+ $classMetadata->getAssociationMapping('accompanyingPeriodWorkEvaluation')['joinColumns'][0]['name'],
+ $evaluationMetadata->getColumnName('id')
+ ));
+ $query->addJoinClause(sprintf(
+ 'JOIN %s action ON evaluation.%s = action.%s',
+ $accompanyingPeriodWorkMetadata->getTableName(),
+ $evaluationMetadata->getAssociationMapping('accompanyingPeriodWork')['joinColumns'][0]['name'],
+ $accompanyingPeriodWorkMetadata->getColumnName('id')
+ ));
+
+ $query->addWhereClause(
+ sprintf('action.%s = ?', $accompanyingPeriodWorkMetadata->getAssociationMapping('accompanyingPeriod')['joinColumns'][0]['name']),
+ [$accompanyingPeriod->getId()],
+ [Types::INTEGER]
+ );
+
+ if (null !== $startDate) {
+ $query->addWhereClause(
+ sprintf('doc_store.%s <= ?', $storedObjectMetadata->getColumnName('createdAt')),
+ [$startDate],
+ [Types::DATE_IMMUTABLE]
+ );
+ }
+
+ if (null !== $endDate) {
+ $query->addWhereClause(
+ sprintf('doc_store.%s > ?', $storedObjectMetadata->getColumnName('createdAt')),
+ [$endDate],
+ [Types::DATE_IMMUTABLE]
+ );
+ }
+
+ if (null !== $content) {
+ $query->addWhereClause(
+ sprintf('apwed.%s ilike ?', $classMetadata->getColumnName('title')),
+ ['%' . $content . '%'],
+ [Types::STRING]
+ );
+ }
+
+ return $query;
+ }
+
+ public function isAllowedForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod): bool
+ {
+ return $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $accompanyingPeriod);
+ }
+
+
+}
diff --git a/src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php
new file mode 100644
index 000000000..5da8297fb
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Service/GenericDoc/Renderer/AccompanyingPeriodWorkEvaluationGenericDocRenderer.php
@@ -0,0 +1,42 @@
+key === AccompanyingPeriodWorkEvaluationGenericDocProvider::KEY;
+ }
+
+ public function getTemplate(GenericDocDTO $genericDocDTO, $options = []): string
+ {
+ return '@ChillPerson/GenericDoc/evaluation_document.html.twig';
+ }
+
+ public function getTemplateData(GenericDocDTO $genericDocDTO, $options = []): array
+ {
+ return [
+ 'document' => $this->accompanyingPeriodWorkEvaluationDocumentRepository->find($genericDocDTO->identifiers['id'])
+ ];
+ }
+}
diff --git a/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php
new file mode 100644
index 000000000..c9ed96581
--- /dev/null
+++ b/src/Bundle/ChillPersonBundle/Tests/Service/GenericDoc/Providers/AccompanyingPeriodWorkEvaluationGenericDocProviderTest.php
@@ -0,0 +1,79 @@
+entityManager = self::$container->get(EntityManagerInterface::class);
+ }
+
+ /**
+ * @dataProvider provideSearchArguments
+ */
+ public function testBuildFetchQueryForAccompanyingPeriod(
+ ?\DateTimeImmutable $startDate = null,
+ ?\DateTimeImmutable $endDate = null,
+ ?string $content = null
+ ): void {
+ $period = $this->entityManager->createQuery("SELECT a FROM " . AccompanyingPeriod::class . ' a')
+ ->setMaxResults(1)
+ ->getSingleResult();
+
+ if (null === $period) {
+ throw new \RuntimeException('no accompanying period in databasee');
+ }
+
+ $security = $this->prophesize(Security::class);
+
+ $provider = new AccompanyingPeriodWorkEvaluationGenericDocProvider(
+ $security->reveal(),
+ $this->entityManager
+ );
+
+ $query = $provider->buildFetchQueryForAccompanyingPeriod($period, $startDate, $endDate, $content);
+ ['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query);
+
+ $nb = $this->entityManager->getConnection()->executeQuery(
+ 'SELECT COUNT(*) FROM ('.$sql.') AS sq',
+ $params,
+ $types
+ )->fetchOne();
+
+ self::assertIsInt($nb, "Test that there are no errors");
+ }
+
+ public function provideSearchArguments(): iterable
+ {
+ yield [null, null, null];
+ yield [new \DateTimeImmutable('1 month ago'), null, null];
+ yield [new \DateTimeImmutable('1 month ago'), new \DateTimeImmutable('now'), null];
+ yield [null, null, 'test'];
+ }
+}