protected function process()
 {
     $this->show_fs_toolbar = FALSE;
     $this->familia = new familia();
     if (isset($_POST['ncodfamilia'])) {
         $fam = new familia();
         $fam->codfamilia = $_POST['ncodfamilia'];
         $fam->descripcion = $_POST['ndescripcion'];
         if ($fam->save()) {
             Header('location: ' . $fam->url());
         } else {
             $this->new_error_msg("¡Imposible guardar la familia!");
         }
     } else {
         if (isset($_GET['delete'])) {
             $fam = new familia();
             $fam->codfamilia = $_GET['delete'];
             if ($fam->delete()) {
                 $this->new_message("Familia " . $_GET['delete'] . " eliminada correctamente");
             } else {
                 $this->new_error_msg("¡Imposible eliminar la familia " . $_GET['delete'] . "!");
             }
         }
     }
     if ($this->query != '') {
         $this->resultados = $this->familia->search($this->query);
     } else {
         $this->resultados = $this->familia->all();
     }
 }
Example #2
0
 protected function process()
 {
     $this->familia = new familia();
     $this->madre = NULL;
     if (isset($_REQUEST['madre'])) {
         $this->madre = $_REQUEST['madre'];
     }
     if (isset($_POST['ncodfamilia'])) {
         $fam = $this->familia->get($_POST['ncodfamilia']);
         if ($fam) {
             $this->new_error_msg('La familia <a href="' . $fam->url() . '">' . $fam->codfamilia . '</a> ya existe.');
         } else {
             $fam = new familia();
             $fam->codfamilia = $_POST['ncodfamilia'];
             $fam->descripcion = $_POST['ndescripcion'];
             $fam->madre = $this->madre;
             if ($fam->save()) {
                 Header('location: ' . $fam->url());
             } else {
                 $this->new_error_msg("¡Imposible guardar la familia!");
             }
         }
     } else {
         if (isset($_GET['delete'])) {
             $fam = $this->familia->get($_GET['delete']);
             if ($fam) {
                 if ($fam->delete()) {
                     $this->new_message("Familia " . $_GET['delete'] . " eliminada correctamente");
                 } else {
                     $this->new_error_msg("¡Imposible eliminar la familia " . $_GET['delete'] . "!");
                 }
             } else {
                 $this->new_error_msg("Familia " . $_GET['delete'] . " no encontrada.");
             }
         }
     }
     if ($this->query != '') {
         $this->resultados = $this->familia->search($this->query);
     } else {
         $this->resultados = $this->familia->madres();
         $this->share_extensions();
     }
 }