diff --git a/app/Resources/views/admin/mail/edit.html.twig b/app/Resources/views/admin/mail/edit.html.twig index e69de29bb..8b1378917 100644 --- a/app/Resources/views/admin/mail/edit.html.twig +++ b/app/Resources/views/admin/mail/edit.html.twig @@ -0,0 +1 @@ + diff --git a/src/AppBundle/Controller/BookingController.php b/src/AppBundle/Controller/BookingController.php index dd53e51bd..9b1448c88 100644 --- a/src/AppBundle/Controller/BookingController.php +++ b/src/AppBundle/Controller/BookingController.php @@ -651,4 +651,35 @@ private function createShiftValidateInvalidateForm(Shift $shift) ->setMethod('POST') ->getForm(); } + + /** + * Creates a form to book a shift entity. + * + * @param Shift $shift The shift entity + * + * @return \Symfony\Component\Form\Form The form + */ + private function createBookForm(Shift $shift) + { + $form = $this->get('form.factory')->createNamedBuilder('shift_book_forms_' . $shift->getId()) + ->setAction($this->generateUrl('admin_shift_book', array('id' => $shift->getId()))) + ->add('shifter', AutocompleteBeneficiaryType::class, array('label'=>'Numéro d\'adhérent ou nom du membre', 'required'=>true)); + + if ($this->useFlyAndFixed) { + $form = $form->add('fixe', RadioChoiceType::class, [ + 'choices' => [ + 'Volant' => 0, + 'Fixe' => 1, + ], + 'data' => 0 + ]); + } else { + $form = $form->add('fixe', HiddenType::class, [ + 'data' => 0 + ]); + } + + return $form->getForm(); + } + } diff --git a/src/AppBundle/Controller/PeriodController.php b/src/AppBundle/Controller/PeriodController.php index 9540a48ea..fda31bfcd 100644 --- a/src/AppBundle/Controller/PeriodController.php +++ b/src/AppBundle/Controller/PeriodController.php @@ -365,8 +365,6 @@ public function bookPeriodPositionAction(Request $request, Period $period, Perio { $session = new Session(); - $form = $this->createPeriodPositionBookForm($period, $position); - $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -539,71 +537,4 @@ public function generateShiftsForDateAction(Request $request, KernelInterface $k )); } - /** - * Creates a form to delete a period entity. - * - * @param Period $period The period entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createPeriodDeleteForm(Period $period) - { - return $this->createFormBuilder() - ->setAction($this->generateUrl('period_delete', array('id' => $period->getId()))) - ->setMethod('DELETE') - ->getForm(); - } - - /** - * Creates a form to add a period position entity. - * - * @param Period $period The period entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createPeriodPositionAddForm(Period $period) - { - return $this->createForm( - PeriodPositionType::class, - new PeriodPosition(), - array( - 'action' => $this->generateUrl( - 'period_position_new', - array('id' => $period->getId()) - ) - )); - } - - /** - * Creates a form to book a period position entity. - * - * @param Period $period The period entity - * @param PeriodPosition $position The period position entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createPeriodPositionBookForm(Period $period, PeriodPosition $position) - { - return $this->get('form.factory')->createNamedBuilder('positions_book_forms_' . $position->getId()) - ->setAction($this->generateUrl('period_position_book', array('id' => $period->getId(), 'position' => $position->getId()))) - ->setMethod('POST') - ->add('shifter', AutocompleteBeneficiaryType::class, array('label' => 'Numéro d\'adhérent ou nom du membre', 'required' => true)) - ->getForm(); - } - - /** - * Creates a form to delete a period position entity. - * - * @param Period $period The period entity - * @param PeriodPosition $position The period position entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createPeriodPositionDeleteForm(Period $period, PeriodPosition $position) - { - return $this->get('form.factory')->createNamedBuilder('positions_delete_forms_' . $position->getId()) - ->setAction($this->generateUrl('period_position_delete', array('id' => $period->getId(), 'position' => $position->getId()))) - ->setMethod('DELETE') - ->getForm(); - } } diff --git a/src/AppBundle/Entity/Beneficiary.php b/src/AppBundle/Entity/Beneficiary.php index 4409d6424..8e2d48660 100644 --- a/src/AppBundle/Entity/Beneficiary.php +++ b/src/AppBundle/Entity/Beneficiary.php @@ -242,7 +242,7 @@ public function getDisplayName(): string */ public function getDisplayNameWithMemberNumber(): string { - return '#' . $this->getMemberNumber() . ' ' . $this->getDisplayName(); + return '#' . $this->getMemberNumber() . ' ' . $this->getFirstname() . ' ' . $this->getLastname(); } public function getPublicDisplayName(): string diff --git a/src/AppBundle/Repository/BeneficiaryRepository.php b/src/AppBundle/Repository/BeneficiaryRepository.php index e7a326013..4b11c6d9a 100644 --- a/src/AppBundle/Repository/BeneficiaryRepository.php +++ b/src/AppBundle/Repository/BeneficiaryRepository.php @@ -86,4 +86,24 @@ public function findCoShifters($shift) ->getResult(); } + + public function findCoShifters($shift) + { + $qb = $this->createQueryBuilder('b') + ->leftJoin('b.shifts', 's') + ->where('s.start = :start') + ->andWhere('s.end = :end') + ->andWhere('s.job = :job') + ->andWhere('s.id != :id') + ->andWhere('s.shifter IS NOT NULL') + ->setParameter('start', $shift->getStart()) + ->setParameter('end', $shift->getEnd()) + ->setParameter('job', $shift->getJob()) + ->setParameter('id', $shift->getId()); + + return $qb + ->getQuery() + ->getResult(); + + } }