/** * @Route("/clientes/add-report/{idCliente}", name="profesional_clientes_add_report") * @Template() */ public function addreportAction($idCliente) { $em = $this->getDoctrine()->getManager(); $client = $em->getRepository('UserClientBundle:Client')->find($idCliente); $report = new Report(); $report->setClient($client); $form = $this->createForm(new ReportType(), $report); $request = $this->getRequest(); if ($request->getMethod() == 'POST') { $form->bind($request); if ($form->isValid()) { $report->setCreatedAt(new \DateTime()); $client->addReport($report); $em->persist($report); $em->persist($client); $em->flush(); return $this->redirect($this->generateUrl('profesional_clientes_show', array('idCliente' => $idCliente))); } } return array('form' => $form->createView(), 'cliente' => $client); }
/** * @Route("/retrieve-client-consulta", name="profesional_retrieve_chunk_user") * @Template() */ public function chunkInfoUserConsultaAction() { if ($this->getRequest()->getMethod() != 'POST') { throw new \Exception('Hack attemp :('); } $me = $this->get('security.context')->getToken()->getUser(); $em = $this->getDoctrine()->getManager(); $id = $this->getRequest()->get('idUser'); $user = $em->getRepository('CoreUserBundle:User')->find($id); $report = new Report(); $report->setCreatedAt(new \DateTime()); $report->setClient($user->getClient()); $report->setProfessional($me->getProfessional()); $form = $this->createForm(new ReportType(), $report); return array('entity' => $user->getClient(), 'form' => $form->createView()); }