buli
2022-05-14 ead4df22dca33a867279471821ca675f91dec760
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
public with sharing class CampaignRelationshipController {
 
    public string campaignId {get; set;}
    public List<CampaignRelationship__c> CRList {get; set;}
    public List<CampaignRelationship__c> RVICRList {get; set;}
    public List<CampaignRelationship__c> NDTCRList {get; set;}
    public List<CampaignRelationship__c> ANICRList {get; set;}
    public List<CampaignRelationship__c> IECRList {get; set;}
 
    public String baseUrl { get; set; }
 
    public  CampaignRelationshipController(){
 
        baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
        String path = URL.getCurrentRequestUrl().getPath();
        if (path.indexOf('/apex') > 0) {
            baseUrl += path.substring(0, path.indexOf('/apex'));
        }
        campaignId = System.currentPageReference().getParameters().get('campaignId');
 
 
    } 
 
    public CampaignRelationshipController(ApexPages.StandardController controller) {
        campaignId = controller.getRecord().Id;
        system.debug('campaignId---->'+campaignId);
 
        baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
        String path = URL.getCurrentRequestUrl().getPath();
        if (path.indexOf('/apex') > 0) {
            baseUrl += path.substring(0, path.indexOf('/apex'));
        }
 
    }
 
    public PageReference init() {
        
        CRList  = new List<CampaignRelationship__c>();
        CRList = [SELECT Id,Name,RelationshipAccount__c,RelationshipAccount__r.Name,
                            RelationshipAccountStatus__c,RelationshipProductSegment__c,
                            RelationshipCampaign__c,ManagementCode__c 
                FROM CampaignRelationship__c 
                WHERE RelationshipCampaign__c = :campaignId Order by Id];
        
        
        RVICRList  = new List<CampaignRelationship__c>();
        NDTCRList  = new List<CampaignRelationship__c>();
 
        ANICRList  = new List<CampaignRelationship__c>();
 
        IECRList  = new List<CampaignRelationship__c>();
        if (CRList.size() > 0) {
            for (CampaignRelationship__c cr:CRList) {
                if (cr.RelationshipProductSegment__c == 'RVI') {
                    RVICRList.add(cr);
                } else if (cr.RelationshipProductSegment__c == 'NDT') {
                    NDTCRList.add(cr);
                } else if (cr.RelationshipProductSegment__c == 'ANI') {
                    ANICRList.add(cr);
                } else if (cr.RelationshipProductSegment__c == 'IE') {
                    IECRList.add(cr);
                }
            }
        }
        return null;
    }
 
 
    public PageReference DataLoadAccount(){
 
        PageReference ref = new Pagereference(baseUrl +'/apex/DataLoadAccount?campaignId=' + campaignId);
        ref.setRedirect(true);
        return ref;
        //return null ;
    }
 
    //public PageReference UnabletoEdit() {
 //       PageReference ref = new Pagereference('/apex/TSRepair?Id=' + repairId);
 //       ref.setRedirect(true);
 //       return ref;
 //   }
}