/*
 * Author: Yanan Chen
 * Created Date: 02/14/2022
 * Purpose: Utility class for describe layouts
 * Test Class: NewAndEditRepairSubOrderController
 * History: 
 *      02/14/2022 - Yanan Chen - Initial Code.
 * 
 * */
global class NewAndEditRepairSubOrderController extends NewAndEditBaseController 
{
    public String contactsInfo {set;get;}//key sfid;value awsid
    public String PIPL_Input_Account_Error_Msg{set;get;}
    public String contactId{set;get;}//For Lookup field
    public String staticResourceContact {get; set;}
    //zhj MEBG新方案改造 2022-11-29 start
    public String staticResourceV2 {get; set;}
    //zhj MEBG新方案改造 2022-11-29 end
    public NewAndEditRepairSubOrderController(ApexPages.StandardController controller) {
        List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('RepairSubOrder__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);
        }
        LookUpOverrideFields.add('Receiver__c');
        LookUpOverrideFields.add('Applicanter__c');
        //contactId = LookUpOverrideFieldsMapJson;
        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());
        }
        staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));
        //zhj MEBG新方案改造 2022-11-29 start
        staticResourceV2 = JSON.serialize(PIHelper.getPIIntegrationInfo('RepairSubOrder__cV2'));
        //zhj MEBG新方案改造 2022-11-29 end
    }

    
    @RemoteAction
    global static Response saveRepairSubOrder(String leadJson,String transId,Boolean isNew) {
        return save(new RepairSubOrder__c(),leadJson,transId,isNew);
    }
}