consejo.php 4.95 KB
<?php

include_once 'sesiones/session_admin.php';

class Consejo extends Controller{

    function __construct()
    {
    parent::__construct();    
    }

    function render(){

        $consejs=$this->model->get();
        $this->view->consejs=$consejs;

        $this->view->render('consejo/index');
    }
    
    function Registrar(){
    
        $this->view->render('consejo/registrar');
    }


    function RegistrarConsejo(){

        $descripcion=$_POST['descripcion'];
        $fecha=$_POST['fecha'];

        $d=date("d-m-Y");

        if($fecha > $d)
    {
        $mensaje='<div  class="alert alert-danger icons-alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <i class="icofont icofont-close-line-circled"></i>
        </button>
        <p style="text-align:center;"><strong></strong> La fecha del Consejo no puede ser mayor que la vigente. Verifique la fecha.</p>
        </div>';
    
        $this->view->mensaje=$mensaje;
        $this->render();
        exit();

    }
    
        if($this->model->insert(['descripcion'=>$descripcion, 'fecha'=>$fecha])){

            $mensaje='<div class="alert alert-success icons-alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <i class="icofont icofont-close-line-circled"></i>
        </button>
        <p><strong>Exitoso!</strong>  <code style="color: green;"> Consejo Registrado</code> <strong>Correctamente</strong>.</p>
    </div>';
    
        }else{
    
            $mensaje='<div class="alert alert-danger icons-alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <i class="icofont icofont-close-line-circled"></i>
            </button>
            <p><strong>Error</strong> Al Intentar <code> Registrar el Consejo </code> Por Favor, Intentalo de Nuevo.</p>
        </div>';
    
        }
    
        $this->view->mensaje=$mensaje;
        $this->render();
    }


    function ViewEdit($param=null){

        $id_tipo_consejo=$param[0];
    
        $edicion=$this->model->getID($id_tipo_consejo);
        $this->view->edicion=$edicion;
    
     $this->view->render('consejo/ViewEdit');
     
    }
    
    public function EditarConsejo(){
    

        $id_tipo_consejo=$_POST['id_tipo_consejo'];
        $descripcion=$_POST['descripcion'];
        $fecha=$_POST['fecha'];

        $d=date("d-m-Y");

        if($fecha > $d)
        {
            $mensaje='<div  class="alert alert-danger icons-alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <i class="icofont icofont-close-line-circled"></i>
            </button>
            <p style="text-align:center;"><strong></strong> La fecha del Consejo no puede ser mayor que la vigente. Verifique la fecha.</p>
            </div>';
        
            $this->view->mensaje=$mensaje;
            $this->render();
            exit();
    
        }
    
        if($this->model->update(['descripcion'=>$descripcion, 'fecha'=>$fecha, 'id_tipo_consejo'=>$id_tipo_consejo])){

            $mensaje='<div class="alert alert-success icons-alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <i class="icofont icofont-close-line-circled"></i>
        </button>
        <p><strong>Exitoso!</strong>  <code style="color: green;"> Consejo Modificado</code> <strong>Correctamente</strong>.</p>
    </div>';
    
        }else{
    
            $mensaje='<div class="alert alert-danger icons-alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <i class="icofont icofont-close-line-circled"></i>
            </button>
            <p><strong>Error</strong> Al Intentar <code>Editar el Consejo </code> Por Favor, Intentalo de Nuevo.</p>
        </div>';
    
        }
        $this->view->mensaje=$mensaje;
        $this->render();
    }



    function eliminar($param = null){
     
        $id_tipo_consejo = $param[0];
    
        if($this->model->delete($id_tipo_consejo)){
         
            $mensaje='<div class="alert alert-success icons-alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <i class="icofont icofont-close-line-circled"></i>
            </button>
            <p><strong>Exitoso!</strong>  <code style="color: green;"> Se ha Eliminado el Consejo </code> <strong>Correctamente</strong>.</p>
        </div>';
          
        }else{
    
            $mensaje='<div class="alert alert-danger icons-alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <i class="icofont icofont-close-line-circled"></i>
            </button>
            <p><strong>Error</strong> Al Intentar <code>Eliminar el Consejo </code> Por Favor, Intentalo de Nuevo.</p>
        </div>';
        
        }
    
     $this->view->mensaje=$mensaje;
    $this->render();
    
      }

}

?>