<%--
  - FileName   : SuppSSRDetail.jsp
  - Author     : gyeongmo an
  - Date       : 2014.08.12
  - Copyright  : Copyright (c) www.udapsoft.co.kr, Inc.
  - All rights reserved.
--%>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.udapsoft.ebid.buyer.common.file.FileManager"%>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="com.udapsoft.waf.common.util.DateUtil" %>
<%@ page import="kr.co.udapsoft.common.code.CommCodeManager" %>
<%@ page import="java.text.*" %>
<%@ page import="com.udapsoft.waf.common.util.*" %>
<%@ page import="kr.co.hsnc.common.sql.util.RowSetUtility" %>   
<%@ include file="/jsp/work/taglib.jsp" %>
<jsp:useBean id="ctx" class="com.udapsoft.waf.system.context.SessionContext" scope="session" />

<%
DecimalFormat df = new DecimalFormat("###,###");
%>
<%
    ctx.init(request, response);
	String fevent = ctx.get("fevent");
	HandlerStorage storage = ctx.getHandlerStorage();

	ValueObject params = storage.getParams();
	ValueObject user = storage.getValueObject("User");
	
	ValueObject vo = storage.getValueObject("ssrDetail");
	
	//기타 첨부서류
	RowSet purchaseFileRow = storage.getRowSet("purchaseFileRow");
	
	// 첨부파일
	ValueObject vo_file = storage.getValueObject("SSR_DETAIL");
    

	String isModify = "";
	if(vo.get("shipping_id").equals("")) {
		isModify = "false";
	} else {
		isModify = "true";
	}
	
	String package_qty = "";
	
	String twenty_dc = "";
	String twenty_dt = "";
	String twenty_fr = "";
	String fourty_dc = "";
	String fourty_dt = "";
	String fourty_fr = "";
	String fourty_fft = "";
	String total = "";
	
	if(!vo.get("package_qty").equals(""))
	{
		package_qty = df.format(Integer.parseInt(vo.get("package_qty")));
	}
	if(!vo.get("twenty_dc").equals(""))
	{
		twenty_dc = df.format(Integer.parseInt(vo.get("twenty_dc")));
	}
	if(!vo.get("twenty_dt").equals(""))
	{
		twenty_dt = df.format(Integer.parseInt(vo.get("twenty_dt")));
	}
	if(!vo.get("twenty_fr").equals(""))
	{
		twenty_fr = df.format(Integer.parseInt(vo.get("twenty_fr")));
	}
	if(!vo.get("fourty_dc").equals(""))
	{
		fourty_dc = df.format(Integer.parseInt(vo.get("fourty_dc")));
	}
	if(!vo.get("fourty_dt").equals(""))
	{
		fourty_dt = df.format(Integer.parseInt(vo.get("fourty_dt")));
	}
	if(!vo.get("fourty_fr").equals(""))
	{
		fourty_fr = df.format(Integer.parseInt(vo.get("fourty_fr")));
	}
	if(!vo.get("fourty_fft").equals(""))
	{
		fourty_fft = df.format(Integer.parseInt(vo.get("fourty_fft")));
	}
	if(!vo.get("total").equals(""))
	{
		total = df.format(Integer.parseInt(vo.get("total")));
	}
	CommCodeManager commCodeManager = new CommCodeManager();
	InitCombo initCombo = new InitCombo();
	
	String today = DateUtil.formatDateTime(DateUtil.getToday(), "yyyyMMdd", "yyyyMMdd");
	initCombo.makeComboData(commCodeManager.getCodeRowSet("911"), "CODE", "NAME");
	String statusSheetComboListText = initCombo.getCode();
	String statusSheetComboListValue = initCombo.getCodeName();
	
	//현장별 컬럼값 가져오기 
	RowSet deptCols = CommCodeManager.getCodeRowsetStatic("SSR_DEPT", "DETAILCD", params.get("dept_cd"));
	ValueObject ColObject = null;
	String[] col = {"", "", "", "", ""};
	 int rowSize = deptCols.size();
	
	if (deptCols != null && rowSize > 0) {
		ColObject = RowSetUtility.getValueObject(deptCols.getRow(0));
		col[0] = ColObject.get("CHG_CODE01");
		col[1] = ColObject.get("CHG_CODE02");
		col[2] = ColObject.get("CHG_CODE03");
		col[3] = ColObject.get("CHG_CODE04");
		col[4] = ColObject.get("CHG_CODE05");
	}	  
%>

