
META-INF.resources.organization.services.jsp Maven / Gradle / Ivy
<%--
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
--%>
<%@ include file="/init.jsp" %>
<%
long organizationId = ParamUtil.getLong(request, "organizationId");
Organization organization = OrganizationServiceUtil.fetchOrganization(organizationId);
List orgLabors = Collections.emptyList();
int[] orgLaborsIndexes = null;
String orgLaborsIndexesParam = ParamUtil.getString(request, "orgLaborsIndexes");
if (Validator.isNotNull(orgLaborsIndexesParam)) {
orgLabors = new ArrayList();
orgLaborsIndexes = StringUtil.split(orgLaborsIndexesParam, 0);
for (int orgLaborsIndex : orgLaborsIndexes) {
OrgLabor orgLabor = new OrgLaborImpl();
orgLabor.setSunOpen(-1);
orgLabor.setSunClose(-1);
orgLabor.setMonOpen(-1);
orgLabor.setMonClose(-1);
orgLabor.setTueOpen(-1);
orgLabor.setTueClose(-1);
orgLabor.setWedOpen(-1);
orgLabor.setWedClose(-1);
orgLabor.setThuOpen(-1);
orgLabor.setThuClose(-1);
orgLabor.setFriOpen(-1);
orgLabor.setFriClose(-1);
orgLabor.setSatOpen(-1);
orgLabor.setSatClose(-1);
orgLabors.add(orgLabor);
}
}
else {
if (organizationId > 0) {
orgLabors = OrgLaborServiceUtil.getOrgLabors(organizationId);
orgLaborsIndexes = new int[orgLabors.size()];
for (int i = 0; i < orgLabors.size(); i++) {
orgLaborsIndexes[i] = i;
}
}
if (orgLabors.isEmpty()) {
orgLabors = new ArrayList();
OrgLabor orgLabor = new OrgLaborImpl();
orgLabor.setSunOpen(-1);
orgLabor.setSunClose(-1);
orgLabor.setMonOpen(-1);
orgLabor.setMonClose(-1);
orgLabor.setTueOpen(-1);
orgLabor.setTueClose(-1);
orgLabor.setWedOpen(-1);
orgLabor.setWedClose(-1);
orgLabor.setThuOpen(-1);
orgLabor.setThuClose(-1);
orgLabor.setFriOpen(-1);
orgLabor.setFriClose(-1);
orgLabor.setSatOpen(-1);
orgLabor.setSatClose(-1);
orgLabors.add(orgLabor);
orgLaborsIndexes = new int[] {0};
}
if (orgLaborsIndexes == null) {
orgLaborsIndexes = new int[0];
}
}
Format timeFormat = FastDateFormatFactoryUtil.getSimpleDateFormat("HH:mm", locale);
%>
<%
Calendar cal = CalendarFactoryUtil.getCalendar();
String[] days = CalendarUtil.getDays(locale);
String[] paramPrefixes = {"sun", "mon", "tue", "wed", "thu", "fri", "sat"};
for (int i = 0; i < orgLaborsIndexes.length; i++) {
int orgLaborsIndex = orgLaborsIndexes[i];
OrgLabor orgLabor = orgLabors.get(i);
int[] openArray = new int[paramPrefixes.length];
for (int j = 0; j < paramPrefixes.length; j++) {
openArray[j] = ParamUtil.getInteger(request, paramPrefixes[j] + "Open" + orgLaborsIndex, BeanPropertiesUtil.getInteger(orgLabor, paramPrefixes[j] + "Open", -1));
}
int[] closeArray = new int[paramPrefixes.length];
for (int j = 0; j < paramPrefixes.length; j++) {
closeArray[j] = ParamUtil.getInteger(request, paramPrefixes[j] + "Close" + orgLaborsIndex, BeanPropertiesUtil.getInteger(orgLabor, paramPrefixes[j] + "Close", -1));
}
%>
<%
for (int j = 0; j < days.length; j++) {
int close = closeArray[j];
String day = days[j];
int open = openArray[j];
String paramPrefix = paramPrefixes[j];
%>
<%= day %>
<%
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
int today = cal.get(Calendar.DATE);
while (cal.get(Calendar.DATE) == today) {
String timeOfDayDisplay = timeFormat.format(cal.getTime());
int timeOfDayValue = GetterUtil.getInteger(StringUtil.replace(timeOfDayDisplay, CharPool.COLON, StringPool.BLANK));
cal.add(Calendar.MINUTE, 30);
%>
<%
}
%>
<%
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
int today = cal.get(Calendar.DATE);
while (cal.get(Calendar.DATE) == today) {
String timeOfDayDisplay = timeFormat.format(cal.getTime());
int timeOfDayValue = GetterUtil.getInteger(StringUtil.replace(timeOfDayDisplay, CharPool.COLON, StringPool.BLANK));
cal.add(Calendar.MINUTE, 30);
%>
<%
}
%>
<%
}
%>
<%
}
%>
new Liferay.AutoFields(
{
contentBox: '# services',
fieldIndexes: ' orgLaborsIndexes',
namespace: ' '
}
).render();
© 2015 - 2025 Weber Informatics LLC | Privacy Policy