Current File : //usr/local/tomcat8/work/Catalina/ms.obaba.in/ROOT/org/apache/jsp/ledgerByIdPDF_jsp.java |
/*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/8.0.39
* Generated at: 2022-04-13 05:30:55 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
public final class ledgerByIdPDF_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent,
org.apache.jasper.runtime.JspSourceImports {
String typ=null;
String ref_id=null;
String under=null;
double i=0;
double j=0;
double s=0;
double su=0;
String sum=null;
String sum2=null;
String i1=null;
String j1=null;
String ledgername=null;
String opbal=null;
String cr=null;
String dr=null;
String addr=null;
String comp=null;
String add1=null;
String add2=null;
String city=null;
String zip=null;
String phone=null;
String email=null;
String web=null;
String gst=null;
String bankname=null;
String acno=null;
String ifsc=null;
String branch=null;
String logo=null;
String state=null;
String curryear=null;
String currdate=null;
private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory();
private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
static {
_jspx_dependants = new java.util.HashMap<java.lang.String,java.lang.Long>(1);
_jspx_dependants.put("/Connection.jsp", Long.valueOf(1633514572000L));
}
private static final java.util.Set<java.lang.String> _jspx_imports_packages;
private static final java.util.Set<java.lang.String> _jspx_imports_classes;
static {
_jspx_imports_packages = new java.util.HashSet<>();
_jspx_imports_packages.add("java.sql");
_jspx_imports_packages.add("javax.servlet");
_jspx_imports_packages.add("javax.servlet.http");
_jspx_imports_packages.add("javax.servlet.jsp");
_jspx_imports_classes = null;
}
private volatile javax.el.ExpressionFactory _el_expressionfactory;
private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager;
public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
}
public java.util.Set<java.lang.String> getPackageImports() {
return _jspx_imports_packages;
}
public java.util.Set<java.lang.String> getClassImports() {
return _jspx_imports_classes;
}
public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
if (_el_expressionfactory == null) {
synchronized (this) {
if (_el_expressionfactory == null) {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
}
}
}
return _el_expressionfactory;
}
public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
if (_jsp_instancemanager == null) {
synchronized (this) {
if (_jsp_instancemanager == null) {
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
}
}
return _jsp_instancemanager;
}
public void _jspInit() {
}
public void _jspDestroy() {
}
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
final java.lang.String _jspx_method = request.getMethod();
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method) && !javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSPs only permit GET POST or HEAD");
return;
}
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("text/html; charset=ISO-8859-1");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write(" ");
out.write("\n");
out.write(" \n");
out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
out.write("<html>\n");
out.write("<head>\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n");
out.write("\n");
out.write("</head>\n");
out.write("<body>\n");
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/obabain_market","obabain_ms21","Bz$nO8SSt");
out.write("\n");
out.write(" </body>\n");
out.write(" </html>\n");
out.write("\r\n");
out.write(" ");
out.write("\r\n");
out.write(" ");
String loginid=(String)session.getAttribute("logid");
Statement st=con.createStatement();
ResultSet rs=null;
String id=request.getParameter("Id");
String from=request.getParameter("from");
String to=request.getParameter("to");
rs=st.executeQuery("select tb.*,(CONCAT(UCASE(MID(ledger_name,1,1)),LCASE(MID(ledger_name,2)))) as ledgname,(case when type=2 then (select supplier_address_1 from ip_suppliers where supplier_id=tb.ref_id) else (case when type=3 then (select client_address_1 from ip_clients where client_id=tb.ref_id) else '' end)end)addr from account_ledger tb where l_id="+id+"");
while(rs.next())
{
typ=rs.getString("type");
ledgername=rs.getString("ledgname");
ref_id=rs.getString("ref_id");
under=rs.getString("under");
opbal=rs.getString("opening_bal");
addr=rs.getString("addr");
}
rs=st.executeQuery("select tb.*,upper(tb.user_company)company from ip_users tb where login_id="+loginid+"");
while(rs.next())
{
comp=rs.getString("company");
add1=rs.getString("user_address_1");
add2=rs.getString("user_address_2");
city=rs.getString("user_city");
zip=rs.getString("user_zip");
state=rs.getString("user_state");
phone=rs.getString("user_phone");
email=rs.getString("user_email");
web=rs.getString("user_web");
gst=rs.getString("user_vat_id");
bankname=rs.getString("bank_name");
acno=rs.getString("account_no");
ifsc=rs.getString("ifsc");
branch=rs.getString("bank_branch");
}
rs=st.executeQuery("select * from ip_logo where login_id="+loginid+"");
while(rs.next())
{
logo=rs.getString("name");
}
out.write("\r\n");
out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\r\n");
out.write("<link rel=\"shortcut icon\" type=\"image/x-icon\" href=\"img/ico.ico\" />\r\n");
out.write(" <link href=\"css/bootstrap.min.css\" rel=\"stylesheet\">\r\n");
out.write(" <link href=\"css/estilos.css\" rel=\"stylesheet\">\r\n");
out.write(" \r\n");
out.write(" <link href=\"css/Mystyle.css\" rel=\"stylesheet\">\r\n");
out.write(" <script src=\"http://cdn.ckeditor.com/4.6.1/standard/ckeditor.js\"></script>\r\n");
out.write(" <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js\"></script>\r\n");
out.write("<script src=\"js/jscolor.js\"></script>\r\n");
out.write("<style>\r\n");
out.write("/* tbody div{\r\n");
out.write(" overflow:scroll;\r\n");
out.write(" height:350px;\r\n");
out.write("} */\r\n");
out.write(".borderless table {\r\n");
out.write(" border-top-style: none;\r\n");
out.write(" border-left-style: none;\r\n");
out.write(" border-right-style: none;\r\n");
out.write(" border-bottom-style: none;\r\n");
out.write("}\r\n");
out.write(".viewtable>thead>tr>th\r\n");
out.write("{\r\n");
out.write("width:10%;\r\n");
out.write("}\r\n");
out.write("\r\n");
out.write("</style>\r\n");
out.write("<style type=\"text/css\">\r\n");
out.write("footer {\r\n");
out.write(" font-size: 9px;\r\n");
out.write(" width:210mm;\r\n");
out.write(" text-align: left;\r\n");
out.write(" /* border-top:1px solid black; */\r\n");
out.write("}\r\n");
out.write("\r\n");
out.write("@page {\r\n");
out.write(" size: A4;\r\n");
out.write(" margin: 9mm 17mm 17mm 17mm;\r\n");
out.write("}\r\n");
out.write("\r\n");
out.write("@media print {\r\n");
out.write(" footer {\r\n");
out.write(" position: fixed;\r\n");
out.write(" bottom: 0;\r\n");
out.write(" /* border-top:1px solid black; */\r\n");
out.write(" width:210mm;\r\n");
out.write(" text-align:left;\r\n");
out.write(" \r\n");
out.write(" }\r\n");
out.write(" body {\r\n");
out.write(" width: 210mm;\r\n");
out.write(" height: 297mm;\r\n");
out.write(" \r\n");
out.write(" \r\n");
out.write(" }\r\n");
out.write(" </style>\r\n");
out.write("<title>Insert title here</title>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write("\r\n");
out.write("<form>\r\n");
out.write("\r\n");
out.write("<div class=\"content\">\r\n");
out.write(" <div class=\"row\">\r\n");
out.write(" <div class=\"col-md-9\" >\r\n");
out.write(" <div class=\"panel panel-default\" >\r\n");
out.write(" \r\n");
out.write(" \r\n");
out.write("<div class=\"panel-body\">\r\n");
out.write("<table class=\"viewtable\">\r\n");
out.write("<thead>\r\n");
out.write("<tr>\r\n");
out.write("<th>\r\n");
out.write("<div class=\"row\">\r\n");
out.write("<div class=\"col-xs-3\" style=\"text-align:center; margin-top:50px;\"><img src=\"");
out.print(logo );
out.write("\"></div>\r\n");
out.write("<div class=\"col-xs-8\">\r\n");
out.write("<div style=\"width:80%;\" align=\"center\"><span style=\" font-size:large;\"><b>");
out.print(comp );
out.write("</b></span></div>\r\n");
out.write("<div style=\"width:80%;\" align=\"center\"><span style=\" font-size:large;\">");
out.print(add1 );
out.write("</span>\r\n");
out.write("<br>\r\n");
out.write("<span style=\" font-size:large;\">");
out.print(add2 );
out.write("</span><br>\r\n");
out.write("<span style=\" font-size:large;\"><u>");
out.print(city );
out.write('-');
out.print(zip );
out.write("</u></span><br>\r\n");
out.write("<span style=\" font-size:large;\"></span><br>\r\n");
out.write("</div>\r\n");
out.write("\r\n");
out.write("<div style=\"width:80%;\" align=\"center\"><span style=\" font-size:large;\"><b>");
out.print(ledgername );
out.write("</b></span>\r\n");
out.write("<br><span style=\" font-size:large;\">Ledger Account</span>\r\n");
out.write("</div>\r\n");
out.write("<div style=\"width:80%;\" align=\"center\"><span style=\" font-size:large;\">");
out.print(addr );
out.write("</span>\r\n");
out.write("<br>\r\n");
out.write("\r\n");
out.write("</div>\r\n");
out.write("<input type=\"hidden\" id=\"demo\" value=\"");
out.print(from );
out.write("\">\r\n");
out.write("<input type=\"hidden\" id=\"demo2\" value=\"");
out.print(to );
out.write("\">\r\n");
out.write("<div style=\"width:80%;\" align=\"center\"><span><p id=\"period\"></p></span></div> \r\n");
out.write("</div>\r\n");
out.write("</div>\r\n");
out.write("</th>\r\n");
out.write("</tr>\r\n");
out.write("</thead>\r\n");
out.write("<tbody>\r\n");
out.write("<tr><td>\r\n");
out.write("<table class=\"viewtable table-borderless\">\r\n");
out.write("<thead>\r\n");
out.write("<tr>\r\n");
out.write("<th>Date</th>\r\n");
out.write("<th>Vch.No.</th>\r\n");
out.write("<th>Particular</th>\r\n");
out.write("<th>Vch.Type</th>\r\n");
out.write("<th style=\" text-align:right; padding-right:0px;\">Debit</th>\r\n");
out.write("<th style=\" text-align:right; padding-right:5px;\">Credit</th>\r\n");
out.write("</tr>\r\n");
out.write("</thead>\r\n");
out.write("\r\n");
out.write("<tbody>\r\n");
out.write("\r\n");
if(typ.equals("2"))
{
rs=st.executeQuery("select (select ledger_name from account_ledger where l_id=account_voucher_main.account)parti, voucher_id,voucher_type, voucher_no,voucher_date,(case when cash_cheque='cash' then 'Payment' else 'Cheque Payment' end) as vtype,credit_amt as debit,0 as credit from account_voucher_main where particular="+id+" and voucher_type='payment' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select (select ledger_name from account_ledger where l_id=account_voucher_main.account)parti, voucher_id,voucher_type, voucher_no,voucher_date,'Receipt' as vtype,0,credit_amt from account_voucher_main where particular="+id+" and voucher_type='receipt' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select 'Purchase' as parti, pinvoice_id,'purchase' as voucher_type, purchase_invoice_no,invoice_date_created,'Purchase' as vtype,0,total from ip_puchase_invoice2 where supplier_id="+ref_id+" and invoice_date_created between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=account_voucher_sub.particular)parti ,voucher_id,voucher_type,(select voucher_no from account_voucher_main where voucher_id=account_voucher_sub.voucher_id) as voucher_no,voucher_date,(case when voucher_type='payment' then 'Payment' else 'Receipt' end) as voucher_type,(case when voucher_type='payment' then debit_amt else 0 end)as debit,(case when voucher_type='receipt' then debit_amt else 0 end)as credit from account_voucher_sub where bill_no="+id+" and type='O' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select (select ledger_name from account_ledger where l_id=tb.particulars)parti,tb.ref_no,'journal',tb.journal_no,created_date,'Journal',0 as debit,(select credit from journalentry where type=2 and ref_no=tb.ref_no)credit from journalentry tb where ref_no in (select ref_no from journalentry where particulars="+id+" and type=2 ) and type <>2 and created_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=debit_note.purchase_ledger)parti,voucher_id,'debitnote' as voucher_type,voucher_no,voucher_date,'DebitNote' as vtype ,0 as debit,total as credit from debit_note where supplier="+ref_id+" and voucher_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=tb.particulars)parti,tb.ref_no,'journal',tb.journal_no,created_date,'Journal',(select debit from journalentry where type=1 and ref_no=tb.ref_no)debit,0 as credit from journalentry tb where ref_no in (select ref_no from journalentry where particulars="+id+" and type=1 ) and type <>1 and created_date between '"+from+"' and '"+to+"' order by voucher_date desc");
}
else if(typ.equals("3"))
{
rs=st.executeQuery("select (select ledger_name from account_ledger where l_id=account_voucher_main.account)parti, voucher_id,voucher_type, voucher_no,voucher_date,(case when cash_cheque='cash' then 'Payment' else 'Cheque Payment' end) as vtype,credit_amt as debit,0 as credit from account_voucher_main where particular="+id+" and voucher_type='payment' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select (select ledger_name from account_ledger where l_id=account_voucher_main.account)parti, voucher_id,voucher_type, voucher_no,voucher_date,'Receipt' as vtype,0,credit_amt from account_voucher_main where particular="+id+" and voucher_type='receipt' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select 'Sales' as parti, sinvoice_id,'sales' as voucher_type, sales_invoice_no,invoice_date_created,'Sales' as vtype,total,0 from ip_sales_invoice where supplier_id="+ref_id+" and invoice_date_created between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=account_voucher_sub.particular)parti ,voucher_id,voucher_type,(select voucher_no from account_voucher_main where voucher_id=account_voucher_sub.voucher_id) as voucher_no,voucher_date,(case when voucher_type='payment' then 'Payment' else 'Receipt' end) as voucher_type,(case when voucher_type='payment' then debit_amt else 0 end)as debit,(case when voucher_type='receipt' then debit_amt else 0 end)as credit from account_voucher_sub where bill_no="+id+" and type='O' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select (select ledger_name from account_ledger where l_id=tb.particulars)parti,tb.ref_no,'journal',tb.journal_no,created_date,'Journal',0 as debit,(select credit from journalentry where type=2 and ref_no=tb.ref_no)credit from journalentry tb where ref_no in (select ref_no from journalentry where particulars="+id+" and type=2 ) and type <>2 and created_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=tb.particulars)parti,tb.ref_no,'journal',tb.journal_no,created_date,'Journal',(select debit from journalentry where type=1 and ref_no=tb.ref_no)debit,0 as credit from journalentry tb where ref_no in (select ref_no from journalentry where particulars="+id+" and type=1 ) and type <>1 and created_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=credit_note.purchase_ledger)parti,voucher_id,'creditnote' as voucher_type,voucher_no,voucher_date,'CreditNote' as vtype ,total as debit,0 as credit from credit_note where supplier="+ref_id+" and voucher_date between '"+from+"' and '"+to+"' order by voucher_date desc");
}
else if(typ.equals("0") && under.equals("26"))
{
rs=st.executeQuery(" select (select ledger_name from account_ledger where l_id=account_voucher_main.account)parti, voucher_id,voucher_type, voucher_no,voucher_date,'Receipt' as vtype,0 as debit,credit_amt as credit from account_voucher_main where particular="+id+" and voucher_type='receipt' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select (select ledger_name from account_ledger where l_id=account_voucher_main.account)parti, voucher_id,voucher_type, voucher_no,voucher_date,(case when cash_cheque='cash' then 'Payment' else 'Cheque Payment' end) as vtype,credit_amt as debit,0 as credit from account_voucher_main where particular="+id+" and voucher_type='payment' and voucher_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=account_voucher_sub.particular)parti ,voucher_id,voucher_type,(select voucher_no from account_voucher_main where voucher_id=account_voucher_sub.voucher_id) as voucher_no,voucher_date,(case when voucher_type='payment' then 'Payment' else 'Receipt' end) as voucher_type,(case when voucher_type='payment' then debit_amt else 0 end)as debit,(case when voucher_type='receipt' then debit_amt else 0 end)as credit from account_voucher_sub where bill_no="+id+" and type='O' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select (select ledger_name from account_ledger where l_id=tb.particulars)parti,tb.ref_no,'journal',tb.journal_no,created_date,'Journal',0 as debit,(select credit from journalentry where type=2 and ref_no=tb.ref_no)credit from journalentry tb where ref_no in (select ref_no from journalentry where particulars="+id+" and type=2 ) and type <>2 and created_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=account_voucher_sub.particular)parti ,voucher_id,voucher_type,(select voucher_no from account_voucher_main where voucher_id=account_voucher_sub.voucher_id) as voucher_no,voucher_date,(case when voucher_type='payment' then 'Payment' else 'Receipt' end) as voucher_type,(case when voucher_type='payment' then debit_amt else 0 end)as debit,(case when voucher_type='receipt' then debit_amt else 0 end)as credit from account_voucher_sub where bill_no="+id+" and type='O' and voucher_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=tb.particulars)parti,tb.ref_no,'journal',tb.journal_no,created_date,'Journal',(select debit from journalentry where type=1 and ref_no=tb.ref_no)debit,0 as credit from journalentry tb where ref_no in (select ref_no from journalentry where particulars="+id+" and type=1 ) and type <>1 and created_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=credit_note.purchase_ledger)parti,voucher_id,'creditnote' as voucher_type,voucher_no,voucher_date,'CreditNote' as vtype ,total as debit,0 as credit from credit_note where supplier="+ref_id+" and voucher_date between '"+from+"' and '"+to+"' order by voucher_date desc");
}
else if(under.equals("15") || under.equals("16") || under.equals("17"))
{
rs=st.executeQuery("select (select ledger_name from account_ledger where l_id=account_voucher_main.particular)parti, voucher_id,voucher_type, voucher_no,voucher_date,(case when cash_cheque='cash' then 'Payment' else 'Cheque Payment' end) as vtype,0 as debit,credit_amt as credit from account_voucher_main where account="+id+" and voucher_type='payment' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select (select ledger_name from account_ledger where l_id=account_voucher_main.particular)parti, voucher_id,voucher_type, voucher_no,voucher_date,'Receipt' as vtype,credit_amt,0 from account_voucher_main where account="+id+" and voucher_type='receipt' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select (select ledger_name from account_ledger where l_id=contra_voucher.particular)parti,v_id,voucher_type,voucher_no,voucher_date,'Contra' as vtype,amount,0 from contra_voucher where account="+id+" and voucher_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=contra_voucher.account)parti,v_id,voucher_type,voucher_no,voucher_date,'Contra' as vtype,0,amount from contra_voucher where particular="+id+" and voucher_date between '"+from+"' and '"+to+"' order by voucher_date desc");
/* +" union"
+" select (select ledger_name from account_ledger where l_id=account_voucher_sub.bill_no)parti ,voucher_id,voucher_type,(select voucher_no from account_voucher_main where voucher_id=account_voucher_sub.voucher_id) as voucher_no,voucher_date,(case when voucher_type='payment' then 'Payment' else 'Receipt' end) as voucher_type,(case when voucher_type='payment' then debit_amt else 0 end)as debit,(case when voucher_type='receipt' then debit_amt else 0 end)as credit from account_voucher_sub where bill_no="+id+" and type='O'");
*/
}
else /* if(typ.equals("1")) */
{
rs=st.executeQuery("select (select ledger_name from account_ledger where l_id=tb.particulars)parti,tb.ref_no as voucher_id,'journal' as voucher_type ,tb.journal_no as voucher_no,created_date as voucher_date ,'Journal' as vtype,0 as debit,(select credit from journalentry where type=2 and ref_no=tb.ref_no)credit from journalentry tb where ref_no in (select ref_no from journalentry where particulars="+id+" and type=2 ) and type <>2 and created_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=tb.particulars)parti,tb.ref_no as voucher_id,'journal' as voucher_type ,tb.journal_no as voucher_no,created_date as voucher_date,'Journal' as vtype,(select debit from journalentry where type=1 and ref_no=tb.ref_no)debit,0 as credit from journalentry tb where ref_no in (select ref_no from journalentry where particulars="+id+" and type=1 ) and type <>1 and created_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select ledger_name from account_ledger where l_id=account_voucher_sub.particular)parti ,voucher_id,voucher_type,(select voucher_no from account_voucher_main where voucher_id=account_voucher_sub.voucher_id) as voucher_no,voucher_date,(case when voucher_type='payment' then 'Payment' else 'Receipt' end) as voucher_type,(case when voucher_type='payment' then debit_amt else 0 end)as debit,(case when voucher_type='receipt' then debit_amt else 0 end)as credit from account_voucher_sub where bill_no="+id+" and type='O' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select (select ledger_name from account_ledger where l_id=account_voucher_main.account)parti, voucher_id,voucher_type, voucher_no,voucher_date,(case when cash_cheque='cash' then 'Payment' else 'Cheque Payment' end) as vtype,credit_amt as debit,0 as credit from account_voucher_main where particular="+id+" and voucher_type='payment' and voucher_date between '"+from+"' and '"+to+"'"
+" union"
+" select (select ledger_name from account_ledger where l_id=account_voucher_main.account)parti, voucher_id,voucher_type, voucher_no,voucher_date,'Receipt' as vtype,0,credit_amt from account_voucher_main where particular="+id+" and voucher_type='receipt' and voucher_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select supplier_name from ip_suppliers where supplier_id=debit_note.supplier)parti,voucher_id,'debitnote' as voucher_type,voucher_no,voucher_date,'DebitNote' as vtype ,total as debit,0 as credit from debit_note where purchase_ledger="+id+" and voucher_date between '"+from+"' and '"+to+"'"
+" union "
+" select (select client_name from ip_clients where client_id=credit_note.supplier)parti,voucher_id,'creditnote' as voucher_type,voucher_no,voucher_date,'CreditNote' as vtype ,0 as debit,total as credit from credit_note where purchase_ledger="+id+" and voucher_date between '"+from+"' and '"+to+"' order by voucher_date desc");
}
i=0;
j=0;
while(rs.next())
{
i=i+Double.parseDouble(rs.getString("credit"));
j=j+Double.parseDouble(rs.getString("debit"));
i1=String.format("%.2f", i);
j1=String.format("%.2f", j);
out.write("\r\n");
out.write("\r\n");
out.write("<tr>\r\n");
out.write("<td >");
out.print(rs.getString("voucher_date") );
out.write("</td>\r\n");
out.write("<td >");
out.print(rs.getString("voucher_no") );
out.write("</td>\r\n");
out.write("<td >");
out.print(rs.getString("parti") );
out.write("</td>\r\n");
out.write("<td >");
out.print(rs.getString("vtype") );
out.write("</td>\r\n");
out.write("<td align=\"right\">");
out.print(rs.getString("debit") );
out.write("</td>\r\n");
out.write("<td align=\"right\">");
out.print(rs.getString("credit") );
out.write("</td>\r\n");
out.write("</tr>\r\n");
}
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
rs=st.executeQuery("select * from account_ledger where l_id="+id+"");
while(rs.next())
{
String opbaltype=rs.getString("dr_cr");
if(opbaltype.equals("C"))
{
cr=opbal;
dr="0.00";
}
else
{
dr=opbal;
cr="0.00";
}
}
out.write("\r\n");
out.write("<tr style=\"border-top:1px solid black;\">\r\n");
out.write(" <td colspan=\"4\" align=\"right\" >Opening Balance: </td>\r\n");
out.write(" <td align=\"right\" style=\"padding-right:0px;\"> <span ><b>");
out.print(dr );
out.write("</b></span></td>\r\n");
out.write(" <td align=\"right\" style=\"padding-right:5px;\"><span ><b>");
out.print(cr );
out.write("</b></span></td>\r\n");
out.write(" \r\n");
out.write("\r\n");
out.write("</tr>\r\n");
out.write(" <tr>\r\n");
out.write(" <td colspan=\"4\" align=\"right\" >Current Balance: </td>\r\n");
out.write(" <td align=\"right\" style=\"padding-right:0px;\"> <span ><b>");
out.print(j1 );
out.write("</b></span></td>\r\n");
out.write(" <td align=\"right\" style=\"padding-right:5px;\"><span ><b>");
out.print(i1 );
out.write("</b></span></td>\r\n");
out.write(" \r\n");
out.write(" </tr>\r\n");
out.write(" ");
if(i>j)
{
s=Double.parseDouble(cr)+i-(j+Double.parseDouble(dr));
sum = String.format("%.2f", s);
sum2="";
}
else
{
su=Double.parseDouble(dr)+j-(i+Double.parseDouble(cr));
sum2 = String.format("%.2f", su);
sum="";
}
out.write("\r\n");
out.write(" <tr>\r\n");
out.write(" <td colspan=\"4\" align=\"right\" >Closing Balance: </td>\r\n");
out.write(" <td align=\"right\" style=\"padding-right:0px;\"><b>");
out.print(sum2 );
out.write("</b> </td>\r\n");
out.write(" <td align=\"right\" style=\"padding-right:5px;\"><b>");
out.print(sum );
out.write("</b> </td>\r\n");
out.write(" </tr>\r\n");
out.write(" \r\n");
out.write(" </tbody> \r\n");
out.write("</table>\r\n");
out.write("</td>\r\n");
out.write("</tr>\r\n");
out.write("</tbody>\r\n");
out.write("</table>\r\n");
out.write("</div>\r\n");
out.write("</div>\r\n");
out.write("</div>\r\n");
out.write("</div>\r\n");
out.write("</div>\r\n");
out.write("</form>\r\n");
out.write("\r\n");
out.write("</body>\r\n");
out.write("<script type=\"text/javascript\">\r\n");
out.write("function goBack() {\r\n");
out.write(" window.history.back(); \r\n");
out.write("};\r\n");
out.write("\r\n");
out.write(" \r\n");
out.write("\r\n");
out.write("</script>\r\n");
out.write("<script>\r\n");
out.write("$(document).ready(function(){\r\n");
out.write("\t\r\n");
out.write("\tvar d = new Date($(\"#demo\").val());\r\n");
out.write("\tvar curr_date = d.getDate();\r\n");
out.write("\tvar curr_month = d.getMonth() + 1; //Months are zero based\r\n");
out.write("\tvar curr_year = d.getFullYear();\r\n");
out.write("\t//alert(curr_date + \"-\" + curr_month + \"-\" + curr_year);\r\n");
out.write("\t\r\n");
out.write("\tvar e = new Date($(\"#demo2\").val());\r\n");
out.write("\tvar curr_date2 = e.getDate();\r\n");
out.write("\tvar curr_month2 = e.getMonth() + 1; //Months are zero based\r\n");
out.write("\tvar curr_year2 = e.getFullYear();\r\n");
out.write("\t//alert(curr_date2 + \"-\" + curr_month2 + \"-\" + curr_year2);\r\n");
out.write("\t\r\n");
out.write("\t//alert(curr_date + \"-\" + curr_month + \"-\" + curr_year + \" to \" +curr_date2 + \"-\" + curr_month2 + \"-\" + curr_year2 )\r\n");
out.write("\tdocument.getElementById(\"period\").innerHTML =(curr_date + \"-\" + curr_month + \"-\" + curr_year + \" to \" +curr_date2 + \"-\" + curr_month2 + \"-\" + curr_year2 );\r\n");
out.write("\r\n");
out.write("});\r\n");
out.write("</script>\r\n");
out.write("</html>");
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try {
if (response.isCommitted()) {
out.flush();
} else {
out.clearBuffer();
}
} catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}