trigger DailyReportSetHospitalCount on Daily_Report__c (after update) { 
 | 
    /* 
 | 
    List<String> accParentList = new List<String>(); 
 | 
    List<Date> actDateList1 = new List<Date>(); 
 | 
    List<String> accParentParentList = new List<String>(); 
 | 
    List<Date> actDateList2 = new List<Date>(); 
 | 
    */ 
 | 
    List<String> eIdList = new List<String>(); 
 | 
  
 | 
    List<Id> drId = new List<Id>(); 
 | 
    for (Daily_Report__c dr : Trigger.new) { 
 | 
        if (Trigger.isUpdate) { 
 | 
            if (Trigger.oldMap.get(dr.Id).get('Status__c') != dr.Status__c) { 
 | 
                drId.add(dr.Id); 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
    List<Event__c> ecList = [Select Id, ActivityDate__c, AccountParentId__c, AccountParentParentId__c from Event__c where AccountParentId__c <> null and Daily_Report__c in :drId]; 
 | 
    for (Event__c ec : ecList) { 
 | 
        // 報告日は現在日時の前後100日以内のみ対応 
 | 
        Integer days = ec.ActivityDate__c.daysBetween(Date.today()); 
 | 
        if (days >= -ControllerUtil.ReportDayRange && days <= ControllerUtil.ReportDayRange) { 
 | 
            /* 
 | 
            accParentList.add(ec.AccountParentId__c); 
 | 
            actDateList1.add(ec.ActivityDate__c); 
 | 
            if (!String.isBlank(ec.AccountParentParentId__c)) { 
 | 
                accParentParentList.add(ec.AccountParentParentId__c); 
 | 
                actDateList2.add(ec.ActivityDate__c); 
 | 
            } 
 | 
            */ 
 | 
            eIdList.add(ec.Id); 
 | 
        } 
 | 
    } 
 | 
     
 | 
    // 活動1,2,3を空更新 
 | 
    List<Activity_History_Daily_Report__c> ahdrList = [select Id from Activity_History_Daily_Report__c where EventC_ID__c in :eIdList]; 
 | 
    List<Event_Oppotunity__c> eoList = [select Id from Event_Oppotunity__c where EventC_ID__c in :eIdList]; 
 | 
    List<Event_Service__c> esList = [select Id from Event_Service__c where EventC_ID__c in :eIdList]; 
 | 
     
 | 
    if (ahdrList.size() > 0) update ahdrList; 
 | 
    if (eoList.size() > 0) update eoList; 
 | 
    if (esList.size() > 0) update esList; 
 | 
     
 | 
    //ControllerUtil.updateAccountMonth(accParentList, actDateList1, accParentParentList, actDateList2); 
 | 
} 
 |