<%--
  - Name   : PSR.jsp
  - Author(s)  : gyeongmo an
  - Date       : 2014.09.03
  - Copyright  : Copyright (c) 2014 www.udapsoft.co.kr, Inc.
  - Description: PSR
  --%>
  
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.udapsoft.common.code.CommCodeManager" %>
<%@ page import="com.udapsoft.waf.common.util.DateUtil" %>

<%@ include file="/jsp/work/taglib.jsp" %>

<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />

<%
    ctx.init(request, response);
    HandlerStorage storage = ctx.getHandlerStorage();
    ValueObject params = storage.getParams();
    ValueObject user = storage.getUser();
    String fevent = storage.getEvent();
    
    RowSet psrActivityCodeRowSet = storage.getRowSet("psrActivityCodeRowSet");
    
    String today = DateUtil.formatDateTime(DateUtil.getToday(), "yyyyMMdd", "yyyyMMdd");
%>

<SCRIPT language="JavaScript">
/*예약함수*/
var sheet1;
var sheet1Row;
var sheet1PageNo = 1;
var sheet2;
var sheet2Row;
var sheet2PageNo = 1;
var sheet3;
var sheet3Row;
var sheet3PageNo = 1;
var sheet4;
var sheet4Row;
var sheet4PageNo = 1;
var pageLastRowIndex = 1;
var validationResult = false;
var filterShow = false;
var newYn = "N";
var selectRow = 0;

function _onReady(){
	var f= document.form1;

	//$("#btnExcelSave").css("display", "none");
	
	 $("#sheet3_div").hide();
	 $("#sheet4_div").hide();
	
	gridInit(sheet1);
	gridInit(sheet2);
	gridInit(sheet3);	// excel upload 용도
	gridInit(sheet4);	// excel sample 용도

	jQuery("#btnSearch").click(function() {
		selectRow = 2;
		
		if(jQuery("#dept_cd").val() == "" && jQuery("#fevent").val() != "SAVE_PSR_EXCEL") {
			alert("현장을 선택해 주세요.");
			return;
		}
		
		newYn = "N";
		sheet2.RemoveAll();

		jQuery("#fevent").val("GET_PSR");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/PSR_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 10, "");
	});
	
	jQuery("#btnAdd").click(function() {
		if(f.dept_cd.value == "") {
			alert("현장을 선택하세요.");
			return;
		}
		f.p_discipline2.value = "";
		f.p_mr_no2.value = "";
		f.remarks2.value = "";
		newYn = "Y";
		
		sheet2.RemoveAll();
		
		<%
			for(int i=0; i<psrActivityCodeRowSet.size(); i++) {
		%>
			var Row = sheet2.DataInsert(-1);
			sheet2.SetCellValue(Row, "status", "I");
			sheet2.SetCellValue(Row, "psr_activity_nm", "<%=psrActivityCodeRowSet.getRow(i).get("psr_activity_name")%>");
			sheet2.SetCellValue(Row, "psr_activity_cd", "<%=psrActivityCodeRowSet.getRow(i).get("psr_activity_cd")%>");
			sheet2.SetCellValue(Row, "weight_factor", "<%=psrActivityCodeRowSet.getRow(i).get("psr_activity_std_wf")%>");
		<%
			}
		%>
	});

	
	jQuery("#btnSave").click(function() {
		var f= document.form1;
		
		if(sheet1.RowCount("D") > 0 ) {
			if(confirm("삭제하시겠습니까?")) {
				jQuery("#fevent").val("DELETE_PSR");
				var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/PSR_sheet.screen";
				Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), 10, "");	
			}
			
		} else {
			if(f.p_discipline2.value == "") {
				alert("Discipline을 선택해 주세요.");
				f.p_discipline2.focus();
				return;
			} 
			if(f.p_mr_no2.value == "") {
				alert("MR No을 입력해 주세요.");
				f.p_mr_no2.focus();
				return;
			} 
			
			
			if(confirm("저장하시겠습니까?")) {
				if(newYn == "Y") {
					jQuery("#fevent").val("SAVE_PSR");
				} else {
					jQuery("#fevent").val("UPDATE_PSR");	
				}
				
				var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/PSR_sheet.screen";
				Modular.view.IBSheet7.doSave(sheet2, url, jQuery("#form1"), 10, "");	
			}			
		}
	});
	
	
	jQuery("#btnExcelSave").click(function() {
		if(sheet3.RowCount() < 1) {
			alert("먼저 업로드 해주세요.");
			return;
		}
		
		if( sheet1.GetCellValue(2, "dept_cd") != document.form1.dept_cd.value ) {
			alert("엑셀의 현장과 화면의 Project를 맞춰주시기 바랍니다.");
			return;
		}
	
		savePSRExcel();
	});
	
	
	jQuery("#btnUpload").click(function() {
		sheet3.RemoveAll();

		/* 
		sheet3.LoadExcel({ExtendParam:'a=discipline_nm & b=mr_no & c=ord_doc_no & d=mr_desc & e=corp_name & f=ir_rcv & ' +
			' g=inq_iss & h=bid_due & i=quot_rcv & j=tbe_rcv & k=cbe_com & l=pr_rcv & m=po_iss & n=po_del & o=inspection ' + 
			' & p=po_ship & q=etd & r=atd & s=vp_in & t=vp_out & u=so & v=rm & w=fab & x=delivery & y=remarks'});
 */
		var vColumnMapping = "0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|0|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24";
 
 			/* sheet3.LoadExcel({Mode:'HeaderSkip', ColumnMapping:'discipline_nm|mr_no|ord_doc_no|mr_desc|corp_name|ir_rcv|inq_iss|bid_due|quot_rcv|etd|atd|vp_in|vp_out|so|rm|fab|delivery|remarks'}); */ 
		//sheet3.LoadExcel({Mode:'HeaderSkip', ColumnMapping:vColumnMapping});
		sheet3.LoadExcel({Mode : "NoHeader", ColumnMapping:vColumnMapping, StartRow:"4"});
	});
	
	
	jQuery("#btnSample").click(function() {
		if(sheet4.RowCount() < 1) {
			sheet4.DataInsert(-1);
		}
		
		var params = { FileName : "PSR_Sample.xls",  SheetName : "PSR_Sample", SheetDesign:0, Merge:1, DownCols:"discipline_nm|mr_no|ord_doc_no|corp_name|ir_rcv|inq_iss|bid_due|quot_rcv|tbe_rcv|cbe_com|"+
				"pr_rcv|po_iss|po_del|po_ship|etd|atd|onsite|vp_in|vp_out|so|rm|fab|delivery|inspection|remarks|discipline|psr_id|corp_id|demanded_id|pur_cont_id|dept_cd"
				, TitleText:"PSR_SAMPLE", UserMerge:"0,0,1,31", AutoSizeColumn:1};

		sheet4.Down2Excel(params);
	});
	
	jQuery("#btnExcel").click(function(){
		if(sheet1.RowCount() == 0) {
			alert("내역이 없습니다.");
			return;
		}

		var params = { FileName : "PSR.xls",  SheetName : "PSR", SheetDesign:1, Merge:1, DownCols:"discipline_nm|mr_no|ord_doc_no|corp_name|ir_rcv|inq_iss|bid_due|quot_rcv|tbe_rcv|cbe_com|"+
				"pr_rcv|po_iss|po_del|po_ship|etd|atd|onsite|vp_in|vp_out|so|rm|fab|delivery|inspection|remarks|discipline|psr_id|corp_id|demanded_id|pur_cont_id|dept_cd"
				, TitleText:"PSR", UserMerge:"0,0,1,31", AutoSizeColumn:1, HiddenColumn:1};
		
		sheet1.Down2Excel(params);
	});
	
	jQuery("#btnRecount").click(function(){
		if(confirm("재집계 하시겠습니까?")) {
			submitXmlRequest("/process/process/PSR_form.screen", "RECOUNT", document.form1);
		}
	});

	
	sheet1.SetActionMenu("ExcelDown");
	autoResize();
}


