/**
  * @Route("/contract/step1/create",name="contract_notice_step1_create")
  * @Template()
  * @Security("has_role('ROLE_CONTRACTING')")
  */
 public function contractStep1CreateAction(Request $request)
 {
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $contract = new Contract();
     $contract->setReferenceNumber(uniqid());
     $contract->setContractingUser($user);
     $contract->setStatus("Draft");
     $form = $this->createForm(ContractStep1Type::class, $contract);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $data = $form->getData();
         $em = $this->getDoctrine()->getManager();
         $em->persist($data);
         $em->flush();
         //Audit
         $audit = new Audit();
         $audit->setUsername($user->getUsername());
         $audit->setName($user->getFirstname() . " " . $user->getLastname());
         $audit->setFunctionType("Contracting");
         $audit->setEventType("Create notice step 1");
         $audit->setDossier($data);
         $em->persist($audit);
         $em->flush();
         if ($form->get('save')->isClicked()) {
             return $this->redirectToRoute('contract_notice_step1_edit', array('id' => $contract->getId()), 301);
         } else {
             return $this->redirectToRoute('contract_notice_step2_edit', array('id' => $contract->getId()), 301);
         }
     }
     $engine = $this->container->get('templating');
     $content = $engine->render('AppBundle:Contracting:contract_notice_preliminary_question.html.twig', array('form' => $form->createView(), 'contract' => $contract));
     return $response = new Response($content);
 }
 public function __construct(\AppBundle\Entity\Contract $contract)
 {
     $this->id = $contract->getId();
 }