public with sharing class OpportunityAAdvancedController {

	public Opportunity opp { get; set; }
	public String oppId { get; private set; }
	 public String baseUrl { get; set; }

	public Boolean FV3000Flag { get; private set; }
	public Boolean FVMPERSFlag { get; private set; }
	public Boolean SPINFlag { get; private set; }
	public Boolean VS200Flag { get; private set; }
	public Boolean PhaseviewFlag {get; private set; }

	public OpportunityAAdvancedController() { 
		
		baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
        String path = URL.getCurrentRequestUrl().getPath();
        if (path.indexOf('/apex') > 0) {
            baseUrl += path.substring(0, path.indexOf('/apex'));
        }
        oppId = System.currentPageReference().getParameters().get('oppid');

		List<Opportunity> oppList = [select Id, 
		                             OppOtherDescription__c,OppPartyProduct__c,AC_objective_FVMPE_RS__c,
		                             Camera_SPIN__c,Customization_FV3000__c,Customization_FVMPE_RS__c,Detector_FV3000__c,
		                             detector_FVMPE_RS__c,FL_Camera_VS200__c,Frame_FV3000__c,Frame_FVMPE_RS__c,
		                             IR_laser_FVMPE_RS__c,Laser_FV3000__c,Laser_SPIN__c,Loader_VS200__c,Observation_Set_VS200__c,
		                             Remark_FV3000__c,Remark_FVMPE_RS__c,Remark_SPIN__c,Scanner_FV3000__c,Scanner_SPIN__c,
		                             SIM_FVMPE_RS__c,Software_FV3000__c,Software_FVMPE_RS__c,Software_SPIN__c,Software_VS200__c,
		                             Upgrade_SPIN__c,Upgrade_VS200__c,SystemNew__c 
		                             from Opportunity where Id = :oppId];
		if (oppList != null && oppList.size() >0) {
			opp = oppList[0];
		}
	}
	public OpportunityAAdvancedController(ApexPages.StandardController controller) {
		//获取询价ID
		oppId = controller.getRecord().Id;
		
		baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
        String path = URL.getCurrentRequestUrl().getPath();
        if (path.indexOf('/apex') > 0) {
            baseUrl += path.substring(0, path.indexOf('/apex'));
        }

		List<Opportunity> oppList = [select Id,
		                             OppOtherDescription__c,OppPartyProduct__c,AC_objective_FVMPE_RS__c,
		                             Camera_SPIN__c,Customization_FV3000__c,Customization_FVMPE_RS__c,Detector_FV3000__c,
		                             detector_FVMPE_RS__c,FL_Camera_VS200__c,Frame_FV3000__c,Frame_FVMPE_RS__c,
		                             IR_laser_FVMPE_RS__c,Laser_FV3000__c,Laser_SPIN__c,Loader_VS200__c,Observation_Set_VS200__c,
		                             Remark_FV3000__c,Remark_FVMPE_RS__c,Remark_SPIN__c,Scanner_FV3000__c,Scanner_SPIN__c,
		                             SIM_FVMPE_RS__c,Software_FV3000__c,Software_FVMPE_RS__c,Software_SPIN__c,Software_VS200__c,
		                             Upgrade_SPIN__c,Upgrade_VS200__c,Light_sheet_illuminator_Phaseview__c,Laser_Phaseview__c,
		                             Camera_Phaseview__c,SystemNew__c 
		                             from Opportunity where Id = :oppId];
		if (oppList != null && oppList.size() >0) {
			opp = oppList[0];
		}
		

	}

	public PageReference init() {

		FV3000Flag = false;
		FVMPERSFlag = false;
		SPINFlag = false;
		VS200Flag = false;
		if (opp != null ) {
			// FV3000Flag = 'FV3000'.equals(opp.OppSystem__c) ? true:false;
			// FVMPERSFlag = 'FVMPE-RS'.equals(opp.OppSystem__c) ? true:false;
			// SPINFlag = 'SPIN'.equals(opp.OppSystem__c) ? true:false;
			// VS200Flag = 'VS200'.equals(opp.OppSystem__c) ? true:false;
			// system.debug(opp.SystemNew__c);
			String str = opp.SystemNew__c;
			if(str != null){
				FV3000Flag = str.contains('FV3000');
				FVMPERSFlag = str.contains('FVMPE-RS');
				SPINFlag = str.contains('SPIN');
				VS200Flag = str.contains('VS200');
				PhaseviewFlag = str.contains('Phaseview');
			}

		}

		return null;
	}

	public PageReference saveLine() {

		if (opp != null) {
			update opp;
		}

		return null;
	}
}