public with sharing class OFSRepairConsignPDFController {
    public Repair__c rp { get; set; }
    public String userName { get; set; }
    public Boolean notGuarantee { get; set; }
    
    public Map<String, Boolean> acceMap { get; set; }
    
    public void init() {
        String id = ApexPages.currentPage().getParameters().get('id');
        rp = this.getRepairData(id);
        
        userName = UserInfo.getLastName() + ' ' + UserInfo.getFirstName();
        
        notGuarantee = false;
        if (rp.NewProductGuaranteeObject_PDF__c == false && rp.ReRepairObject__c == false && rp.Number_of_EffectiveContract__c == '无') {
            notGuarantee = true;
        }
        
        acceMap = new Map<String, Boolean>();
        //String acceStr = rp.Accsessory__c;
        Map<String, String> tmpMap = new Map<String, String>();
        if (rp.Accsessory__c != null) {
            for (String str : rp.Accsessory__c.split(';', -1)) {
                tmpMap.put(str, str);
            }
        }
        
        Schema.DescribeFieldResult fieldResult = Repair__c.Accsessory__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        for(Schema.PicklistEntry f : ple) {
            if (tmpMap.containsKey(f.getValue())) {
                acceMap.put(f.getValue(), true);
            } else {
                acceMap.put(f.getValue(), false);
            }
        }
    }
    
    private Repair__c getRepairData(String id) {
        Schema.DescribeSobjectResult d = Repair__c.sObjectType.getDescribe();
        Map<String, Schema.SObjectField> fieldMap = d.fields.getMap();
        
        String soql = 'select ';
        String fields = '';
        for (String field : fieldMap.keySet()) {
            if (fields.length() > 0) {
                fields += ', ';
            }
            fields += field;
        }
        soql += fields;
        soql += ', Delivered_Product__r.Name';
        soql += ' from Repair__c where Id = \'' + id + '\'';
        
        return Database.query(soql);
    }
}