/****************************************************************/
function getXY( oElement )
{
var iReturnValueX = 0;
var iReturnValueY = 0;
while( oElement != null ) {
iReturnValueY += oElement.offsetTop;
iReturnValueX += oElement.offsetLeft;
oElement = oElement.offsetParent;
}
return {x:iReturnValueX,y:iReturnValueY};
}
/****************************************************************/
function que(obj)
{
if (document.activeElement.tagName=="A" && document.activeElement.getAttribute("targetcontrol")=="1"){
return
}else {obj.style.display='none'}
}
/****************************************************************/
function nopastecode(){
if( window.event.button==2) {alert("Accion no permitida");return;}
if (window.event.shiftKey && window.event.keyCode==45)window.event.returnValue = false;
if (window.event.ctrlKey && window.event.keyCode==86)window.event.returnValue = false;
}
/****************************************************************/
function AplicarFormato(controlhtml,obj){
controlhtml.document.focus()
if (obj.tagName=="SELECT") {
var cmd=obj.options(obj.selectedIndex).getAttribute("cmd")
controlhtml.document.execCommand(cmd, false, obj.value);
}else{
controlhtml.document.execCommand(obj.getAttribute("cmd"), true, null);
}
controlhtml.click()
window.event.cancelBounce=false
window.event.returnValue=false
}
/****************************************************************/
function makea(portlet,params,text){
var str=""+text+""
return str
}
/****************************************************************/
/****************************************************************/
/****************************************************************/
/****************************************************************/
function MultiControl(str){
this.objectParam = str
if (!this.objectParam.labelwidth) this.objectParam.labelwidth="200px"
this.nic="-----12345"
var bredraw=0
var iirow=0
this.serializeCount=0;
/****************************************************************/
this.NoCaracteresEspecialesNiNumeros=function(){
//No permite el ingreso de los caracteres @ alt 64, % alt 37, & alt 38
// No permite puntos ni comas
var x = window.event.keyCode;
switch (x){
case 173: case 128: case 135: case 64: case 37: case 8: case 9: case 39: case 42: case 44: case 46: case 47:
case 48: case 49: case 50: case 51: case 45:
case 52: case 53: case 54: case 55: case 56: case 57: case 64: case 37: case 38:
case 33: case 34: case 35: case 36: case 40: case 41: case 60: case 61: case 62:
case 63: case 166: case 167: case 168: case 92: case 43: case 186: case 170: case 161: case 191: case 183:
case 96: case 94: case 231: case 58: case 59: case 199: case 95:
window.event.keyCode = 0;
break;
default:
return;
}
}
/****************************************************************/
this.validaNumerico=function(obj) {
var escribe=1;
var key=window.event.keyCode; //código de tecla.
if (key <46 || key > 57 || key==47){ //si no es numero o punto decimal "."
window.event.keyCode=0; //anula la entrada de texto.
}
}
/****************************************************************/
this.validamail=function(obj) {
var at="@"
var dot="."
var lat=obj.value.indexOf(at)
var lstr=obj.value.length
var ldot=obj.value.indexOf(dot)
window.event.cancel=true
if (obj.value.indexOf(at)==-1){
alert("Debe ingresar un correo electronico válido1")
obj.focus()
return false
}
if (obj.value.indexOf(at)==-1 || obj.value.indexOf(at)==0 || obj.value.indexOf(at)==lstr){
alert("Debe ingresar un correo electronico válido2")
obj.focus()
return false
}
if (obj.value.indexOf(dot)==-1 || obj.value.indexOf(dot)==0 || obj.value.indexOf(dot)==lstr){
alert("Debe ingresar un correo electronico válido3")
obj.focus()
window.event.returnValue=true
window.event.cancelBubble =true
return false
}
if (obj.value.indexOf(at,(lat+1))!=-1){
alert("Debe ingresar un correo electronico válido4")
obj.focus()
return false
}
if (obj.value.substring(lat-1,lat)==dot || obj.value.substring(lat+1,lat+2)==dot){
alert("Debe ingresar un correo electronico válido5")
obj.focus()
return false
}
if (obj.value.indexOf(dot,(lat+2))==-1){
alert("Debe ingresar un correo electronico válido6")
obj.focus()
return false
}
if (obj.value.indexOf(" ")!=-1){
alert("Debe ingresar un correo electronico válido7")
obj.focus()
return false
}
return true
}
/****************************************************************/
this.getValueHtmlObject=function (ptarget,pvalue,ptext,obj){
pvalue.value=obj.getAttribute("pvalue")
ptext.value=obj.getAttribute("ptext")
ptarget.style.display="none"
}
/****************************************************************/
this.getAjaxRuc=function(obj,pvalue,ltype){
if (pvalue.length<11 && ltype!=-1) return
var stringvalue = getPortletAjax ("servicios/wsSunatGetDatosGenerales.asp?ruc=" + pvalue)
var stringArray =stringvalue.split(".-.")
if (stringArray.length != 2) stringArray=["",""]
if (ltype!=-1){
document.all.item(obj.name+"div_raz").innerHTML = "Razon Social :" + stringArray[0]
document.all.item(obj.name+"div_dom").innerHTML = "Domicilio :" + stringArray[1]
document.all.item(obj.name+"_raz").value = stringArray[0]
document.all.item(obj.name+"_dom").value = stringArray[1]
} else {
return stringArray
}
}
/****************************************************************/
this.getAjaxInLine=function(psize,obj,pname,pnamemask,pnamemaskdiv,pportletid,pparam){
if (obj.value.length"+nodeList[i].getAttribute("text")+""
}
html+=""
pnamemaskdiv.innerHTML=html
pnamemaskdiv.style.display==""
}// else {pnamemaskdiv.style.display="none"}
}
/****************************************************************/
this.getAjaxInLineIni=function(pportletid,pparam,pvalue){
return getPortletXML ("portlet5openxml.asp?_portletid_="+pportletid+"&"+pparam+"=" + pvalue+"&returnValue=0")
}
/****************************************************************/
this.setReDrawOff=function(){
bredraw=1
}
/****************************************************************/
this.setReDrawOn=function(){
bredraw=0
}
/****************************************************************/
this.getReDrawOn=function(){
return bredraw
}
/****************************************************************/
this.setRow=function(lrow){
iirow=lrow
}
/****************************************************************/
this.getRow=function(){
return iirow
}
/****************************************************************/
this.rowCount=function(){
var lser=0;
var adddelete=0;
for (vn in this.objectParam.arrayData)
{
adddelete=0
if (this.objectParam.arrayData[vn][this.objectParam.showdelete.column]=="1"){
if (!this.objectParam.showdelete.deleteadd) adddelete=1
}
if (adddelete==0){
lser++;
}
}
return lser
}
/****************************************************************/
this.htmlrawdata=""
this.makeHeader=function(){
var tblHeader="
"
for (var i in this.objectParam.fieldset){
tblHeader+="
" + this.objectParam.fieldset[i].label + "
"
}
if (this.objectParam.showdelete)tblHeader+="
"
tblHeader+="
"
tblHeader+="
"
htmlrawdata+=tblHeader
}
/****************************************************************/
this.makeHeaderForm=function(){
var tblHeader="
"
htmlrawdata+=tblHeader
}
/****************************************************************/
this.replace=function (strText,pnic,ppnic){
var strReplaceAll = strText;
var intIndexOfMatch = strReplaceAll.indexOf( pnic );
while (intIndexOfMatch != -1){
strReplaceAll = strReplaceAll.replace( pnic, ppnic )
intIndexOfMatch = strReplaceAll.indexOf( pnic );
}
return strReplaceAll
}
/****************************************************************/
this.existsCSS=function(pcond,pattr,pvalue){
return ((pcond)?pattr+":"+pvalue:"")
}
/****************************************************************/
this.existsAttr=function(pcond,pattr,pvalue){
return ((pcond)?pattr+"="+pvalue:"")
}
/****************************************************************/
this.getValue=function(irow,icol){
return this.replace(this.objectParam.arrayData[irow][this.objectParam.fieldset[icol].id],"\"",""")
}
/****************************************************************/
this.makeRow=function(irow){
var tblRow=""
for (var i =0 in this.objectParam.fieldset){
try{
if (this.objectParam.format && this.objectParam.fieldset[i].label ) tblRow+="
"+this.objectParam.fieldset[i].label+"
"
//else
tblRow+="
"
if (!this.objectParam.editform){
if (this.objectParam.fieldset[i].arrayData){
for (vn in this.objectParam.fieldset[i].arrayData){
if (this.objectParam.fieldset[i].arrayData[vn].id==this.getValue(irow,i))
tblRow+=this.objectParam.fieldset[i].arrayData[vn].text
}
}else {
if (this.objectParam.fieldset[i].htmlout+""=="undefined")
{
tblRow+=this.getValue(irow,i)
}
else {
tblRow+=this.objectParam.fieldset[i].htmlout(irow,this.objectParam.arrayData[irow])
}
}
} else {
if (this.objectParam.fieldset[i].type=="ubigeo" ){
this.objectParam.fieldset[i].type="ajaxlist"
this.objectParam.fieldset[i].arrayData=[{portletid:"usp_1501_opcion_ubicacion_geografica",param:"ubigeo",size:4}]
this.objectParam.fieldset[i].help="Escriba el nombre del departamento, provincia o distrito que desea seleccionar y haga clic en el elemento de la lista que aparece."
}
if (this.objectParam.fieldset[i].type=="entidadpublica" ){
this.objectParam.fieldset[i].type="ajaxlist"
this.objectParam.fieldset[i].arrayData=[{portletid:"usp_entidade_publicas",param:"pcodconsucode",size:4}]
this.objectParam.fieldset[i].help="Seleccione una entidad de la lista."
}
if (this.objectParam.fieldset[i].type=="ritch" ) tblRow+=getPortletAjax("jslib/ritchcontrol.asp?controlname="+this.objectParam.fieldset[i].name+"&controlwidth="+this.objectParam.fieldset[i].width).replace("@htmldata@",this.getValue(irow,i)).replace("@htmldata1@",this.getValue(irow,i))
if (this.objectParam.fieldset[i].type=="html" ) tblRow+=this.objectParam.fieldset[i].htmlout(irow,this.objectParam.arrayData[irow])
if (this.objectParam.fieldset[i].type=="date" ) tblRow+=""
if (this.objectParam.fieldset[i].type=="text") tblRow+=""
if (this.objectParam.fieldset[i].type=="imagen") tblRow+=""
if (this.objectParam.fieldset[i].type=="linkdownload") tblRow+="Descargar"
if (this.objectParam.fieldset[i].type=="email") tblRow+=""
if (this.objectParam.fieldset[i].type=="number") tblRow+=""
if (this.objectParam.fieldset[i].type=="alpha") tblRow+=""
if (this.objectParam.fieldset[i].type=="password") tblRow+=""
var returnValueText=""
if (this.objectParam.fieldset[i].type=="ajaxlist"){
tblRow+=""
if (this.getValue(irow,i)!=""){
var xdoc = this.getAjaxInLineIni(this.objectParam.fieldset[i].arrayData[0].portletid,this.objectParam.fieldset[i].arrayData[0].param,this.getValue(irow,i))
try{
returnValueText = xdoc.selectSingleNode("//td[@value='"+this.getValue(irow,i)+"']").getAttribute("text")
}catch(e){alert (e.description)}
}
tblRow+=""
tblRow+=""
}
if (this.objectParam.fieldset[i].type=="rucrazdom"){
tblRow+=""
var strArray=this.getAjaxRuc(null,this.getValue(irow,i),-1)
tblRow+="
Razon Social :"+strArray[0]+"
"
tblRow+="
Domicilio :"+strArray[1]+"
"
}
if (this.objectParam.fieldset[i].type=="file" ) tblRow+=""
if (this.objectParam.fieldset[i].type=="select" ){
tblRow+=""
}
if (!this.objectParam.fieldset[i].type ) tblRow+=this.getValue(irow,i)
}
if (this.objectParam.editform==2){
if (this.objectParam.format && this.objectParam.fieldset[i].help )
tblRow+=" "+this.objectParam.fieldset[i].help+"
"
}else{
tblRow+=""
if (this.objectParam.format && this.objectParam.fieldset[i].help )
tblRow+="
"
}catch(e){alert(e.description +"\r\n"+ this.objectParam.fieldset[i].name)}
}
if (!this.objectParam.format)
if(this.objectParam.editform){
if (this.objectParam.format) tblRow+="
"
if (this.objectParam.showdelete)tblRow+="
"
if (this.objectParam.format) tblRow+="
"
}else tblRow+="
"
return tblRow
}
/****************************************************************/
this.makeRows=function(){
var tblRows=""
for (var lirow in this.objectParam.arrayData){
if (!this.objectParam.format) tblRows+="
"
if((this.objectParam.showdelete+"")!="undefined"){
//alert (this.objectParam.arrayData[lirow][this.objectParam.showdelete.column])
if (this.objectParam.arrayData[lirow][this.objectParam.showdelete.column]!="1"){
tblRows+=this.makeRow(lirow);
}
}else
tblRows+=this.makeRow(lirow);
if (!this.objectParam.format) tblRows+="
"
}
htmlrawdata+=tblRows
}
/****************************************************************/
this.attachEvents=function(){
for (var i in this.objectParam.attachEvents){
var ele = this.objectParam.attachEvents[i]
var numero =0
try{
numero = document.all.item(this.objectParam.htmlform).item(ele.name)
}catch(e){return}
if (!numero.length) {
numero=1
}else{
numero = numero.length
}
if (numero ==1)
document.all.item(this.objectParam.htmlform).item(ele.name).attachEvent (ele.a,ele.b)
else
for (var n=0;n<=numero;n++) {
document.all.item(this.objectParam.htmlform).item(ele.name)[n].attachEvent (ele.a,ele.b)
}
}
}
/****************************************************************/
this.redraw=function (){
htmlrawdata=""
if (!this.objectParam.format){
htmlrawdata=""
this.makeHeader();
this.makeRows();
htmlrawdata+="
"
}
this.objectParam.container.innerHTML = htmlrawdata
this.attachEvents()
}
/****************************************************************/
this.draw=function (){
htmlrawdata=""
if (!this.objectParam.format){
this.makeHeader();
this.makeRows();
}else{
this.makeHeaderForm();
this.makeRows();
}
htmlrawdata+=""
return htmlrawdata
}
/****************************************************************/
this.setValueArray2=function(irow,icol,value){
this.objectParam.arrayData[irow][icol]=value
}
/****************************************************************/
this.setValueArray=function(obj,irow,icol,value){
if (this.objectParam.inputconvert=="upper")obj.value=obj.value.toUpperCase()
if (this.objectParam.inputconvert=="lower")obj.value=obj.value.toLowerCase()
this.objectParam.arrayData[irow][icol]=obj.value
}
/****************************************************************/
this.deleteRow=function(irow){
if (confirm(this.objectParam.showdelete.message)==0)return
try{
this.setValueArray2(irow,this.objectParam.showdelete.column,"1");
}catch(e){alert(e.description)}
this.redraw();
}
/****************************************************************/
this.insertRow=function(){
var irow =this.objectParam.arrayData.length
this.objectParam.arrayData[irow]=new Array(this.objectParam.fieldset.length);
for (vn in this.objectParam.fieldset){
this.objectParam.arrayData[irow][vn]=((this.objectParam.fieldset[vn].defaultValue)?this.objectParam.fieldset[vn].defaultValue:"")
}
if (this.getReDrawOn()==0){
this.redraw();
}
this.setReDrawOn()
return irow
}
/****************************************************************/
this.serialize=function(){
var lser="";
var adddelete=0;
this.serializeCount=0;
for (vn in this.objectParam.arrayData)
{
adddelete=0
if (this.objectParam.arrayData[vn][this.objectParam.showdelete.column]=="1"){
if (!this.objectParam.showdelete.deleteadd) adddelete=1
}
if (adddelete==0){
for (vn1 in this.objectParam.fieldset)
{
lser+=this.nic+ this.objectParam.arrayData[vn][this.objectParam.fieldset[vn1].id]
}
if (this.objectParam.showdelete.deleteadd)lser+=this.nic+((this.objectParam.arrayData[vn][this.objectParam.showdelete.column]!="1")?"0":"1")
this.serializeCount++;
}
}
lser=this.nic+this.serializeCount+lser+this.nic
return lser
}
/****************************************************************/
this.valid=function(){
var lser=""
for (vn in this.objectParam.arrayData){
for (vn1 in this.objectParam.fieldset){
//if (this.objectParam.arrayData[vn][this.objectParam.showdelete.column]!="1"){
if (this.objectParam.fieldset[vn1].mandatory+""!="undefined" && this.objectParam.arrayData[vn][this.objectParam.fieldset[vn1].id]=="") {
if (this.objectParam.showdelete+"" != "undefined"){
if (this.objectParam.arrayData[vn][this.objectParam.showdelete.column]!="1"){
vn2=parseInt(vn)+1
lser+="Fila :" + vn2 + "."+ "Debe ingresar el valor para el campo "+this.objectParam.fieldset[vn1].label +"\r\n"
}
}else{
vn2=parseInt(vn)+1
lser+="Fila :" + vn2 + "."+ "Debe ingresar el valor para el campo "+this.objectParam.fieldset[vn1].label +"\r\n"
}
//}
}
}
}
if (lser!=""){
lser="AVISO\r\n" + lser
alert (lser)
}
return lser
}
/*
if (this.getReDrawOn()==0){
this.redraw();
}
*/
}
/****************************************************************/
/****************************************************************/
/****************************************************************/
/****************************************************************/
/****************************************************************/
/*nueva definicion del MultiControl(str)*/
function SearchOnlyForm(pform,str){
var l = new MultiControl(str)
l.objectParam.container.innerHTML = "" + l.draw()
return l
}
/****************************************************************/
function SearchForm(pform,str){
var l = new MultiControl(str)
l.objectParam.container.innerHTML = "
Todos
" + l.draw()
return l
}
/****************************************************************/
function SearchNewForm(pform,str){
var l = new MultiControl(str)
l.objectParam.container.innerHTML = "
" + l.draw()
return l
}
/****************************************************************/
function FormMultiControl(pform,str){
var l = new MultiControl(str)
var strHTML=""
strHTML+="
"
strHTML+=" "
strHTML+=""
strHTML+="
"
strHTML+= l.draw()
strHTML+="
"
strHTML+=" "
strHTML+=""
strHTML+="
"
strHTML+=""
strHTML+=""
l.objectParam.container.innerHTML = strHTML
return l
}
/****************************************************************/
function FormDetailMultiControl(pform,container,str,strdetail){
var l = new MultiControl(str)
var ld = new MultiControl(strdetail)
var strHTML=""
strHTML+="