mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	[export] add dates for filter "user working on course"
This commit is contained in:
		
							
								
								
									
										6
									
								
								.changes/unreleased/Feature-20230629-131558.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.changes/unreleased/Feature-20230629-131558.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| kind: Feature | ||||
| body: '[export] on "filter by user working" on accompanying period, add two dates | ||||
|   to filters intervention within a period' | ||||
| time: 2023-06-29T13:15:58.070316708+02:00 | ||||
| custom: | ||||
|   Issue: "113" | ||||
| @@ -13,7 +13,10 @@ namespace Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters; | ||||
|  | ||||
| use Chill\MainBundle\Entity\User; | ||||
| use Chill\MainBundle\Export\FilterInterface; | ||||
| use Chill\MainBundle\Form\Type\PickRollingDateType; | ||||
| use Chill\MainBundle\Form\Type\PickUserDynamicType; | ||||
| use Chill\MainBundle\Service\RollingDate\RollingDate; | ||||
| use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; | ||||
| use Chill\MainBundle\Templating\Entity\UserRender; | ||||
| use Chill\PersonBundle\Entity\AccompanyingPeriod; | ||||
| use Chill\PersonBundle\Export\Declarations; | ||||
| @@ -27,11 +30,9 @@ use Symfony\Component\Form\FormBuilderInterface; | ||||
|  */ | ||||
| readonly class UserWorkingOnCourseFilter implements FilterInterface | ||||
| { | ||||
|     private const AI_ALIAS = 'user_working_on_course_filter_acc_info'; | ||||
|     private const AI_USERS = 'user_working_on_course_filter_users'; | ||||
|  | ||||
|     public function __construct( | ||||
|         private UserRender $userRender, | ||||
|         private RollingDateConverterInterface $rollingDateConverter, | ||||
|     ) { | ||||
|     } | ||||
|  | ||||
| @@ -40,11 +41,23 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface | ||||
|         $builder | ||||
|             ->add('users', PickUserDynamicType::class, [ | ||||
|                 'multiple' => true, | ||||
|             ]); | ||||
|             ]) | ||||
|             ->add('start_date', PickRollingDateType::class, [ | ||||
|                 'label' => 'export.filter.course.by_user_working.User working after' | ||||
|             ]) | ||||
|             ->add('end_date', PickRollingDateType::class, [ | ||||
|                 'label' => 'export.filter.course.by_user_working.User working before' | ||||
|             ]) | ||||
|         ; | ||||
|     } | ||||
|  | ||||
|     public function getFormDefaultData(): array | ||||
|     { | ||||
|         return []; | ||||
|         return [ | ||||
|             'users' => [], | ||||
|             'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START), | ||||
|             'end_date' => new RollingDate(RollingDate::T_TODAY), | ||||
|         ]; | ||||
|     } | ||||
|  | ||||
|     public function getTitle(): string | ||||
| @@ -55,7 +68,7 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface | ||||
|     public function describeAction($data, $format = 'string'): array | ||||
|     { | ||||
|         return [ | ||||
|             'export.filter.course.by_user_working.Filtered by user working on course: only %users%', [ | ||||
|             'export.filter.course.by_user_working.Filtered by user working on course: only %users%, between %start_date% and %end_date%', [ | ||||
|                 '%users%' => implode( | ||||
|                     ', ', | ||||
|                     array_map( | ||||
| @@ -63,6 +76,8 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface | ||||
|                         $data['users'] | ||||
|                     ) | ||||
|                 ), | ||||
|                 '%start_date%' => $this->rollingDateConverter->convert($data['start_date'])?->format('d-m-Y'), | ||||
|                 '%end_date%' => $this->rollingDateConverter->convert($data['end_date'])?->format('d-m-Y'), | ||||
|             ], | ||||
|         ]; | ||||
|     } | ||||
| @@ -74,14 +89,21 @@ readonly class UserWorkingOnCourseFilter implements FilterInterface | ||||
|  | ||||
|     public function alterQuery(QueryBuilder $qb, $data): void | ||||
|     { | ||||
|         $ai_alias = 'user_working_on_course_filter_acc_info'; | ||||
|         $ai_users = 'user_working_on_course_filter_users'; | ||||
|         $start = 'acp_use_work_on_start'; | ||||
|         $end = 'acp_use_work_on_end'; | ||||
|  | ||||
|         $qb | ||||
|             ->andWhere( | ||||
|                 $qb->expr()->exists( | ||||
|                     "SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " " . self::AI_ALIAS . " " . | ||||
|                     "WHERE " . self::AI_ALIAS . ".user IN (:" . self::AI_USERS .") AND IDENTITY(" . self::AI_ALIAS . ".accompanyingPeriod) = acp.id" | ||||
|                     "SELECT 1 FROM " . AccompanyingPeriod\AccompanyingPeriodInfo::class . " {$ai_alias}  " . | ||||
|                     "WHERE {$ai_alias}.user IN (:{$ai_users}) AND IDENTITY({$ai_alias}.accompanyingPeriod) = acp.id AND {$ai_alias}.infoDate >= :{$start} and {$ai_alias}.infoDate < :{$end}" | ||||
|                 ) | ||||
|             ) | ||||
|             ->setParameter(self::AI_USERS, $data['users']) | ||||
|             ->setParameter($ai_users, $data['users']) | ||||
|             ->setParameter($start, $this->rollingDateConverter->convert($data['start_date'])) | ||||
|             ->setParameter($end, $this->rollingDateConverter->convert($data['end_date'])) | ||||
|         ; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -1082,7 +1082,9 @@ export: | ||||
|                 Only course with events between %startDate% and %endDate%: Seulement les parcours ayant reçu une intervention entre le %startDate% et le %endDate% | ||||
|             by_user_working: | ||||
|                 title: Filter les parcours par intervenant | ||||
|                 'Filtered by user working on course: only %users%': 'Filtré par intervenants sur le parcours: seulement %users%' | ||||
|                 'Filtered by user working on course: only %users%, between %start_date% and %end_date%': 'Filtré par intervenants sur le parcours: seulement %users%, entre le %start_date% et le %end_date%' | ||||
|                 User working after: Intervention après le | ||||
|                 User working before: Intervention avant le | ||||
|             by_step: | ||||
|                 Filter by step: Filtrer les parcours par statut du parcours | ||||
|                 Filter by step between dates: Filtrer les parcours par statut du parcours entre deux dates | ||||
|   | ||||
		Reference in New Issue
	
	Block a user