<SCRIPT language="JavaScript">
/*예약함수*/
var sheet1= new ibsheetObject();
var sheet1Row;
var sheet1PageNo = 1;
var sheet2= new ibsheetObject();
var sheet2Row;
var sheet2PageNo = 1;
var pageLastRowIndex = 1;
var validationResult = false;
var filterShow = false;

var deptPurGubun = "";

function _onReady(){
	gridInit(sheet1);
	gridInit(sheet2); 

	jQuery("#btnList").click(function() {
		jQuery("#fevent").val("GET_LIST");
		jQuery("#form1").attr("action", "/supplier/portal/process/process/SuppSSRList.screen");
		jQuery("#form1").attr("target", "_self");
		jQuery("#form1").attr("method", "post");
		jQuery("#form1").submit();	
	});
	
	jQuery("#btnSave").click(function() {
		
		var f = document.form1;
		
		if ( stringByteSize4UTF($("#vessel_name").val()) > 50 ) {
	    	alert("invoice_no은 영문 50자 한글 15자 까지 입력하실 수 있습니다.");
	    	return;
	    }
		
		if(jQuery("#save_msg").val() == 'N'){
			jQuery("#fevent").val("UPDATE_SSR_DETAIL");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/SSRDetail_sheet.screen";
			var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);		
		}else{
    		if(confirm("저장하시겠습니까?")){
    			if(<%=isModify%> == false){
    				//저장 insert
    				jQuery("#fevent").val("SAVE_SSR_DETAIL"); 
    		    }else{
    				//수정 update
    				jQuery("#fevent").val("UPDATE_SSR_DETAIL");
    			}
    			var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/SSRDetail_sheet.screen";
    			var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);		
    		}
    	}	
	});
	
	//2015.3.17 ATD/ATA저장
	jQuery("#btnSubSave").click(function() {
		if(confirm("ATD/ATA 저장하시겠습니까?")){
			jQuery("#fevent").val("UPDATE_ATDATA_DETAIL");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/SSRDetail_sheet.screen";
			var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);				
		}
	}); 
	
	jQuery("#btn_invAdd").click(function() {
		var f = document.form1;
		if(jQuery("#shipping_id").val() == "") {
			alert("데이터 저장 후 Inovice 등록 할 수 있습니다.");
			return;
		}
		rowIdx = sheet2.DataInsert(0);
		sheet2.SetCellValue(rowIdx, "SHIPPING_ID", jQuery("#shipping_id").val());
		sheet2.SetCellValue(rowIdx, "INV_NO", '');
		sheet2.SetCellValue(rowIdx, "INV_VALUE", 0); 
	});	 
	
	 
	jQuery("#btnComp").click(function() {
		var f = document.form1;
		
		if(<%=isModify%> == false){
			alert("저장을 먼저 해주세요.");
			return;
		}
		
		<%-- if( f.esti_departure.value == "" ) {
			alert("ETD를 선택해 주세요.");
			$("#esti_departure").focus();
			return;
		}
		if( f.departure.value == "" ) {
			alert("ATD를 선택해 주세요.");
			$("#departure").focus();
			return;
		}
		if( f.esti_arrival.value == "" ) {
			alert("ETA를 선택해 주세요.");
			$("#esti_arrival").focus();
			return;
		}
		if( f.arrival.value == "" ) {
			alert("ATA를 선택해 주세요.");
			$("#arrival").focus();
			return;
		}			
		if(f.departure.value.replace(/-/gi, "") > '<%=today%>') {
			alert("POL ATD가 오늘보다 나중 날짜 입니다.");
			return;
		} --%>
		
		if(confirm("저장 후 완료 하시겠습니까?")) {
			f.will_status.value = "3";
			f.save_msg.value = "N";
			jQuery("#btnSave").click();
		}
	});	
	
	$.test = function(resultVal)
	{
		for(var i=0; i < resultVal[0].length; i++)
		{
			var f = document.form1;
			f.vendor_cd.value = resultVal[0][i];   
			f.vendor_nm.value = resultVal[2][i];   
		}
		setTimeout(function(){fLayerPopClose('corp');	},100);
	};
	
	
	$("[name=date_img]").click(function(){
		var id = $(this).attr("id").substring(0, $(this).attr("id").lastIndexOf("_"));
		dlgCalendar(id);
	});

    get_ssr_detail_sheet(); 
    get_ssr_inv_sheet(); 
    autoResize();
}

