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.lm.balancetransfer.BalanceTransfer;
020    import org.kuali.hr.time.calendar.TkCalendar;
021    import org.kuali.hr.time.service.base.TkServiceLocator;
022    import org.kuali.hr.time.timeblock.TimeBlock;
023    import org.kuali.hr.time.timesummary.TimeSummary;
024    import org.kuali.hr.time.util.TKUtils;
025    import org.kuali.hr.time.util.TkConstants;
026    
027    import java.text.SimpleDateFormat;
028    import java.util.*;
029    
030    public class TimeDetailActionForm extends TimeDetailActionFormBase {
031    
032        private static SimpleDateFormat SDF_NO_TZ = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
033    
034        /**
035         *
036         */
037        private static final long serialVersionUID = 5277197287612035236L;
038    
039    
040            private TimeBlock timeBlock;
041            private String clockAction;
042            private String serverTimezone;
043            private String userTimezone;
044            private TimeSummary timeSummary;
045            private Map<String, String> assignStyleClassMap = new HashMap<String, String>();
046        private String timeBlockString;
047        private String leaveBlockString;
048        private TkCalendar calendar;
049        private String docEditable;
050        private String workingOnItsOwn;     // true if the user is working on its own timesheet
051        private List<String> overtimeEarnCodes = new ArrayList<String>();
052        private String tkTimeHourDetailId;
053        private String isLunchDeleted;
054        private boolean canAddTimeblock;
055    
056        public TkCalendar getTkCalendar() {
057            return calendar;
058        }
059    
060        public void setTkCalendar(TkCalendar calendar) {
061            this.calendar = calendar;
062        }
063    
064            public List<TimeBlock> getTimeBlockList() {
065                    return this.getTimesheetDocument().getTimeBlocks();
066            }
067            
068            // for Actual Time Inquiry display only
069            public List<TimeBlock> getClockLogTimeBlockList() {
070                    List<TimeBlock> clockList = new ArrayList<TimeBlock>();
071                    for(TimeBlock tb : this.getTimeBlockList()){
072                            if(tb.getClockLogCreated()) {
073                                    clockList.add(tb);
074                            }
075                    }
076                    return clockList;
077            }
078    
079            public TimeBlock getTimeBlock() {
080                    return timeBlock;
081            }
082    
083            public void setTimeBlock(TimeBlock timeBlock) {
084                    this.timeBlock = timeBlock;
085            }
086    
087            public String getClockAction() {
088                    return clockAction;
089            }
090    
091            public void setClockAction(String clockAction) {
092                    this.clockAction = clockAction;
093            }
094    
095            public String getIsVirtualWorkDay() {
096                    Calendar cal = Calendar.getInstance();
097                    cal.setTime(getBeginPeriodDateTime());
098                    return Boolean.toString(TKUtils.isVirtualWorkDay(cal));
099            }
100    
101            public TimeSummary getTimeSummary() {
102                    return timeSummary;
103            }
104    
105            public void setTimeSummary(TimeSummary timeSummary) {
106                    this.timeSummary = timeSummary;
107            }
108    
109            public String getServerTimezone() {
110                    return TKUtils.getSystemTimeZone();
111            }
112    
113            public String getUserTimezone() {
114                    return TkServiceLocator.getTimezoneService().getUserTimezone();
115            }
116    
117            public Map<String, String> getAssignStyleClassMap() {
118                    return assignStyleClassMap;
119            }
120    
121            public void setAssignStyleClassMap(Map<String, String> assignStyleClassMap) {
122                    this.assignStyleClassMap = assignStyleClassMap;
123            }
124    
125        public String getTimeBlockString() {
126            return timeBlockString;
127        }
128    
129        public void setTimeBlockString(String timeBlockString) {
130            this.timeBlockString = timeBlockString;
131        }
132    
133        public String getBeginPeriodDTNoTZ() {
134            return SDF_NO_TZ.format(this.getBeginPeriodDateTime());
135        }
136    
137        public String getEndPeriodDTNoTZ() {
138            return SDF_NO_TZ.format(this.getEndPeriodDateTime());
139        }
140    
141            public String getDocEditable() {
142                    if(StringUtils.isEmpty(docEditable)) {
143                            docEditable="false";
144                    }
145                    return docEditable;
146            }
147    
148            public void setDocEditable(String docEditable) {
149                    this.docEditable = docEditable;
150            }
151    
152            public List<String> getOvertimeEarnCodes() {
153                    return overtimeEarnCodes;
154            }
155    
156            public void setOvertimeEarnCodes(List<String> overtimeEarnCodes) {
157                    this.overtimeEarnCodes = overtimeEarnCodes;
158            }
159    
160        public String getTkTimeHourDetailId() {
161            return tkTimeHourDetailId;
162        }
163    
164        public void setTkTimeHourDetailId(String tkTimeHourDetailId) {
165            this.tkTimeHourDetailId = tkTimeHourDetailId;
166        }
167    
168        public String getLunchDeleted() {
169            return isLunchDeleted;
170        }
171    
172        public void setLunchDeleted(String lunchDeleted) {
173            isLunchDeleted = lunchDeleted;
174        }
175    
176        public boolean isCanAddTimeblock() {
177            return TkServiceLocator.getPermissionsService().canAddTimeBlock();
178        }
179    
180            public String getWorkingOnItsOwn() {
181                    if(StringUtils.isEmpty(workingOnItsOwn)) {
182                            workingOnItsOwn="false";
183                    }
184                    return workingOnItsOwn;
185            }
186    
187            public void setWorkingOnItsOwn(String workingOnItsOwn) {
188                    this.workingOnItsOwn = workingOnItsOwn;
189            }
190    
191            public String getLeaveBlockString() {
192                    return leaveBlockString;
193            }
194    
195            public void setLeaveBlockString(String leaveBlockString) {
196                    this.leaveBlockString = leaveBlockString;
197            }
198    
199    }