/**
  * 		display_country_states
  *
  * 		@access 	public
  * 		@param 	string 		$CNT_ISO
  * 		@return 		string
  */
 public function display_country_states($CNT_ISO = '')
 {
     $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
     if (!$CNT_ISO) {
         return '';
     }
     // for ajax
     remove_all_filters('FHEE__EEH_Form_Fields__label_html');
     remove_all_filters('FHEE__EEH_Form_Fields__input_html');
     add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
     add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
     $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
     //			echo '<h4>$CNT_ISO : ' . $CNT_ISO . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //			global $wpdb;
     //			echo '<h4>' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
     //			EEH_Debug_Tools::printr( $states, '$states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     if ($states) {
         foreach ($states as $STA_ID => $state) {
             if ($state instanceof EE_State) {
                 //STA_abbrev 	STA_name 	STA_active
                 $state_input_types = array('STA_abbrev' => array('type' => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'mid-text'), 'STA_name' => array('type' => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'regular-text'), 'STA_active' => array('type' => 'RADIO_BTN', 'input_name' => 'states[' . $STA_ID . ']', 'options' => $this->_yes_no_values, 'use_desc_4_label' => true));
                 $this->_template_args['states'][$STA_ID]['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($state, $state_input_types);
                 $query_args = array('action' => 'delete_state', 'STA_ID' => $STA_ID, 'CNT_ISO' => $CNT_ISO, 'STA_abbrev' => $state->abbrev());
                 $this->_template_args['states'][$STA_ID]['delete_state_url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, GEN_SET_ADMIN_URL);
             }
         }
     } else {
         $this->_template_args['states'] = FALSE;
     }
     //		EEH_Debug_Tools::printr( $this->_template_args['states'], 'states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'add_new_state'), GEN_SET_ADMIN_URL);
     $state_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', $this->_template_args, TRUE);
     if (defined('DOING_AJAX')) {
         $notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
         echo json_encode(array('return_data' => $state_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors']));
         die;
     } else {
         return $state_details_settings;
     }
 }
 /**
  *        generate_question_form_inputs_for_object
  *
  * @access    protected
  * @param bool|object $object $object
  * @param    array    $input_types
  * @return        array
  */
 static function generate_question_form_inputs_for_object($object = FALSE, $input_types = array())
 {
     if (!is_object($object)) {
         return FALSE;
     }
     $inputs = array();
     $fields = $object->get_model()->field_settings(FALSE);
     //		$pk = $object->ID(); <<< NO!
     //		printr( $object, get_class( $object ) . '<br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     //		printr( $fields, '$fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     //		printr( $input_types, '$input_types  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
     foreach ($fields as $field_ID => $field) {
         if ($field instanceof EE_Model_Field_Base) {
             //			echo '<h4>$field_ID : ' . $field_ID . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
             //			printr( $field, '$field  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
             if (isset($input_types[$field_ID])) {
                 // get saved value for field
                 $value = $object->get($field_ID);
                 //				echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                 // if no saved value, then use default
                 $value = $value !== NULL ? $value : $field->get_default_value();
                 //			if ( $field_ID == 'CNT_active' )
                 //				echo '<h4>$value : ' . $value . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
                 // determine question type
                 $type = isset($input_types[$field_ID]) ? $input_types[$field_ID]['type'] : 'TEXT';
                 // input name
                 $input_name = isset($input_types[$field_ID]) && isset($input_types[$field_ID]['input_name']) ? $input_types[$field_ID]['input_name'] . '[' . $field_ID . ']' : $field_ID;
                 // css class for input
                 $class = isset($input_types[$field_ID]['class']) && !empty($input_types[$field_ID]['class']) ? ' ' . $input_types[$field_ID]['class'] : '';
                 // whether to apply htmlentities to answer
                 $htmlentities = isset($input_types[$field_ID]['htmlentities']) ? $input_types[$field_ID]['htmlentities'] : TRUE;
                 // whether to apply htmlentities to answer
                 $label_b4 = isset($input_types[$field_ID]['label_b4']) ? $input_types[$field_ID]['label_b4'] : FALSE;
                 // whether to apply htmlentities to answer
                 $use_desc_4_label = isset($input_types[$field_ID]['use_desc_4_label']) ? $input_types[$field_ID]['use_desc_4_label'] : FALSE;
                 // create EE_Question_Form_Input object
                 $QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_ID' => 0, 'QST_display_text' => $field->get_nicename(), 'QST_type' => $type)), EE_Answer::new_instance(array('ANS_ID' => 0, 'QST_ID' => 0, 'REG_ID' => 0, 'ANS_value' => $value)), array('input_id' => $field_ID . '-' . $object->ID(), 'input_name' => $input_name, 'input_class' => $field_ID . $class, 'input_prefix' => '', 'append_qstn_id' => FALSE, 'htmlentities' => $htmlentities, 'label_b4' => $label_b4, 'use_desc_4_label' => $use_desc_4_label));
                 // does question type have options ?
                 if (in_array($type, array('DROPDOWN', 'SINGLE', 'MULTIPLE')) && isset($input_types[$field_ID]) && isset($input_types[$field_ID]['options'])) {
                     foreach ($input_types[$field_ID]['options'] as $option) {
                         $option = stripslashes_deep($option);
                         $option_id = !empty($option['id']) ? $option['id'] : 0;
                         $QSO = EE_Question_Option::new_instance(array('QSO_value' => (string) $option_id, 'QSO_desc' => $option['text'], 'QSO_deleted' => FALSE));
                         // all QST (and ANS) properties can be accessed indirectly thru QFI
                         $QFI->add_temp_option($QSO);
                     }
                 }
                 // we don't want ppl manually changing primary keys cuz that would just lead to total craziness man
                 if ($field_ID == $object->get_model()->primary_key_name()) {
                     $QFI->set('QST_disabled', TRUE);
                 }
                 //printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                 $inputs[$field_ID] = $QFI;
                 //			if ( $field_ID == 'CNT_active' ) {
                 //				printr( $QFI, '$QFI  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
                 //			}
             }
         }
     }
     return $inputs;
 }
 /**
  * This preps dropdowns that are specialized.
  *
  * @since  4.6.0
  *
  * @param EE_Question_Form_Input $QFI
  *
  * @return EE_Question_Form_Input
  */
 protected static function _load_specialized_dropdowns($QFI)
 {
     switch ($QFI->get('QST_type')) {
         case 'STATE':
             $QFI = self::generate_state_dropdown($QFI);
             break;
         case 'COUNTRY':
             $QFI = self::generate_country_dropdown($QFI);
             break;
     }
     return $QFI;
 }
 /**
  * 		generate s HTML for the billing info form during registration
  * 		@access 		protected
  * 		@param		array	$billing_inputs - array of input field details
  * 		@param		array	$section - what part of the billing info form, "address", "credit_card", or "other"
  * 		@return 		string
  */
 protected function _generate_billing_info_form_fields($billing_inputs = array(), $section = FALSE)
 {
     do_action('AHEE_log', __FILE__, __FUNCTION__, '');
     if (empty($billing_inputs) || !$section) {
         return;
     }
     global $wp_filter, $css_class;
     // fill out section name
     $section = '_billing_info_' . $section . '_fields';
     // if you don't behave - this is what you're gonna get !!!
     $output = '';
     // cycle thru billing inputs
     foreach ($billing_inputs as $input_key => $billing_input) {
         // is the billing input in the requested section	?
         if (in_array($input_key, $this->{$section})) {
             // required fields get a *
             $required = $billing_input['required'] ? EEH_Form_Fields::prep_required(array('class' => 'required', 'label' => '<em>*</em>')) : '';
             // answer
             $answer = EE_Registry::instance()->REQ->is_set($input_key) ? EE_Registry::instance()->REQ->get($input_key) : $billing_input['value'];
             if ($input_key == '_reg-page-billing-card-exp-date-mnth-' . $this->_gateway_name) {
                 // Credit Card MONTH
                 add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_month_input_wrap'), 10, 2);
                 remove_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2);
                 remove_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2);
                 $output .= EEH_Form_Fields::select(__('Expiry Date', 'event_espresso'), $answer, EEH_Form_Fields::two_digit_months_dropdown_options(), $input_key, $input_key, $css_class . ' ee-credit-card-month display-inline small-txt', $required, '', '', '', FALSE, TRUE, FALSE);
                 remove_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_month_input_wrap'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2);
                 $output .= "\n\t\t\t" . '&nbsp;/&nbsp;';
             } elseif ($input_key == '_reg-page-billing-card-exp-date-year-' . $this->_gateway_name) {
                 // Credit Card YEAR
                 // remove label
                 add_filter('FHEE__EEH_Form_Fields__label_html', array('EEH_Form_Fields', 'remove_label_keep_required_msg'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_year_input_wrap'), 10, 2);
                 remove_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2);
                 remove_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2);
                 $output .= EEH_Form_Fields::select(__('Year', 'event_espresso'), $answer, EEH_Form_Fields::next_decade_two_digit_year_dropdown_options(), $input_key, $input_key, $css_class . ' ee-credit-card-year display-inline small-txt', $required, '', '', '', FALSE, TRUE, FALSE);
                 // remove filter that removes label, or else no other inputs will have labels
                 remove_filter('FHEE__EEH_Form_Fields__label_html', array('EEH_Form_Fields', 'remove_label_keep_required_msg'), 10, 2);
                 remove_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'reg_form_billing_cc_year_input_wrap'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__label_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_label_wrap'), 10, 2);
                 add_filter('FHEE__EEH_Form_Fields__input_html', array('EED_Single_Page_Checkout', 'reg_form_form_field_input__wrap'), 10, 2);
                 $output .= "\n\t\t\t" . '<span class="small-text lt-grey-text">' . __('(mm/yy)', 'event_espresso') . '</span>';
             } else {
                 // create question form input
                 $QFI = new EE_Question_Form_Input(EE_Question::new_instance(array('QST_display_text' => $billing_input['label'], 'QST_system' => $billing_input['db-col'], 'QST_type' => $billing_input['input'], 'QST_required' => $billing_input['required'])), EE_Answer::new_instance(array('ANS_value' => $answer)), array('input_name' => $input_key, 'input_id' => $input_key, 'input_class' => $css_class, 'input_prefix' => '', 'append_qstn_id' => FALSE));
                 // add options
                 if (isset($billing_input['options'])) {
                     $options = is_array($billing_input['options']) ? $billing_input['options'] : explode(',', $billing_input['options']);
                     foreach ($options as $option) {
                         $QSO = EE_Question_Option::new_instance(array('QSO_value' => $option, 'QSO_desc' => $option));
                         $QFI->add_temp_option($QSO);
                     }
                 }
                 $output .= EEH_Form_Fields::generate_form_input($QFI);
             }
         }
         // end if ( in_array( $input_key, $this->$section ))
     }
     // end foreach( $billing_inputs as $input_key => $billing_input )
     return $output;
 }