From 4dc9021d8834906321662a51f2fc74f449087680 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Mon, 21 Nov 2016 21:53:33 +0100 Subject: [PATCH] Add a logging mechanism for repeating events --- .../Command/GenerateEventsCommand.php | 8 ++- .../Controller/RepeatingEventController.php | 22 ++++++ .../Entity/RepeatingEventLogEntry.php | 70 +++++++++++++++++++ .../views/RepeatingEvent/logIndex.html.twig | 58 +++++++++++++++ 4 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 src/Hackspace/Bundle/CalciferBundle/Entity/RepeatingEventLogEntry.php create mode 100644 src/Hackspace/Bundle/CalciferBundle/Resources/views/RepeatingEvent/logIndex.html.twig diff --git a/src/Hackspace/Bundle/CalciferBundle/Command/GenerateEventsCommand.php b/src/Hackspace/Bundle/CalciferBundle/Command/GenerateEventsCommand.php index 9f7878a..c0c540b 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Command/GenerateEventsCommand.php +++ b/src/Hackspace/Bundle/CalciferBundle/Command/GenerateEventsCommand.php @@ -12,6 +12,7 @@ namespace Hackspace\Bundle\CalciferBundle\Command; use Doctrine\ORM\EntityManager; use Hackspace\Bundle\CalciferBundle\Entity\Event; use Hackspace\Bundle\CalciferBundle\Entity\RepeatingEvent; +use Hackspace\Bundle\CalciferBundle\Entity\RepeatingEventLogEntry; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -52,7 +53,6 @@ class GenerateEventsCommand extends ContainerAwareCommand $event = null; while (($next_date = $parser->getNext()) < $end) { /** @var \DateTime $next_date */ - $output->writeln(sprintf("Creating Event %s for %s",$entity->summary,$next_date->format('Y-m-d H:i'))); $event = new Event(); $event->location = $entity->location; $event->startdate = $next_date; @@ -75,6 +75,12 @@ class GenerateEventsCommand extends ContainerAwareCommand $event->addTag($tag); } $entityManager->persist($event); + $logEntry = new RepeatingEventLogEntry(); + $logEntry->event = $event; + $logEntry->repeating_event = $entity; + $logEntry->event_startdate = $event->startdate; + $logEntry->event_enddate = $event->enddate; + $entityManager->persist($logEntry); $entityManager->flush(); $parser->setNow($next_date); } diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/RepeatingEventController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/RepeatingEventController.php index 28b1341..a4bd194 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Controller/RepeatingEventController.php +++ b/src/Hackspace/Bundle/CalciferBundle/Controller/RepeatingEventController.php @@ -48,6 +48,28 @@ class RepeatingEventController extends Controller ]; } + /** + * Displays all repeating events + * + * @Route("/logs", name="repeating_event_logs") + * @Method("GET") + * @Template() + */ + public function logIndexAction() + { + /** @var EntityManager $em */ + $em = $this->getDoctrine()->getManager(); + + /** @var EntityRepository $repo */ + $repo = $em->getRepository('CalciferBundle:RepeatingEventLogEntry'); + + $entities = $repo->findBy([], ['event_startdate' => 'DESC']); + + return [ + 'entities' => $entities, + ]; + } + /** * Displays a form to create a repeating event * diff --git a/src/Hackspace/Bundle/CalciferBundle/Entity/RepeatingEventLogEntry.php b/src/Hackspace/Bundle/CalciferBundle/Entity/RepeatingEventLogEntry.php new file mode 100644 index 0000000..90b520c --- /dev/null +++ b/src/Hackspace/Bundle/CalciferBundle/Entity/RepeatingEventLogEntry.php @@ -0,0 +1,70 @@ + + {% endstylesheets %} +{% endblock %} + +{% block javascripts %} + {% javascripts + "@CalciferBundle/Resources/assets/js/events.js" %} + + {% endjavascripts %} +{% endblock %} + +{% block body -%} +
+

+ Logeinträge für Wiederholende Termine +

+
+ +
+ + + + + + + + + + + {% for entity in entities %} + + + + + + + {% endfor %} + +
Wiederholender TerminTerminTermin StartdatumTermin Enddatum
+ {{ entity.repeating_event.summary }} + + {{ entity.event.summary }} + + {{ entity.event_startdate.format('Y-m-d H:i') }} + + {% if entity.event_enddate %} + {{ entity.event_enddate.format('Y-m-d H:i') }} + {% endif %} +
+ +
+ +{% endblock %}