  <%--
  - FileName   : SSRList.jsp
  - Author     : gyeongmo an
  - Date       : 2014.08.12
  - Copyright  : Copyright (c) 2014 www.udapsoft.co.kr, Inc.
  - All rights reserved.
  - Description: Shiping Status Report
--%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="com.udapsoft.waf.system.HandlerStorage" %>
<%@ page import="com.udapsoft.waf.common.ui.*" %>
<%@ page import="com.udapsoft.waf.common.ui.InitCombo" %>
<%@ page import="kr.co.udapsoft.common.code.*" %>
<%@ page import="kr.co.udapsoft.common.code.CommCodeManager" %>
<%@ page import="kr.co.hsnc.common.util.*"%>
<%@ page import="kr.co.hsnc.common.sql.*" %>
<%@ 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" />

<%
    ctx.init(request, response);
    HandlerStorage storage = ctx.getHandlerStorage();
	ValueObject params 	   = storage.getParams();
	ValueObject user 	   = storage.getUser();
	String fevent   	   = storage.getEvent();	
	
	//공통코드
	CommCodeManager commCodeManager = new CommCodeManager();
	InitCombo initCombo = new InitCombo();

	initCombo.makeComboData(commCodeManager.getCodeRowSet("SHIP_MODE"), "NAME", "CODE");
	String SHIP_CD = initCombo.getCode();
	String SHIP_NM = initCombo.getCodeName();
	
	//현장별 컬럼값 가져오기 
	RowSet deptCols = CommCodeManager.getCodeRowsetStatic("SSR_DEPT", "DETAILCD", user.get("dept_cd"));
	ValueObject ColObject = null;
	String[] col = {"", "", "", "", ""};
	Boolean[] col_yn = {true, true, true, true, true};
	 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");
		
		for (int i = 0; i<5; i ++ ) {
			if(col[i].length() > 0 ){ 
				col_yn[i] = false;
			}
		} 
	}	
	
		
%>
<SCRIPT language="JavaScript">
/*예약함수*/
var sheet1;
var sheet1Row;
var sheet1PageNo = 1;
var pageLastRowIndex = 1;
var validationResult = false;
var filterShow = false;

var sheet2;
var sheet2Row;
var sheet2PageNo = 1;

function _onReady(){
	gridInit(sheet1);
	gridInit2(sheet2);
	
	jQuery("#btnSearch").click(function() { 
		var f= document.form1;
		if(f.dept_cd.value == "") {
			alert("현장을 선택해 주세요.");
			return;
		}

		jQuery("#fevent").val("GET_SSR_LIST");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/SSRList_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet1, url, jQuery("#form1"), 30, "");
	});
	
	jQuery("#btnAdd").click(function() {
		var f= document.form1;
		if(f.dept_cd.value == "") {
			//f.dept_cd. = "1604";
			alert("현장을 선택해 주세요.");
			return;
		}
		jQuery("#fevent").val("REG_SSR_DETAIL");
		jQuery("#form1").attr("action", "/process/process/SSRDetail.screen");
		jQuery("#form1").attr("target", "_self");
		jQuery("#form1").attr("method", "post");
		jQuery("#form1").submit();	
	});
	
	jQuery("#btnSave").click(function() {
		if(confirm("저장하시겠습니까?")) {
			jQuery("#fevent").val("SAVE_SSR_LIST");
			var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/SSRList_sheet.screen";
			var result = Modular.view.IBSheet7.doSave(sheet1, url, jQuery("#form1"), false);	
		}
	});
	
	jQuery("#btnExcel").click(function() {
		//sheetExcelDown(sheet1,$('li').html());
		 var f= document.form1;
		var dept = "Project Name : " + f.dept_nm.value ;
		if(sheet1.RowCount() == 0) {
			alert("내역이 없습니다.");
			return;
		}
		var col_nm = "";
		
		<% for (int i = 0; i<5; i ++ ) {
			if(col[i].length() > 0 ){%>
				col_nm = col_nm + "data" + "<%=i+1%>" + "|";
			<%}
		}%>
		
		var params = { FileName : "SSRList.xls",  SheetName : "SSRList", SheetDesign:1, Merge:1, DownCols:"ship_no|inv_no|Partial_yn|ORD_DOC_NO|"+
				"description|vendor_info|CURRENCY|po_value|inv_cur|invoice_value|condition|origin|PACKAGE_QTY|PKG_WGT|PKG_CBM|shipping_mode|"+
				"twenty_dc|twenty_dt|twenty_fr|fourty_dc|fourty_dt|fourty_fr|pol|pod|vessel_name|bl_no|ESTI_DEPARTURE|ESTI_ARRIVAL|DEPARTURE|ARRIVAL|CLEAR_CUSTOM|ONSITE|"+col_nm+
		 		"remarks|STATUS_NM", TitleText:dept, UserMerge:"0,0,1,4", AutoSizeColumn:1, NumberTypeToText:1  } ;
		
		sheet1.Down2Excel(params); 
	});
	
	jQuery("#btnExcelNew").click(function() {
		var f= document.form1;
		if(f.dept_cd.value == "") {
			alert("현장을 선택해 주세요.");
			return;
		}

		jQuery("#fevent").val("GET_SSR_LIST_EXCEL");
		var url = Modular.model.PageContext.CONTEXT_ROOT + "/process/process/SSRList_sheet.screen";
		Modular.view.IBSheet7.doSearch(sheet2, url, jQuery("#form1"), 30, "");	
	});
	
	jQuery("#btnColModi").click(function() {
    	var win_id = "_searchUserPopup";
 		var link = "/process/process/dlgSSRDeptColumnPop.screen";
 		    link += "?pop_win_id="+win_id;
 		    link += "&BASECD=SSR_DEPT&fevent=DEPTPOP";
 		
 		fLayerPop(win_id, link, 700,400, '', '', 'NO');
	});
	 
	jQuery("#btnNew").click(function() {
		var f= document.form1;
		if(f.dept_cd.value == "") {
			alert("현장을 선택해 주세요.");
			return;
		}
		f.fevent.value ="REG_SSR_DETAIL";
		f.action = "/process/process/SSRDetail.screen";
		f.target = "_self";
		f.method = "post";  
		f.submit();
	});
	$("#dataClear2").click(function(){$("#sYmdSt").val("");$("#sYmdEd").val("");});

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

