diff --git a/module/CudiBundle/Controller/Admin/Sale/Session/OpeningHourController.php b/module/CudiBundle/Controller/Admin/Sale/Session/OpeningHourController.php index 03cfeb6a08..0310b623ed 100644 --- a/module/CudiBundle/Controller/Admin/Sale/Session/OpeningHourController.php +++ b/module/CudiBundle/Controller/Admin/Sale/Session/OpeningHourController.php @@ -127,6 +127,7 @@ public function editAction() public function scheduleAction() { $form = $this->getForm('cudi_sale_session_opening-hour_schedule'); + $shiftForm = $this->getForm('shift_shift_schedule'); $registrationForm = $this->getForm('shift_registration-shift_schedule'); $now = (new DateTime())->format('d/m/Y H:i'); @@ -147,6 +148,7 @@ public function scheduleAction() $startDate = $split[2] . ' ' . $startHour; $endDate = $split[2] . ' ' . $endHour; + // OPENING HOURS $data = array(); $data["start_date"] = $startDate; $data["end_date"] = $endDate; @@ -155,6 +157,32 @@ public function scheduleAction() $form->getHydrator()->hydrate($data) ); + // SHIFTS + $reward = $startHour == '12:30'? 2: 1; + + $shift = array( + 'name' => 'Boekjes verkopen', + 'description' => 'Kom helpen met boeken verkopen. Leer nieuwe mensen kennen en kom de sfeer opsnuiven. +(Er is altijd begeleiding dus wees niet bang als je voor de eerste keer komt ;))', + 'manager' => false, + 'unit' => 1, + 'event' => '', + 'location' => 1, + 'start_date' => $startDate, + 'end_date' => $endDate, + 'nb_responsibles' => 1, + 'nb_volunteers' => $formData['volunteers_' . $startHour . '-' . $endHour . '_' . $split[2]], + 'nb_volunteers_min' => $formData['volunteers-min_' . $startHour . '-' . $endHour . '_' . $split[2]], + 'reward' => $reward, + 'handled_on_event' => false, + 'ticket_needed' => false, + 'points' => 0, + ); + $this->getEntityManager()->persist( + $shiftForm->getHydrator()->hydrate($shift) + ); + + // REGISTRATION SHIFTS $count = 0; $startHour_ = $startHour; // creating dummy variable that is updated $signoutDate = (DateTime::createFromFormat('d/m/Y', $split[2]))->modify('+1 day')->format('d/m/Y') . ' 00:00'; diff --git a/module/CudiBundle/Form/Admin/Sale/Session/OpeningHour/Schedule.php b/module/CudiBundle/Form/Admin/Sale/Session/OpeningHour/Schedule.php index 5b25b1ba36..7fb1492826 100644 --- a/module/CudiBundle/Form/Admin/Sale/Session/OpeningHour/Schedule.php +++ b/module/CudiBundle/Form/Admin/Sale/Session/OpeningHour/Schedule.php @@ -27,22 +27,108 @@ public function init() 'type' => 'checkbox', 'name' => 'interval_12:30-14:00_' . $day->format('d/m/Y'), 'label' => $day->format('l') . ' 12:30 - 14:00', + 'required' => true, 'attributes' => array( 'id' => 'interval_12:30-14:00_' . $day->format('d/m/Y'), ), ) ); + $this->add( + array( + 'type' => 'text', + 'name' => 'volunteers_12:30-14:00_' . $day->format('d/m/Y'), + 'label' => 'Volunteers', + 'attributes' => array( + 'value' => '0', + ), + 'options' => array( + 'input' => array( + 'filters' => array( + array('name' => 'StringTrim'), + ), + 'validators' => array( + array('name' => 'Int'), + ), + ), + ), + ) + ); + + $this->add( + array( + 'type' => 'text', + 'name' => 'volunteers-min_12:30-14:00_' . $day->format('d/m/Y'), + 'label' => 'Min. Volunteers', + 'attributes' => array( + 'value' => '0', + ), + 'options' => array( + 'input' => array( + 'filters' => array( + array('name' => 'StringTrim'), + ), + 'validators' => array( + array('name' => 'Int'), + ), + ), + ), + ) + ); + $this->add( array( 'type' => 'checkbox', 'name' => 'interval_18:00-19:00_' . $day->format('d/m/Y'), - 'label' => $day->format('l') . ' 18:00 - 19:00', + 'label' => '18:00 - 19:00', + 'required' => true, 'attributes' => array( 'id' => 'interval_18:00-19:00_' . $day->format('d/m/Y'), ), ) ); + + $this->add( + array( + 'type' => 'text', + 'name' => 'volunteers_18:00-19:00_' . $day->format('d/m/Y'), + 'label' => 'Volunteers', + 'attributes' => array( + 'value' => '0', + ), + 'options' => array( + 'input' => array( + 'filters' => array( + array('name' => 'StringTrim'), + ), + 'validators' => array( + array('name' => 'Int'), + ), + ), + ), + ) + ); + + $this->add( + array( + 'type' => 'text', + 'name' => 'volunteers-min_18:00-19:00_' . $day->format('d/m/Y'), + 'label' => 'Min. Volunteers', + 'attributes' => array( + 'value' => '0', + ), + 'options' => array( + 'input' => array( + 'filters' => array( + array('name' => 'StringTrim'), + ), + 'validators' => array( + array('name' => 'Int'), + ), + ), + ), + ) + ); } $this->addSubmit('Add', 'clock_add'); diff --git a/module/ShiftBundle/Form/Admin/Shift/Schedule.php b/module/ShiftBundle/Form/Admin/Shift/Schedule.php new file mode 100644 index 0000000000..3ba5c9f19d --- /dev/null +++ b/module/ShiftBundle/Form/Admin/Shift/Schedule.php @@ -0,0 +1,14 @@ + + */ +class Schedule extends \CommonBundle\Component\Form\Admin\Form +{ + protected $hydrator = 'ShiftBundle\Hydrator\Shift'; +} + diff --git a/module/ShiftBundle/Hydrator/Shift.php b/module/ShiftBundle/Hydrator/Shift.php index 7db8224aa9..28a769dc2a 100644 --- a/module/ShiftBundle/Hydrator/Shift.php +++ b/module/ShiftBundle/Hydrator/Shift.php @@ -70,9 +70,13 @@ protected function doHydrate(array $data, $object = null) ->setEndDate(self::loadDateTime($data['end_date'])); } - $manager = $this->getEntityManager() - ->getRepository('CommonBundle\Entity\User\Person\Academic') - ->findOneById($data['manager']['id']); + if ($data['manager']) { + $manager = $this->getEntityManager() + ->getRepository('CommonBundle\Entity\User\Person\Academic') + ->findOneById($data['manager']['id']); + } else { + $manager = $this->getPersonEntity(); + } $editRoles = array(); if (isset($data['edit_roles'])) {