Skip to content

Commit

Permalink
Horaires d'ouverture : pouvoir définir le type d'horaire (#964)
Browse files Browse the repository at this point in the history
* Create OpeningHourKind entity

* AdminOpeningHourKindController list, new, edit & delete

* Rename PeriodPosition controller views

* New OpeningHour.kind field. Update templates

* Update widget generator
  • Loading branch information
raphodn authored Aug 25, 2023
1 parent 4bf7508 commit 623dfb2
Show file tree
Hide file tree
Showing 38 changed files with 977 additions and 184 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230825104026 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() 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('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');
}
}
39 changes: 39 additions & 0 deletions app/DoctrineMigrations/Version20230825120912_opening_hour_kind.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230825120912 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() 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 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');
}
}
56 changes: 56 additions & 0 deletions app/Resources/views/admin/event/_partial/form.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{% set edit = edit ?? false %}

<div class="errors">
{{ form_errors(form) }}
</div>
<div class="row">
<div class="col m6">
{{ form_row(form.title) }}
</div>
<div class="col m6">
{{ form_row(form.kind) }}
</div>
</div>
<div class="row">
<div class="col m6">
{{ form_row(form.date) }}
</div>
<div class="col m6">
{{ form_row(form.end) }}
</div>
</div>
<div class="row">
{{ form_row(form.location) }}
</div>
<div class="row">
{{ form_row(form.description) }}
</div>
<div class="row">
{{ form_row(form.imgFile) }}
</div>

{% if edit %}
<h5>Nécessite un vote ?</h5>
<div class="row">
<div class="col m6">
{{ form_errors(form.need_proxy) }}
<label>
{{ form_widget(form.need_proxy) }}
<span>{{ form.need_proxy.vars.label }}</span>
</label>
</div>
<div class="col m6">
{{ form_errors(form.anonymous_proxy) }}
<label>
{{ form_widget(form.anonymous_proxy) }}
<span>{{ form.anonymous_proxy.vars.label }}</span>
</label>
</div>
</div>
<div class="row">
<div class="col m6">
{{ form_row(form.max_date_of_last_registration) }}
</div>
</div>
{% include "admin/member/_partial/created_updated_card.html.twig" with { item: event } %}
{% endif %}
83 changes: 7 additions & 76 deletions app/Resources/views/admin/event/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,79 +13,10 @@
<h4>Editer un événement</h4>

{{ form_start(form) }}
<div class="errors">
{{ form_errors(form) }}
</div>
<div class="row">
<div class="col m6">
{{ form_row(form.title) }}
</div>
<div class="col m6">
{{ form_row(form.kind) }}
</div>
</div>
<div class="row">
<div class="col m6">
{{ form_row(form.date) }}
</div>
<div class="col m6">
{{ form_row(form.end) }}
</div>
</div>
<div class="row">
{{ form_row(form.location) }}
</div>
<div class="row">
{{ form_row(form.description) }}
</div>
<div class="row">
<div class="col s12">
<div class="errors">
{{ form_errors(form.imgFile) }}
</div>
<div class="">
{{ form_widget(form.imgFile) }}
{{ form_label(form.imgFile) }}
</div>
</div>
</div>
<h5>Nécessite un vote ?</h5>
<div class="row">
<div class="col m6">
{{ form_errors(form.need_proxy) }}
<label>
{{ form_widget(form.need_proxy) }}
<span>{{ form.need_proxy.vars.label }}</span>
</label>
</div>
<div class="col m6">
{{ form_errors(form.anonymous_proxy) }}
<label>
{{ form_widget(form.anonymous_proxy) }}
<span>{{ form.anonymous_proxy.vars.label }}</span>
</label>
</div>
</div>
<div class="row">
<div class="col m6">
{{ form_row(form.max_date_of_last_registration) }}
</div>
</div>
{% if event.createdBy or event.updatedBy %}
<div class="card-panel">
{% if event.createdBy %}
<i>Création le {{ event.createdAt | date_fr_full_with_time }} par {% include "admin/member/_partial/member_or_user_link.html.twig" with { user: event.createdBy, target_blank: true } %}</i>
<br />
{% endif %}
{% if event.updatedBy %}
<i>Dernière modification le {{ event.updatedAt | date_fr_full_with_time }} par {% include "admin/member/_partial/member_or_user_link.html.twig" with { user: event.updatedBy, target_blank: true } %}</i>
{% endif %}
</div>
{% endif %}
<br />
<div>
<button type="submit" class="btn waves-effect waves-light"><i class="material-icons left">save</i>Enregistrer</button>
</div>
{% include "/admin/event/_partial/form.html.twig" with { form: form, edit: true, event: event } %}
<button type="submit" class="btn waves-effect waves-light" title="Enregistrer">
<i class="material-icons left">save</i>Enregistrer
</button>
{{ form_end(form) }}

