高章伟
2022-02-24 2aa8da8af66aa8ae00f25831aed6bb0364176e7b
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
public with sharing class OFSDailyReportController {
    public List<Event> elist {get; private set;}
    public List<dr> drList {get; private set;}
    /** ログイン者情報 */
    public User me {get;set;}
    
    public void init(){
        
        // ログイン者情報取得
        me = [Select Id, Name, Post__c, Employee_No__c, Department, Job_Category__c, Category4__c, Category6__c, ManagerId, Manager.Email From User Where Id = :UserInfo.getUserId()];
        
        //date
        String dateStr = System.currentPageReference().getParameters().get('date');
        Date dateParam;
        if (String.isBlank(dateStr) == true) {
           dateParam = date.today().addDays(1);
        } else {
           dateParam = date.parse(dateStr);
        }
        elist =[
            select id, ActivityDate, OwnerId, Subject, whatid__c, EventC_ID__c, NextEventC_ID__c, AppCdId__c, SyncCreatedDate__c, 
                  StartDateTime, EndDateTime, DurationInMinutes, Main_Visit_Location__c, Activity_Type2__c, IsScheduled__c, BeforeActivityDate__c,
                  Purpose_Type__c, Location, Related_Opportunity1__c, Related_Service1__c, Related_Opportunity1_ID__c, Related_Service1_ID__c, 
                  WS_flg__c, HPArriveFlg__c, HPLeaveFlg__c
            from Event where ActivityDate = :dateParam and OwnerId = :me.Id order by StartDateTime];
        
        drList = new List<dr>();
       
           boolean nowEventFind = false; 
        for(Event e : elist){
            drList.add(new dr(e, !e.HPArriveFlg__c && !nowEventFind));
            if (!e.HPArriveFlg__c) nowEventFind = true;
        }
    }
    
    public class dr{
        public Event rec {get; private set;}
        public Date getActivityDate() {
            return starttime.date();
        }
        public datetime starttime {get; private set;}
        public datetime endtime {get; private set;}
        
        public String subject {get; private set;}
        public String activityType {get;private set;}
        public String location {get;private set;}
        public Boolean arriveFlg {get;private set;}
        public Boolean leaveFlg {get;private set;}
        public Boolean nowEvent {get;private set;}
        public String ecId {get;private set;}
        public String eId {get;private set;}
        public Boolean wsFlg {get;private set;}
        
        public dr(Event e, boolean nowEventFlg) {
            rec = e;
            starttime = e.StartDateTime;
            endtime = e.EndDateTime;
            subject = e.Subject;
            location = e.Location;
            //ecId = e.Id;
            eId = e.Id;
            arriveFlg = e.HPArriveFlg__c;
            leaveFlg = e.HPLeaveFlg__c;
            activityType = e.Activity_Type2__c;
            nowEvent = nowEventFlg;
            wsFlg = e.WS_flg__c;
        }
    }
}