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->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) { $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(); // 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); } }