forked from elefan-grenoble/gestion-compte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pouvoir gérer une liste d'horaires d'ouvertures (elefan-grenoble#830)
* OpeningHourController. Add templates. Add button on admin page * Assert start < end. Order list by day & time * rename to Horaires d'ouverture. rename listAction to indexAction * Simple widget to display opening hours
- Loading branch information
1 parent
52ddb5e
commit dcda2a0
Showing
19 changed files
with
646 additions
and
26 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/DoctrineMigrations/Version20230423173822_opening_hour.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?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 Version20230423173822 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 (id INT AUTO_INCREMENT NOT NULL, day_of_week SMALLINT NOT NULL, start TIME NOT NULL, end TIME NOT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'); | ||
} | ||
|
||
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/Resources/views/admin/openinghour/_partial/form.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div class="errors"> | ||
{{ form_errors(form) }} | ||
</div> | ||
<div class="row"> | ||
<div class="col m4"> | ||
<div class="errors"> | ||
{{ form_errors(form.dayOfWeek) }} | ||
</div> | ||
<div class="input-field"> | ||
{{ form_widget(form.dayOfWeek) }} | ||
{{ form_label(form.dayOfWeek) }} | ||
</div> | ||
</div> | ||
<div class="col m4"> | ||
<div class="errors"> | ||
{{ form_errors(form.start) }} | ||
</div> | ||
<div class="input-field"> | ||
{{ form_widget(form.start) }} | ||
{{ form_label(form.start) }} | ||
</div> | ||
</div> | ||
<div class="col m4"> | ||
<div class="errors"> | ||
{{ form_errors(form.end) }} | ||
</div> | ||
<div class="input-field"> | ||
{{ form_widget(form.end) }} | ||
{{ form_label(form.end) }} | ||
</div> | ||
</div> | ||
</div> |
22 changes: 22 additions & 0 deletions
22
app/Resources/views/admin/openinghour/_partial/widget.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div class="card-panel"> | ||
<table style=" width: max-content; margin-top: 10px; margin-left: auto; margin-right: auto; border-collapse: separate; border-spacing: 10px 0px" class="no-padding"> | ||
<tbody> | ||
{% set dayOfWeek = -1 %} | ||
{% for openingHour in openingHours %} | ||
{% if openingHour.dayOfWeek == dayOfWeek %} | ||
& {{ openingHour.start | date('G\\hi') }}-{{ openingHour.end | date('G\\hi') }} | ||
{% else %} | ||
{# close previous day #} | ||
{% if loop.index > 0 %}</td></tr>{% endif %} | ||
{# open new day #} | ||
<tr> | ||
<td class="no-padding" style="text-align:right">{{ openingHour.dayOfWeekString | capitalize }} : </td> | ||
<td class="no-padding">{{ openingHour.start | date('G\\hi') }}-{{ openingHour.end | date('G\\hi') }} | ||
{% endif %} | ||
{% set dayOfWeek = openingHour.dayOfWeek %} | ||
{% endfor %} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% extends 'layout.html.twig' %} | ||
|
||
{% block title %}Editer l'horaire d'ouverture - {{ 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> Administration</a><i class="material-icons">chevron_right</i> | ||
<a href="{{ path('admin_openinghour_index') }}"><i class="material-icons">schedule</i> Horaires d'ouverture</a><i class="material-icons">chevron_right</i> | ||
<i class="material-icons">edit</i> Editer | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h4>Editer l'horaire d'ouverture</h4> | ||
|
||
{{ form_start(form) }} | ||
{% include "/admin/openinghour/_partial/form.html.twig" with { form: form } %} | ||
<div> | ||
<button type="submit" class="btn waves-effect waves-light"><i class="material-icons left">save</i>Enregistrer</button> | ||
</div> | ||
{{ form_end(form) }} | ||
|
||
{{ form_start(delete_form) }} | ||
{{ form_widget(delete_form) }} | ||
<div> | ||
<button type="submit" class="btn waves-effect waves-light red">Supprimer</button> | ||
</div> | ||
{{ form_end(delete_form) }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{% extends 'layout.html.twig' %} | ||
|
||
{% block title %}Horaires d'ouverture - {{ 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> Administration</a><i class="material-icons">chevron_right</i> | ||
<i class="material-icons">schedule</i> Horaires d'ouverture | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h4>Horaires d'ouverture</h4> | ||
|
||
{% if openingHours %} | ||
<div class="row"> | ||
<div class="col m6"> | ||
{% include "/admin/openinghour/_partial/widget.html.twig" with { openingHours: openingHours } %} | ||
</div> | ||
</div> | ||
{% else %} | ||
<div class="card-panel yellow lighten-3"> | ||
Aucune horaire d'ouverture à afficher. | ||
</div> | ||
{% endif %} | ||
|
||
<h4>Liste des horaires d'ouverture ({{ openingHours | length }})</h4> | ||
|
||
<table class="responsive-table"> | ||
<thead> | ||
<tr> | ||
<th>Jour d'ouverture</th> | ||
<th>Heure de début</th> | ||
<th>Heure de fin</th> | ||
<th>Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for openingHour in openingHours %} | ||
<tr> | ||
<td>{{ openingHour.dayOfWeekString | capitalize }}</td> | ||
<td>{{ openingHour.start | date('H:i') }}</td> | ||
<td>{{ openingHour.end | date('H:i') }}</td> | ||
<td> | ||
<a href="{{ path("admin_openinghour_edit", { 'id': openingHour.id }) }}"> | ||
<i class="material-icons">edit</i>editer | ||
</a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
|
||
<br /> | ||
<a href="{{ path('admin_openinghour_new') }}" class="btn"> | ||
<i class="material-icons left">add</i>Ajouter une horaire d'ouverture | ||
</a> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% extends 'layout.html.twig' %} | ||
|
||
{% block title %}Ajouter une horaire d'ouverture - {{ 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> Administration</a><i class="material-icons">chevron_right</i> | ||
<a href="{{ path('admin_openinghour_index') }}"><i class="material-icons">schedule</i> Horaires d'ouverture</a><i class="material-icons">chevron_right</i> | ||
<i class="material-icons">add</i> Ajouter | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h4>Nouvelle horaire d'ouverture</h4> | ||
|
||
{{ form_start(form) }} | ||
{% include "/admin/openinghour/_partial/form.html.twig" with { form: form } %} | ||
<div> | ||
<button type="submit" class="btn waves-effect waves-light">Créer</button> | ||
</div> | ||
{{ form_end(form) }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/Resources/views/user/_partial/period_position_card.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.