function gridInit(sheetName){
	var init_sheet = {};
	init_sheet.Cfg = {SearchMode:2, Page:10};
	if(sheetName.id == "sheet1") {
		init_sheet.Cols = [
		       			{Header:'상태',					Type:"Status",		SaveName:"status", 		        Width:50, 	Align:"Center", Hidden:"false", Hidden:"True"},
		       			{Header:'Del',					Type:"DelCheck",	SaveName:"check", 		        Width:50, 	Align:"Center", HeaderCheck:1},
		       			{Header:'Material Code',		Type:"Text",		SaveName:"material_cd", 	    Width:90, 	Align:"Center", Edit:"false"},
		       			{Header:'☞Material Name',			Type:"Text",		SaveName:"material_name",  	    Width:150, 	Align:"Left", Edit:"false", Cursor:"Pointer"},
		       			{Header:'Material Spec',		Type:"Text",		SaveName:"material_spec", 	    Width:100, 	Align:"Left", Edit:"false"},
		       			{Header:'Material Unit',		Type:"Text",		SaveName:"item_unit", 		    Width:50, 	Align:"Center", Edit:"false"},
		       			{Header:'PO No',				Type:"Text",		SaveName:"ord_doc_no", 		    Width:130, 	Align:"Left", Edit:"false"},
		       			{Header:'Partial',				Type:"Combo",		SaveName:"Partial_YN", 		    Width:90, 	Align:"Center", Edit:"true", ComboText:"All|Partial", ComboCode:"All|Partial"}, 
		       			{Header:'PO Title',				Type:"Text",		SaveName:"cst_doc_name", 	    Width:250, 	Align:"Left", Edit:"false"},
		       			{Header:'Vendor Name',			Type:"Text",		SaveName:"vendor_nm", 		    Width:90, 	Align:"Left", Edit:"false"},
		       			{Header:'Payment',				Type:"Text",		SaveName:"payment_nm", 		    Width:90, 	Align:"Left", Edit:"false"},
		       			{Header:'Condition',			Type:"Text",		SaveName:"condition_nm", 	    Width:90, 	Align:"Left", Edit:"false"},
		       			{Header:'Ship Qty',				Type:"Float",		SaveName:"ship_qty", 		    Width:90, 	Align:"Right", PointCount:2, Edit:"false"},
		       			{Header:'Ship Price',			Type:"Float",		SaveName:"shp_unit_cost", 	    Width:90, 	Align:"Right", Edit:"false", PointCount:2},
		       			{Header:'Ship Amount',			Type:"Float",		SaveName:"shp_amt", 		    Width:90, 	Align:"Right", Edit:"false", Hidden:"True", PointCount:2},
		       			{Header:'shipping_detail_id',	Type:"Text",		SaveName:"shipping_detail_id", 	Width:100, 	Align:"Center", PointCount:2, Hidden:"True"},
		       			{Header:'계약ID',				Type:"Text",		SaveName:"pur_cont_id", 		Width:100, 	Align:"Center", Hidden:"True"},
		       			{Header:'shipping_id',			Type:"Text",		SaveName:"shipping_id", 		Width:100, 	Align:"Center", Hidden:"True"},
		       			{Header:'통화구분',				Type:"Text",		SaveName:"currency_gb", 		Width:100, 	Align:"Center", Hidden:"True"},
		       			{Header:'국내외구분',				Type:"Text",		SaveName:"oversea_gb", 		    Width:100, 	Align:"Center", Hidden:"True"},          
		       			{Header:'업체코드',				Type:"Text",		SaveName:"corp_id", 		    Width:100, 	Align:"Center", Hidden:"True"},               
		       			{Header:'자재구분코드',			Type:"Text",		SaveName:"material_gb", 		Width:90, 	Align:"Right", Hidden:"True"}
		    		];
	}
	else { 

			init_sheet.Cols = [
				       			{Header:'상태',					Type:"Status",		SaveName:"status", 		        Width:50, 	Align:"Center", Hidden:"True"},
				       			{Header:'Del',					Type:"DelCheck",	SaveName:"check", 		        Width:50, 	Align:"Center", HeaderCheck:1},
				       			{Header:'shipping_id',			Type:"Text",		SaveName:"shipping_id", 		Width:90, 	Align:"Left", Edit:"false", Hidden:"True"},
				       			{Header:'shipping_detail_id',	Type:"Text",		SaveName:"shipping_detail_id", 	Width:150, 	Align:"Left", Edit:"false", Hidden:"True"},
				       			{Header:'ORDER',			    Type:"Text",		SaveName:"ORD", 		        Width:60, 	Align:"Left", Edit:"true"},
				       			{Header:'Invoice No',			Type:"Text",		SaveName:"inv_no", 		        Width:180, 	Align:"Left", Edit:"true"},
				       			{Header:'Invoice Value',		Type:"Float",		SaveName:"inv_value", 		    Width:120, 	Align:"Right", Edit:"true"},
				       			{Header:'Currency',				Type:"Combo",		SaveName:"inv_cur", 		    Width:70, 	Align:"Center", Edit:"true",  ComboText:"<%=statusSheetComboListText%>", ComboCode:"<%=statusSheetComboListValue%>" } ,
				       			{Header:'DESCRIPTION',		    Type:"Text",		SaveName:"INV_DESC",	        Width:160, 	Align:"Left", Edit:"true"}
				       	];
	}
	init_sheet.HeaderMode = {Sort:1};
	IBS_InitSheet(sheetName, init_sheet);
	sheetName.SetDataAutoTrim(0);
	//setGridSize();
}

