query->get('client'); $psn = $request->query->get('psn'); $preSale = $request->query->get('preSale'); $preSales = $errors = array(); $result = false; if(!is_null($client) && !is_null($psn)) { $em = $this->get("doctrine.orm.entity_manager"); $preSales = $em->getRepository(PreSale::class)->findBy(array('clientId' => $client)); $onu = $em->getRepository(ONU::class)->findOneBy(array('ponSerialNumber' => $psn)); if(empty($preSales)) $errors[] = "We don't register a pending installation to this client."; if(is_null($onu)) $errors[] = "ONU doesn't exist."; if(!is_null($preSale) && !is_null($onu)) { $sale = $em->getRepository(PreSale::class)->findOneById($preSale); if($sale) { $this->updateOnu($sale->getClientId(), $sale->getProfile(), $onu, $sale->getAddress()); $onu = $em->getRepository(ONU::class)->findOneBy(array('ponSerialNumber' => $psn)); if($onu->getClientId() == $sale->getClientId() && $onu->getProfile() == $sale->getProfile()) { $result = true; $em->remove($sale); $em->flush(); } } } } return $this->render('FTTHBundle:Portal:index.html.twig', array( 'result' => $result, 'errors' => $errors, 'preSales' => $preSales, 'client' => $client, 'psn' => $psn )); } private function updateOnu($clientId, $profile, $onu, $address) { $onu->setClientId($clientId); $onu->setProfile($profile); $em = $this->get("doctrine.orm.entity_manager"); $em->persist($onu); $em->flush(); } }