Está en la página 1de 13

<%@page import="utility.

WebKeys"%>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.liferay.portal.security.auth.PrincipalException"%>
<%@page import="com.liferay.portal.service.permission.PortletPermissionUtil"%>
<%@page import="com.liferay.portal.security.permission.PermissionChecker"%>
<%@page import="com.liferay.portal.model.Layout"%>
<%@page import="com.liferay.portal.service.LayoutLocalServiceUtil"%>
<%@page import="com.liferay.portal.service.permission.PortletPermission"%>
<%-- <%@page import="utility.ActionKeys"%> --%>
<%@page import="utility.Constants"%>
<%@page import="exception.InvalidImageException"%>
<%@page import="utility.DateUtil"%>
<%@page import="com.intranet.event_mngt.model.Event"%>

<%@ include file="/init.jsp" %>


<%Event advertise = (Event)request.getAttribute("event"); %>

<div class="block">
<div class="block-title">
<h2><strong>Events</strong></h2>
</div>

<%
boolean approvepermission=true,
addpermission=true,editpermission=true,deletepermission=true;

%>

<portlet:actionURL var="addEventURL">
<portlet:param name="action" value="add"></portlet:param>
</portlet:actionURL>
<liferay-portlet:actionURL var="uploadEventActionURL">
<portlet:param name="action" value="uploadEventAction"/>
</liferay-portlet:actionURL>
<portlet:resourceURL var="branchChosenCallUrl" id="branchChosenCall"
></portlet:resourceURL>

<liferay-ui:error exception="<%=InvalidImageException.class%>" message="valid-


image" />
<liferay-ui:success key="record-add-success" message="record-add-success"/>
<liferay-ui:error key="record-add-error" message="record-add-error"/>
<liferay-ui:error key="event-max-length" message="record-add-error"/>
<liferay-ui:success key="record-update-success" message="record-update-success"/>
<liferay-ui:success key="record-delete-success" message="record-delete-success"/>
<liferay-ui:error key="record-delete-error" message="record-delete-error"/>

<liferay-ui:error key="event-title-empty" message="event-title-empty" />


<liferay-ui:error key="event-max-length" message="event-max-length" />
<liferay-ui:error key="event-Description-empty" message="event-Description-
empty" />
<liferay-ui:error key="Description-max-length" message="Description-max-length" />
<liferay-ui:error key="Eventtype-date-empty" message="Eventtype-date-empty" />
<liferay-ui:error key="EventStartDate-date-empty" message="EventStartDate-date-
empty" />
<liferay-ui:error key="EventStartTime-date-empty" message="EventStartTime-date-
empty" />
<liferay-ui:error key="Url-date-empty" message="Url-date-empty" />
<liferay-ui:error key="Img-date-empty" message="Img-date-empty" />
<liferay-ui:error key="event-object-empty" message="event-object-empty" />
<liferay-ui:error key="EventTarget-date-empty" message="EventTarget-date-empty" />

<liferay-ui:success key="record-restore-success" message="Record restored


Successfully"/>
<liferay-ui:error key="record-restore-error" message="record-restore-error"/>

<form:form cssClass="form-bordered" id="eventForm" modelAttribute="event"


action="${addEventURL}" method="post" enctype="multipart/form-data">
<form:hidden path="eventId"/>
<c:if test="${empty approve || approve eq false }">
<form:input path="status" type="hidden"/>
</c:if>
<fmt:formatDate var = "fDate" value="${event.eventStartDate}" pattern="<
%=DateUtil.getFormat()%>"/>
<fmt:formatDate var = "tDate" value="${event.eventEndDate}" pattern="<
%=DateUtil.getFormat()%>" />

<div class="row form-group">