function sheet1_OnSearchEnd(code, message) {
    if(code == 0) {
    	setGridSize();
   } else {
		//조회 에러 수행
		alert("조회 실패");
	}
}

function sheet1_OnSaveEnd(code, msg) {
	if(code >= 0) {
    	if(jQuery("#fevent").val() == "UPDATE_SSR_DETAIL") {
    		save_ssr_detail_sheet();
    	}
    	else if(jQuery("#fevent").val() == "SAVE_SSR_DETAIL"){
    		alert("저장했습니다.");
    		jQuery("#btnList").click();
    	}else{
    		alert("처리되었습니다.");
    		reloading();
    	}
    } else {
    	alert(msg);
    }
}
function sheet2_OnSaveEnd(code, msg) {
    if(code >= 0) {
    	if(jQuery("#save_msg").val() == 'N'){
    		jQuery("#fevent").val("CONFIRM_SSR_DETAIL"); 
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/SSRDetail_sheet.screen";
			var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);
    	}else{
    		alert("저장했습니다.");
        	reloading();
    	}    	
    } else {
    	alert(msg);
    }
}
/**
 *	IBSheet size setting
 */
function setGridSize() {
	sheet1.FitColWidth();
	sheet2.FitColWidth();
}
	
function sheet1_OnSmartResize(Width, Height) { 
	autoResize();
}

function sheet2_OnSmartResize(Width, Height) { 
	autoResize();
}

function autoResize(){
	var t1_height = document.getElementById("f_table").scrollHeight + document.getElementById("title").scrollHeight + 24 + 45;  
	var iframeHeight= document.body.scrollHeight - t1_height;   
	
	sheet1.SetSheetHeight(iframeHeight); 
	sheet2.SetSheetHeight(iframeHeight);	  
}

function save_ssr_detail_sheet() {
    jQuery("#fevent").val("UPDATE_SSR_INV");
	var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/SSRDetail_sheet.screen";
	var result = Modular.view.IBSheet7.doSave(sheet2, url, jQuery("#form1"), false);
}


function reloading() {
	var f = document.form1;
		
	f.fevent.value ="GET_SSR_DETAIL";
	f.action = "/supplier/portal/process/process/SuppSSRDetail.screen";
	f.target = "_self";
	f.method = "post";  
	f.submit();
}

function SearchShippingTargetSearch(result) {
	if(result != null) {
		
		var material_cd = result[0];
		var material_name = result[1];
		var material_spec = result[2];
		var item_unit = result[3];
		var ship_qty = result[4];
		var shp_unit_cost = result[5];
		var shp_amt = result[6];
		var pur_cont_id = result[7];
		var ord_doc_no = result[8];
		var cst_doc_name = result[9];
		var currency_gb = result[10];
		var oversea_gb = result[11];
		var corp_id = result[12];
		var material_gb = result[13];
		

		var stop = 1;
		for ( var j = 0; j < material_cd.length; j++) {

			stop = 1;

			with (sheet1) {
				if (LastRow() >= 1) {
					for ( var i = 1; i <= LastRow(); i++) {
						if (GetCellValue(i, "material_cd") == material_cd[j] && GetCellValue(i, "pur_cont_id") == pur_cont_id[j]) {
							alert(material_cd[j] + "(은)는 중복된 이름입니다.");
							stop = 2;
							break;
						}
					}
				}
			}
			if (stop == 1) {
				var rowIndex;
				rowIndex = sheet1.DataInsert(-1);
				
				sheet1.SetCellValue(rowIndex, "material_cd", material_cd[j]); 
				sheet1.SetCellValue(rowIndex, "material_name", material_name[j]); 
				sheet1.SetCellValue(rowIndex, "material_spec", material_spec[j]); 
				sheet1.SetCellValue(rowIndex, "item_unit", item_unit[j]); 
				sheet1.SetCellValue(rowIndex, "ship_qty", ship_qty[j]);
				sheet1.SetCellValue(rowIndex, "shp_unit_cost", shp_unit_cost[j]); 
				sheet1.SetCellValue(rowIndex, "shp_amt", shp_amt[j]);
				sheet1.SetCellValue(rowIndex, "ord_doc_no", ord_doc_no[j]);
				sheet1.SetCellValue(rowIndex, "cst_doc_name", cst_doc_name[j]);
				sheet1.SetCellValue(rowIndex, "pur_cont_id", pur_cont_id[j]);
				sheet1.SetCellValue(rowIndex, "currency_gb", currency_gb[j]);
				sheet1.SetCellValue(rowIndex, "oversea_gb", oversea_gb[j]);
				sheet1.SetCellValue(rowIndex, "corp_id", corp_id[j]);
				sheet1.SetCellValue(rowIndex, "material_gb", material_gb[j]);
			}
		}
	}
	
	fLayerPopClose('_shippingTargetSearch');
}

