Author: adrianc
Date: Tue Aug 4 23:40:00 2009
New Revision: 801024
URL:
http://svn.apache.org/viewvc?rev=801024&view=revLog:
Fixed a bug in the Month view work effort calendar.
Modified:
ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy
Modified: ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy?rev=801024&r1=801023&r2=801024&view=diff==============================================================================
--- ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy (original)
+++ ofbiz/trunk/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy Tue Aug 4 23:40:00 2009
@@ -51,24 +51,30 @@
context.prevMillis = new Long(prev.getTime()).toString();
next = UtilDateTime.getDayStart(start, numDays+1, timeZone, locale);
context.nextMillis = new Long(next.getTime()).toString();
-end = UtilDateTime.getDayStart(start, numDays, timeZone, locale);
+end = UtilDateTime.getMonthEnd(start, timeZone, locale);
//Find out what date to get from
getFrom = null;
prevMonthDays = tempCal.get(Calendar.DAY_OF_WEEK) - tempCal.getFirstDayOfWeek();
-if (prevMonthDays < 0) prevMonthDays = 7 + prevMonthDays;
-tempCal.add(Calendar.DATE,-(prevMonthDays));
+if (prevMonthDays < 0) prevMonthDays += 7;
+tempCal.add(Calendar.DATE, -prevMonthDays);
numDays += prevMonthDays;
getFrom = new Timestamp(tempCal.getTimeInMillis());
firstWeekNum = tempCal.get(Calendar.WEEK_OF_YEAR);
context.put("firstWeekNum", new Integer(firstWeekNum));
// also get days until the end of the week at the end of the month
-lastWeekCal = UtilDateTime.toCalendar(UtilDateTime.addDaysToTimestamp(start, numDays - prevMonthDays), timeZone, locale);
-followingMonthDays = 7 + lastWeekCal.getFirstDayOfWeek() - lastWeekCal.get(Calendar.DAY_OF_WEEK);
-if (followingMonthDays < 7) numDays += followingMonthDays;
+lastWeekCal = UtilDateTime.toCalendar(end, timeZone, locale);
+monthEndDay = lastWeekCal.get(Calendar.DAY_OF_WEEK);
+getTo = UtilDateTime.getWeekEnd(end, timeZone, locale);
+lastWeekCal = UtilDateTime.toCalendar(getTo, timeZone, locale);
+followingMonthDays = lastWeekCal.get(Calendar.DAY_OF_WEEK) - monthEndDay;
+if (followingMonthDays < 0) {
+ followingMonthDays += 7;
+}
+numDays += followingMonthDays;
-serviceCtx = UtilMisc.toMap("userLogin", userLogin, "start", getFrom,"numPeriods", new Integer(numDays), "periodType", new Integer(Calendar.DATE));
+serviceCtx = UtilMisc.toMap("userLogin", userLogin, "start", getFrom, "numPeriods", new Integer(numDays), "periodType", new Integer(Calendar.DATE));
serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "locale", locale, "timeZone", timeZone));
if (entityExprList) {
serviceCtx.putAll(["entityExprList" : entityExprList]);