function regis_form($values = null, $primary_only = false, $show_cc_form = true, $show_new_user_form = true, $meta = array())
 {
     global $event_details, $epl_error, $email_regis_form;
     $email_regis_form = '';
     if (epl_is_empty_array($event_details)) {
         $this->ecm->setup_event_details((int) $_REQUEST['event_id']);
     }
     $data = array();
     $data['forms'] = '';
     $action = epl_get_element('epl_action', $_GET);
     if ($this->mode == 'edit') {
         //not overview
         $_data = apply_filters('epl_regis_form_edit_mode', $_REQUEST);
         $this->_set_relevant_data();
         $this->set_event_capacity_info();
         //
         $this->ok_to_proceed();
         //Are there available spaces for the dates, times, prices in the cart?
         $this->event_snapshot();
     }
     if (epl_regis_flow() == 2 && $action == 'regis_form' || $this->mode == 'overview' && $action == 'show_cart_overview' || $action == 'payment_page') {
         //overview mode comes after user enters their info in the fields and submits
         if ($_GET['epl_action'] != 'payment_page') {
             //$this->_set_relevant_data( '_attendee_info', $_POST ); //from the regis form, add to session
             //$this->add_registration_to_db( $this->current_data ); //create the record
         }
         $data['cc_form'] = '';
         if ($this->has_selected_cc_payment() && $show_cc_form && !epl_is_zero_total() && !epl_is_waitlist_flow()) {
             $_f = epl_cc_billing_fields();
             $gateway_info = $this->get_gateway_info();
             $accepted_cards = (array) $gateway_info['_epl_accepted_cards'];
             //Temp solution
             foreach ($_f['epl_cc_billing_fields']['_epl_cc_card_type']['options'] as $k => $v) {
                 if (!in_array($k, $accepted_cards)) {
                     unset($_f['epl_cc_billing_fields']['_epl_cc_card_type']['options'][$k]);
                 }
             }
             $_field_args = array('section' => $_f['epl_cc_billing_fields'], 'fields_to_display' => array_keys($_f['epl_cc_billing_fields']), 'meta' => array('_view' => 0, '_type' => 'ind', 'value' => $_POST));
             $data['_f'] = $this->epl_util->render_fields($_field_args);
             if ($this->has_selected_cc_payment(null, true) == '_stripe') {
                 $egm = $this->epl->load_model('epl-gateway-model');
                 $data['cc_form'] = $egm->setup_stripe_form();
             } else {
                 $data['cc_form'] = $this->epl->load_view($this->dest . '/registration/regis-cc-form', $data, true);
             }
         }
     }
     $this->num_events_in_cart = 0;
     if (is_null($values)) {
         $values = $this->get_cart_values('_events');
     } else {
         $values = $values['_events'];
     }
     if (empty($values)) {
         return $this->epl_util->epl_invoke_error(20);
     }
     $r = '';
     $data['forms'] .= $this->get_user_list_dd();
     //$events = array_keys( $values['_epl_start_date'] );
     //if ( epl_sc_is_enabled() && epl_get_num_events_in_cart() > 1 ) {
     $is_waitlist = !empty($meta['waitlist_flow']) || epl_is_waitlist_flow();
     if (version_compare(epl_regis_plugin_version(), '1.4', '>=') && epl_sc_is_enabled() && epl_get_setting('epl_sc_options', 'epl_sc_forms_to_use') == 1) {
         if (!$primary_pulled) {
             $data['forms'] .= $this->get_registration_forms(array('scope' => $is_waitlist ? 'waitlist' : 'ticket_buyer', 'process' => 'esc', 'forms' => 'epl_sc_primary_regis_forms', 'price_name' => '', 'date_display' => '', 'price_id' => null));
             $data['forms'] .= $this->get_new_user_form($show_new_user_form);
             $primary_pulled = true;
         }
         $_cart = $this->get_cart_values('_dates');
         $attendee_forms = epl_get_setting('epl_sc_options', 'epl_sc_addit_regis_forms');
         if (!epl_is_empty_array($attendee_forms) && !epl_is_waitlist_flow()) {
             foreach ((array) $_cart['_att_quantity'] as $event_id => $quantities) {
                 if (!isset($values[$event_id])) {
                     continue;
                 }
                 setup_event_details($event_id);
                 $reset_count = true;
                 foreach ($quantities as $price_id => $qty) {
                     $attendee_qty = is_array($qty) ? array_sum($qty) : $qty;
                     if ($attendee_qty > 0) {
                         $data['forms'] .= $this->get_registration_forms(array('scope' => 'regis_forms', 'event_id' => $event_id, 'process' => 'esc', 'forms' => 'epl_sc_addit_regis_forms', 'attendee_qty' => $attendee_qty, 'price_id' => $price_id, 'date_display' => '', 'reset_count' => $reset_count, 'price_name' => $event_details['_epl_price_name'][$price_id]));
                         $reset_count = false;
                     }
                 }
             }
         }
     } else {
         $primary_pulled = false;
         $_cart = $this->get_cart_values('_dates');
         $this->pulling_forms = 'pri';
         $this->num_events_in_cart = count($values);
         foreach ($values as $event_id => $event_dates) {
             if (!empty($meta['event_id']) && $meta['event_id'] != $event_id) {
                 continue;
             }
             setup_event_details($event_id);
             //display the ticket purchaser form.
             //we need to combine primary forms so the info is only displayed once.
             if (!$primary_pulled) {
                 $data['forms'] .= $this->get_registration_forms(array('scope' => $is_waitlist ? 'waitlist' : 'ticket_buyer', 'event_id' => $event_id, 'process' => 'non_esc', 'forms' => '_epl_primary_regis_forms', 'price_name' => '', 'date_display' => '', 'price_id' => null));
                 //$primary_pulled = true;
             }
         }
         $data['forms'] .= $this->get_new_user_form($show_new_user_form);
         $this->pulling_forms = 'att';
         //if ( !$primary_only ) {
         if (!epl_is_waitlist_flow()) {
             foreach ($values as $event_id => $event_dates) {
                 //if ( epl_is_empty_array( epl_get_element( '_epl_addit_regis_forms', $event_details ) ) )
                 // continue;
                 setup_event_details($event_id);
                 foreach ((array) $_cart['_att_quantity'][$event_id] as $price_id => $qty) {
                     $attendee_qty = is_array($qty) ? array_sum($qty) : $qty;
                     if ($attendee_qty > 0) {
                         $data['forms'] .= $this->get_registration_forms(array('scope' => 'regis_forms', 'event_id' => $event_id, 'process' => 'non_esc', 'forms' => '_epl_addit_regis_forms', 'attendee_qty' => $attendee_qty, 'price_id' => $price_id, 'date_display' => '', 'price_name' => $event_details['_epl_price_name'][$price_id]));
                     }
                 }
             }
             //$data['forms'] .= $this->get_registration_forms( array( 'scope' => 'regis_forms', 'event_id' => $event_id, 'forms' => '_epl_addit_regis_forms', 'attendee_qty' => $attendee_qty ) );
             //$r .= $thiis->epl->load_view( 'front/registration/regis-page', $data, true );
         }
     }
     //TODO - temp solution
     $egm = $this->epl->load_model('epl-gateway-model');
     $data['redirect_form_data'] = $egm->get_redirect_form_data();
     $r = $this->epl->load_view($this->dest . '/registration/regis-page', $data, true);
     return $r;
 }
 function process_cc()
 {
     global $cart_totals;
     $this->get_values();
     //events, dates, times, prices, quantities
     $this->erm->set_mode($GLOBALS['epl_ajax'] ? 'overview' : 'edit');
     $this->erm->setup_current_data($this->regis_meta);
     $_f = epl_cc_billing_fields();
     $gateway_info = $this->erm->get_gateway_info($_REQUEST['gateway_id']);
     $egm = $this->epl->load_model('epl-gateway-model');
     $pay_type = $gateway_info['_epl_pay_type'];
     $is_cc = $gateway_info['_epl_pay_type'] == '_pp_pro' || $gateway_info['_epl_pay_type'] == '_auth_net_aim' || $gateway_info['_epl_pay_type'] == '_firstdata' || $gateway_info['_epl_pay_type'] == '_qbmc' ? true : false;
     if ($pay_type == '_pp_pro') {
         $r = $egm->paypal_pro_process();
     } elseif ($pay_type == '_auth_net_aim') {
         $r = $egm->authnet_aim_process();
     } elseif ($pay_type == '_firstdata') {
         $r = $egm->firstdata_process();
     }
     if ($r === true) {
         $this->epl->epl_util->set_response_param('cc_processed', 1);
     }
     $this->edbm->reset_table_for_registration($_REQUEST['post_ID']);
     if ($GLOBALS['epl_ajax']) {
         return $r;
     }
     echo $r;
 }