var PrnKind =1; var PrnMarginLeft =0; var PrnMarginTop =0; var PageSize = ""; function astfInsertGridData(src_grid, trgt_grid, row_select_val, chkbox_col_nm, src_grid_col_nm_matrix, dupl_val_matrix) { var grid_matrix_val = astfChkMatrixData(src_grid_col_nm_matrix) if(grid_matrix_val == "E"){ return 0; } var dupl_matrix_val = astfChkMatrixData(dupl_val_matrix); if(dupl_matrix_val == "E"){ return 1; } var chk_opener = checkOpener(); var src_gridCols = src_grid.cols; var trgt_gridCols = trgt_grid.cols; if(row_select_val == 1){ var insert_vali = true; var src_node_set = src_grid.nodeset + "[" + src_grid.row+ "]/"; if(dupl_val_matrix != ""){ var dupl_trgt_nodeset = trgt_grid.nodeset + "["; var chk = dupl_matrix_val.length; for(var j=0; j < chk; j+=2){ if(j == 0){ dupl_trgt_nodeset += dupl_matrix_val[j+1] + "='" + model.getValue(src_node_set+dupl_matrix_val[j]) + "'"; } else { dupl_trgt_nodeset += " and " + dupl_matrix_val[j+1] + "='" + model.getValue(src_node_set+dupl_matrix_val[j]) + "'"; } } dupl_trgt_nodeset += "]/" + dupl_matrix_val[1]; if ( chk_opener ) { if(opener.model.getValue(dupl_trgt_nodeset) != ""){ insert_vali = false; } } else { if(model.getValue(dupl_trgt_nodeset) != ""){ insert_vali = false; } } if(!insert_vali){ messageBox("데이터가 중복되어 처리 ", "E001"); return 2; } } if(insert_vali) { trgt_grid.addRow(); var trgt_node_set = trgt_grid.nodeset + "[" + (trgt_grid.rows-1) + "]/"; for(var i = src_grid.fixedcols; i < src_gridCols; i++){ var src_ref_nm = src_grid.colattribute(i,"ref"); for(var j = trgt_grid.fixedcols; j < trgt_gridCols; j++){ var trgt_ref_nm = trgt_grid.colattribute(j,"ref"); if( src_ref_nm == trgt_ref_nm){ if ( chk_opener ) { opener.model.setValue(trgt_node_set+trgt_ref_nm,model.getValue(src_node_set+src_ref_nm)); } else { model.setValue(trgt_node_set+trgt_ref_nm,model.getValue(src_node_set+src_ref_nm)); } } } } if( src_grid_col_nm_matrix != ""){ var chk = grid_matrix_val.length; for(var i=0; i < chk; i+=2){ if ( chk_opener ) { opener.model.setValue(trgt_node_set+grid_matrix_val[i+1],model.getValue(src_node_set+grid_matrix_val[i])); } else { model.setValue(trgt_node_set+grid_matrix_val[i+1],model.getValue(src_node_set+grid_matrix_val[i])); } } } model.refresh(); } } else if(row_select_val == 2){ if(chkbox_col_nm == ""){ return 3; } var insert_vali = true; var insert_cnt = 0; for(var t = src_grid.fixedrows; t < src_grid.rows; t++){ var src_node_set = src_grid.nodeset + "[" + t + "]/"; insert_vali = true; if(model.getValue(src_node_set+chkbox_col_nm) == "true"){ if(dupl_val_matrix != ""){ var dupl_trgt_nodeset = trgt_grid.nodeset + "["; var chk = dupl_matrix_val.length; for(var j=0; j < chk; j+=2){ if(j == 0){ dupl_trgt_nodeset += dupl_matrix_val[j+1] + "='" + model.getValue(src_node_set+dupl_matrix_val[j]) + "'"; } else { dupl_trgt_nodeset += " and " + dupl_matrix_val[j+1] + "='" + model.getValue(src_node_set+dupl_matrix_val[j]) + "'"; } } dupl_trgt_nodeset += "]/" + dupl_matrix_val[1]; if ( chk_opener ) { if(opener.model.getValue(dupl_trgt_nodeset) != ""){ insert_vali = false; } } else { if(model.getValue(dupl_trgt_nodeset) != ""){ insert_vali = false; } } } if(insert_vali){ insert_cnt++; trgt_grid.addRow(); var trgt_node_set = trgt_grid.nodeset + "[" + (trgt_grid.rows-1)+ "]/"; for(var i = src_grid.fixedcols; i < src_gridCols; i++){ var src_ref_nm = src_grid.colattribute(i,"ref"); for(var j = trgt_grid.fixedcols; j < trgt_gridCols; j++){ var trgt_ref_nm = trgt_grid.colattribute(j,"ref"); if( src_ref_nm == trgt_ref_nm){ if ( chk_opener ) { opener.model.setValue(trgt_node_set+trgt_ref_nm,model.getValue(src_node_set+src_ref_nm)); } else { model.setValue(trgt_node_set+trgt_ref_nm,model.getValue(src_node_set+src_ref_nm)); } } } } if( src_grid_col_nm_matrix != ""){ var chk = grid_matrix_val.length; for(var i=0; i < chk; i+=2){ if ( chk_opener ) { opener.model.setValue(trgt_node_set+grid_matrix_val[i+1],model.getValue(src_node_set+grid_matrix_val[i])); } else { model.setValue(trgt_node_set+grid_matrix_val[i+1],model.getValue(src_node_set+grid_matrix_val[i])); } } } } } } model.refresh(); if(insert_cnt == 0){ return 2; } } else if(row_select_val == 3){ var insert_vali = true; var insert_cnt = 0; for(var t = src_grid.fixedrows; t < src_grid.rows; t++){ var src_node_set = src_grid.nodeset + "[" + t + "]/"; insert_vali = true; if(dupl_val_matrix != ""){ var dupl_trgt_nodeset = trgt_grid.nodeset + "["; var chk = dupl_matrix_val.length; for(var j=0; j < chk; j+=2){ if(j == 0){ dupl_trgt_nodeset += dupl_matrix_val[j+1] + "='" + model.getValue(src_node_set+dupl_matrix_val[j]) + "'"; } else { dupl_trgt_nodeset += " and " + dupl_matrix_val[j+1] + "='" + model.getValue(src_node_set+dupl_matrix_val[j]) + "'"; } } dupl_trgt_nodeset += "]/" + dupl_matrix_val[1]; if ( chk_opener ) { if(opener.model.getValue(dupl_trgt_nodeset) != ""){ insert_vali = false; } } else { if(model.getValue(dupl_trgt_nodeset) != ""){ insert_vali = false; } } } insert_cnt++; trgt_grid.addRow(); var trgt_node_set = trgt_grid.nodeset + "[" + (trgt_grid.rows-1)+ "]/"; for(var i = src_grid.fixedcols; i < src_gridCols; i++){ var src_ref_nm = src_grid.colattribute(i,"ref"); for(var j = trgt_grid.fixedcols; j < trgt_gridCols; j++){ var trgt_ref_nm = trgt_grid.colattribute(j,"ref"); if( src_ref_nm == trgt_ref_nm){ if ( chk_opener ) { opener.model.setValue(trgt_node_set+trgt_ref_nm,model.getValue(src_node_set+src_ref_nm)); } else { model.setValue(trgt_node_set+trgt_ref_nm,model.getValue(src_node_set+src_ref_nm)); } } } } if( src_grid_col_nm_matrix != ""){ var chk = grid_matrix_val.length; for(var i=0; i < chk; i+=2){ if ( chk_opener ) { opener.model.setValue(trgt_node_set+grid_matrix_val[i+1],model.getValue(src_node_set+grid_matrix_val[i])); } else { model.setValue(trgt_node_set+grid_matrix_val[i+1],model.getValue(src_node_set+grid_matrix_val[i])); } } } model.refresh(); } if(insert_cnt == 0){ return 2; } } if ( chk_opener ) { opener.model.refresh(); } else { model.refresh(); } return 10; } function astfChkMatrixData(matrix_val) { var col_data = ""; if(matrix_val != ""){ var col_flag = ","; col_data = matrix_val.split(col_flag); if(col_data.length <= 1) { col_data = "E"; return col_data; } var chk = col_data.length % 2; if( chk == 1 ) { col_data = "E"; return col_data; } } return col_data; } function astfMakePopup(ctrID, xPath){ var id = ctrID.elementName; if (m_event.button == 3){ if(id == "xforms:datagrid"){ if(ctrID.isCell(m_event.target) && ctrID.mouseRow >= ctrID.fixedrows){ window.setPopupMenu(true, xPath, label, func, false); }else{ window.setPopupMenu(false); } } else if(id == "xforms:calendar" || id == "xforms:select" || id == "xforms:select1" || id == "xforms:treeview"){ if(ctrID.isCell(m_event.target)){ window.setPopupMenu(true, xPath, "label", "func", false); }else{ window.setPopupMenu(false); } } else if(id == "xforms:multilinegrid"){ if(ctrID.mouseRow >= ctrID.fixedrows){ window.setPopupMenu(true, xPath, "label", "func", false); }else{ window.setPopupMenu(false); } } else if(id == "xforms:img"){ window.setPopupMenu(true, xPath, "label", "func", false); } else { window.setPopupMenu(false); } } } function astfAddCombo(combopath, parentnode, nodename, nodeval) { nodename = nodename.split(","); nodeval = nodeval.split(","); if(nodename.length != nodeval.length){ return; } var label = model.instances.item(0).createElement(nodename[0]); var val = model.instances.item(0).createElement(nodename[1]); var combo = model.instances.item(0).createElement(parentnode); label.setValue("" + nodeval[0] + ""); val.setValue("" + nodeval[1] + ""); combo.appendChild(label); combo.appendChild(val); chkNode = model.instances.item(0).selectSingleNode(combopath); if(chkNode == null){ model.makeNode(combopath); srcNode = model.instances.item(0).selectSingleNode(combopath); }else{ srcNode = model.instances.item(0).selectSingleNode(combopath); } desNode = model.instances.item(0).selectSingleNode(combopath + "/" + parentnode); if(desNode == null){ return 0; }else{ srcNode.insertBefore(combo, desNode); } model.refresh(); } function astfCopyNodeSet(trgtNodeSet, srcNodeSet) { var nodename_array = trgtNodeSet.split("/"); var nodename = ""; for( var i = 1; i< nodename_array.length -1; i++ ) { nodename += "/"+nodename_array[i]; } var srcNodeList = model.instance1.selectNodes(srcNodeSet); if( srcNodeList.length == 0 ) return; var tmpNodeSet; for( var j = srcNodeList.length - 1; j >= 0; j-- ) { tmpSrcNode = srcNodeList.item(j).cloneNode(true); tmpSrcNode.nodeName = nodename_array[i]; model.duplicate(nodename, tmpSrcNode); } } function astfTrim(val) { var result_val = ""; var i = 0; var j = 0; for(i = 0; i < val.length; i++){ var temp = val.substr(i,1); if(temp == null || temp == "" || temp == " " || temp == " " || temp == "undefined"){ } else { break; } } for(j = val.length; j > 0; j--){ var temp = val.substr(j,1); if(temp == null || temp == "" || temp == " " || temp == " " || temp == "undefined"){ } else { break; } } return ( (i > 0) || (j < val.length) ) ? val.substring(i, j-i+1) : val; } function astfMatrixData(pData, pRow, pCol) { var rowSep = "▩"; var colSep = "▦"; var arrRow = pData.split(rowSep); if(arrRow.length <= pRow) return ""; var arrCol = arrRow[pRow].split(colSep); if(arrCol.length <= pCol) return ""; return arrCol[pCol]; } function astfStartFormat(pX, pY, pPage) { PageSize = pPage; if ( PrnKind == 2 || PrnKind == 7 ) { if(pPage == "S") { return "AA107000500V00H00L0101"; }else { return "AA110300820V00H00L0101"; } } else { return "^XA^SEE:UHANGUL.DAT^FS^CWQ,E:AAAAA.FNT^FS^CI26" + "^LH" + pX + "," + pY; } } function astfEndFormat(pCnt) { var vCnt = 1; if (isNull(pCnt)) { vCnt = 1; } else { vCnt = pCnt } if ( PrnKind == 2 || PrnKind == 7 ) { return "Q"+ vCnt +"Z"; } else { return "^PQ" + vCnt + "^XZ"; } } function astfFiendOrigin(pX, pY) { if ( PrnKind == 2 || PrnKind == 7 ) { return "V"+pY+"H"+pX; } else { return "^FO" + pX + "," + pY; } } function astfChangeFont(pF, pH, pW) { var sBuf = ""; sBuf = "^CF" + pF; sBuf += "," + pH; sBuf += "," + pW; return sBuf; } function astfGraphicBox(pX, pY, pW, pH, pBF) { var sBuf = ""; if ( PrnKind == 2 || PrnKind == 7 ) { } else { sBuf = astfFiendOrigin(pX, pY); sBuf += "^GB" + pW + "," + pH + "," + pBF + "^FS"; } return sBuf; } function astfFieldDataA(pX, pY, pData, pReverse) { var sBuf = ""; sBuf = astfFiendOrigin(pX, pY); if (!isNull(pReverse)) { if (pReverse.getTrim() == "Y") { sBuf += "^FR"; } } sBuf += "^FD" + pData + "^FS"; return sBuf; } function astfFieldDataH(pX, pY, pW, pH, pData) { var sBuf = ""; sBuf += astfFiendOrigin(pX, pY); sBuf += "^CFA" + "," + pW + "," + pH;; sBuf += "^FD" + pData + "^FS"; return sBuf; } function astfBarCode_Code39(pX, pY, pO, pH, pData, pBigYN) { var sBuf = ""; pX = parseInt(pX) + parseInt(PrnMarginLeft); pY = parseInt(pY) + parseInt(PrnMarginTop); sBuf = astfFiendOrigin(pX, pY); if ( PrnKind == 2 || PrnKind == 7 ) { if ( PageSize == "S" ) { sBuf += "V"+pY+"H"+pX+"BG01070" + pData ; } else { sBuf += "V"+pY+"H"+pX+"BG02070" + pData ; } } else { if(pBigYN == "S"){ sBuf += "^BY1,2.0"; } else if(pBigYN == "B"){ sBuf += "^BY2,2.0"; } else { sBuf += "^BY2,2.0"; } sBuf += "^B3" + pO + ",N," + pH + ",N,N^FD" + pData + "^FS"; } return sBuf; } function astfPrintOutH(pX, pY, pFont, pImage, pData, pReverse) { var sBuf = ""; if ( PrnKind == 2 || PrnKind == 7 ) { sBuf= CommAX.PrtImgOut(pX,pY,pData); } else { sBuf = astfFontSize(pFont); sBuf += CommAX.PrtImgOut(pImage, pData); sBuf += astfFiendOrigin(pX, pY); sBuf += "^XG"+pImage+",2,1^FS"; } return sBuf; } function astfPrintOutA(pX, pY, pFont, pData, pReverse) { var sBuf = ""; sBuf += astfFontSize(pFont); sBuf += astfFieldDataA(pX, pY, pData, pReverse); return sBuf; } function astfPrintOut(pX, pY, pFont, pData, pReverse) { var sBuf = ""; pX = parseInt(pX) + parseInt(PrnMarginLeft); pY = parseInt(pY) + parseInt(PrnMarginTop); if ( PrnKind == 2 ) { sBuf = astfFiendOrigin(pX, pY); sBuf += astfFontSize(pFont); sBuf += pData+""; } else if (PrnKind == 7){ if(pFont == 6 || pFont == 7 || pFont == 10){ sBuf += CommAX.PrtImgOut(parseInt( pY), parseInt(pX), pData,2,2,"0","K2B"); } else { sBuf += CommAX.PrtImgOut(parseInt( pY), parseInt(pX), pData,1,1,"0","K2B"); } } else { sBuf = astfFiendOrigin(pX, pY); sBuf += astfFontSize(pFont); if (!isNull(pReverse)) { if (pReverse.getTrim() == "Y") { sBuf += "^FR"; } } sBuf += "^FD"+pData+"^FS"; } return sBuf; } function astfFontSize(pFont) { var sBuf = ""; var pW = 0; var pH = 0; if ( PrnKind == 2 || PrnKind == 7 ) { if(pFont == 6 || pFont == 7 || pFont == 10){ sBuf ="L0202K8D"; } else { sBuf ="L0101K9D"; } } else { if(pFont == 1){ pH = 21; pW = 10; } else if(pFont == 2){ pH = 26; pW = 19; } else if(pFont == 3){ pH = 31; pW = 23; } else if(pFont == 4){ pH = 36; pW = 28; } else if(pFont == 5){ pH = 41; pW = 33; } else if(pFont == 6){ pH = 46; pW = 38; } else if(pFont == 7){ pH = 50; pW = 43; } else if(pFont == 8){ pH = 55; pW = 48; } else if(pFont == 9){ pH = 60; pW = 53; } else if(pFont == 10){ pH = 70; pW = 62; } else if(pFont == 11){ pH = 25; pW = 13; } else if(pFont == 21){ pH = 25; pW = 19; } else if(pFont == 24){ pH = 26; pW = 16; } else if(pFont == 27){ pH = 31; pW = 26; } else if(pFont == 28){ pH = 30; pW = 19; }else if(pFont == 29){ pH = 31; pW = 20; }else if(pFont == 31){ pH = 33; pW = 23; } else if(pFont == 32){ pH = 35; pW = 24; } else if(pFont == 33){ pH = 35; pW = 25; } else if(pFont == 34){ pH = 35; pW = 26; } else if(pFont == 35){ pH = 35; pW = 28; } sBuf = "^AQN,"+pH+","+pW; } return sBuf; } function astfNullValidation(pNodeSet, pCol, pMsg) { var cntnull = model.getXPathValue("count(" + pNodeSet + " [normalize-space(string(" + pCol + ")) = ''])"); if(cntnull > 0) { messageBox(pMsg , "C001"); return false; } return true; } function astfCopyRenameNodeSet(refNodeSet, srcNodeSet) { var refNodeCnt = instance1.selectNodes(refNodeSet).length; for(var i = 1; i <= instance1.selectNodes(srcNodeSet).length; i++) { var makeNodeCnt = parseInt(refNodeCnt) + parseInt(i); model.makeNode(refNodeSet + "[" + makeNodeCnt + "]"); model.copyNode(refNodeSet + "[" + makeNodeCnt + "]", srcNodeSet + "[" + i + "]"); } }