Skip to content

Instantly share code, notes, and snippets.

@victorabraham
Last active August 29, 2015 14:27
Show Gist options
  • Save victorabraham/54bcfc32d00076d14044 to your computer and use it in GitHub Desktop.
Save victorabraham/54bcfc32d00076d14044 to your computer and use it in GitHub Desktop.
Controller for showing Google chart in visualforce page
public class myAttendanceController {
public Id contactId;
public Integer attendedCount{get;set;}
public Integer partialCount{get;set;}
public Integer absentCount{get;set;}
public myAttendanceController(){
attendedCount = 0;
partialCount = 0;
absentCount = 0;
User loggedInUser = [Select Id,contactId FROM User WHERE ID=:userinfo.getUserId()];
contactId = loggedInUser.contactId;
List<AggregateResult> aggList =[Select Attendence_Status__c,Count(Id) FROM Attendance__c WHERE Enrollment__r.Student__c=:contactId GROUP BY Attendence_Status__c];
for(AggregateResult aggResult:aggList){
if(aggResult.get('Attendence_Status__c')=='Partially Attended'){
partialCount= (Integer)aggResult.get('expr0');
}else if(aggResult.get('Attendence_Status__c')=='Attended'){
attendedCount = (Integer)aggResult.get('expr0');
}else if(aggResult.get('Attendence_Status__c')=='Absent'){
absentCount= (Integer)aggResult.get('expr0');
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment