Current File : /home/obabain/ms_obaba_in/ViewModule.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 rsPagination = null;
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;
%>
<!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>
<form method="post" action="MenustatusUpdate.jsp">
<%@include file="master.jsp" %>
<div class="content">
<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">Modules</h3>
</div>
</div>
<div class="headerbar-item pull-right" style="margin-top:10px;"><a class="btn btn-danger " onclick="goBack()"><li class="glyphicon glyphicon-triangle-left"></li>Back</a>
</div>
<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></th>
<th>Menu Name</th>
<th></th>
<th>SortOrder</th>
<th>Redirection</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<%
ResultSet rsm=null;
Statement stm=con.createStatement();
if(filt==null)
{
rsRowCnt=st.executeQuery("select count(*)as cnt from ip_menu_creation");
if(rsRowCnt.next())
{
iTotalRows=rsRowCnt.getInt("cnt");
}
rsm=stm.executeQuery("SELECT tb.*,(case when tb.status=0 then 'img/bullet_ball_glass_green.png' else 'img/orange.png' end)img,(case when tb.status=0 then 'active' else 'disabled' end )stat,(case when tb.status=0 then '1' else '0' end )changestat FROM ip_menu_creation tb limit "+iPageNo+","+iShowRows+"");
}
else
{
rsRowCnt=st.executeQuery("select count(*)as cnt from ip_menu_creation where menu_name like '"+filt+"%'");
if(rsRowCnt.next())
{
iTotalRows=rsRowCnt.getInt("cnt");
}
rsm=stm.executeQuery("select * from ip_menu_creation where menu_name like '"+filt+"%' limit "+iPageNo+","+iShowRows+"");
}
while(rsm.next())
{
%>
<tr>
<td><input type="hidden" name="id" value="<%=rsm.getString("id") %>"></td>
<td><%=rsm.getString("menu_name") %></td>
<td><input type="hidden" name="id" value="<%=rsm.getString("menu_parent_id") %>"></td>
<td><%=rsm.getString("sortorder") %></td>
<td><%=rsm.getString("redirection_page") %></td>
<td>
<a href="MenustatusUpdate.jsp?Id=<%=rsm.getString("id") %>&status=<%=rsm.getString("changestat") %>"><img src="<%=rsm.getString("img")%>" ></a><%=rsm.getString("stat") %>
</td>
<!--
<td><a href="editmenu.jsp?Id=<%=rsm.getString("id") %>"><span class="glyphicon glyphicon-pencil"></span></a></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(filt==null)
{
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="ViewModule.jsp?iPageNo=<%=prePageNo%>&cPageNo=<%=prePageNo%>"> << Previous</a>
<%
}
for(i=((cPage*iTotalSearchRecords)-(iTotalSearchRecords-1));i<=(cPage*iTotalSearchRecords);i++)
{
if(i==((iPageNo/iShowRows)+1))
{
%>
<a href="ViewModule.jsp?iPageNo=<%=i%>" style="cursor:pointer;color: red"><b><%=i%></b></a>
<%
}
else if(i<=iTotalPages)
{
%>
<a href="ViewModule.jsp?iPageNo=<%=i%>"><%=i%></a>
<%
}
}
if(iTotalPages>iTotalSearchRecords && i<iTotalPages)
{
%>
<a href="ViewModule.jsp?iPageNo=<%=i%>&cPageNo=<%=i%>"> >> Next</a>
<%
}
}
}
else{
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="ViewModule.jsp?iPageNo=<%=prePageNo%>&cPageNo=<%=prePageNo%>&filter=<%=filt%>"> << Previous</a>
<%
}
for(i=((cPage*iTotalSearchRecords)-(iTotalSearchRecords-1));i<=(cPage*iTotalSearchRecords);i++)
{
if(i==((iPageNo/iShowRows)+1))
{
%>
<a href="ViewModule.jsp?iPageNo=<%=i%>&filter=<%=filt%>" style="cursor:pointer;color: red"><b><%=i%></b></a>
<%
}
else if(i<=iTotalPages)
{
%>
<a href="ViewModule.jsp?iPageNo=<%=i%>&filter=<%=filt%>"><%=i%></a>
<%
}
}
if(iTotalPages>iTotalSearchRecords && i<iTotalPages)
{
%>
<a href="ViewModule.jsp?iPageNo=<%=i%>&cPageNo=<%=i%>&filter=<%=filt%>"> >> Next</a>
<%
}
}
}
%>
<span style="margin-left:50px;"><b>Rows <%=iStartResultNo%> - <%=iEndResultNo%> Total Result <%=iTotalRows%> </b></span>
</tbody>
</table>
</div>
</div>
</div>
</form>
<script type="text/javascript">
function goBack() {
window.history.back();
};
</script>
</body>
</html>