<?php
$selected_plans = isset($data->model->field_options->subscription_plans) ? maybe_unserialize($data->model->field_options->subscription_plans) : array();
$subscription_plans = array();
if(class_exists('RMSubscriptions')){
    $subscription_plans = RMSubscriptions_DBManager::get_subscription_list();
}
$options = '';
$plans = array();
if(!empty($subscription_plans)){
    foreach($subscription_plans as $sub){
        $plans[$sub->id] = $sub->name;
        if(!empty($selected_plans) && in_array($sub->id, $selected_plans)){
            $options .= '<option value="'. esc_attr__($sub->id).'" selected>'.esc_html__($sub->name).'</option>';
        }else{
            $options .= '<option value="'. esc_attr__($sub->id).'">'.esc_html__($sub->name).'</option>';
        }
    }
}
$form->addElement(new Element_Select("<b>" . RM_UI_Strings::get('LABEL_SELECT_SUBSCRIPTION_PLANS') . "</b>", "subscription_plans", $plans, array("multiple"=>true,"required"=>true, "id" => "rm_subscription_plans", "value" => $selected_plans, "class" => "rm_subscription_plans rm_static_field", "longDesc"=> RM_UI_Strings::get('HELP_TEXT_SELECT_SUBSCRIPTION_PLANS'))));

?>
<script>
jQuery(document).ready(function(e){
    //jQuery('#rm_subscription_plans').attr('multiple', true);
});

</script>
<style>
    #rm_subscription_plans{
       min-height: 100px;
       margin: 0px;
       width: 80%;
    }
    
    #rm_subscription_plans option{
       padding: 5px 5px;
       width: 100%;
    }
    
</style>