function gridInit(sheetName){
	var init_sheet = {};
	init_sheet.Cfg = {SearchMode:2, Page:10, MergeSheet:msHeaderOnly};
	
	if(sheetName.id == "sheet1") {
		init_sheet.Cols = [
			       			{Header:'status',	Type:"Status",	SaveName:"status",		Width:0, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			/* {Header:'선택|선택',	Type:"CheckBox",	SaveName:"check",		Width:50, 	Align:"Center"}, */
			       			{Header:'Del|Del',	Type:"DelCheck",	SaveName:"del_check",		Width:50, 	Align:"Center", ColMerge:"True"},
			       			{Header:'Discipline|Discipline',	Type:"Text",	SaveName:"discipline_nm",		Width:100, 	Align:"Center", Edit:"false", ColMerge:"True"},
			    			{Header:'MR Number|MR Number',	Type:"Text",	SaveName:"mr_no",		Width:100, 	Align:"Left", Edit:"false"},
			    			{Header:'PO Number|PO Number',	Type:"Text",	SaveName:"ord_doc_no",		Width:110, 	Align:"Left", Edit:"false"},
			       			{Header:'Vendor|Vendor',	Type:"Text",	SaveName:"corp_name",		Width:70, 	Align:"Left", Edit:"False"},
			       			{Header:'Biding Info|IR Receive',	Type:"Date",	SaveName:"ir_rcv",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Biding Info|Inq Issue',	Type:"Date",	SaveName:"inq_iss",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Biding Info|Bid due Date',	Type:"Date",	SaveName:"bid_due",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Biding Info|Quot Receive',	Type:"Date",	SaveName:"quot_rcv",		Width:70, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Biding Info|TBE Commit',	Type:"Date",	SaveName:"tbe_rcv",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Biding Info|CBE Commit',	Type:"Date",	SaveName:"cbe_com",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Contract Amount|PR Receive',	Type:"Date",	SaveName:"pr_rcv",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Contract Amount|PO Issue',	Type:"Date",	SaveName:"po_iss",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Contract Amount|PO Delivery',	Type:"Date",	SaveName:"po_del",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Fowarding|Shipping',	Type:"Date",	SaveName:"po_ship",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Fowarding|POL',	Type:"Date",	SaveName:"etd",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Fowarding|POD',	Type:"Date",	SaveName:"atd",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Fowarding|onSite',	Type:"Date",	SaveName:"onsite",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'WPR|VP in',	Type:"Date",	SaveName:"vp_in",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'WPR|VP Out',	Type:"Date",	SaveName:"vp_out",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'WPR|Sub Order',	Type:"Date",	SaveName:"so",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'WPR|Receive Material',	Type:"Date",	SaveName:"rm",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'WPR|Fabrication',	Type:"Date",	SaveName:"fab",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'WPR|Delivery',	Type:"Date",	SaveName:"delivery",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'WPR|Inspection',	Type:"Date",	SaveName:"inspection",		Width:70, 	Align:"Center", Format:"yy-MM-dd", Edit:"false"},
			       			{Header:'Remarks|Remarks',	Type:"Text",	SaveName:"remarks",		Width:100, 	Align:"Left", Edit:"false"},
			       			{Header:'System Infomation|discipline',	Type:"Text",	SaveName:"discipline",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'System Infomation|psr_id',	Type:"Text",	SaveName:"psr_id",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'System Infomation|corp_id',	Type:"Text",	SaveName:"corp_id",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'System Infomation|demanded_id',	Type:"Text",	SaveName:"demanded_id",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'System Infomation|pur_cont_id',	Type:"Text",	SaveName:"pur_cont_id",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'System Infomation|dept_cd',	Type:"Text",	SaveName:"dept_cd",		Width:50, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'status2|status2',	Type:"Text",	SaveName:"status2",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|IR Receive',	Type:"Date",	SaveName:"ir_rcv_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|Inq Issue',	Type:"Date",	SaveName:"inq_iss_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|Bid Due Date',	Type:"Date",	SaveName:"bid_due_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|Quot Receive',	Type:"Date",	SaveName:"quot_rcv_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|TBE Commit',	Type:"Date",	SaveName:"tbe_rcv_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|CBE Commit',	Type:"Date",	SaveName:"cbe_com_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Contract AMOUNT|PR Receive',	Type:"Date",	SaveName:"pr_rcv_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Contract AMOUNT|PO Issue',	Type:"Date",	SaveName:"po_iss_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Contract AMOUNT|PO Delivery',	Type:"Date",	SaveName:"po_del_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Fowarding|Shipping',	Type:"Date",	SaveName:"ship_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Fowarding|POL',	Type:"Date",	SaveName:"pod_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Fowarding|POD',	Type:"Date",	SaveName:"pol_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Fowarding|onSite',	Type:"Date",	SaveName:"onsite_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|VP In',	Type:"Date",	SaveName:"vp_in_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|VP Out',	Type:"Date",	SaveName:"vp_out_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|Sub Order',	Type:"Date",	SaveName:"sub_order_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|Receive Material',	Type:"Date",	SaveName:"receive/material_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|Fabrication',	Type:"Date",	SaveName:"fabrication_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|Delivery',	Type:"Date",	SaveName:"delivery_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|Inspection',	Type:"Date",	SaveName:"final_inspection_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'MR Title|MR Title',	Type:"Text",	SaveName:"mr_desc",		Width:70, 	Align:"Left", Edit:"False", Hidden:"True"},
			       			{Header:'flag_yn|flag_yn',	Type:"Text",	SaveName:"flag_yn",		Width:70, 	Align:"Left", Edit:"False", Hidden:"True"}
		];
	} else if (sheetName.id == "sheet2") {
		init_sheet.Cols = [
			       			{Header:'status',	Type:"Status",	SaveName:"status",		Width:0, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Activity|Activity',	Type:"Text",	SaveName:"psr_activity_nm",		Width:110, 	Align:"Left", Edit:"false"},
			       			{Header:'psr_activity_cd|psr_activity_cd',	Type:"Text",	SaveName:"psr_activity_cd",		Width:0, 	Align:"Center", Hidden:"True"},
			       			{Header:'Schedule|Plan',	Type:"Date",	SaveName:"plan_dt",		Width:110, 	Align:"Center"},
			       			{Header:'Schedule|Fore',	Type:"Date",	SaveName:"forecasting_dt",		Width:110, 	Align:"Center"},
			       			{Header:'Schedule|Act',	Type:"Date",	SaveName:"actual_dt",		Width:100, 	Align:"Center", Edit:"false"},
			       			{Header:'weight_factor|weight_factor',	Type:"Text",	SaveName:"weight_factor",		Width:0, 	Align:"Center", Hidden:"True"},
			       			{Header:'psr_id|psr_id',	Type:"Text",	SaveName:"psr_id",		Width:70, 	Align:"Center", Hidden:"True"},
			       			{Header:'mr_no|mr_no',	Type:"Text",	SaveName:"mr_no",		Width:70, 	Align:"Center", Hidden:"True"},
			       			{Header:'demanded_id|demanded_id',	Type:"Text",	SaveName:"demanded_id",		Width:70, 	Align:"Center", Hidden:"True"},
			       			{Header:'pur_cont_id|pur_cont_id',	Type:"Text",	SaveName:"pur_cont_id",		Width:70, 	Align:"Center", Hidden:"True"},
			       			{Header:'dept_cd|dept_cd',	Type:"Text",	SaveName:"dept_cd",		Width:70, 	Align:"Center", Hidden:"True"}
		];
	} else if (sheetName.id == "sheet3") {
		init_sheet.Cols = [
			       			{Header:'status',	Type:"Status",	SaveName:"status",		Width:0, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			/* {Header:'선택|선택',	Type:"CheckBox",	SaveName:"check",		Width:50, 	Align:"Center"}, */
			       			{Header:'Discipline/Item|Discipline/Item',	Type:"Text",	SaveName:"discipline_nm",		Width:80, 	Align:"Center", Edit:"false", ColMerge:"True"},
			    			{Header:'MR Number|MR Number',	Type:"Text",	SaveName:"mr_no",		Width:100, 	Align:"Center", Edit:"false"},
			    			{Header:'PO Number|PO Number',	Type:"Text",	SaveName:"ord_doc_no",		Width:110, 	Align:"Left", Edit:"false"},
			       			{Header:'Vendor|Vendor',	Type:"Text",	SaveName:"corp_name",		Width:70, 	Align:"Left", Edit:"False"},
			       			{Header:'Biding Info|I/R RCV',	Type:"Date",	SaveName:"ir_rcv",		Width:60, 	Align:"Center", Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'Biding Info|INQ-ISS',	Type:"Date",	SaveName:"inq_iss",		Width:60, 	Align:"Center", Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'Biding Info|BID-DUE',	Type:"Date",	SaveName:"bid_due",		Width:60, 	Align:"Center", Edit:"false", Format:"yy-MM-dd" },
			       			{Header:'Biding Info|QUOT-RCV',	Type:"Date",	SaveName:"quot_rcv",		Width:60, 	Align:"Center", Edit:"false", Format:"yy-MM-dd" },
			       			{Header:'Biding Info|TBE-RCV',	Type:"Date",	SaveName:"tbe_rcv",		Width:60, 	Align:"Center", Edit:"false", Format:"yy-MM-dd" },
			       			{Header:'Biding Info|CBE-COM',	Type:"Date",	SaveName:"cbe_com",		Width:60, 	Align:"Center", Edit:"false", Format:"yy-MM-dd" },
			       			{Header:'Contract AMOUNT|P/R-RCV',	Type:"Date",	SaveName:"pr_rcv",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'Contract AMOUNT|P/O-ISS',	Type:"Date",	SaveName:"po_iss",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'Contract AMOUNT|PO DEL',	Type:"Date",	SaveName:"po_del",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'Fowarding|P/O SHIP',	Type:"Date",	SaveName:"ship",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'Fowarding|ETD_POL',	Type:"Date",	SaveName:"pod",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'Fowarding|ETA_POD',	Type:"Date",	SaveName:"pol",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'Fowarding|onSite',	Type:"Date",	SaveName:"onsite",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'WPR|VP IN',	Type:"Date",	SaveName:"vp_in",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'WPR|VP OUT',	Type:"Date",	SaveName:"vp_out",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'WPR|S/O',	Type:"Date",	SaveName:"sub_order",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'WPR|R/M',	Type:"Date",	SaveName:"receive/material",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'WPR|Fab',	Type:"Date",	SaveName:"fabrication",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'WPR|Delivery',	Type:"Date",	SaveName:"delivery",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'WPR|Inspection',	Type:"Date",	SaveName:"inspection",		Width:60, 	Align:"Center" , Edit:"false", Format:"yy-MM-dd"},
			       			{Header:'Remarks|Remarks',	Type:"Text",	SaveName:"remarks",		Width:100, 	Align:"Left", Edit:"false"},
			       			{Header:'discipline|discipline',	Type:"Text",	SaveName:"discipline",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'psr_id|psr_id',	Type:"Text",	SaveName:"psr_id",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'corp_id|corp_id',	Type:"Text",	SaveName:"corp_id",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'demanded_id|demanded_id',	Type:"Text",	SaveName:"demanded_id",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'pur_cont_id|pur_cont_id',	Type:"Text",	SaveName:"pur_cont_id",		Width:0, 	Align:"Left", Edit:"false", Hidden:"True"},
			       			{Header:'dept_cd|dept_cd',	Type:"Text",	SaveName:"dept_cd",		Width:50, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'status2|status2',	Type:"Text",	SaveName:"status2",		Width:50, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|I/R RCV',	Type:"Date",	SaveName:"ir_rcv_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|INQ-ISS',	Type:"Date",	SaveName:"inq_iss_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|BID-DUE',	Type:"Date",	SaveName:"bid_due_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|QUOT-RCV',	Type:"Date",	SaveName:"quot_rcv_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|TBE-RCV',	Type:"Date",	SaveName:"tbe_rcv_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Biding Info|CBE-COM',	Type:"Date",	SaveName:"cbe_com_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Contract AMOUNT|P/R-RCV',	Type:"Date",	SaveName:"pr_rcv_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Contract AMOUNT|P/O-ISS',	Type:"Date",	SaveName:"po_iss_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Contract AMOUNT|PO DEL',	Type:"Date",	SaveName:"po_del_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Fowarding|P/O SHIP',	Type:"Date",	SaveName:"ship_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Fowarding|ETD_POL',	Type:"Date",	SaveName:"pod_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Fowarding|ETA_POD',	Type:"Date",	SaveName:"pol_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'Fowarding|onSite',	Type:"Date",	SaveName:"onsite_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|VP IN',	Type:"Date",	SaveName:"vp_in_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|VP OUT',	Type:"Date",	SaveName:"vp_out_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|S/O',	Type:"Date",	SaveName:"sub_order_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|R/M',	Type:"Date",	SaveName:"receive/material_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|Fab',	Type:"Date",	SaveName:"fabrication_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|Delivery',	Type:"Date",	SaveName:"delivery_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'WPR|Inspection',	Type:"Date",	SaveName:"final_inspection_h",		Width:60, 	Align:"Center", Edit:"false", Hidden:"True"},
			       			{Header:'MR Title|MR Title',	Type:"Text",	SaveName:"mr_desc",		Width:70, 	Align:"Left", Edit:"False", Hidden:"True"}
		];
	} else if ( sheetName.id == "sheet4" ) {
		init_sheet.Cols = [
			       			/* {Header:'선택|선택',	Type:"CheckBox",	SaveName:"check",		Width:50, 	Align:"Center"}, */
			       			{Header:'Discipline|Discipline',	Type:"Text",	SaveName:"discipline_nm",		Width:80, 	Align:"Center", Edit:"false", ColMerge:"True", DefaultValue:"사업관리"},
			    			{Header:'MR Number|MR Number',	Type:"Text",	SaveName:"mr_no",		Width:100, 	Align:"Center", Edit:"false", DefaultValue:"MR-111"},
			    			{Header:'PO Number|PO Number',	Type:"Text",	SaveName:"ord_doc_no",		Width:110, 	Align:"Left", Edit:"false", DefaultValue:"PO-111"},
			       			{Header:'MR Title|MR Title',	Type:"Text",	SaveName:"mr_desc",		Width:70, 	Align:"Left", Edit:"False", DefaultValue:"MR샘플입니다."},
			       			{Header:'Vendor|Vendor',	Type:"Text",	SaveName:"corp_name",		Width:70, 	Align:"Left", Edit:"False", DefaultValue:"거래처명"},
			       			{Header:'Biding Info|IR Receive',	Type:"Date",	SaveName:"ir_rcv",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Biding Info|Inq Issue',	Type:"Date",	SaveName:"inq_iss",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Biding Info|Bid Due Date',	Type:"Date",	SaveName:"bid_due",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Biding Info|Quot Receive',	Type:"Date",	SaveName:"quot_rcv",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Biding Info|TBE Commit',	Type:"Date",	SaveName:"tbe_rcv",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Biding Info|CBE Commit',	Type:"Date",	SaveName:"cbe_com",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Contract AMOUNT|PR Receive',	Type:"Date",	SaveName:"pr_rcv",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Contract AMOUNT|PO Issue',	Type:"Date",	SaveName:"po_iss",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Contract AMOUNT|PO Delivery',	Type:"Date",	SaveName:"po_del",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Fowarding|Shipping',	Type:"Date",	SaveName:"po_ship",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Fowarding|POL',	Type:"Date",	SaveName:"etd",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Fowarding|POD',	Type:"Date",	SaveName:"atd",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Fowarding|onSite',	Type:"Date",	SaveName:"onsite",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'WPR|VP In',	Type:"Date",	SaveName:"vp_in",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'WPR|VP Out',	Type:"Date",	SaveName:"vp_out",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'WPR|Sub Order',	Type:"Date",	SaveName:"so",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'WPR|Receive Material',	Type:"Date",	SaveName:"rm",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'WPR|Fabrication',	Type:"Date",	SaveName:"fab",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'WPR|Inspection',	Type:"Date",	SaveName:"inspection",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'WPR|Delivery',	Type:"Date",	SaveName:"delivery",		Width:60, 	Align:"Center", Format:"yy-MM-dd", Edit:"false", DefaultValue:"20140314"},
			       			{Header:'Remarks|Remarks',	Type:"Text",	SaveName:"remarks",		Width:100, 	Align:"Left", Edit:"false", DefaultValue:"비고입니다."},
			       			{Header:'System Infomation|discipline',	Type:"Text",	SaveName:"discipline",		Width:0, 	Align:"Left", Hidden:"True", Edit:"false", DefaultValue:"000"},
			       			{Header:'System Infomation|psr_id',	Type:"Text",	SaveName:"psr_id",		Width:0, 	Align:"Left", Hidden:"True", Edit:"false", DefaultValue:"000"},
			       			{Header:'System Infomation|corp_id',	Type:"Text",	SaveName:"corp_id",		Width:0, 	Align:"Left", Hidden:"True", Edit:"false", DefaultValue:"000"},
			       			{Header:'System Infomation|demanded_id',	Type:"Text",	SaveName:"demanded_id",		Width:0, 	Align:"Left", Hidden:"True", Edit:"false", DefaultValue:"000"},
			       			{Header:'System Infomation|pur_cont_id',	Type:"Text",	SaveName:"pur_cont_id",		Width:0, 	Align:"Left", Hidden:"True", Edit:"false", DefaultValue:"000"},
			       			{Header:'System Infomation|dept_cd',	Type:"Text",	SaveName:"dept_cd",		Width:50, 	Align:"Center", Edit:"false", Hidden:"True", DefaultValue:"000"}
		];
	}
	
 
	init_sheet.HeaderMode = {Sort:1};
	IBS_InitSheet(sheetName, init_sheet);
	sheetName.SetDataAutoTrim(0);
	//setGridSize(sheetName);
}

function setGridSize(sheetName) {
	sheetName.FitColWidth();
}


function sheet1_OnSearchEnd(code, message) {
    if(code == 0) {
    	//setGridSize(sheet1);
		if(jQuery("#fevent").val() == "GET_TEMP_EXCEL_TABLE") {
	    	//$("#btnUpload").hide();
	    	//$("#btnExcelSave").show();
    	} else {
    		//$("#btnUpload").show();
    		//$("#btnExcelSave").hide();
    	}
		
		for(var i=0; i<sheet1.RowCount(); i++) {
    		if(sheet1.GetCellValue(i+2, "flag_yn") == "Y") {
    			sheet1.SetCellFontColor(i+2, "mr_no", "#CD1039");
    		}
    	}
		
    	sheet1.SetSelectRow(selectRow);
    	
    	if(sheet1.RowCount() > 0) { sheet1_OnClick(selectRow); };
	} else {
		//조회 에러 수행
		alert(message);
	}
    
/*   	sheet1.SetRangeBackColor(4,27,sheet1.RowCount+4,32,"#fffacd"); */
  	sheet1.SetRangeBackColor(2,27,sheet1.RowCount()+2,32,"#33CC66");
}

function sheet2_OnSearchEnd(code, message) {
    if(code == 0) {
    	newYn = "N";
    	
    	for(var i=0; i<sheet2.RowCount(); i++) {
    		if( sheet2.GetCellValue(i+2, "plan_dt") != "" ) {
    			if('<%=today%>' > sheet2.GetCellValue(i+2, "plan_dt") && sheet2.GetCellValue(i+2, "actual_dt") == "") {
      				sheet2.SetCellFontColor(i+2, "plan_dt", "#CD1039");
      			}	
    		}
    	}
    	
    	setGridSize(sheet2);
    	
	} else {
		//조회 에러 수행
		alert(message);
	}
}



function sheet1_OnClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
	var f= document.form1;
	selectRow = sheet1.GetSelectRow();
	
	if(Row < 2) return;
	
	
	if(sheet1.ColSaveName(0, Col) == "del_check") {
		if(sheet1.GetCellValue(Row, "demanded_id") != "" || sheet1.GetCellValue(Row, "pur_cont_id") != "") {
			/* 
			alert("발주의뢰 접수, 계약수립 이후에는 삭제할수 없습니다.");
			sheet1.SetCellValue(Row, "del_check", 0);
			return;
			 */
			
		}		
	} else {
		jQuery("#fevent").val("GET_PSR_DETAIL");
		jQuery("#psr_id").val(sheet1.GetCellValue(Row, "psr_id"));
		
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/PSR_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet2, url, jQuery("#form1"), 10, "");
		
		f.p_discipline2.value = sheet1.GetCellValue(Row, "discipline");
		f.p_mr_no2.value = sheet1.GetCellValue(Row, "mr_no");
		f.remarks2.value = sheet1.GetCellValue(Row, "remarks");
	}
	
}

function clearDiscipline() {
	var f= document.form1;
	f.p_discipline.value = "";
}

function clearDiscipline2() {
	var f= document.form1;
	f.p_discipline2.value = "";
}


function sheet2_OnSaveEnd(code, msg) {
    if(code >= 0) {
    	alert("저장 성공");
    } else {
    	alert("저장실패");
    }
    	newYn = "N";
    	//reloading();
		
    	newYn = "N";
		sheet2.RemoveAll();

		jQuery("#fevent").val("GET_PSR");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/PSR_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 10, "");
}

function sheet3_OnSaveEnd(code, msg) {
    if(code >= 0) {
		//alert("sheet3 저장성공!");
    } else {
    	//alert("sheet3 저장실패!");
    }
    
	//sheet3.RemoveAll();
	
	sheet2.RemoveAll();

	
	jQuery("#temp_excel_table_seq").val(sheet3.GetEtcData("ETC-DATA"));

	
	jQuery("#fevent").val("GET_TEMP_EXCEL_TABLE");
	
	var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/PSR_sheet.screen";
	Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 10, "");
}
	
function sheet1_OnSaveEnd(code, msg) {
    if(code >= 0) {
    	if(jQuery("#fevent").val() == "SAVE_PSR_EXCEL") {
        	alert("엑셀 업로드 성공");
        	//$("#btnUpload").show();
        	//$("#btnExcelSave").hide();
        }
    	if( jQuery("#fevent").val() == "DELETE_PSR" ) {
    		alert("삭제 성공");
    	}
    
    } else {
    	alert(msg);	
    
    }
    
    jQuery("#btnSearch").click();
    
}
	

function sheet3_OnLoadExcel(result) {
	
	  if(result) {
	    //alert("sheet3 엑셀 로딩이 완료되었습니다.");
	    // return;
	  } else {
		//alert("sheet3 엑셀 로딩중 오류가 발생하였습니다.");
		// return;
		}
	  checkValidation();
}

function checkValidation() {
	var temp = false;
	var temp2 = "";
	var temp3 = "";
	
	var temp2Cnt = 0;
	var temp3Cnt = 0;
	
	
	/* 
	
	jQuery("#fevent").val("SAVE_TEMP_EXCEL_TABLE");
	var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/PSR_sheet.screen";
	Modular.view.IBSheet7.doSave(sheet3, url, jQuery("#form1"), 10, "");
	 */
	
	
	
	// 무결성체크 (조건)
	/*
		1. discipline 없는 행 저장 안된다.
		2. pur_cont_id는 같은게 있으면 안된다.
		3. mr_no는 null이거나 blank 안된다.
		4. mr_no가 같을 경우 demanded_id가 다르면 안된다.
		5. 중복 check는 mr_no + pur_cont_id 가 같은게 있으면 안된다.
	
	*/
	for(var i=2; i<sheet3.RowCount()+2; i++) {
		// 조건 1.
		if(sheet3.GetCellValue(i, "discipline_nm") == "") {  //2017.07.21 discipline->discipline_nm 으로 변경 .text와 mapping안되면 default='사업관리'
			//alert("discipline이 없는 행이 존재합니다.");
			temp = true;
			temp2 += ", " + Number(i+1);
			temp2Cnt++;
		}	
	}
	
	
	// 조건2.
	if(sheet3.ColValueDup("pur_cont_id") > 0) {
		// 공백을 중복으로 체크할 경우는 제외한다.
		var returnRow = sheet3.ColValueDupRows("pur_cont_id", true, false);
		
		returnRow = returnRow.split(",");
	
		for(var i=0; i<returnRow.length; i++) {
			if(sheet3.GetCellValue(returnRow[i], "pur_cont_id") != "") {
				alert("계약번호가 동일 행 존재. 행 : " + Number(sheet3.ColValueDup("pur_cont_id") + 1));
				sheet3.RemoveAll();
				temp = false;
				return;		
			}	
		}
	}

	
	
	for(var i=2; i<sheet3.RowCount()+2; i++) {
		// 조건3.
		if(sheet3.GetCellValue(i, "mr_no") == "" || sheet3.GetCellValue(i, "mr_no") == null) {
			//alert("MR_NO가 없는 행이 존재합니다.");
			temp = true;
			temp3 += ", " + Number(i+1);
			temp3Cnt++;
		}
	}			
		
		
	// 조건4, 조건 5
	for(var i=2; i<sheet3.RowCount()+2; i++) {
		for(var j=2; j<sheet3.RowCount()+2; j++) {

			if(i == j) continue;
			
			if(sheet3.GetCellValue(i, "mr_no") == sheet3.GetCellValue(j, "mr_no") && sheet3.GetCellValue(i, "mr_no")!="") {
				// 조건4.
				if(sheet3.GetCellValue(i, "demanded_id") != sheet3.GetCellValue(j, "demanded_id")) {
					alert("MR_NO는 같고 발주ID 는 다른 자료 존재. 행 : " + Number(i+1) + ", " + Number(j+1));
					sheet3.RemoveAll();
					temp = false;
					return;
				}
				
				//조건5.		
				if(sheet3.GetCellValue(i, "pur_cont_id") == sheet3.GetCellValue(j, "pur_cont_id")) {
					alert("MR_NO도 같고 계약번호도 같은 자료 존재. 행 : " + Number(i+1) + ", " + Number(j+1));
					sheet3.RemoveAll();
					temp = false;
					return;
				}	
			}
		}
	}
	
	if(temp == true) {
		temp = false;
		sheet3.RemoveAll();
		
		if(temp2 != "") {
			if(temp2Cnt > 3) {
				var tempArray2 = temp2.replace(",", "").split(",");
				alert("discipline 없는 행 존재 : " + tempArray2[0] + ", " + tempArray2[1] + ", " + tempArray2[2] + " 외 " + Number(temp2Cnt -3) + "건");
			} else {
				alert("discipline 없는 행 존재 : " + temp2.replace(",", ""));
			}
			
			temp2 = "";
			temp2Cnt = 0;
			return;
		}

		if(temp3 != "") {
			if(temp3Cnt > 3) {
				var tempArray4 = temp3.replace(",", "").split(",");
				alert("MR NO 없는 행 존재 : " + tempArray4[0] + ", " + tempArray4[1] + ", " + tempArray4[2] + " 외 " + Number(temp3Cnt -3) + "건");
			} else {
				alert("MR NO 없는 행 존재 : " + temp3.replace(",", ""));
			}
			
			temp3 = "";
			temp3Cnt = 0;
			return;
		}

		
		/* 
		alert("Excel Upload 오류");
		return;
		 */
		
	} else {
		// 아무이상없으면 임시테이블에 저장
		jQuery("#fevent").val("SAVE_TEMP_EXCEL_TABLE");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/PSR_sheet.screen";
		Modular.view.IBSheet7.doSave(sheet3, url, jQuery("#form1"), 10, "");
	}
}


function savePSRExcel() {
	if(confirm("저장하시겠습니까?")) {
		sheet3.RemoveAll();
		
		newYn = "N";
		
		jQuery("#fevent").val("SAVE_PSR_EXCEL");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/PSR_sheet.screen";
		Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), 10, "");	
	}
	
}


