Current File : //home/obabain/anms_obaba_in/SalesReportMonth.jsp |
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ include file="Connection.jsp" %>
<%@include file="master.jsp" %>
<%!String mnth=null;
String mn=null;
int yr=0;
int year=0;
int currmnth=0;
public int nullIntconv(String str)
{
int conv=0;
if(str==null)
{
str="0";
}
else if((str.trim()).equals("null"))
{
str="0";
}
else if(str.equals(""))
{
str="0";
}
try{
conv=Integer.parseInt(str);
}
catch(Exception e)
{
}
return conv;
}
%>
<%
ResultSet rsRowCnt = null;
int iShowRows=10; // Number of records show on per page
int iTotalSearchRecords=10; // Number of pages index shown
int iTotalRows=nullIntconv(request.getParameter("iTotalRows"));
int iTotalPages=nullIntconv(request.getParameter("iTotalPages"));
int iPageNo=nullIntconv(request.getParameter("iPageNo"));
int cPageNo=nullIntconv(request.getParameter("cPageNo"));
String filt=request.getParameter("filter");
if(iPageNo==0)
{
iPageNo=0;
}
else{
iPageNo=Math.abs((iPageNo-1)*iShowRows);
}
int iStartResultNo=0;
int iEndResultNo=0;
Statement st=con.createStatement();
ResultSet rs=null;
String month=request.getParameter("month");
if(month.equals("Jan"))
{
mnth="January";
mn="01";
}
else if(month.equals("Feb"))
{
mnth="February";
mn="02";
}
else if(month.equals("Mar"))
{
mnth="March";
mn="03";
}
else if(month.equals("Apr"))
{
mnth="April";
mn="04";
}
else if(month.equals("May"))
{
mnth="May";
mn="05";
}
else if(month.equals("Jun"))
{
mnth="June";
mn="06";
}
else if(month.equals("Jul"))
{
mnth="July";
mn="07";
}
else if(month.equals("Aug"))
{
mnth="August";
mn="08";
}
else if(month.equals("Sep"))
{
mnth="September";
mn="09";
}
else if(month.equals("Oct"))
{
mnth="October";
mn="10";
}
else if(month.equals("Nov"))
{
mnth="November";
mn="11";
}
else if(month.equals("Dec"))
{
mnth="December";
mn="12";
}
rs=st.executeQuery("select MONTH(NOW()) as currmonth");
yr=Integer.parseInt(request.getParameter("yr"));
if(yr==0)
{
ResultSet ry=st.executeQuery("select YEAR(NOW())as fyear");
while(ry.next())
{
year=Integer.parseInt(ry.getString("fyear"));
}
}
else
{
year=yr;
}
// yr=Integer.parseInt(request.getParameter("yr"));
/* if(yr==0)
{
ResultSet ry=st.executeQuery("select YEAR(NOW())as fyear");
while(ry.next())
{
year=Integer.parseInt(ry.getString("fyear"));
}
}
else
{
year=yr;
} */
%>
<!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">
<script src='https://code.jquery.com/jquery-3.3.1.js'></script>
<script src='https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js'></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js" charset="utf-8">
</script>
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
-->
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css"> -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css">
<title>Inventory</title>
</head>
<style>
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 12px;
font-size: 16px;
border: none;
cursor: pointer;
height:35px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
</style>
<style>
table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid #ddd;
}
tr, td {
text-align: left;
padding: 8px;
}
tr:nth-child(even){background-color: #f2f2f2}
</style>
<body>
<script type="text/javascript">
$(document).ready(function() {
$('#example').DataTable();
} );
</script>
<form>
<div class="content">
<div class="row">
<div class="col-md-9" style="background-color:#eae9e9;width:80%;">
<div class="panel panel-default" >
<div class="panel-heading main-color-bg">
<h3 class="panel-title">Sales Invoice 2021-22</h3>
</div>
</div>
<div class="headerbar-item pull-right" style="margin-top:-55px;"><a class="btn btn-danger" style="background:" onclick="goBack()">Back</a>
<a class="btn btn-danger" style="background:" href="SalesInvoiceMain.jsp">New</a>
<a class="btn btn-info" style="background:#204b58" href="Datewisepii.jsp">Date Wise View</a>
<a class="btn btn-info" style="background:#204b58" href="Datewiseee.jsp">Date Wise </a>
</div>
<br>
<div class="dropdown" style="margin-top:-32px;">
<button class="dropbtn" style="margin-left:745px;">View All</button>
<div class="dropdown-content" style="margin-left:775px;">
<a href="ViewInvoices.jsp">2019-20</a>
<a href="ViewInvoices.jsp">2020-21</a>
<a href="sales21.jsp">2021-22</a>
</div>
</div>
<div class="panel-body">
<input type="hidden" name="month" value="<%=month%>">
<input type="hidden" name="yr" value="<%=yr%>">
<input type="hidden" name="mn" value="<%=mn%>" id="mn">
<input type="hidden" name="year" value="<%=year%>" id="year">
<table class="table table-bordered" id="example">
<thead>
<tr>
<th style="width:10%;">Date</th>
<th style="width:10%;">Invoice No.</th>
<th style="width:10%;"> Client Name</th>
<th style="width:10%;"> Item Name</th>
<th style="width:10%;text-align:right;">Qty</th>
<th style="width:10%;">Net Amount</th>
<th style="width:10%;">Total Amount</th>
</tr>
</thead>
<tbody>
<%
double debittot=0;
double credittot=0;
String deb="0.00";
String cred="0.00";
rsRowCnt=st.executeQuery("select count(*)as cnt from ip_sales_invoice_item1 where MONTHNAME(item_date_added)='"+mnth+"'");
if(rsRowCnt.next())
{
iTotalRows=rsRowCnt.getInt("cnt");
}
//rs=st.executeQuery("select tb.*,(select client_name from ip_clients where client_id=tb.supplier_id)suppl from ip_sales_invoice tb where MONTHNAME(invoice_date_created)='"+mnth+"'limit "+iPageNo+","+iShowRows+"");
if(yr==0)
{
if(mnth=="January" || mnth=="February" || mnth=="March")
{
ResultSet ry=st.executeQuery("select MONTH(NOW()) as currmnth");
while(ry.next())
{
currmnth=Integer.parseInt(ry.getString("currmnth"));
}
if(currmnth==01 || currmnth==02|| currmnth==03)
{
yr=year;
}
else
{
yr=year+1;
}
}
else
{
ResultSet ry=st.executeQuery("select MONTH(NOW()) as currmnth");
while(ry.next())
{
currmnth=Integer.parseInt(ry.getString("currmnth"));
}
if(currmnth==01 || currmnth==02|| currmnth==03)
{
yr=year-1;
}
else
{
yr=year;
}
}
}
else
{
if(mnth=="January" || mnth=="February" || mnth=="March")
{
yr=yr+1;
}
}
rs=st.executeQuery("select tb.*,(select invoice_date_created from ip_sales_invoice1 where sinvoice_id=tb.invoice_id )gdate ,(select podate from ip_sales_invoice1 where sinvoice_id=tb.invoice_id)podate ,(select supplier_id from ip_sales_invoice1 where sinvoice_id=tb.invoice_id )name ,(select sales_invoice_no from ip_sales_invoice1 where sinvoice_id=tb.invoice_id)inv ,(select total from ip_sales_invoice1 where sinvoice_id=tb.invoice_id)total ,ROUND((item_qty*item_price),2)as stock,ROUND((case when (select tax_rate_name from ip_tax_rates where tax_rate_id=tb.item_tax_rate_id)='IGST' then ((item_qty*item_price)*(select tax_rate_percent from ip_tax_rates where tax_rate_id=tb.item_tax_rate_id))/100 else 0 end),2)as igst,ROUND((case when (select tax_rate_name from ip_tax_rates where tax_rate_id=tb.item_tax_rate_id)='IGST' then 0 else ((item_qty*item_price)*(select tax_rate_percent from ip_tax_rates where tax_rate_id=tb.item_tax_rate_id))/100 end),2)as sgst FROM ip_sales_invoice_item1 tb where MONTHNAME(item_date_added)='"+mnth+"' and YEAR(item_date_added)="+yr+"");
while(rs.next())
{
%>
<tr>
<td>
<%=rs.getString("gdate") %>
</td>
<td>
<%=rs.getString("inv") %>
</td>
<td>
<%=rs.getString("name") %>
</td>
<td >
<%=rs.getString("item_name") %>
</td>
<td align="right" >
<%=rs.getString("item_qty") %>
</td>
<td align="right">
<%=rs.getString("item_price") %>
</td>
<td align="right">
<%=rs.getString("total") %>
</td>
</tr>
<%} %>
<%-- <%
//// calculate next record start record and end record
try{
if(iTotalRows<(iPageNo+iShowRows))
{
iEndResultNo=iTotalRows;
}
else
{
iEndResultNo=(iPageNo+iShowRows);
}
iStartResultNo=(iPageNo+1);
iTotalPages=((int)(Math.ceil((double)iTotalRows/iShowRows)));
}
catch(Exception e)
{
e.printStackTrace();
}
%><tr>
<td colspan="5" align="center">
<div>
<%
//// index of pages
int i=0;
int cPage=0;
if(iTotalRows!=0)
{
cPage=((int)(Math.ceil((double)iEndResultNo/(iTotalSearchRecords*iShowRows))));
int prePageNo=(cPage*iTotalSearchRecords)-((iTotalSearchRecords-1)+iTotalSearchRecords);
if((cPage*iTotalSearchRecords)-(iTotalSearchRecords)>0)
{
%>
<a href="SalesReportMonth_view.jsp?month=<%=mnth %>&iPageNo=<%=prePageNo%>&cPageNo=<%=prePageNo%>"> << Previous</a>
<%
}
for(i=((cPage*iTotalSearchRecords)-(iTotalSearchRecords-1));i<=(cPage*iTotalSearchRecords);i++)
{
if(i==((iPageNo/iShowRows)+1))
{
%>
<a href="SalesReportMonth_view.jsp?month=<%=mnth %>&iPageNo=<%=i%>" style="cursor:pointer;color: red"><b><%=i%></b></a>
<%
}
else if(i<=iTotalPages)
{
%>
<a href="SalesReportMonth_view.jsp?month=<%=mnth %>&iPageNo=<%=i%>"><%=i%></a>
<%
}
}
if(iTotalPages>iTotalSearchRecords && i<iTotalPages)
{
%>
<a href="SalesReportMonth_view.jsp?month=<%=mnth %>&iPageNo=<%=i%>&cPageNo=<%=i%>"> >> Next</a>
<%
}
}
%>
<span style="margin-left:50px;"><b>Rows <%=iStartResultNo%> - <%=iEndResultNo%> Total Result <%=iTotalRows%> </b></span> --%>
</table>
</div>
</td>
</tr>
<tr>
</tr>
</tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<%
ResultSet re=null;
re=st.executeQuery("select IFNULL(sum(item_qty*item_price),0)sqty from ip_sales_invoice_item1 tb where MONTHNAME(item_date_added)='"+mnth+"' and YEAR(item_date_added)="+yr+"");
while(re.next())
{
%>
<Lable style="text-align: center;color:red;">Total Net Amount <%=re.getString("sqty")%></Lable><br>
<%} %>
<%
ResultSet rp=null;
rp=st.executeQuery("select IFNULL(sum(total),0)sqtyy from ip_sales_invoice1 ");
while(rp.next())
{
%>
<Lable style="text-align: center;color:red;">Total Amount <%=rp.getString("sqtyy")%></Lable><br>
<%} %>
<br>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</form>
<script type="text/javascript">
function goBack() {
window.history.back();
};
</script>
<script>
var m=document.getElementById("mn").value;
var y=document.getElementById("year").value;
if(m==01 || m==02 || m==03)
{
y=parseInt(y)+1;
}
var fromday = y+"-"+m+"-01" ;
if(m==01 || m==03 || m==05 || m==07 || m==08 || m==10 || m==12)
{
var today=y+"-"+m+"-31";
}
else if(m==02)
{
if((y%4==0 && y%100!=0)||y%400==0)
{
var today=y+"-"+m+"-29";
}
else
{
var today=y+"-"+m+"-28";
}
}
else
{
var today=y+"-"+m+"-30";
}
document.getElementById("from").value = fromday;
document.getElementById("to").value = today;
</script>
</html>