/** * Cancel Bill action * * @Secure(roles="ROLE_USER") */ public function cancelbillAction(Intervention $entity) { $em = $this->getDoctrine()->getManager(); if ($entity->getMustBeBilled()) { if ($entity->getBill() !== null) { // annuler la facture existante $bill = $entity->getBill(); $bill->setIntervention(); $bill->setState(-1); $entity->setBill(); $em->persist($bill); } elseif ($entity->getExternalBill() !== null) { $entity->setExternalBill(); } } $entity->setMustBeBilled(null); $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl('intervention_redirect', array('id' => $entity->getId(), 'act' => 'show'))); }