I have a controller which filters for variables: Sales Rep, Month, Revenue. However, in the VF page, I want to show this table as a matrix which would have Sales Reps in rows, Months in column and goal in respective cell in the matrix.
Controller:
public List<RevMonthscol> getRevMonthscol()
{
Integer regnInt = (regn!=null) ? Integer.valueOf(regn) : -1;
List<RevMonthscol> accscol = new List<RevMonthscol>();
for (User_Stats__c a : [Select Sales_Rep__c, Month_Number__c,Year__c, Total_Rental_Revenue_Actual__c From User_Stats__c
where ((Month_Number__c = : today.month() AND Year__c = : string.valueof(today.year()))
OR (Month_Number__c = : monthPlus1.month() AND Year__c = : string.valueof(monthPlus1.year()))
OR (Month_Number__c = : monthPlus2.month() AND Year__c = : string.valueof(monthPlus2.year()))
OR (Month_Number__c = : monthMinus1.month() AND Year__c = : string.valueof(monthMinus1.year()))
OR (Month_Number__c = : monthMinus2.month() AND Year__c = : string.valueof(monthMinus2.year()))
OR (Month_Number__c = : monthMinus3.month() AND Year__c = : string.valueof(monthMinus3.year()))
OR (Month_Number__c = : monthMinus4.month() AND Year__c = : string.valueof(monthMinus4.year()))
OR (Month_Number__c = : monthMinus5.month() AND Year__c = : string.valueof(monthMinus5.year()))
OR (Month_Number__c = : monthMinus6.month() AND Year__c = : string.valueof(monthMinus6.year()))
OR (Month_Number__c = : monthMinus7.month() AND Year__c = : string.valueof(monthMinus7.year()))
OR (Month_Number__c = : monthMinus8.month() AND Year__c = : string.valueof(monthMinus8.year())))
and Region__c =: regnInt and District__c =: dist and Sales_Rep__c != null and Region__c != null and District__c != null
order by Sales_Rep__c asc, Year__c asc, Month_Number__c asc])
{
RevMonthscol opp = new RevMonthscol((String) string.valueof(a.get('Sales_Rep__c')),
(Integer) integer.valueof(a.get('Month_Number__c')),
(Double)a.get('Total_Rental_Revenue_Actual__c'));
accscol.add(opp);
}
return accscol;
}
public class RevMonthscol
{
public Integer month { get; set; }
public String monthString { get; set; }
public String OSRRep { get; set; }
public Double Revenue { get; set; }
public RevMonthscol(String rep, Integer mon, Double Reve)
{
month = integer.valueof(mon);
OSRRep = rep;
monthString = DateTime.newInstanceGMT(System.Date.newInstance(2000, month, 1), System.Time.newInstance(0, 0, 0, 0)).formatGMT('MMM');
Revenue = Reve;
}
}
How do I code this in VF page to make the Matrix table? Please help.