<?php

class RegistroIngresoActividadesControlador extends Controladores {
    


/*function mostrarRegistroIngresoActividades(){
        $registroingresoactividad = RegistroIngresoActividades::mostrarTodos();
        Vistas::mostrar("planeador", "registroIngresoActividades/mostrartodo",array('PlanesIngresos'=> $registroingresoactividad ));
        
}*/

    function mostrarRegistroIngresoActividades(){
        Vistas::mostrar("planeador", "registroIngresoActividades/mostrartodo", array());
    }
    
  
    function tablatodas(){
        $registroingresoactividad = RegistroIngresoActividades::mostrarTodos();
        Vistas::mostrar("planeador", "registroIngresoActividades/tbl-registroIngreso",array('PlanesIngresos'=> $registroingresoactividad));
    }

 /*function crearRegistroIngresoActividades(){
      
 
       $objPlanes=null;
       $objActividades=null;
       $objClasesIngresos=null;
       $objRegistroIngresoActividades=null;
       $clasesIngresos = ClasesIngresos::mostrarTodos();
       $actividades = Actividades::mostrarTodos();
       $planes = Planes::mostrarTodos();
       if(@$this->planIngresoID){
            $objRegistroIngresoActividades=RegistroIngresoActividades::getIdRegistroIngresoActividades($this->planIngresoID);
            
            Vistas::mostrar("planeador", "registroIngresoActividades/crear",array('Planes'=>$planes, 'ClasesIngresos'=>$clasesIngresos, 
            'PlanesActividades'=>$actividades, 'objRegistroIngresoActividades'=>$objRegistroIngresoActividades));
        }    else{
       
            Vistas::mostrar("planeador", "registroIngresoActividades/crear",array('Planes'=>$planes, 'ClasesIngresos'=>$clasesIngresos, 
            'PlanesActividades'=>$actividades, 'objRegistroIngresoActividades'=>$objRegistroIngresoActividades, 'objPlanes'=>$objPlanes,  
            'objActividades'=>$objActividades,'objClasesIngresos'=>$objClasesIngresos ));
        } 
    } */
    
    function crearRegistroIngresoActividades(){
        $planes = Planes::mostrarTodos();
        $clasesIngresos = ClasesIngresos::mostrarTodos();
        $actividades = Actividades::mostrarTodos();
        Vistas::mostrar("planeador", "registroIngresoActividades/crear",array("Planes"=>$planes, "ClasesIngresos"=>$clasesIngresos, "PlanesActividades"=>$actividades));
    } 
    
    function editarRegistroIngresoActividades(){
        $planes = Planes::mostrarTodos();
        $clasesIngresos = ClasesIngresos::mostrarTodos();
        $actividades = Actividades::todas();
        $objRegistroIngresoActividades=RegistroIngresoActividades::getIdRegistroIngresoActividades($this->planIngresoID);
        Vistas::mostrar(
            "planeador", 
            "registroIngresoActividades/crear",
            array('Planes'=>$planes, 
            'ClasesIngresos'=>$clasesIngresos, 
            'PlanesActividades'=>$actividades, 
            'objRegistroIngresoActividades'=>$objRegistroIngresoActividades));
    } 
    
    
    
     function registrar() {

        $respuesta=0; 
        
    if($this->planIngresoID!="") {
        
     $respuesta=RegistroIngresoActividades::actualizar($this->planIngresoID, $this->plan, $this->actividad, $this->claseIngreso, 
     $this->presupuesto, $this->proyectadoPublico, $this->proyectadoPrivado, $this->crecimientoPublico, $this->crecimientoPrivado,
     $this->recibidoPublico, $this->recibidoPrivado, $this->fechaProyectado, $this->usuarioProyectado, $this->fechaRecibido, $this->usuarioRecibido);
        
      $respuesta=1; 
           }
           
       
    else{
        $respuesta=RegistroIngresoActividades::guardar($this->plan, $this->actividad, $this->claseIngreso, $this->presupuesto,
        $this->proyectadoPublico, $this->proyectadoPrivado, $this->crecimientoPublico, $this->crecimientoPrivado, $this->recibidoPublico, 
        $this->recibidoPrivado, $this->fechaProyectado, $this->usuarioProyectado, $this->fechaRecibido, $this->usuarioRecibido );
        
      }
     


        if($respuesta>0){
            echo RespuestasSistema::exito("Registro guardado con éxito");
        }else if ($respuesta==NULL){
            echo RespuestasSistema::alerta("La operación se ejecutó con posibles alertas");
        }else{
            echo RespuestasSistema::fallo("El sistema colapsó");
        }
    
    }
    
       function getIdRegistroIngresoActividades(){
        RegistroIngresoActividades::getIdRegistroIngresoActividades($this->$idRegistroIngresoActividades);
        
    }

    function eliminar(){
    
        $respuesta=0;
        foreach ($this->checkb as $value) {
            /*Validar si La operación predefinida está atada a otro*/
            $respuesta=RegistroIngresoActividades::eliminar($value);
        }
     
     if($respuesta>'0'){
    echo RespuestasSistema::exito( "Operacion guardada con éxito");
     exit;
    }else if ($respuesta=='0'){
        echo RespuestasSistema::alerta( "La operación se ejecutó con posibles alertas");
        }else{
        echo RespuestasSistema::fallo("El sistema colapsó");
        
    }
       
    }
    
}   
 


