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
nikkeynikkey 

Show Data for Current year and future years

Can any one help me out .How to show past,current and future years data in visual force page pdf format . I get the data displayed for the current year (2015 ).Any Example, Any Suggestion .I shall appreciate your help.

Code :
for (gmod__Opportunity_Forecast__c oppforecast: opflist) {

            String prodName = oppforecast.gmod__Product__r.Name;
            String monthText = oppforecast.gmod__Month_Text__c;
            Integer year = Integer.valueof(oppforecast.gmod__Year__c);
            Integer previousyear = date.today().year()-1;
            Integer currentyear = date.today().year();


            Map<String, Decimal> quarterMap;
            Map<String, Decimal> amountMap;

            if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==currentyear)){
                quarterMap = Quarter1;
                 system.debug('quarterMap@@@@@@@@'+quarterMap);
                amountMap = Amount1;
            if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);

        }
Similary for the quarters the code gets repeated.The logic should if the data exists or not it should display the o/p as per the products.
 
ManojjenaManojjena
Hi Nikky,

Please check with below queries an ddisplay in PDF .
 
SELECT Id FROM gmod__Opportunity_Forecast__c WHERE CloseDate < NEXT_N_YEARS:20
SELECT Id FROM gmod__Opportunity_Forecast__c WHERE CloseDate > LAST_N_YEARS:20
SELECT Id FROM gmod__Opportunity_Forecast__c WHERE CloseDate = THIS_YEAR

I think it will help you if you want more than 20 or less than that you can change and add filter on that .
Please let me know if it helps . 
nikkeynikkey
Hi Manoj Kumar jena,
Thanks for your reply....
As per the requirement ,i need to show the past ,present and future data in table in visual force page which is in PDF format.I have written a controller which has a wrapper class and the object if from managed package.So can we write any logic to get the data for the past ,present and future.Any help very much appreciated.