function doResult(resultObj) {
	try {
		document.form1.isSubmit = false;
		if( resultObj.getRequestEvent() == "DELETE_TEMP_EXCEL_TABLE") {
			if( resultObj.getSuccess() ) {
				alert("삭제완료.");
				jQuery("#btnSearch").click();				
				
			}
			else {
				alert("삭제실패.");
				//dlgErrorMsg(resultObj);
			}
		} else if( resultObj.getRequestEvent() == "RECOUNT" ) {
			if( resultObj.getSuccess() ) {
				alert("재집계 성공");
				jQuery("#btnSearch").click();
			}
			else {
				alert("재집계 실패");
			}
		}
	}
	catch(errorObject) {
		showErrorDlg("doResult()", errorObject);
	}
}

function sheet1_OnSelectMenu(Text, Code) {
	switch(Text) {
		case "ExcelDown":
			jQuery("#btnExcel").click();
		break;
	}
}

	 function sheet1_OnSmartResize(Width, Height) { 
			//sheet1.FitColWidth();
			autoResize();
			
		}
	
	 function sheet2_OnSmartResize(Width, Height) { 
			//sheet2.FitColWidth();
			autoResize();
			
		}

	function autoResize(){

		var t1_height = document.getElementById("search-table").scrollHeight + document.getElementById("title").scrollHeight + document.getElementById("sheet_title").scrollHeight + 34;
		var iframeHeight= document.body.scrollHeight - t1_height;   
		
		sheet1.SetSheetHeight(iframeHeight);
		sheet2.SetSheetHeight(iframeHeight);

	}	
	
	document.body.onresize = addEvent( document.body.onresize, "autoResize()");
	
