001 /**
002 * Copyright 2004-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.hr.time.detail.web;
017
018 import org.apache.commons.lang.StringUtils;
019 import org.kuali.hr.time.calendar.TkCalendar;
020 import org.kuali.hr.time.service.base.TkServiceLocator;
021 import org.kuali.hr.time.timeblock.TimeBlock;
022 import org.kuali.hr.time.timesummary.TimeSummary;
023 import org.kuali.hr.time.util.TKUtils;
024 import org.kuali.hr.time.util.TkConstants;
025
026 import java.text.SimpleDateFormat;
027 import java.util.*;
028
029 public class TimeDetailActionForm extends TimeDetailActionFormBase {
030
031 private static SimpleDateFormat SDF_NO_TZ = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
032
033 /**
034 *
035 */
036 private static final long serialVersionUID = 5277197287612035236L;
037
038
039 private TimeBlock timeBlock;
040 private String clockAction;
041 private String serverTimezone;
042 private String userTimezone;
043 private TimeSummary timeSummary;
044 private Map<String, String> assignStyleClassMap = new HashMap<String, String>();
045 private String timeBlockString;
046 private TkCalendar calendar;
047 private String docEditable;
048 private String workingOnItsOwn; // true if the user is working on its own timesheet
049 private List<String> overtimeEarnCodes = new ArrayList<String>();
050 private String tkTimeHourDetailId;
051 private String isLunchDeleted;
052 private boolean canAddTimeblock;
053 private String spanningWeeks; // KPME-1446
054
055 public String getSpanningWeeks() {
056 return spanningWeeks;
057 }
058
059 public void setSpanningWeeks(String spanningWeeks) {
060 this.spanningWeeks = spanningWeeks;
061 }
062
063
064 public TkCalendar getTkCalendar() {
065 return calendar;
066 }
067
068 public void setTkCalendar(TkCalendar calendar) {
069 this.calendar = calendar;
070 }
071
072 public List<TimeBlock> getTimeBlockList() {
073 return this.getTimesheetDocument().getTimeBlocks();
074 }
075
076 // for Actual Time Inquiry display only
077 public List<TimeBlock> getClockLogTimeBlockList() {
078 List<TimeBlock> clockList = new ArrayList<TimeBlock>();
079 for(TimeBlock tb : this.getTimeBlockList()){
080 if(tb.getClockLogCreated()) {
081 clockList.add(tb);
082 }
083 }
084 return clockList;
085 }
086
087 public TimeBlock getTimeBlock() {
088 return timeBlock;
089 }
090
091 public void setTimeBlock(TimeBlock timeBlock) {
092 this.timeBlock = timeBlock;
093 }
094
095 public String getClockAction() {
096 return clockAction;
097 }
098
099 public void setClockAction(String clockAction) {
100 this.clockAction = clockAction;
101 }
102
103 public String getIsVirtualWorkDay() {
104 Calendar cal = Calendar.getInstance();
105 cal.setTime(getBeginPeriodDateTime());
106 return Boolean.toString(TKUtils.isVirtualWorkDay(cal));
107 }
108
109 public TimeSummary getTimeSummary() {
110 return timeSummary;
111 }
112
113 public void setTimeSummary(TimeSummary timeSummary) {
114 this.timeSummary = timeSummary;
115 }
116
117 public String getServerTimezone() {
118 return TKUtils.getSystemTimeZone();
119 }
120
121 public String getUserTimezone() {
122 return TkServiceLocator.getTimezoneService().getUserTimezone();
123 }
124
125 public Map<String, String> getAssignStyleClassMap() {
126 return assignStyleClassMap;
127 }
128
129 public void setAssignStyleClassMap(Map<String, String> assignStyleClassMap) {
130 this.assignStyleClassMap = assignStyleClassMap;
131 }
132
133 public String getTimeBlockString() {
134 return timeBlockString;
135 }
136
137 public void setTimeBlockString(String timeBlockString) {
138 this.timeBlockString = timeBlockString;
139 }
140
141 public String getBeginPeriodDTNoTZ() {
142 return SDF_NO_TZ.format(this.getBeginPeriodDateTime());
143 }
144
145 public String getEndPeriodDTNoTZ() {
146 return SDF_NO_TZ.format(this.getEndPeriodDateTime());
147 }
148
149 public String getDocEditable() {
150 if(StringUtils.isEmpty(docEditable)) {
151 docEditable="false";
152 }
153 return docEditable;
154 }
155
156 public void setDocEditable(String docEditable) {
157 this.docEditable = docEditable;
158 }
159
160 public List<String> getOvertimeEarnCodes() {
161 return overtimeEarnCodes;
162 }
163
164 public void setOvertimeEarnCodes(List<String> overtimeEarnCodes) {
165 this.overtimeEarnCodes = overtimeEarnCodes;
166 }
167
168 public String getTkTimeHourDetailId() {
169 return tkTimeHourDetailId;
170 }
171
172 public void setTkTimeHourDetailId(String tkTimeHourDetailId) {
173 this.tkTimeHourDetailId = tkTimeHourDetailId;
174 }
175
176 public String getLunchDeleted() {
177 return isLunchDeleted;
178 }
179
180 public void setLunchDeleted(String lunchDeleted) {
181 isLunchDeleted = lunchDeleted;
182 }
183
184 public boolean isCanAddTimeblock() {
185 return TkServiceLocator.getPermissionsService().canAddTimeBlock();
186 }
187
188 public String getWorkingOnItsOwn() {
189 if(StringUtils.isEmpty(workingOnItsOwn)) {
190 workingOnItsOwn="false";
191 }
192 return workingOnItsOwn;
193 }
194
195 public void setWorkingOnItsOwn(String workingOnItsOwn) {
196 this.workingOnItsOwn = workingOnItsOwn;
197 }
198 }