Skip to content

Commit

Permalink
automatic shifts add for waaiberg cantus
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrodevog committed Oct 16, 2023
1 parent a1e526d commit 472cf25
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 3 deletions.
182 changes: 182 additions & 0 deletions module/CalendarBundle/Controller/Admin/CalendarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Handles system admin for calendar.
*
* @author Kristof Mariën <[email protected]>
* @author Pedro Devogelaere <[email protected]>
*/
class CalendarController extends \CommonBundle\Component\Controller\ActionController\AdminController
{
Expand Down Expand Up @@ -85,6 +86,187 @@ public function addAction()
);
}

public function templateAction()
{
$form = $this->getForm('calendar_event_add');
$shiftForm = $this->getForm('shift_shift_add');

if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
$form->setData($formData);

if ($form->isValid()) {
$event = $form->hydrateObject();

$this->getEntityManager()->persist($event);
$this->getEntityManager()->flush();

$data = array(
'manager' => false,
'unit' => 3,
'event' => $event->getId(),
'location' => 2,
'nb_responsibles' => 0,
'handled_on_event' => false,
'ticket_needed' => false,
'points' => 0,
);

$startDate = $event->getStartDate()->format('d/m/Y');
$endDate = $event->getEndDate()->format('d/m/Y');

$data['name'] = 'Pispolitie';
$data['description'] = 'Mensen die naar het toilet willen een strafje geven';
$data['nb_volunteers'] = 2;
$data['nb_volunteers_min'] = 2;
$data['reward'] = 2;
$data['start_date'] = $startDate . ' 20:30';
$data['end_date'] = $startDate . ' 22:00';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['start_date'] = $startDate . ' 22:15';
$data['end_date'] = $endDate . ' 00:00';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['name'] = 'Controleren QR-code + bandjes uitdelen';
$data['description'] = 'Controleren QR-code + bandjes uitdelen';
$data['reward'] = 1;
$data['start_date'] = $startDate . ' 20:00';
$data['end_date'] = $startDate . ' 20:30';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['name'] = 'Stewarden';
$data['description'] = 'Zorgen dat er niemand luid is buiten en fiksen dat er geen drank buiten geraakt';
$data['start_date'] = $startDate . ' 22:00';
$data['end_date'] = $startDate . ' 22:15';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['start_date'] = $endDate . ' 00:00';
$data['end_date'] = $endDate . ' 00:15';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['name'] = 'Bijrijden';
$data['description'] = 'Chille in de kar. Locatie van de loods is: Tervuursevest 238';
$data['nb_volunteers_min'] = 1;
$data['start_date'] = $startDate . ' 18:00';
$data['end_date'] = $startDate . ' 19:00';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['name'] = 'Corona stilhouden';
$data['description'] = 'Je mag ze ook buiten gooien als ze niet stil zijn xxx';
$data['start_date'] = $endDate . ' 00:15';
$data['end_date'] = $endDate . ' 01:00';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['name'] = 'Bandjes controleren';
$data['description'] = 'Bandjes controleren tijdens de tempus';
$data['nb_volunteers'] = 1;
$data['start_date'] = $startDate . ' 22:00';
$data['end_date'] = $startDate . ' 22:15';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['start_date'] = $endDate . ' 00:00';
$data['end_date'] = $endDate . ' 00:15';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['name'] = 'Tappen & Rondbrengen';
$data['description'] = 'Tappen & Rondbrengen';
$data['nb_volunteers'] = 4;
$data['nb_volunteers_min'] = 3;
$data['reward'] = 2;
$data['start_date'] = $startDate . ' 20:30';
$data['end_date'] = $startDate . ' 22:00';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['start_date'] = $startDate . ' 22:15';
$data['end_date'] = $endDate . ' 00:00';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['start_date'] = $endDate . ' 00:15';
$data['end_date'] = $endDate . ' 01:00';
$data['reward'] = 1;

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['name'] = 'Opbouwen';
$data['description'] = 'Wat tafels en stoelen klaar zetten voor de cantus';
$data['start_date'] = $startDate . ' 19:00';
$data['end_date'] = $startDate . ' 20:00';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$data['name'] = 'Afbraak';
$data['description'] = 'Please help ons mee en zorg dat we na een half uurtje klaar kunnen zijn :))';
$data['nb_volunteers'] = 5;
$data['start_date'] = $endDate . ' 01:00';
$data['end_date'] = $endDate . ' 02:00';

$this->getEntityManager()->persist(
$shiftForm->getHydrator()->hydrate($data)
);

$this->getEntityManager()->flush();

$this->flashMessenger()->success(
'Success',
'The event and shifts were successfully added!'
);

$this->redirect()->toRoute(
'calendar_admin_calendar',
array(
'action' => 'manage',
)
);

return new ViewModel();
}
}

