+++ /dev/null
-<?php
-
-namespace Rapsys\AirBundle\Controller;
-
-use Symfony\Component\HttpFoundation\Request;
-
-use Rapsys\AirBundle\Entity\Slot;
-use Rapsys\AirBundle\Entity\Session;
-use Rapsys\AirBundle\Entity\Location;
-use Rapsys\AirBundle\Entity\User;
-
-class UserController extends DefaultController {
- /**
- * List all sessions for the user
- *
- * @desc Display all sessions for the user with an application or login form
- *
- * @param Request $request The request instance
- * @param int $id The user id
- *
- * @return Response The rendered view
- */
- public function view(Request $request, $id) {
- //Fetch doctrine
- $doctrine = $this->getDoctrine();
-
- //Fetch user
- $user = $doctrine->getRepository(User::class)->findOneById($id);
-
- //Set section
- $section = $user->getPseudonym();
-
- //Set title
- $title = $section.' - '.$this->translator->trans($this->config['site']['title']);
-
- //Init context
- $context = [];
-
- //Create application form for role_guest
- if ($this->isGranted('ROLE_GUEST')) {
- //Create ApplicationType form
- $application = $this->createForm('Rapsys\AirBundle\Form\ApplicationType', null, [
- //Set the action
- 'action' => $this->generateUrl('rapsys_air_application_add'),
- //Set the form attribute
- 'attr' => [ 'class' => 'col' ],
- //Set admin
- 'admin' => $this->isGranted('ROLE_ADMIN'),
- //Set default user to current
- 'user' => $this->getUser()->getId(),
- //Set default slot to evening
- //XXX: default to Evening (3)
- 'slot' => $doctrine->getRepository(Slot::class)->findOneById(3)
- ]);
-
- //Add form to context
- $context['application'] = $application->createView();
- //Create login form for anonymous
- } elseif (!$this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
- //Create ApplicationType form
- $login = $this->createForm('Rapsys\UserBundle\Form\LoginType', null, [
- //Set the action
- 'action' => $this->generateUrl('rapsys_user_login'),
- //Set the form attribute
- 'attr' => [ 'class' => 'col' ]
- ]);
-
- //Add form to context
- $context['login'] = $login->createView();
- }
-
- //Compute period
- $period = new \DatePeriod(
- //Start from first monday of week
- new \DateTime('Monday this week'),
- //Iterate on each day
- new \DateInterval('P1D'),
- //End with next sunday and 4 weeks
- new \DateTime('Monday this week + 5 week')
- );
-
- //Fetch calendar
- //TODO: highlight with current session route parameter
- $calendar = $doctrine->getRepository(Session::class)->fetchUserCalendarByDatePeriod($this->translator, $period, $id, $request->get('session'));
-
- //Fetch locations
- //XXX: we want to display all active locations anyway
- $locations = $doctrine->getRepository(Location::class)->fetchTranslatedUserLocationByDatePeriod($this->translator, $period, $id);
-
- //Render the view
- return $this->render('@RapsysAir/user/view.html.twig', ['id' => $id, 'title' => $title, 'section' => $section, 'calendar' => $calendar, 'locations' => $locations]+$context+$this->context);
- }
-}
--- /dev/null
+{% extends '@RapsysAir/body.html.twig' %}
+{% block content %}
+ <section id="dashboard">
+ <h2><a href="{{ path('rapsys_air_organizer_view', {'id': id}) }}">{{ section }}</a></h2>
+ <div class="panel calendar">
+ {% if calendar is defined and calendar %}
+ <div class="grid">
+ {% for date, day in calendar %}
+ <section class="{{ ['cell', 'seventh']|merge(day.class)|join(' ') }}">
+ <h3>{{ day.title }}</h3>
+ {% if day.sessions is not empty %}
+ <ul>
+ {% for session in day.sessions %}
+ <li class="{{ ['session']|merge(session.class)|join(' ') }}">
+ <a href="{{ path('rapsys_air_session_view', {'id': session.id}) }}" title="{{ session.applications|join('\n') }}">{{ session.title }}</a>
+ <span>
+ {% if session.weather is defined and session.weather %}<span title="{{ session.weathertitle }}">{{ session.weather }}</span>{% endif %}
+ <span title="{{ session.slottitle }}">{{ session.slot }}</span>
+ </span>
+ </li>
+ {% endfor %}
+ </ul>
+ {% else %}
+
+ {% endif %}
+ </section>
+ {% endfor %}
+ </div>
+ {% endif %}
+ {{ include('@RapsysAir/form/_toolbox.html.twig') }}
+ </div>
+ </section>
+ {% if locations is defined and locations %}
+ <section id="location">
+ <h2>{% trans %}Locations{% endtrans %}</h2>
+ <div class="panel grid">
+ {% for id, title in locations %}
+ <section class="cell">
+ <h3><a href="{{ path('rapsys_air_location_view', {'id': id}) }}">{{ title }}</a></h3>
+ {% if snippets is defined and snippets[id] is defined and snippets[id] %}
+ {{ form_start(snippets[id]) }}
+ <div>
+ {{ form_row(snippets[id].description) }}
+
+ {{ form_row(snippets[id].submit) }}
+
+ {% if snippets[id].delete is defined %}
+ {{ form_row(snippets[id].delete) }}
+ {% endif %}
+ </div>
+
+ {# render csrf token etc .#}
+ <footer style="display:none">{{ form_rest(snippets[id]) }}</footer>
+ {{ form_end(snippets[id]) }}
+ {% endif %}
+ </section>
+ {% endfor %}
+ </div>
+ </section>
+ {% endif %}
+{% endblock %}
+++ /dev/null
-{% extends '@RapsysAir/body.html.twig' %}
-{% block content %}
-<section id="dashboard">
- <h2><a href="{{ path('rapsys_air_user_view', {'id': id}) }}">{{ section }}</a></h2>
- <div class="panel calendar">
- {% if calendar is defined and calendar %}
- <div class="grid">
- {% for date, day in calendar %}
- <section class="{{ ['cell', 'seventh']|merge(day.class)|join(' ') }}">
- <h3>{{ day.title }}</h3>
- {% if day.sessions is not empty %}
- <ul>
- {% for session in day.sessions %}
- <li class="{{ ['session']|merge(session.class)|join(' ') }}">
- <a href="{{ path('rapsys_air_session_view', {'id': session.id}) }}" title="{{ session.applications|join('\n') }}">{{ session.title }}</a>
- <span>
- {% if session.weather is defined and session.weather %}<span title="{{ session.weathertitle }}">{{ session.weather }}</span>{% endif %}
- <span title="{{ session.slottitle }}">{{ session.slot }}</span>
- </span>
- </li>
- {% endfor %}
- </ul>
- {% else %}
-
- {% endif %}
- </section>
- {% endfor %}
- </div>
- {% endif %}
- {{ include('@RapsysAir/form/_toolbox.html.twig') }}
- </div>
- {% if locations is defined and locations %}
- <div class="panel location">
- <section>
- <h3>{% trans %}Locations{% endtrans %}</h3>
- <div class="grid">
- {% for id, title in locations %}
- <section class="cell">
- <h4><a href="{{ path('rapsys_air_location_view', {'id': id}) }}">{{ title }}</a></h4>
- </section>
- {% endfor %}
- </div>
- </section>
- </div>
- {% endif %}
-</section>
-{% endblock %}