コード例 #1
0
 function grabardataAction()
 {
     try {
         $SesionUsuarioPlugin = $this->SesionUsuarioPlugin();
         $EntityManagerPlugin = $this->EntityManagerPlugin();
         $GrupoDispoCabBO = new GrupoDispoCabBO();
         $InventarioBO = new InventarioBO();
         $CalidadBO = new CalidadBO();
         $GrupoDispoCabBO->setEntityManager($EntityManagerPlugin->getEntityManager());
         $InventarioBO->setEntityManager($EntityManagerPlugin->getEntityManager());
         $CalidadBO->setEntityManager($EntityManagerPlugin->getEntityManager());
         $respuesta = $SesionUsuarioPlugin->isLoginAdmin();
         if ($respuesta == false) {
             return false;
         }
         $usuario_id = $SesionUsuarioPlugin->getUsuarioId();
         $body = $this->getRequest()->getContent();
         $json = json_decode($body, true);
         $accion = $json['accion'];
         $id = $json['id'];
         $GrupoDispoCabData = new GrupoDispoCabData();
         $GrupoDispoCabData->setId($id);
         $GrupoDispoCabData->setNombre($json['nombre']);
         $GrupoDispoCabData->setInventarioId($json['inventario_id']);
         $GrupoDispoCabData->setCalidadId($json['calidad_id']);
         $GrupoDispoCabData->setUsuarioIngId($usuario_id);
         $GrupoDispoCabData->setUsuarioModId($usuario_id);
         switch ($accion) {
             case 'I':
                 //Ingreso
                 $result = $GrupoDispoCabBO->registrarPorAccion('I', $GrupoDispoCabData);
                 $id = $result['id'];
                 break;
             case 'M':
                 //Modificar
                 $result = $GrupoDispoCabBO->registrarPorAccion('M', $GrupoDispoCabData);
                 $id = $result['id'];
                 break;
         }
         //end switch
         $row = $GrupoDispoCabBO->consultarCabecera($id, \Application\Constants\ResultType::MATRIZ);
         //Retorna la informacion resultante por JSON
         $response = new \stdClass();
         $response->respuesta_code = 'OK';
         $response->row = $row;
         $response->inventario_opciones = $InventarioBO->getCombo($row['inventario_id'], "<Seleccione>");
         $response->calidad_opciones = $CalidadBO->getComboCalidad($row['calidad_id'], "<Seleccione>");
         $response->grupo_opciones = $GrupoDispoCabBO->getComboGrupoDispo($id);
         $json = new JsonModel(get_object_vars($response));
         return $json;
         //false
     } catch (\Exception $e) {
         $excepcion_msg = utf8_encode($this->ExcepcionPlugin()->getMessageFormat($e));
         $response = $this->getResponse();
         $response->setStatusCode(500);
         $response->setContent($excepcion_msg);
         return $response;
     }
 }