<div class="col-md-4 "><form:label path="name">Name<span class="text-
danger">*</span></form:label></div>
<div class="col-md-4">
<form:input type="text" path="name" />
</div>
</div>
<div class="row form-group">
<div class="col-md-4"><label>Select Audience Target<span class="text-
danger">*</span></label></div>
<div class="col-md-4">
<select id="target" name="target" class="form-control"
style="width:100%;">
<option value="">Select Option</option>
<%-- <c:forEach items="<%=Constants.TARGET.values()%>"
var="target"> --%>
<%-- <option value="${target.getValue()}" <c:if test="$
{target.getValue() eq event.target}">selected</c:if>>${target.getName()}</option>
--%>
<%-- </c:forEach> --%>
<option value="<%=Constants.TARGET.ZONE.getValue()%>" <c:if
test="${target.getValue() eq event.target}">selected</c:if>>Zone</option>
<option value="<%=Constants.TARGET.BRANCH.getValue()%>" <c:if
test="${target.getValue() eq event.target}">selected</c:if>>Branch</option>
<option value="<%=Constants.TARGET.DEPARTMENT.getValue()%>"
<c:if test="${target.getValue() eq
event.target}">selected</c:if>>Department</option>
</select>
</div>
</div>
<!-- <div class="col-md-4"> -->
<%-- <form:select > --%>
<%-- <form:option value="" >Select</form:option> --%>
<%-- <c:forEach items="${zoneList}" var="zoneList" > --%>
<%-- <form:option value="${zoneList.zoneId}">$
{zoneList.name}</form:option> --%>
<%-- </c:forEach> --%>
<%-- </form:select> --%>
<!-- </div> -->
<div class="row form-group" id="zoneDiv">
<div class="col-md-4"><label>Select Zones</label></div>
<div class="col-md-4">
<select id="zoneIds" name="zoneIds" class="chosen-select"
autocomplete="off" style="width:100%;" multiple="multiple">
<option value="">Select atleast one zone</option>
<c:forEach items="${zoneList}" var="zone">
<option value="${zone.zoneId}">${zone.name}</option>
</c:forEach>
</select>
</div>
</div>
<div class="row form-group" id="branchDiv">
<div class="col-md-4"><label>Select Branches</label></div>
<div class="col-md-4">
<select id="branchIds" name="branchIds" class="chosen-select"
autocomplete="off" style="width:100%;" multiple="multiple">
<c:forEach items="${branchList}" var="branch">
<option value="${branch.branchId}" selected>$
{branch.name}</option>
</c:forEach>
</select>
</div>
</div>

<div class="row form-group">


<div class="col-md-4">
<form:label path="eventType">Event Type<span class="text-
danger">*</span>
</form:label>
</div>
<div class="col-md-4">
<form:select path="eventType" >
<form:option value="" >Select</form:option>
<c:forEach items="${eventTypeList}"
var="eventTypeobj" >
<form:option value="${eventTypeobj.value}">$
{eventTypeobj.value}</form:option>
</c:forEach>
</form:select>
</div>
</div>
<div class="row form-group" id="departmentDiv">
<div class="col-md-4"><label>Select Departments</label></div>
<div class="col-md-4">
<select id="departmentIds" name="departmentIds" class="chosen-
select" multiple="multiple">
<c:forEach items="${departmentList}" var="department">
<option value="${department.departmentId}" selected>$
{department.name}</option>
</c:forEach>
</select>
</div>
</div>
<div class="row form-group">
<div class="col-md-4 "><form:label path="description">Description<span
class="text-danger">*</span></form:label></div>
<div class="col-md-6"><form:textarea path="description"
style="height:100px"/></div>
</div>
<div class="row form-group">
<div class="col-md-8 col-md-offset-4" >
Single date<input type="radio" checked="checked"
onclick="javascript:yesnoCheck2();" name="yesno" id="yesCheck"/>

Multiple date<input type="radio" onclick="javascript:yesnoCheck();"


name="yesno" id="noCheck"//>
</div>
</div>
<div class="row form-group">
<div class="col-md-4 "><form:label path="eventStartDate">Select Date
Range<span class="text-danger">*</span></form:label></div>
<div class="col-md-8">
<div class="input-group input-daterange row" data-date-
format="dd/mm/yyyy">
<div class="col-md-8" id="ifYes">
<form:input path="eventStartDate" class="form-control
text-center col-md-4" placeholder="From" value="${fDate}"/>
</div>
</div>
<div>
<!-- <div class="col-md-4"> -->
<!-- <span class="input-group-addon col-md-1"><i class="fa fa-
angle-right"></i></span> -->
<!-- </div> -->

<div class="input-group input-daterange row" data-date-


