Esempio n. 1
0
 /**
  * Remove stops
  *
  * @param \JLM\ModelBundle\Entity\DoorStop $stops
  */
 public function removeStop(\JLM\ModelBundle\Entity\DoorStop $stops)
 {
     $stops->setDoor();
     $this->stops->removeElement($stops);
     return $this;
 }
 /**
  * Close an existing Fixing entity.
  *
  * @Template()
  * @Secure(roles="ROLE_USER")
  */
 public function closeupdateAction(Request $request, Fixing $entity)
 {
     $form = $this->createForm(new FixingCloseType(), $entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         // Mise à l'arrêt
         if ($entity->getDone()->getId() == 3) {
             $stop = $entity->getDoor()->getLastStop();
             if ($stop === null) {
                 $stop = new DoorStop();
                 $stop->setBegin(new \DateTime());
                 $stop->setState('Non traitée');
             }
             $stop->setReason($entity->getReport());
             $entity->getDoor()->addStop($stop);
             $em->persist($stop);
         }
         $entity->setClose(new \DateTime());
         $em->persist($entity);
         $em->flush();
         return $this->redirect($this->generateUrl('fixing_show', array('id' => $entity->getId())));
     }
     return array('entity' => $entity, 'form' => $form->createView());
 }
 /**
  * Stop door
  *
  * @Template("JLMDailyBundle:Door:show.html.twig")
  * @Secure(roles="ROLE_USER")
  */
 public function stopAction(Door $entity)
 {
     $em = $this->getDoctrine()->getManager();
     if ($entity->getLastStop() === null) {
         $stop = new DoorStop();
         $stop->setBegin(new \DateTime());
         $stop->setReason('À définir');
         $stop->setState('Non traitée');
         $entity->addStop($stop);
         $em->persist($stop);
         $em->flush();
     }
     return $this->showAction($entity);
 }