<%@ page language="java" contentType="text/html;charset=Shift_JIS"%>
<%@ page import = "java.util.*"%>
<%@ page import = "java.sql.*"%>
<%//@ include file="../../connect.jsp" %>
<%@ include file="../../connect.jsp" %>

<HTML>
<HEAD>
<title>OpenOLAP Viewer</title>
<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<link rel="stylesheet" type="text/css" href="../../../css/explorer.css">
<link rel="stylesheet" type="text/css" href="../../../css/dimList.css">
<link rel="stylesheet" type="text/css" href="../../../css/rightclick.css"/>
<link rel="stylesheet" type="text/css" href="../../../css/tree.css"/>
<script type="text/javascript" src="../js/spread.js"></script>
<script type="text/javascript" src="../js/colRange.js"></script>
<%
String objSeq = (String)session.getValue("objSeq");
%>
<script type="text/javascript" src="../js/tableRightclick.js"></script>
</HEAD>
<BODY id="SpreadBody" onload="loadSpread();createMenu();" onselectstart="return false" onresize="resizeArea()" onContextmenu="return false" ondrop="return false" ondragenter="return false" ondragover="return false" topmargin="0" leftmargin="0">

<FORM name="SpreadForm" method="post" action="">
<SPAN onmousedown="mouseDown();" onmouseup="mouseUp();">
<TABLE id="SpreadTable" class="SpreadTable">
<TR>
<TD>
<SPAN id="ColumnHeaderArea" onmousemove="mouseMove();">
<TABLE class="ColumnHeaderTable" cellspacing="0" cellpadding="2">
<COLGROUP id="CH_CG">
<COL id="CH_CG0" style="width:150;">
<COL id="CH_CG1" style="width:30;">
<COL id="CH_CG2" style="width:50;">
<COL id="CH_CG3" style="width:150;">
<COL width="80">
</COLGROUP>
<TR ID="CH_R0" Spread="ColumnHeaderRow">
<TD id="CH_R0C0">名前</TD>
<TD id="CH_R0C1">ID</TD>
<TD id="CH_R0C2">種類</TD>
<TD id="CH_R0C3">最終更新日</TD>
<TD style="border:none;" class="adjustCell"></TD>
</TR>
</TABLE></SPAN></TD>
</TR>
<TR>
<TD>
<DIV id="DataTableArea">
<TABLE id="DataTable" cellspacing="0" cellpadding="2">
<COLGROUP>
<COL id="DT_CG0" style="width:150;">
<COL id="DT_CG1" style="width:30;">
<COL id="DT_CG2" style="width:50;">
<COL id="DT_CG3" style="width:150;">
</COLGROUP>


<%
/*
Connection connMeta = null;
Statement stmt = null;
Statement stmt2 = null;
Statement stmt3 = null;
ResultSet rs = null;
ResultSet rs2 = null;
ResultSet rs3 = null;
connMeta = (Connection)session.getValue(session.getId()+"Conn");
stmt     = (Statement) session.getValue(session.getId()+"Stmt");
stmt2     = (Statement) session.getValue(session.getId()+"Stmt2");
stmt3     = (Statement) session.getValue(session.getId()+"Stmt3");
*/


String dimSeq = (String)session.getValue("dimSeq");


	String keyStr = request.getParameter("id");
	String SQL ="";





	SQL = 		" select ";
	SQL = SQL + " report_id,'---' AS code,report_name,to_char(update_date,'YYYY/MM/DD') as long_name,'---' as min_val,'---' as max_val,kind_flg AS kind";
	SQL = SQL + " from " + session.getValue("CustomTableName") + "";

	if (keyStr.equals("root")) {
		SQL = SQL + " where par_id is null ";
	} else {
		SQL = SQL + " where par_id= " + keyStr;
	}
	SQL = SQL + " ORDER BY kind_flg,report_name";
	rs = stmt.executeQuery(SQL);





	//クローンバーチャルフォルダ
	out.println("<TR id='clone' kind='F' selectflg='0' style='display:none;'>");
	out.println("<TD><nobr><IMG SRC='../../../images/tree/folder2.gif'/><A href='javascript:return false;' onclick='objClick(this);return false;' ondragstart='JavaScript:startDrag()' ondragend='JavaScript:endDrag();' ondrop='JavaScript:drop();'  ondragover='JavaScript:overDrag();' ondragleave='JavaScript:leaveDrag();' ondragenter='JavaScript:enterDrag();' ondblclick='JavaScript:dblclickClickNode(this);'></A></nobr></TD>");
	out.println("<TD><nobr></nobr></TD>");
	out.println("<TD><nobr></nobr></TD>");
	out.println("<TD><nobr></nobr></TD>");
	out.println("</TR>");

	while(rs.next()) {





			String imgKind="";
			if ("R".equals((rs.getString("kind")))) {
				imgKind = "../../../images/tree/report2.gif";
			} else if ("F".equals((rs.getString("kind")))) {
				imgKind = "../../../images/tree/folder2.gif";
			} else {
				imgKind = "../../../images/foldericon2.gif";
			}


			out.println("<TR id='"+rs.getString("report_id")+"' kind='"+rs.getString("kind")+"' selectflg='0'>");
			out.println("<TD><nobr><IMG SRC='" + imgKind + "'/><A href='javascript:return false;' onclick='objClick(this);return false;' ondragstart='JavaScript:startDrag()' ondragend='JavaScript:endDrag();' ondrop='JavaScript:drop();'  ondragover='JavaScript:overDrag();' ondragleave='JavaScript:leaveDrag();' ondragenter='JavaScript:enterDrag();' ondblclick='JavaScript:dblclickClickNode(this);'>"+rs.getString("report_name")+"</A></nobr></TD>");
			out.println("<TD><nobr>"+rs.getString("report_id")+"</nobr></TD>");
			if ("R".equals((rs.getString("kind")))) {
				out.println("<TD><nobr>レポート</nobr></TD>");
			} else if ("F".equals((rs.getString("kind")))) {
				out.println("<TD><nobr>フォルダ</nobr></TD>");
			}
			out.println("<TD><nobr>"+rs.getString("long_name")+"</nobr></TD>");

			out.println("</TR>");




	}
	rs.close();
