TAU409.jsp 7.43 KB
Newer Older
Thitichaipun Wutthisak committed
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*"  %>
<%@page import="java.util.*,java.net.*,java.io.*,com.csc.upload.*,com.csc.library.cscimport.MyImport;"%>
<jsp:useBean id="upload" class="com.csc.library.system.Task" scope="page"/>
<jsp:useBean id="hmul" class="com.csc.upload.HttpMultiPartParser" scope="page"/>
<%
	upload.setChannel(request,response); 
	upload.checkProfile();	
	UProfile u=upload.getUProfile();

 	InitialEnvironment en = new InitialEnvironment("GLOBAL");
    String filePath=en.getValue("dirimport-dir");

	String tempdir = ".";

	request.setAttribute("dir", request.getParameter("dir"));
	String browser_name = request.getRequestURI();	
	String status="";
	Hashtable ht=new Hashtable();	
	String dir="";
	//String table = "ttimetemp";
	String table="";
	String xml="";
	//out.print(filePath);

	if ((request.getContentType()!=null)&&(request.getContentType().toLowerCase().startsWith("multipart"))){
		response.setContentType("text/html");
		try{		
			int bstart = request.getContentType().lastIndexOf("oundary=");
			String bound = request.getContentType().substring(bstart+8);
			ht = hmul.processData(request.getInputStream(), bound, tempdir);
    		hmul.uploadFiles(ht);									
			u.set("upload","true");			
			dir=(String) ht.get("dir");
			xml=(String) ht.get("__xml");
			
			FileInfo f = (FileInfo) ht.get("myFile");
			String fileFullPath = f.file.toString();			
			String fileName="";
			StringTokenizer str = new StringTokenizer(fileFullPath, "\\");
			while (str.hasMoreTokens()) {
				fileName = str.nextToken();							
			}			
			//response.sendRedirect("ViewData.jsp?datafile="+fileFullPath+"&__xmlType="+xml);
			response.sendRedirect("TAU409_IMPORT.jsp?__fileName="+fileName+"&__cmd=process_data&__xml="+xml+"&__table="+table);
		}
		catch (Exception e){ e.printStackTrace(); }
	}	
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<link href="../CSS/bootstrap.css" rel="stylesheet"  type="text/css">
<link href="../CSS/bootstrap_csc_backend.css" rel="stylesheet"  type="text/css">
<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
<script type='text/javascript' src="../JS/bootstrap.js"></script>
<script language="JavaScript" src="../JS/SCREEN.js"></script>
<script type='text/javascript' src='/hr/dwr/interface/SearchDWR.js'></script>
<script type='text/javascript' src='/hr/dwr/engine.js'></script>
<script type='text/javascript' src='/hr/dwr/util.js'></script>
<script type="text/javascript" src="/hr/dwr/interface/SystemCode.js"></script>
<script type="text/javascript" src="/hr/dwr/interface/CscCalendar.js"></script>
<script language="javascript">setLang('<%=upload.getUProfile().get("lang")%>');</script>
<script language="JavaScript" >
<!--
function checktype(){
 	var stdstr="";
    with(document.cscform){
		if(myFile.value.length>0){
			stdstr=myFile.value.substring(myFile.value.lastIndexOf("\\")+1,myFile.value.length);
			if(stdstr.indexOf(".csv")>-1){				
				submit(); 
			}else if(stdstr.indexOf(".CSV")>-1){					
				submit(); 
			} else{
				alert("กรุณาเลือกไฟล์ (.csv) เท่านั้น");
			}
		} else if (myFile.value.length==0)
			alert("กรุณาเลือกไฟล์ก่อน");
	}
}

var moddata;
var isViewed = false;
function getFieldData(code){
	SystemCode.getValueDWR(new Array("FIELDTYPE",code,document.cscform.__language.value), {
	  callback:function(data) {	moddata= data	;},
	  async:false
	});

}

