/** * Lists all User entities. * * @Route("/list", name="user_list") * @Method("GET") */ public function indexAction(Request $request) { $em = $this->getDoctrine()->getManager(); $errorMessage = ""; $province = Commons::getArrayProvince('Todas las provincias'); $zona = Commons::getArrayZona('Todas las zonas'); $type = Commons::getArrayType('Todos los usuarios'); $s_name = $request->get('s_name', ''); $s_zona = $request->get('s_zona', ''); $s_type = $request->get('s_type', ''); $document_id = $request->get('document_id', ''); $s_province = $request->get('s_province', ''); $entities = $em->getRepository('AppBundle:User')->findByRoleAttendant($s_name, $s_zona, $s_type, $s_province, $document_id); if ($request->isXmlHttpRequest()) { // return json return new JsonResponse(array_map(function (User $user) { return $user->getId(); }, $entities)); } $paginator = $this->get('knp_paginator'); $pagination = $paginator->paginate($entities, $request->get('page', 1), 10); if (!$entities) { $errorMessage = 'No existen registros guardados'; } return $this->render('AppBundle:User:list.html.twig', ['entities' => $pagination, 'message' => $errorMessage, 'province' => $province, 'zona' => $zona, 'type' => $type, 's_name' => $s_name, 's_zona' => $s_zona, 's_type' => $s_type, 's_province' => $s_province, 'document_id' => $document_id]); }
/** * form Document entities. * */ public function formAction(Request $request, $form, $document, $label, $type) { $em = $this->getDoctrine()->getManager(); $user_repository = $em->getRepository('AppBundle:User'); $user = $user_repository->findAll(); //$user_repository->findUserNotDocument($document->getUsers()); $user_array_document = $user_repository->getArrayData($document->getUsers()); if ($request->isMethod('POST')) { $form->handleRequest($request); $to = $request->get('to', ''); $user_to = $user_repository->getUsersInId($to); $user_array_document = $user_repository->getArrayData($user_to); if ($form->isValid()) { $em->persist($document); $em->flush(); foreach ($document->getUsers() as $user_document) { $document->removeUser($user_document); $user_document->removeDocument($document); $em->persist($user_document); $em->persist($document); $em->flush(); } foreach ($user_to as $user) { $document->addUser($user); $user->addDocument($document); $em->persist($user); $em->persist($document); $em->flush(); } $this->get('session')->getFlashBag()->set('update_info', 'Se actualizo el registro'); return $this->redirect($this->generateUrl('doc_list')); } } return $this->render('AppBundle:Document:form.html.twig', ['form' => $form->createView(), 'provincias' => Commons::getArrayProvince('Todas las provincias'), 'zonas' => Commons::getArrayZona('Todas las zonas'), 'tipos' => Commons::getArrayType('Todos los usuarios'), 'label' => $label, 'type' => $type, 'users' => $user, 'user_array_document' => $user_array_document, 'document' => $document]); }
/** * @param OptionsResolverInterface $resolver */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('firstname', 'text', array('label' => 'Nombre', "mapped" => true, 'required' => true, 'attr' => array("class" => "celda3", "maxlength" => 32)))->add('lastname', 'text', array('label' => 'Apellido', "mapped" => true, 'attr' => array("class" => "celda3", "maxlength" => 32)))->add('company', 'text', array('label' => 'Empresa', "mapped" => true, 'attr' => array("class" => "celda3", "maxlength" => 32)))->add('address', 'text', array('label' => 'Domicilio', "mapped" => true, 'attr' => array("class" => "celda3", "maxlength" => 32)))->add('locality', 'text', array('label' => 'Localidad', "mapped" => true, 'attr' => array("class" => "celda3", "maxlength" => 32)))->add('province', 'choice', array('label' => 'Provincia', 'choices' => Commons::getArrayProvince(), "mapped" => true, 'attr' => array("class" => "celda3", "maxlength" => 32)))->add('zona', 'choice', array('label' => 'Zona', 'choices' => Commons::getArrayZona(), "mapped" => true, 'attr' => array("class" => "celda3", "maxlength" => 32)))->add('phone', 'text', array('label' => 'Teléfono', 'attr' => array("class" => "celda3 phoneNumber", "maxlength" => 32, "onkeypress" => "return isNumericInteger(event)")))->add('email', 'email', array('label' => 'E-mail', 'attr' => array("class" => "celda3 login-input wv-tooltip unique-field", "id" => "signupEmail")))->add('web', 'text', array('label' => 'Web', "mapped" => true, "required" => false, 'attr' => array("class" => "celda3 UrlType", "maxlength" => 32)))->add('types', 'choice', array('label' => 'Tipo', 'choices' => Commons::getArrayType(), "mapped" => true, 'attr' => array("class" => "celda3", "maxlength" => 32)))->add('activity', 'text', array('label' => 'Actividad', "mapped" => true, "required" => false, 'attr' => array("class" => "celda3", "maxlength" => 32, "autocomplete" => 'off'))); }