You need to sign in to do that
Don't have an account?
Generate the Report using Visualforce page
Hi friends,
how can i calculate the total hours for each user, for each month and display in the visulaforce page on the respective columns(like jan,feb...dec).
as of now i am just getting the one month results in the page, i need to display all the months results in the same visualforce page.
First i need to get all the owners of the records and display in the first column. one owner is not having any records in any months needs to display 0.
Like this i need to get all the months records and display in the page.
My controller
=====================
public class TAC_Effort_reportController{
public decimal grand{get;set;}
public decimal June_grand{get;set;}
public MayEffort[] MayEfforts { get; set; }
public June_Effort[] June_Efforts { get; set; }
public TAC_Effort_reportController(){
//Effort= [select name,Owner.name, Business_Days__c,Hours__c,Minutes__c,Total_in_Hours__c from Effort__C Order By Owner.name];
grand = 0.0;
June_grand=0;
AggregateResult[] results = [SELECT owner.Name o, Sum(Total_in_Hours__c) Hrs,MAX(Business_Days__c) bd FROM Effort__C where Month_Of_Start_Day__c='5' GROUP BY Owner.Name ];
// AggregateResult[] results_all = [SELECT owner.Name o, Sum(Total_in_Hours__c) Hrs, MAX(Business_Days__c), Sum(Total_in_Hours__c)/(MAX(Business_Days__c)*8) aggre FROM Effort__C GROUP BY Owner.Name, Month_Of_Start_Day__c];
AggregateResult[] Jan_Results = [SELECT owner.Name o, Sum(Total_in_Hours__c) Hrs,MAX(Business_Days__c) bd FROM Effort__C where Month_Of_Start_Day__c='1' GROUP BY Owner.Name ];
MayEfforts = new List<MayEffort>();
for (AggregateResult ar : results) {
Grand +=(Decimal) ar.get('Hrs') ;
MayEfforts.add(new MayEffort(ar));
}
for (AggregateResult ar : Jan_Results) {
June_grand +=(Decimal) ar.get('Hrs') ;
June_Efforts.add(new June_Effort(ar));
}
}
// wrapper class to hold aggregate data
public class MayEffort {
public Decimal TotalHours { get; private set; }
public String OwnerName { get; private set; }
public String totalPercent{get;private set;}
public MayEffort(AggregateResult ar) {
TotalHours = (Decimal) ar.get('Hrs');
totalPercent =((TotalHours/(1*8))*100)+'%';
OwnerName = (String) ar.get('o');
}
}
}
====================
VF Page
=====================
<apex:page sidebar="false" controller="TAC_Effort_reportController" showHeader="false" >
<apex:form >
<apex:pageBlock >
<apex:pageblocktable value="{!MayEfforts}" var="e">
<apex:column headerValue="OwnerName#" style="text-align:center; width:5%" value="{!e.OwnerName}" breakBefore="true" styleClass="colborder"/>
<apex:column headerValue="TotalHours(Hrs & Percent)" style="text-align:center; width:10%" styleClass="colborder" colspan="3" >
<apex:outputtext value="{!e.TotalHours }"/>
<apex:column headerValue="Hourse&Minutes" style="text-align:center; width:10%" styleClass="colborder">
<b><apex:outputField value="{!e.Hours__c}"/> <br/>
<apex:outputField value="{!e.Minutes__c}"/> <br/></b>
</apex:column>
<B>Grand Total:</b>
<apex:outputtext value="{!grand}"/>
</apex:pageblocktable>
</apex:pageBlock>
</apex:form>
</apex:page>
please help me on this.
Thanks in advance..
balu...