<?php

include('../../path.php');

require_once(ROOT_CONTROLLER.'rol.php');

$Obj_rol = new rol();

require_once(ROOT_CHARACTER_FIX);

//require_once($context_rol.'bussines/fix_characters.php');

$Obj_fix_characters = new fix_characters();



$action=!empty($_REQUEST['action'])?$_REQUEST['action']:'';

$pagina=!empty($_REQUEST['pagina'])?$_REQUEST['pagina']:'';

$_ScrollTo=!empty($_REQUEST['_ScrollTo'])?$_REQUEST['_ScrollTo']:'';





if (!empty($_POST))

{

    $Id_Rol=!empty($_REQUEST['Id_Rol'])?$_REQUEST['Id_Rol']:'';

   $Titulo_Rol=!empty($_REQUEST['Titulo_Rol'])?$_REQUEST['Titulo_Rol']:'';

   $Fecha_Registro=!empty($_REQUEST['Fecha_Registro'])?$_REQUEST['Fecha_Registro']:'';

   $Fecha_Modifico=!empty($_REQUEST['Fecha_Modifico'])?$_REQUEST['Fecha_Modifico']:'';

   

    $Field=!empty($_REQUEST['Field'])?$_REQUEST['Field']:''; 

    $Field=$Obj_fix_characters->fix($Field);

    $Value=!empty($_REQUEST['Value'])?$_REQUEST['Value']:''; 

    $Value=$Obj_fix_characters->fix($Value);

    $Value_Hidden=!empty($_REQUEST['Value_Hidden'])?$_REQUEST['Value_Hidden']:''; 

    $Value_Hidden=$Obj_fix_characters->fix($Value_Hidden);

    $Type=!empty($_REQUEST['Type'])?$_REQUEST['Type']:''; 

    $Type=$Obj_fix_characters->fix($Type);



}    



switch ($action) {

    case 'campos_front':

        try{

            $Obj_usuario->update_field_front_rol($Field,$Value,$Id_Rol);

        }catch (Exception $e) {

            echo 'Excepcion capturada: ',  $e->getMessage(), "\n";

        }

        break;



    case 'campos':

        try{

            $Obj_rol->update_field_rol($Field,$Value,$Id_Rol);

            //$locations="Location: ./?pagina=$pagina&_Id_Registro=$Id_Rol&_ScrollTo=$_ScrollTo";

            //header($locations);

            }   

        catch (Exception $e) {

            echo 'Excepcion capturada: ',  $e->getMessage(), "\n";

        }

        break;



    

    case 'editar':



        try{

             $Obj_rol->update_rol($Id_Rol, $Titulo_Rol, $Fecha_Registro, $Fecha_Modifico);

              $locations="Location: ../view/?pagina=$pagina&_Id_Registro=$Id_Rol&_ScrollTo=$_ScrollTo";

            header($locations);

            }   

        catch (Exception $e) {

            echo 'Excepcion capturada: ',  $e->getMessage(), "\n";

        }

        break;



        case 'registrar':



        try{



         $idtupla=$Obj_rol->insert_rol($Titulo_Rol, $Fecha_Registro, $Fecha_Modifico);

            $locations="Location: ../view/?pagina=1&_Id_Registro=$Id_Rol&_ScrollTo=$_ScrollTo";

            header($locations);        

           }    

        catch (Exception $e) {

            echo 'Excepcion capturada: ',  $e->getMessage(), "\n";

        }   



        break;

        case 'duplicar':



        try{



         $idtupla=$Obj_rol->insert_rol($Titulo_Rol, $Fecha_Registro, $Fecha_Modifico);

            $locations="Location: ../view/?pagina=1&_Id_Registro=$Id_Rol&_ScrollTo=$_ScrollTo";

            header($locations);        

           }    

        catch (Exception $e) {

            echo 'Excepcion capturada: ',  $e->getMessage(), "\n";

        }   



        break;

    

        case 'eliminar':           

                try{

              $Obj_rol->delete_rol($Id_Rol);

                 $locations ="Location: ../view";

                 header($locations);

                }

        

                catch (Exception $e) {

                    echo 'Excepcion capturada: ',  $e->getMessage(), "\n";

                }   



        break;



    default:

        

        break;

}

?>