function doResult(resultObj) {
	try {
		if( resultObj.getRequestEvent() == "" ) {
			if( resultObj.getSuccess() ) { 
				save_ssr_detail_sheet();
			}
			else {
				dlgErrorMsg(resultObj);
			}
		}
	}
	catch(errorObject) {
		showErrorDlg("doResult()", errorObject);
	}
}

//첨부파일   
function doAttachFile(obj,No,fileName) {
		
		if(obj.value == ''){
			alert("데이터를 저장 후, 파일을 첨부할 수가 있습니다.");
		}
		else if(obj.value != ''){
			
			var upLoadFlg = "N";
			if (document.form1.status.value == "2"){	//업체작성중 상태일때만 
				upLoadFlg = "Y"; 
			} 
								
			viewFileListNew('SSR_DETAIL_'+obj.value, No, document.getElementById("fileMapIDDiv"), upLoadFlg, "progress/ssr/"+obj.value, null, fileName);
		} 
}

/**
 * 첨부파일 예약 함수
 */
function fileDown(file_id){
		var url="/common/file/FileDownloadServlet";
 		url += "?file_id=" + file_id;
 		
 		window.open(url, "_fileDown", "toolbar=no, width=400, height=100, top=500, left=400, toolbar=no,directories=no,status=no,scrollbars=yes,resize=no,menubar=no,target=new")
}

function get_ssr_detail_sheet() {
	jQuery("#fevent").val("GET_SSR_DETAIL_SHEET");
	var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/SSRDetail_sheet.screen";
	Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 10, "");
}
function get_ssr_inv_sheet() {
	jQuery("#fevent").val("GET_SSR_INV_SHEET");
	var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/SSRDetail_sheet.screen";
	Modular.view.IBSheet7.doSearch(sheet2, url, jQuery("#form1"), 10, "");
}


function changeContainerType() {
	 var f = document.form1;
	 var hap = 0;	
	 hap = Number(f.twenty_dc.value.replace(/,/gi, "")) + Number(f.twenty_dt.value.replace(/,/gi, "")) + 
	 Number(f.twenty_fr.value.replace(/,/gi, "")) + Number(f.fourty_dc.value.replace(/,/gi, "")) + 
	 Number(f.fourty_dt.value.replace(/,/gi, "")) + Number(f.fourty_fr.value.replace(/,/gi, ""))+ Number(f.fourty_fft.value.replace(/,/gi, ""));
	 f.total.value = hap;
}


function fileCheck(checkObj, val){
	var f = document.form1;
	var obj = eval("document.getElementById('" + val + "')");
	
	if(obj.style.display == "none"){
		obj.style.display = "inline";
		checkObj.checked = true;
	}else{
		obj.style.display = "none";
		checkObj.checked = false;
	}
} 
 

