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.base.web;
017    
018    import org.kuali.hr.time.service.base.TkServiceLocator;
019    import org.kuali.hr.time.util.TKContext;
020    import org.kuali.hr.time.util.TKUser;
021    import org.kuali.rice.core.api.config.property.ConfigContext;
022    import org.kuali.rice.kns.web.struts.form.KualiForm;
023    
024    public class TkForm extends KualiForm {
025    
026            private static final long serialVersionUID = -3945893347262537122L;
027    
028            private String methodToCall;
029            private String principalId;
030        private String documentId;
031    
032            public String getMethodToCall() {
033                    return methodToCall;
034            }
035    
036            public void setMethodToCall(String methodToCall) {
037                    this.methodToCall = methodToCall;
038            }
039    
040            public TKUser getUser() {
041                    return TKContext.getUser();
042            }
043    
044            public String getPrincipalId() {
045                    return principalId;
046            }
047    
048            public void setPrincipalId(String principalId) {
049                    this.principalId = principalId;
050            }
051            
052        public String getDocumentId() {
053            return documentId;
054        }
055    
056        public void setDocumentId(String documentId) {
057            this.documentId = documentId;
058        }
059            
060            public String getWorkflowUrl(){
061                    return ConfigContext.getCurrentContextConfig().getProperty("workflow.url");
062            }
063            
064            public String getDocumentIdFromContext(){
065                    return TKContext.getCurrentTimesheetDocumentId();
066            }
067    
068        public String getDocumentStatus() {
069            return TKContext.getCurrentTimesheetDocument().getDocumentHeader().getDocumentStatus();
070        }
071    
072        public String getLeaveCalendarDocumentStatus() {
073            return TKContext.getCurrentLeaveCalendarDocument().getDocumentHeader().getDocumentStatus();
074        }
075        
076        public boolean getLeaveEnabled() {
077            boolean canViewLeaveTab= false;
078            canViewLeaveTab = this.getViewLeaveTabsWithNEStatus() || TkServiceLocator.getPermissionsService().canViewLeaveTabsWithEStatus();
079            return canViewLeaveTab; 
080        }
081        
082        public boolean getTimeEnabled() {
083            return TkServiceLocator.getPermissionsService().canViewTimeTabs();
084        }
085        
086        public String getLeaveDocumentIdFromContext(){
087                    return TKContext.getCurrentLeaveCalendarDocumentId();
088            }
089     
090        public boolean getViewLeaveTabsWithNEStatus() {
091            return TkServiceLocator.getPermissionsService().canViewLeaveTabsWithNEStatus();
092        }
093    }