Current File : //home/obabain/khb_obaba_in/PurchaseReports.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@include file="Connection.jsp" %>
    <%!
     int yr=0;
     int year=0;
     %>
    <%Statement st=con.createStatement();
    ResultSet rs=null;
    ResultSet ry=st.executeQuery("select YEAR(NOW())as fyear");
 	while(ry.next())
 	{
 		year=Integer.parseInt(ry.getString("fyear"));
 	}
 	 yr=year+1;
 	
    %>
<!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>
</head>
<body>
<%@include file="master.jsp" %>
<form>

<div class="content">
 <div class="row" style="width:90%">
    <div class="col-md-9" >
       <div class="panel panel-default" >
       <div class="panel-heading main-color-bg">
        <h3 class="panel-title">Purchase Reports</h3>
    </div>
<div class="panel-body">

<div class="row" style="color:#F24591;" >    
       <div class="col-xs-3">
          <label for="lastname" >This Year</label> 
          </div>
          <div class="col-xs-4">
         <%--  <%
          rs=st.executeQuery("select IFNULL(sum(total),0) tot from ip_puchase_invoice where branch_id="+loginid+" and YEAR(invoice_date_created)=(select YEAR(NOW()))");
        		  while(rs.next())
        		  {
          %>
           <span><%=rs.getString("tot") %></span>
           <%} %> --%>
           <%
           String deb="0.00";
           double sum=0;
           double sum2=0;
           rs=st.executeQuery("select 'Apr' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='04' and YEAR(IFNULL(invoice_date_created,NOW()))=(select YEAR(NOW()))"
        			
	+" UNION	select 'May' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='05' and YEAR(IFNULL(invoice_date_created,NOW()))=(select YEAR(NOW()))"
		
	+" UNION	select 'Jun' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='06' and YEAR(IFNULL(invoice_date_created,NOW()))=(select YEAR(NOW()))"
		
		+" UNION select 'Jul' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='07' and YEAR(IFNULL(invoice_date_created,NOW()))=(select YEAR(NOW()))"
		
		+" UNION select 'Aug' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='08' and YEAR(IFNULL(invoice_date_created,NOW()))=(select YEAR(NOW()))"
		
		+" UNION select 'Sep' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='09' and YEAR(IFNULL(invoice_date_created,NOW()))=(select YEAR(NOW()))"
		
		+" UNION select 'Oct' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='10' and YEAR(IFNULL(invoice_date_created,NOW()))=(select YEAR(NOW()))"
		
		+" UNION select 'Nov' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='11' and YEAR(IFNULL(invoice_date_created,NOW()))=(select YEAR(NOW()))"
		
		+" UNION select 'Dec' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='12' and YEAR(IFNULL(invoice_date_created,NOW()))=(select YEAR(NOW()))"

+" UNION select 'Jan' as month ,ROUND(IFNULL(sum(total),0),2)  tot  from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='01' and YEAR(IFNULL(invoice_date_created,NOW()))="+yr+""

+" UNION select 'Feb' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='02' and YEAR(IFNULL(invoice_date_created,NOW()))="+yr+""
		 
+" UNION select 'Mar' as month ,ROUND(IFNULL(sum(total),0),2)  tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(IFNULL(invoice_date_created,NOW()))='03' and YEAR(IFNULL(invoice_date_created,NOW()))="+yr+"");

while(rs.next())
{
	System.out.print(yr);
	/* Double cr=Double.parseDouble(rs.getString("tot"));
	int s=(int)(Math.round(cr));
	if(s>0)
	{
	sum=sum+s;
	sum2=sum;
	} */
	//else sum=0.0;
	double c=0;
	
	 c=Double.parseDouble(rs.getString("tot"));
	 
	sum=sum+c;
	deb = String.format("%.2f", sum);
	
}
%>
<span><%=deb %></span>
           
          </div>             
          </div>
<div class="row" style="color:#E7A046;">    
       <div class="col-xs-3">
          <label for="lastname" >This Month</label> 
          </div>
          <div class="col-xs-4">
          <%
          rs=st.executeQuery("select IFNULL(sum(total),0)tot from ip_puchase_invoice where branch_id="+loginid+" and MONTH(invoice_date_created)=(select MONTH(NOW())) and YEAR(invoice_date_created)=(select YEAR(NOW()))");
        		  while(rs.next())
        		  {
          %>
           <span><%=rs.getString("tot") %></span>
           <%} %>
          </div>             
          </div>
          <hr>
        <div class="row" > 
        <div class="col-xs-4">
        <div class="well dash-box">
        <a href="PurchaseReportMonthwise.jsp" class="btn btn-primary">Purchase Register</a>
        </div>
        </div>
        </div>  
          <div class="modal-footer" id="contact_submit">
         <input type="button" value="Back" style="background:#204b58;" class="pull-left btn btn-info" onclick="goBack()" />
         </div>
</div>

</div>
</div>
</div>
</div>
<%@include file="footer.jsp" %>
</form>
</body>
<script type="text/javascript">
function goBack() {
    window.history.back(); 
};
</script>
</html>