//첨부목록 조회
function getFileListForTextarea(){
	document.form1.p_AttachFile.value = "";
	var f = document.form1;  
	jQuery("#fevent").val("GET_ATTACHFILE");
	submitXmlRequest("/payment/purchase/PayInstallResult_form.screen", "GET_ATTACHFILE", f, "VALUEOBJECT");	
}

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">
<div style="display:none;" id="fileMapIDDiv" class="attach_file_view" onPropertyChange="JavaScript:getFileListForTextarea();"></div>
<INPUT type="hidden" name="fevent" value="<%= params.get("fevent") %>">
<INPUT type="hidden" name="shipping_id" value="<%= params.get("shipping_id") %>">
<INPUT type="hidden" name="shipping_seq" value="<%= params.get("shipping_seq") %>">
<INPUT type="hidden" name="dept_cd" value="<%= params.get("dept_cd") %>">
<INPUT type="hidden" name="dept_nm" value="<%=StringUtils.nvl(params.get("dept_nm"), vo.get("dept_nm"))%>">
<INPUT type="hidden" name="status" value="<%= vo.get("status") %>">
<INPUT type="hidden" name="will_status" value="">
<INPUT type="hidden" name="sYmdSt" value="<%= params.get("sYmdSt") %>">
<INPUT type="hidden" name="sYmdEd" value="<%= params.get("sYmdEd") %>">
<INPUT type="hidden" name="p_origin" value="<%= params.get("p_origin") %>">
<INPUT type="hidden" name="p_shipping_mode" value="<%= params.get("p_shipping_mode") %>">
<INPUT type="hidden" name="p_status" value="<%= params.get("p_status") %>">
<INPUT type="hidden" name="save_msg" id="save_msg" value="">
	    	
	<!-- 제목 및 버튼 -->
   	<table width="100%">
		<colgroup>
			<col width="500" />
			<col width="*" />
		</colgroup>
	<tr>
	   	<th>
		   <div align="left" id="title">
		    <ul>
		     <li>Shipping Detail(<%=vo.get("status_nm") %>)</li>
		    </ul>
		   </div>
	   </th>
	   <td align="right">
	        <span class="btnSearch center"><a href="javascript:void(0);" id="btnList">List</a></span>
			<%  if(vo.get("status").equals("2")) {
			%>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnSave">Save</a></span>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnComp">Complete</a></span>		
			<%
				}
			%>  
	   </td>
   	</tr>
   	</table>


