diff --git a/app/DoctrineMigrations/Version20230825104026_opening_hour_kind_entity.php b/app/DoctrineMigrations/Version20230825104026_opening_hour_kind_entity.php
new file mode 100644
index 000000000..4327fd5d3
--- /dev/null
+++ b/app/DoctrineMigrations/Version20230825104026_opening_hour_kind_entity.php
@@ -0,0 +1,37 @@
+abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+ $this->addSql('CREATE TABLE opening_hour_kind (id INT AUTO_INCREMENT NOT NULL, created_by_id INT DEFAULT NULL, updated_by_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, start_date DATE DEFAULT NULL, end_date DATE DEFAULT NULL, enabled TINYINT(1) DEFAULT \'0\' NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_5AEDCF52B03A8386 (created_by_id), INDEX IDX_5AEDCF52896DBBDE (updated_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC');
+ $this->addSql('ALTER TABLE opening_hour_kind ADD CONSTRAINT FK_5AEDCF52B03A8386 FOREIGN KEY (created_by_id) REFERENCES fos_user (id)');
+ $this->addSql('ALTER TABLE opening_hour_kind ADD CONSTRAINT FK_5AEDCF52896DBBDE FOREIGN KEY (updated_by_id) REFERENCES fos_user (id)');
+ }
+
+ public function down(Schema $schema) : void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+ $this->addSql('DROP TABLE opening_hour_kind');
+ }
+}
diff --git a/app/DoctrineMigrations/Version20230825120912_opening_hour_kind.php b/app/DoctrineMigrations/Version20230825120912_opening_hour_kind.php
new file mode 100644
index 000000000..9be4c9737
--- /dev/null
+++ b/app/DoctrineMigrations/Version20230825120912_opening_hour_kind.php
@@ -0,0 +1,39 @@
+abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+ $this->addSql('ALTER TABLE opening_hour ADD opening_hour_kind_id INT DEFAULT NULL');
+ $this->addSql('ALTER TABLE opening_hour ADD CONSTRAINT FK_969BD7659BA06AF0 FOREIGN KEY (opening_hour_kind_id) REFERENCES opening_hour_kind (id) ON DELETE SET NULL');
+ $this->addSql('CREATE INDEX IDX_969BD7659BA06AF0 ON opening_hour (opening_hour_kind_id)');
+ }
+
+ public function down(Schema $schema) : void
+ {
+ // this down() migration is auto-generated, please modify it to your needs
+ $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
+
+ $this->addSql('ALTER TABLE opening_hour DROP FOREIGN KEY FK_969BD7659BA06AF0');
+ $this->addSql('DROP INDEX IDX_969BD7659BA06AF0 ON opening_hour');
+ $this->addSql('ALTER TABLE opening_hour DROP opening_hour_kind_id');
+ }
+}
diff --git a/app/Resources/views/admin/event/_partial/form.html.twig b/app/Resources/views/admin/event/_partial/form.html.twig
new file mode 100644
index 000000000..e09959df6
--- /dev/null
+++ b/app/Resources/views/admin/event/_partial/form.html.twig
@@ -0,0 +1,56 @@
+{% set edit = edit ?? false %}
+
+
+ {{ openingHourKind.name }}
+ {% if openingHourKind.startDate and openingHourKind.endDate %}
+ (du {{ openingHourKind.startDate | date_fr_long }} au {{ openingHourKind.endDate | date_fr_long }})
+ {% endif %}
+
{% endif %}
{% if align == "left" %}
{% include "/admin/openinghour/_partial/list.html.twig" with { openingHours: openingHours } %}
diff --git a/app/Resources/views/admin/openinghour/edit.html.twig b/app/Resources/views/admin/openinghour/edit.html.twig
index fba237f20..1ae1e3d4c 100644
--- a/app/Resources/views/admin/openinghour/edit.html.twig
+++ b/app/Resources/views/admin/openinghour/edit.html.twig
@@ -14,15 +14,15 @@
{{ form_start(form) }}
{% include "/admin/openinghour/_partial/form.html.twig" with { form: form } %}
-
@@ -31,6 +33,7 @@
Jour d'ouverture |
Heure de début |
Heure de fin |
+
Type |
Actions |
@@ -40,6 +43,7 @@
{{ openingHour.dayOfWeekString | capitalize }} |
{{ openingHour.start | time_short }} |
{{ openingHour.end | time_short }} |
+
{{ openingHour.kind }} |
edit Editer
diff --git a/app/Resources/views/admin/openinghour/_partial/card.html.twig b/app/Resources/views/admin/openinghour/kind/_partial/card.html.twig
similarity index 50%
rename from app/Resources/views/admin/openinghour/_partial/card.html.twig
rename to app/Resources/views/admin/openinghour/kind/_partial/card.html.twig
index e1a20bde6..791e4f88a 100644
--- a/app/Resources/views/admin/openinghour/_partial/card.html.twig
+++ b/app/Resources/views/admin/openinghour/kind/_partial/card.html.twig
@@ -1,5 +1,6 @@
{% set openingHourJoinString = "&" %}
- {% include "/admin/openinghour/_partial/table.html.twig" with { openingHours: openingHours } %}
+ {{ openingHourKind.name }}
+ {% include "/admin/openinghour/_partial/table.html.twig" with { openingHours: openingHourKind.openingHours } %}
diff --git a/app/Resources/views/admin/openinghour/kind/_partial/form.html.twig b/app/Resources/views/admin/openinghour/kind/_partial/form.html.twig
new file mode 100644
index 000000000..ad59402e3
--- /dev/null
+++ b/app/Resources/views/admin/openinghour/kind/_partial/form.html.twig
@@ -0,0 +1,25 @@
+{% set edit = edit ?? false %}
+
+
+ {{ form_errors(form) }}
+
+{{ form_row(form.name) }}
+
+
+ {{ form_row(form.start_date) }}
+
+
+ {{ form_row(form.end_date) }}
+
+
+
+ {{ form_errors(form.enabled) }}
+
+
+
+{% if edit %}
+ {% include "admin/member/_partial/created_updated_card.html.twig" with { item: openingHourKind } %}
+{% endif %}
diff --git a/app/Resources/views/admin/openinghour/kind/edit.html.twig b/app/Resources/views/admin/openinghour/kind/edit.html.twig
new file mode 100644
index 000000000..583b286ad
--- /dev/null
+++ b/app/Resources/views/admin/openinghour/kind/edit.html.twig
@@ -0,0 +1,30 @@
+{% extends 'layout.html.twig' %}
+
+{% block title %}Editer un type d'horaire d'ouverture - {{ site_name }}{% endblock %}
+
+{% block breadcrumbs %}
+homechevron_right
+build Administrationchevron_right
+list Liste des types d'horaire d'ouvertureschevron_right
+edit Editer
+{% endblock %}
+
+{% block content %}
+Editer un type d'horaire d'ouverture
+
+{{ form_start(form) }}
+{% include "/admin/openinghour/kind/_partial/form.html.twig" with { form: form, edit: true, openingHourKind: openingHourKind } %}
+
+{{ form_end(form) }}
+
+{% if is_granted("ROLE_ADMIN") %}
+ {{ form_start(delete_form) }}
+ {{ form_widget(delete_form) }}
+
+ {{ form_end(delete_form) }}
+{% endif %}
+{% endblock %}
diff --git a/app/Resources/views/admin/openinghour/kind/list.html.twig b/app/Resources/views/admin/openinghour/kind/list.html.twig
new file mode 100644
index 000000000..5f65d1cb8
--- /dev/null
+++ b/app/Resources/views/admin/openinghour/kind/list.html.twig
@@ -0,0 +1,55 @@
+{% extends 'layout.html.twig' %}
+
+{% block title %}Liste des types d'horaires d'ouverture - {{ site_name }}{% endblock %}
+
+{% block breadcrumbs %}
+homechevron_right
+build Administrationchevron_right
+list Liste des types d'horaires d'ouverture
+{% endblock %}
+
+{% block content %}
+Liste des types d'horaires d'ouverture ({{ openingHourKinds | length }})
+
+
+
+
+ Etat |
+ Type d'horaire d'ouverture |
+ Période |
+ Nombre d'horaires d'ouverture |
+ Actions |
+
+
+
+ {% for openingHourKind in openingHourKinds %}
+
+
+ {% if not openingHourKind.enabled %}
+ close
+ {% else %}
+ check
+ {% endif %}
+ |
+ {{ openingHourKind.name }} |
+
+ {% if openingHourKind.startDate and openingHourKind.endDate %}
+ {{ openingHourKind.startDate | date_fr_full }} - {{ openingHourKind.endDate | date_fr_full }}
+ {% endif %}
+ |
+ {{ openingHourKind.openingHours | length }} |
+
+
+ editEditer
+
+ |
+
+ {% endfor %}
+
+
+
+
+
+ addAjouter un type d'horaire d'ouverture
+
+{% endblock %}
diff --git a/app/Resources/views/admin/openinghour/kind/new.html.twig b/app/Resources/views/admin/openinghour/kind/new.html.twig
new file mode 100644
index 000000000..5d4d50b1f
--- /dev/null
+++ b/app/Resources/views/admin/openinghour/kind/new.html.twig
@@ -0,0 +1,23 @@
+{% extends 'layout.html.twig' %}
+
+{% block title %}Ajouter un type d'horaire d'ouverture - {{ site_name }}{% endblock %}
+
+{% block breadcrumbs %}
+homechevron_right
+build Administrationchevron_right
+list Liste des types d'horaire d'ouvertureschevron_right
+add Ajouter
+{% endblock %}
+
+{% block content %}
+Nouveau type d'horaire d'ouverture
+
+{{ form_start(form) }}
+{% include "/admin/openinghour/kind/_partial/form.html.twig" with { form: form } %}
+
+{{ form_end(form) }}
+
+Annuler
+{% endblock %}
diff --git a/app/Resources/views/admin/openinghour/new.html.twig b/app/Resources/views/admin/openinghour/new.html.twig
index 8c182da36..54fd87ce3 100644
--- a/app/Resources/views/admin/openinghour/new.html.twig
+++ b/app/Resources/views/admin/openinghour/new.html.twig
@@ -14,8 +14,10 @@
{{ form_start(form) }}
{% include "/admin/openinghour/_partial/form.html.twig" with { form: form } %}
-
-
-
+
{{ form_end(form) }}
+
+Annuler
{% endblock %}
diff --git a/app/Resources/views/admin/openinghour/widget_generator.html.twig b/app/Resources/views/admin/openinghour/widget_generator.html.twig
index bce39d701..e5487a580 100644
--- a/app/Resources/views/admin/openinghour/widget_generator.html.twig
+++ b/app/Resources/views/admin/openinghour/widget_generator.html.twig
@@ -18,17 +18,24 @@
- {{ form.title.vars.label }}
-
-
-
+ {{ form_label(form.kind) }}
+ {{ form_widget(form.kind) }}
+
+ {{ form_errors(form.title) }}
+
+
+
+ {{ form_errors(form.kind_title) }}
+
+
{{ form_label(form.align) }}
diff --git a/app/Resources/views/event/_partial/widget.html.twig b/app/Resources/views/event/_partial/widget.html.twig
index 250076746..d2476ebb8 100644
--- a/app/Resources/views/event/_partial/widget.html.twig
+++ b/app/Resources/views/event/_partial/widget.html.twig
@@ -2,10 +2,11 @@
{% block content %}
{% if title %}
- liste des prochains événements
- {% if eventKind %} {{ eventKind.name }}{% endif %}
- {% if maxDate %}(jusqu'au {{ maxDate | date_short }}){% endif %}
- :
+
+ liste des prochains événements
+ {% if eventKind %}{{ eventKind.name }}{% endif %}
+ {% if maxDate %}(jusqu'au {{ maxDate | date_short }}){% endif %}
+
{% endif %}
{% for event in events %}
diff --git a/src/AppBundle/Controller/AdminEventController.php b/src/AppBundle/Controller/AdminEventController.php
index dcefca930..cb7230c40 100644
--- a/src/AppBundle/Controller/AdminEventController.php
+++ b/src/AppBundle/Controller/AdminEventController.php
@@ -417,7 +417,7 @@ public function signaturesListAction(Request $request,Event $event): Response
/**
* Event widget generator
*
- * @Route("/widget_generator", name="event_widget_generator", methods={"GET","POST"})
+ * @Route("/widget_generator", name="admin_event_widget_generator", methods={"GET","POST"})
* @Security("has_role('ROLE_PROCESS_MANAGER')")
*/
public function widgetGeneratorAction(Request $request)
@@ -443,12 +443,14 @@ public function widgetGeneratorAction(Request $request)
->add('title', CheckboxType::class, array(
'label' => 'Afficher le titre du widget ?',
'data' => false,
- 'required' => false
+ 'required' => false,
+ 'attr' => array('class' => 'filled-in')
))
->add('links', CheckboxType::class, array(
'label' => 'Afficher un lien vers l\'événement ?',
'data' => false,
- 'required' => false
+ 'required' => false,
+ 'attr' => array('class' => 'filled-in')
))
->add('generate', SubmitType::class, array('label' => 'Générer'))
->getForm();
@@ -458,13 +460,13 @@ public function widgetGeneratorAction(Request $request)
$widgetQueryString = 'event_kind_id=' . ($data['kind'] ? $data['kind']->getId() : '') . '&date_max=' . ($data['date_max'] ? $data['date_max'] : '') . '&limit=' . ($data['limit'] ? $data['limit'] : '') . '&title=' . ($data['title'] ? 1 : 0) . '&links=' . ($data['links'] ? 1 : 0);
- return $this->render('admin/event/widget/generate.html.twig', array(
+ return $this->render('admin/event/widget_generator.html.twig', array(
'query_string' => $widgetQueryString,
'form' => $form->createView(),
));
}
- return $this->render('admin/event/widget/generate.html.twig', array(
+ return $this->render('admin/event/widget_generator.html.twig', array(
'form' => $form->createView(),
));
}
diff --git a/src/AppBundle/Controller/AdminEventKindController.php b/src/AppBundle/Controller/AdminEventKindController.php
index 3fb785b24..c871e7aac 100644
--- a/src/AppBundle/Controller/AdminEventKindController.php
+++ b/src/AppBundle/Controller/AdminEventKindController.php
@@ -14,7 +14,7 @@
/**
* AdminEventKind controller
*
- * @Route("admin/event/kinds")
+ * @Route("admin/events/kinds")
*/
class AdminEventKindController extends Controller
{
diff --git a/src/AppBundle/Controller/AdminOpeningHourController.php b/src/AppBundle/Controller/AdminOpeningHourController.php
index 748e105ea..be9b05d4d 100644
--- a/src/AppBundle/Controller/AdminOpeningHourController.php
+++ b/src/AppBundle/Controller/AdminOpeningHourController.php
@@ -5,6 +5,7 @@
use AppBundle\Entity\OpeningHour;
use AppBundle\Form\OpeningHourType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
@@ -32,9 +33,11 @@ public function indexAction(Request $request)
$em = $this->getDoctrine()->getManager();
$openingHours = $em->getRepository('AppBundle:OpeningHour')->findAll();
+ $openingHourKinds = $em->getRepository('AppBundle:OpeningHourKind')->findAll();
return $this->render('admin/openinghour/index.html.twig', array(
- 'openingHours' => $openingHours
+ 'openingHours' => $openingHours,
+ 'openingHourKinds' => $openingHourKinds,
));
}
@@ -144,10 +147,23 @@ public function deleteAction(Request $request, OpeningHour $openingHour)
public function widgetGeneratorAction(Request $request)
{
$form = $this->createFormBuilder()
+ ->add('kind', EntityType::class, array(
+ 'label' => "Quel type d'horaire d'ouverture ?",
+ 'class' => 'AppBundle:OpeningHourKind',
+ 'choice_label' => 'name',
+ 'multiple' => false
+ ))
->add('title', CheckboxType::class, array(
'required' => false,
'data' => true,
- 'label' => 'Afficher le titre du widget ?'
+ 'label' => 'Afficher le titre du widget ?',
+ 'attr' => array('class' => 'filled-in')
+ ))
+ ->add('kind_title', CheckboxType::class, array(
+ 'required' => false,
+ 'data' => true,
+ 'label' => 'Afficher les détails du type d\'horaire d\'ouverture ?',
+ 'attr' => array('class' => 'filled-in')
))
->add('align', ChoiceType::class, array(
'label' => 'Alignement',
@@ -160,7 +176,7 @@ public function widgetGeneratorAction(Request $request)
if ($form->handleRequest($request)->isValid()) {
$data = $form->getData();
- $widgetQueryString = 'title=' . ($data['title'] ? 1 : 0) . '&align=' . $data['align'];
+ $widgetQueryString = 'opening_hour_kind_id=' . ($data['kind'] ? $data['kind']->getId() : '') . '&title=' . ($data['title'] ? 1 : 0) . '&kind_title=' . ($data['kind_title'] ? 1 : 0) . '&align=' . $data['align'];
return $this->render('admin/openinghour/widget_generator.html.twig', array(
'query_string' => $widgetQueryString,
diff --git a/src/AppBundle/Controller/AdminOpeningHourKindController.php b/src/AppBundle/Controller/AdminOpeningHourKindController.php
new file mode 100644
index 000000000..846084361
--- /dev/null
+++ b/src/AppBundle/Controller/AdminOpeningHourKindController.php
@@ -0,0 +1,134 @@
+getDoctrine()->getManager();
+
+ $openingHourKinds = $em->getRepository('AppBundle:OpeningHourKind')->findAll();
+
+ return $this->render('admin/openinghour/kind/list.html.twig', array(
+ 'openingHourKinds' => $openingHourKinds,
+ ));
+ }
+
+ /**
+ * Add new opening hour kind
+ *
+ * @Route("/new", name="admin_openinghour_kind_new", methods={"GET","POST"})
+ * @Security("has_role('ROLE_PROCESS_MANAGER')")
+ */
+ public function newAction(Request $request)
+ {
+ $session = new Session();
+ $em = $this->getDoctrine()->getManager();
+ $current_user = $this->get('security.token_storage')->getToken()->getUser();
+
+ $openingHourKind = new OpeningHourKind();
+ $form = $this->createForm(OpeningHourKindType::class, $openingHourKind);
+ $form->handleRequest($request);
+
+ if ($form->isSubmitted() && $form->isValid()) {
+ $openingHourKind->setCreatedBy($current_user);
+ $em->persist($openingHourKind);
+ $em->flush();
+
+ $session->getFlashBag()->add('success', 'Le type d\'horaire d\'ouverture a bien été créé !');
+ return $this->redirectToRoute('admin_openinghour_kind_list');
+ }
+
+ return $this->render('admin/openinghour/kind/new.html.twig', array(
+ 'form' => $form->createView(),
+ ));
+ }
+
+ /**
+ * Edit opening hour kind
+ *
+ * @Route("/{id}/edit", name="admin_openinghour_kind_edit", methods={"GET","POST"})
+ * @Security("has_role('ROLE_PROCESS_MANAGER')")
+ */
+ public function editAction(Request $request, OpeningHourKind $openingHourKind)
+ {
+ $session = new Session();
+ $em = $this->getDoctrine()->getManager();
+ $current_user = $this->get('security.token_storage')->getToken()->getUser();
+
+ $form = $this->createForm(OpeningHourKindType::class, $openingHourKind);
+ $form->handleRequest($request);
+
+ if ($form->isSubmitted() && $form->isValid()) {
+ $openingHourKind->setUpdatedBy($current_user);
+ $em->persist($openingHourKind);
+ $em->flush();
+
+ $session->getFlashBag()->add('success', 'Le type d\'horaire d\'ouverture a bien été édité !');
+ return $this->redirectToRoute('admin_openinghour_kind_list');
+ }
+
+ return $this->render('admin/openinghour/kind/edit.html.twig', array(
+ 'form' => $form->createView(),
+ 'openingHourKind' => $openingHourKind,
+ 'delete_form' => $this->getDeleteForm($openingHourKind)->createView(),
+ ));
+ }
+
+ /**
+ * Delete opening hour kind
+ *
+ * @Route("/{id}", name="admin_openinghour_kind_delete", methods={"DELETE"})
+ * @Security("has_role('ROLE_ADMIN')")
+ */
+ public function deleteAction(Request $request, OpeningHourKind $openingHourKind)
+ {
+ $session = new Session();
+ $em = $this->getDoctrine()->getManager();
+
+ $form = $this->getDeleteForm($openingHourKind);
+ $form->handleRequest($request);
+
+ if ($form->isSubmitted() && $form->isValid()) {
+ $em->remove($openingHourKind);
+ $em->flush();
+
+ $session->getFlashBag()->add('success', 'Le type d\'horaire d\'ouverture a bien été supprimé !');
+ }
+
+ return $this->redirectToRoute('admin_openinghour_kind_list');
+ }
+
+ /**
+ * @param OpeningHourKind $openingHourKind
+ * @return \Symfony\Component\Form\FormInterface
+ */
+ protected function getDeleteForm(OpeningHourKind $openingHourKind)
+ {
+ return $this->createFormBuilder()
+ ->setAction($this->generateUrl('admin_openinghour_kind_delete', array('id' => $openingHourKind->getId())))
+ ->setMethod('DELETE')
+ ->getForm();
+ }
+}
diff --git a/src/AppBundle/Controller/AdminPeriodController.php b/src/AppBundle/Controller/AdminPeriodController.php
index d47a113be..d3babc957 100644
--- a/src/AppBundle/Controller/AdminPeriodController.php
+++ b/src/AppBundle/Controller/AdminPeriodController.php
@@ -190,7 +190,7 @@ public function editPeriodAction(Request $request, Period $period)
}
/**
- * @Route("/{id}/position/add", name="admin_period_position_new", methods={"POST"})
+ * @Route("/{id}/position/add", name="admin_periodposition_new", methods={"POST"})
* @Security("has_role('ROLE_SHIFT_MANAGER')")
*/
public function newPeriodPositionAction(Request $request, Period $period)
@@ -237,7 +237,7 @@ public function newPeriodPositionAction(Request $request, Period $period)
}
/**
- * @Route("/{id}/position/{position}", name="admin_period_position_delete", methods={"DELETE"})
+ * @Route("/{id}/position/{position}", name="admin_periodposition_delete", methods={"DELETE"})
* @Security("has_role('ROLE_ADMIN')")
*/
public function deletePeriodPositionAction(Request $request, Period $period, PeriodPosition $position)
@@ -261,7 +261,7 @@ public function deletePeriodPositionAction(Request $request, Period $period, Per
/**
* Book a period.
*
- * @Route("/{id}/position/{position}/book", name="admin_period_position_book", methods={"POST"})
+ * @Route("/{id}/position/{position}/book", name="admin_periodposition_book", methods={"POST"})
* @Security("has_role('ROLE_SHIFT_MANAGER')")
*/
public function bookPeriodPositionAction(Request $request, Period $period, PeriodPosition $position): Response
@@ -305,7 +305,7 @@ public function bookPeriodPositionAction(Request $request, Period $period, Perio
/**
* Free a position.
*
- * @Route("/{id}/position/{position}/free", name="admin_period_position_free", methods={"POST"})
+ * @Route("/{id}/position/{position}/free", name="admin_periodposition_free", methods={"POST"})
* @Security("has_role('ROLE_SHIFT_MANAGER')")
*/
public function freePeriodPositionAction(Request $request, Period $period, PeriodPosition $position)
@@ -477,7 +477,7 @@ private function createPeriodPositionAddForm(Period $period)
new PeriodPosition(),
array(
'action' => $this->generateUrl(
- 'admin_period_position_new',
+ 'admin_periodposition_new',
array('id' => $period->getId())
)
));
@@ -494,7 +494,7 @@ private function createPeriodPositionAddForm(Period $period)
private function createPeriodPositionBookForm(Period $period, PeriodPosition $position)
{
return $this->get('form.factory')->createNamedBuilder('positions_book_forms_' . $position->getId())
- ->setAction($this->generateUrl('admin_period_position_book', array('id' => $period->getId(), 'position' => $position->getId())))
+ ->setAction($this->generateUrl('admin_periodposition_book', array('id' => $period->getId(), 'position' => $position->getId())))
->setMethod('POST')
->add('shifter', AutocompleteBeneficiaryType::class, array('label' => 'Numéro d\'adhérent ou nom du membre', 'required' => true))
->getForm();
@@ -511,7 +511,7 @@ private function createPeriodPositionBookForm(Period $period, PeriodPosition $po
private function createPeriodPositionFreeForm(Period $period, PeriodPosition $position)
{
return $this->get('form.factory')->createNamedBuilder('positions_free_forms_' . $position->getId())
- ->setAction($this->generateUrl('admin_period_position_free', array('id' => $period->getId(), 'position' => $position->getId())))
+ ->setAction($this->generateUrl('admin_periodposition_free', array('id' => $period->getId(), 'position' => $position->getId())))
->setMethod('POST')
->getForm();
}
@@ -527,7 +527,7 @@ private function createPeriodPositionFreeForm(Period $period, PeriodPosition $po
private function createPeriodPositionDeleteForm(Period $period, PeriodPosition $position)
{
return $this->get('form.factory')->createNamedBuilder('positions_delete_forms_' . $position->getId())
- ->setAction($this->generateUrl('admin_period_position_delete', array('id' => $period->getId(), 'position' => $position->getId())))
+ ->setAction($this->generateUrl('admin_periodposition_delete', array('id' => $period->getId(), 'position' => $position->getId())))
->setMethod('DELETE')
->getForm();
}
diff --git a/src/AppBundle/Controller/OpeningHourController.php b/src/AppBundle/Controller/OpeningHourController.php
index 55e6795c6..f779cae95 100644
--- a/src/AppBundle/Controller/OpeningHourController.php
+++ b/src/AppBundle/Controller/OpeningHourController.php
@@ -23,14 +23,24 @@ public function widgetAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
+ $openingHourKind = null;
+
$filter_title = $request->query->has('title') ? ($request->get('title') == 1) : true;
+ $filter_kind_title = $request->query->has('kind_title') ? ($request->get('kind_title') == 1) : true;
$filter_align = $request->query->has('align') ? $request->get('align') : 'center';
- $openingHours = $em->getRepository('AppBundle:OpeningHour')->findAll();
+ $filter_opening_hour_kind_id = $request->get('opening_hour_kind_id');
+ if ($filter_opening_hour_kind_id) {
+ $openingHourKind = $em->getRepository('AppBundle:OpeningHourKind')->find($filter_opening_hour_kind_id);
+ }
+
+ $openingHours = $em->getRepository('AppBundle:OpeningHour')->findAll($openingHourKind);
return $this->render('admin/openinghour/_partial/widget.html.twig', [
'openingHours' => $openingHours,
+ 'openingHourKind' => $openingHourKind,
'title' => $filter_title,
+ 'kind_title' => $filter_kind_title,
'align' => $filter_align,
]);
}
diff --git a/src/AppBundle/Entity/OpeningHour.php b/src/AppBundle/Entity/OpeningHour.php
index fdcf619d5..f25f23339 100644
--- a/src/AppBundle/Entity/OpeningHour.php
+++ b/src/AppBundle/Entity/OpeningHour.php
@@ -44,6 +44,12 @@ class OpeningHour
*/
private $end;
+ /**
+ * @ORM\ManyToOne(targetEntity="OpeningHourKind", inversedBy="openingHours", fetch="EAGER")
+ * @ORM\JoinColumn(name="opening_hour_kind_id", referencedColumnName="id", onDelete="SET NULL")
+ */
+ private $kind;
+
/**
* @var \DateTime
*
@@ -60,7 +66,7 @@ public function setCreatedAtValue()
}
/**
- * Get id.
+ * Get id
*
* @return int
*/
@@ -161,7 +167,31 @@ public function isStartBeforeEnd()
}
/**
- * Set createdAt.
+ * Set kind
+ *
+ * @param \AppBundle\Entity\OpeningHourKind $openingHourKind
+ *
+ * @return Event
+ */
+ public function setKind(\AppBundle\Entity\OpeningHourKind $openingHourKind = null)
+ {
+ $this->kind = $openingHourKind;
+
+ return $this;
+ }
+
+ /**
+ * Get kind
+ *
+ * @return OpeningHourKind
+ */
+ public function getKind()
+ {
+ return $this->kind;
+ }
+
+ /**
+ * Set createdAt
*
* @param \DateTime $createdAt
*
@@ -175,7 +205,7 @@ public function setCreatedAt($createdAt)
}
/**
- * Get createdAt.
+ * Get createdAt
*
* @return \DateTime
*/
diff --git a/src/AppBundle/Entity/OpeningHourKind.php b/src/AppBundle/Entity/OpeningHourKind.php
new file mode 100644
index 000000000..60d80f13f
--- /dev/null
+++ b/src/AppBundle/Entity/OpeningHourKind.php
@@ -0,0 +1,291 @@
+name;
+ }
+
+ /**
+ * @ORM\PrePersist
+ */
+ public function setCreatedAtValue()
+ {
+ $this->createdAt = new \DateTime();
+ }
+
+ /**
+ * @ORM\PrePersist
+ * @ORM\PreUpdate
+ */
+ public function setUpdatedAtValue()
+ {
+ $this->updatedAt = new \DateTime();
+ }
+
+ /**
+ * Get id
+ *
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Set name
+ *
+ * @param string $name
+ *
+ * @return OpeningHourKind
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Set startDate
+ *
+ * @param \DateTime $date
+ *
+ * @return OpeningHourKind
+ */
+ public function setStartDate($date)
+ {
+ $this->startDate = $date;
+
+ return $this;
+ }
+
+ /**
+ * Get startDate
+ *
+ * @return \DateTime
+ */
+ public function getStartDate()
+ {
+ return $this->startDate;
+ }
+
+ /**
+ * Set endDate
+ *
+ * @param \DateTime $date
+ *
+ * @return OpeningHourKind
+ */
+ public function setEndDate($date)
+ {
+ $this->endDate = $date;
+
+ return $this;
+ }
+
+ /**
+ * Get endDate
+ *
+ * @return \DateTime
+ */
+ public function getEndDate()
+ {
+ return $this->endDate;
+ }
+
+ /**
+ * Get enabled
+ *
+ * @return bool
+ */
+ public function getEnabled()
+ {
+ return $this->enabled;
+ }
+
+ /**
+ * Set enabled
+ *
+ * @param bool $enabled
+ */
+ public function setEnabled(bool $enabled)
+ {
+ $this->enabled = $enabled;
+ }
+
+ /**
+ * Get openingHours
+ *
+ * @return \Doctrine\Common\Collections\Collection
+ */
+ public function getOpeningHours()
+ {
+ return $this->openingHours;
+ }
+
+ /**
+ * Get createdAt
+ *
+ * @return \DateTime
+ */
+ public function getCreatedAt()
+ {
+ return $this->createdAt;
+ }
+
+ /**
+ * Set createdBy
+ *
+ * @param \AppBundle\Entity\User $user
+ *
+ * @return OpeningHourKind
+ */
+ public function setCreatedBy(\AppBundle\Entity\User $user = null)
+ {
+ $this->createdBy = $user;
+
+ return $this;
+ }
+
+ /**
+ * Get createdBy
+ *
+ * @return \AppBundle\Entity\User
+ */
+ public function getCreatedBy()
+ {
+ return $this->createdBy;
+ }
+
+ /**
+ * Get updatedAt
+ *
+ * @return \DateTime
+ */
+ public function getUpdatedAt()
+ {
+ return $this->updatedAt;
+ }
+
+ /**
+ * Set updatedBy
+ *
+ * @param \AppBundle\Entity\User $user
+ *
+ * @return OpeningHourKind
+ */
+ public function setUpdatedBy(\AppBundle\Entity\User $user = null)
+ {
+ $this->updatedBy = $user;
+
+ return $this;
+ }
+
+ /**
+ * Get updatedBy
+ *
+ * @return \AppBundle\Entity\User
+ */
+ public function getUpdatedBy()
+ {
+ return $this->updatedBy;
+ }
+}
diff --git a/src/AppBundle/Form/JobType.php b/src/AppBundle/Form/JobType.php
index c16341fb3..bc37d7212 100644
--- a/src/AppBundle/Form/JobType.php
+++ b/src/AppBundle/Form/JobType.php
@@ -23,7 +23,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('color', TextType::class, array('label' => 'Couleur des créneaux dans le planning'))
->add('description', MarkdownEditorType::class, array('label' => 'Description', 'required' => false, 'empty_data' => ''))
->add('url', TextType::class, array('label' => 'Lien vers une documentation', 'required' => false))
- ->add('enabled', CheckboxType::class, array('required' => false, 'label' => 'Poste activé', 'attr' => array('class' => 'filled-in')));
+ ->add('enabled', CheckboxType::class, array('label' => 'Poste activé', 'required' => false, 'attr' => array('class' => 'filled-in')));
}
/**
diff --git a/src/AppBundle/Form/OpeningHourKindType.php b/src/AppBundle/Form/OpeningHourKindType.php
new file mode 100644
index 000000000..25bfcfd86
--- /dev/null
+++ b/src/AppBundle/Form/OpeningHourKindType.php
@@ -0,0 +1,43 @@
+add('name', TextType::class, array('label' => 'Nom', 'required' => true))
+ ->add('start_date', DateType::class, array('label' => 'Date de début (optionnel)', 'required' => false, 'html5' => false, 'widget' => 'single_text', 'attr' => array('class' => 'datepicker')))
+ ->add('end_date', DateType::class, array('label' => 'Date de fin (optionnel)', 'required' => false, 'html5' => false, 'widget' => 'single_text', 'attr' => array('class' => 'datepicker')))
+ ->add('enabled', CheckboxType::class, array('label' => 'Actif', 'required' => false, 'attr' => array('class' => 'filled-in')));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'data_class' => 'AppBundle\Entity\OpeningHourKind'
+ ));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBlockPrefix()
+ {
+ return 'appbundle_OpeningHourKind';
+ }
+}
diff --git a/src/AppBundle/Form/OpeningHourType.php b/src/AppBundle/Form/OpeningHourType.php
index 87257dd49..5fce23796 100644
--- a/src/AppBundle/Form/OpeningHourType.php
+++ b/src/AppBundle/Form/OpeningHourType.php
@@ -4,6 +4,8 @@
use AppBundle\Entity\OpeningHour;
use AppBundle\Entity\Period;
+use AppBundle\Repository\OpeningHourKindRepository;
+use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -20,7 +22,17 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add('dayOfWeek', ChoiceType::class, array('label' => 'Jour de la semaine', 'choices' => Period::DAYS_OF_WEEK_LIST_WITH_INT))
->add('start', TextType::class, array('label' => 'Heure de début', 'attr' => array('class' => 'timepicker')))
- ->add('end', TextType::class, array('label' => 'Heure de fin', 'attr' => array('class' => 'timepicker')));
+ ->add('end', TextType::class, array('label' => 'Heure de fin', 'attr' => array('class' => 'timepicker')))
+ ->add('kind', EntityType::class, array(
+ 'label' => 'Type d\'horaire d\'ouverture',
+ 'class' => 'AppBundle:OpeningHourKind',
+ 'choice_label' => 'name',
+ 'multiple' => false,
+ 'query_builder' => function (OpeningHourKindRepository $repository) {
+ return $repository->createQueryBuilder('ohk')
+ ->orderBy('ohk.id', 'ASC');
+ },
+ ));
}
/**
diff --git a/src/AppBundle/Repository/OpeningHourKindRepository.php b/src/AppBundle/Repository/OpeningHourKindRepository.php
new file mode 100644
index 000000000..87e7b0960
--- /dev/null
+++ b/src/AppBundle/Repository/OpeningHourKindRepository.php
@@ -0,0 +1,17 @@
+findBy(array(), array('id' => 'ASC'));
+ }
+}
diff --git a/src/AppBundle/Repository/OpeningHourRepository.php b/src/AppBundle/Repository/OpeningHourRepository.php
index 02472e795..f1c5af3b7 100644
--- a/src/AppBundle/Repository/OpeningHourRepository.php
+++ b/src/AppBundle/Repository/OpeningHourRepository.php
@@ -2,6 +2,8 @@
namespace AppBundle\Repository;
+use AppBundle\Entity\OpeningHourKind;
+
/**
* OpeningHourRepository
*
@@ -10,8 +12,25 @@
*/
class OpeningHourRepository extends \Doctrine\ORM\EntityRepository
{
- public function findAll()
+ public function findAll(OpeningHourKind $openingHourKind = null)
{
- return $this->findBy(array(), array('dayOfWeek' => 'ASC', 'start' => 'ASC'));
+ $qb = $this->createQueryBuilder('oh')
+ ->leftJoin('oh.kind', 'ohk')
+ ->addSelect('ohk');
+
+ if ($openingHourKind) {
+ $qb
+ ->andwhere('oh.kind = :kind')
+ ->setParameter('kind', $openingHourKind);
+ }
+
+ $qb
+ ->addOrderBy('ohk.id', 'ASC')
+ ->addOrderBy('oh.dayOfWeek', 'ASC')
+ ->addOrderBy('oh.start', 'ASC');
+
+ return $qb
+ ->getQuery()
+ ->getResult();
}
}
|