public with sharing class QISPDFController {
    public QIS_Report__c qr { get; private set; }
    public User usr { get; private set; }
    public Boolean inGuarantee { get; private set; }
    public string staticResource { get; private set; }
    
    //  HWAG-BC68W3  故障发生日为空时， 它为真  start
    public Boolean outOfGuarantee { get; private set; }
    //  HWAG-BC68W3  故障发生日为空时， 它为真  end
    public QISPDFController() {
        qr = new QIS_Report__c();
        usr = new User();
        inGuarantee = false;
        staticResource = JSON.serialize(PIHelper.getPIIntegrationInfo('QIS_Report__c'));
        
    }
    
    public void init() {
        String id = ApexPages.currentPage().getParameters().get('id');
        
        Schema.DescribeSobjectResult d = QIS_Report__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 += ', Hospital_Department__r.Phone, Hospital_Department__r.Parent.Parent.State_Master__r.Name, Hospital_Department__r.Parent.Parent.City_Master__r.Name, Hospital__r.Name'
              + ', RC__r.Alias__c, RC_manager__r.Alias__c, OSH_Manager__r.Alias__c, OSH_Manager__r.BuchangApprovalManager__c, OSH_Manager__r.BuchangApprovalManager__r.Alias__c';

        soql += ' from QIS_Report__c where Id = \'' + id + '\'';
        
        List<QIS_Report__c> qrList = Database.query(soql);
        if (qrList.size() > 0) {
            qr = qrList[0];
            // TODO 一つのSOQLで出来る？
            usr = [select Name, Manager.Name, fen_corp_name__c, Salesdepartment__c from User where Id = :qr.OwnerId];
            // HWAG-BC68W3 
            /*
            if (qr.QIS_Submit_day__c >= Date.today()) {
            */
           if (qr.Faliour_date__c == null) {
                outOfGuarantee = true;
           }
           if ( qr.Faliour_date__c !=null && qr.guarantee_period_formula__c >= qr.Faliour_date__c) {
            //HWAG-BC68W3 end
            	inGuarantee = true;
            }
        }
    }
}