<!-- 데이터 영역 : 시작 -->
<TABLE class="form-table" id="f_table">
		<colgroup>
			<col width="10%" />
			<col width="35%" />
			<col width="13%" />
			<col width="*" />
		</colgroup>	
  <TR height="25"> 
    <th> SRN No</th>
	<TD>
			<%= InputText.get("ship_no", vo.get("ship_no"), 95, 20, " persize") %>
    </TD>
    <th>운송업체</th>
	<TD>
		<INPUT type="hidden" name="vendor_cd" value="<%= vo.get("vendor_cd") %>">
        <%= InputText.get("vendor_nm", vo.get("vendor_nm"), 30, 30, "english,desc=Project,readonly") %>
	</TD>
  </TR>		
  <TR height="25"> 
	<th>Bill of Lading</th>
	<TD> 
		<%= InputText.get("bl_no", vo.get("bl_no"), 95, 30, "persize") %>
	</TD>
	<th>Origin</th>
    <TD>
      	<%= InputText.get("origin", vo.get("origin"), 95, 100, "persize") %>
    </TD>
  </TR> 
  <TR height="25"> 
       <th>PKG / KGS</th>
      <TD> 
      	<%= InputText.get("package_qty", package_qty, 46, 2, "number, persize, right") %>
      	<%= InputText.get("pkg_wgt", vo.get("pkg_wgt"), 46, 30, "persize, right") %>
      </TD> 
      <th>CBM</th>
	  <TD>
      	<%= InputText.get("pkg_cbm", vo.get("pkg_cbm"), 95, 30, "persize") %>
      </TD>
  </TR>
   <TR height="25">
    <th>Vessel Name</th>
      <TD > 
      	<%= InputText.get("vessel_name", vo.get("vessel_name"), 95, 50, "persize") %>
      </TD>
      <th>Shipping Mode</th>
      <TD>
        <%= CommCodeManager.getSelectCodeList("SHIP_MODE", "ship_mode", "width:26%;height=18px;", "", vo.get("ship_mode"), "") %>
      </TD>
   </TR>
   
   <TR height="25">
      <th rowspan="3">Container Type</th>
      <TD rowspan="3">
      	<table>
      		<tr>
      			<td>20'DC</td><td>20'OT</td><td>20'FR</td><td>40'DC</td><td>40'OT</td><td>40'FR</td><td>45'FT</td><td>Total</td>
      		</tr>
      		<tr height="25">
      			<td>
      				<%= InputText.get("twenty_dc", twenty_dc, 70, 2, "number, persize, right", "", "onPropertyChange=\"javascript:changeContainerType()\"") %>
      			</td>
      			<td>
      				<%= InputText.get("twenty_dt", twenty_dt, 70, 2, "number, persize, right", "", "onPropertyChange=\"javascript:changeContainerType()\"") %>
      			</td>
      			<td>
      				<%= InputText.get("twenty_fr", twenty_fr, 70, 2, "number, persize, right", "", "onPropertyChange=\"javascript:changeContainerType()\"") %>
      			</td>
      			<td>
      				<%= InputText.get("fourty_dc", fourty_dc, 70, 2, "number, persize, right", "", "onPropertyChange=\"javascript:changeContainerType()\"") %>
      			</td>
      			<td>
      				<%= InputText.get("fourty_dt", fourty_dt, 70, 2, "number, persize, right", "", "onPropertyChange=\"javascript:changeContainerType()\"") %>
      			</td>
      			<td>
      				<%= InputText.get("fourty_fr", fourty_fr, 70, 2, "number, persize, right", "", "onPropertyChange=\"javascript:changeContainerType()\"") %>
      			</td>
      			<td>
      				<%= InputText.get("fourty_fft", fourty_fft, 70, 2, "number, persize, right", "", "onPropertyChange=\"javascript:changeContainerType()\"") %>
      			</td>
      			<td>
					<%= InputText.get("total", total, 70, 20, "number, persize, readOnly, right") %>
				</td>
      		</tr>
      	</table>
      </TD>
   	   <th class="required">POL ETD/ATD</th>
      <TD>
        <%= InputText.get("pol", vo.get("pol"), 52, 30, "persize") %>
        <%= InputText.get("esti_departure", DateUtil.formatDateTime(vo.get("esti_departure"), "yyyyMMdd", "yyyy-MM-dd"), 15, 50, "readOnly, persize, center") %>
		<IMG name="polEtd_date_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" onClick="JavaScript:dlgCalendar('esti_departure');">
		<%= InputText.get("departure", DateUtil.formatDateTime(vo.get("departure"), "yyyyMMdd", "yyyy-MM-dd"), 15, 50, "readOnly, persize, center") %>
		<IMG name="polAtd_date_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" onClick="JavaScript:dlgCalendar('departure');">
      </TD>      
     </tr>
     <tr height= "25">
     <th class="required">POD ETA/ATA</th>
      <TD>
        <%= InputText.get("pod", vo.get("pod"), 52, 30, "persize") %>
        <%= InputText.get("esti_arrival", DateUtil.formatDateTime(vo.get("esti_arrival"), "yyyyMMdd", "yyyy-MM-dd"), 15, 50, "readOnly, persize, center") %>
		<IMG name="podEtd_date_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" onClick="JavaScript:dlgCalendar('esti_arrival');">
		<%= InputText.get("arrival", DateUtil.formatDateTime(vo.get("arrival"), "yyyyMMdd", "yyyy-MM-dd"), 15, 50, "readOnly, persize, center") %>
		<IMG name="podAtd_date_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" onClick="JavaScript:dlgCalendar('arrival');">
      </TD>
	 
    </tr> 
    <tr height="25">
      <th>Customs Clearance/ATA Site</th>
      <TD>
        <%= InputText.get("clear_custom", DateUtil.formatDateTime(vo.get("clear_custom"), "yyyyMMdd", "yyyy-MM-dd"), 20, 50, "readOnly, persize, center") %>
		<IMG name="cc_date_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" onClick="JavaScript:dlgCalendar('clear_custom');">
		<%= InputText.get("onsite", DateUtil.formatDateTime(vo.get("onsite"), "yyyyMMdd", "yyyy-MM-dd"), 20, 50, "readOnly, persize, center") %>
		<IMG name="onsiteArrivalDate_date_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" onClick="JavaScript:dlgCalendar('onsite');">
      </TD>
   </TR>
   <TR height="25">
      <th>Field Material Manager 1</th>
      <TD> 
      	<%= InputText.get("dept_emp_name", vo.get("dept_emp_name"), 17, 10, "desc=,readOnly") %>
		<INPUT type='hidden' name="deptempno" desc="" value="<%=vo.get("deptempno")%>">
		<%= InputText.get("deptemp_hp", vo.get("deptemp_hp"), 20, 50, "readOnly, persize, center") %>
		<%= InputText.get("deptemp_email", vo.get("deptemp_email"), 38, 50, "readOnly, persize, center") %>
      </TD>
      <th style="text-align: left;">Field Material Manager 2</th>
      <TD> 
      	<%= InputText.get("pur_emp_name", vo.get("pur_emp_name"), 12, 10, "desc=,readOnly, center") %>
		<INPUT type='hidden' name="pur_emp_no" desc="" value="<%=vo.get("pur_emp_no")%>">
		<%= InputText.get("puremp_hp", vo.get("puremp_hp"), 24, 30, "persize, readOnly, center") %>
		<%= InputText.get("puremp_email", vo.get("puremp_email"), 39, 30, "persize, readOnly, center") %>
      </TD>
   </tr>
   <TR height="25">
   		<th>Remarks</th>
      <TD> 
      	<TEXTAREA name="remarks" style="width:95%" rows="8" class="input"><%=vo.get("remarks") %></TEXTAREA>
      </TD>
      <th> Attach File</th>
        <td style="padding-top: 3px;"> 
        	<TABLE class="inner_table" border="0" >
				<%
				if(purchaseFileRow.size() > 0){
					int i_mod = 0;
					for(int i = 0; purchaseFileRow.size() > i; i++){
						i_mod = i%4;
						if(i_mod == 0){ %>
							<TR>
					<%	} %>
								<td width="2%">
								<input type="checkbox" name="doc_cd" value="<%=purchaseFileRow.getRow(i).get("DETAILCD") %>" style="cursor:pointer;" onClick="fileCheck(this,'<%=purchaseFileRow.getRow(i).get("DETAILCD") %>')" <%if(!purchaseFileRow.getRow(i).get("DOC_CD").equals("")){out.print("checked");} %>>
								</td>
								<td width="15%">
								<%=purchaseFileRow.getRow(i).get("DETAILNM") %>
								</td>
								<td width="7%" height="24">
								<IMG src="/img/supplier/button/bt_attach_file.gif" id="<%=purchaseFileRow.getRow(i).get("DETAILCD") %>" alt="첨부파일 관리" align="top" style="display:<%if(!purchaseFileRow.getRow(i).get("DOC_CD").equals("")){out.print("inline");}else{out.print("none");} %>" onClick="doAttachFile(document.form1.shipping_id, '<%=purchaseFileRow.getRow(i).get("DETAILCD") %>', '<%=purchaseFileRow.getRow(i).get("DETAILNM")%>');" class="button">
								</td>
					<%	if(i_mod == 3) { %>		
							</TR>
					<%	} %>		
				<%
					}
					for(int i=i_mod+1; i<4; i++){ %>
						<td></td>
				<%	}
					if(i_mod == 0 || i_mod == 1){ %>
						</TR>	
				<%	}
				}
				%>
			</TABLE>	
			<TEXTAREA name="p_AttachFile" style="width:85%" rows="7" class="input" readOnly><%=vo_file.get("SSR_DETAIL") %></TEXTAREA>
		</td>
   </TR>
   <TR height="25">
      <th>추가항목</th>
      <TD colspan="3">
        <%if (col[0].length() > 0 ){ %>
        <%= col[0]%> <%= InputText.get("data1", vo.get("data1"), 17, 10, "") %>
        <%}
        if (col[1].length() > 0 ){ %>
        <%= col[1]%> <%= InputText.get("data2", vo.get("data2"), 17, 10, "") %>
        <%}
        if (col[2].length() > 0 ){ %>
        <%= col[2]%> <%= InputText.get("data3", vo.get("data3"), 17, 10, "") %>
        <%}
        if (col[3].length() > 0 ){ %>
        <%= col[3]%> <%= InputText.get("data4", vo.get("data4"), 17, 10, "") %>
        <%}
        if (col[4].length() > 0 ){ %>
        <%= col[4]%> <%= InputText.get("data5", vo.get("data5"), 17, 10, "") %>
        <%} %>
      </TD>
   </tr>
 </TABLE>
 