function gridInit(sheetName){
	var init_sheet = {}; 
	
	init_sheet.Cfg = {FrozenCol:5, SearchMode:2, Page:50, MergeSheet:msHeaderOnly+msPrevColumnMerge};//, PrevColumnMergeMode:0 msPrevColumnMerge
	init_sheet.Cols = [
                    {Header:'상태|상태',								Type:"Status",			SaveName:"status", 				Width:50, 	Align:"Center", Hidden:"True"},
	       			{Header:'삭제|삭제',								Type:"DelCheck",		SaveName:"del_check", 			Width:50, 	Align:"Center",  ColMerge:0, HeaderCheck:0},
	    			{Header:'현장코드|현장코드',						Type:"Text", 			SaveName:"dept_cd", 			Width:0, 	Align:"Center", Edit:"false", Hidden:"True"},
	    			{Header:'Project|Project',						Type:"Text", 			SaveName:"dept_nm", 			Width:250, 	Align:"Left", Edit:"false", Hidden:"True"},
	    			{Header:'Numbering|☞SRN No',					Type:"Text", 			SaveName:"ship_no", 			Width:120, 	Align:"Center", ColMerge:1, Edit:"false", Cursor:"Pointer"},
	    			{Header:'Numbering|Invoice No',					Type:"Text", 			SaveName:"inv_no",   			Width:150, 	Align:"Left", ColMerge:0,   Edit:"false"},
	    			{Header:'Numbering|Partial',					Type:"Combo", 			SaveName:"Partial_yn",			Width:100, 	Align:"Center", ColMerge:0, Edit:"false", ComboText:"All|Partial", ComboCode:"All|Partial"},
	    			{Header:'PO|PO No',					            Type:"Text", 			SaveName:"ORD_DOC_NO", 			Width:150,	Align:"Left", Edit:"false", ColMerge:0},
	    			{Header:'PO|Description',						Type:"Text", 			SaveName:"description", 		Width:200, 	Align:"Left", Edit:"false", ColMerge:0},
	    			{Header:'PO|Vendor',							Type:"Text", 			SaveName:"vendor_info", 		Width:100, 	Align:"Left", Edit:"false", ColMerge:0},
	    			{Header:'PO|C',   							    Type:"Text",	 		SaveName:"CURRENCY",  			Width:20, 	Align:"Right", Edit:"false", ColMerge:0},
	    			{Header:'PO|PO value',							Type:"Text",	 		SaveName:"po_value", 			Width:100, 	Align:"Right", Edit:"false", ColMerge:0},
	    			{Header:'PO|C',		        				    Type:"Text", 			SaveName:"inv_cur",   		    Width:20, 	Align:"Right", Edit:"false", ColMerge:0},
	    			{Header:'PO|Invoice Value',						Type:"Text", 			SaveName:"invoice_value", 		Width:100, 	Align:"Right", Edit:"false", ColMerge:0},
	    			{Header:'PO|Condition',					        Type:"Text", 			SaveName:"condition", 			Width:110, 	Align:"Center", Edit:"false", ColMerge:0},
	    			{Header:'PO|Origin',						    Type:"Text", 			SaveName:"origin", 				Width:100, 	Align:"Left", Edit:"True"},
	    	        {Header:'Shipping Information|PKG',				Type:"Float", 			SaveName:"PACKAGE_QTY", 		Width:70, 	Align:"Right", Edit:"True", PointCount:2},
	    			{Header:'Shipping Information|KGS',				Type:"Float", 			SaveName:"PKG_WGT", 			Width:70, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|CBM',				Type:"Float", 	        SaveName:"PKG_CBM", 			Width:100, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|Shipping Mode',	Type:"Combo", 	  		SaveName:"shipping_mode", 		Width:130, 	Align:"Center", Edit:"True", ComboText:"<%=SHIP_NM%>", ComboCode:"<%=SHIP_CD%>"},
	    			{Header:'Shipping Information|20\'DC',			Type:"Float",    		SaveName:"twenty_dc", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|20\'OT',			Type:"Float", 		    SaveName:"twenty_dt", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|20\'FR',			Type:"Float", 		    SaveName:"twenty_fr", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|40\'DC',			Type:"Float", 		    SaveName:"fourty_dc", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|40\'OT',			Type:"Float", 		    SaveName:"fourty_dt", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|40\'FR',			Type:"Float", 		    SaveName:"fourty_fr", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|45\'FT',			Type:"Float", 		    SaveName:"fourty_fft", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Schedule|POL',	            Type:"Text", 			SaveName:"pol", 				Width:100, 	Align:"Left", Edit:"True"},
	    			{Header:'Shipping Schedule|POD',	            Type:"Text", 			SaveName:"pod", 				Width:100, 	Align:"Left", Edit:"True"},
	    			{Header:'Shipping Schedule|Vessel Name',		Type:"Text", 			SaveName:"vessel_name", 		Width:150, 	Align:"Left", Edit:"True"},
	    			{Header:'Shipping Schedule|B/L No',				Type:"Text", 			SaveName:"bl_no", 				Width:150,	Align:"Left", Edit:"True"},
	    			{Header:'Shipping Schedule|ETD POL',			Type:"Date", 			SaveName:"ESTI_DEPARTURE", 		Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'Shipping Schedule|ETA POD',			Type:"Date", 			SaveName:"ESTI_ARRIVAL", 		Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'Shipping Schedule|ATD POL',			Type:"Date", 			SaveName:"DEPARTURE", 			Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'Shipping Schedule|ATA POD',			Type:"Date", 			SaveName:"ARRIVAL", 			Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'Shipping Schedule|Customs Clearance',	Type:"Date", 			SaveName:"CLEAR_CUSTOM", 		Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'Shipping Schedule|ATA Site',			Type:"Date", 			SaveName:"ONSITE", 			    Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'ETC|<%=col[0]%>',		                Type:"Text", 			SaveName:"data1", 		   	    Width:90, 	Align:"Center", Edit:"True", Hidden:"<%=col_yn[0]%>"},
	    			{Header:'ETC|<%=col[1]%>',		                Type:"Text", 			SaveName:"data2", 			    Width:90, 	Align:"Center", Edit:"True", Hidden:"<%=col_yn[1]%>"},
	    			{Header:'ETC|<%=col[2]%>',		                Type:"Text", 			SaveName:"data3", 			    Width:90, 	Align:"Center", Edit:"True", Hidden:"<%=col_yn[2]%>"},
	    			{Header:'ETC|<%=col[3]%>',		                Type:"Text", 			SaveName:"data4", 			    Width:90, 	Align:"Center", Edit:"True", Hidden:"<%=col_yn[3]%>"},
	    			{Header:'ETC|<%=col[4]%>',		                Type:"Text", 			SaveName:"data5", 			    Width:90, 	Align:"Center", Edit:"True", Hidden:"<%=col_yn[4]%>"},
	    			{Header:'Remarks|Remarks',						Type:"Text", 			SaveName:"remarks", 			Width:400, 	Align:"Left", Edit:"True"},	    				    			
	    			{Header:'status|status',          				Type:"Text", 			SaveName:"STATUS_NM", 			Width:200, 	Align:"Left", Edit:"false" },
	    			{Header:'Confirm Date|Confirm Date',			Type:"Date", 			SaveName:"confirm_date", 		Width:90, 	Align:"Center", Edit:"false", Hidden:"True"},
	    			{Header:'Confirm User|Confirm User',			Type:"Text", 			SaveName:"confirm_emp_no", 		Width:90, 	Align:"Center", Edit:"false", Hidden:"True"},
	    			{Header:'shipping_id|shipping_id',				Type:"Text", 			SaveName:"shipping_id", 		Width:200, 	Align:"Left", Edit:"false", Hidden:"True"},
	    			{Header:'pur_cont_id|pur_cont_id',				Type:"Text", 			SaveName:"pur_cont_id", 		Width:200, 	Align:"Left", Edit:"false", Hidden:"True"},
	    			{Header:'status|status',          				Type:"Text", 			SaveName:"STATUS", 			    Width:200, 	Align:"Left", Edit:"false" , Hidden:"True"},
	    			{Header:'shipping_seq|shipping_seq',			Type:"Text", 		    SaveName:"shipping_seq", 		Width:200, 	Align:"Left", Edit:"false", Hidden:"True"},
	    			{Header:'선적서류|선적서류',			            Type:"Text", 		    SaveName:"file_cnt", 		    Width:50, 	Align:"Center", Edit:"false", Cursor:'pointer'},
	    			{Header:'Dummy',								Type:"AutoSum",			SaveName:"", 					Width:0, 	Align:"Center", Edit:"false", Hidden:"True"}
	    			];

	init_sheet.HeaderMode = {Sort:1};
	IBS_InitSheet(sheetName, init_sheet);
	sheetName.SetDataAutoTrim(0); 
	setGridSize();	
	
} 

function sheet1_OnSearchEnd(code, message) {
    if(code == 0) {
    	var sumPKG = 0.0;
    	var sumKGS = 0.0;
    	var sumCBM = 0.0;
    	var sum20DC = 0.0;
    	var sum20OT = 0.0;
    	var sum20FR = 0.0;
    	var sum40DC = 0.0;
    	var sum40OT = 0.0;
    	var sum40FR = 0.0;
    	var sum45FT = 0.0;
    	
    	sheet1.SetColFontColor("ship_no", "#0000ff");  
    	
    	for (var i = 2; i <= sheet1.RowCount()+1; i ++){  
           	if (sheet1.GetCellValue(i, "STATUS") =="2" || sheet1.GetCellValue(i, "STATUS") == "9"){
           		sheet1.SetRowEditable(i, false);           		
           	} 
           	
           	if(sheet1.GetCellValue(i-1, "ship_no") != sheet1.GetCellValue(i, "ship_no")){				
           		sumPKG += Number(sheet1.GetCellValue(i, "PACKAGE_QTY"));
           		sumKGS += Number(sheet1.GetCellValue(i, "PKG_WGT"));
           		sumCBM += Number(sheet1.GetCellValue(i, "PKG_CBM"));
           		sum20DC += Number(sheet1.GetCellValue(i, "twenty_dc"));
           		sum20OT += Number(sheet1.GetCellValue(i, "twenty_dt"));
           		sum20FR += Number(sheet1.GetCellValue(i, "twenty_fr"));
           		sum40DC += Number(sheet1.GetCellValue(i, "fourty_dc"));
           		sum40OT += Number(sheet1.GetCellValue(i, "fourty_dt"));
           		sum40FR += Number(sheet1.GetCellValue(i, "fourty_fr"));
           		sum45FT += Number(sheet1.GetCellValue(i, "fourty_fft"));           		
           	}
        }

    	sheet1.SetSumValue(0,4,"합 계");
    	sheet1.SetCellAlign(sheet1.LastRow(),4,"Center");
    	sheet1.SetCellValue(sheet1.LastRow(),16,sumPKG.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet1.SetCellValue(sheet1.LastRow(),17,sumKGS.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet1.SetCellValue(sheet1.LastRow(),18,sumCBM.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet1.SetCellValue(sheet1.LastRow(),20,sum20DC.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet1.SetCellValue(sheet1.LastRow(),21,sum20OT.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet1.SetCellValue(sheet1.LastRow(),22,sum20FR.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet1.SetCellValue(sheet1.LastRow(),23,sum40DC.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet1.SetCellValue(sheet1.LastRow(),24,sum40OT.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet1.SetCellValue(sheet1.LastRow(),25,sum40FR.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet1.SetCellValue(sheet1.LastRow(),26,sum45FT.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
	} else {
		alert(message);
	}    
}

function sheet1_OnSaveEnd(code, msg) {
    if(code >= 0) {
    	alert("저장했습니다.");
    } else {
    	alert(msg);
    }
    jQuery("#btnSearch").click();
}

function sheet1_OnSelectMenu(Text, Code) {
	switch(Text) {
		case "ExcelDown":
			//sheetExcelDown(sheet1,$('li').html());
			$('#btnExcelNew').click();
            break; 
		break;
	}
}

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

function autoResize(){
	var t1_height = document.getElementById("search-table").scrollHeight + document.getElementById("title").scrollHeight + 24;
	var iframeHeight= document.body.scrollHeight - t1_height;   
	var iframeWidth= document.body.scrollWidth;  
	
	sheet1.SetSheetHeight(iframeHeight);
}	

 
function sheet1_OnDblClick(Row, Col, Value, CellX, CellY, CellW, CellH) {
	if (sheet1.ColSaveName(0, Col) == "ship_no") {
		var f = document.form1;
		f.shipping_id.value = sheet1.GetCellValue(Row, "shipping_id");
		f.shipping_seq.value = sheet1.GetCellValue(Row, "shipping_seq");
		f.fevent.value ="GET_SSR_DETAIL";
	    f.action = "/process/process/SSRDetail.screen";
	    f.target = "_self";
	    f.method = "post";  
	    f.submit();
	}
	else if(sheet1.ColSaveName(Col) == "file_cnt"){ 
		viewFileListNew('SSR_DETAIL_'+sheet1.GetCellValue(Row, "shipping_id"),'10',  document.getElementById("fileMapIDDiv"), 'N', "progress/ssr/"+sheet1.GetCellValue(Row, "shipping_id"), null);
	}
}

function on_change_dept() {
	var f = document.form1;
	var win_id = "_searchSiteNew";
	var link = "/lib/dlgSearchSpotDept_Unitcd_New.screen";
	    link += "?sheetOpenYn=Y&pop_win_id="+win_id+"&obj_dept_cd="+f.dept_cd.value+"&obj_dept_nm="+f.dept_nm.value;
	fLayerPop(win_id, link, 570,420, '', '', 'NO'); 
}
function searchSiteClose(result) { 
	var f = document.form1;
	if( result == null ){
		f.dept_cd.value = "";   //부서코드
		f.dept_nm.value = "";   //부서명
	}else{
		f.dept_cd.value = result[0];   //부서코드
		f.dept_nm.value = result[1];   //부서명
	}
	fLayerPopClose('_searchSiteNew');
	
	//현장변경후 reload(컬럼변경)
	f.fevent.value ="";
	f.action = "/process/process/SSRList.screen";
	f.target = "_self";
	f.method = "post";  
	f.submit();
}

function gridInit2(sheetName){
	var init_sheet = {}; 
	
	init_sheet.Cfg = {FrozenCol:5, SearchMode:0, Page:50, MergeSheet:msHeaderOnly+msPrevColumnMerge};//, PrevColumnMergeMode:0 msPrevColumnMerge
	init_sheet.Cols = [
                    {Header:'상태|상태',								Type:"Status",			SaveName:"status", 				Width:50, 	Align:"Center", Hidden:"True"},
	       			{Header:'삭제|삭제',								Type:"DelCheck",		SaveName:"del_check", 			Width:50, 	Align:"Center",  ColMerge:0, HeaderCheck:0},
	    			{Header:'현장코드|현장코드',						Type:"Text", 			SaveName:"dept_cd", 			Width:0, 	Align:"Center", Edit:"false", Hidden:"True"},
	    			{Header:'Project|Project',						Type:"Text", 			SaveName:"dept_nm", 			Width:250, 	Align:"Left", Edit:"false", Hidden:"True"},
	    			{Header:'Numbering|☞SRN No',					Type:"Text", 			SaveName:"ship_no", 			Width:120, 	Align:"Center", ColMerge:1, Edit:"false", Cursor:"Pointer"},
	    			{Header:'Numbering|Invoice No',					Type:"Text", 			SaveName:"inv_no",   			Width:150, 	Align:"Left", ColMerge:0,   Edit:"false"},
	    			{Header:'Numbering|Partial',					Type:"Combo", 			SaveName:"Partial_yn",			Width:100, 	Align:"Center", ColMerge:0, Edit:"false", ComboText:"All|Partial", ComboCode:"All|Partial"},
	    			{Header:'PO|PO No',					            Type:"Text", 			SaveName:"ORD_DOC_NO", 			Width:150,	Align:"Left", Edit:"false", ColMerge:0},
	    			{Header:'PO|Description',						Type:"Text", 			SaveName:"description", 		Width:200, 	Align:"Left", Edit:"false", ColMerge:0},
	    			{Header:'PO|Vendor',							Type:"Text", 			SaveName:"vendor_info", 		Width:100, 	Align:"Left", Edit:"false", ColMerge:0},
	    			{Header:'PO|C',   							    Type:"Text",	 		SaveName:"CURRENCY",  			Width:20, 	Align:"Right", Edit:"false", ColMerge:0},
	    			{Header:'PO|PO value',							Type:"Text",	 		SaveName:"po_value", 			Width:100, 	Align:"Right", Edit:"false", ColMerge:0},
	    			{Header:'PO|C',		        				    Type:"Text", 			SaveName:"inv_cur",   		    Width:20, 	Align:"Right", Edit:"false", ColMerge:0},
	    			{Header:'PO|Invoice Value',						Type:"Text", 			SaveName:"invoice_value", 		Width:100, 	Align:"Right", Edit:"false", ColMerge:0},
	    			{Header:'PO|Condition',					        Type:"Text", 			SaveName:"condition", 			Width:110, 	Align:"Center", Edit:"false", ColMerge:0},
	    			{Header:'PO|Origin',						    Type:"Text", 			SaveName:"origin", 				Width:100, 	Align:"Left", Edit:"True"},
	    	        {Header:'Shipping Information|PKG',				Type:"Float", 			SaveName:"PACKAGE_QTY", 		Width:70, 	Align:"Right", Edit:"True", PointCount:2},
	    			{Header:'Shipping Information|KGS',				Type:"Float", 			SaveName:"PKG_WGT", 			Width:70, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|CBM',				Type:"Float", 	        SaveName:"PKG_CBM", 			Width:100, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|Shipping Mode',	Type:"Combo", 	  		SaveName:"shipping_mode", 		Width:130, 	Align:"Center", Edit:"True", ComboText:"<%=SHIP_NM%>", ComboCode:"<%=SHIP_CD%>"},
	    			{Header:'Shipping Information|20\'DC',			Type:"Float",    		SaveName:"twenty_dc", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|20\'OT',			Type:"Float", 		    SaveName:"twenty_dt", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|20\'FR',			Type:"Float", 		    SaveName:"twenty_fr", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|40\'DC',			Type:"Float", 		    SaveName:"fourty_dc", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|40\'OT',			Type:"Float", 		    SaveName:"fourty_dt", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|40\'FR',			Type:"Float", 		    SaveName:"fourty_fr", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Information|45\'FT',			Type:"Float", 		    SaveName:"fourty_fft", 			Width:40, 	Align:"Right", Edit:"True"},
	    			{Header:'Shipping Schedule|POL',	            Type:"Text", 			SaveName:"pol", 				Width:100, 	Align:"Left", Edit:"True"},
	    			{Header:'Shipping Schedule|POD',	            Type:"Text", 			SaveName:"pod", 				Width:100, 	Align:"Left", Edit:"True"},
	    			{Header:'Shipping Schedule|Vessel Name',		Type:"Text", 			SaveName:"vessel_name", 		Width:150, 	Align:"Left", Edit:"True"},
	    			{Header:'Shipping Schedule|B/L No',				Type:"Text", 			SaveName:"bl_no", 				Width:150,	Align:"Left", Edit:"True"},
	    			{Header:'Shipping Schedule|ETD POL',			Type:"Date", 			SaveName:"ESTI_DEPARTURE", 		Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'Shipping Schedule|ETA POD',			Type:"Date", 			SaveName:"ESTI_ARRIVAL", 		Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'Shipping Schedule|ATD POL',			Type:"Date", 			SaveName:"DEPARTURE", 			Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'Shipping Schedule|ATA POD',			Type:"Date", 			SaveName:"ARRIVAL", 			Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'Shipping Schedule|Customs Clearance',	Type:"Date", 			SaveName:"CLEAR_CUSTOM", 		Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'Shipping Schedule|ATA Site',			Type:"Date", 			SaveName:"ONSITE", 			    Width:90, 	Align:"Center", Edit:"True"},
	    			{Header:'ETC|<%=col[0]%>',		                Type:"Text", 			SaveName:"data1", 		   	    Width:90, 	Align:"Center", Edit:"True", Hidden:"<%=col_yn[0]%>"},
	    			{Header:'ETC|<%=col[1]%>',		                Type:"Text", 			SaveName:"data2", 			    Width:90, 	Align:"Center", Edit:"True", Hidden:"<%=col_yn[1]%>"},
	    			{Header:'ETC|<%=col[2]%>',		                Type:"Text", 			SaveName:"data3", 			    Width:90, 	Align:"Center", Edit:"True", Hidden:"<%=col_yn[2]%>"},
	    			{Header:'ETC|<%=col[3]%>',		                Type:"Text", 			SaveName:"data4", 			    Width:90, 	Align:"Center", Edit:"True", Hidden:"<%=col_yn[3]%>"},
	    			{Header:'ETC|<%=col[4]%>',		                Type:"Text", 			SaveName:"data5", 			    Width:90, 	Align:"Center", Edit:"True", Hidden:"<%=col_yn[4]%>"},
	    			{Header:'Remarks|Remarks',						Type:"Text", 			SaveName:"remarks", 			Width:400, 	Align:"Left", Edit:"True"},	    				    			
	    			{Header:'status|status',          				Type:"Text", 			SaveName:"STATUS_NM", 			Width:200, 	Align:"Left", Edit:"false" },
	    			{Header:'Confirm Date|Confirm Date',			Type:"Date", 			SaveName:"confirm_date", 		Width:90, 	Align:"Center", Edit:"false", Hidden:"True"},
	    			{Header:'Confirm User|Confirm User',			Type:"Text", 			SaveName:"confirm_emp_no", 		Width:90, 	Align:"Center", Edit:"false", Hidden:"True"},
	    			{Header:'shipping_id|shipping_id',				Type:"Text", 			SaveName:"shipping_id", 		Width:200, 	Align:"Left", Edit:"false", Hidden:"True"},
	    			{Header:'pur_cont_id|pur_cont_id',				Type:"Text", 			SaveName:"pur_cont_id", 		Width:200, 	Align:"Left", Edit:"false", Hidden:"True"},
	    			{Header:'status|status',          				Type:"Text", 			SaveName:"STATUS", 			    Width:200, 	Align:"Left", Edit:"false" , Hidden:"True"},
	    			{Header:'shipping_seq|shipping_seq',			Type:"Text", 		    SaveName:"shipping_seq", 		Width:200, 	Align:"Left", Edit:"false", Hidden:"True"},
	    			{Header:'선적서류|선적서류',			            Type:"Text", 		    SaveName:"file_cnt", 		    Width:50, 	Align:"Center", Edit:"false", Cursor:'pointer'},
	    			{Header:'Dummy',								Type:"AutoSum",			SaveName:"", 					Width:0, 	Align:"Center", Edit:"false", Hidden:"True"}
	    			];

	init_sheet.HeaderMode = {Sort:1};
	IBS_InitSheet(sheetName, init_sheet);
	sheetName.SetDataAutoTrim(0); 
	setGridSize();	
	
} 

function sheet2_OnSearchEnd(code, message) {
    if(code == 0) {
    	var sumPKG = 0.0;
    	var sumKGS = 0.0;
    	var sumCBM = 0.0;
    	var sum20DC = 0.0;
    	var sum20OT = 0.0;
    	var sum20FR = 0.0;
    	var sum40DC = 0.0;
    	var sum40OT = 0.0;
    	var sum40FR = 0.0;
    	var sum45FT = 0.0;
    	
    	sheet2.SetColFontColor("ship_no", "#0000ff");  
    	
    	for (var i = 2; i <= sheet2.RowCount()+1; i ++){  
           	if (sheet2.GetCellValue(i, "STATUS") =="2" || sheet2.GetCellValue(i, "STATUS") == "9"){
           		sheet2.SetRowEditable(i, false);           		
           	} 
           	
           	if(sheet2.GetCellValue(i-1, "ship_no") != sheet2.GetCellValue(i, "ship_no")){
           		sumPKG += Number(sheet2.GetCellValue(i, "PACKAGE_QTY"));
           		sumKGS += Number(sheet2.GetCellValue(i, "PKG_WGT"));
           		sumCBM += Number(sheet2.GetCellValue(i, "PKG_CBM"));
           		sum20DC += Number(sheet2.GetCellValue(i, "twenty_dc"));
           		sum20OT += Number(sheet2.GetCellValue(i, "twenty_dt"));
           		sum20FR += Number(sheet2.GetCellValue(i, "twenty_fr"));
           		sum40DC += Number(sheet2.GetCellValue(i, "fourty_dc"));
           		sum40OT += Number(sheet2.GetCellValue(i, "fourty_dt"));
           		sum40FR += Number(sheet2.GetCellValue(i, "fourty_fr"));
           		sum45FT += Number(sheet2.GetCellValue(i, "fourty_fft"));           		
           	}
        }

    	sheet2.SetSumValue(0,4,"합 계");
    	sheet2.SetCellAlign(sheet2.LastRow(),4,"Center");
    	sheet2.SetCellValue(sheet2.LastRow(),16,sumPKG.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet2.SetCellValue(sheet2.LastRow(),17,sumKGS.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet2.SetCellValue(sheet2.LastRow(),18,sumCBM.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet2.SetCellValue(sheet2.LastRow(),20,sum20DC.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet2.SetCellValue(sheet2.LastRow(),21,sum20OT.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet2.SetCellValue(sheet2.LastRow(),22,sum20FR.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet2.SetCellValue(sheet2.LastRow(),23,sum40DC.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet2.SetCellValue(sheet2.LastRow(),24,sum40OT.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet2.SetCellValue(sheet2.LastRow(),25,sum40FR.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	sheet2.SetCellValue(sheet2.LastRow(),26,sum45FT.toFixed(2).split(/(?=(?:\d{3})+(?:\.|$))/g).join(','));
    	
		var f= document.form1;
		var dept = "Project Name : " + f.dept_nm.value ;
		if(sheet2.RowCount() == 0) {
			alert("내역이 없습니다.");
			return;
		}
		
		var col_nm = "";
			
		<% for (int i = 0; i<5; i ++ ) {
			if(col[i].length() > 0 ){%>
				col_nm = col_nm + "data" + "<%=i+1%>" + "|";
			<%}
		}%>
			
		var params = { FileName : "SSRList.xls",  SheetName : "SSRList", SheetDesign:1, Merge:1, DownCols:"ship_no|inv_no|Partial_yn|ORD_DOC_NO|"+
					"description|vendor_info|CURRENCY|po_value|inv_cur|invoice_value|condition|origin|PACKAGE_QTY|PKG_WGT|PKG_CBM|shipping_mode|"+
					"twenty_dc|twenty_dt|twenty_fr|fourty_dc|fourty_dt|fourty_fr|pol|pod|vessel_name|bl_no|ESTI_DEPARTURE|ESTI_ARRIVAL|DEPARTURE|ARRIVAL|CLEAR_CUSTOM|ONSITE|"+col_nm+
			 		"remarks|STATUS_NM", TitleText:dept, UserMerge:"0,0,1,4", AutoSizeColumn:1, NumberTypeToText:1  } ;
			
		sheet2.Down2Excel(params);     	
	} else {
		alert(message);
	}    
}

$(document).on("keyup", "input:text", function(e) {
	if (e.keyCode == 13)
    {
    	jQuery("#btnSearch").click();
    }
});

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%;">
<div style="display:none;" id="fileMapIDDiv" class="attach_file_view" onPropertyChange="JavaScript:getFileListForTextarea();"></div>
<INPUT type="hidden" name="fevent" id="fevent" value="">
<INPUT type="hidden" name="shipping_id" id="shipping_id" value="">
<INPUT type="hidden" name="shipping_seq" id="shipping_seq" value="">

<div align="left" id="title">
    <ul>
     <li>Shipping Status Report</li>
    </ul>
  </div> 
  
	<!-- 검색조건 시작 -->
	<table id="search-table" class="search-form-table">
		<colgroup>
			<col width="80" />
			<col width="400" />
			<col width="120" />
			<col width="200" />
			<col width="80" />
			<col width="*" />
			<col width="200" />
		</colgroup>
		<tr>
			<th>Project</th>
			<td>
				<span>
		   		<%= InputText.get("dept_cd", user.get("dept_cd"), 5, 5, "hangule,center,desc=Project,ReadOnly") %>
		   		<%= InputText.get("dept_nm", user.get("dept_nm"), 30, 30, "hangule,desc=Project,ReadOnly") %>
		   		<IMG id='_btn_dept'  onClick="on_change_dept();" src='/img/buyer/button/bt_search_right.gif' border='0' align='absmiddle' alt='[현장찾기]' style='cursor:pointer;'>
                &nbsp;<IMG id='_btn_clear' onClick="dlgClearNew('dept_cd', 'dept_nm'); " src='/img/buyer/button/bt_eraser1.gif' border='0' align='absmiddle' alt='[초기화]' style='cursor:pointer;'>
				</span>
			</td>
			<th>POL ETD</th>
			<td colspan=3>
				<%= InputText.get("sYmdSt", params.get("sYmdSt"), 10, 50, "hangule,center, desc=기간,ReadOnly") %>
				<IMG name="sYmdSt_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgMCalendar('sYmdSt');">
							~
				<%= InputText.get("sYmdEd", params.get("sYmdEd"), 10, 50, "hangule,center, desc=기간,ReadOnly") %>
				<IMG name="sYmdEd_img" src="/img/buyer/button/bt_calender.gif" border="0" align="absmiddle" style="cursor:pointer;" onClick="JavaScript:dlgMCalendar('sYmdEd');">
				<IMG name="dataClear2" id="dataClear2" src="/img/buyer/button/bt_eraser1.gif" border="0" align="absmiddle" style="cursor:pointer;">
			</td>
			<td class="button" rowspan="3">
			<% if(storage.getUser().get("RIGHT_NAME").equals("PURCHASE")||storage.getUser().get("RIGHT_NAME").equals("ADMIN NEW")){%>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnSearch">Search</a></span>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnNew">New</a></span> 
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnSave">Save</a></span>
				<p style="height:2px;"></p>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnColModi">Def Column</a></span>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnExcelNew">Excel</a></span>
			<%}else { %>
			    <span class="btnSearch center"><a href="javascript:void(0);" id="btnSearch">Search</a></span>
				<span class="btnSearch center"><a href="javascript:void(0);" id="btnExcelNew">Excel</a></span>
			<%} %>
			</td>
		</tr>
		<tr>
			<th>PO No.</th>
			<td>
				<%= InputText.get("p_origin", params.get("p_origin"), 77, 50, "hangule, desc=origin, PerSize") %>
			</td>
			<th>Shipping Mode</th>
			<td>
				<%= CommCodeManager.getSelectCodeList("SHIP_MODE", "p_shipping_mode", "width:90%;height=18px;", "<option value=''>--전체--</option>", params.get("p_shipping_mode"), "") %>
			</td>
			<th>Status</th>
			<td>
				<SELECT name="p_status">
					<OPTION value="">--전체--</OPTION>
	                <OPTION value="1">작성</OPTION>
	                <OPTION value="2">업체요청</OPTION>
	                <OPTION value="3">업체완료</OPTION>
	                <OPTION value="9">완료</OPTION>
	            </SELECT>
			</td>
		</tr>
		<tr>
			<th>SRN No</th>
			<td>
				<%= InputText.get("p_srn_no", params.get("p_srn_no"), 20, 20, "english,left,desc=SRN NO") %>
			</td>
			<th>Vendor</th>
			<td colspan=3>
				<%= InputText.get("p_vendor", params.get("p_vendor"), 65, 80, "left,desc=Vendor") %>
			</td>
		</tr>
	</table>
	<!-- 검색조건 종료 -->
	<div id="sheet1_div" style="padding-top:5px; height: auto; min-height: 400px; overflow: auto;">
		<script>createIBSheet('sheet1','100%', '400px');</script>
	</div>
	<div id="sheet2_div"  style="display:none;">
		<script>createIBSheet('sheet2','100%', '400px');</script>
	</div>
</FORM>

