/*
 * Author: Yanan Chen
 * Created Date: 03/03/2022
 * Purpose: Utility class for describe layouts
 * Test Class: NewAndEditLoanerUserController  
 * History: 
 *      03/03/2022 - Yanan Chen - Initial Code.
 * 
 * */
global class NewAndEditLoanerUserController extends NewAndEditBaseController {

    public String PIPL_Input_Account_Error_Msg{set;get;}
    public String contactId{set;get;}//For Lookup field
    public String staticResourceContact {get; set;}
    
    public NewAndEditLoanerUserController (ApexPages.StandardController controller){
        List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('loaner_user__c').getDescribe().fields.getMap().keyset());  
        // Add fields to controller. This is to avoid the SOQL error in visualforce page
        if(!Test.isRunningTest()){
            controller.addFields(fieldList); // contact lookup
        }
        LookUpOverrideFields.add('Contact__c');
        Init(controller.getRecord());
        //添加项
        PIPL_Input_Account_Error_Msg = label.PIPL_Input_Account_Error_Msg;
        // SObject obj = controller.getRecord();
        // if(obj.Id == null){
        //     //初始化加载值
        //     obj.put('OwnerId',UserInfo.getUserId());
        // }
        //contact信息（搜索查询query url用）
        staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));
    }

    
    @RemoteAction
    global static Response saveLoanerUser(String sobJson, String transId, Boolean isNew){
        system.debug('JSON Payload:' + sobJson);
        return save(new loaner_user__c(), sobJson, transId, isNew);
    }
}