• erhimanicloud1.3965023856052195E12
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am facing a problem ,I am using visualforce compnent in an email template where value not show in template .But when i am using it on a simple visual force page all values are shown .

global with sharing Class OfferComponenetController1{

    public string offerId {get; set;}
    public Set<id>siteid {get; set;}
    public List<RealSteer__Offer_Site__c> offerSiteList {get;set;}
    public List<RealSteer__LeaseOffer__c> offrList  {get; set;}
    Public List<wrapper> lstwrap {get;set;}
    Public Integer ocpncy {get;set;}
    Public Integer noMonth {get;set;}
    Public Double Occp{get;set;}
    public Map<String, Double> ocpmap;
    Map<id,RealSteer__Offer_Site__c> offerMap = new  Map<id,RealSteer__Offer_Site__c>();
   
    public OfferComponenetController1(ApexPages.StandardController controller){
        offerid = ApexPages.CurrentPage().getParameters().get('id');
        offrList  = new List<RealSteer__LeaseOffer__c>();
        ocpmap = new Map<String, Double>();
        offerSiteList  = new List<RealSteer__Offer_Site__c>();
        siteid = new Set<id>(); 
        lstwrap = new List<wrapper>();
        system.debug('===offerSiteList =='+offerSiteList );
        Occupancy();
    }
    
    public RealSteer__LeaseOffer__c getOffr(){
        RealSteer__LeaseOffer__c offr = new RealSteer__LeaseOffer__c();
        
    System.debug('++++++++Entering+++++++');
        offr = [Select id , Name ,Priority__c, RealSteer__Account__r.Name,Payment_Status__c,PropertyName__c,Type_of_Business__c,Total_Discount1__c,Running_Since_Last__c, RealSteer__Total_Amount__c,RealSteer__Total_Amount_to_be_paid__c,RealSteer__Total_List_Price_Month__c,RealSteer__Total_Unit_Price__c, 
                        Reason_For_Discounting__c,RealSteer__Status__c,CreatedDate 
                  from RealSteer__LeaseOffer__c 
                 Where id=:offerId] ;
                 
        Date startDate = Date.today().toStartOfMonth();
        Integer daysInMonth = date.daysInMonth(startDate.year(), startDate.month());
        Date endDate  = startDate.addDays(daysInMonth -1);
        
        String offerName = '';
        if(offr.name != null)
            offerName = offr.name;
        Id offerId;
        if(offr.id != null)
        offerId = offr.id;    
        
        System.debug('===offerName====' +offr.name +'==:==:'+ +offerName);
       
        String str = 'Select id , Name ,CreatedBy.name, RealSteer__Account__r.Name,Payment_Status__c,PropertyName__c,Type_of_Business__c,Total_Discount1__c,Running_Since_Last__c, RealSteer__Total_Amount__c,RealSteer__Total_Amount_to_be_paid__c,RealSteer__Total_List_Price_Month__c,RealSteer__Total_Unit_Price__c,'+ 
                      '  Reason_For_Discounting__c,RealSteer__Status__c from RealSteer__LeaseOffer__c Where id !=: offerId';  
        
        str += ' AND CreatedDate >=: startDate AND CreatedDate <=: endDate';
        str += ' AND Name like \'%' + String.escapeSingleQuotes(offerName) +'%\'';  
        System.debug('++++++++str+++++++'+str); 
        offrList = Database.query(str);
                 
    System.debug('++++++++offrList +++++++'+offrList );
        
        return offr;     
    } 
    
     public void Occupancy(){
     
       Set<Id> ids = new  Set<Id>();
       List<Site_Occupancy__c> occupancy = new List<Site_Occupancy__c>();
       List<RealSteer__Offer_Site__c> offerSitss = [select ID,RealSteer__Sites__c from RealSteer__Offer_Site__c where RealSteer__Offer__c=: offerId];
       if(offerSitss.size() > 0 && offerSitss != null){
           for(RealSteer__Offer_Site__c ofst : offerSitss){
               ids.add(ofst.RealSteer__Sites__c);
           }
       }
        
       system.debug('========'+offerId);   
        if(ids != null && ids.size() > 0){
        system.debug('========'+siteid); 
             AggregateResult[] occ = [SELECT Sites__c site,Count(id)noOfIds,Sum(Occupancy__c)occp,Count(Month__c)nomnth FROM Site_Occupancy__c  Where Sites__c in :ids Group By Sites__c Having Count(Month__c)>=6];  
           
             system.debug('========'+occ);
             
             for(AggregateResult agr : occ){
                 ocpncy = Integer.valueOf(agr.get('occp'));
                 system.debug('====ocpncy==='+ocpncy); 
                 noMonth = Integer.valueOf(agr.get('nomnth'));
                 system.debug('====noMonth==='+noMonth);
                 if(noMonth!=null && noMonth!= 0)
                 Occp = ocpncy/noMonth;
                 String temp = String.valueOf(agr.get('site'));
                 system.debug('====temp ==='+temp );
                 if(!ocpmap.containsKey(String.valueOf(agr.get('site')))){
                     ocpmap.put(String.valueOf(agr.get('site')),Occp);
                      system.debug('====ocpmap==='+ocpmap); 
                 }
                 
             }  
        }
        
        
       List<RealSteer__Offer_Site__c> offerSits = new List<RealSteer__Offer_Site__c>();
        system.debug('========'+offerId);   
        if(offerId != null){
            offerSits = [SELECT Id, Name,RealSteer__Location__r.Name,RealSteer__Sites__r.Name,RealSteer__Sites__r.RealSteer__Height__c,
            RealSteer__Sites__r.RealSteer__Width__c,RealSteer__Sites__r.RealSteer__Sub_Location__c,RealSteer__Sites__r.RealSteer__Location__c, 
            RealSteer__Sites__r.RealSteer__Location__r.Name, RealSteer__Offer__c, RealSteer__Sites__c,
            CreatedDate, RealSteer__List_Price_month__c, RealSteer__Unit_Price__c, Card_Rate_Month__c, DiscountGiven__c,
            RealSteer__DiscountPercent__c, RealSteer__Mounting_Start_Date__c, RealSteer__Mounting_End_Date__c, Re_Mount_Date__c,Re_Print_Date__c,
            Re_Mount_Cost__c,Re_Print_Cost__c,RealSteer__Blocking_End_date__c, RealSteer__Blocking_Start_date__c,
            RealSteer__Sales_Price__c, RealSteer__Discount__c, RealSteer__Status__c, RealSteer__Location__c, RealSteer__Sub_Location__c 
            FROM RealSteer__Offer_Site__c Where RealSteer__Offer__c=: offerId] ; 
              
        }
        System.debug('+++++++++++++++offerSits+++++++++++++++'+offerSits);
        for(RealSteer__Offer_Site__c off : offerSits){
              offerMap.put(off.RealSteer__Sites__c,off);
              System.debug('=:ocpmap.get(off.RealSteer__Sites__c):=' +ocpmap.get(off.RealSteer__Sites__c));
              if(ocpmap != null && ocpmap.containsKey(off.RealSteer__Sites__c))
              {
                  lstwrap.add(new wrapper(off,ocpmap.get(off.RealSteer__Sites__c)));
              }
          }
          System.debug('++++++++++lstwrap++++++++++'+lstwrap+'=:lstwrap='+lstwrap.size());
           
     }
    Public class wrapper {
        Public RealSteer__Offer_Site__c offersite {get;set;}
        Public Double occpncy {get; set;}
            Public wrapper(RealSteer__Offer_Site__c ofs,Double occpncy){
            offersite = ofs;
            this.occpncy = occpncy;

}
}



<apex:component access="global" controller="OfferComponenetController"> <apex:attribute name="offID" access="public" type="String" assignTo="{!offerID}" description="Offer id"/> <html> <head> <style> table{ font-family: Arial,Helvetica,sans-serif } .tfooter{ font-weight:bold; border-top:1px solid black; text-align: right; } .tdLabel{ font-weight: bold; width:30%; font-size : 14px; } .tdValue{ font-size : 14px; text-align:left; width:50%; border-bottom-1px solid black; } </style> </head> <body> <table id="mainTable" style="font-size : 14px;"> <TR> <TD class="header" colspan="2"> <table width="100%"> <tr> <td style="text-align:center;width:60%"><h3><u>Discounting Approval</u></h3></td> <td style="width:10%"></td> </tr> </table> <br/><br/> </TD> </TR> <tr> <apex:outputPanel style="font-size:15px;font-weight:bold;color:Green"> <td style="font-weight:bold; width:30%;text-align:left">Priority</td> <td style="width:50%;text-align:left;"><apex:outputField value="{!offr.Priority__c}" ></apex:outputField> <apex:image url="http://4vector.com/i/free-vector-button-red-clip-art_116764_Buttonred_clip_art_hight.png" width="20" height="20" rendered="{!if(offr.Priority__c == 'high',true,false)}"/> <!-- rendered="{!if(offr.Priority__c == 'high',true,false) --> <apex:image url="http://www.caribbeanbelleweddings.com/wp-content/uploads/2013/03/slide-circle-green.png" width="20" height="20" rendered="{!if(offr.Priority__c == 'low',true,false)}"/> </td> </apex:outputPanel> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">1. Client Name</td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.Name}" ></apex:outputField></td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">2. Agency Name</td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.Realsteer__Account__r.Name}" ></apex:outputField></td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">3. Deal value</td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.RealSteer__Total_Amount__c}"></apex:outputField></td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">4. Total Discount</td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.Total_Discount1__c}"></apex:outputField></td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">5. Total Selling Rate/Month</td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.RealSteer__Total_Unit_Price__c}"></apex:outputField></td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">6. Total Card Rate/Month</td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.RealSteer__Total_List_Price_Month__c}"></apex:outputField></td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">7. Type Of Business</td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.Type_of_Business__c}"></apex:outputField></td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">8. Running Since Last</td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.Running_Since_Last__c}"></apex:outputField></td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">9. Payment/Outstanding Status</td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.Payment_Status__c}"></apex:outputField></td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">10. Deal Status</td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.RealSteer__Status__c}"></apex:outputField></td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left"> <apex:outputLabel value="10. Reason For Discounting"> </apex:outputLabel> </td> <td style="border-bottom: 1px dotted black;width:50%;text-align:left;"> <apex:outputField value="{!offr.Reason_For_Discounting__c}"/> </td> </tr> <tr> <td> </td> </tr> <tr> <td style="font-weight:bold; width:30%;text-align:left">12. Deal Detail</td> <td> </td> </tr> <tr> <td colspan="2"> <table width="100%" id="recTable" style="font-size:12px;border-collapse: collapse;" border="1"> <thead> <th width="5%" class="theader" style="border-bottom:1px solid black;">Sr No </th> <!--<th width="40%" class="theader" style="border-bottom:1px solid black;">Location </th>--> <th width="20%" class="theader" style="border-bottom:1px solid black;">Site </th> <th width="8%" class="theader" style="border-bottom:1px solid black;">Start Date</th> <th width="8%" class="theader" style="border-bottom:1px solid black;">End Date</th> <th width="15%" class="theader" style="border-bottom:1px solid black;">Card Rate/Month</th> <th width="10%" class="theader" style="border-bottom:1px solid black;">Selling Price/Month</th> <th width="10%" class="theader" style="border-bottom:1px solid black;">Deal Value </th> <th width="10%" class="theader" style="border-bottom:1px solid black;"> Discount (%) </th> <th width="10%" class="theader" style="border-bottom:1px solid black;"> Occupancy </th> </thead> <tbody> <apex:variable value="{!1}" var="count"/> <apex:variable value="{!0}" var="cardRateSum"/> <apex:variable value="{!0}" var="sellingRateSum"/> <apex:variable value="{!0}" var="discountSum"/> <apex:variable value="{!0}" var="unitPriceSum"/> <apex:repeat value="{!lstwrap}" var="item" id="rt"> <tr> <td class="tdValueCenter" style="text-align:center;">{!count}</td> <td class="tdValueLeft" style="text-align:left;"><apex:outputField value="{!item.offersite.RealSteer__Location__r.Name}"/></td> <td class="tdValueLeft" style="text-align:left;"><apex:outputField value="{!item.offersite.RealSteer__Sites__c}" id="site"/></td> <td class="tdValueLeft" style="text-align:left;"><apex:outputField value="{!item.offersite.RealSteer__Blocking_Start_date__c}" id="startdate"/></td> <td class="tdValueLeft" style="text-align:left;"><apex:outputField value="{!item.offersite.RealSteer__Blocking_End_date__c}" id="enddate"/></td> <td class="tdValueright" style="text-align:right;"><apex:outputField value="{!item.offersite.Card_Rate_Month__c}" id="rate"/></td> <td class="tdValueright" style="text-align:right;"><apex:outputField value="{!item.offersite.RealSteer__Unit_Price__c}" id="unitprice"/></td> <td class="tdValueright" style="text-align:right;"><apex:outputField value="{!item.offersite.RealSteer__Sales_Price__c}" id="salesprice"/></td> <td class="tdValueright" style="text-align:right;"><apex:outputField value="{!item.offersite.DiscountGiven__c}" id="discount"/></td> <!-- <td class="tdValueright" style="text-align:right;">{!item.occpncy}</td> --> </tr> <apex:variable value="{!count+1}" var="count"/> <apex:variable value="{!cardRateSum+item.offersite.Card_Rate_Month__c}" var="cardRateSum"/> <apex:variable value="{!unitPriceSum+item.offersite.RealSteer__Unit_Price__c}" var="unitPriceSum"/> <apex:variable value="{!sellingRateSum+item.offersite.RealSteer__Sales_Price__c}" var="sellingRateSum"/> <apex:variable value="{!discountSum+item.offersite.DiscountGiven__c}" var="discountSum"/> </apex:repeat> </tbody> <tfoot> <tr> <td style="border-Top:1px solid black;"></td> <td style="border-Top:1px solid black;"></td> <td style="border-Top:1px solid black;"></td> <td style="border-Top:1px solid black;"></td> <td style="border-Top:1px solid black;text-align:right;font-weight:bold;">Total</td> <td style="border-Top:1px solid black;text-align:right;font-weight:bold;">Rs.{!cardRateSum}</td> <td style="border-Top:1px solid black;text-align:right;font-weight:bold;">Rs.{!unitPriceSum}</td> <td style="border-Top:1px solid black;text-align:right;font-weight:bold;">Rs.{!sellingRateSum}</td> <td style="border-Top:1px solid black;text-align:right;font-weight:bold;"> <apex:outputText value="{0, number, 0.00} %"> <apex:param value="{!IF(cardRateSum > 0, ((cardRateSum - unitPriceSum)*100/cardRateSum ), 0)}" /> </apex:outputText> </td> </tr> </tfoot> </table> <br/><br/> </td> </tr> </table> <apex:outputPanel rendered="{!(if(offrList.size > 0 , true ,false))}"> <span style="font-weight:bold; width:30%;text-align:left"><b> 13 . Other Campaign Details of Current Month </b></span> <table width="100%" style="font-size:12px;border-collapse: collapse;" border="1"> <thead> <th width="5%" class="theader" style="border-bottom:1px solid black;">Property </th> <th width="5%" class="theader" style="border-bottom:1px solid black;">Client Name </th> <th width="5%" class="theader" style="border-bottom:1px solid black;">Total Card Rate/Month </th> <th width="5%" class="theader" style="border-bottom:1px solid black;">Total Site Offer Value </th> <th width="5%" class="theader" style="border-bottom:1px solid black;">Total Discount </th> <th width="5%" class="theader" style="border-bottom:1px solid black;">Owner </th> </thead> <apex:repeat value="{!offrList}" var="item"> <tr> <td style="border-Top:1px solid black;"> <apex:outputField value="{!item.PropertyName__c}"/> </td> <td style="border-Top:1px solid black;"> <apex:outputField value="{!item.name}"/> </td> <td style="border-Top:1px solid black;"> <apex:outputField value="{!item.RealSteer__Total_List_Price_Month__c}"/> </td> <td style="border-Top:1px solid black;"> <apex:outputField value="{!item.RealSteer__Total_Amount_to_be_paid__c}"/> </td> <td style="border-Top:1px solid black;"> <apex:outputField value="{!item.Total_Discount1__c}"/> </td> <td style="border-Top:1px solid black;"> <apex:outputField value="{!item.Createdby.name}"/> </td> </tr> </apex:repeat> </table> </apex:outputPanel> </body> </html> <!--<apex:pageBlockSection> <apex:pageBlockTable value="{!offrList}" var="ofrlst" rendered="{!if(offrList.size > 0 , true, false)}"> <apex:column value="{!ofrlst.Name}"/> </apex:pageBlockTable> </apex:pageBlockSection> --> </apex:component>


























        } 
    }
}
hii , my requirement is to calculate hours between two dates according to my bussiness hours .
my bussiness hours is 10:00AM to 7 :00PM and  Saturday and sunday holiday .
hii , my requirement is to calculate hours between two dates according to my bussiness hours .
my bussiness hours is 10:00AM to 7 :00PM and  Saturday and sunday holiday .
hii , my requirement is to calculate hours between two dates according to my bussiness hours .
my bussiness hours is 10:00AM to 7 :00PM and  Saturday and sunday holiday .