return new ViewModel(
array(
'form' => $form,
)
);
}

public function editAction()
{
$event = $this->getEventEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
return array(
'calendarbundle' => array(
'calendar_admin_calendar' => array(
'add', 'delete', 'edit', 'editPoster', 'manage', 'old', 'poster', 'upload',
'add', 'delete', 'edit', 'editPoster', 'manage', 'old', 'poster', 'upload', 'template',
),
'calendar_admin_calendar_registration' => array(
'export', 'manage',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@

{% include 'admin/partials/flashMessenger.twig' %}

<aside>
{% if hasAccess('calendar_admin_calendar', 'template') %}
<div class="sidebox" style="margin-top: 35px">
<div class="title">Cantus template</div>
<div class="content">
<p>
<i>Please hit the link below to add a Waaiberg cantus from the template! This ensures all shifts are made automatically.</i>
</p>
<p>
<a href="{{ url('calendar_admin_calendar', {"action": "template"}) }}">&rarr; Template</a>
</p>
</div>
</div>
{% endif %}
</aside>

<div id="controller_action">
{% import 'admin/partials/form.twig' as forms %}
{{ forms.renderForm(form) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<li><a {% if 'calendar_admin_calendar_registration' == getParam('controller') %} class="active" {% endif %} href="{{ url('calendar_admin_calendar_registration', {"action": "manage"}) }}">Registration</a></li>
{% endif %}
{% if hasAccess('calendar_admin_calendar', 'add') %}
<li><a {% if 'add' == getParam('action') and 'calendar_admin_calendar' == getParam('controller') %} class="active" {% endif %} href="{{ url('calendar_admin_calendar', {"action": "add"}) }}">Add</a></li>
<li><a {% if ('add' == getParam('action') or 'template' == getParam('action')) and 'calendar_admin_calendar' == getParam('controller') %} class="active" {% endif %} href="{{ url('calendar_admin_calendar', {"action": "add"}) }}">Add</a></li>
{% endif %}
{% if hasAccess('calendar_admin_calendar', 'old') %}
<li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{% extends 'admin/base.twig' %}

{% block content %}
{% include 'calendar/admin/calendar/partials/navigation.twig' %}

{% include 'admin/partials/flashMessenger.twig' %}

<aside>
{% if hasAccess('calendar_admin_calendar', 'add') %}
<div class="sidebox" style="margin-top: 35px">
<div class="title">Go back</div>
<div class="content">
<p>
<i>Please hit the link below to go back to the normal add function!</i>
</p>
<p>
<a href="{{ url('calendar_admin_calendar', {"action": "add"}) }}">&rarr; Add</a>
</p>
</div>
</div>
{% endif %}
</aside>

<div id="controller_action">
{% import 'admin/partials/form.twig' as forms %}
{{ forms.renderForm(form) }}
</div>
{% endblock %}

{% block content_script %}
<script type="text/javascript">
$(document).ready(function () {
$('#languages a:first').click();
});
$(document).ready(function () {
$('textarea').gollum({
toolbar: {
"bold": ["bold", "Bold", "bold"],
"italic": ["italic", "Italic", "italic"],
"divider": "-",
"link": ["link", "Link", "link"],
"divider": "-",
"ul": ["ul", "Unordered List", "u-list"],
"ol": ["ol", "Ordered List", "o-list"],
"blockquote": ["blockquote", "Blockquote", "quotemark"],
"hr": ["hr", "Horizontal Rule", "horizontal-rule"],
"divider": "-",
"help": ["help", "Help", "help"],
},
});
});
</script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% include 'shop/admin/opening-hour/partials/navigation.twig' %}

{% include 'admin/partials/flashMessenger.twig' %}
<h1>Week: <b>{{ nextMonday.format('l d/m') }}</b> - <b>{{ nextMonday.modify('next thursday').format('l d/m') }}</b></h1>
<h1>Week: <b>{{ nextMonday.format('l d/m') }}</b> - <b>{{ nextMonday.modify('next friday').format('l d/m') }}</b></h1>
<div id="controller_action">
{% import 'admin/partials/form.twig' as forms %}
{{ forms.renderForm(form) }}
Expand Down

0 comments on commit 472cf25

Please sign in to comment.