/**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Generating people...');
     /** @var \Doctrine\ORM\EntityManager $entityManager */
     $entityManager = $this->getContainer()->get('doctrine')->getManager();
     $faker = Factory::create();
     $people = array();
     for ($i = 0; $i < self::$NUMBER_Of_PERSONS; $i++) {
         $person = new Person();
         $gender = rand(0, 1) == 0 ? Gender::MALE() : Gender::FEMALE();
         $person->setFirstName($faker->format("firstName", array($gender->getName())));
         $person->setLastName($faker->lastName);
         $person->setGender($gender);
         $person->setBirthday($faker->dateTimeBetween('-60 years', '-18 years'));
         $entityManager->persist($person);
         $people[] = $person;
         $output->write('.');
     }
     $output->writeln('');
     $output->writeln('Generating calendars with appointments...');
     for ($i = 0; $i < self::$NUMBER_Of_CALENDARS; $i++) {
         $calendar = new Calendar();
         $calendar->setPerson($faker->randomElement($people));
         $entityManager->persist($calendar);
         for ($j = 0; $j < $faker->randomDigit; $j++) {
             $appointment = new Appointment();
             $appointment->setWhen($faker->dateTimeThisYear);
             $appointment->setWhat($faker->text);
             $appointment->setCalendar($calendar);
             $entityManager->persist($appointment);
         }
         $output->write('.');
     }
     $entityManager->flush();
 }
 /**
  * @param Calendar $calendar
  *
  * @return Model;
  */
 public function entityToModel(Calendar $calendar)
 {
     $model = new Model();
     $model->setId($calendar->getId())->setTitle($calendar->getTitle())->setActive($calendar->isActive());
     if ($this->isModeFull()) {
         $model->setGoogleConnections($this->googleConnectionTransformer->entitiesToModel($calendar->getGoogleConnections()->toArray()));
     }
     return $model;
 }
 /**
  * Edit or build a report.
  *
  * @param Calendar $calendar
  * @param Report   $report
  *
  * @return Report $report
  */
 public function build(Calendar $calendar, Report $report = null)
 {
     if (null === $report) {
         $report = new Report();
     }
     /** @var NurseryCalendar $nurseryCalendar */
     foreach ($calendar->getNurseryCalendars() as $nurseryCalendar) {
         $month = (int) $nurseryCalendar->getDate()->format('m');
         $year = (int) $nurseryCalendar->getDate()->format('Y');
         $nurseryReportYear = $report->getNurseryReportYear($year);
         $nurseryReportMonth = $nurseryReportYear->getMonth($month);
         $nurseryReportMonth->addPeriod($nurseryCalendar->getDuration(), $nurseryCalendar->isMeal());
     }
     $report->update();
     return $report;
 }
Exemplo n.º 4
0
 /**
  * Edit or build a report.
  *
  * @param Calendar $calendar
  * @param Report   $report
  *
  * @return Report $report
  */
 public function build(Calendar $calendar, Report $report = null)
 {
     if (null === $report) {
         $report = new Report();
     }
     /** @var JobCalendar $jobCalendar */
     foreach ($calendar->getJobCalendars() as $jobCalendar) {
         $month = (int) $jobCalendar->getDate()->format('m');
         $year = (int) $jobCalendar->getDate()->format('Y');
         $job = $jobCalendar->getJob();
         $jobReportYear = $report->getJobReportYear($year);
         $jobReportMonth = $jobReportYear->getMonth($month);
         $jobReportRow = $jobReportMonth->getRow($job->getCode(), $job->getTitle(), $job->getDuration());
         $jobReportRow->add();
     }
     $report->update();
     return $report;
 }
 /**
  * @param Calendar $calendar
  * @param Request  $request
  *
  * @return JsonResponse
  *
  * @Route("/{id}/deactivate", requirements={"id": "^\d+$"}, name="app_calendars_deactivate", methods="PATCH")
  * @Security("has_role('ROLE_CALD_CALD_ACTIV')")
  */
 public function deactivateAction(Calendar $calendar, Request $request)
 {
     $this->assertXmlHttpRequest($request);
     $calendar->setActive(false);
     $this->get('doctrine.orm.entity_manager')->flush();
     return new JsonResponse(['message' => $this->get('translator')->trans('calendars.message.inactive')]);
 }
 /**
  * @param Calendar $calendar
  *
  * @return Response
  *
  * @Route("/calendar/{id}", name="app_google_connections_list_calendar", methods="GET")
  * @Security("has_role('ROLE_CALD_GOOGL_SHOW')")
  */
 public function listByCalendarAction(Calendar $calendar)
 {
     return $this->render('googleConnections/listByCalendar.html.twig', ['googleConnections' => $calendar->getGoogleConnections(), 'calendar' => $calendar]);
 }
 /**
  * @param Calendar $calendar
  *
  * @return Response
  *
  * @Route("/{id}/jobs", name="app_v0_calendars_jobcalendars", methods="GET")
  */
 public function getJobCalendarsAction(Calendar $calendar)
 {
     $transformer = $this->get('app.transformer.job_calendar');
     return new Response($this->get('serializer')->serialize($transformer->entitiesToModel($calendar->getJobCalendars()->toArray()), 'json'), Response::HTTP_OK, ['content-type' => 'application/json']);
 }