public without sharing class OrderSplitRatioController {
	public String UsId { get; set; }
	public String BsAgm { get; set; }
	public String AppSta { get; set; }
	public String new_profileId { get; set; }
	String oldResponse;
	//订单
	public Order ord { get; set; }
	public Order ra1 { get; set; }
    public Order cc { get; set; }
    public Boolean hasError { get; private set; }
	// 订单ID
    public Id raid { get; private set; }
    public String baseUrl { get; private set; }

	public OrderSplitRatioController() {
		baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
        raid = ApexPages.currentPage().getParameters().get('raid');
	}
	public OrderSplitRatioController(ApexPages.StandardController stdController) {
        //Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
        baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
        raid = stdController.getId();
    }

    // 画面初始化
    public void init() {
    	//新的获取人员简档ID
        new_profileId = calendarUtil.getMemberProfileID(UserInfo.getUserId().subString(0,15));
        new_profileId = new_profileId.substring(0,15);
    	AppSta = '';
        hasError = false;
        ord = new Order();
        cc = new Order();
        List<Order> raList = [select Id, Name, Dealer__c,SplitRatio__c,CrossCooperativeDealerText__c,SplitRatioFormule__c,BS_AsistGenManger_BS__c,ApproveStatus__c from Order where Id = :raid];
        UsId = UserInfo.getUserId().subString(0, 15);
        if (raList.size() > 0) {
            ord = raList[0];
            BsAgm = raList[0].BS_AsistGenManger_BS__c;
            if(BsAgm != null){
                BsAgm = BsAgm.substring(0, 15);
            }

            if(raList[0].ApproveStatus__c == 'Submit' || raList[0].ApproveStatus__c == 'OrderSubmit'){
            	AppSta = '1';
            }
        }
        /*System.debug('AppSta='+AppSta);
        System.debug('new_profileId='+new_profileId);
        System.debug('BsAgm='+BsAgm);*/
    }
    
     // 画面初始化 UP
    public void init1() {
    	AppSta = '';
        hasError = false;
        ra1 = new Order();
        List<Order> ra1List = [select Id, Name, Dealer__c,SplitRatio__c,CrossCooperativeDealerText__c,SplitRatioFormule__c,BS_AsistGenManger_BS__c from Order where Id = :raid];
        UsId = UserInfo.getUserId().subString(0, 15);
        if (ra1List.size() > 0) {
            ra1 = ra1List[0];
        }
    }



    // 保存按钮
    public PageReference saveBtn() {
        hasError = false;
        String response = ra1.SplitRatio__c;
        if (String.isBlank(ra1.SplitRatio__c)) {
		/*String SplitRatiotext = ra1.Dealer__c +' '+ ra1.SplitRatio__c +' '+ ra1.CrossCooperativeDealerText__c;
		ra1.SplitRatiotext__c = SplitRatiotext;*/
	    update ra1;
    	}else {
    		update ra1;
    	}
        
        return null;
    }
}