Commit c64fcee4 authored by chavanp's avatar chavanp

UPDATE TO DOWNLOAD GST TEMPLATE ON BUTTON CLICK.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@106725 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 70abebbf
......@@ -4,9 +4,16 @@
<%@ page import="java.net.URLEncoder"%>
<%@ page import="java.io.*" %>
<%@ page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page trimDirectiveWhitespaces="true" %>
<%
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- <title>Excel File DOWNLOADED...</title>
--></head>
<body>
<!-- <h2> Excel File DOWNLOADED...</h2>
--> <%
ibase.utility.UserInfoBean userInfo = (ibase.utility.UserInfoBean)session.getAttribute("USER_INFO");
String referer = request.getRequestURL().toString();
referer = referer.substring( referer.indexOf( "ibase" ) - 1 );
......@@ -16,46 +23,86 @@
if( userInfo == null )
{
%>
<jsp:forward page="/jsp/DirectAccess.jsp">
<%-- <jsp:forward page="/jsp/DirectAccess.jsp">
<jsp:param name="REFERER" value="<%=referer%>"/>
</jsp:forward>
</jsp:forward> --%>
<%
}
String filePath1 = "";
String objName = request.getParameter("OBJ_NAME");
String Description=request.getParameter("DESCR");
String download = request.getParameter("download");
%>
<%
String objName = request.getParameter("OBJ_NAME");
System.out.println("objName ["+objName+"]");
if("gstr".equalsIgnoreCase(objName))
{
String filePath = CommonConstants.JBOSSHOME+File.separator+"DOWNLOAD"+File.separator+"template"+File.separator+"GSTR1_Template.xls";
System.out.println("filepath in jsp file is........." + filePath);
response.setContentType("application/excel");
System.out.println("file name is........." );
String fileName = "GSTR1_Template.xls";
response.setHeader("Content-Disposition","attachment; fileName=\"" + fileName + "\"");
java.io.FileInputStream fileInputStream=new java.io.FileInputStream(filePath);
HSSFWorkbook workBook = new HSSFWorkbook(fileInputStream);
OutputStream outStream = response.getOutputStream();
workBook.write(outStream);
outStream.flush();
try
{
System.out.println("Description ["+download+"]");
if("Yes".equalsIgnoreCase(download))
{
if("gstr".equalsIgnoreCase(objName))
{
String filePath = CommonConstants.JBOSSHOME+File.separator+"DOWNLOAD"+File.separator+"template"+File.separator+"GSTR-1_Template.xls";
System.out.println("filepath in jsp file is........." + filePath);
response.setContentType("application/excel");
System.out.println("file name is sales." );
String fileName = "GSTR-1_Template.xls";
response.setHeader("Content-Disposition","attachment; fileName=\"" + fileName + "\"");
java.io.FileInputStream fileInputStream=new java.io.FileInputStream(filePath);
HSSFWorkbook workBook = new HSSFWorkbook(fileInputStream);
out.clear();
OutputStream outStream = response.getOutputStream();
workBook.write(outStream);
outStream.flush();
outStream.close();
}
else
{
String filePath = CommonConstants.JBOSSHOME+File.separator+"DOWNLOAD"+File.separator+"template"+File.separator+"GSTR-2_Template.xls";
System.out.println("filepath in jsp file is........." + filePath);
response.setContentType("application/excel");
System.out.println("file name is purchase." );
String fileName = "GSTR-2_Template.xls";
response.setHeader("Content-Disposition","attachment; fileName=\"" + fileName + "\"");
java.io.FileInputStream fileInputStream=new java.io.FileInputStream(filePath);
HSSFWorkbook workBook = new HSSFWorkbook(fileInputStream);
out.clear();
OutputStream outStream = response.getOutputStream();
workBook.write(outStream);
outStream.flush();
outStream.close();
}
}
else
{
String filePath = CommonConstants.JBOSSHOME+File.separator+"Download"+File.separator+"Template"+File.separator+"GSTR2_Template.xls";
System.out.println("filepath in jsp file is........." + filePath);
response.setContentType("application/excel");
System.out.println("file name is........." );
String fileName = "GSTR2_Template.xls";
response.setHeader("Content-Disposition","attachment; fileName=\"" + fileName + "\"");
java.io.FileInputStream fileInputStream=new java.io.FileInputStream(filePath);
HSSFWorkbook workBook = new HSSFWorkbook(fileInputStream);
OutputStream outStream = response.getOutputStream();
workBook.write(outStream);
outStream.flush();
}
}catch (Exception e)
{
System.out.println("Exception occour...."+e );
}
%>
<html>
<body>
<!-- <h2> Excel File DOWNLOADED...</h2>
-->
<link rel="stylesheet" type="text/css" href="/ibase/webitm/css/Galaxy/galaxy-theme.css" media="screen"/>
<link rel="stylesheet" href="/ibase/webitm/css/GetGSTTemplate.css" >
<div class="agile-its">
<div>
<% out.print(Description); %>
</div>
<div class ="txtDiv">
<% out.print("Click Button To Download Template"); %>
</div>
<iframe id="my_iframe" style="display:none;"></iframe>
<div class="btnDiv">
<input type="button" onclick="Download('/ibase/webitm/jsp/GetGSTTemplate.jsp?OBJ_NAME=<%=objName%>&download=Yes')" value="Download">
</div>
</div>
</body>
<script>
function Download(url)
{
document.getElementById('my_iframe').src = url;
};
</script>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment