Commit 126915b3 authored by prumde's avatar prumde

Updated

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@211006 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 64c84796
<%System.out.println("------------BGProcessStatus Called------"); %> <%System.out.println("------------executeSaleTrends Called------"); %>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<%@page import="ibase.webitm.bean.*, ibase.utility.CommonConstants"%> <%@page import="ibase.webitm.bean.*, ibase.utility.CommonConstants"%>
<%@page import="ibase.webitm.utility.ITMException"%> <%@page import="ibase.webitm.utility.ITMException"%>
...@@ -10,42 +10,258 @@ ...@@ -10,42 +10,258 @@
<%@page import="java.sql.*"%> <%@page import="java.sql.*"%>
<%@page import="java.sql.DriverManager"%> <%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.SQLException"%> <%@page import="java.sql.SQLException"%>
<%@page import="ibase.webitm.reports.utility.CustwiseSalesBean"%>
<%@page import="ibase.system.config.ConnDriver"%> <%@page import="ibase.system.config.ConnDriver"%>
<%!
public HashMap getSQLResultData(String sqlStr, String transDB)
{
HashMap sqlDataMap = null;
Connection con = null;
Statement stmt=null;;
ResultSet rs = null;
<html> try
<head> {
<style> System.out.println("Inside SaleTrendsDetails::getSQLResultData transDB [" +transDB + "] SQL Exection done ! SQL => \n " + sqlStr);
#dataTable {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; ConnDriver mConnDriver = new ConnDriver();
border-collapse: collapse; con = mConnDriver.getConnectDB(transDB);
width: 100%; if( con == null ) {
} System.out.println("Unable to get connection for [" + transDB + "]");
throw new Exception("Unable to get connection for [" + transDB + "]");
}
ArrayList<HashMap<String, String>> dataRows = new ArrayList<HashMap<String, String>>();
HashMap<Integer, String> dataCols = new HashMap<Integer, String>();
sqlDataMap = new HashMap();
int noOfRows = 0;
int noOfColumns = 0;
#dataTable td, #dataTable th { stmt = con.createStatement();
border: 1px solid #ddd; rs = stmt.executeQuery(sqlStr);
padding: 8px;
white-space: nowrap; ResultSetMetaData rsmd = rs.getMetaData();
while(rs.next())
{
//System.out.println("Result iteration !");
HashMap<String, String> rowDataMap = new HashMap<String, String>();
noOfColumns = rsmd.getColumnCount();
//System.out.println("Result noOfColumns !" + noOfColumns);
for(int ctr = 1; ctr <= noOfColumns; ctr++)
{
if( noOfRows == 0 )
{
dataCols.put(ctr, rsmd.getColumnName(ctr));
}
rowDataMap.put(rsmd.getColumnName(ctr), rs.getString(ctr));
}
//System.out.println("Result dataMap !" + dataMap);
dataRows.add(rowDataMap);
noOfRows++;
}
//System.out.println("Result dataArray !" + dataArray);
sqlDataMap.put("COLS", dataCols);
sqlDataMap.put("ROWS", dataRows);
}
catch(Exception e)
{
sqlDataMap = null;
System.out.println("Inside SaleTrendsDetails::getSQLResultData Exception : " + e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if( stmt != null )
{
stmt.close();
stmt = null;
}
if( con != null )
{
con.close();
con = null;
}
}
catch( Exception eI )
{
eI.printStackTrace();
}
}
return sqlDataMap;
} }
#dataTable tr:nth-child(even){background-color: #f2f2f2;} %>
#dataTable tr:hover {background-color: #ddd;} <html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<style>
/*
#dataTable {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
margin : 16px;
width: auto;
}
#dataTable th { #dataTable td, #dataTable th {
padding-top: 12px; border: 1px solid #ddd;
padding-bottom: 12px; padding: 8px;
text-align: left; white-space: nowrap;
background-color: #b4adee ; /*#5fdeb2*/ text-transform: capitalize;
color: white; }
} #dataTable td {text-align: right;}
</style>
</head> #dataTable tr:nth-child(even){background-color: #f2f2f2;}
<body>
<Div style="position:relative;top:0;left:0;height:85%;width:100%;overflow:scroll;"> #dataTable tr:hover {background-color: #ddd;}
#dataTable th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #b4adee ;
color: white;
}
*/
*{
font-family: Arial, Helvetica, sans-serif;
}
body{
background-color: #efefef;
}
.db-kpi-container{
background-color: #efefef;
display: grid;
width: 100%;
height: auto;
}
.db-kpi-row {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
}
.db-kpi-column {
display: flex;
flex-direction: column;
flex-basis: 100%;
flex: 1;
padding: 3px;
}
.kpi-card-containers {
padding: 0 0.3em 0 0;
}
.detail-box {
display: block;
color: #fff;
text-align: center;
height: 150px;
width: calc(100% - 16px);
position: relative;
MIN-WIDTH: 0;
float: left;
box-shadow: 0 0 15px -5px rgba(0,0,0,.1), 0 0 0 1px rgb(144,157,165,.1);
margin: 10px;
border-radius: 4px;
overflow: hidden;
}
.detail-box-kpi-value{
display: block;
font-size: 52px;
position: relative;
height: 108px;
line-height: 118px;
}
.detail-box-kpi-name{
font-size: 14px;
display: block;
position: relative;
background-color: rgba(0,0,0,.07);
height: 42px;
line-height: 44px;
font-weight: 700;
}
.summary-box{
display: block;
text-align: center;
height: 80px;
width: calc(100% - 16px);
position: relative;
MIN-WIDTH: 0;
background-color: #fff;
float: left;
box-shadow: 0 0 15px -5px rgba(0,0,0,.1), 0 0 0 1px rgb(144,157,165,.1);
margin: 10px;
border-radius: 4px;
overflow: hidden;
}
.summary-box-kpi-value{
font-size: 42px;
line-height: 68px;
}
.summary-box-kpi-name{
display: block;
position: relative;
bottom: 14px;
font-size: 14px;
font-weight: bold;
line-height: 24px;
}
@media screen and (min-width: 64em){
.large-3 {
width: calc(25% - 5px) !important;
}
}
@media screen and (max-width: 39.9375em) {
.small-12 {
width: 100% !important;
}
}
@media screen and (min-width: 40em){
.medium-4 {
width: calc(33.33333% - 5px);
}
}
.column, .columns {
float: left;
}
.ang-dbtitle {
font-size: 18px;
color: #666;
}
.ang-dbSubTitleLbl {
font-size: 14px;
font-weight: 400;
color: #787878;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<% <%
//Modified by Ahmed on 15/06/2016 [UserInfoBean is initialized and session is checked] [START]
UserInfoBean userInfo = (ibase.utility.UserInfoBean) session.getAttribute("USER_INFO"); UserInfoBean userInfo = (ibase.utility.UserInfoBean) session.getAttribute("USER_INFO");
String referer = request.getRequestURL().toString(); String referer = request.getRequestURL().toString();
referer = referer.substring(referer.indexOf("ibase") - 1); referer = referer.substring(referer.indexOf("ibase") - 1);
...@@ -78,202 +294,299 @@ ...@@ -78,202 +294,299 @@
{ {
month = "10/2019"; month = "10/2019";
} }
Connection con = null;
Statement stmt=null;;
ResultSet rs = null;
StringBuffer htmlStrBuff = new StringBuffer();
try try
{ {
StringBuffer sqlbuffer = new StringBuffer(); StringBuffer summarySqlBuff = new StringBuffer();
sqlbuffer.append("select DSS.DOC_DATE as \"TRANSACTION DATE\","); summarySqlBuff.append(" select DHH.POS_CODE, DHH.LV1_DESCR, ");
sqlbuffer.append(" DSS.POS_CODE as \"LEVEL CODE\","); summarySqlBuff.append(" SUM(DSS.SALES_VALUE) as \"SALES VALUE\", ");
sqlbuffer.append(" DHH.lv4 as \"LEVEL1 CODE\","); summarySqlBuff.append(" SUM(DSS.SALES_QTY) as \"SALES QUANTITY\", ");
sqlbuffer.append(" DHH.lv4_descr as \"LEVEL1 DESCRIPTION\","); summarySqlBuff.append(" SUM(DSS.FREE_SALES_VALUE) as \"FREE SALES VALUE\", ");
sqlbuffer.append(" DHH.lv3 as \"LEVEL2 CODE\","); summarySqlBuff.append(" SUM(DSS.FREE_QTY) as \"FREE QUANTITY\", ");
sqlbuffer.append(" DHH.lv3_descr as \"LEVEL2 DESCRIPTION\","); summarySqlBuff.append(" SUM(DSS.NET_SALES_VALUE) as \"NET SALES VALUE\", ");
sqlbuffer.append(" DHH.lv2 as \"LEVEL3 CODE\","); summarySqlBuff.append(" SUM(DSS.NET_SALES_QTY) as \"NET SALES QUANTITY\", ");
sqlbuffer.append(" DHH.lv2_descr as \"LEVEL3 DESCRIPTION\","); summarySqlBuff.append(" SUM(DSS.GROSS_SALES_VALUE) as \"GROSS SALES VALUE\", ");
sqlbuffer.append(" DHH.lv1 as \"LEVEL4 CODE\","); summarySqlBuff.append(" SUM(DSS.REPL_VALUE) as \"REPLACEMENT VALUE\", ");
sqlbuffer.append(" DHH.lv1_descr as \"LEVEL4 DESCRIPTION\","); summarySqlBuff.append(" SUM(DSS.SALEABLE_RETURN_QTY) as \"SALEABLE RETURN QUANTITY\", ");
sqlbuffer.append(" DHH.POS_CODE as \"POSITION CODE\","); summarySqlBuff.append(" SUM(DSS.SALEABLE_RETURN_AMT) as \"SALEABLE RETURN VALUE\", ");
sqlbuffer.append(" DHH.POOL_CODE as \"POOL CODE\","); summarySqlBuff.append(" SUM(DSS.BREAKAGE_RETURN_QTY) as \"DAMAGED RETURN QUANTITY\", ");
sqlbuffer.append(" DHH.TABLE_NO as \"TABLE NO\","); summarySqlBuff.append(" SUM(DSS.BREAKAGE_RETURN_AMT) as \"DAMAGED RETURN VALUE\", ");
sqlbuffer.append(" DHH.VERSION_ID as \"VERSION ID\","); summarySqlBuff.append(" SUM(DSS.EXPIRY_RETURN_QTY) as \"EXPIRY RETURN QUANTITY\", ");
sqlbuffer.append(" DSS.CUST_CODE as \"CUSTOMER CODE\","); summarySqlBuff.append(" SUM(DSS.EXPIRY_RETURN_AMT) as \"EXPIRY RETURN VALUE\", ");
sqlbuffer.append(" (SELECT CUST_NAME from SUNERP.CUSTOMER where CUST_CODE = DSS.CUST_CODE) as \"CUSTOMER NAME\","); summarySqlBuff.append(" SUM(DSS.CORRECTION_RETURN_QTY) as \"CANCELED RETURN QUANTITY\", ");
sqlbuffer.append(" DSS.SITE_CODE as \"SITE CODE\","); summarySqlBuff.append(" SUM(DSS.CORRECTION_RETURN_AMT) as \"CANCELED RETURN VALUE\", ");
sqlbuffer.append(" (SELECT DESCR from SUNERP.SITE where SITE_CODE = DSS.SITE_CODE) as \"SITE DESCRIPTION\","); summarySqlBuff.append(" SUM(DSS.REPL_RETURN_QTY) as \"REPLACEMENT RETURN QUANTITY\", ");
sqlbuffer.append(" DSS.ITEM_CODE AS \"ITEM CODE\", I.DESCR AS \"ITEM DESCRIPTION\","); summarySqlBuff.append(" SUM(DSS.REPL_RETURN_VALUE) as \"REPLACEMENT RETURN VALUE\", ");
sqlbuffer.append(" I.ITEM_SER as \"ITEM SERIES\","); summarySqlBuff.append(" SUM(DSS.RETURN_QTY) as \"RETURN QUANTITY\", ");
sqlbuffer.append(" ISER.DESCR as \"ITEM SERIES DESCRIPTION\","); summarySqlBuff.append(" SUM(DSS.RETURN_VALUE) as \"RETURN VALUE\", ");
sqlbuffer.append(" ISER.PRODUCT_LINE as \"PRODUCT LINE\","); summarySqlBuff.append(" SUM(DSS.GROSS_RETURN_VALUE) as \"GROSS RETURN VALUE\", ");
sqlbuffer.append(" (SELECT descr from SUNERP.GENCODES where FLD_NAME='PRODUCT_LINE' AND mod_name='W_ITEMSER' AND RPAD(fld_value, 5, ' ') = ISER.PRODUCT_LINE) as \"PRODUCT LINE DESCRIPTION\","); summarySqlBuff.append(" SUM(DSS.NET_RETURN_VALUE) as \"NET RETURN VALUE\" , ");
sqlbuffer.append(" DSS.NET_SALES_VALUE as \"NET SALES VALUE\","); summarySqlBuff.append(" SUM(DSS.CGST_AMT) as \"CGST Amount\", ");
sqlbuffer.append(" DSS.SALES_QTY as \"SALES QUANTITY\","); summarySqlBuff.append(" SUM(DSS.SGST_AMT) as \"SGST Amount\", ");
sqlbuffer.append(" DSS.GROSS_SALES_VALUE as \"GROSS SALES VALUE\","); summarySqlBuff.append(" SUM(DSS.IGST_AMT) as \"IGST Amount\" ");
sqlbuffer.append(" DSS.FREE_QTY as \"FREE QUANTITY\","); summarySqlBuff.append(" from MESMERVIS.DWH_SALES_SUM DSS ");
sqlbuffer.append(" DSS.FREE_SALES_VALUE as \"FREE SALES VALUE\","); summarySqlBuff.append(" LEFT OUTER JOIN MESMERVIS.ITEM I ON DSS.ITEM_CODE = I.ITEM_CODE ");
sqlbuffer.append(" DSS.NET_SALES_QTY as \"NET SALES QUANTITY\","); summarySqlBuff.append(" LEFT OUTER JOIN MESMERVIS.ITEMSER ISER ON I.ITEM_SER = ISER.ITEM_SER, ");
sqlbuffer.append(" DSS.REPL_VALUE as \"REPLACEMENT VALUE\","); summarySqlBuff.append(" ( ");
sqlbuffer.append(" DSS.SALEABLE_RETURN_QTY as \"SALEABLE RETURN QUANTITY\","); summarySqlBuff.append(" select lv4.level_no lv1_no, lv1.pos_code lv1, lv1.pos_code__repto lv1_repo, case when lv1.descr is null then 'NA' else lv1.descr end lv1_descr, ");
sqlbuffer.append(" DSS.SALEABLE_RETURN_AMT as \"SALEABLE RETURN VALUE\","); summarySqlBuff.append(" lv2.pos_code lv2, lv2.pos_code__repto lv2_repo, case when lv2.descr is null then 'NA' else lv2.descr end lv2_descr, ");
sqlbuffer.append(" DSS.BREAKAGE_RETURN_QTY as \"DAMAGED RETURN QUANTITY\","); summarySqlBuff.append(" lv3.pos_code lv3, lv3.pos_code__repto lv3_repo, case when lv3.descr is null then 'NA' else lv3.descr end lv3_descr, ");
sqlbuffer.append(" DSS.BREAKAGE_RETURN_AMT as \"DAMAGED RETURN VALUE\","); summarySqlBuff.append(" lv4.pos_code lv4, lv4.pos_code__repto lv4_repo, case when lv4.descr is null then 'NA' else lv4.descr end lv4_descr, ");
sqlbuffer.append(" DSS.EXPIRY_RETURN_QTY as \"EXPIRY RETURN QUANTITY\","); summarySqlBuff.append(" lv1.pos_code, lv1.table_no, lv1.version_id, lv1.pool_code ");
sqlbuffer.append(" DSS.EXPIRY_RETURN_AMT as \"EXPIRY RETURN VALUE\","); summarySqlBuff.append(" from MESMERVIS.org_structure lv1 ");
sqlbuffer.append(" DSS.CORRECTION_RETURN_QTY as \"CANCELED RETURN QUANTITY\","); summarySqlBuff.append(" left outer join MESMERVIS.org_structure lv2 on lv1.pos_code__repto = lv2.pos_code and Lv1.TABLE_NO=Lv2.TABLE_NO and Lv1.VERSION_ID=Lv2.VERSION_ID ");
sqlbuffer.append(" DSS.CORRECTION_RETURN_AMT as \"CANCELED RETURN VALUE\","); summarySqlBuff.append(" left outer join MESMERVIS.org_structure lv3 on lv2.pos_code__repto = lv3.pos_code and Lv2.TABLE_NO=Lv3.TABLE_NO and Lv2.VERSION_ID=Lv3.VERSION_ID ");
sqlbuffer.append(" DSS.REPL_RETURN_QTY as \"REPLACEMENT RETURN QUANTITY\","); summarySqlBuff.append(" left outer join MESMERVIS.org_structure lv4 on lv3.pos_code__repto = lv4.pos_code and Lv3.TABLE_NO=Lv4.TABLE_NO and Lv3.VERSION_ID=Lv4.VERSION_ID ");
sqlbuffer.append(" DSS.REPL_RETURN_VALUE as \"REPLACEMENT RETURN VALUE\","); summarySqlBuff.append(" ) DHH ");
sqlbuffer.append(" DSS.RETURN_QTY as \"RETURN QUANTITY\","); summarySqlBuff.append(" WHERE DHH.POS_CODE = DSS.POS_CODE ");
sqlbuffer.append(" DSS.GROSS_RETURN_VALUE as \"GROSS RETURN VALUE\","); summarySqlBuff.append(" AND DHH.VERSION_ID in (SELECT V.VERSION_ID FROM MESMERVIS.VERSION V WHERE TO_DATE(SYSDATE) BETWEEN V.EFF_FROM AND V.VALID_UPTO) ");
sqlbuffer.append(" DSS.NET_RETURN_VALUE as \"NET RETURN VALUE\" ,"); summarySqlBuff.append(" AND DHH.TABLE_NO=NVL(ISER.TABLE_NO__HIER, ISER.ITEM_SER) ");
sqlbuffer.append(" DSS.TRAN_ID,"); summarySqlBuff.append(" AND to_char(DSS.DOC_DATE, 'MM/YYYY')= '"+ month +"' ");
sqlbuffer.append(" DSS.REPL_QTY as \"REPLACEMENT QUANTITY\","); summarySqlBuff.append(" AND I.ITEM_SER >= '00' ");
sqlbuffer.append(" DSS.DISC_AMT,"); summarySqlBuff.append(" AND I.ITEM_SER <= 'zz' ");
sqlbuffer.append(" DSS.MRP,"); summarySqlBuff.append(" AND DSS.SITE_CODE = '" + siteCode + "' ");
sqlbuffer.append(" DSS.PTR,"); summarySqlBuff.append(" AND DSS.POS_CODE in ( ");
sqlbuffer.append(" DSS.PTS,"); summarySqlBuff.append(" SELECT POS_CODE FROM MESMERVIS.ORG_STRUCTURE ");
sqlbuffer.append(" DSS.HSN_CODE,"); summarySqlBuff.append(" WHERE VERSION_ID IN (SELECT V.VERSION_ID FROM MESMERVIS.VERSION V WHERE TO_DATE(SYSDATE) BETWEEN V.EFF_FROM AND V.VALID_UPTO) ");
sqlbuffer.append(" DSS.PACK,"); summarySqlBuff.append(" AND TABLE_NO <> 'NFE' ");
sqlbuffer.append(" DUE_DATE,"); summarySqlBuff.append(" START WITH POS_CODE = (SELECT POS_CODE FROM MESMERVIS.ORG_STRUCTURE WHERE EMP_CODE= '" + empCode + "' AND VERSION_ID IN (SELECT V.VERSION_ID FROM MESMERVIS.VERSION V WHERE TO_DATE(SYSDATE) BETWEEN V.EFF_FROM AND V.VALID_UPTO) AND TABLE_NO <> 'NFE' ) ");
sqlbuffer.append(" DSS.CGST_AMT,"); summarySqlBuff.append(" CONNECT BY PRIOR POS_CODE = POS_CODE__REPTO) ");
sqlbuffer.append(" DSS.CGST_RATE,"); summarySqlBuff.append(" group by DHH.POS_CODE, DHH.LV1_DESCR ");
sqlbuffer.append(" DSS.SGST_RATE,");
sqlbuffer.append(" DSS.SGST_AMT,"); HashMap sqlDataMap = getSQLResultData(summarySqlBuff.toString(), transDB);
sqlbuffer.append(" DSS.CITY,"); System.out.println("Result sqlDataMap !" + sqlDataMap);
sqlbuffer.append(" DSS.ITEM_BRAND,"); ArrayList<HashMap<String, String>> dataRows = (ArrayList<HashMap<String, String>>) sqlDataMap.get("ROWS");
sqlbuffer.append(" DSS.IGST_AMT,");
sqlbuffer.append(" DSS.IGST_RATE,"); int noOfRows = dataRows.size();
sqlbuffer.append(" DSS.REF_SER,"); System.out.println("Result dataRows !" + dataRows);
sqlbuffer.append(" DSS.SALES_VALUE,");
sqlbuffer.append(" DSS.RETURN_VALUE,"); for( int rowNum = 0; rowNum < noOfRows; rowNum++ ) {
sqlbuffer.append(" DSS.CUST_CODE__BIL"); HashMap<String, String> dataMap = dataRows.get(rowNum);
sqlbuffer.append(" from SUNERP.DWH_SALES_SUM DSS");
sqlbuffer.append(" LEFT OUTER JOIN SUNERP.ITEM I ON DSS.ITEM_CODE = I.ITEM_CODE"); /*
sqlbuffer.append(" LEFT OUTER JOIN SUNERP.ITEMSER ISER ON I.ITEM_SER = ISER.ITEM_SER,"); htmlStrBuff.append("<details open>");
sqlbuffer.append(" ("); htmlStrBuff.append("<TABLE id =\"dataTable\" >");
sqlbuffer.append(" select lv1.pos_code lv1, lv1.pos_code__repto lv1_repo, case when lv1.descr is null then 'NA' else lv1.descr end lv1_descr,"); htmlStrBuff.append("<tr>");
sqlbuffer.append(" lv2.pos_code lv2, lv2.pos_code__repto lv2_repo, case when lv2.descr is null then 'NA' else lv2.descr end lv2_descr,"); htmlStrBuff.append("<th></th>");
sqlbuffer.append(" lv3.pos_code lv3, lv3.pos_code__repto lv3_repo, case when lv3.descr is null then 'NA' else lv3.descr end lv3_descr,"); htmlStrBuff.append("<th>value</th>");
sqlbuffer.append(" lv4.pos_code lv4, lv4.pos_code__repto lv4_repo, case when lv4.descr is null then 'NA' else lv4.descr end lv4_descr,"); htmlStrBuff.append("<th>quantity</th>");
sqlbuffer.append(" lv1.pos_code, lv1.table_no, lv1.version_id, lv1.pool_code"); htmlStrBuff.append("</tr>");
sqlbuffer.append(" from SUNERP.org_structure lv1"); htmlStrBuff.append("<tr>");
sqlbuffer.append(" left outer join SUNERP.org_structure lv2 on lv1.pos_code__repto = lv2.pos_code and Lv1.TABLE_NO=Lv2.TABLE_NO and Lv1.VERSION_ID=Lv2.VERSION_ID"); htmlStrBuff.append("<th>sales</th>");
sqlbuffer.append(" left outer join SUNERP.org_structure lv3 on lv2.pos_code__repto = lv3.pos_code and Lv2.TABLE_NO=Lv3.TABLE_NO and Lv2.VERSION_ID=Lv3.VERSION_ID"); htmlStrBuff.append("<td>").append(dataMap.get("SALES VALUE")).append("</td>");
sqlbuffer.append(" left outer join SUNERP.org_structure lv4 on lv3.pos_code__repto = lv4.pos_code and Lv3.TABLE_NO=Lv4.TABLE_NO and Lv3.VERSION_ID=Lv4.VERSION_ID"); htmlStrBuff.append("<td>").append(dataMap.get("SALES QUANTITY")).append("</td>");
sqlbuffer.append(" ) DHH"); htmlStrBuff.append("</tr>");
sqlbuffer.append(" WHERE DHH.POS_CODE = DSS.POS_CODE"); htmlStrBuff.append("<tr>");
sqlbuffer.append(" AND DHH.VERSION_ID in (SELECT V.VERSION_ID FROM SUNERP.VERSION V WHERE TO_DATE(SYSDATE) BETWEEN V.EFF_FROM AND V.VALID_UPTO)"); htmlStrBuff.append("<th>free sales</th>");
sqlbuffer.append(" AND DHH.TABLE_NO=NVL(ISER.TABLE_NO__HIER, ISER.ITEM_SER)"); htmlStrBuff.append("<td>").append(dataMap.get("FREE SALES VALUE")).append("</td>");
sqlbuffer.append(" AND to_char(DSS.DOC_DATE, 'MM/YYYY')= '"+ month +"'"); htmlStrBuff.append("<td>").append(dataMap.get("FREE QUANTITY")).append("</td>");
sqlbuffer.append(" AND I.ITEM_SER >= '00'"); htmlStrBuff.append("</tr>");
sqlbuffer.append(" AND I.ITEM_SER <= 'zz'"); htmlStrBuff.append("<tr>");
sqlbuffer.append(" AND DSS.SITE_CODE = '" + siteCode + "' "); htmlStrBuff.append("<th>gross sales</th>");
sqlbuffer.append(" AND DSS.POS_CODE IN ("); htmlStrBuff.append("<td>").append(dataMap.get("GROSS SALES VALUE")).append("</td>");
sqlbuffer.append(" SELECT POS_CODE FROM SUNERP.ORG_STRUCTURE"); htmlStrBuff.append("</tr>");
sqlbuffer.append(" WHERE VERSION_ID IN (SELECT V.VERSION_ID FROM SUNERP.VERSION V WHERE TO_DATE(SYSDATE) BETWEEN V.EFF_FROM AND V.VALID_UPTO) AND TABLE_NO <> 'NFE'"); htmlStrBuff.append("<tr>");
sqlbuffer.append(" START WITH POS_CODE = ( SELECT POS_CODE FROM SUNERP.ORG_STRUCTURE "); htmlStrBuff.append("<th>net sales</th>");
sqlbuffer.append(" WHERE EMP_CODE= '" + empCode + "' "); htmlStrBuff.append("<td>").append(dataMap.get("NET SALES VALUE")).append("</td>");
sqlbuffer.append(" AND VERSION_ID IN (SELECT V.VERSION_ID FROM SUNERP.VERSION V WHERE TO_DATE(SYSDATE) BETWEEN V.EFF_FROM AND V.VALID_UPTO) AND TABLE_NO <> 'NFE' )"); htmlStrBuff.append("<td>").append(dataMap.get("NET SALES QUANTITY")).append("</td>");
sqlbuffer.append(" CONNECT BY PRIOR POS_CODE = POS_CODE__REPTO)"); htmlStrBuff.append("</tr>");
htmlStrBuff.append("</TABLE>");
htmlStrBuff.append("<summary style=\"outline: none;cursor: pointer;\">");
htmlStrBuff.append("Sales Summary");
htmlStrBuff.append("</summary>");
htmlStrBuff.append("</details>");
htmlStrBuff.append("<details>");
htmlStrBuff.append("<TABLE id =\"dataTable\" >");
htmlStrBuff.append("<tr>");
htmlStrBuff.append("<th></th>");
htmlStrBuff.append("<th>value</th>");
htmlStrBuff.append("<th>quantity</th>");
htmlStrBuff.append("</tr>");
htmlStrBuff.append("<tr>");
htmlStrBuff.append("<th>saleable return</th>");
htmlStrBuff.append("<td>").append(dataMap.get("SALEABLE RETURN VALUE")).append("</td>");
htmlStrBuff.append("<td>").append(dataMap.get("SALEABLE RETURN QUANTITY")).append("</td>");
htmlStrBuff.append("</tr>");
htmlStrBuff.append("<tr>");
htmlStrBuff.append("<th>damaged return</th>");
htmlStrBuff.append("<td>").append(dataMap.get("DAMAGED RETURN VALUE")).append("</td>");
htmlStrBuff.append("<td>").append(dataMap.get("DAMAGED RETURN QUANTITY")).append("</td>");
htmlStrBuff.append("</tr>");
htmlStrBuff.append("<tr>");
htmlStrBuff.append("<th>expiry return</th>");
htmlStrBuff.append("<td>").append(dataMap.get("EXPIRY RETURN VALUE")).append("</td>");
htmlStrBuff.append("<td>").append(dataMap.get("EXPIRY RETURN QUANTITY")).append("</td>");
htmlStrBuff.append("</tr>");
htmlStrBuff.append("<tr>");
htmlStrBuff.append("<th>canceled return</th>");
htmlStrBuff.append("<td>").append(dataMap.get("CANCELED RETURN VALUE")).append("</td>");
htmlStrBuff.append("<td>").append(dataMap.get("CANCELED RETURN QUANTITY")).append("</td>");
htmlStrBuff.append("</tr>");
htmlStrBuff.append("<tr>");
htmlStrBuff.append("<th>gross return</th>").append("<td>").append(dataMap.get("GROSS RETURN VALUE")).append("</td>");
htmlStrBuff.append("</tr>");
htmlStrBuff.append("<tr>");
htmlStrBuff.append("<th>net return</th>").append("<td>").append(dataMap.get("NET RETURN VALUE")).append("</td>");
htmlStrBuff.append("</tr>");
htmlStrBuff.append("</TABLE>");
htmlStrBuff.append("<summary style=\"outline: none;cursor: pointer;\">");
htmlStrBuff.append("Returns Summary");
htmlStrBuff.append("</summary>");
htmlStrBuff.append("</details>");
*/
htmlStrBuff.append("<div style=\"padding: 10px 0 10px 10px;\"> ");
htmlStrBuff.append(" <div class=\"ang-dbtitle\">Sales Trends Data</div>");
htmlStrBuff.append(" <div class=\"ang-dbSubTitleLbl\">");
htmlStrBuff.append(" Employee Code : ").append(empCode);
htmlStrBuff.append(", Site Code : ").append(siteCode);
htmlStrBuff.append(", Month : ").append(month);
htmlStrBuff.append(" </div>");
htmlStrBuff.append("</div>");
htmlStrBuff.append("<details open style=\"padding: 10px 0;\" >");
htmlStrBuff.append("<div class=\"db-kpi-container\">");
htmlStrBuff.append(" <div class=\"kpi-container\">");
htmlStrBuff.append(" <div class=\"small-12 medium-4 large-3 column kpi-card-containers\">");
htmlStrBuff.append(" <div class=\"detail-box\" style=\"background-color: #89cbfc;\">");
htmlStrBuff.append(" <span class=\"detail-box-kpi-value\">").append(dataMap.get("SALES VALUE")).append("</span>");
htmlStrBuff.append(" <span class=\"detail-box-kpi-name\">SALES VALUE</span>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" <div class=\"small-12 medium-4 large-3 column kpi-card-containers\">");
htmlStrBuff.append(" <div class=\"detail-box\" style=\"background-color: #86e8c6;\">");
htmlStrBuff.append(" <span class=\"detail-box-kpi-value\">").append(dataMap.get("FREE SALES VALUE")).append("</span>");
htmlStrBuff.append(" <span class=\"detail-box-kpi-name\">FREE SALES VALUE</span>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" <div class=\"small-12 medium-4 large-3 column kpi-card-containers\">");
htmlStrBuff.append(" <div class=\"detail-box\" style=\"background-color: #c0b9f6;\">");
htmlStrBuff.append(" <span class=\"detail-box-kpi-value\">").append(dataMap.get("GROSS SALES VALUE")).append("</span>");
htmlStrBuff.append(" <span class=\"detail-box-kpi-name\">GROSS SALES VALUE</span>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" <div class=\"small-12 medium-4 large-3 column kpi-card-containers\">");
htmlStrBuff.append(" <div class=\"detail-box\" style=\"background-color: #f9af92;\">");
htmlStrBuff.append(" <span class=\"detail-box-kpi-value\">").append(dataMap.get("NET SALES VALUE")).append("</span>");
htmlStrBuff.append(" <span class=\"detail-box-kpi-name\">NET SALES VALUE</span>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append("</div>");
htmlStrBuff.append("<summary style=\"outline: none;cursor: pointer;\">");
htmlStrBuff.append("Sales Summary");
htmlStrBuff.append("</summary>");
htmlStrBuff.append("</details>");
htmlStrBuff.append("<details open style=\"padding: 10px 0;\" >");
htmlStrBuff.append("<div class=\"db-kpi-container\">");
htmlStrBuff.append(" <div class=\"kpi-container\">");
htmlStrBuff.append(" <div>");
htmlStrBuff.append(" <div class=\"small-12 medium-4 large-3 column kpi-card-containers\">");
htmlStrBuff.append(" <div class=\"detail-box\" style=\"background-color: #89cbfc;\">");
htmlStrBuff.append(" <span class=\"detail-box-kpi-value\">").append(dataMap.get("SALEABLE RETURN VALUE")).append("</span>");
htmlStrBuff.append(" <span class=\"detail-box-kpi-name\">SALEABLE RETURN VALUE</span>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" <div class=\"summary-box\">");
htmlStrBuff.append(" <span class=\"summary-box-kpi-value\" style=\"color: #c26be9;\"> ").append(dataMap.get("DAMAGED RETURN VALUE")).append(" </span>");
htmlStrBuff.append(" <span class=\"summary-box-kpi-name\">DAMAGED RETURN VALUE</span>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" <div>");
htmlStrBuff.append(" <div class=\"small-12 medium-4 large-3 column kpi-card-containers\">");
htmlStrBuff.append(" <div class=\"detail-box\" style=\"background-color: #86e8c6;\">");
htmlStrBuff.append(" <span class=\"detail-box-kpi-value\">").append(dataMap.get("EXPIRY RETURN VALUE")).append("</span>");
htmlStrBuff.append(" <span class=\"detail-box-kpi-name\">EXPIRY RETURN VALUE</span>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" <div class=\"summary-box\">");
htmlStrBuff.append(" <span class=\"summary-box-kpi-value\" style=\"color: #ffca3b;\"> ").append(dataMap.get("CANCELED RETURN VALUE")).append(" </span>");
htmlStrBuff.append(" <span class=\"summary-box-kpi-name\">CANCELED RETURN VALUE</span>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" <div>");
htmlStrBuff.append(" <div class=\"small-12 medium-4 large-3 column kpi-card-containers\">");
htmlStrBuff.append(" <div class=\"detail-box\" style=\"background-color: #c0b9f6;\">");
htmlStrBuff.append(" <span class=\"detail-box-kpi-value\">").append(dataMap.get("GROSS RETURN VALUE")).append("</span>");
htmlStrBuff.append(" <span class=\"detail-box-kpi-name\">GROSS RETURN VALUE</span>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" <div class=\"summary-box\">");
htmlStrBuff.append(" <span class=\"summary-box-kpi-value\" style=\"color: #f37487;\"> ").append(dataMap.get("NET RETURN VALUE")).append(" </span>");
htmlStrBuff.append(" <span class=\"summary-box-kpi-name\">NET RETURN VALUE</span>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append(" </div>");
htmlStrBuff.append("</div>");
htmlStrBuff.append("<summary style=\"outline: none;cursor: pointer;\">");
htmlStrBuff.append("Returns Summary");
htmlStrBuff.append("</summary>");
htmlStrBuff.append("</details>");
}
/*
89cbfc
c26be9
ConnDriver mConnDriver = new ConnDriver(); 86e8c6
con = mConnDriver.getConnectDB(transDB); ffca3b
stmt = con.createStatement();
rs = stmt.executeQuery(sqlbuffer.toString());
System.out.println("transDB [" +transDB + "] SQL Exection done ! SQL => \n " + sqlbuffer.toString());
ResultSetMetaData rsmd = rs.getMetaData();
ArrayList<HashMap<String, String>> dataList = new ArrayList<HashMap<String, String>>();
HashMap<Integer, String> dataColsMap = new HashMap<Integer, String>(); c0b9f6
int noOfRows = 0; f37487
int noOfColumns = 0;
while(rs.next()) f9af92
{ 3e3f3f
System.out.println("Result iteration !");
HashMap<String, String> dataMap = new HashMap<String, String>(); POS_CODE
noOfColumns = rsmd.getColumnCount(); LV1_DESCR
System.out.println("Result noOfColumns !" + noOfColumns);
for(int ctr = 1; ctr <= noOfColumns; ctr++) SALES VALUE SALES QUANTITY
{ FREE SALES VALUE FREE QUANTITY
if( noOfRows == 0 )
{ GROSS SALES VALUE
dataColsMap.put(ctr, rsmd.getColumnName(ctr));
} SALEABLE RETURN QUANTITY SALEABLE RETURN VALUE
dataMap.put(rsmd.getColumnName(ctr), rs.getString(ctr)); DAMAGED RETURN QUANTITY DAMAGED RETURN VALUE
} EXPIRY RETURN QUANTITY EXPIRY RETURN VALUE
System.out.println("Result dataMap !" + dataMap); CANCELED RETURN QUANTITY CANCELED RETURN VALUE
dataList.add(dataMap);
noOfRows++; REPLACEMENT RETURN QUANTITY REPLACEMENT RETURN VALUE
} RETURN QUANTITY RETURN VALUE
System.out.println("Result dataColsMap !" + dataColsMap);
int totalRows = noOfRows > 100 ? 100 : noOfRows; GROSS RETURN VALUE
%> NET RETURN VALUE
<div>
Sales Trends Data for Month <%=month%> (<%=noOfRows%> rows) <br/> NET SALES VALUE
Displaying <%=totalRows%> rows <br/> NET SALES QUANTITY
User <%=empCode%> of Site <%=siteCode%> <br/>
</div> CGST Amount
<TABLE id ="dataTable" class="tableFormat" align="left" width="100%"> SGST Amount
<tr> IGST Amount
<% */
for( int ctr = 1; ctr <= noOfColumns; ctr++ )
{
%>
<th><%=dataColsMap.get(ctr)%></th>
<%
}
%>
</tr>
<%
for( int rowNum = 0; rowNum < totalRows; rowNum++ )
{
HashMap<String, String> dataMap = dataList.get(rowNum);
%>
<tr>
<%
for( int ctr = 1; ctr <= noOfColumns; ctr++ )
{
String keyStr = dataColsMap.get(ctr);
%>
<td><%=dataMap.get(keyStr)%></td>
<%
}
%>
</tr>
<%
}
} }
catch(Exception e) catch(Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
finally
{
try
{
if( stmt != null )
{
stmt.close();
stmt = null;
}
if( con != null )
{
con.close();
con = null;
}
}
catch( Exception eI )
{
eI.printStackTrace();
}
}
%> %>
<%=htmlStrBuff.toString()%>
</TABLE> <!--
</Div > <form method="POST" action="saleTrendsDetails.jsp">
</body> <%=htmlStrBuff.toString()%>
<input type="hidden" name="empCode" id="empCode" value='<%=empCode%>'/>
<input type="hidden" name="siteCode" id="siteCode" value='<%=siteCode%>'/>
<input type="hidden" name="month" id="month" value='<%=month%>'/>
<button type="submit">Explore Data</button>
</form>
-->
</body>
</html> </html>
<html> <html>
<head>
<style>
*{
font-family: Arial, Helvetica, sans-serif;
}
body{
background-color: #efefef;
}
.input-field label{
display: block;
font-size: 12px;
}
.input-field input{
border: none;
border-bottom: 1px solid #000;
outline: none;
background-color: transparent;
}
.input-field{
padding: 10px 0;
display: block;
}
.view-button{
border-style: none;
border-radius: 2px;
background-color: #b4adee;
color: #fff;
padding: 5px 10px;
min-width: 80px;
cursor: pointer;
}
.ang-dbtitle {
font-size: 18px;
color: #666;
}
.input-form{
padding: 10px;
}
</style>
<title>Sales Trends</title>
</head>
<body> <body>
<h3>Sales Trends Data</h3> <div style="padding: 10px 0 10px 10px;">
<div class="ang-dbtitle">
Sales Trends Data
</div>
</div>
<form method="POST" action="executeSaleTrends.jsp"> <form method="POST" action="executeSaleTrends.jsp">
Employee Code : <br/> <div class="input-form">
<input type="text" name="empCode" id="empCode"/><br/><br/> <div class="input-field">
Site Code : <br/> <label>Employee Code : </label>
<input type="text" name="siteCode" id="siteCode"/><br/><br/> <input type="text" name="empCode" id="empCode"/>
Month : <br/> </div>
<input type="text" placeholder="MM/YYYY" name="month" id="month"/><br/><br/> <div class="input-field">
<button type="submit">View Data</button> <label>Site Code : </label>
<input type="text" name="siteCode" id="siteCode"/>
</div>
<div class="input-field">
<label>Month : </label>
<input type="text" placeholder="MM/YYYY" name="month" id="month"/>
</div>
<button class="view-button" type="submit">View Data</button>
</div>
</form> </form>
</body> </body>
</html> </html>
<%System.out.println("------------SaleTrendsDetails Called------"); %>
<?xml version="1.0" encoding="UTF-8"?>
<%@page import="ibase.webitm.bean.*, ibase.utility.CommonConstants"%>
<%@page import="ibase.webitm.utility.ITMException"%>
<%@page import="ibase.utility.*"%>
<%@page import="ibase.utility.UserInfoBean"%>
<%@page import="java.io.*,java.util.*,java.util.zip.*"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.*"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.SQLException"%>
<%@page import="ibase.system.config.ConnDriver"%>
<%!
public HashMap getSQLResultData(String sqlStr, String transDB)
{
HashMap sqlDataMap = null;
Connection con = null;
Statement stmt=null;;
ResultSet rs = null;
try
{
System.out.println("Inside SaleTrendsDetails::getSQLResultData transDB [" +transDB + "] SQL Exection done ! SQL => \n " + sqlStr);
ConnDriver mConnDriver = new ConnDriver();
con = mConnDriver.getConnectDB(transDB);
if( con == null ) {
System.out.println("Unable to get connection for [" + transDB + "]");
throw new Exception("Unable to get connection for [" + transDB + "]");
}
ArrayList<HashMap<String, String>> dataRows = new ArrayList<HashMap<String, String>>();
HashMap<Integer, String> dataCols = new HashMap<Integer, String>();
sqlDataMap = new HashMap();
int noOfRows = 0;
int noOfColumns = 0;
stmt = con.createStatement();
rs = stmt.executeQuery(sqlStr);
ResultSetMetaData rsmd = rs.getMetaData();
while(rs.next())
{
//System.out.println("Result iteration !");
HashMap<String, String> rowDataMap = new HashMap<String, String>();
noOfColumns = rsmd.getColumnCount();
//System.out.println("Result noOfColumns !" + noOfColumns);
for(int ctr = 1; ctr <= noOfColumns; ctr++)
{
if( noOfRows == 0 )
{
dataCols.put(ctr, rsmd.getColumnName(ctr));
}
rowDataMap.put(rsmd.getColumnName(ctr), rs.getString(ctr));
}
//System.out.println("Result dataMap !" + dataMap);
dataRows.add(rowDataMap);
noOfRows++;
}
//System.out.println("Result dataArray !" + dataArray);
sqlDataMap.put("COLS", dataCols);
sqlDataMap.put("ROWS", dataRows);
}
catch(Exception e)
{
sqlDataMap = null;
System.out.println("Inside SaleTrendsDetails::getSQLResultData Exception : " + e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if( stmt != null )
{
stmt.close();
stmt = null;
}
if( con != null )
{
con.close();
con = null;
}
}
catch( Exception eI )
{
eI.printStackTrace();
}
}
return sqlDataMap;
}
%>
<html>
<head>
<style>
#dataTable {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}
#dataTable td, #dataTable th {
border: 1px solid #ddd;
padding: 8px;
white-space: nowrap;
}
#dataTable tr:nth-child(even){background-color: #f2f2f2;}
#dataTable tr:hover {background-color: #ddd;}
#dataTable th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #b4adee ; /*#5fdeb2*/
color: white;
}
</style>
</head>
<body>
<Div style="position:relative;top:0;left:0;height:85%;width:100%;overflow:scroll;">
<%
UserInfoBean userInfo = (ibase.utility.UserInfoBean) session.getAttribute("USER_INFO");
String referer = request.getRequestURL().toString();
referer = referer.substring(referer.indexOf("ibase") - 1);
referer = referer + "?" + (String) request.getQueryString();
if (userInfo == null) //Ahmed
{
%>
<jsp:forward page="/jsp/DirectAccess.jsp">
<jsp:param name="REFERER" value="<%=referer%>"/>
</jsp:forward>
<%
}
//Modified by Ahmed on 15/06/2016 [UserInfoBean is initialized and session is checked] [END]
String userCode = userInfo.getLoginCode();
String transDB = userInfo.getTransDB();
String site = userInfo.getPropValue("SITE_CODE");
String empCode = request.getParameter("empCode");
if( empCode == null || empCode.trim().length() == 0)
{
empCode = userCode;
}
String siteCode = request.getParameter("siteCode");
if( siteCode == null || siteCode.trim().length() == 0)
{
siteCode = site;
}
String month = request.getParameter("month");
if( month == null || month.trim().length() == 0)
{
month = "10/2019";
}
StringBuffer htmlStrBuff = new StringBuffer();
try
{
StringBuffer detailSqlBuff = new StringBuffer();
detailSqlBuff.append(" SELECT ");
detailSqlBuff.append(" DSS.TRAN_ID, ");
detailSqlBuff.append(" DSS.DOC_DATE as \"TRANSACTION DATE\",");
detailSqlBuff.append(" DSS.REF_SER,");
detailSqlBuff.append(" DHH.POS_CODE as \"POSITION CODE\",");
detailSqlBuff.append(" DSS.CUST_CODE as \"CUSTOMER CODE\",");
detailSqlBuff.append(" (SELECT CUST_NAME from MESMERVIS.CUSTOMER where CUST_CODE = DSS.CUST_CODE) as \"CUSTOMER NAME\",");
detailSqlBuff.append(" DSS.SITE_CODE as \"SITE CODE\",");
detailSqlBuff.append(" (SELECT DESCR from MESMERVIS.SITE where SITE_CODE = DSS.SITE_CODE) as \"SITE DESCRIPTION\",");
detailSqlBuff.append(" DSS.ITEM_CODE AS \"ITEM CODE\", I.DESCR AS \"ITEM DESCRIPTION\",");
detailSqlBuff.append(" I.ITEM_SER as \"ITEM SERIES\",");
detailSqlBuff.append(" ISER.DESCR as \"ITEM SERIES DESCRIPTION\",");
detailSqlBuff.append(" ISER.PRODUCT_LINE as \"PRODUCT LINE\",");
detailSqlBuff.append(" (SELECT descr from MESMERVIS.GENCODES where FLD_NAME='PRODUCT_LINE' AND mod_name='W_ITEMSER' AND RPAD(fld_value, 5, ' ') = ISER.PRODUCT_LINE) as \"PRODUCT LINE DESCRIPTION\",");
detailSqlBuff.append(" DSS.SALES_VALUE as \"SALES VALUE\",");
detailSqlBuff.append(" DSS.SALES_QTY as \"SALES QUANTITY\",");
detailSqlBuff.append(" DSS.FREE_QTY as \"FREE QUANTITY\",");
detailSqlBuff.append(" DSS.FREE_SALES_VALUE as \"FREE SALES VALUE\",");
detailSqlBuff.append(" DSS.REPL_VALUE as \"REPLACEMENT VALUE\",");
detailSqlBuff.append(" DSS.REPL_QTY as \"REPLACEMENT QUANTITY\",");
detailSqlBuff.append(" DSS.GROSS_SALES_VALUE as \"GROSS SALES VALUE\",");
detailSqlBuff.append(" DSS.NET_SALES_VALUE as \"NET SALES VALUE\",");
detailSqlBuff.append(" DSS.NET_SALES_QTY as \"NET SALES QUANTITY\",");
detailSqlBuff.append(" DSS.SALEABLE_RETURN_AMT as \"SALEABLE RETURN VALUE\",");
detailSqlBuff.append(" DSS.SALEABLE_RETURN_QTY as \"SALEABLE RETURN QUANTITY\",");
detailSqlBuff.append(" DSS.BREAKAGE_RETURN_AMT as \"DAMAGED RETURN VALUE\",");
detailSqlBuff.append(" DSS.BREAKAGE_RETURN_QTY as \"DAMAGED RETURN QUANTITY\",");
detailSqlBuff.append(" DSS.EXPIRY_RETURN_AMT as \"EXPIRY RETURN VALUE\",");
detailSqlBuff.append(" DSS.EXPIRY_RETURN_QTY as \"EXPIRY RETURN QUANTITY\",");
detailSqlBuff.append(" DSS.CORRECTION_RETURN_AMT as \"CANCELED RETURN VALUE\",");
detailSqlBuff.append(" DSS.CORRECTION_RETURN_QTY as \"CANCELED RETURN QUANTITY\",");
detailSqlBuff.append(" DSS.REPL_RETURN_VALUE as \"REPLACEMENT RETURN VALUE\",");
detailSqlBuff.append(" DSS.REPL_RETURN_QTY as \"REPLACEMENT RETURN QUANTITY\",");
detailSqlBuff.append(" DSS.RETURN_VALUE as \"RETURN VALUE\",");
detailSqlBuff.append(" DSS.RETURN_QTY as \"RETURN QUANTITY\",");
detailSqlBuff.append(" DSS.GROSS_RETURN_VALUE as \"GROSS RETURN VALUE\",");
detailSqlBuff.append(" DSS.NET_RETURN_VALUE as \"NET RETURN VALUE\" ,");
detailSqlBuff.append(" DSS.DISC_AMT \"DISCOUNT AMOUNT\",");
detailSqlBuff.append(" DSS.MRP \"MRP\",");
detailSqlBuff.append(" DSS.PTR \"PTR\",");
detailSqlBuff.append(" DSS.PTS \"PTS\",");
detailSqlBuff.append(" DSS.HSN_CODE \"HSN CODE\",");
detailSqlBuff.append(" DSS.PACK \"PACK CODE\",");
detailSqlBuff.append(" DUE_DATE \"DUE DATE\",");
detailSqlBuff.append(" DSS.CITY \"CITY\",");
detailSqlBuff.append(" DSS.ITEM_BRAND \"ITEM BRAND\",");
detailSqlBuff.append(" DSS.CGST_AMT \"CGST AMOUNT\",");
detailSqlBuff.append(" DSS.CGST_RATE \"CGST RATE\",");
detailSqlBuff.append(" DSS.SGST_AMT \"SGST AMOUNT\",");
detailSqlBuff.append(" DSS.SGST_RATE \"SGST RATE\",");
detailSqlBuff.append(" DSS.IGST_AMT \"IGST AMOUNT\",");
detailSqlBuff.append(" DSS.IGST_RATE \"IGST RATE\",");
detailSqlBuff.append(" DSS.CUST_CODE__BIL as \"CUSTOMER CODE BILLING\",");
detailSqlBuff.append(" DSS.POS_CODE as \"LEVEL CODE\",");
detailSqlBuff.append(" DHH.lv4 as \"LEVEL1 CODE\",");
detailSqlBuff.append(" DHH.lv4_descr as \"LEVEL1 DESCRIPTION\",");
detailSqlBuff.append(" DHH.lv3 as \"LEVEL2 CODE\",");
detailSqlBuff.append(" DHH.lv3_descr as \"LEVEL2 DESCRIPTION\",");
detailSqlBuff.append(" DHH.lv2 as \"LEVEL3 CODE\",");
detailSqlBuff.append(" DHH.lv2_descr as \"LEVEL3 DESCRIPTION\",");
detailSqlBuff.append(" DHH.lv1 as \"LEVEL4 CODE\",");
detailSqlBuff.append(" DHH.lv1_descr as \"LEVEL4 DESCRIPTION\" ");
detailSqlBuff.append(" from MESMERVIS.DWH_SALES_SUM DSS");
detailSqlBuff.append(" LEFT OUTER JOIN MESMERVIS.ITEM I ON DSS.ITEM_CODE = I.ITEM_CODE");
detailSqlBuff.append(" LEFT OUTER JOIN MESMERVIS.ITEMSER ISER ON I.ITEM_SER = ISER.ITEM_SER,");
detailSqlBuff.append(" (");
detailSqlBuff.append(" select lv1.pos_code lv1, lv1.pos_code__repto lv1_repo, case when lv1.descr is null then 'NA' else lv1.descr end lv1_descr,");
detailSqlBuff.append(" lv2.pos_code lv2, lv2.pos_code__repto lv2_repo, case when lv2.descr is null then 'NA' else lv2.descr end lv2_descr,");
detailSqlBuff.append(" lv3.pos_code lv3, lv3.pos_code__repto lv3_repo, case when lv3.descr is null then 'NA' else lv3.descr end lv3_descr,");
detailSqlBuff.append(" lv4.pos_code lv4, lv4.pos_code__repto lv4_repo, case when lv4.descr is null then 'NA' else lv4.descr end lv4_descr,");
detailSqlBuff.append(" lv1.pos_code, lv1.table_no, lv1.version_id, lv1.pool_code");
detailSqlBuff.append(" from MESMERVIS.org_structure lv1");
detailSqlBuff.append(" left outer join MESMERVIS.org_structure lv2 on lv1.pos_code__repto = lv2.pos_code and Lv1.TABLE_NO=Lv2.TABLE_NO and Lv1.VERSION_ID=Lv2.VERSION_ID");
detailSqlBuff.append(" left outer join MESMERVIS.org_structure lv3 on lv2.pos_code__repto = lv3.pos_code and Lv2.TABLE_NO=Lv3.TABLE_NO and Lv2.VERSION_ID=Lv3.VERSION_ID");
detailSqlBuff.append(" left outer join MESMERVIS.org_structure lv4 on lv3.pos_code__repto = lv4.pos_code and Lv3.TABLE_NO=Lv4.TABLE_NO and Lv3.VERSION_ID=Lv4.VERSION_ID");
detailSqlBuff.append(" ) DHH");
detailSqlBuff.append(" WHERE DHH.POS_CODE = DSS.POS_CODE");
detailSqlBuff.append(" AND DHH.VERSION_ID in (SELECT V.VERSION_ID FROM MESMERVIS.VERSION V WHERE TO_DATE(SYSDATE) BETWEEN V.EFF_FROM AND V.VALID_UPTO)");
detailSqlBuff.append(" AND DHH.TABLE_NO=NVL(ISER.TABLE_NO__HIER, ISER.ITEM_SER)");
detailSqlBuff.append(" AND to_char(DSS.DOC_DATE, 'MM/YYYY')= '"+ month +"'");
detailSqlBuff.append(" AND I.ITEM_SER >= '00'");
detailSqlBuff.append(" AND I.ITEM_SER <= 'zz'");
detailSqlBuff.append(" AND DSS.SITE_CODE = '" + siteCode + "' ");
detailSqlBuff.append(" AND DSS.POS_CODE IN (");
detailSqlBuff.append(" SELECT POS_CODE FROM MESMERVIS.ORG_STRUCTURE");
detailSqlBuff.append(" WHERE VERSION_ID IN (SELECT V.VERSION_ID FROM MESMERVIS.VERSION V WHERE TO_DATE(SYSDATE) BETWEEN V.EFF_FROM AND V.VALID_UPTO) AND TABLE_NO <> 'NFE'");
detailSqlBuff.append(" START WITH POS_CODE = ( SELECT POS_CODE FROM MESMERVIS.ORG_STRUCTURE ");
detailSqlBuff.append(" WHERE EMP_CODE= '" + empCode + "' ");
detailSqlBuff.append(" AND VERSION_ID IN (SELECT V.VERSION_ID FROM MESMERVIS.VERSION V WHERE TO_DATE(SYSDATE) BETWEEN V.EFF_FROM AND V.VALID_UPTO) AND TABLE_NO <> 'NFE' )");
detailSqlBuff.append(" CONNECT BY PRIOR POS_CODE = POS_CODE__REPTO)");
HashMap sqlDataMap = getSQLResultData(detailSqlBuff.toString(), transDB);
System.out.println("Result sqlDataMap !" + sqlDataMap);
ArrayList<HashMap<String, String>> dataRows = (ArrayList<HashMap<String, String>>) sqlDataMap.get("ROWS");
HashMap<Integer, String> dataCols = (HashMap<Integer, String>)sqlDataMap.get("COLS");
int noOfRows = dataRows.size();
int totalRows = noOfRows > 100 ? 100 : noOfRows;
int noOfColumns = dataCols.size();
htmlStrBuff.append("<TABLE id =\"dataTable\">");
htmlStrBuff.append("<tr>");
for( int ctr = 1; ctr <= noOfColumns; ctr++ ) {
htmlStrBuff.append("<th>");
htmlStrBuff.append(dataCols.get(ctr));
htmlStrBuff.append("</th>");
}
htmlStrBuff.append("</tr>");
for( int rowNum = 0; rowNum < totalRows; rowNum++ ) {
htmlStrBuff.append("<tr>");
HashMap<String, String> dataMap = dataRows.get(rowNum);
for( int ctr = 1; ctr <= noOfColumns; ctr++ ) {
String keyStr = dataCols.get(ctr);
htmlStrBuff.append("<td>");
htmlStrBuff.append(dataMap.get(keyStr));
htmlStrBuff.append("</td>");
}
htmlStrBuff.append("</tr>");
}
htmlStrBuff.append("</TABLE>");
}
catch(Exception e)
{
e.printStackTrace();
}
%>
<%=htmlStrBuff.toString()%>
</Div >
</body>
</html>
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