@@ -302,16 +302,16 @@ private function loadResourcesAvailabilities(ObjectManager $manager, array $reso
302302 $ resourcePartiallyAvailable = \array_slice ($ resourcesRandom , $ index , (int ) ($ resourceCount * $ percentPartiallyAvailable ));
303303
304304 // Creating slots locked
305- $ data = $ this ->createAvailabilities ($ resourceLocked , $ today , AvailabilityInterface::STATUS_LOCKED );
305+ $ data = $ this ->createAvailabilities ($ resourceLocked , $ today , AvailabilityInterface::STATUS_LOCKED , false , ' Raison médicale ' );
306306
307307 // Creating slots available
308308 $ data = array_merge ($ data , $ this ->createAvailabilities ($ resourceAvailable , $ today , AvailabilityInterface::STATUS_AVAILABLE ));
309309
310310 // Creating slots partially available
311- $ data = array_merge ($ data , $ this ->createAvailabilities ($ resourcePartiallyAvailable , $ today , AvailabilityInterface::STATUS_AVAILABLE , true ));
311+ $ data = array_merge ($ data , $ this ->createAvailabilities ($ resourcePartiallyAvailable , $ today , AvailabilityInterface::STATUS_AVAILABLE , true , ' Alpha ' . random_int ( 1 , 8 ) ));
312312
313313 $ insert = sprintf (
314- 'INSERT INTO %s (id, %s, start_time, end_time, status, created_at, updated_at, planning_agent_id) VALUES %s ' ,
314+ 'INSERT INTO %s (id, %s, start_time, end_time, status, created_at, updated_at, planning_agent_id, comment ) VALUES %s ' ,
315315 $ manager ->getClassMetadata ($ class )->getTableName (),
316316 UserAvailability::class === $ class ? 'user_id ' : 'asset_id ' ,
317317 implode (', ' , $ data )
@@ -327,7 +327,7 @@ private function loadResourcesAvailabilities(ObjectManager $manager, array $reso
327327 $ manager ->getConnection ()->exec (sprintf ('SELECT setval( \'' .$ sequence .'\', %d, true) ' , $ this ->availabilitiesId ));
328328 }
329329
330- private function createAvailabilities (array $ objects , \DateTimeInterface $ thisWeek , string $ globalStatus , bool $ partiallyAvailable = false ): array
330+ private function createAvailabilities (array $ objects , \DateTimeInterface $ thisWeek , string $ globalStatus , bool $ partiallyAvailable = false , string $ defaultComment = '' ): array
331331 {
332332 $ data = [];
333333
@@ -360,14 +360,18 @@ private function createAvailabilities(array $objects, \DateTimeInterface $thisWe
360360 $ organizationId = $ this ->getRandomOrganization ();
361361 }
362362
363- $ data [] = '( ' .$ this ->availabilitiesId ++.', ' .
364- $ object ->getId ().', ' .
365- "' " .$ slot ->format ('Y-m-d H:i:s ' )."', " .
366- "' " .$ this ->closeInterval ($ slot )->format ('Y-m-d H:i:s ' )."', " .
367- "' " .$ status ."', " .
368- "' " .date ('Y-m-d H:i:s ' )."', " .
369- "' " .date ('Y-m-d H:i:s ' )."', " .
370- ($ organizationId ?: 'NULL ' ).') ' ;
363+ $ data [] = sprintf (
364+ "(%d,%d,'%s','%s','%s','%s','%s',%s, '%s') " ,
365+ $ this ->availabilitiesId ++,
366+ $ object ->getId (),
367+ $ slot ->format ('Y-m-d H:i:s ' ),
368+ $ this ->closeInterval ($ slot )->format ('Y-m-d H:i:s ' ),
369+ $ status ,
370+ date ('Y-m-d H:i:s ' ),
371+ date ('Y-m-d H:i:s ' ),
372+ $ organizationId ?: 'NULL ' ,
373+ AvailabilityInterface::STATUS_AVAILABLE !== $ status ? $ defaultComment : '' ,
374+ );
371375 }
372376
373377 $ slot = $ slot ->add (new \DateInterval (self ::SLOT_INTERVAL ));
0 commit comments