format="dd/mm/yyyy">
<div class="col-md-8">
<form:input id="ifNo" path="eventEndDate" class="form-
control text-center col-md-4" placeholder="To" value="${tDate}" disabled="true"/>
</div>
</div>
<!-- </div> -->
</div>
</div>
<div class="col-md-4">eventStartTime<span class="text-
danger">*</span></div><div class="col-md-offset-4">
<div class="input-group bootstrap-timepicker"
id="timepicker">
<input type="text" id="eventStartTime"
name="eventStartTime"
value="${eventStartTime}"
class="form-control input-timepicker204"
readonly="readonly">
<span class="input-group-btn"> <a
href="javascript:void(0)"
class="btn btn-primary"><i class="fa fa-
clock-o"></i></a>
</span>
</div>
</div>
</div>
<!-- <div class="col-md-4"> -->
<!-- <div class="input-group bootstrap-timepicker"
id="timepicker"> -->
<!-- <input type="text" id="eventStartTime"
name="eventStartTime" -->
<%-- value="${eventStartTime}" --%>
<!-- class="form-control input-timepicker204"
readonly="readonly"> -->
<!-- <span class="input-group-btn"> <a
href="javascript:void(0)" -->
<!-- class="btn btn-primary"><i class="fa fa-
clock-o"></i></a> -->
<!-- </span> -->
<!-- </div> -->
<!-- </div> -->
<div class="row form-group">
<div class="col-md-4 "><form:label path="url">Url<span class="text-
danger">*</span></form:label></div>
<div class="col-md-8"><form:input path="url" maxlength="255" /></div>
</div>

<c:if test="${approve eq true}">

<div class="row form-group">


<div class="col-md-4">
<input type="radio" name="status" value="<
%=WebKeys.STATUS_APPROVAL.APPROVED.getValue()%>" id="approve"> Approve
</div>
<div class="col-md-4">
<input type="radio" name="status" value="<
%=WebKeys.STATUS_APPROVAL.REJECT.getValue()%>" id="reject"> Reject
</div>
</div>

<div class="row form-group" id="approveRemark" style="display: none">


<div class="col-md-4"><label>Approval Remarks<span class="text-
danger">*</span></label></div>
<div class="col-md-8">
<form:textarea path="approvalremarks"
style="height:100px"/>
</div>
</div>

<div class="row form-group" id="rejectRemark" style="display: none">


<div class="col-md-4"><label >Rejection Remarks<span class="text-
danger">*</span></label></div>
<div class="col-md-8">
<form:textarea path="rejectionremarks"
style="height:100px"/>
</div>
</div>

</c:if>
<div class="row form-group">
<div class="col-md-4 "><form:label path="fileData">Image<span
class="text-danger">*</span></form:label></div>
<div class="col-md-8">
<div><img src="${event.imagepath }" style="width:150px"/> </div>
<form:input path="fileData" type="file" />
<div>Kindly upload images of 500 X 300 dimension</div>
</div>
</div>
<%
Event eventObj = (Event)request.getAttribute("event");
if((addpermission && eventObj.getEventId()==0) || editpermission ||
approvepermission) { %>
<div class="row form-group">
<div class="col-md-12">
<button type="submit" class="btn btn-primary" id="submitdetails"
value="Save">Save</button>

<button type="button" id="uploadCSV" class="btn btn-sm


btn-info"><i class="fa fa-angle-right"></i> Upload</button>

</div>
</div>

<% } %>
</form:form>

<portlet:resourceURL var="reportUrl" id="generateReport"/>


<portlet:resourceURL var="filterReportUrl" id="filterReport"/>
<portlet:resourceURL var="noEventReportUrl" id="noEventReport"/>

<!-- <div style="margin-left:50px;"> -->


<%-- <a class="btn btn-sm btn-primery" href="${reportUrl}"><strong>Download
List</strong></a> --%>
<%-- <a class="btn btn-sm btn-primery" href="${filterReportUrl}"><strong>List
Expirying in Next 7 days</strong></a> --%>
<!-- </div> -->