<TABLE border="0" cellspacing="0" cellpadding="0" width="100%">
		<tr>
			<td width="*">
			        <table width="99%" >
			        <colgroup>
						<col width="100" />
						<col width="*" />
					</colgroup>
			        <tr>
			        <th>
				   		<div class="application-info magT20">
							<div class="application-sub-title">
								<span class="title">ITEM List</span>
							</div>
						</div>
				   	</th>
				   	<td align="right">
			   		</td>
			        </tr>
			        </table>
			</td>
			<td width="420px">
			        <table width="100%" >
			        <colgroup>
						<col width="100" />
						<col width="*" />
					</colgroup>
			        <tr>
			        <th>
				   		<div class="application-info magT20">
							<div class="application-sub-title">
								<span class="title">Invoice List</span>
							</div>
						</div>
				   	</th>
				   	<td align="right">
						<%
							if((vo.get("status").equals("2"))) {
						%>
						    <span class="btnSearch center"><a href="javascript:void(0);" id="btn_invAdd">Add</a></span> 
						<%
							}
						%>
			   		</td>
			        </tr>
			        </table>			
			</td>
		</tr>
		<tr>
		    <td>
					<div id="sheet1_div" style="padding-top:5px; height: auto; min-height: 10px; overflow: auto;">
						<script>createIBSheet('sheet1','99%', '100px');</script>
					</div>			
			</td>
			<td>
				<div id="sheet2_div" style="padding-top:5px; height: auto; min-height: 10px; overflow: auto;">
					<script>createIBSheet('sheet2','100%', '100px');</script>
				</div>
			</td>
		</tr>
</TABLE>

</FORM>