• R@v!
  • NEWBIE
  • 10 Points
  • Member since 2015
  • Salesforce Developer
  • Girikon Solutions Pvt ltd..

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
//Apex Class

public class ManagePhasescontroller {
    Public Integer count {get; set;}
    Public Integer countRecord {get; set;}
    public boolean bCounter {get;set;}
    Public Integer benchSize {get; Set;}
    public string para{get;set;}

 public void getselectedbenchmark() {
     try{
         if(MonthAcc.Account__c !=null && selectedPhase != null)
         selectedbenchmark = [SELECT Responsible__c,Date_Completed__c,Target_Date__c,Objective__c,Phase__c,Sequence__c from Phase_Benchmark__c where Phase__r.Account__c=:MonthAcc.Account__c AND  Phase__c = :selectedPhase.Id  AND Completed__c=false ORDER BY Sequence__c ASC]; 
        if(selectedbenchmark!=null  && selectedbenchmark.size()>0){
        benchSize = selectedbenchmark.size(); 
        }
            count = 0;
            countRecord = 1;
            bCounter = true;
        }
         catch (Exception e){}
    }
    
    
     //**Method for incement the counter
     public PageReference incrementCounter() {
        
            count++;
         
             countRecord++;
           
             bCounter = false;
      
         return null;
    }
    
    //**Method for decrement the counter
    public PageReference decrementCounter() {
      
            count--;
      
            countRecord--;
   
            return null;
    }
    
    //**Method for fetch count value
    public Integer getCount() { 
        return count;
    }



//VF Page


<apex:outputPanel id="thePanel">
                                <apex:outputPanel styleClass="red" rendered="{!if(selectedPhase!=null,true,false)}" >
                                    <apex:pageBlockSection title="Phase Information">
                                        <apex:outputField value="{!selectedPhase.Phase_Number__c}"/> 
                                        <apex:outputField value="{!selectedPhase.Description__c}"/>
                                        <apex:outputField value="{!selectedPhase.Start_Date__c}"/>
                                        <apex:outputField value="{!selectedPhase.End_Date__c}"/>
                                    </apex:pageBlockSection><br/>
                                    <apex:outputPanel rendered="{!if(selectedbenchmark=null,true,false)}" >
                                        <center> All Benchmark for this Phase have been Completed.<br/><br/>
                                            <apex:commandButton value="Move to Next Phase" action="{!movenextphase}" reRender="MonthlyFrm"/>
                                        </center>
                                    </apex:outputPanel>
                                   </apex:outputPanel>
                                </apex:outputPanel><br/>
                                <apex:outputPanel id="Panel">
                                <apex:repeat value="{!selectedbenchmark}" var="bench" id="theRepeat" rows="1" first="{!if(count=-1,0 ,count)}">
                                    <apex:outputPanel styleClass="red"  rendered="{!if(selectedbenchmark!=null,true,false)}">
                                   
                                       <apex:pageBlockSection title="Phase BenchMark">
                                         
                                            <apex:outputField value="{!bench.Responsible__c}"/> 
                                            <apex:outputField value="{!bench.Target_Date__c}"/>
                                            <apex:outputField value="{!bench.Objective__c}"/>
                                            <apex:outputField value="{!bench.Date_Completed__c}"/>  
                                          
                                       </apex:pageBlockSection><br/>    
                                    <apex:outputPanel >
                                   <center>  
                                 
                                   <apex:outputpanel id="panel2">
                   
                                    <apex:commandButton value="<<" rerender="btn2" disabled="{!if((bCounter=true || count=0),true ,false)}"/>
                                    <apex:actionSupport id="btn2" event="onclick" action="{!decrementCounter}" rerender="panel,panel2,out,panel1"/>
                                        
                                    </apex:outputpanel>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <apex:outputPanel >
                                    <apex:commandButton value="Complete this Benchmark" action="{!completebenchmark}" reRender="MonthlyFrm,Panel">
                                    <apex:param value="{!bench.Id}" assignTo="{!para}"/></apex:commandButton>
                                    </apex:outputPanel>
                                    &nbsp;&nbsp;&nbsp;&nbsp;<apex:outputText value="{!countRecord}" id="out"/>/{!benchSize}&nbsp;&nbsp;&nbsp;&nbsp;
                                    <apex:outputpanel id="panel1">
                                    <apex:commandButton value=">>" rerender="btn1" disabled="{!if(countRecord=benchSize,true ,false)}"/>
                                    <apex:actionSupport id="btn1" event="onclick" action="{!incrementCounter}" rerender="Panel,panel2,out,panel1"/>
                                    </apex:outputpanel>
                                                                   
                                                                  
                                </center>
                            </apex:outputPanel>                             
                        </apex:outputPanel>
                       </apex:repeat>
                    </apex:outputPanel>

 
  • May 27, 2016
  • Like
  • 0
public class Onboarding_OffboardingCtr {
    public string sFirstName{get;set;}
    public string sLastName {get;set;}
    public string sEmail {get;set;}
    public date dFirstDate{get;set;}
    Public date dLAstdate{get;set;}
    public boolean sSalesforceUser{get;set;}
    public boolean bTeamWorkUser{get;set;}
    public boolean bOnboarding {get;set;}
    public boolean bOffboarding {get;set;}
    public profile sProfileId{get;set;}
    public  Id profile {get;set;}
    