<%
List<Event> eventList =
(List<Event>)request.getAttribute("eventList");
if(eventList !=null){
%>
<h4>
<spring:message code="label.events" />
</h4>
<liferay-ui:search-container id="events"
emptyResultsMessage="no-events-found"
delta="<%=WebKeys.DEFAULT_DELTA%>">
<liferay-ui:search-container-results>
<%
results = ListUtil.subList(
eventList, searchContainer.getStart(), searchContainer.getEnd());
total = eventList.size();

pageContext.setAttribute("results", results);

pageContext.setAttribute("total", total);
%>
</liferay-ui:search-container-results>

<liferay-ui:search-container-row
className="com.intranet.event_mngt.model.Event"
modelVar="event" indexVar="count">

<liferay-ui:search-container-column-text>
<img src="<%=event.getImagepath() %>"
style="width: 75px;" >
</liferay-ui:search-container-column-text>

<liferay-ui:search-container-column-text
property="name">
</liferay-ui:search-container-column-
text>

<liferay-ui:search-container-column-text
name="Event Type">
<%= event.getEventType() %>
</liferay-ui:search-container-column-
text>

<liferay-ui:search-container-column-text
name="Start Date"
>
<%=
DateUtil.getFormattedDate(event.getEventStartDate()) %>
</liferay-ui:search-container-column-
text>

<liferay-ui:search-container-column-text
name="End Date"
>
<%=
DateUtil.getFormattedDate(event.getEventEndDate()) %>
</liferay-ui:search-container-column-
text>

<liferay-ui:search-container-column-text
name="Active"
property="active" />

<liferay-ui:search-container-column-text
name="Status" >
<%=
WebKeys.STATUS_APPROVAL.fromInt(event.getStatus())%>
</liferay-ui:search-container-column-
text>

<liferay-ui:search-container-column-text>

<% if(deletepermission) { %>


<%if(event.getActive()){ %>

<portlet:actionURL var="deleteeventURL">
<portlet:param name="action"
value="delete"></portlet:param>
<portlet:param name="eventId"
value="<%=String.valueOf(event.getEventId())%>"></portlet:param>
</portlet:actionURL>

<a class="btn btn-danger" href="<


%=deleteeventURL %>"><spring:message
code="label.delete" /></a>
<%} else {%>

<portlet:actionURL var="restoreeventURL">
<portlet:param name="action"
value="restore"></portlet:param>
<portlet:param name="eventId"
value="<%=String.valueOf(event.getEventId())%>"></portlet:param>
</portlet:actionURL>

<a class="btn btn-primary" href="<


%=restoreeventURL %>"><spring:message
code="label.restore" /></a>
<%} %>
<%} %>

<portlet:renderURL
var="editpersonalityURL">
<portlet:param name="action"
value=""></portlet:param>
<portlet:param name="id" value="<
%=String.valueOf(event.getEventId())%>"></portlet:param>
</portlet:renderURL>

<portlet:renderURL var="approveURL">
<portlet:param name="action"
value=""></portlet:param>
<portlet:param name="approve"
value="1"></portlet:param>
<portlet:param name="id" value="<
%=String.valueOf(event.getEventId())%>"></portlet:param>
</portlet:renderURL>

<% if(editpermission) { %>


<a class="btn btn-primary" href="<
%=editpersonalityURL%>">Edit</a>
<%} %>
<%if(event.getStatus() ==
WebKeys.STATUS_APPROVAL.REQUESTED.getValue() && approvepermission){
%>

<a class="btn btn-primary" href="<


%=approveURL%>">Approve</a>
<% }%>

</liferay-ui:search-container-column-text>

</liferay-ui:search-container-row>

<liferay-ui:search-iterator type="article" />


</liferay-ui:search-container>
<% } %>
</div>

<div class="modal fade" id="csvUpload" role="dialog"


style="display: none;">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<form action="<%=uploadEventActionURL%>" method="post"
id="holidayCSVForm" class="form-horizontal form-bordered" enctype="multipart/form-
data">
<div class="modal-header">
<button type="button" class="close" data-
dismiss="modal">&times;</button>
<h4 class="modal-title">Event CSV Upload</h4>
</div>
<div class="modal-body">
<div class="form-group">

</div>
<div class="form-group">
<label class="col-md-3 col-sm-3 control-label"
for="example-file-input">Event CSV</label>
<div class="col-md-6">
<input id="eventCSV" name="eventCSV"
type="file" accept=".csv">
<p class="help-block"><a href="$
{sampleUrl}">Sample Download</a></p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default"
>Upload</button>
<button type="button" class="btn btn-default" data-
dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
<script>

// window.onload = function() {
// document.getElementById('ifYes').style.display = 'none';
// }