function modify(x){
	for(n=0;n<x.length;n++){
		getFieldData(x[n][3]);
		x[n][3] = moddata;
	}
	return x;
}

function chkType(fromView){
	if(fromView)
		isViewed=true;
	if(isViewed){
		with( document.cscform ){	
			var a = document.getElementById("trans");	
			var b = document.getElementById("head");	
			console.log(fromView);
			if(fromView == true){
				a.style.display="";
				b.style.display="";
			}
		}
	}
}



//-->
</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form  name="cscform"  enctype="multipart/form-data" method="POST" >
  <input type="hidden" name="__language" value="<%=upload.getUProfile().get("lang")%>">
 

<!----------BEGIN CSC INITIAL ZONE ------------------------>

<!--%=screen.InitialVariable()%>

<!----------END CSC INITIAL ZONE -------------------------->

<br>
  	<div align="center">
    <table  cellpadding="0"  cellspacing="0">
    <tr > 
    	<td  class="header">PRU316,&nbsp;<script language="javascript">swapLang("Import Set Punch");</script>&nbsp;</td> 
  	</tr>
    <tr > 
    	<td  colspan="2">
			<table width="630" border="0">            
          <tr> 
            	<td colspan="3"></td>
            </tr>
            <tr> 
             	<td class="columnlabel"><script language="javascript">swapLang("File");</script>&nbsp;</td>
              	<td colspan="2">
					<input type="hidden"name="__screen"  value="upload">
            		<input type="hidden" name="dir" value="<%=filePath%>">
            		<input type="file" name="myFile">				</td>				              	
           	</tr>

				<tr>
					<td  class="buttonline" colspan="7"><div align="center">
						<button type="button" class="btn btn-primary width100" swlang code="SW013170" onClick=chkType(true);">VIEW</button>&nbsp;
						<button type="button" class="btn btn-primary width100" swlang code="SW013181" onClick="checktype();">UPLOAD</button>
					</div>
					</td>
				</tr>
				&nbsp;&nbsp;&nbsp;
				<%=upload.getUProfile().get("lang").equalsIgnoreCase("THA") ? "กรุณาใช้ชื่อไฟล์เป็นภาษาอังกฤษ" : "Please Use English File Name Only" %>
			</td>
			</tr>
    
            <tr> 
              	<td colspan="3" class="blankspace"  ></td>
            </tr>
       	</table>		</td>
   	</tr>

   	    <tr id="head"  style="display:none"> 
    	<td  class="header"><script language="javascript">swapLang("Text Files Format Example");</script>&nbsp;</td> 
  	</tr>  
  	    <tr id="trans" style="display:none">
  	      <td align="center">
  	        <table width="200" border="0" align="center" cellpadding="0" cellspacing="0" class="large">
            <tr>
              <td><table width="200" border="0" cellpadding="0" cellspacing="0" class="inframe">
                <tr>
                  <td class="row3">employeeid,forget_date,forget_time,forget_type,reasonid,bossid</td>
                </tr>
                <tr>
                	<td><b>* Import ข้อมูลสูงสุด 50 รายการ&nbsp;</b></td>
                </tr>
                <tr>
                  <td><b>
                    <script language="javascript">swapLang("Example");</script> :&nbsp;</b></td>
                </tr>
                <tr name="trans">
                  <td class="columnData" >&nbsp;&nbsp;&nbsp;&nbsp;000001,2016-04-01,8.00,0,BL,410305</td>
                </tr>
                <tr name="trans">
                  <td class="columnData">&nbsp;&nbsp;&nbsp;&nbsp;000002,2016-12-30,18.00,1,OW,410305</td>
                </tr>
                
              </table></td>
            </tr>
          </table>
          </td>
      </tr>    	
 	    <tr> 
    	<td class="blankspace">&nbsp;</td>
   	  </tr>    
  	    <tr> 
    	<td  class="bottom"></td>
   	</tr>	  
    </table>

  </div>
</form>

</body>
</html>