
// // JavaScript Document// JavaScript Document
//NUMERO DE REGISTRO POR PAGINA EN PAGINACION DE LISTA DE PROVEEDORES
var registroxPagina=20;
var validaCedula=false;
var totCajas=0;
var prueba='';
var validarGuardado=true;
var lisInvitado = new Array();
var validaRazon=false;
function listaInvitadosExRuc (result,resp){
    $('cargando').innerHTML = '';
    if(result != "")
    {
        num=1;
        num1=1;
        validarGuardado = true;
        //  res=dibujarCabeceraInvitado();
        //  res1=dibujarCabeceraCon();
        result.each(function(invitacion){
            // invitacion.pro.i.each(function(deta){
            //         res+=dibujarCuerpo(num,deta.cedula,deta.resolucion,deta.motivo,deta.fecha_inicio,deta.fecha_fin,deta.NombreComercial,deta.reportado,deta.estado,deta.secuencial,deta.casoCerrado);
            //       num++;
            //  });

            invitacion.pro.j.each(function(deta){
                if (deta.estado1==1)
                    estado1='Incumplido';
                else
                    estado1='Cumplido';
                res1+=dibujarCuerpoCon(num1,deta.cedula1,deta.NombreComercial1,deta.reportado1,deta.fecha_inicio1,estado1,deta.secuencial,deta.casoCerrado);
                num1++;
            });
        });
        res+='</tr></table></form>';
        res1+='</tr></table></form>';
        $('divListaInv').innerHTML = res;
        $('divListaContra').innerHTML = res1;
    }

    else alert ("NO SE ENCONTRARON PROVEEDORES CON ESTE CRITERIO DE BUSQUEDA");
	
    $('ruc').value = '';
    $('ruc').focus();
}
///////////funcion para cambiar la caja de texto de ruc o razon social/////
function cajatextoCambiar(radio){
    if(radio=='porRUC')
    {
        $("ruc").style.display = 'block';
        $("txtRazonSocial").style.display = 'none';
    }
    else {
        $("ruc").style.display = 'none';
        $("txtRazonSocial").style.display = 'block';
    }
}
////////////////////////////////////////
///////////////////////////////////////////////
//Funci?n: dibujarCabeceraInvitados
//Esta funci?n dibuja la cabecera de la tabla
///////////////////////////////////////////////
function dibujarCabeceraInvitado()
{
    var html='<form id="formPaginas" name="formPaginas"><table width="100%" ><tr class="tituloFondoClaro">';
    html+='<td align="center" width="5%">Num</td>';
    html+='<td align="center" width="10%">Cedula</td>';
    html+=' <td align="center" width="15%">Resoluci&oacute;n</td>';
    html+=' <td align="center" width="25%">Motivo</td>';
    html+=' <td align="center" width="20%">Fecha Ingreso</td>';
    html+=' <td align="center" width="20%">Fecha de Salida</td>';
    html+='<td align="center"  width="20%">Empresa</td>';
    html+='<td align="center"  width="20%">Reportó</td>';
    html+='<td align="center" >Estado</td>';
    html+='</tr>';
    return html;
} //Fin dibujarCabeceraInvitados

function dibujarCabeceraCon()
{
    var html='<form id="formPaginas" name="formPaginas"><table width="100%" ><tr class="tituloFondoClaro">';
    html+='<td align="center">Num</td>';
    html+='<td align="center">Cedula</td>';
    html+='<td align="center">Empresa</td>';
    html+='<td align="center">Reportado</td>';
    html+='<td align="center">Fecha</td>';
    html+='<td align="center">Estado</td>';
    //html+='<td align="center" >cedula</td>';
    html+='</tr>';
    return html;
} //Fin dibujarCabeceraInvitados

function dibujarCuerpo(num,cedula,resolucion,motivo,fecha_inicio,fecha_fin,NombreComercial,reportado,estado)
{
    //alert(casoCerrado)
    //alert (num+cedula+NombreComercial+resolucion+motivo+fecha_inicio+fecha_fin+reportado);
    html='<tr>';
    html+='<td class="textoAzul12" align="center" >'+num+'</td>';
    html+='<td class="textoAzul12" align="center" >'+cedula+'</td>';
    html+='<td class="textoAzul12">'+resolucion+'</td>';
    html+='<td class="textoAzul12">'+motivo+'</td>';
    fecha_inicio=fecha_inicio.substr(0,10);
    html+='<td class="textoAzul12" align="center">'+fecha_inicio+'</td>';
    if (fecha_fin)
        fecha_fin=fecha_fin.substr(0,10);
    html+='<td class="textoAzul12" align="center">'+fecha_fin+'</td>';
    html+='<td class="textoAzul12">'+NombreComercial+'</td>';
    if (reportado==null)
        reportado='(vacio)';
    html+='<td class="textoAzul12">'+reportado+'</td>';
    if (estado==null)
        estado='(vacio)';
    html+='<td class="textoAzul12">'+estado+'</td>';
    html+='</tr>';
    return html;
} //Fin dibujarCabeceraInvitados

