Exemplo n.º 1
0
 /**
  * Create new vial (of a stock)
  *
  * @Route("/new/{id}", defaults={"id" = null})
  * @Template()
  *
  * @param  mixed                                      $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createAction($id = null)
 {
     $request = $this->getRequest();
     if ($request->getMethod() != 'POST') {
         $class = $this->getEntityClass();
         $vial = new $class();
         if (null !== $id) {
             $stock = $this->getStockEntity($id);
             $vial->setStock($stock);
         }
         $data = array('vial' => $vial, 'number' => 1);
         $form = $this->createForm($this->getCreateForm(), $data);
         return array('form' => $form->createView());
     } else {
         return parent::createAction();
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function handleBatchAction($data)
 {
     $action = $data['action'];
     $vials = new ArrayCollection($data['items']);
     $response = $this->getDefaultBatchResponse();
     switch ($action) {
         case 'marksterile':
             $this->markSterile($vials);
             $response = $this->getBackBatchResponse();
             break;
         case 'marksuccessful':
             $this->markSuccessful($vials);
             $response = $this->getBackBatchResponse();
             break;
         case 'markfailed':
             $this->markFailed($vials);
             $response = $this->getBackBatchResponse();
             break;
         default:
             return parent::handleBatchAction($data);
     }
     return $response;
 }