/* --------------------------------------------------------------------- SMRSC09000_»óºñ¾àǰ°ü¸®.xrw (SMRSC09000.xfm - JScript ) - Version : 1) : Ver.1.00.01 : Create By Francis Choi : 2010.02.16 ---------------------------------------------------------------------- */ var gPurcDeptcd = ""; // ¾à±¹ »ç¿ëºÎ¼­ // -------------------------------------------------- // »ç¿ëÀÚ±ÇÇÑ Check // -------------------------------------------------- function fInitForm() { fInitialize(); model.refresh(); } // -------------------------------------------------------------- // È­¸é open½Ã¿Í ÃʱâÈ­ ¹öư Ŭ¸¯½Ã È­¸é ÃʱâÈ­ ±â´ÉÀ» ¼öÇàÇÑ´Ù. // -------------------------------------------------------------- function fInitialize() { var vInstCd = getUserInfo("dutplceinstcd"); model.removenode("/root/main/stockdata/item"); //[2010.08.26]AS-IS ÄÚµå TO_BE ÄÚµå ÀüȯÀ» À§ÇÑ ¹°Ç°±¸ºÐ º¯°æ (goodflag= P) => (goodflag= PH) model.setValue(ipt_goodflag.attribute("ref"), "PH"); rszfUserReqInstList(cmb_instcd , getUserInfo("userid"),"1","B"); rszfLMSComboList(model.getValue(ipt_goodflag.attribute("ref")), "", "", "cmb_lrg", "", "L", "Y", "Y"); misfComboComCdListMulti("Z0007", "cmb_instcd"); //±â°üÄÚµå model.setValue(cmb_instcd.attribute("ref"), vInstCd); // Login »ç¿ëÀÚ ±â°üÄÚµå model.setValue(otp_usernm.attribute("ref"), getUserInfo("usernm")); // Login »ç¿ëÀÚ ±â°üÄÚµå cmb_lrg.value = ""; misfGridInit(grd_dept); misfGridInit(grd_stock); misfGridInit(grd_history); misfGridInit(grd_drugprtlist); //grd_dept.explorerbar = "sortshow"; //grd_stock.explorerbar = "sortshow"; //grd_history.explorerbar = "sortshow"; // ------------------------------------------------------------------------------------- // ±â°üº° ±¸¸Å½Ã½ºÅÛ ±âº»Á¤º¸¸¦ Á¶È¸ÇÑ´Ù // vPathResult = "/root/init/RscsysinftLists"; // drugdept ¾àÁ¦´ã´çºÎ¼­ // ------------------------------------------------------------------------------------- //rszfRscsysinftLists(vInstCd); //gPurcDeptcd = getRscsysinftInfo("drugdept"); // // ------------------------------------------- // ±â°üº° ±¸¸Å¹ßÁÖÀÚ ±âº»Á¤º¸¸¦ Á¶È¸ÇÑ´Ù // ------------------------------------------- //rszfRscsysordtLists(vInstCd, gPurcDeptcd, getUserInfo("userid")) //var vPurcOrdId = getRscsysordtInfo("purcordid"); model.setValue(rdo_drugflag.attribute("ref"),"1"); //°ü¸®±¸ºÐ 1.ÀϹݾàǰ 2:¸¶¾à·ù // alert(getUserInfo("userid")+"=="+vPurcOrdId); // var usrDeptCd = getUserInfo("dutplcecd"); // if (usrDeptCd.substring(0,4) != "3242") { // vPurcOrdId = "1"; /*if (vPurcOrdId == "") { btn_find.disabled = true; btn_save.disabled = true; btn_addRow.disabled = true; btn_delRow.disabled = true; grd_stock.colAttribute(grd_stock.colRef("drugqty" ), "editable") = false; grd_stock.colAttribute(grd_stock.colRef("keepmth" ), "editable") = false; grd_stock.colAttribute(grd_stock.colRef("clinicreason"), "editable") = false; grd_stock.colAttribute(grd_stock.colRef("modifyreason"), "editable") = false; grd_stock.colAttribute(grd_stock.colRef("cmt" ), "editable") = false; grd_stock.colDisabled(grd_stock.colRef("goodcd" )) = true; grd_stock.colDisabled(grd_stock.colRef("drugqty" )) = true; grd_stock.colDisabled(grd_stock.colRef("keepmth" )) = true; grd_stock.colDisabled(grd_stock.colRef("clinicreason")) = true; grd_stock.colDisabled(grd_stock.colRef("modifyreason")) = true; grd_stock.colDisabled(grd_stock.colRef("cmt" )) = true; if (getUserInfo("dutplcecd").substring(0,3) != "324") { model.setValue(ipt_deptcd.attribute("ref"), getUserInfo("dutplcecd")); model.setValue(opt_deptnm.attribute("ref"), getUserInfo("dutplcenm")); ipt_deptcd.disabled = true; } } else { cpt_excel.visible = true; // ÀúÀå }*/ cpt_excel.visible = true; // ÀúÀå submit("TRRSC09001"); model.setValue("/root/main/articleCnt", ""); model.setValue("/root/main/totalPrice", ""); //misfGridInit(grd_stock); //misfGridInit(grd_history); } // -------------------------------------------------------------- // »óºñ¾àǰ·®°ú º¯°æÀÌ·Â Á¶È¸ // -------------------------------------------------------------- function fSearch() { // misfGridInit(grd_dept); misfGridInit(grd_stock); misfGridInit(grd_history); submit("TRRSC09002"); submit("TRRSC09003"); fSumViewOption(grd_stock,ckb_reqdeptcd , "reqdeptcd" ); fSumViewOption(grd_stock,ckb_reqdeptnm , "reqdeptnm" ); fSumViewOption(grd_stock,ckb_lrgnm , "lrgnm" ); fSumViewOption(grd_stock,ckb_mdlnm , "mdlnm" ); fSumViewOption(grd_stock,ckb_smlnm , "smlnm" ); fSumViewOption(grd_stock,ckb_lastupdt , "lastupdt" ); fSumViewOption(grd_stock,ckb_lastupdt , "lastupdt" ); fSumViewOption(grd_stock,chk_lastupdtnm, "lastupdtnm"); // fTotalData(); } // -------------------------------------------------------------- // »óºñ¾àǰ ÃÑ·®°ú ±Ý¾× Sum // -------------------------------------------------------------- function fTotalData() { var articleCnt = model.getXPathValue("count(/root/main/stockdata/item)"); var totalPrice = 0; for (var i = 1; i < grd_stock.rows; i++) { var aCnt = model.getValue(grd_stock.nodeset+"["+i+"]/drugqty" ); // ¼ö·® var cost = model.getValue(grd_stock.nodeset+"["+i+"]/goodunitcost"); // ´Ü°¡ var itemamt = model.getValue(grd_stock.nodeset+"["+i+"]/itemamt" ); // Á¶È¸½Ã ±Ý¾× totalPrice += parseFloat(itemamt); // totalPrice += parseFloat(aCnt)*parseFloat(cost); grd_stock.isReadOnly( i, grd_stock.colRef("goodcd"), i, grd_stock.colRef("goodcd")) = true; //Àüü Grid ReadOnly false } // model.setValue("/root/main/articleCnt", articleCnt); // model.setValue("/root/main/totalPrice", totalPrice); // caption8.refresh(); // caption10.refresh(); } // -------------------------------------------------------------- // ¾àǰÄÚµåÁ¶È¸ // -------------------------------------------------------------- function fButtonClick() { if (grd_stock.col == grd_stock.colRef("goodcd")) { fSelectDrug(); } else { } } // -------------------------------------------------------------- // ¾àǰÄÚµåÁ¶È¸ // -------------------------------------------------------------- function fSelectDrug() { modal("SPRSC09000", 0, 100, 150, "SPRSC09000", "/root/temp/receivedata", "/root/target"); var usrSelVal = model.getValue("/root/temp/usrSelectDrugcd"); if (usrSelVal != "") { var tmp = usrSelVal.split("¢Ì"); var tmp1 = tmp[0].split("¢Ë"); var tmp2 = tmp[1].split("¢Ë"); for (var i = 0; i < tmp1.length; i++) { if (tmp1[i] == "goodcd") { model.setValue("/root/send/search/drugcd", tmp2[i]); } if (tmp1[i] == "goodnm") { model.setValue("/root/send/search/drugnm", tmp2[i]); } } } else { model.setValue("/root/send/search/drugcd", ""); model.setValue("/root/send/search/drugnm", ""); } model.setValue("/root/temp/usrSelectDrugcd", ""); ipt_goodcd.refresh(); opt_goodnm.refresh(); } // -------------------------------------------------------------- // ºÎ¼­ ¼±Åýà »óºñ¾àǰ Á¶È¸ ó¸® // -------------------------------------------------------------- function fSearchStockList() { var selRow = grd_dept.row; if (grd_dept.isCell(event.target) && selRow > 0) { if(grd_dept.col != grd_dept.colRef("chk")){ var deptcd = model.getValue("/root/main/deptdata/item["+selRow+"]/deptcd"); var deptnm = model.getValue("/root/main/deptdata/item["+selRow+"]/deptnm"); var allsizespecid = model.getValue("/root/main/deptdata/item["+selRow+"]/allsizespecid"); model.setValue("/root/send/search/deptcd" , deptcd); model.setValue("/root/send/search/deptnm" , deptnm); model.setValue("/root/send/search/allsizespecid", allsizespecid); fSearch(); model.refresh(); } } } // -------------------------------------------------------------- // ºÎ¼­ »óºñ¾àǰ ÀÌ·Â Á¶È¸ // -------------------------------------------------------------- function fSearchHistory() { if (grd_stock.isCell(event.target) && grd_stock.row > 0) { } } // -------------------------------------------------------------- // ºÎ¼­ »óºñ¾àǰ º¯°æ½Ã ÀúÀåó¸® // -------------------------------------------------------------- function fSave() { model.setValue("/root/send/saveData", grd_stock.getUpdateData()); if (model.getValue("/root/send/saveData").split("¢Ì").length < 3) { } else { var chkData = model.getValue("/root/send/saveData"); var tmpData = chkData.split("¢Ì"); var tmpHeader = tmpData[0].split("¢Ë"); var submitType = true; // alert(tmpData); for (var i = 1; i < tmpData.length; i++) { tmpChkData = tmpData[i].split("¢Ë"); // ºÎ¼­ // alert(tmpChkData[grd_stock.colRef("reqdeptcd")+1]+"===>>"+grd_stock.colRef("reqdeptcd")); if (tmpChkData[grd_stock.colRef("reqdeptcd")+1] == "") { messageBox("ºÎ¼­´Â ", "I003"); submitType = false; break; } // ¾àǰ if (tmpChkData[grd_stock.colRef("goodcd")+1] == "") { messageBox("»óǰÄÚµå´Â ", "I003"); submitType = false; break; } // ¼ö·® if (tmpChkData[grd_stock.colRef("drugqty")+1] == "") { messageBox("¼ö·®Àº ", "I003"); submitType = false; break; } //º¯°æ »çÀ¯ /*if (tmpChkData[grd_stock.colRef("modifyreason")+1] == "") { messageBox("º¯°æ»çÀ¯´Â ", "I003"); submitType = false; break; }*/ } if (submitType) { misfSave("TXRSC09001"); var tmpDeptcd = model.getValue("/root/send/search/deptcd"); var tmpAllsize= model.getValue("/root/send/search/allsizespecid"); model.setValue("/root/send/search/deptcd", ""); model.setValue("/root/send/search/allsizespecid", ""); submit('TRRSC09001'); model.setValue("/root/send/search/deptcd" , tmpDeptcd); model.setValue("/root/send/search/allsizespecid", tmpAllsize); fSearch(); } } } // -------------------------------------------------------------- // ºÎ¼­ »óºñ¾àǰ Excel ÀúÀåó¸® // -------------------------------------------------------------- function fSaveExcel() { var files = window.fileDialog("save","|", true, "ºÎ¼­º°»óºñ¾àǰÁ¡°Ë³»¿ª_"+getCurrentDate(),"xls","Excel Files(*.xls)|*.xls"); // var filesarr= files.split("\\"); // var filenm = filesarr[filesarr.length-1]; // var filepath= files.split(filenm); if (files != "") { var sendPath = "/root/send/search"; var ptxt = ""; ptxt += "&instcd=" + model.getValue(sendPath+"/instcd" ); ptxt += "&deptcd=" + model.getValue(sendPath+"/deptcd" ); ptxt += "&lrgcd=" + model.getValue(sendPath+"/lrgcd" ); ptxt += "&mdlcd=" + model.getValue(sendPath+"/mdlcd" ); ptxt += "&smlcd=" + model.getValue(sendPath+"/smlcd" ); ptxt += "&drugcd=" + model.getValue(sendPath+"/drugcd" ); ptxt += "&drugtxt=" + model.getValue(sendPath+"/drugtxt" ); ptxt += "&allsizespecid=" + model.getValue(sendPath+"/allsizespecid"); // try { model.download(getActionURL("TRRSC09004")+ptxt, files, false); } catch(e) { } } } // -------------------------------------------------------------- // ºÎ¼­ »óºñ¾àǰ ÀÌ·Â Excel ÀúÀåó¸® // -------------------------------------------------------------- function fSaveHistoryExcel() { var file = window.fileDialog("save","","false","","xls","Excel Files(*.xls)|*.xls"); if (file != "") { grd_history.saveExcel(file); } } // -------------------------------------------------------------- // ºÎ¼­ »óºñ¾àǰ Ãß°¡ ó¸® // -------------------------------------------------------------- function fAddRow() { misfGridIUD(grd_stock, "A"); grd_stock.row = grd_stock.rows - grd_stock.fixedRows ; grd_stock.col = grd_stock.colRef("goodcd"); model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/reqdeptcd", model.getValue(ipt_deptcd.attribute("ref"))); model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/reqdeptnm", model.getValue(opt_deptnm.attribute("ref"))); model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/drugflag" , model.getValue(rdo_drugflag.attribute("ref"))); if (model.getValue(ipt_allsizespecid.attribute("ref")) != "-") { model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/cmt" , model.getValue(opt_deptnm.attribute("ref"))); model.setValue(grd_stock.nodeset +"[" + grd_stock.row + "]/allsizespecid", model.getValue(ipt_allsizespecid.attribute("ref"))); } // grd_stock.colDisabled(grd_stock.colRef("goodcd")) = true; grd_stock.isReadOnly( grd_stock.row , grd_stock.col, grd_stock.row, grd_stock.col) = false; //Àüü Grid ReadOnly false grd_stock.editCell(); } // -------------------------------------------------------------- // ºÎ¼­ »óºñ¾àǰ Row Copy ó¸® // -------------------------------------------------------------- function fRowCopy() { var selRow = grd_stock.row; grd_stock.insertRow(selRow,"below"); var copyPath = "/root/main/stockdata/item["+(selRow+1)+"]"; model.copyNode(copyPath , grd_stock.nodeset +"["+selRow+"]"); model.setValue(copyPath + "/drugqty" , ""); model.setValue(copyPath + "/lastupdt", ""); grd_stock.refresh(); } // -------------------------------------------------------------- // ºÎ¼­ »óºñ¾àǰ Row »èÁ¦ ó¸® // -------------------------------------------------------------- function fDelRow() { var deleteRowIdx = grd_stock.row; var rowStatus = grd_stock.rowStatus(deleteRowIdx); if (rowStatus == 1 || rowStatus == 3 || rowStatus == 5) { if (deleteRowIdx > -1) { grd_stock.deleteRow(deleteRowIdx, true); } } else { grd_stock.addStatus(deleteRowIdx,"delete"); // model.setValue(grd_stock.nodeset +"["+deleteRowIdx+"]/modifyreason", ""); } } // -------------------------------------------------------------- // ºÎ¼­ »óºñ¾àǰ³»¿ª OnClick ó¸® // -------------------------------------------------------------- function fOperationStockGrid() { if (grd_stock.isCell(event.target) && grd_stock.row >= grd_stock.fixedRows ) { var tmpChk = model.getValue(grd_stock.nodeset +"["+grd_stock.row+"]/lastupdt"); var selCol = grd_stock.col; if (tmpChk == "") { if (selCol == grd_stock.colRef("reqdeptcd")) { model.setValue("/root/target/recvref", "/root/target/recvitem[1]"); modal( "SPRPZ00200", 0, 100, 150, "SPRPZ00200", "/root/target", "/root/target" ); model.setValue(grd_stock.nodeset +"["+grd_stock.row+"]/reqdeptcd", model.getValue("/root/target/recvitem/reqdeptcd")); model.setValue(grd_stock.nodeset +"["+grd_stock.row+"]/reqdeptnm", model.getValue("/root/target/recvitem/reqdeptnm")); model.setValue("/root/target/recvitem/reqdeptcd", ""); model.setValue("/root/target/recvitem/reqdeptnm", ""); grd_stock.refresh(); } else if ((selCol == grd_stock.colRef("goodcd")) || (selCol == grd_stock.colRef("goodnm")) ){ modal("SPRSC09000", 0, 100, 150, "SPRSC09000", "/root/temp/receivedata", "/root/target"); var usrSelVal = model.getValue("/root/temp/usrSelectDrugcd"); if (usrSelVal != "") { var tmp = usrSelVal.split("¢Ì"); var tmp1 = tmp[0].split("¢Ë"); var tmp2 = tmp[1].split("¢Ë"); for (var i = 0; i < tmp1.length; i++) { if (tmp1[i] != "") { try { model.setValue(grd_stock.nodeset +"["+grd_stock.row+"]/"+tmp1[i], tmp2[i]); } catch(e) { } } } model.setValue("/root/temp/usrSelectDrugcd", ""); grd_stock.refresh(); } } } else { if (selCol != 9 && selCol != 12 && selCol != 14 && selCol != 15 && selCol != 16) { var tmpDrugcd = model.getValue("/root/send/search/drugcd"); var searchDrugcd = model.getValue("/root/main/stockdata/item["+grd_stock.row+"]/goodcd"); model.setValue("/root/send/search/drugcd", searchDrugcd); submit("TRRSC09003"); model.setValue("/root/send/search/drugcd", tmpDrugcd); ipt_goodcd.refresh(); } } } } // -------------------------------------------------------------- // ºÎ¼­ »óºñ¾àǰ³»¿ª Value-Changed ó¸® // -------------------------------------------------------------- function fStockChangeReasonReset() { var selRow = grd_stock.row; var selCol = grd_stock.col; if (selCol != 15) { model.setValue("/root/main/stockdata/item["+selRow+"]/modifyreason", ""); } } // -------------------------------------------------- // View Option ó¸®ÇÏ´Â ÇÔ¼ö // -------------------------------------------------- function fSumViewOption(pGrid,pOption, pCol) { pGrid.colHidden(pGrid.colRef(pCol)) = (pOption.value =="Y") ? false : true; } /* ------------------------------------------------- */ /* ------End Of List ------------------------------- */ /* -------------------------------------------------- */