高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
public with sharing class SI_SearchSetProductController {
    public Product_Set__c rc {get;set;}
    public Product_Set__c sc {get;set;}
    public List<Product_Set__c> cl {get;set;}
 
    public String SearchName {get;set;}
    public String SearchCode {get;set;}
    public String SearchPrice {get;set;}
    public String SearchQuantity {get;set;}
 
    public String baseUrl {get;set;}
    public String reportid {get;set;}
    public List<String> setProductidFullList{get;set;}
    public List<SSPLine> activities {get;set;}
    public String setPFString {get;set;}
    public String DataStatus {get;set;}
    public SI_SearchSetProductController(ApexPages.StandardController controller){
 
        rc = new Product_Set__c();
        sc = new Product_Set__c();
        cl = new List<Product_Set__c>();
        baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
    }
 
    public void init(){
        Report r = new Report();
        List<Report> rs = new List<Report>();
        rs=[Select id,DeveloperName,Name,NamespacePrefix from Report Where DeveloperName='Set_Product_Detail'];
        if (rs.size()>0){
                reportid = rs[0].id;
                reportid = reportid.substring(0,15);
        }
    }
 
    public PageReference serContact(){
        String searchSql = 'Select id, name, Price__c, Product_Set_CD__c, Quantity__c,Valid_Status__c,Quote_Select_Info__c From Product_Set__c ';
        String whereStr = 'Where id != null ';
        String whereSql = '';
 
        if(SearchName != null && SearchName != ''){
            whereSql += 'and name Like ' + '\'%' + SearchName + '%\' ';
        }
 
        if(SearchCode != null && SearchCode != ''){
            whereSql += 'and Product_Set_CD__c like ' + '\'%' + SearchCode + '%\' ';
        }
/*
*/
        searchSql = searchSql + whereStr + whereSql;
 
        searchSql += ' order by Product_Set_CD__c limit 500';
 
        cl = Database.query(searchSql);
        activities = New List<SSPLine>();
//    SSPLine a = new SSPLine();
        for(Product_Set__c psl : cl){
                SSPLine a = new SSPLine(psl);
                activities.add(a);
        }
        return null;
    }
    public void SelectDone(){
        setPFString = '';
        setProductidFullList = New List<String>();
        if(activities.size()==1){
            setPFString = activities[0].setProductidFull;
        }else{
            for(SSPLine arc : activities){
                if(arc.isSelected==true){
                    if(String.isblank(setPFString)||setPFString==null){
                        setPFString = arc.setProductidFull;
                    }else{
                        setPFString = setPFString+','+arc.setProductidFull;
                    }
                    
                }
            }
        }
        DataStatus = 'Fin';
    }
        public class SSPLine {
                public Boolean isSelected {get;set;}
                public String setProductid { get; set; }
                public String setProductidFull { get; set; }
                public Decimal Quantity { get; set; }
                public Product_Set__c theObject { get; set; }
                public String Name { get; set; }       
                public String Product_Set_CD_c { get; set; }
                public String Quote_Select_Info_c { get; set; }
                public Boolean Valid_c { get; set; }
 
                public SSPLine(Product_Set__c psl) {
                        isSelected = false;
                        setProductid = psl.id;
                        setProductid = setProductid.substring(0,15);
                        setProductidFull = psl.id;
                        Name = psl.Name;
                        Product_Set_CD_c= psl.Product_Set_CD__c;
                        Quantity = psl.Quantity__c;
                        Quote_Select_Info_c = psl.Quote_Select_Info__c;
                        Valid_c = psl.Valid_Status__c;
                }
        }
}