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
Joseph BaroneJoseph Barone 

Customize Wrapper Class output with VF

Hello,

I've created a wrapper class that handles the specific data that I need.  When I output to VF, the data renders properly but now I'm trying to customize the output and am having issues.  

Here is what I currently have:
Current Output

What I'm looking for is to create a table for each change in TimeKeeper such that the header and the footer appears for each timekeeper.  

Below is both my Apex and VisualForce code.  Thank you in advanced for any help you may be able to provide.
 
<apex:page controller="StaffingController" cache="True" readonly="true" >
    <apex:pageMessages />
    
    <apex:variable value="{!0.00}" var="billable"/> <apex:variable value="{!0.00}" var="non"/>
    <apex:pageblock >
          
              
     <apex:pageBlockTable title="Test" value="{!result}" var="p">
         <!--     <apex:repeat value="{!result}" var="p">
              
          <apex:pageBlockTable value="{!p.timew}" var="q"> -->
              <apex:column headerValue="Employee" width="20"> <apex:outputField value="{!p.timew.Timekeeper__c}"/>
              </apex:column>
              <apex:column headerValue="Client" width="100"><apex:outputField value="{!p.timew.Client__c}"/>
              
         </apex:column>
              <apex:column headerValue="Matter" width="400"><apex:outputField value="{!p.timew.mcodes__c}"/> 
                  <apex:facet name="footer">SubTotal Billable: <span class="t1" /> <br/> SubTotal Non-Billable: <span class="t2" /></apex:facet>   
         </apex:column>
        
              <apex:column headerValue="Week1" >
              <apex:outputText value="{!p.P}" />
                  <apex:variable var="Billable" value="{!p.BillTime}" />      
         
         </apex:column>
              <apex:column headerValue="Week2" >
              <apex:outputText value="{!p.P}" /> 
                  <apex:variable var="non" value="{!p.NonBill}" />
              </apex:column>
              <apex:column headerValue="Week3" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week4" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week5" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week6" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week7" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week8" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week9" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week10" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week11" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
              <apex:column headerValue="Week12" >
              <apex:outputText value="{!p.P}" /> 
              </apex:column>
               
      <!--   </apex:pageBlockTable> -->
          
        
         
         
              
              </apex:pageBlockTable>
        </apex:pageblock>
<script>
    document.getElementsByClassName('t1')[0].innerHTML = '{!Billable}';
    document.getElementsByClassName('t2')[0].innerHTML = '{!non}';
    
    </script>
</apex:page>
 
public class StaffingController {

    Public List<User> Professionals {get;set;}
    Public List<Time_Entry__c> timeE {get;set;}

    Public User[] getUsers()
    {
        system.debug('getUsers');
        return [select id, Name, Alias FROM User WHERE UserRole.Name = 'Professional' AND IsActive = True];
    }
 	
   
    Public list <Staffing> result {get;set;}
        
         
    Public StaffingController()
    {                
        Integer ProfCount = 1;
        system.debug ('in wrapper');
        result = new Staffing[]{};
        List <client__c> nonbillable1 = [select ID from Client__c Where Name='CMD' AND InActive__c=False LIMIT 1];
            string nonbillid = nonbillable1.get(0).id;
        User[] professionals = getUsers();
        system.debug('Called Professionals'+professionals);
        
        List<string> holder = new List<string>();
                
        for (user p : professionals)
        {holder.add(p.Alias);}

            List<Time_Entry__c> timeE= [Select Name,Client__c,mcodes__c,Date__c,Timekeeper__c,Hours_Worked__c From Time_Entry__c Where Timekeeper__c In :holder];
        system.debug(timeE);
        
          
        for (user p: professionals)
        {
            
            List<Time_Entry__c> ProfTime = new List <Time_Entry__c>();
            integer hoursworktotal =0;
            integer entrycount=0;
            double projection=0;
            double bill = 0.00;
            double non = 0.00;
            
            for (Time_Entry__c te: timeE)
            {
            	 if (p.alias == te.Timekeeper__c)
             	{
                 	ProfTime.add(te);
                    system.debug('Add Time to ProfTime'+ProfTime);
                }
            }
            
            for(integer i=0; i<ProfTime.size();i++)
            {
                system.debug('ProfTime Value'+i+'-'+ProfTime.get(i));
            }
            
            if(ProfTime.size()!=0)
            {	
                    	// ProfTime is Single User's Time Block.
            	entrycount=ProfTime.size();
           
         	   List <string> alldata =  new List<String> ();
            
           	 string x = Proftime.get(0).client__c;
            string y = Proftime.get(0).mcodes__c;
            string z = x + '-' + y;
            system.debug('z'+z);
            alldata.add(z);
            //client and matter combine
           for(integer k=1; k<entrycount; k++)
           {
               Boolean toadd = false; 
               string x1 = Proftime.get(k).client__c;
            	system.debug('x1'+x1);
               string y1 = Proftime.get(k).mcodes__c;
               system.debug('y1'+y1);
            	string z1 = x1 +'-'+ y1;
               system.debug('z1'+z1);
            		
               for(string ad: alldata)
               {
                   if (z1 <> ad)
                   {
                      
                       toadd=true;
                       
                   }
                   else
                   {toadd=false;}
               }
               if(toadd == true)
               {
                   alldata.add(z1);
           
           		}
           }
            system.debug('alldata'+ alldata);
           for (string running: alldata)
           {
               
               Double totalhours=0.0;
               date firstentry = ProfTime.get(0).date__c;
               date lastentry = ProfTime.get(0).date__c;
              
               Time_Entry__c timetransfer = new Time_Entry__c ();
               for(Time_Entry__c tec1 : ProfTime)
               {
                string a1 = tec1.client__c;
                string b1 = tec1.mcodes__c;
            	string c1 = a1 +'-'+ b1;
                system.debug(running+ '==' +c1);
                   if(running == c1)
                   {
                       if(tec1.Client__c == nonbillid)
                       {
                           non+=tec1.Hours_Worked__c;
                       }
                       else
                       {
                           bill+=tec1.Hours_Worked__c;
                       }
                       totalhours+=tec1.Hours_Worked__c;
                       timetransfer = tec1;
                       system.debug(totalhours);
                       if(tec1.date__c < firstentry)
                       {
                           firstentry = tec1.date__c;
                       }
                       if(tec1.date__c > lastentry)
                       {
                           lastentry = tec1.date__c;
                       }
                   }
                             
               }
               system.debug(firstentry+' '+lastentry);
               Integer noOfDays = firstentry.daysBetween(lastentry)+1;
               system.debug(noOfDays + 'number of days');
               
               if(noOfDays > 7)
               {               
               Decimal Average = totalhours / noOfDays;
               system.debug(average);
               decimal Sday = Math.round(Average*7);
               projection = double.valueof(Sday);
               }
               else
               {projection = totalhours;}
               
               
            result.add(new Staffing(timetransfer,projection,bill,non, ProfCount));
               system.debug(result.size()+'result size');
           }
          
            }
            ProfCount++;
            }  
        
      }

    Public class Staffing
    {
        public Time_Entry__c timew {get;set;}
        public Double P {get;set;}
  

        Public decimal BillTime {get;set;}
        Public decimal NonBill {get;set;}
        Public integer profcount {get;set;}
        
        
        
        public Staffing(Time_Entry__c timew1, Double P1, Double Billable, Double non, integer loopcount)
        {
            timew=timew1;
            P=P1;
            BillTime=Billable;
            NonBill=non;
            profcount=loopcount;
            
         
        }
    }
}