{% if is_granted("ROLE_ADMIN") %}
Expand All @@ -102,9 +33,9 @@

{{ form_start(delete_form) }}
{{ form_widget(delete_form) }}
<div>
<button type="submit" class="btn waves-effect waves-light red">Supprimer</button>
</div>
<button type="submit" class="btn waves-effect waves-light red" onclick="return confirm('Etes-vous sûr ?!');">
<i class="material-icons left">delete</i>Supprimer
</button>
{{ form_end(delete_form) }}
{% endif %}
{% endblock %}
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/views/admin/event/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
{% endif %}
<br />
<a href="{{ path('admin_event_new') }}" class="btn"><i class="material-icons left">add</i>Ajouter un événement</a>
<a href="{{ path('event_widget_generator') }}" class="btn"><i class="material-icons left">tune</i>Générer un widget</a>
<a href="{{ path('admin_event_widget_generator') }}" class="btn"><i class="material-icons left">tune</i>Générer un widget</a>
{% endblock %}
6 changes: 6 additions & 0 deletions app/Resources/views/admin/event/kind/_partial/form.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div class="errors">
{{ form_errors(form) }}
</div>
<div class="row">
{{ form_row(form.name) }}
</div>
20 changes: 7 additions & 13 deletions app/Resources/views/admin/event/kind/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,18 @@
<h4>Editer un type d'événement</h4>

{{ form_start(form) }}
<div class="errors">
{{ form_errors(form) }}
</div>
<div class="row">
{{ form_row(form.name) }}
</div>
<br />
<div>
<button type="submit" class="btn waves-effect waves-light"><i class="material-icons left">save</i>Enregistrer</button>
</div>
{% include "/admin/event/kind/_partial/form.html.twig" with { form: form } %}
<button type="submit" class="btn waves-effect waves-light" title="Enregistrer">
<i class="material-icons left">save</i>Enregistrer
</button>
{{ form_end(form) }}

{% if is_granted("ROLE_ADMIN") %}
{{ form_start(delete_form) }}
{{ form_widget(delete_form) }}
<div>
<button type="submit" class="btn waves-effect waves-light red">Supprimer</button>
</div>
<button type="submit" class="btn waves-effect waves-light red" onclick="return confirm('Etes-vous sûr ?!');">
<i class="material-icons left">delete</i>Supprimer
</button>
{{ form_end(delete_form) }}
{% endif %}
{% endblock %}
8 changes: 6 additions & 2 deletions app/Resources/views/admin/event/kind/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
<td class="{{ eventKind.name }}">{{ eventKind.name }}</td>
<td>{{ eventKind.events | length }}</td>
<td>
<a href="{{ path('admin_event_kind_edit', { 'id': eventKind.id }) }}"><i class="material-icons">edit</i>Editer</a>
<a href="{{ path('admin_event_kind_edit', { 'id': eventKind.id }) }}">
<i class="material-icons">edit</i>Editer
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>

<br />
<a href="{{ path('admin_event_kind_new') }}" class="btn"><i class="material-icons left">add</i>Ajouter un type d'événement</a>
<a href="{{ path('admin_event_kind_new') }}" class="btn">
<i class="material-icons left">add</i>Ajouter un type d'événement
</a>
{% endblock %}
21 changes: 11 additions & 10 deletions app/Resources/views/admin/event/kind/new.html.twig
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{% extends 'layout.html.twig' %}

{% block title %}Ajouter un événement - {{ site_name }}{% endblock %}
{% block title %}Ajouter un type d'événement - {{ site_name }}{% endblock %}

