Current File : //home/obabain/khb_obaba_in/ViewReceiptVoucher.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ include file="Connection.jsp" %>
    <%!
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;
}
%>
     <%
    
    	
    	Statement st=con.createStatement();
     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;
   /*   if(filt==null)
     {
    	 rsRowCnt=st.executeQuery("select count(*)as cnt from ip_stock_register where type='P' and status=0 ");
    	 if(rsRowCnt.next())
         {
            iTotalRows=rsRowCnt.getInt("cnt");
         }
    
     }
     else
     {
     	rsRowCnt=st.executeQuery("select count(*)as cnt from ip_stock_register where  type='P' and status=0  and product_name like '%"+filt+"%'");
     	if(rsRowCnt.next())
         {
            iTotalRows=rsRowCnt.getInt("cnt");
         }
     } */
     
    	
    	
    %>
<!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">
<input type="hidden" name="iPageNo" value="<%=iPageNo%>">
<input type="hidden" name="cPageNo" value="<%=cPageNo%>">
<input type="hidden" name="iShowRows" value="<%=iShowRows%>">
<div class="row">
<div class="col-md-9"  style="background-color:white;">
<div class="panel panel-default" >
       <div class="panel-heading main-color-bg">
        <h3 class="panel-title">Receipt Voucher</h3>
              </div>
             </div>
             <div class="col-md-12">
                          <!-- <input class="form-control" type="text" placeholder="Search..." name="filter"> -->
                          
                      </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" style="background:#204b58" href="Receiptvoucher.jsp">New</a>
 
</div><br><hr>
<table class="table table-hover" style="width:85%;">
<thead>
<tr>
<th>Date</th>
<th>Voucher No.</th>
<th>Particulars</th>
<th style="text-align:right;">Credit</th>
<!-- <th>Options</th> -->
</tr>
</thead>
<tbody>
<%
rsRowCnt=st.executeQuery("select count(*)as cnt from account_voucher_main where  voucher_type='receipt' and branch_id="+loginid+"");
if(rsRowCnt.next())
{
   iTotalRows=rsRowCnt.getInt("cnt");
}
ResultSet rs=st.executeQuery("select tb.*,date(tb.voucher_date)as vdate,IFNULL((select ledger_name from account_ledger where l_id=tb.particular),'')parti from account_voucher_main tb where voucher_type='receipt' and branch_id="+loginid+" order by voucher_date desc limit "+iPageNo+","+iShowRows+"");
while(rs.next())
{
%>
<tr>
<td><%=rs.getString("vdate") %></td>
<td><a href="ViewReceiptByNo.jsp?id=<%=rs.getString("voucher_id") %>"><%=rs.getString("voucher_no") %></a></td>
<td><%=rs.getString("parti") %></td>
<td align="right"><%=rs.getString("credit_amt") %></td>
<td align="right">
<div class="options btn-group">
<a class="btn btn-default  dropdown-toggle fontstyle" data-toggle="dropdown">
<li class="glyphicon glyphicon-cog"><span class="fontstyle">Options</span></li>
</a>
<ul class="dropdown-menu">
<%-- <li> --%>

</a><%--
</li> --%>
<li>
<a href="ReceiptpdfFrame.jsp?Id=<%=rs.getString("voucher_id")%>"><span class="fontstyle">Download PDF(Original)</span></a> 
<a href="editRecVoucher.jsp?Id=<%=rs.getString("voucher_id")%>">
<span class="fontstyle">Edit</span>
<a href="deleteReceipt.jsp?Id=<%=rs.getString("voucher_id")%>" onclick = "if (! confirm('Continue?')) { return false; }">
<span class="fontstyle">Delete</span>
</a>
</li> 
</ul>
</div>
</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="ViewReceiptVoucher.jsp?iPageNo=<%=prePageNo%>&cPageNo=<%=prePageNo%>"> << Previous</a>
         <%
        }
         
        for(i=((cPage*iTotalSearchRecords)-(iTotalSearchRecords-1));i<=(cPage*iTotalSearchRecords);i++)
        {
          if(i==((iPageNo/iShowRows)+1))
          {
          %>
           <a href="ViewReceiptVoucher.jsp?iPageNo=<%=i%>" style="cursor:pointer;color: red"><b><%=i%></b></a>
          <%
          }
          else if(i<=iTotalPages)
          {
          %>
           <a href="ViewReceiptVoucher.jsp?iPageNo=<%=i%>"><%=i%></a>
          <% 
          }
        }
        if(iTotalPages>iTotalSearchRecords && i<iTotalPages)
        {
         %>
         <a href="ViewReceiptVoucher.jsp?iPageNo=<%=i%>&cPageNo=<%=i%>"> >> Next</a> 
         <%
        }
        }
         
      %>
      <span style="margin-left:50px;"><b>Rows <%=iStartResultNo%> - <%=iEndResultNo%>   Total Result  <%=iTotalRows%> </b></span>
</tbody>
</table>

</div>
</div>
</div>

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