Current File : //home/obabain/public_html/abc/PurchaseReportMonth_view.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
     <%@include file="Connection.jsp" %>
     <%!String mnth=null;
     int yr=0;
     int year=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";
     else if(month.equals("Feb"))
    	 mnth="February";
     else if(month.equals("Mar"))
    	 mnth="March";
     else if(month.equals("Apr"))
    	 mnth="April";
     else if(month.equals("May"))
    	 mnth="May";
     else if(month.equals("Jun"))
    	 mnth="June";
     else if(month.equals("Jul"))
    	 mnth="July";
     else if(month.equals("Aug"))
    	 mnth="August";
     else if(month.equals("Sep"))
    	 mnth="September";
     else if(month.equals("Oct"))
    	 mnth="October";
     else if(month.equals("Nov"))
    	 mnth="November";
     else if(month.equals("Dec"))
    	 mnth="December";
     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">
<style>
tbody div{
    overflow:scroll;
    height:350px;
}
.borderless table {
    border-top-style: none;
    border-left-style: none;
    border-right-style: none;
    border-bottom-style: none;
}
.viewtable>thead>tr>th
{
width:10%;
}

</style>
<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</h3>
    </div>
    <div class="headerbar-item pull-right" style="margin-top:10px;"><a class="btn btn-info" style="background:#204b58"   onclick="goBack()">Back</a>
<a class="btn btn-info" href="purchase_reg_month_printFrame.jsp?month=<%=month %>&yr=<%=yr %>" style="background:#204b58" >Print</a>
<!-- <a  class="btn btn-info"  style="background:#204b58"  data-toggle="modal" data-target="#myModalledg">Period</a> -->
</div>
<div class="panel-body">
<input type="hidden" name="iPageNo" value="<%=iPageNo%>">
<input type="hidden" name="cPageNo" value="<%=cPageNo%>">
<input type="hidden" name="iShowRows" value="<%=iShowRows%>">
<table class="table">
<thead>
<tr>
<th style="width:10%;">Date</th>
<th style="width:10%;">Particulars</th>
<th style="width:10%;">Vch.No.</th>

<th style="text-align:right;width:10%; padding-right:35px;">Credit</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="6">
 <div class="scrollit">
 <table class="viewtable table-borderless viewtable-hover">
<%
double debittot=0;
double credittot=0;
String deb="0.00";
String cred="0.00";
rsRowCnt=st.executeQuery("select count(*)as cnt from ip_puchase_invoice where branch_id="+loginid+" and MONTHNAME(invoice_date_created)='"+mnth+"'");
if(rsRowCnt.next())
{
   iTotalRows=rsRowCnt.getInt("cnt");
}
//rs=st.executeQuery("select tb.*,(select supplier_name from ip_suppliers where supplier_id=tb.supplier_id)suppl from ip_puchase_invoice tb where MONTHNAME(invoice_date_created)='"+mnth+"'limit "+iPageNo+","+iShowRows+"");
if(mnth=="January" || mnth=="February" || mnth=="March")
{
	year=year+1;
}
rs=st.executeQuery("select tb.*,(select supplier_name from ip_suppliers where supplier_id=tb.supplier_id)suppl from ip_puchase_invoice tb where branch_id="+loginid+" and MONTHNAME(invoice_date_created)='"+mnth+"' and YEAR(invoice_date_created)="+year+"");
while(rs.next())
{
	debittot=debittot+Double.parseDouble(rs.getString("total"));
	 deb = String.format("%.2f", debittot);
%>
<tr>
<td>
<%=rs.getString("invoice_date_created") %>
</td>
<td><a href="Suplier_wise_Report.jsp?id=<%=rs.getString("supplier_id")%>"><%=rs.getString("suppl") %></a>

</td>
<td>
<%=rs.getString("purchase_invoice_no") %>
</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="PurchaseReportMonth_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="PurchaseReportMonth_view.jsp?month=<%=mnth %>&iPageNo=<%=i%>" style="cursor:pointer;color: red"><b><%=i%></b></a>
          <%
          }
          else if(i<=iTotalPages)
          {
          %>
           <a href="PurchaseReportMonth_view.jsp?month=<%=mnth %>&iPageNo=<%=i%>"><%=i%></a>
          <% 
          }
        }
        if(iTotalPages>iTotalSearchRecords && i<iTotalPages)
        {
         %>
         <a href="PurchaseReportMonth_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>
<td colspan="4" align="right" style="padding-right: 25px;"><b><%=deb %></b></td>

</tr>
</tbody>
</table>
<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>