    public Onboarding_OffboardingCtr(){
        sFirstName = null;
        sLastName = null;
        sEmail = null;
        dFirstDate  = null;
        dLAstdate  = null;
        sSalesforceUser = false;
        bTeamWorkUser = false;
    }
    
    Public pageReference Submit(){
        try{
            if(sSalesforceUser == true){
                sProfileId = [SELECT Id from profile Where Name = 'Force.com -App Sub. Custom' LIMIT 1];
                if(sProfileId != null)
                    profile = sProfileId.id;
                List<User> lstUser = [SELECT Id FROM User WHERE Email =: sEmail];
                if(lstUser.size()==0){
                    system.debug(sSalesforceUser);
                    system.debug(sProfileId);
                    system.debug(sFirstName);
                    system.debug(sLastName);
                    User newUser = new User();
                    newUser.Username= sEmail;
                    if(validateEmail(sEmail) == true)
                    newUser.Email = sEmail;
                    else
                    ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.Error, 'Check your email'));
                    newUser.Lastname = sLastName;
                    newUser.Firstname = sFirstName;
                    newUser.ProfileId = profile;
                    newUser.CommunityNickname = sFirstName;
                    newUser.Alias = sLastName;
                    newUser.TimeZoneSidKey = 'GMT';
                    newUser.LocaleSidKey = 'en_US';
                    newUser.EmailEncodingKey = 'ISO-8859-1';
                    newUser.LanguageLocaleKey = 'en_US';
                    newUser.UserPermissionsMobileUser = false;
                   insert newUser;
                   ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.CONFIRM, 'Salesforce user successfully create'));
                }
            }
            
            if(bTeamWorkUser==true){
                List<User> lstUser = [SELECT Id, Email FROM User WHERE Email =:sEmail AND IsActive= true];
                if(lstUser.size()>0){
                    string sUserEmail = lstUser.get(0).Email;
                    string bodyRes = TPM_Common.retrieveItem('people.json?emailaddress='+sUserEmail);
                    if(bodyRes != null){
                        Map<String, Object> root = (Map<String, Object>)JSON.deserializeUntyped(bodyRes);
                        if(root.containsKey('people') && root.get('people')!=''){
                            List<Object> items = (List<Object>)root.get('people');
                            if(items.size() >0){
                                System.Debug('rootSize : '+items.size());
                                System.Debug('root : '+root.containsKey('people'));
                                System.Debug('root : '+root.get('people'));
                                system.debug('---------------------------------'+bodyRes);
                                ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'User already exist in TeamWorkPM'));
                            }
                            else{
                                string body = '{"person": {"first-name": "'+sFirstName+'","last-name": "'+sLastName+'","email-address": "'+sEmail+'","user-type": "account","user-name": "'+sEmail+'","company-id": "1446","dateFormat": "dd/mm/yyyy","sendWelcomeEmail": "no","receiveDailyReports": "no","autoGiveProjectAccess": "yes","userLanguage": "EN","administrator": "yes","canAddProjects": "yes","timezoneId" : "15","notifyOnTaskComplete":"no","userReceiveNotifyWarnings":"no","notify-on-added-as-follower":"yes","notify-on-status-update":"yes"}}';
                                string sTeamWorkPM_Id = TPM_Common.createItem(body, 'people.json');
                                lstUser.get(0).TeamworkPM_User_ID__c = sTeamWorkPM_Id;
                                update lstUser;
                                ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.CONFIRM, 'TeamWork user successfully create'));
                            }
                        }
                      }
                  }
              else{
                   ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'No Salesforce User with this Email Id'));
              }
            }
            
            if(bOnboarding == true){
                string sDate = TPM_Common.formatDate(dFirstDate);
                List<Tasklist_Template__c> lstTaskTemp = [SELECT Id, Description__c, TeamworkPM_Template_ID__c FROM  Tasklist_Template__c WHERE Phase_Template__r.Associated_Phase__c = 'Onboarding'];
                if(lstTaskTemp.size()>0 && lstTaskTemp != null){
                    for(Tasklist_Template__c oTemplate : lstTaskTemp){
                        string body = '{"todo-list": {"name": "OnBoarding Tasklist","private": false,"pinned": true,"milestone-id": "","description": "'+oTemplate.Description__c+'","todo-list-template-id":  "'+oTemplate.TeamworkPM_Template_ID__c+'","todo-list-template-start-date":"'+sDate+'"}}';
                        string sTeamWorkPM_Id = TPM_Common.createItem(body, 'projects/94222/tasklists.json');
                        ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.CONFIRM, 'OnBoarding Tasklist has been successfully create'));
                    }
                }            
            }
            
            if(bOffboarding == true){
                string sDate = TPM_Common.formatDate(dLAstdate);
                List<Tasklist_Template__c> lstTaskTemp = [SELECT Id, Description__c, TeamworkPM_Template_ID__c FROM  Tasklist_Template__c WHERE Phase_Template__r.Associated_Phase__c = 'Offboarding'];
                if(lstTaskTemp.size()>0 && lstTaskTemp != null){
                    for(Tasklist_Template__c oTemplate : lstTaskTemp){
                        string body = '{"todo-list": {"name": "OffBoarding Tasklist","private": false,"pinned": true,"milestone-id": "","description": "'+oTemplate.Description__c+'","todo-list-template-id":  "'+oTemplate.TeamworkPM_Template_ID__c+'","todo-list-template-start-date":"'+sDate+'"}}';
                        string sTeamWorkPM_Id = TPM_Common.createItem(body, 'projects/94222/tasklists.json');
                        ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.CONFIRM, 'OffBoarding Tasklist has been successfully create'));
                    }
                }            
            }
          
        }
        catch (DMLException e)
        {
           if (e.getMessage().contains('LICENSE_LIMIT_EXCEEDED'))
           {
               ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.Error, 'Your org does not have sufficient licenses'));
           }
           else
           {
              // rethrow the exception or take some other action here
              throw e;
           }
        }
            
        return null;
    }
    
    //Email validation 
    public static Boolean validateEmail(String email) {
    Boolean res = true;
    String emailRegex = '^[a-zA-Z0-9._|\\\\%#~`=?&/$^*!}{+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$'; // source: <a rel="nofollow" href="http://www.regular-expressions.info/email.html" target="_blank">http://www.regular-expressions.info/email.html</a>
    Pattern MyPattern = Pattern.compile(emailRegex);
    Matcher MyMatcher = MyPattern.matcher(email);

    if (!MyMatcher.matches()){ 
        res = false;
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Check your email')); 
    }
    return res; 
    }  
}

 
  • April 26, 2016
  • Like
  • 0