function yesnoCheck() {
if (document.getElementById('noCheck').checked) {
document.getElementById('ifNo').style.display = 'block';
document.getElementById('ifNo').disabled=false;
}
else {
document.getElementById('ifNo').style.display = 'none';
}
}
function yesnoCheck2() {
if (document.getElementById('yesCheck').checked) {
document.getElementById('ifYes').style.display = 'block';
document.getElementById('ifNo').disabled=true;
// document.getElementById('ifNo').style.display = 'none';
}
else {
document.getElementById('ifNo').style.display = 'none';
}
}
$(function () {

$("input[name=status]:radio").change(function(){
if(this.value == <%=WebKeys.STATUS_APPROVAL.APPROVED.getValue()%>
&& this.checked){
$("#approveRemark").css("display","block");
$("#rejectRemark").css("display","none");
}
else if(this.value == <
%=WebKeys.STATUS_APPROVAL.REJECT.getValue()%> && this.checked){
$("#rejectRemark").css("display","block");
$("#approveRemark").css("display","none");
}
});

$('.input-datepicker, .input-daterange').datepicker({weekStart:
1}).on('changeDate', function(e){ $(this).datepicker('hide'); });
$("#eventForm").validate(
{ rules : {
name : {
required : true,
maxlength:40
},
description : {
required : true,
maxlength:2000
},
eventType : {
required : true
},
eventStartDate : {
required : true
},
eventEndDate : {
required : true
},
url : {
maxlength : 255,
required : true
},
approvalremarks:{
required : true
},
rejectionremarks:{
required : true
},
eventStartTime:{
required : true
},
target:{
required : true
},
fileData : {
<%
if(advertise.getImageId()==0){%>
required : true,
<%}%>
extension:
"<spring:message code='validate.file.ext'/>"
}
},
messages : {
name : {
required : "Please select
name",
maxlength :"Please enter name
of max length 40 characters",
},
description : {
required : "Please select
description"
},
eventType : {
required : "Please select
event type"
},
eventStartDate : {
required : "Please select
from date"
},
eventEndDate : {
required : "Please select to
date"
},
url : {
maxlength :"Please enter url
of max length 255 characters",
required : "Please enter
url",
},
approvalremarks:{
required : true
},
rejectionremarks:{
required : true
},
eventStartTime:{
required : "Please enter
StartTime"
},
target:{
required : "Please enter target"
},
fileData : {
<%
if(advertise.getImageId()==0){%>
required : "Please upload
image",
<%}%>
extension : "Please select
images of (.gif,.jpeg,.jpg,.png) extention"
}
}
});
$("#submitdetails").click(function() {
$("#eventForm").submit();
});

/* var id = $("#eventId").val();
var endDate = ${enddate};
if(id != null && endDate != null){

document.getElementById('ifNo').disabled=false;
document.getElementById('ifNo').style.display
= 'block';
} */

});

$("#uploadCSV").click(function(){
$("#csvUpload").modal('toggle');

});
jQuery( document ).ready(function() {
jQuery(".input-timepicker204").timepicker({
minuteStep: 1,
showSeconds: false,
showMeridian: false,
defaultTime: false

});
initZone();
initBranch();

});

if(jQuery('#target').val()==''){
jQuery('#zoneDiv').hide();
jQuery('#branchDiv').hide();
jQuery('#departmentDiv').hide();
}else if(jQuery('#target').val()=='1'){
jQuery('#zoneDiv').hide();
jQuery('#branchDiv').hide();
}else if(jQuery('#target').val()=='2'){
jQuery('#branchDiv').hide();
}

jQuery('#target').change(function(){
if(jQuery('#target').val()==''||jQuery('#target').val()=='1'){
jQuery('#zoneDiv').hide();
jQuery('#branchDiv').hide();

}else if(jQuery('#target').val()=='2'){
jQuery('#zoneDiv').show();
initZone();

}else if(jQuery('#target').val()=='3'){
jQuery('#zoneDiv').show();
jQuery('#branchDiv').show();
initZone();
initBranch();
}
else if(jQuery('#target').val()=='4'){
jQuery('#zoneDiv').hide();
jQuery('#branchDiv').hide();
jQuery('#departmentDiv').show();
}
});

function initZone(){
jQuery('#zoneIds').chosen('destroy');
jQuery("#zoneIds").chosen({no_results_text: "Oops, nothing found!"});
}
function initBranch(){
jQuery('#branchIds').chosen('destroy');
jQuery("#branchIds").chosen({no_results_text: "Oops, nothing found!"});
}
function initBranch(){
jQuery('#departmentIds').chosen('destroy');
jQuery("#departmentIds").chosen({no_results_text: "Oops, nothing
found!"});
}
jQuery('#zoneIds').change(function(){
if(jQuery('#target').val()=='3'){
jQuery('#branchIds').empty();
jQuery('#branchIds').chosen('destroy');
var ids = jQuery('#zoneIds').val();
jQuery.ajax({
url:"<%=branchChosenCallUrl.toString()%>&zoneId="+ids,
method: "POST",
dataType : "json",
async : true,
success: function(data){
$.each(data, function (key, item) {
$.each(item, function (index, obj) {
jQuery("#branchIds").append("<option
value='"+obj.id+"'>"+obj.text+"</option>");
})
})

initBranch();
}
});
}

});

</script>

También podría gustarte