public function consultarEmpleadosJSONAction() { $request = $this->getRequest(); $empleadoDao = new EmpleadoDao($this->getDoctrine()); $empleados = $empleadoDao->getEmpleados(); $numfilas = count($empleados); $emple = new Empleado(); $i = 0; foreach ($empleados as $emple) { $unidad = $emple->getUnidadOrganizativa(); if ($unidad == null) { $unidad = new UnidadOrganizativa(); } $rows[$i]['id'] = $emple->getIdEmpleado(); $rows[$i]['cell'] = array($emple->getIdEmpleado(), $emple->getPrimerNombre(), $emple->getSegundoNombre(), $emple->getPrimerApellido(), $emple->getSegundoApellido(), $emple->getDui(), $unidad->getNombreUnidad()); $i++; } $datos = json_encode($rows); $jsonresponse = '{ "page":"1", "total":"1", "records":"' . $numfilas . '", "rows":' . $datos . '}'; $response = new Response($jsonresponse); return $response; }
public function ingresarUnidadOrg($nombreUnidad, $direccion, $responsable, $telefono, $fax, $tipoUnidad, $unidadPadre, $departameto, $municipio, $descripcion) { $municipioDao = new MunicipioDao($this->doctrine); $muncipioObj = $municipioDao->getMunicipio($municipio); $informacionGeneral = new InformacionGeneral(); $informacionGeneral->setDireccion($direccion); $informacionGeneral->setTelefono($telefono); $informacionGeneral->setFax($fax); $unidadOrg = new UnidadOrganizativa(); $unidadOrg->setNombreUnidad($nombreUnidad); $unidadOrg->setTipoUnidad($tipoUnidad); if ($unidadPadre != 0) { $unidadParent = $this->repositorio->find($unidadPadre); $unidadOrg->setParent($unidadParent); } $unidadOrg->setIdMunicipio($municipio); $unidadOrg->setInformacionGeneral($informacionGeneral); $unidadOrg->setDescripcionUnidad($descripcion); $informacionGeneral->setUnidadOrganizativa($unidadOrg); $this->em->persist($unidadOrg); $this->em->persist($informacionGeneral); $this->em->flush(); $matrizMensajes = array('El proceso de almacenar Unidad Organizativa termino con exito', 'Unidad ' . $unidadOrg->getIdUnidadOrg()); return $matrizMensajes; }
public function consultarUnidadesOrgJSONSelectAction() { $unidadOrgDao = new UnidadOrganizativaDao($this->getDoctrine()); $unidadesOrg = $unidadOrgDao->getUnidadesOrg(); $numfilas = count($unidadesOrg); $select = "<select>"; $uni = new UnidadOrganizativa(); $i = 0; foreach ($unidadesOrg as $uni) { $infogeneral = $uni->getInformacionGeneral(); if ($infogeneral == null) { $infogeneral = new InformacionGeneral(); } $select = $select . "<option value=" . $uni->getIdUnidadOrg() . ">" . $uni->getNombreUnidad() . "</option>"; } $select = $select . "</select>"; $response = new Response($select); return $response; }