Search field with the below drop-down texts:
1. All Bookings
2. Executed Bookings
3. Cancelled Bookings
4. Cancelation Requests.
service.xml
<entity name="BookingInfo" local-service="true" remote-service="false">
<column name="bookingId" type="String" primary="true"/>
<column name="customerId" type="String" />
<column name="carId" type="String" />
<column name="carType" type="String" />
<column name="emailId" type="String" />
<column name="phNumb" type="String" />
<column name="fromlocation" type="String" />
<column name="toLocation" type="String"/>
<column name="dateOut" type="String" />
<column name="timeOut" type="String" />
<column name="dateIn" type="String" />
<column name="timeIn" type="String" />
<column name="dateDueIn" type="String" />
<column name="timeDueIn" type="String" />
<column name="insurance" type="String" />
<column name="paymentStatus" type="boolean" />
<column name="amount" type="String" />
<column name="carStatus" type="String" />
<column name="cardType" type="String" />
<column name="cardNumb" type="String" />
<column name="cardExpMon" type="String" />
<column name="cardExpYear" type="String" />
<order>
<order-column name="bookingId" order-by="desc" />
</order>
<finder return-type="Collection" name="phNumb">
<finder-column name="phNumb" />
</finder>
<finder return-type="Collection" name="email">
<finder-column name="emailId" />
<finder-column name="paymentStatus" />
</finder>
<finder return-type="Collection" name="carStatus">
<finder-column name="carStatus" />
</finder>
BookingInfoLocalServiceImpl.java
public class BookingInfoLocalServiceImpl extends BookingInfoLocalServiceBaseImpl {
public List<BookingInfo> searchByPhNumb(String phNumb) throws SystemException {
List<BookingInfo> booking = bookingInfoPersistence.findByphNumb(phNumb);
return booking;
}
public List<BookingInfo> searchEmail(String email) throws SystemException {
List<BookingInfo> booking = bookingInfoPersistence.findByemail(email, true);
return booking;
}
public List<BookingInfo> searchByCarStatus(String carStatus) throws SystemException {
List<BookingInfo> booking = bookingInfoPersistence.findBycarStatus(carStatus);
return booking;
}
}
view.jsp
<%@page import="javax.portlet.ActionRequest"%>
<%@page import="javax.portlet.ActionResponse"%>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@page import="com.liferay.portal.kernel.dao.search.SearchContainer"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.slayer.service.BookingInfoLocalServiceUtil"%>
<%@page import="com.slayer.model.BookingInfo"%>
<%@page import="java.util.List"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@page import="javax.portlet.PortletURL"%>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<portlet:defineObjects />
<style>
.href{
text-decoration: none;
}
</style>
<%
List <BookingInfo> bookingInfo = BookingInfoLocalServiceUtil.getBookingInfos(0, -1);
PortletURL iteratorURL = renderResponse.createRenderURL();
iteratorURL.setParameter("jspPage", "/html/Admin/bookingdetail/view.jsp");
String select = "all" ;
String abc = "all";
select = renderRequest.getParameter("select");
abc =(String) request.getAttribute("select");
if(select==null){
select="all";
bookingInfo = BookingInfoLocalServiceUtil.getBookingInfos(0, -1);
}if(abc==null){
abc = "all";
}if(select.equalsIgnoreCase("cancelReq") || abc.equalsIgnoreCase("cancelReq")){
select ="cancelReq";
bookingInfo = BookingInfoLocalServiceUtil.searchByCarStatus("cancelReq");
}
if(select.equalsIgnoreCase("Cancelled") || abc.equalsIgnoreCase("Cancelled")){
select ="Cancelled";
bookingInfo = BookingInfoLocalServiceUtil.searchByCarStatus("Cancelled");
}
if(select.equalsIgnoreCase("Executed")||abc.equalsIgnoreCase("Executed")){
select="Executed";
bookingInfo=BookingInfoLocalServiceUtil.searchByCarStatus("Executed");
}
%>
<div>
<form action="<%=iteratorURL %>" method="post">
<select name="select">
<option value="all" <%if(select.equalsIgnoreCase("all")){ %> selected="selected" <%} %>>All Bookings</option>
<option value="Executed" <%if(select.equalsIgnoreCase("Executed")){ %> selected="selected" <%} %> >Executed Bookings</option>
<option value="cancelled" <%if(select.equalsIgnoreCase("Cancelled")){ %> selected="selected" <%} %> > Cancelled Bookings</option>
<option value="cancelReq" <%if(select.equalsIgnoreCase("cancelReq")){ %> selected="selected" <%} %> >Cancellation Requests</option>
</select>
<input type="submit" value="show">
</form>
</div>
<div>
<liferay-ui:search-container delta="10" emptyResultsMessage="Sorry. There are no items to display." iteratorURL="<%=iteratorURL%>">
<liferay-ui:search-container-results total="<%=bookingInfo.size()%>"
results="<%=ListUtil.subList(bookingInfo, searchContainer.getStart(), searchContainer.getEnd())%>" />
<liferay-ui:search-container-row modelVar="info" className="BookingInfo">
<liferay-ui:search-container-column-text name="Booking Id" property="bookingId"/>
<liferay-ui:search-container-column-text name="Car Type" property="carType"/>
<liferay-ui:search-container-column-text name="Email Id" property="emailId"/>
<liferay-ui:search-container-column-text name="Pick Up Date & Time" value="<%= info.getDateOut() + \" \" + info.getTimeOut() %>"/>
<liferay-ui:search-container-column-text name=" Drop Off Date & Time" value="<%= info.getDateDueIn() + \" \" + info.getTimeDueIn() %>"/>
<liferay-ui:search-container-column-text name=" Actual Drop Off Date & Time" value="<%= info.getDateIn() + \" \" + info.getTimeIn() %>"/>
<liferay-ui:search-container-column-text name="Status" property="carStatus"/>
<liferay-ui:search-container-column-text name="Amount" value="<%=\" $ \" + info.getAmount() %>"/>
<%
if(select.equalsIgnoreCase("cancelReq")){
%>
<liferay-ui:search-container-column-jsp path="/html/Admin/bookingdetail/actionBookingDetails.jsp" name="Action">
</liferay-ui:search-container-column-jsp>
<%}%>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator searchContainer="<%=searchContainer%>" />
</liferay-ui:search-container>
</div>
1. All Bookings
2. Executed Bookings
3. Cancelled Bookings
4. Cancelation Requests.
service.xml
<entity name="BookingInfo" local-service="true" remote-service="false">
<column name="bookingId" type="String" primary="true"/>
<column name="customerId" type="String" />
<column name="carId" type="String" />
<column name="carType" type="String" />
<column name="emailId" type="String" />
<column name="phNumb" type="String" />
<column name="fromlocation" type="String" />
<column name="toLocation" type="String"/>
<column name="dateOut" type="String" />
<column name="timeOut" type="String" />
<column name="dateIn" type="String" />
<column name="timeIn" type="String" />
<column name="dateDueIn" type="String" />
<column name="timeDueIn" type="String" />
<column name="insurance" type="String" />
<column name="paymentStatus" type="boolean" />
<column name="amount" type="String" />
<column name="carStatus" type="String" />
<column name="cardType" type="String" />
<column name="cardNumb" type="String" />
<column name="cardExpMon" type="String" />
<column name="cardExpYear" type="String" />
<order>
<order-column name="bookingId" order-by="desc" />
</order>
<finder return-type="Collection" name="phNumb">
<finder-column name="phNumb" />
</finder>
<finder return-type="Collection" name="email">
<finder-column name="emailId" />
<finder-column name="paymentStatus" />
</finder>
<finder return-type="Collection" name="carStatus">
<finder-column name="carStatus" />
</finder>
BookingInfoLocalServiceImpl.java
public class BookingInfoLocalServiceImpl extends BookingInfoLocalServiceBaseImpl {
public List<BookingInfo> searchByPhNumb(String phNumb) throws SystemException {
List<BookingInfo> booking = bookingInfoPersistence.findByphNumb(phNumb);
return booking;
}
public List<BookingInfo> searchEmail(String email) throws SystemException {
List<BookingInfo> booking = bookingInfoPersistence.findByemail(email, true);
return booking;
}
public List<BookingInfo> searchByCarStatus(String carStatus) throws SystemException {
List<BookingInfo> booking = bookingInfoPersistence.findBycarStatus(carStatus);
return booking;
}
}
view.jsp
<%@page import="javax.portlet.ActionRequest"%>
<%@page import="javax.portlet.ActionResponse"%>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@page import="com.liferay.portal.kernel.dao.search.SearchContainer"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.slayer.service.BookingInfoLocalServiceUtil"%>
<%@page import="com.slayer.model.BookingInfo"%>
<%@page import="java.util.List"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@page import="javax.portlet.PortletURL"%>
<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<portlet:defineObjects />
<style>
.href{
text-decoration: none;
}
</style>
<%
List <BookingInfo> bookingInfo = BookingInfoLocalServiceUtil.getBookingInfos(0, -1);
PortletURL iteratorURL = renderResponse.createRenderURL();
iteratorURL.setParameter("jspPage", "/html/Admin/bookingdetail/view.jsp");
String select = "all" ;
String abc = "all";
select = renderRequest.getParameter("select");
abc =(String) request.getAttribute("select");
if(select==null){
select="all";
bookingInfo = BookingInfoLocalServiceUtil.getBookingInfos(0, -1);
}if(abc==null){
abc = "all";
}if(select.equalsIgnoreCase("cancelReq") || abc.equalsIgnoreCase("cancelReq")){
select ="cancelReq";
bookingInfo = BookingInfoLocalServiceUtil.searchByCarStatus("cancelReq");
}
if(select.equalsIgnoreCase("Cancelled") || abc.equalsIgnoreCase("Cancelled")){
select ="Cancelled";
bookingInfo = BookingInfoLocalServiceUtil.searchByCarStatus("Cancelled");
}
if(select.equalsIgnoreCase("Executed")||abc.equalsIgnoreCase("Executed")){
select="Executed";
bookingInfo=BookingInfoLocalServiceUtil.searchByCarStatus("Executed");
}
%>
<div>
<form action="<%=iteratorURL %>" method="post">
<select name="select">
<option value="all" <%if(select.equalsIgnoreCase("all")){ %> selected="selected" <%} %>>All Bookings</option>
<option value="Executed" <%if(select.equalsIgnoreCase("Executed")){ %> selected="selected" <%} %> >Executed Bookings</option>
<option value="cancelled" <%if(select.equalsIgnoreCase("Cancelled")){ %> selected="selected" <%} %> > Cancelled Bookings</option>
<option value="cancelReq" <%if(select.equalsIgnoreCase("cancelReq")){ %> selected="selected" <%} %> >Cancellation Requests</option>
</select>
<input type="submit" value="show">
</form>
</div>
<div>
<liferay-ui:search-container delta="10" emptyResultsMessage="Sorry. There are no items to display." iteratorURL="<%=iteratorURL%>">
<liferay-ui:search-container-results total="<%=bookingInfo.size()%>"
results="<%=ListUtil.subList(bookingInfo, searchContainer.getStart(), searchContainer.getEnd())%>" />
<liferay-ui:search-container-row modelVar="info" className="BookingInfo">
<liferay-ui:search-container-column-text name="Booking Id" property="bookingId"/>
<liferay-ui:search-container-column-text name="Car Type" property="carType"/>
<liferay-ui:search-container-column-text name="Email Id" property="emailId"/>
<liferay-ui:search-container-column-text name="Pick Up Date & Time" value="<%= info.getDateOut() + \" \" + info.getTimeOut() %>"/>
<liferay-ui:search-container-column-text name=" Drop Off Date & Time" value="<%= info.getDateDueIn() + \" \" + info.getTimeDueIn() %>"/>
<liferay-ui:search-container-column-text name=" Actual Drop Off Date & Time" value="<%= info.getDateIn() + \" \" + info.getTimeIn() %>"/>
<liferay-ui:search-container-column-text name="Status" property="carStatus"/>
<liferay-ui:search-container-column-text name="Amount" value="<%=\" $ \" + info.getAmount() %>"/>
<%
if(select.equalsIgnoreCase("cancelReq")){
%>
<liferay-ui:search-container-column-jsp path="/html/Admin/bookingdetail/actionBookingDetails.jsp" name="Action">
</liferay-ui:search-container-column-jsp>
<%}%>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator searchContainer="<%=searchContainer%>" />
</liferay-ui:search-container>
</div>
No comments:
Post a Comment