-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ba0631
commit bfd60bf
Showing
5 changed files
with
139 additions
and
1 deletion.
There are no files selected for viewing
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
66 changes: 66 additions & 0 deletions
66
module/CudiBundle/Form/Admin/Sale/Session/OpeningHour/Schedule.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,66 @@ | ||
<?php | ||
|
||
namespace CudiBundle\Form\Admin\Sale\Session\OpeningHour; | ||
|
||
use DateInterval; | ||
use DatePeriod; | ||
use DateTime; | ||
|
||
/** | ||
* Add Order | ||
* | ||
* @author Pedro Devogelaere <[email protected]> | ||
*/ | ||
class Schedule extends \CommonBundle\Component\Form\Admin\Form | ||
{ | ||
protected $hydrator = 'CudiBundle\Hydrator\Sale\Session\OpeningHour'; | ||
|
||
public function init() | ||
{ | ||
parent::init(); | ||
|
||
$days = $this->createDaysArray(); | ||
|
||
foreach ($days as $day) { | ||
$this->add( | ||
array( | ||
'type' => 'checkbox', | ||
'name' => 'interval_12:30-14:00_' . $day->format('d/m/Y'), | ||
'label' => $day->format('l') . ' 12:30 - 14:00', | ||
'attributes' => array( | ||
'id' => 'interval_12:30-14:00_' . $day->format('d/m/Y'), | ||
), | ||
) | ||
); | ||
|
||
$this->add( | ||
array( | ||
'type' => 'checkbox', | ||
'name' => 'interval_18:00-19:00_' . $day->format('d/m/Y'), | ||
'label' => $day->format('l') . ' 18:00 - 19:00', | ||
'attributes' => array( | ||
'id' => 'interval_18:00-19:00_' . $day->format('d/m/Y'), | ||
), | ||
) | ||
); | ||
} | ||
|
||
$this->addSubmit('Add', 'clock_add'); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
private function createDaysArray() | ||
{ | ||
$dt = new DateTime(); // create DateTime object with current time | ||
$dt->setISODate($dt->format('o'), $dt->format('W') + 1); // set object to Monday on next week | ||
$periods = new DatePeriod($dt, new DateInterval('P1D'), 3); // get all 1day periods from Monday to +6 days | ||
$days = iterator_to_array($periods); // convert DatePeriod object to array | ||
// $days[0] is Monday, ..., $days[3] is Thursday | ||
// to format selected date do: $days[1]->format('Y-m-d'); | ||
|
||
return $days; | ||
} | ||
} | ||
|
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
12 changes: 12 additions & 0 deletions
12
module/CudiBundle/Resources/views/cudi/admin/sale/session/opening-hour/schedule.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,12 @@ | ||
{% extends 'admin/base.twig' %} | ||
|
||
{% block content %} | ||
{% include 'cudi/admin/sale/session/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> | ||
<div id="controller_action"> | ||
{% import 'admin/partials/form.twig' as forms %} | ||
{{ forms.renderForm(form) }} | ||
</div> | ||
{% endblock %} |