function dibujarCuerpoCon(num1,cedula1,NombreComercial1,reportado1,fecha1,estado1)
{
    //alert (num+cedula+NombreComercial+resolucion+motivo+fecha_inicio+fecha_fin+reportado);
    html='<tr>';
    html+='<td class="textoAzul12" align="center" >'+num1+'</td>';
    html+='<td class="textoAzul12" align="center" >'+cedula1+'</td>';
    html+='<td class="textoAzul12" align="center">'+NombreComercial1+'</td>';
    html+='<td class="textoAzul12" align="center">'+reportado1+'</td>';
    html+='<td class="textoAzul12" align="center">'+fecha1+'</td>';
    html+='<td class="textoAzul12" align="center">'+estado1+'</td>';
    html+='</tr>';
    return html;
} //Fin dibujarCabeceraInvitados
//funcion ajax para buscar proveedor por ruc
function buscarProveedor()
{
    var ruc1=0;
    var i=0;
    for(i=0; i <document.formRadio.porRuc.length; i++)
    {
        if(document.formRadio.porRuc[i].checked)
        {
            if(document.formRadio.porRuc[i].value=='porRUC')
            {
                var ruc=$F("ruc");
                cedula = ruc;
                if(cedula != "")
                {
                    var data ="&ruc="+ruc;
                    var clazz = "ProveedorIncumplido";
                    var action = "ProveedoresIncumplidosxRuc";
                    //asignarImagenCargando ('cargando');
                    //ajax_call ( data, clazz, action, listaInvitadosExRuc );
                    ajax_call_updater ('divListaInv', data, clazz, action, callbackSenal);
                }
                else alert('Tiene que ingresar el ruc para realizar la busqueda');
            }
            else if(document.formRadio.porRuc[i].value=='porRazon')
            {
                if (validarCampoAlert($("txtRazonSocial"),true,"soloVacio","Razon Social"))
                {
                    var razonSocial=$F("txtRazonSocial")
                    var data ="razonSocial="+razonSocial;
                    var clazz = "ProveedorIncumplido";
                    var action = "ProveedoresIncumplidosxRazon";
                    // asignarImagenCargando ('cargando');
                    //  ajax_call ( data, clazz, action, listaInvitadosExRuc );
                    ajax_call_updater ('divListaInv', data, clazz, action, callbackSenal);
                }//fin de if q valida q el campo razon social no este vacio
            }//fin del if q valida cual radio button ha sido marcado
        }//fin de if q verifica los q han sido checked
    }//fin de for
}
//funcion ajax q recibe la respuesta de tcom%invitacion

function buscarProveedorReporte()
{
    var ruc1=0;
    var i=0;
    for(i=0; i <document.formRadio.porRuc.length; i++)
    {
        if(document.formRadio.porRuc[i].checked)
        {
            if(document.formRadio.porRuc[i].value=='porRUC')
            {
                var ruc=$F("ruc");
                cedula = ruc;
                if(cedula != "")
                {
                    var data ="&ruc="+ruc;
                    var clazz = "ProveedorIncumplido";
                    var action = "ReporteIncumplidosxRuc";
                    ajax_call_updater ('divListaInv', data, clazz, action, callbackSenal);
                }
                else alert('Tiene que ingresar el ruc para realizar la busqueda');
            }
            else if(document.formRadio.porRuc[i].value=='porRazon')
            {
                if (validarCampoAlert($("txtRazonSocial"),true,"soloVacio","Razon Social"))
                {
                    var razonSocial=$F("txtRazonSocial")
                    var data ="razonSocial="+razonSocial;
                    var clazz = "ProveedorIncumplido";
                    var action = "ReporteIncumplidosxRazon";
                    ajax_call_updater ('divListaInv', data, clazz, action, callbackSenal);
                }//fin de if q valida q el campo razon social no este vacio
            }//fin del if q valida cual radio button ha sido marcado
        }//fin de if q verifica los q han sido checked
    }//fin de for
}
//funcion ajax q recibe la respuesta de tcom%invitacion

function provIncumplido()
{
    location.href='../Empresa/ingresarProveedorIncumplido.php';
}

function provIncumplidoRegistrado()
{
    //var ruc=0;
    ruc=prompt('Ingrese el Ruc ','');
    if (ruc!=null)
        location.href='../Empresa/ingresarProveedorIncumplidoRegistrado.php?ruc='+ruc;
}

function callbackSenal(){
}

