View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.hr.time.detail.web;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.joda.time.DateTime;
20  import org.joda.time.format.DateTimeFormat;
21  import org.joda.time.format.DateTimeFormatter;
22  import org.kuali.hr.lm.balancetransfer.BalanceTransfer;
23  import org.kuali.hr.time.calendar.TkCalendar;
24  import org.kuali.hr.time.service.base.TkServiceLocator;
25  import org.kuali.hr.time.timeblock.TimeBlock;
26  import org.kuali.hr.time.timesummary.TimeSummary;
27  import org.kuali.hr.time.util.TKUtils;
28  import org.kuali.hr.time.util.TkConstants;
29  
30  import java.text.SimpleDateFormat;
31  import java.util.*;
32  
33  public class TimeDetailActionForm extends TimeDetailActionFormBase {
34  
35      private static DateTimeFormatter SDF_NO_TZ = DateTimeFormat.forPattern("EEE MMM d HH:mm:ss yyyy");
36  
37      /**
38       *
39       */
40      private static final long serialVersionUID = 5277197287612035236L;
41  
42  
43  	private TimeBlock timeBlock;
44  	private String clockAction;
45  	private String serverTimezone;
46  	private String userTimezone;
47  	private TimeSummary timeSummary;
48  	private Map<String, String> assignStyleClassMap = new HashMap<String, String>();
49      private String timeBlockString;
50      private String leaveBlockString;
51      private TkCalendar calendar;
52      private String docEditable;
53      private String workingOnItsOwn;	// true if the user is working on its own timesheet
54      private List<String> overtimeEarnCodes = new ArrayList<String>();
55      private String tkTimeHourDetailId;
56      private String isLunchDeleted;
57      private boolean canAddTimeblock;
58  
59      public TkCalendar getTkCalendar() {
60          return calendar;
61      }
62  
63      public void setTkCalendar(TkCalendar calendar) {
64          this.calendar = calendar;
65      }
66  
67  	public List<TimeBlock> getTimeBlockList() {
68  		return this.getTimesheetDocument().getTimeBlocks();
69  	}
70  	
71  	// for Actual Time Inquiry display only
72  	public List<TimeBlock> getClockLogTimeBlockList() {
73  		List<TimeBlock> clockList = new ArrayList<TimeBlock>();
74  		for(TimeBlock tb : this.getTimeBlockList()){
75  			if(tb.getClockLogCreated()) {
76  				clockList.add(tb);
77  			}
78  		}
79  		return clockList;
80  	}
81  
82  	public TimeBlock getTimeBlock() {
83  		return timeBlock;
84  	}
85  
86  	public void setTimeBlock(TimeBlock timeBlock) {
87  		this.timeBlock = timeBlock;
88  	}
89  
90  	public String getClockAction() {
91  		return clockAction;
92  	}
93  
94  	public void setClockAction(String clockAction) {
95  		this.clockAction = clockAction;
96  	}
97  
98  	public String getIsVirtualWorkDay() {
99  		Calendar cal = Calendar.getInstance();
100 		cal.setTime(getBeginPeriodDateTime());
101 		return Boolean.toString(TKUtils.isVirtualWorkDay(cal));
102 	}
103 
104 	public TimeSummary getTimeSummary() {
105 		return timeSummary;
106 	}
107 
108 	public void setTimeSummary(TimeSummary timeSummary) {
109 		this.timeSummary = timeSummary;
110 	}
111 
112 	public String getServerTimezone() {
113 		return TKUtils.getSystemTimeZone();
114 	}
115 
116 	public String getUserTimezone() {
117 		return TkServiceLocator.getTimezoneService().getUserTimezone();
118 	}
119 
120 	public Map<String, String> getAssignStyleClassMap() {
121 		return assignStyleClassMap;
122 	}
123 
124 	public void setAssignStyleClassMap(Map<String, String> assignStyleClassMap) {
125 		this.assignStyleClassMap = assignStyleClassMap;
126 	}
127 
128     public String getTimeBlockString() {
129         return timeBlockString;
130     }
131 
132     public void setTimeBlockString(String timeBlockString) {
133         this.timeBlockString = timeBlockString;
134     }
135 
136     public String getBeginPeriodDTNoTZ() {
137         return SDF_NO_TZ.print(new DateTime(this.getBeginPeriodDateTime()));
138     }
139 
140     public String getEndPeriodDTNoTZ() {
141         return SDF_NO_TZ.print(new DateTime(this.getEndPeriodDateTime()));
142     }
143     
144 
145     public boolean isCurrentTimesheet() {
146     	return (TKUtils.getCurrentDate().compareTo(this.getBeginPeriodDateTime()) >= 0 && TKUtils.getCurrentDate().compareTo(this.getEndPeriodDateTime()) < 0 );
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 
199 	public String getLeaveBlockString() {
200 		return leaveBlockString;
201 	}
202 
203 	public void setLeaveBlockString(String leaveBlockString) {
204 		this.leaveBlockString = leaveBlockString;
205 	}
206 
207 }