protected function process()
 {
     $this->codejercicio = $this->empresa->codejercicio;
     $this->ejercicio = new ejercicio();
     $grupo0 = new grupo_epigrafes();
     $epi0 = new epigrafe();
     $this->super_epigrafes = array();
     /// ¿El usuario tiene permiso para eliminar en esta página?
     $this->allow_delete = $this->user->allow_delete_on(__CLASS__);
     if (isset($_POST['ngrupo'])) {
         $this->epigrafe = FALSE;
         $this->grupo = $grupo0->get_by_codigo($_GET['ngrupo'], $_POST['ejercicio']);
         if (!$this->grupo) {
             $this->grupo = new grupo_epigrafes();
             $this->grupo->codejercicio = $_POST['ejercicio'];
             $this->grupo->codgrupo = $_POST['ngrupo'];
             $this->grupo->descripcion = $_POST['descripcion'];
             if ($this->grupo->save()) {
                 header('Location: ' . $this->grupo->url());
             } else {
                 $this->new_error_msg('Error al guardar el grupo.');
                 $this->grupo = FALSE;
             }
         }
     } else {
         if (isset($_GET['grupo'])) {
             $this->epigrafe = FALSE;
             $this->grupo = $grupo0->get($_GET['grupo']);
             if ($this->grupo and isset($_POST['descripcion'])) {
                 $this->grupo->descripcion = $_POST['descripcion'];
                 if ($this->grupo->save()) {
                     $this->new_message('Grupo modificado correctamente.');
                 } else {
                     $this->new_error_msg('Error al modificar el grupo.');
                 }
             }
         } else {
             if (isset($_GET['deleteg'])) {
                 $grupo1 = $grupo0->get($_GET['deleteg']);
                 if ($grupo1) {
                     if ($grupo1->delete()) {
                         $this->new_message('Grupo eliminado correctamente.');
                     } else {
                         $this->new_error_msg('Error al eliminar el grupo.');
                     }
                 } else {
                     $this->new_error_msg('Grupo no encontrado.');
                 }
                 $this->grupo = FALSE;
                 $this->epigrafe = FALSE;
             } else {
                 if (isset($_POST['nepigrafe'])) {
                     $this->epigrafe = $epi0->get_by_codigo($_POST['nepigrafe'], $_POST['ejercicio']);
                     if (!$this->epigrafe) {
                         $this->epigrafe = new epigrafe();
                         $this->epigrafe->codejercicio = $_POST['ejercicio'];
                         $this->epigrafe->codepigrafe = $_POST['nepigrafe'];
                         if (isset($_POST['idpadre'])) {
                             $this->epigrafe->idpadre = $_POST['idpadre'];
                         } else {
                             $this->epigrafe->codgrupo = $_POST['codgrupo'];
                             $this->epigrafe->idgrupo = $_POST['idgrupo'];
                             $this->grupo = $grupo0->get($_POST['idgrupo']);
                         }
                         $this->epigrafe->descripcion = $_POST['descripcion'];
                         if ($this->epigrafe->save()) {
                             header('Location: ' . $this->epigrafe->url());
                         } else {
                             $this->new_error_msg('Error al guardar el epígrafe.');
                         }
                     }
                 } else {
                     if (isset($_GET['epi'])) {
                         $this->grupo = FALSE;
                         $this->epigrafe = $epi0->get($_GET['epi']);
                         if ($this->ejercicio and isset($_POST['descripcion'])) {
                             $this->epigrafe->descripcion = $_POST['descripcion'];
                             if ($this->epigrafe->save()) {
                                 $this->new_message('Epígrafe modificado correctamente.');
                             } else {
                                 $this->new_error_msg('Error al modificar el epígrafe.');
                             }
                         }
                     } else {
                         if (isset($_GET['deletee'])) {
                             $epi1 = $epi0->get($_GET['deletee']);
                             if ($epi1) {
                                 $this->grupo = $grupo0->get($epi1->idgrupo);
                                 if ($epi1->delete()) {
                                     $this->new_message('Epígrafe eliminado correctamente.');
                                 } else {
                                     $this->new_error_msg('Error al eliminar el epígrafe.');
                                 }
                             } else {
                                 $this->new_error_msg('Epígrafe no encontrado.');
                                 $this->grupo = FALSE;
                             }
                         } else {
                             if (isset($_POST['ncuenta'])) {
                                 $this->grupo = FALSE;
                                 $this->epigrafe = FALSE;
                                 $cuenta0 = new cuenta();
                                 $cuenta1 = $cuenta0->get_by_codigo($_POST['ncuenta'], $_POST['ejercicio']);
                                 if ($cuenta1) {
                                     header('Location: ' . $cuenta1->url());
                                 } else {
                                     $cuenta1 = new cuenta();
                                     $cuenta1->codcuenta = $_POST['ncuenta'];
                                     $cuenta1->codejercicio = $_POST['ejercicio'];
                                     $cuenta1->codepigrafe = $_POST['codepigrafe'];
                                     $cuenta1->descripcion = $_POST['descripcion'];
                                     $cuenta1->idepigrafe = $_POST['idepigrafe'];
                                     if ($cuenta1->save()) {
                                         header('Location: ' . $cuenta1->url());
                                     } else {
                                         $this->new_error_msg('Error al guardar la cuenta.');
                                     }
                                     $this->epigrafe = $epi0->get($_POST['idepigrafe']);
                                 }
                             } else {
                                 if (isset($_GET['deletec'])) {
                                     $this->grupo = FALSE;
                                     $this->epigrafe = FALSE;
                                     $cuenta0 = new cuenta();
                                     $cuenta1 = $cuenta0->get($_GET['deletec']);
                                     if ($cuenta1) {
                                         $this->epigrafe = $epi0->get($cuenta1->idepigrafe);
                                         if ($cuenta1->delete()) {
                                             $this->new_message('Cuenta eliminada correctamente.');
                                         } else {
                                             $this->new_error_msg('Error al eliminar la cuenta.');
                                         }
                                     } else {
                                         $this->new_error_msg('Cuenta no encontrada.');
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($this->grupo) {
         $this->ppage = $this->page->get($this->page->name);
         $this->page->title = 'Grupo: ' . $this->grupo->codgrupo;
         $this->resultados = $this->grupo->get_epigrafes();
     } else {
         if ($this->epigrafe) {
             /// configuramos la página previa
             $this->ppage = $this->page->get($this->page->name);
             if (!is_null($this->epigrafe->idgrupo)) {
                 $this->ppage->title = 'Grupo: ' . $this->epigrafe->codgrupo;
                 $this->ppage->extra_url = '&grupo=' . $this->epigrafe->idgrupo;
             } else {
                 if (!is_null($this->epigrafe->idpadre)) {
                     $this->ppage->title = 'Padre';
                     $this->ppage->extra_url = '&epi=' . $this->epigrafe->idpadre;
                 }
             }
             $this->page->title = 'Epigrafe: ' . $this->epigrafe->codepigrafe;
             $this->resultados = $this->epigrafe->get_cuentas();
         } else {
             if (isset($_POST['ejercicio'])) {
                 $this->codejercicio = $_POST['ejercicio'];
                 $this->grupo = FALSE;
                 $this->epigrafe = FALSE;
                 $this->resultados = $grupo0->all_from_ejercicio($this->codejercicio);
                 $this->super_epigrafes = $epi0->super_from_ejercicio($this->codejercicio);
             } else {
                 $this->grupo = FALSE;
                 $this->epigrafe = FALSE;
                 $this->resultados = $grupo0->all_from_ejercicio($this->empresa->codejercicio);
                 $this->super_epigrafes = $epi0->super_from_ejercicio($this->empresa->codejercicio);
             }
         }
     }
 }