{% block breadcrumbs %}
<a href="{{ path('homepage') }}"><i class="material-icons">home</i></a><i class="material-icons">chevron_right</i>
<a href="{{ path('admin') }}"><i class="material-icons">build</i>&nbsp;Administration</a><i class="material-icons">chevron_right</i>
<a href="{{ path('admin_event_index') }}"><i class="material-icons">list</i>&nbsp;Liste des types d'événements</a><i class="material-icons">chevron_right</i>
<a href="{{ path('admin_event_kind_list') }}"><i class="material-icons">list</i>&nbsp;Liste des types d'événements</a><i class="material-icons">chevron_right</i>
<i class="material-icons">add</i>&nbsp;Ajouter
{% endblock %}

{% block content %}
<h4>Nouveau type d'événement</h4>
<h4>Nouveau type d'événement</h4>

{{ form_start(form) }}
{{ form_widget(form) }}
<br />
<div>
<button type="submit" class="btn waves-effect waves-light">Créer</button>
</div>
{{ form_end(form) }}
{{ form_start(form) }}
{% include "/admin/event/kind/_partial/form.html.twig" with { form: form } %}
<button type="submit" class="btn waves-effect waves-light" title="Créer">
<i class="material-icons left">save</i>Créer
</button>
{{ form_end(form) }}

<a href="{{ path('admin_event_kind_list') }}" class="btn waves-effect waves-light red" title="Annuler">Annuler</a>
{% endblock %}
36 changes: 6 additions & 30 deletions app/Resources/views/admin/event/new.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,11 @@
<h4>Nouvel événement</h4>

{{ form_start(form) }}
<div class="errors">
{{ form_errors(form) }}
</div>
<div class="row">
<div class="col m6">
{{ form_row(form.title) }}
</div>
<div class="col m6">
{{ form_row(form.kind) }}
</div>
</div>
<div class="row">
<div class="col m6">
{{ form_row(form.date) }}
</div>
<div class="col m6">
{{ form_row(form.end) }}
</div>
</div>
<div class="row">
{{ form_row(form.location) }}
</div>
<div class="row">
{{ form_row(form.description) }}
</div>
<div class="row">
{{ form_row(form.imgFile) }}
</div>
<a href="{{ path('admin_event_index') }}" class="waves-effect waves-light btn red white-text" title="Annuler">Annuler</a>
<button type="submit" class="btn waves-effect waves-light"><i class="material-icons left">save</i>Créer</button>
{% include "/admin/event/_partial/form.html.twig" with { form: form } %}
<button type="submit" class="btn waves-effect waves-light" title="Créer">
<i class="material-icons left">save</i>Créer
</button>
{{ form_end(form) }}

<a href="{{ path('admin_event_index') }}" class="btn waves-effect waves-light red" title="Annuler">Annuler</a>
{% endblock %}
3 changes: 3 additions & 0 deletions app/Resources/views/admin/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
<a href="{{ path("admin_openinghour_index") }}" class="waves-effect waves-light btn teal">
<i class="material-icons left">schedule</i>Horaires d'ouverture
</a>
<a href="{{ path("admin_openinghour_kind_list") }}" class="waves-effect waves-light btn teal">
<i class="material-icons left">schedule</i>Types d'horaires d'ouverture
</a>
<a href="{{ path("admin_closingexception_index") }}" class="waves-effect waves-light btn teal">
<i class="material-icons left">block</i>Fermetures exceptionnelles
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% if item.createdBy or item.updatedBy %}
<div class="card-panel">
{% if item.createdBy %}
<i>Création le {{ item.createdAt | date_fr_full_with_time }} par {% include "admin/member/_partial/member_or_user_link.html.twig" with { user: item.createdBy, target_blank: true } %}</i>
<br />
{% endif %}
{% if item.updatedBy %}
<i>Dernière modification le {{ item.updatedAt | date_fr_full_with_time }} par {% include "admin/member/_partial/member_or_user_link.html.twig" with { user: item.updatedBy, target_blank: true } %}</i>
{% endif %}
</div>
{% endif %}
Loading

0 comments on commit 623dfb2

Please sign in to comment.