function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SamarSSamarS 

How can I approach to develop a custom app for employee time tracking and their utilization in projects?

I have an internal requirement where I want a weekly time sheet submission from employees, where their whole week's activity has to be tracked along with activity duration and in-time/out-time. How should I approach for it?
Best Answer chosen by SamarS
pconpcon
The code below should help you with that

aPage.vfp
<apex:page controller="aController" >
    <apex:form id="vf-page" >
        <apex:sectionHeader title="Dates" />
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:outputLabel value="Start" />
                <apex:outputText value="{!startDate}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection >
                <apex:outputLabel value="Today" />
                <apex:outputText value="{!todayDate}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection >
                <apex:outputLabel value="End" />
                <apex:outputText value="{!endDate}" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

aController.cls
public class aController {
    public Date todayDate {
        get;
        set;
    }
    
    public Date startDate {
        get;
        set;
    }
    
    public Date endDate {
        get;
        set;
    }
    
    public aController() {
        this.todayDate = Date.today();
        
        // toStartOfWeek assumes a start day of Sunday
        // adding 1 day to get to Monday
        this.startDate = this.todayDate.toStartOfWeek().addDays(1);
        
        // Work week is 5 days long but we only have to add 4
        this.endDate = this.startDate.addDays(4);
    }
}

Output
User-added image

All Answers

pconpcon
You can create these as custom objects and track it that way.  You probably could reuse the standard Activity object but I'm not certain it has everything you need / want and I don't know if you can link it to a custom object such as your "timesheet" object.
SamarSSamarS
Thanks for you comment pcon, I have created 3 objects and implemented it with the help of VF page and apex controller.

The thing I am pending is that on page load I want the start week date and end week date should be pre populated with current week dates i.e. from Monday and Friday.

Ex - if today is 9 Dec then Start week shud be - 7 th Dec and end week date shud be - 11 Dec.

Any idea how to do that.

thanks,
Samar
pconpcon
The code below should help you with that

aPage.vfp
<apex:page controller="aController" >
    <apex:form id="vf-page" >
        <apex:sectionHeader title="Dates" />
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:outputLabel value="Start" />
                <apex:outputText value="{!startDate}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection >
                <apex:outputLabel value="Today" />
                <apex:outputText value="{!todayDate}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection >
                <apex:outputLabel value="End" />
                <apex:outputText value="{!endDate}" />
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

aController.cls
public class aController {
    public Date todayDate {
        get;
        set;
    }
    
    public Date startDate {
        get;
        set;
    }
    
    public Date endDate {
        get;
        set;
    }
    
    public aController() {
        this.todayDate = Date.today();
        
        // toStartOfWeek assumes a start day of Sunday
        // adding 1 day to get to Monday
        this.startDate = this.todayDate.toStartOfWeek().addDays(1);
        
        // Work week is 5 days long but we only have to add 4
        this.endDate = this.startDate.addDays(4);
    }
}

Output
User-added image
This was selected as the best answer
SamarSSamarS
Thanks pcon, it worked as I want.
SamarSSamarS
Pcon,

How can I show a roll up summary field created on Master object in VF page - showing the total working hours in a week. I added it in VF page but it is not displaying anything. However, on backend value is getting saved correctly.

thanks,
Samar
pconpcon
You should just be able to inclued the field name as part of the Visualforce page
 
<apex:outputField value="{!Object__c.RollupField__c}" />

This will only work for records that have already been saved and that you are getting from the DB