mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
rdv: rdv-> activity: convert some fields
This commit is contained in:
parent
e8d8a57b4b
commit
17036e83ba
@ -205,6 +205,35 @@ class ActivityController extends AbstractController
|
|||||||
$entity->setType($activityType);
|
$entity->setType($activityType);
|
||||||
$entity->setDate(new \DateTime('now'));
|
$entity->setDate(new \DateTime('now'));
|
||||||
|
|
||||||
|
if ($request->query->has('activityData')) {
|
||||||
|
$activityData = $request->query->get('activityData');
|
||||||
|
|
||||||
|
$durationTimeInMinutes = $activityData['durationTime'];
|
||||||
|
$hours = floor($durationTimeInMinutes / 60);
|
||||||
|
$minutes = $durationTimeInMinutes % 60;
|
||||||
|
|
||||||
|
$duration = \DateTime::createFromFormat("H:i", $hours.':'.$minutes);
|
||||||
|
if ($duration) {
|
||||||
|
$entity->setDurationTime($duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
$date = \DateTime::createFromFormat('Y-m-d', $activityData['date']);
|
||||||
|
if ($date) {
|
||||||
|
$entity->setDate($date);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($activityData['personsId'] as $personId){
|
||||||
|
$person = $em->getRepository(\Chill\PersonBundle\Entity\Person::class)->find($personId);
|
||||||
|
$entity->addPerson($person);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($activityData['professionalsId'] as $professionalsId){
|
||||||
|
$professional = $em->getRepository(\Chill\ThirdPartyBundle\Entity\ThirdParty::class)->find($professionalsId);
|
||||||
|
$entity->addThirdParty($professional);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période
|
// TODO revoir le Voter de Activity pour tenir compte qu'une activité peut appartenir a une période
|
||||||
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity);
|
// $this->denyAccessUnlessGranted('CHILL_ACTIVITY_CREATE', $entity);
|
||||||
|
|
||||||
|
@ -225,11 +225,14 @@ class CalendarController extends AbstractController
|
|||||||
array_push($professionalsId, $p->getId());
|
array_push($professionalsId, $p->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$durationTime = $entity->getEndDate()->diff($entity->getStartDate());
|
||||||
|
$durationTimeInMinutes = $durationTime->days*1440 + $durationTime->h*60 + $durationTime->i;
|
||||||
|
|
||||||
$activityData = [
|
$activityData = [
|
||||||
'personsId' => $personsId,
|
'personsId' => $personsId,
|
||||||
'professionalsId' => $professionalsId,
|
'professionalsId' => $professionalsId,
|
||||||
'date' => $entity->getStartDate()->format('Y-m-d'),
|
'date' => $entity->getStartDate()->format('Y-m-d'),
|
||||||
'durationTime' => $entity->getEndDate()->diff($entity->getStartDate())->format("%H:%M")
|
'durationTime' => $durationTimeInMinutes
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->render($view, [
|
return $this->render($view, [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user