function cod_alum(){
    var cod=get('al_id1');
    
    if(cod==''){
        exit('');
    }
    
    var parametros = {"accion":'info_estudiante',
                          "codigo" :cod
                           };
        $.ajax({
                data:  parametros,
                url:"app/model/acc_notas_promovidos.php",
                type:  'post',
                success:function (response){
                   
                    if(response=='no'){
                        alert('Alumno no Encontrado');
                        document.getElementById('al_id1').value='';
                        document.getElementById('al_id2').value='';
                        
                    }else{
                        
                        var arr=response.split(";");
                        
                        if(arr[0]=='pro'){
                            
                            document.getElementById('g_id1').value=arr[1];
                            document.getElementById('g_id2').value=arr[2];
                            
                            document.getElementById('c_id1').value=arr[3];
                            document.getElementById('c_id2').value=arr[4];
                            
                            document.getElementById('s_id1').value=arr[5];
                            document.getElementById('s_id2').value=arr[6];                            
                            
                            document.getElementById('j_id1').value=arr[7];
                            document.getElementById('j_id2').value=arr[8];
                            
                            document.getElementById('al_id2').value=arr[9];
                            
                            
                            buscar_info();
                        }else{
                            Limpiar_info();
                            //alert('DATOS ACTUALES \n\nGrado : '+arr[1]+'  '+arr[2]+'      Curso : '+arr[3]+'  '+arr[4]+'\nSede : '+arr[5]+'  '+arr[6]+'      Jornada : '+arr[7]+'  '+arr[8]);
                            document.getElementById('al_id1').value=cod;
                            
                            document.getElementById('g_id1').value=arr[1];
                            document.getElementById('g_id2').value=arr[2];
                            
                            document.getElementById('c_id1').value=arr[3];
                            document.getElementById('c_id2').value=arr[4];
                            
                            document.getElementById('s_id1').value=arr[5];
                            document.getElementById('s_id2').value=arr[6];                            
                            
                            document.getElementById('j_id1').value=arr[7];
                            document.getElementById('j_id2').value=arr[8];
                            
                            document.getElementById('al_id2').value=arr[9];
                            buscar_info();
                        }
                        
//                        document.getElementById('al_id2').value=response;
                    }
                        
                }
        });
}

//--------------------------------------------
function retornar(){
    location.href="../menu.php";
}

//----------------------------------------------------
function buscar_info(){
    
var v1=get('al_id1');
var v2=get('p_id1');
var v3=get('s_id1');
var v4=get('g_id1');
var v5=get('c_id1');


//alert(v1+ " - "+v2+ " - "+v3+ " - "+v4+ " - "+v5);

if (v1=="") {
    alert("Digite C&oacute;digo");
    exit();
}
if (v2=="") {
    alert("Digite Periodo");
    exit();
}

if (v3=="") {
    alert("Digite Sede");
    exit();
}
if (v4=="") {
    alert("Digite Grado");
    exit();
}

if (v4=="") {
    alert("Digite Curso");
    exit();
}

var parametros = {"accion":'buscar_notas',
                          "codigo" :v1,
                          "periodo" :v2,
                          "sede" :v3,
                          "grado" :v4,
                          "curso" :v5
                           };
        $.ajax({
                data:  parametros,
                url:"app/model/acc_notas_promovidos.php",
                type:  'post',
                success:function (response){
                        document.getElementById('info_alum').innerHTML=response;
                }
        });
}


//--------------------------------------------
function limpiar_inser(){
    document.getElementById('insertar').innerHTML='';
}


//-----------------------------------------------------
function get(id){
    return document.getElementById(id).value;
}

function Limpiar_info(){
    
    document.getElementById('al_id1').value="";    
    document.getElementById('al_id2').value="";    
    
    document.getElementById('p_id1').value="1";    
    document.getElementById('p_id2').value="PRIMERO";    
    
    document.getElementById('s_id1').value="";    
    document.getElementById('s_id2').value="";
    
    document.getElementById('g_id1').value="";    
    document.getElementById('g_id2').value="";
    
    document.getElementById('c_id1').value="";    
    document.getElementById('c_id2').value="";    
    
    document.getElementById('j_id1').value="";    
    document.getElementById('j_id2').value="";    
    
    document.getElementById('info_alum').innerHTML='';   
    limpiar_inser();
}

//------------------------------------------
function Editar(codigo){
    
    var parametros = {"accion":'editar',"codigo" :codigo};
        $.ajax({
                data:  parametros,
                url:"app/model/acc_notas_promovidos.php",
                type:  'post',
                success: function(response){   
                    
                        document.getElementById('insertar').innerHTML=response;
   
                }
        });
}

function editar_regnew(asig,grado,curso){
    
    var parametros = {"accion":'editar_new',"asig" :asig,"grado":grado,"cruso":curso};
        $.ajax({
                data:  parametros,
                url:"app/model/acc_notas_promovidos.php",
                type:  'post',
                success: function(response){   
                    
                        document.getElementById('insertar').innerHTML=response;
   
                }
        });
}

function Guardar(){

var cod=get('al_id1');
var per=get('p_id1');
var sede=get('s_id1');
var grado=get('g_id1');
var curso=get('c_id1');
var dsem=get('dsp');

var v1=get('asig_id1');
var v2=get('int');
var v3=get('nota');



if (v1=="") {
    alert("Digite Asignatura");
    return 0;
}


var parametros = {"accion":'guardar_info',
                          "cod":cod,
                          "dsem":dsem,
                          "per":per,
                          "sede":sede,
                          "grado":grado,
                          "curso":curso,  
                          "asignatura" :v1,
                          "i_h" :v2,
                          "nota" :v3
                           };
        $.ajax({
                data:  parametros,
                url:"app/model/acc_notas_promovidos.php",
                type:  'post',
                success:function (response){                       
                        
                        //document.getElementById('insertar').innerHTML=response;
                        alert(response);
                        limpiar_inser();
                        buscar_info();
                        
                }
        });


}


function Actualizar(id){

var v1=get('asig_id1');
var v2=get('int');
var v3=get('nota');



if (v1=="") {
    alert("Digite Asignatura");
    return 0;
}


var parametros = {"accion":'actualizar_info',
                          "codigo":id,  
                          "asignatura" :v1,
                          "i_h" :v2,
                          "nota" :v3
                           };
        $.ajax({
                data:  parametros,
                url:"app/model/acc_notas_promovidos.php",
                type:  'post',
                success:function (response){                       
                        
                        document.getElementById('insertar').innerHTML='';
                        alert(response);
                        buscar_info();
                        
                }
        });

}

function nota(){
    
        var nota=get('nota');
        
        if(nota==''){
            exit();
        }
    
       var parametros = {"accion":'nota',"nota":nota};
        $.ajax({
                data:  parametros,
                url:"app/model/acc_notas_promovidos.php",
                type:  'post',
                success:function (response){
                        document.getElementById('dsp').value=response; 
                      
                }
        });
}
//------------------------------------------
function Eliminar(codigo){

   
   var parametros = {"accion":'borrar',"codigo" :codigo};
        $.ajax({
                data:  parametros,
                url:"app/model/acc_notas_promovidos.php",
                type:  'post',
                success:function (response){
                        alert(response);                        
                        buscar_info();
                      
                }
        });
}


//-----------------------------------
function parametro( name ){
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp ( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results == null )
		return "";
	else
		return results[1];
}

