Last active
August 29, 2015 14:27
-
-
Save victorabraham/54bcfc32d00076d14044 to your computer and use it in GitHub Desktop.
Controller for showing Google chart in visualforce page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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