public class Summary {
        public String TDLINXSTR{ get; set; }
        public String AccountId{ get; set; }
        public String AccountName{ get; set; }
        public String Accountbillingstreet{ get; set; }
        public Datetime CloseDate{ get; set; }
        public String Name{ get; set; }
        public Decimal TotalOpportunityQuantity { get; set; }
        public String StageName{ get; set; }
        public String Brand{ get; set; }
        public String Cases{ get; set; }
        public String Customer{ get; set; }
        public String Manager{ get; set; }
        public String Market{ get; set; }
        public String OpportunityType{ get; set; }
        public String PLNBRAND{ get; set; }
        public String SalesRep{ get; set; }


         public Summary(AggregateResult ar) {
            TDLINXSTR=(String) ar.get('TDLINX_STR__c');
            AccountId=(String) ar.get('Id');
            AccountName=(String) ar.get('accName');
            Accountbillingstreet=(String) ar.get('billingstreet');
            CloseDate=(Datetime) ar.get('CloseDate__c');
            Name=(String) ar.get('Name');
            TotalOpportunityQuantity=(Decimal) ar.get('TotalOpportunityQuantity');
            StageName=(String) ar.get('StageName__c');
            Brand=(String) ar.get('Brand__c');
            Cases=(String) ar.get('Cases__c');
            Customer=(String) ar.get('Customer__c');
            Manager=(String) ar.get('Manager__c');
            Market=(String) ar.get('Market__c');
            OpportunityType=(String) ar.get('OpportunityType__c');
            PLNBRAND=(String) ar.get('PLN_BRAND__c');
            SalesRep=(String) ar.get('SalesRep__c');
}
}

 
  • February 18, 2016
  • Like
  • 0
global class UserLogJob implements Schedulable {

       global void execute(SchedulableContext SC) {

          EmailUserLogController M = new EmailUserLogController();
          m.UserLog();

       }

    }
  • February 17, 2016
  • Like
  • 0
global class UserLogJob implements Schedulable {

       global void execute(SchedulableContext SC) {

          EmailUserLogController M = new EmailUserLogController();
          m.UserLog();

       }

    }
  • February 17, 2016
  • Like
  • 0