public with sharing class StageProgressBarExtension {
    public String targetId { get; set; }
    public String targetStageName { get; set; }
    public String recordTypeName { get; private set; }
    public List<String> stages { get; set; }
    
    public StageProgressBarExtension(ApexPages.StandardController controller) {
        Opportunity opp = [select RecordTypeId, RecordType.DeveloperName from Opportunity where Id = :controller.getRecord().Id];
        recordTypeName = opp.RecordType.DeveloperName;
        
        stages = SoapApi.getPicklistValueByRecordType('Opportunity', new String[]{opp.RecordTypeId}, 'StageName');
        /*
        stages = new List<String>();
        PartnerSoapSforceCom.DescribeLayoutResult dlr = SoapApi.describeLayout('Opportunity', null, new String[]{opp.RecordTypeId});
        for (Integer i = 0; i < dlr.layouts.size(); i++) {
            String recordTypeId = dlr.recordTypeMappings[i].recordTypeId;
            PartnerSoapSforceCom.PicklistForRecordType[] ptrList =  dlr.recordTypeMappings[i].picklistsForRecordType;
            for (Integer j = 0; j < ptrList.size(); j++) {
                if (ptrList[j].picklistName == 'StageName') {
                    PartnerSoapSforceCom.PicklistEntry[] pe = ptrList[j].picklistValues;
                    for (Integer k = 0; k < pe.size(); k++) {
                        stages.add(pe[k].label);
                    }
                    break;
                }
            }
        }
        */
    }
    
    public void updateOpp() {
        Opportunity opp = new Opportunity(
            Id = targetId,
            StageName = targetStageName
        );
        StaticParameter.StageProgressBarUpdate = True;
        update opp;
    }
}