</SCRIPT>


<modular:search id="form1">
	<modular:key id="fevent" />
</modular:search>

<form id="form1" name="form1" method="post" modular:type="search" style="width:100%;height:100%;">
<INPUT type="hidden" name="fevent" id="fevent">
<INPUT type="hidden" name="psr_id" id="psr_id">
<INPUT type="hidden" name="temp_excel_table_seq" id="temp_excel_table_seq">


<div align="left" id="title">
    <ul>
     <li>Procurement Status Report</li>
    </ul>
  </div> 

		<table id="search-table" class="search-form-table">
			<colgroup>
				<col width="80" />
				<col width="200" />
				<col width="80" />
				<col width="120" />
				<col width="250" />
				<col width="80" />
				<col width="130" />
				<col width="80" />
				<col width="*" />
				<col width="80" />
			</colgroup>
			<tr>
				<th>Project</th>
				<td colspan="3">
			   		<%=InputText.getSiteCodeNew("dept_cd", "dept_nm", "", user, params.get("dept_cd"), params.get("dept_nm"))%>
				</td>
				<td class="button" rowspan="2">
						<span class="btnSearch center"><a href="javascript:void(0);" id="btnSearch">Search</a></span>
						<span class="btnSearch center"><a href="javascript:void(0);" id="btnUpload">upload</a></span>
						<span class="btnSearch center"><a href="javascript:void(0);" id="btnExcelSave">Excel Save</a></span>
						<p style="height:2px;"></p>
						<span class="btnSearch center"><a href="javascript:void(0);" id="btnSample">Sample</a></span>
						<span class="btnSearch center"><a href="javascript:void(0);" id="btnExcel">Excel</a></span>
						<span class="btnSearch center"><a href="javascript:void(0);" id="btnRecount">Recount</a></span>
				</td>
				<th>Discipline</th>
				<td>
					<%= CommCodeManager.getSelectCodeList("BAS_LVL02", "p_discipline2", "width:73%;height=18px;", "<OPTION value=''>-- 전체 --</OPTION>", params.get("discipline"), "") %>
					<IMG id='_btn_clear' onClick="clearDiscipline2();" src='/img/buyer/button/bt_eraser1.gif' border='0' align='absmiddle' alt='[초기화]' style='cursor:pointer;'>
				</td>
				<th>MR No</th>
				<td>
					<%= InputText.get("p_mr_no2", "", 85, 50, "hangule, desc=MR No, PerSize") %>
				</td>
				<td class="button" rowspan="2">
					<span class="btnSearch center"><a href="javascript:void(0);" id="btnAdd">New</a></span>
					<p style="height:2px;"></p>
					<span class="btnSearch center"><a href="javascript:void(0);" id="btnSave">Save</a></span>
				</td>
			</tr>
			<tr>
				<th>MR No</th>
				<td>
					<%= InputText.get("p_mr_no", "", 95, 50, "hangule, desc=MR No, PerSize") %>
				</td>
				<th>Discipline</th>
				<td>
					<%= CommCodeManager.getSelectCodeList("BAS_LVL02", "p_discipline", "width:73%;height=18px;", "<OPTION value=''>-- 전체 --</OPTION>", params.get("discipline"), "") %>
					<IMG id='_btn_clear' onClick="clearDiscipline();" src='/img/buyer/button/bt_eraser1.gif' border='0' align='absmiddle' alt='[초기화]' style='cursor:pointer;'>
				</td>
				<th>Remarks</th>
				<td colspan="3">
					<%= InputText.get("remarks2", "", 95, 50, "hangule, desc=remarks, PerSize") %>
				</td>
			</tr>
		</table>
	
	<TABLE id="sheet_title" border="0" cellspacing="0" cellpadding="0" width="100%">
		<tr>
			<td width="*">
				<div class="application-info magT10">
						<div class="application-sub-title">
							<span class="title">Plan List</span>
						</div>
						<div class="application-location">
						</div>
					</div>
			</td> 
			<td width="350px">
				<div class="application-info magT10">
					<div class="application-sub-title">
						<span class="title">Detail Description</span>
					</div>
					<div class="application-location">
					</div>
				</div>
			</td>
		</tr>
	</TABLE>
	
	<TABLE border="0" cellspacing="0" cellpadding="0" width="100%">
		<tr>
			<td width="*">
					<div id="sheet1_div" style="padding-top:5px; height: auto; min-height: 300px; overflow: auto;">
						<script>createIBSheet('sheet1','99%', '300px');</script>
					</div>
				<!-- <td width="20%"> -->
					<div id="sheet3_div" style="padding-top:5px; height: auto; min-height: 300px; overflow: auto;">
						<script>createIBSheet('sheet3','100%', '300px');</script>
					</div>
					<div id="sheet4_div" style="padding-top:5px; height: auto; min-height: 300px; overflow: auto;">
						<script>createIBSheet('sheet4','100%', '300px');</script>
					</div>
			</td>
			<td width="350px">
				<div id="sheet2_div" style="padding-top:5px; height: auto; min-height: 300px; overflow: auto;">
					<script>createIBSheet('sheet2','100%', '300px');</script>
				</div>
			</td>
		</tr>
	</TABLE>
	
				
</form>
	
	