Current File : /home/obabain/public_html/abc/salesRecptCustPDF.jsp |
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@include file="Connection.jsp" %>
<%!String selmonth=null;
ResultSet rs1=null;
%>
<%
String custom=request.getParameter("cust");
String mnth=request.getParameter("mnth");
Statement st=con.createStatement();
ResultSet rs = null;
rs=st.executeQuery("SELECT MONTHNAME(STR_TO_DATE("+mnth+", '%m')) as mn");
while(rs.next())
{
selmonth=rs.getString("mn");
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link href="css/Mystyle.css" rel="stylesheet">
</head>
<body>
<div><div style="padding-bottom:30px; background-color:white;" align="center"><u><b><font size="4">Sundry Debtors for the month of <%=selmonth %></font><br></b></u></div>
<table class="pdftable">
<tbody>
<%
Statement st1=con.createStatement();
if((!mnth.equals("0")))
{
if(custom.equals("0"))
{
rs1=st1.executeQuery("select tb.*,(select UPPER(ledger_name) from account_ledger where l_id=tb.particular)cust from account_voucher_main tb where MONTH(voucher_date)='"+mnth+"' and voucher_type='receipt' group by particular");
}
else
{
rs1=st1.executeQuery("select tb.*,(select UPPER(ledger_name) from account_ledger where l_id=tb.particular)cust from account_voucher_main tb where MONTH(voucher_date)='"+mnth+"' and voucher_type='receipt' and particular="+custom+" group by particular");
}
}
else if(mnth.equals("0"))
{
if(!custom.equals("0"))
{
rs1=st1.executeQuery("select tb.*,(select UPPER(ledger_name) from account_ledger where l_id=tb.particular)cust from account_voucher_main tb where voucher_type='receipt' and particular="+custom+" group by particular");
}
else
{
rs1=st1.executeQuery("select tb.*,(select UPPER(ledger_name) from account_ledger where l_id=tb.particular)cust from account_voucher_main tb where voucher_type='receipt' group by particular");
}
}
while(rs1.next())
{
%>
<tr>
<td>
<span><%=rs1.getString("cust") %></span>
</td>
</tr>
<tr>
<td>
<table class="pdftable" style="border-bottom:1px solid black;">
<thead>
<tr>
<th>Date</th>
<th style="text-align:right;">Ref No</th>
<th style="text-align:right;">( <30 days)</th>
<th style="text-align:right;">(30 to 60)</th>
<th style="text-align:right;">(60 to 90)</th>
<th style="text-align:right;">(90 to 120)</th>
<th style="text-align:right;">( >120)</th>
<th style="text-align:right;">On account</th>
</tr>
</thead>
<%
if(mnth.equals("0"))
{
rs=st.executeQuery("select tb.*,sum(debit_amt)amt,(select sales_invoice_no from ip_sales_invoice where sinvoice_id=tb.bill_no)invno,(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)dte,"
+" sum((case when DATEDIFF((voucher_date),(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)) <30 then debit_amt else '' end))thirty,"
+" sum((case when DATEDIFF((voucher_date),(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)) between 30 and 60 then debit_amt else '' end))thirtysixty,"
+" sum((case when DATEDIFF((voucher_date),(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)) between 60 and 90 then debit_amt else '' end))sixtyninty,"
+" sum((case when DATEDIFF((voucher_date),(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)) between 90 and 120 then debit_amt else '' end))nintytwenty,"
+" sum((case when DATEDIFF((voucher_date),(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)) >120 then debit_amt else '' end))onetwenty"
+" from account_voucher_sub tb where"
+" voucher_type='receipt' and particular="+rs1.getString("particular")+" group by bill_no");
}
else
{
rs=st.executeQuery("select tb.*,sum(debit_amt)amt,(select sales_invoice_no from ip_sales_invoice where sinvoice_id=tb.bill_no)invno,(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)dte,"
+" sum((case when DATEDIFF((voucher_date),(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)) <30 then debit_amt else '' end))thirty,"
+" sum((case when DATEDIFF((voucher_date),(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)) between 30 and 60 then debit_amt else '' end))thirtysixty,"
+" sum((case when DATEDIFF((voucher_date),(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)) between 60 and 90 then debit_amt else '' end))sixtyninty,"
+" sum((case when DATEDIFF((voucher_date),(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)) between 90 and 120 then debit_amt else '' end))nintytwenty,"
+" sum((case when DATEDIFF((voucher_date),(select invoice_date_created from ip_sales_invoice where sinvoice_id=tb.bill_no)) >120 then debit_amt else '' end))onetwenty"
+" from account_voucher_sub tb where"
+" MONTH(voucher_date)='"+mnth+"' and voucher_type='receipt' and particular="+rs1.getString("particular")+" group by bill_no");
}
Double sum=0.00;
Double sum2=0.00;
Double sum3=0.00;
Double sum4=0.00;
Double sum5=0.00;
Double onaccsum=0.00;
while(rs.next())
{
Double onaccs=Double.parseDouble(rs.getString("amt"));
onaccsum=onaccsum+onaccs;
Double s=Double.parseDouble(rs.getString("thirty"));
sum=sum+s;
Double s2=Double.parseDouble(rs.getString("thirtysixty"));
sum2=sum2+s2;
Double s3=Double.parseDouble(rs.getString("sixtyninty"));
sum3=sum3+s3;
Double s4=Double.parseDouble(rs.getString("nintytwenty"));
sum4=sum4+s4;
Double s5=Double.parseDouble(rs.getString("onetwenty"));
sum5=sum5+s5;
%>
<tr>
<td align="right"><%=rs.getString("dte") %></td>
<td align="right"><%=rs.getString("bill_no") %></td>
<td align="right"><%=rs.getString("thirty") %></td>
<td align="right"><%=rs.getString("thirtysixty") %></td>
<td align="right"><%=rs.getString("sixtyninty") %></td>
<td align="right"><%=rs.getString("nintytwenty") %></td>
<td align="right"><%=rs.getString("onetwenty") %></td>
<td align="right"><%=onaccsum%></td>
</tr>
<%} %>
<tr style="border-top:1px solid black;">
<td align="right"></td>
<td align="right"></td>
<td align="right"><%=sum %>
</td>
<td align="right"><%=sum2 %>
</td>
<td align="right"><%=sum3 %>
</td>
<td align="right"><%=sum4 %>
</td>
<td align="right"><%=sum5 %>
</td>
<td align="right"><%=onaccsum %></td>
</tr>
</table>
</td>
</tr>
<%} %>
</tbody>
</table>
</div>
</body>
</html>