Contoller code :
public with sharing class QuoteContentController {
    public Map < String, Decimal > PartMap {get;set;}
    public Map < string, Decimal > Quarter1 {get;set;}  
    public Map < string, Decimal > Quarter2 {get;set;}  
    public Map < string, Decimal > Quarter3 {get;set;}  
    public Map < string, Decimal > Quarter4 {get;set;}  
    public Map < string, Decimal > Amount1 {get;set;}  
    public Map < string, Decimal > Amount2 {get;set;}  
    public Map < string, Decimal > Amount3 {get;set;}  
    public Map < string, Decimal > Amount4 {get;set;}  
    public Competitor__c com {get;set;}  
    public gmod__Opportunity_Forecast__c opflist {get;set;}  
    public Id qId {get;set;}  
    Public string all {get;set;}  
    public integer previousyear{get;set;}
    public integer currentyear{get;set;}
    public Id productId {get;set;}
    
    Public QuoteContentController() {}
    Public QuoteContentController(ApexPages.StandardController controller) {
        qId = Apexpages.currentPage().getparameters().get('Id');
        previousyear = date.today().year()-1;
        currentyear = date.today().year();
    }
       
   Public List<wrapperClass> disp_list {get;set;}{
        disp_list = new list < wrapperclass > ();
        //Query all the list     
        List < Quote > q = [select id, Name, QuoteNumber, Effective_Date__c, Comments__c, Quote.Opportunity.id,
                                    Quote.Opportunity.Probability, Quote.Opportunity.AccSegment__c, 
                                    Quote.Opportunity.AccApplication__c, Quote.Opportunity.Persona__c, Quote.Opportunity.Region__c
                                    from Quote where id = : apexpages.currentpage().getparameters().get('id')];
        Opportunity opp = [select id, Name, (select id, Quantity, product2id from OpportunityLineItems), 
                                probability, AccSegment__c 
                                from Opportunity where opportunity.Id = : q[0].opportunity.id LIMIT 1];
        List < gmod__Opportunity_Forecast__c > opflist = [ Select id, Name, gmod__opportunity__r.id, gmod__Quantity__c, gmod__Price__c,
                                                            gmod__Month__c, gmod__date__c, gmod__Quarter__c, gmod__Amount__c, Actual_Price__c, 
                                                            gmod__Year__c, gmod__Month_Text__c, Forecast_Date__c, gmod__Product__r.Name, 
                                                            gmod__opportunity__r.name from gmod__Opportunity_Forecast__c 
                                                            WHERE gmod__Product__c != null and gmod__opportunity__r.id = : opp.id 
                                                            Order BY  gmod__Product__r.Name,gmod__Year__c, gmod__Month__c asc];
        //Iterate through each list to extract the values and add it to the custom wrapper data type  

        PartMap = new Map < String, Decimal > ();
        Quarter1 = new Map < String, Decimal > ();
        Quarter2 = new Map < String, Decimal > ();
        Quarter3 = new Map < String, Decimal > ();
        Quarter4 = new Map < String, Decimal > ();
        Amount1 = new Map < String, Decimal > ();
        Amount2 = new Map < String, Decimal > ();
        Amount3 = new Map < String, Decimal > ();
        Amount4 = new Map < String, Decimal > ();
        
       for (gmod__Opportunity_Forecast__c oppforecast: opflist) {

            String prodName = oppforecast.gmod__Product__r.Name;
            String monthText = oppforecast.gmod__Month_Text__c;
            Integer year = Integer.valueof(oppforecast.gmod__Year__c);
            Integer previousyear = date.today().year()-1;
            Integer currentyear = date.today().year();
            

            Map<String, Decimal> quarterMap;
            Map<String, Decimal> amountMap;

            if ((monthText == 'Jan' || monthText == 'Feb' || monthText == 'Mar')&&(year==currentyear)){
                quarterMap = Quarter1;
                 system.debug('quarterMap@@@@@@@@'+quarterMap);
                amountMap = Amount1;
            if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);
               
        }
        
       }     
            if ((monthText == 'Apr' || monthText == 'May' || monthText == 'June')&&(year==currentyear)){
                quarterMap = Quarter2;
                system.debug('quarterMap!!!!!!!!!'+quarterMap);
                amountMap = Amount2;
                
                if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);
            
                }
                }
            if ((monthText == 'Jul' || monthText == 'Aug' || monthText == 'Sept')&&(year==currentyear)){
                quarterMap = Quarter3;
                 system.debug('quarterMap############'+quarterMap);
                amountMap = Amount3;
                if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);
            }
            }
            if ((monthText == 'Oct' || monthText == 'Nov' || monthText == 'Dec')&&(year==currentyear)) {
                quarterMap = Quarter4;
                 system.debug('quarterMap$$$$$$$$$$'+quarterMap);
                amountMap = Amount4;
                 if (quarterMap.containskey(prodName)) {
                quarterMap.put(prodName, quarterMap.get(prodName) + oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, amountMap.get(prodName) + oppforecast.gmod__Amount__c);
            } else {
                quarterMap.put(prodName, oppforecast.gmod__Quantity__c);
                amountMap.put(prodName, oppforecast.gmod__Amount__c);
                
           
            wrapperclass w = new wrapperclass();
            w.gmod_Opportunity = oppforecast.gmod__Opportunity__r.Name;
            w.gmod_Product = prodName;
            w.gmod_Quantity = oppforecast.gmod__Quantity__c;
            w.gmod_Price = oppforecast.gmod__Price__c;
            w.Name = oppforecast.Name;
            w.gmod_Quarter = oppforecast.gmod__Quarter__c;
            w.gmod_Month = oppforecast.gmod__Month__c;
            w.gmod_Amount = oppforecast.gmod__Amount__c;
            w.Actual_Price = oppforecast.Actual_Price__c;
            w.gmod_Year = oppforecast.gmod__Year__c;
            w.gmod_date = oppforecast.gmod__date__c;
            w.gmod_Month_Text = monthText;
            w.Forecast_Date = oppforecast.Forecast_Date__c;
            disp_list.add(w);
}
     

}            
        
            for (Quote qt: q) {
            System.debug('Quote Size ++ '+q.size());
             System.debug('opp forcast ++ ' +opflist.size());
                for (integer i = 0; i < opflist.size(); i++) {
               
                   
                    //Instantiating the wrapper SObject     
                  /* wrapperclass w = new wrapperclass();
                    //Assigning the wrapper variables from the SObject Fields in the database.     
                    w.gmod_Opportunity = opflist[i].gmod__Opportunity__r.Name;
                    w.gmod_Product = opflist[i].gmod__Product__r.Name;
                    w.gmod_Quantity = opflist[i].gmod__Quantity__c;
                    w.gmod_Price = opflist[i].gmod__Price__c;
                    w.Name = opflist[i].Name;
                    w.gmod_Quarter = opflist[i].gmod__Quarter__c;
                    w.gmod_Month = opflist[i].gmod__Month__c;
                    w.gmod_Amount = opflist[i].gmod__Amount__c;
                    w.Actual_Price = opflist[i].Actual_Price__c;
                    w.gmod_Year = opflist[i].gmod__Year__c;
                    w.gmod_date = opflist[i].gmod__date__c;
                    w.gmod_Month_Text = opflist[i].gmod__Month_Text__c;
                    w.Forecast_Date = opflist[i].Forecast_Date__c;*/
                    
                }//End of For loop int
            }//End of For loop Quote
        }//End of For loop gmod
        
  }//End of disp
         

    //Declare a wrapper class      
       public class Wrapperclass  {
        //custom wrapper datatype      
        Public string Name{get;set;}  
        Public string AccountType{get;set;}  
        Public date todaysDate{get;set;}  
        Public date Expected_Order_Date{get;set;}
        Public string Probability{get;set;}  
        Public string Internal_Comment{get;set;}  
        Public string External_Comment{get;set;}      
        Public string Segment{get;set;}  
        Public string Application{get;set;}  
        Public string Persona{get;set;}  
        Public string Geogrpahy{get;set;}      
        Public string PartNumbers{get;set;}  
        Public Decimal  Price{get;set;}  
        Public Decimal End_Customer_Price{get;set;}  
        Public Decimal Quantity {get;set;}  
        Public Decimal Total{get;set;}      
        Public string RFQ_justification{get;set;}  
        Public string Main_Customer_of_Account{get;set;}  
        Public string Bridgelux_competition_at_account{get;set;}
        Public string Geographic_regions_serviced{get;set;}  
        Public string Annual_lighting_revenue{get;set;}  
        Public string Annual_LED_revenue_or_percent{get;set;}  
        Public string Annual_purchases_of_LED_light_sources{get;set;}
        Public string Percent_of_LED_purchases_that_are_COB{get;set;}  
        Public string Other_information{get;set;}      
        Public string Product_Series{get;set;}  
        Public string Volume{get;set;} 
        Public string Date_Price_is_Valid{get;set;}     
        Public string gmod_Opportunity{get;set;}
        Public string gmod_Product{get;set;}
        Public Decimal gmod_Quantity{get;set;}
        Public Decimal gmod_Price{get;set;}
        Public Decimal gmod_Quarter{get;set;}
        Public Decimal gmod_Month{get;set;}
        Public Decimal gmod_Amount{get;set;}
        Public Decimal Actual_Price{get;set;}
        Public Decimal  gmod_Year{get;set;}
        Public Date gmod_date{get;set;}
        Public string gmod_Month_Text{get;set;}
        Public Date  Forecast_Date{get;set;}
    }
  
   
   
    
} //End of Class