Beispiel #1
0
 public function actionEliminar()
 {
     $msg = null;
     $id;
     if (!isset($_REQUEST['confirmar']) && isset($_REQUEST['id'])) {
         $id = $_REQUEST['id'];
         $tabla = Evento::find()->where(['id_categoria' => $id]);
         if ($tabla->count() != 0) {
             $msg = "existen eventos registrados con esta categoria";
         }
         $tabla = Deportista_cat::find()->where(['id_categoria' => $id]);
         if ($tabla->count() != 0) {
             $msg .= "<br>" . "existen Deportistas registrados con esta categoria";
         }
         $tabla = Comision::find()->where(['id_categoria' => $id]);
         if ($tabla->count() != 0) {
             $msg .= "<br>" . "existen Comisiones registrados con esta categoria";
         }
         if ($msg != null) {
             return $this->render("confirmar", ['msg' => $msg, 'id' => $id]);
         } else {
             if (Categoria::deleteAll($id)) {
                 $msg = "Categoria eliminado con exito";
             } else {
                 $msg = "ocurrio un error";
             }
         }
     } else {
         if (isset($_REQUEST['confirmar'])) {
             if (Categoria::deleteAll($_REQUEST['id'])) {
                 $msg = "Categoria eliminado con exito";
             } else {
                 $msg = "ocurrio un error";
             }
         }
     }
     return $this->render("eliminar", ['msg' => $msg]);
 }