public class Event_CommentController{
    
    /**　コンストラクタ　*/
    public Event_CommentController() {
        String eventId = System.currentPageReference().getParameters().get('Id');
        this.u = [select id, Post__c from User where id =:UserInfo.getUserId()];
        //this.e = [select id, Manager_Comment__c, Accounting_Comment__c from Event__c where id =:eventId];
        this.e = [select id, Minister_Comment__c, Manager_Comment__c from Event__c where id =:eventId];
        this.comment = '';
        this.message2 = '';
        
        if(u.Post__c != '部长' && u.Post__c != '副部长' && u.Post__c != '总监' && u.Post__c != '副总监' && u.Post__c != '经理' && u.Post__c != '副经理'){
            this.message1 = System.Label.Error_Message26;
        }
        else{
            this.message1 = System.Label.Message_004;
            
            if(u.Post__c == '部长' || u.Post__c == '副部长' || u.Post__c == '总监' || u.Post__c == '副总监'){
                //this.comment = e.Manager_Comment__c;
                this.comment = e.Minister_Comment__c;
            }
            else if(u.Post__c == '经理' || u.Post__c == '副经理'){
                //this.comment = e.Accounting_Comment__c;
                this.comment = e.Manager_Comment__c;
            }
        }
    }
    
    public User u{get;set;}
    public Event__c e{get;set;}
    public String comment{get;set;}
    public String message1{get;set;}
    public String message2{get;set;}
    
    /** 初期処理 */
    /*public PageReference init(){
        String eventId = System.currentPageReference().getParameters().get('Id');
        this.u = [select id, Post__c from User where id =:UserInfo.getUserId()];
        this.e = [select id, Manager_Comment__c, Accounting_Comment__c from Event where id =:eventId];
        this.comment = '';
        this.message2 = '';
        
        if(u.Post__c != '部长' && u.Post__c != '经理'){
            this.message1 = System.Label.Error_Message26;
        }
        else{
            this.message1 = System.Label.Message_004;
            
            if(u.Post__c == '部长'){
                this.comment = e.Manager_Comment__c;
            }
            else if(u.Post__c == '经理'){
                this.comment = e.Accounting_Comment__c;
            }
        }
        return null;
    }*/
    
    public PageReference save(){
        if(u.Post__c == '部长' || u.Post__c == '副部长' || u.Post__c == '总监' || u.Post__c == '副总监'){
            //e.Manager_Comment__c = this.comment;
            e.Minister_Comment__c = this.comment;
        }
        else if(u.Post__c == '经理' || u.Post__c == '副经理'){
            //e.Accounting_Comment__c = this.comment;
            e.Manager_Comment__c = this.comment;
        }
        
        update e;
        
        this.message2 = System.Label.Save_Completion;
        

        return null;
    }
}