public function loadEvents(CalendarEvent $calendarEvent) { $startDate = $calendarEvent->getStartDatetime(); $endDate = $calendarEvent->getEndDatetime(); // The original request so you can get filters from the calendar // Use the filter in your query for example $request = $calendarEvent->getRequest(); $filter = $request->get('filter'); // load events using your custom logic here, // for instance, retrieving events from a repository $companyEvents = $this->container->get('doctrine')->getEntityManager()->getRepository('AppBundle:Appointment')->createQueryBuilder('appointemnt')->where('appointemnt.startDatetime BETWEEN :startDate and :endDate AND appointemnt.specialist = :specialist_id')->setParameter('startDate', $startDate->format('Y-m-d H:i:s'))->setParameter('endDate', $endDate->format('Y-m-d H:i:s'))->setParameter('specialist_id', $request->request->get('specialist_id'))->getQuery()->getResult(); // $companyEvents and $companyEvent in this example // represent entities from your database, NOT instances of EventEntity // within this bundle. // // Create EventEntity instances and populate it's properties with data // from your own entities/database values. foreach ($companyEvents as $companyEvent) { $startDate = $companyEvent->getStartDatetime(); $eventEntity = new EventEntity($companyEvent->getStartDatetime()->format($this->container->getParameter('date.format')), $companyEvent->getStartDatetime(), $companyEvent->getEndDatetime()); //optional calendar event settings $eventEntity->setBgColor('#337ab7'); //set the background color of the event's label $eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label $eventEntity->setUrl('http://www.google.com'); // url to send user to when event label is clicked $eventEntity->setCssClass('my-custom-class'); // a custom class you may want to apply to event labels //finally, add the event to the CalendarEvent for displaying on the calendar $calendarEvent->addEvent($eventEntity); } }
public function loadEvents(CalendarEvent $calendarEvent) { $startDateFilter = $calendarEvent->getStartDatetime(); $endDateFilter = $calendarEvent->getEndDatetime(); // alert('event listener!'); // The original request so you can get filters from the calendar // Use the filter in your query for example $request = $calendarEvent->getRequest(); $filter = $request->get('filter'); // load events using your custom logic here, // for instance, retrieving events from a repository $classEvents = $this->entityManager->getRepository('SiploCalendarBundle:Event')->createQueryBuilder('company_events')->where('company_events.startDatetime BETWEEN :startDate and :endDate')->setParameter('startDate', $startDateFilter->format('Y-m-d H:i:s'))->setParameter('endDate', $endDateFilter->format('Y-m-d H:i:s'))->getQuery()->getResult(); // $companyEvents and $companyEvent in this example // represent entities from your database, NOT instances of EventEntity // within this bundle. // // Create EventEntity instances and populate it's properties with data // from your own entities/database values. foreach ($classEvents as $classEvent) { $eventEntity = new EventEntity($classEvent->getTitle(), $classEvent->getStartDatetime(), $classEvent->getEndDatetime(), false); //optional calendar event settings // $eventEntity->setAllDay(true); // default is false, set to true if this is an all day event $eventEntity->setBgColor($classEvent->getBgColor()); //set the background color of the event's label $eventEntity->setFgColor('#000000'); //set the foreground color of the event's label $eventEntity->setUrl('http://www.google.com'); // url to send user to when event label is clicked $eventEntity->setCssClass('my-custom-class'); // a custom class you may want to apply to event labels //finally, add the event to the CalendarEvent for displaying on the calendar $calendarEvent->addEvent($eventEntity); } }
public function loadEvents(CalendarEvent $calendarEvent) { $startDate = $calendarEvent->getStartDatetime(); $endDate = $calendarEvent->getEndDatetime(); // The original request so you can get filters from the calendar // Use the filter in your query for example $request = $calendarEvent->getRequest(); $filter = $request->get('filter'); // load events using your custom logic here, // for instance, retrieving events from a repository $companyEvents = $this->entityManager->getRepository('AppBundle:Event')->findCurrent(); // $companyEvents and $companyEvent in this example // represent entities from your database, NOT instances of EventEntity // within this bundle. // // Create EventEntity instances and populate it's properties with data // from your own entities/database values. foreach ($companyEvents as $companyEvent) { // create an event with a start/end time, or an all day event $eventEntity = new EventEntity($companyEvent->getTitle(), $companyEvent->getDatetime(), $companyEvent->getDatetime()); //optional calendar event settings $eventEntity->setBgColor('#971c1e'); //set the background color of the event's label $eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label //finally, add the event to the CalendarEvent for displaying on the calendar $calendarEvent->addEvent($eventEntity); } }
public function loadEvents(CalendarEvent $calendarEvent) { $startDate = $calendarEvent->getStartDatetime(); $endDate = $calendarEvent->getEndDatetime(); // load events using your custom logic here, // for instance, retrieving events from a repository //compruebo si el usuario es un cliente o un profesional if ($this->user->hasRole('ROLE_PROFESIONAL')) { //es un profesional $companyEvents = $this->entityManager->getRepository('UserProfesionalBundle:ProfessionalEvent')->createQueryBuilder('company_events')->where('company_events.start_date BETWEEN :startDate and :endDate AND company_events.professional = :user')->setParameter('user', $this->user->getProfessional()->getId())->setParameter('startDate', $startDate->format('Y-m-d H:i:s'))->setParameter('endDate', $endDate->format('Y-m-d H:i:s'))->getQuery()->getResult(); } else { //es un cliente $companyEvents = $this->entityManager->getRepository('UserProfesionalBundle:ProfessionalEvent')->createQueryBuilder('company_events')->where('company_events.start_date BETWEEN :startDate and :endDate AND company_events.client = :user')->setParameter('user', $this->user->getProfessional()->getId())->setParameter('startDate', $startDate->format('Y-m-d H:i:s'))->setParameter('endDate', $endDate->format('Y-m-d H:i:s'))->getQuery()->getResult(); } foreach ($companyEvents as $companyEvent) { // create an event with a start/end time, or an all day event $interval = new \DateInterval($companyEvent->getDuration()); $enddate = $companyEvent->getStartDate()->add($interval); $eventEntity = new EventEntity($companyEvent->getClient()->getUser()->getName() . " " . $companyEvent->getClient()->getUser()->getSurname(), $companyEvent->getStartDate(), $enddate); //optional calendar event settings $eventEntity->setAllDay(true); // default is false, set to true if this is an all day event $eventEntity->setBgColor('#5B9BB4'); //set the background color of the event's label $eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label $eventEntity->setUrl($this->router->generate('profesional_show_event', array('idEvent' => $companyEvent->getId()))); // url to send user to when event label is clicked $eventEntity->setCssClass('consulta'); // a custom class you may want to apply to event labels //finally, add the event to the CalendarEvent for displaying on the calendar $calendarEvent->addEvent($eventEntity); } }
public function loadEvents(CalendarEvent $calendarEvent) { $startDate = $calendarEvent->getStartDatetime(); $endDate = $calendarEvent->getEndDatetime(); $user = $this->securityContext->getToken()->getUser(); $instanceRepository = $this->entityManager->getRepository('TSKScheduleBundle:ScheduleInstance'); // TODO: Filter instances based on userId, schoolId, etc ... $scheduleInstances = $instanceRepository->createQueryBuilder('si')->where('si.start BETWEEN :startDate and :endDate')->setParameter(':startDate', $startDate->format('Y-m-d H:i:s'))->setParameter(':endDate', $endDate->format('Y-m-d H:i:s'))->getQuery()->getResult(); foreach ($scheduleInstances as $si) { $eventEntity = new EventEntity($si->getTitle(), $si->getStart(), $si->getEnd(), $si->getIsAllDay()); $eventEntity->setId($si->getId()); $color = ''; $classes = $si->getScheduleEntity()->getClasses(); if ($classes) { $class = $classes->first(); if (is_object($class)) { $color = $class->getScheduleColor(); } } if (!$color) { $color = $si->getScheduleEntity()->getCategory()->getColor(); } if ($color) { $eventEntity->setBgColor($color); } $calendarEvent->addEvent($eventEntity); } }
public function loadEvents(CalendarEvent $calendarEvent) { $startTime = new \DateTime(self::TEST_START_TIME); $endTime = new \DateTime(self::TEST_END_TIME); if ($calendarEvent->getStartDatetime()->getTimestamp() === $startTime->getTimestamp() && $calendarEvent->getEndDatetime()->getTimestamp() === $endTime->getTimestamp()) { $event = new EventEntity("Fake Event Title", new \DateTime(), null, true); $calendarEvent->addEvent($event); } }
public function loadEvents(CalendarEvent $calendarEvent) { $startDate = $calendarEvent->getStartDatetime(); $endDate = $calendarEvent->getEndDatetime(); // The original request so you can get filters from the calendar // Use the filter in your query for example $request = $calendarEvent->getRequest(); $filter = $request->get('param'); // load events using your custom logic here, // for instance, retrieving events from a repository if ($filter == 'calendar') { $companyEvents = $this->entityManager->getRepository('TorBundle:ReservationTor')->findAll(); } else { // $companyEvents = $this->entityManager->getRepository('TorBundle:InstructorsReservation')->findAll(); $companyEvents = $this->entityManager->getRepository('TorBundle:InstructorsReservation')->createQueryBuilder('instructor_events')->where('instructor_events.idInstructor = :id')->setParameter('id', $filter)->getQuery()->getResult(); } // $companyEvents and $companyEvent in this example // represent entities from your database, NOT instances of EventEntity // within this bundle. // // Create EventEntity instances and populate it's properties with data // from your own entities/database values. foreach ($companyEvents as $companyEvent) { // create an event with a start/end time, or an all day event if ($filter == 0) { $eventEntity = new EventEntity((string) $companyEvent->getUserId(), $companyEvent->getDataStart(), $companyEvent->getDateStop()); } else { $eventEntity = new EventEntity((string) $companyEvent->getIdUser(), $companyEvent->getDateStart(), $companyEvent->getDateStop()); } //optional calendar event settings $eventEntity->setAllDay(false); // default is false, set to true if this is an all day event $eventEntity->setBgColor('#FC2A0A'); //set the background color of the event's label $eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label //$eventEntity->setUrl('http://www.google.com'); // url to send user to when event label is clicked $eventEntity->setCssClass('my-custom-class'); // a custom class you may want to apply to event labels //finally, add the event to the CalendarEvent for displaying on the calendar $calendarEvent->addEvent($eventEntity); } }
public function loadEvents(CalendarEvent $calendarEvent) { $startDate = $calendarEvent->getStartDatetime(); $endDate = $calendarEvent->getEndDatetime(); // The original request so you can get filters from the calendar // Use the filter in your query for example $request = $calendarEvent->getRequest(); $filter = $request->get('filter'); $user = $this->securityContext->getToken()->getUser(); // load events using your custom logic here, // for instance, retrieving events from a repository $companyEvents = $this->entityManager->getRepository('CalendarEngineBundle:UserEvent')->createQueryBuilder('user_events')->where('user_events.date BETWEEN :startDate and :endDate')->andWhere('user_events.userId = :id')->setParameter('startDate', $startDate->format('Y-m-d H:i:s'))->setParameter('endDate', $endDate->format('Y-m-d H:i:s'))->setParameter("id", $user->getId())->getQuery()->getResult(); // $companyEvents and $companyEvent in this example // represent entities from your database, NOT instances of EventEntity // within this bundle. // // Create EventEntity instances and populate it's properties with data // from your own entities/database values. foreach ($companyEvents as $companyEvent) { $eventDate = $companyEvent->getDate(); $now = new \DateTime('now'); $eventEntity = new EventEntity($eventDate->format("H:i") . " " . $companyEvent->getEventTitle(), $eventDate, null, true); //optional calendar event settings $eventEntity->setAllDay(true); // default is false, set to true if this is an all day event if ($eventDate < $now) { $eventEntity->setBgColor('#FF0000'); //set the background color of the event's label } else { $eventEntity->setBgColor('#17961E'); //set the background color of the event's label } $eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label $eventEntity->setUrl($this->router->generate('calendar_app_showEvent', ['id' => $companyEvent->getId()])); // url to send user to when event label is clicked $eventEntity->setCssClass('my-custom-class'); // a custom class you may want to apply to event labels //finally, add the event to the CalendarEvent for displaying on the calendar $calendarEvent->addEvent($eventEntity); } }
public function loadEvents(CalendarEvent $calendarEvent) { $sc = $this->sc; $startDate = $calendarEvent->getStartDatetime(); $endDate = $calendarEvent->getEndDatetime(); // load events using your custom logic here, // for instance, retrieving events from a repository $companyEvents = $this->entityManager->getRepository('TaskeetMainBundle:Event')->createQueryBuilder('company_events')->where('company_events.startDate BETWEEN :startDate and :endDate')->andWhere('company_events.owner = :owner ')->setParameter(':startDate', $startDate->format('Y-m-d H:i:s'))->setParameter(':endDate', $endDate->format('Y-m-d H:i:s'))->setParameter(':owner', $sc->getToken()->getUser()->getId())->getQuery()->getResult(); foreach ($companyEvents as $companyEvent) { // create an event with a start/end time, or an all day event //if ($companyEvent->getAllDayEvent() === false) { $eventEntity = new EventEntity($companyEvent->getTitle(), $companyEvent->getStartDate(), $companyEvent->getDueDate()); //} else { // $eventEntity = new EventEntity($companyEvent->getTitle(), $companyEvent->getStartDatetime(), null, true); // } //optional calendar event settings if ($companyEvent->getStartDate() == $companyEvent->getDueDate()) { $eventEntity->setAllDay(true); } else { $eventEntity->setAllDay(false); } if ($companyEvent->getType()->getName() == "categoria 1") { $eventEntity->setBgColor('#FF0000'); //set the background color of the event's label $eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label } else { $eventEntity->setBgColor('#000000'); //set the background color of the event's label $eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label } $eventEntity->setUrl($companyEvent->getid() . '/edit'); // url to send user to when event label is clicked $eventEntity->setCssClass('my-custom-class'); // a custom class you may want to apply to event labels //finally, add the event to the CalendarEvent for displaying on the calendar $calendarEvent->addEvent($eventEntity); } }
/** * @param CalendarEvent $calendarEvent */ public function loadEvents(CalendarEvent $calendarEvent) { $startDate = $calendarEvent->getStartDatetime(); $endDate = $calendarEvent->getEndDatetime(); // The original request so you can get filters from the calendar // Use the filter in your query for example $request = $calendarEvent->getRequest(); $filter = $request->get('filter'); // load events using your custom logic here, // for instance, retrieving events from a repository $events = $this->entityManager->getRepository('AppBundle:Event')->createQueryBuilder('event')->getQuery()->getResult(); // $companyEvents and $companyEvent in this example // represent entities from your database, NOT instances of EventEntity // within this bundle. // // Create EventEntity instances and populate it's properties with data // from your own entities/database values. /** @var Event $event */ foreach ($events as $event) { // create an event with a start/end time, or an all day event // if ($event->isFullDay() === false) { $eventEntity = new EventEntity($event->getName(), $event->getStartDate(), $event->getEndDate()); // } else { // $eventEntity = new EventEntity($event->getName(), $event->getStartDate(), null, true); // } //optional calendar event settings $eventEntity->setAllDay($event->isFullDay()); // default is false, set to true if this is an all day event $eventEntity->setBgColor($event->getColor()); //set the background color of the event's label $eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label // $eventEntity->setUrl('http://www.google.com'); // url to send user to when event label is clicked // $eventEntity->setCssClass('my-custom-class'); // a custom class you may want to apply to event labels //finally, add the event to the CalendarEvent for displaying on the calendar $calendarEvent->addEvent($eventEntity); } }
public function loadEvents(CalendarEvent $calendarEvent) { $startDate = $calendarEvent->getStartDatetime(); $endDate = $calendarEvent->getEndDatetime(); // The original request so you can get filters from the calendar // Use the filter in your query for example $request = $calendarEvent->getRequest(); $filter = $request->get('filter'); // load events using your custom logic here, // for instance, retrieving events from a repository /*=================================================*/ /* I) Détermine quel type d'utilisateur est connecté*/ /* Pourrait être remplacé par $utilisateur->getType() Mais impossible car il type n'est pas un attribut de la BDD; c'est uniquement un champs dans la BDD pour déterminer qui est User,Etudiant ou Prof... /*=================================================*/ /* recuperation de l'utlilisateur actuelle */ $utilisateur = $this->container->get('security.context')->getToken()->getUser(); /* l'entite manager, pour intérgair avec la BDD */ /* construction de la requete */ $query = $this->entityManager->getRepository('UserBundle:Etudiant')->createQueryBuilder('a')->where('a.id = :iduser')->setParameter('iduser', $utilisateur->getId()); /*exectuon de la requete*/ $etudiant = $query->getQuery()->getOneOrNullResult(); /* on ne veut qu'un seul resultat, donc pas de getResult()*/ if ($etudiant == NULL) { $query = $this->entityManager->getRepository('UserBundle:Professeur')->createQueryBuilder('a')->where('a.id = :iduser')->setParameter('iduser', $utilisateur->getId()); $professeur = $query->getQuery()->getOneOrNullResult(); if ($professeur == NULL) { $type = 'user'; } else { $type = 'professeur'; } } else { $type = 'etudiant'; } /*====================================================================*/ /* II) Recherche des evenements en fonction du type de l'utilisateur */ /*====================================================================*/ switch ($type) { case 'user': $companyEvents = $this->entityManager->getRepository('EDTBundle:Evenement')->createQueryBuilder('company_events')->join('company_events.type', 't')->addSelect('t')->getQuery()->getResult(); break; case 'professeur': $companyEvents = $this->entityManager->getRepository('EDTBundle:Evenement')->createQueryBuilder('company_events')->where('company_events.professeur = :prof')->join('company_events.type', 't')->addSelect('t')->setParameter('prof', $utilisateur)->getQuery()->getResult(); break; case 'etudiant': $companyEvents = $this->entityManager->getRepository('EDTBundle:Evenement')->createQueryBuilder('company_events')->join('company_events.type', 't')->addSelect('t')->leftJoin('company_events.groupes', 'groupes')->where('groupes.id = :id_groupe')->setParameter('id_groupe', $etudiant->getGroupe()->getId())->getQuery()->getResult(); break; } // $companyEvents and $companyEvent in this example // represent entities from your database, NOT instances of EventEntity // within this bundle. // // Create EventEntity instances and populate it's properties with data // from your own entities/database values. foreach ($companyEvents as $companyEvent) { // create an event with a start/end time, or an all day event if ($companyEvent->getAllDayEvent() === false) { $eventEntity = new EventEntity($companyEvent->getTitle(), $companyEvent->getStartDatetime(), $companyEvent->getEndDatetime()); } else { $eventEntity = new EventEntity($companyEvent->getTitle(), $companyEvent->getStartDatetime(), null, true); } $color = '#00FFFF'; if ($companyEvent) { switch ($companyEvent->getType()->getNom()) { case 'CM': $color = '#0000FF'; break; case 'TD': $color = '#FF0000'; break; case 'TP': $color = '#00FF00'; break; case 'TDI': $color = '#FF00FF'; break; } } $eventEntity->setBgColor($color); //set the background color of the event's label $eventEntity->setFgColor('#FFFFFF'); //set the foreground color of the event's label $eventEntity->setUrl('#'); // url to send user to when event label is clicked //$eventEntity->setCssClass('my-custom-class'); // a custom class you may want to apply to event labels //finally, add the event to the CalendarEvent for displaying on the calendar $calendarEvent->addEvent($eventEntity); } }