//	out.println("</TABLE>");


%>

</TABLE>
</DIV>
</TD>
</TR>
</TABLE></SPAN>

<input type="hidden" name="hid_par_key" value="<%=keyStr%>"/>
<input type="hidden" name="hid_delete_key" value="<%=keyStr%>"/>
</FORM>
</BODY>
</HTML>

<script language="JavaScript">



function dblclickClickNode(obj){

	var DataTable = document.getElementById("DataTable");
	var nodeId = DataTable.rows[obj.parentNode.parentNode.parentNode.rowIndex].id;

//	if (th.att=="F"){//Fileだったら、何もしない。
//		return;
//	}

	var preClickObj;
	var preClickAhref;
	preClickObj=parent.navi_frm2.getpreClickObj();

	if (preClickObj.lastChild.style.display=='none'){
		parent.navi_frm2.reversePreNextImage(preClickObj);
		parent.navi_frm2.reversePM(preClickObj);
		parent.navi_frm2.reverseDisplay(preClickObj);
	}
	for(i=0;i<preClickObj.lastChild.childNodes.length;i++){
		if(preClickObj.lastChild.childNodes[i].id==nodeId){
			parent.navi_frm2.Toggle('f',preClickObj.lastChild.childNodes[i].lastChild.previousSibling.previousSibling,'report_mng_tree_table.jsp?id='+nodeId);
			return;
		}
	}
}



var srcObj = new Object;

var dummyObj;
var dragData;

function startDrag(){
	window.event.srcElement.parentNode.parentNode.parentNode.selectflg="1";
	window.event.srcElement.style.backgroundColor="navy";
	window.event.srcElement.style.color="white";

	parent.navi_frm2.strDragStart = "TABLE_FRAME";


	var strSelectedKey="";

	var DataTable = document.getElementById("DataTable");
	for(i=0;i<DataTable.rows.length;i++){
		if(DataTable.rows[i].selectflg=="1"){
			if(strSelectedKey!=""){
				strSelectedKey+=",";
			}
			strSelectedKey+=DataTable.rows[i].id;
		}
	}

    dragData = window.event.dataTransfer;

    dragData.setData('Text', strSelectedKey);

    dragData.effectAllowed = 'linkMove';

    dragData.dropEffect = 'move';
}



function enterDrag() {
    window.event.dataTransfer.getData('Text');
}

function endDrag() {
    window.event.dataTransfer.clearData();
}

function overDrag() {
}

function leaveDrag() {
}

function drop() {
}










function addMember(arg1,arg2,arg3,arg4){
}




var lastSelectRow;
function objClick(obj){
	if(!window.event.ctrlKey){
		resetRow();
	}
	if(window.event.shiftKey){
		var DataTable = document.getElementById("DataTable");
		for(i=lastSelectRow;i<=obj.parentNode.parentNode.parentNode.rowIndex;i++){
			DataTable.rows[i].selectflg="1";
			DataTable.rows[i].cells[0].firstChild.childNodes[1].style.backgroundColor="navy";
			DataTable.rows[i].cells[0].firstChild.childNodes[1].style.color="white";
		}
		for(i=obj.parentNode.parentNode.parentNode.rowIndex;i<=lastSelectRow;i++){
			DataTable.rows[i].selectflg="1";
			DataTable.rows[i].cells[0].firstChild.childNodes[1].style.backgroundColor="navy";
			DataTable.rows[i].cells[0].firstChild.childNodes[1].style.color="white";
		}
	}else{
		obj.parentNode.parentNode.parentNode.selectflg="1";
		obj.style.backgroundColor="navy";
		obj.style.color="white";
	}
	lastSelectRow=obj.parentNode.parentNode.parentNode.rowIndex;

}


function resetRow(){
	var DataTable = document.getElementById("DataTable");
	for(i=0;i<DataTable.rows.length;i++){
		DataTable.rows[i].selectflg="0";
		DataTable.rows[i].cells[0].firstChild.childNodes[1].style.backgroundColor="white";
		DataTable.rows[i].cells[0].firstChild.childNodes[1].style.color="black";
	}
}
</script>

<%@ include file="../../connect_close.jsp" %>
