public static function get_instance()
 {
     if (!self::$instance) {
         self::$instance = new EPL_registration_model();
     }
     return self::$instance;
 }
 function populate_db_tables($post_ID = null, $event_id = null)
 {
     //echo "<pre class='prettyprint'>" . __LINE__ . "> " . print_r( (memory_get_usage( true ) / 1048576 ), true ) . "</pre>";
     if (!$post_ID) {
         set_time_limit(300);
         @ini_set('memory_limit', '1024M');
     }
     EPL_registration_model::get_instance()->assign_incremental_id($post_ID);
     global $event_details, $regis_details, $post, $wpdb;
     $this->debug = false;
     $regis_list = $this->get_the_data_new($post_ID);
     $csv_row = '';
     $form_data_array = array();
     $form_data_array_header = array();
     $main_table = array_flip($this->tables('wp_epl_registration'));
     $payment_table = array_flip($this->tables('wp_epl_regis_payment'));
     if (is_null($regis_list)) {
         exit('no records found');
     }
     //echo "<pre class='prettyprint'>" . __LINE__ . "> " . print_r( epl_memory_get_usage(), true ) . "</pre>";
     foreach ($regis_list as $regis) {
         $regis_id = $regis->ID;
         //if ( $regis_id == 12973 )
         //  $this->debug = true;
         $this->ecm->setup_regis_details($regis_id);
         $_regis_key = $regis_details['__epl']['_regis_id'];
         $regis_event_data = $regis_details['__epl'][$_regis_key];
         $user_id = $this->find_user_id_for_regis($regis_id);
         if ($this->debug) {
             echo "<pre class='prettyprint'>" . __LINE__ . "> " . print_r($regis_details, true) . "</pre>";
         }
         #################
         # insert main table data
         #################
         $ins = array();
         if (isset($regis_event_data['cart_totals'])) {
             $ins = array_intersect_key($regis_event_data['cart_totals']['money_totals'], $main_table);
         } else {
             foreach ($main_table as $k => $v) {
                 $ins[$k] = epl_get_element('_epl_' . $k, $regis_details);
             }
         }
         $ins['regis_id'] = $regis_id;
         $ins['regis_key'] = $_regis_key;
         $ins['status'] = $regis_details['_epl_regis_status'];
         $ins['regis_date'] = $regis_details['post_date'];
         $ins['user_id'] = $user_id;
         $regis_data = $this->epl->epl_util->get_the_regis_dates_times_prices($regis_id, true);
         $ins['num_events'] = count($regis_data);
         $wpdb->insert($wpdb->epl_registration, $ins);
         $epl_registration_id = $wpdb->insert_id;
         $total_tickets = 0;
         #################
         # insert payment data, added the $payment_data as of 2.0
         #################
         $payment_data = epl_get_element('_epl_payment_data', $regis_details, array());
         if (empty($payment_data)) {
             $payment_data[] = $regis_details;
         }
         foreach ($payment_data as $k => $p) {
             $ins = array('regis_id' => $regis_id, 'payment_amount' => $p['_epl_payment_amount'], 'payment_date' => !empty($p['_epl_payment_date']) ? date('Y-m-d H:i:s', epl_get_date_timestamp($p['_epl_payment_date'])) : null, 'payment_method_id' => epl_get_element('_epl_payment_method', $p, 0), 'transaction_id' => $p['_epl_transaction_id'], 'note' => $p['note']);
             $wpdb->insert($wpdb->epl_regis_payment, $ins);
         }
         $this->primary_pulled = false;
         foreach ($regis_data as $event_id => $date_data) {
             $this->form_no = 0;
             setup_event_details($event_id);
             #################
             # insert event specific totals
             #################
             $event_totals = (array) $regis_event_data['_events'][$event_id]['money_totals'];
             $event_counts = (array) $regis_event_data['_events'][$event_id]['_att_quantity'];
             $num_dates = $event_details['_epl_event_type'] != 7 ? count($regis_data[$event_id]) : 1;
             $ins = array('regis_id' => $regis_id, 'event_id' => $event_id, 'num_dates' => $num_dates, 'subtotal' => epl_get_element('subtotal', $event_totals, 0), 'surcharge' => epl_get_element('surcharge', $event_totals, 0), 'discountable_total' => epl_get_element('discountable_total', $event_totals, 0), 'non_discountable_total' => epl_get_element('non_discountable_total', $event_totals, 0), 'pre_discount_total' => epl_get_element('pre_discount_total', $event_totals, 0), 'discount_amount' => epl_get_element('discount_amount', $event_totals, 0), 'discount_code' => epl_get_element('discount_code', $event_totals), 'grand_total' => epl_get_element('grand_total', $event_totals, 0));
             $wpdb->insert($wpdb->epl_regis_events, $ins);
             $pack_regis = epl_get_element('_epl_pack_regis', $event_details) == 10;
             $purchased_tickets = (array) $regis_event_data['_dates']['_att_quantity'][$event_id];
             $tickets_to_show = array_intersect_key($purchased_tickets, $event_details['_epl_price_name']);
             #################
             # insert form data
             #################
             $this->form_data($regis_id, $_regis_key, $event_id, $tickets_to_show);
             /*
              *                                
              */
             foreach ($date_data as $date_id => $data) {
                 $times = $data['time'];
                 foreach ($times as $time_id => $time_data) {
                     if ($time_id == 'total_tickets') {
                         continue;
                     }
                     $prices = $time_data['price'];
                     foreach ($prices as $price_id => $price_data) {
                         $price_per_att = $event_totals[$price_id] / $price_data['qty'];
                         if ($price_data['qty'] > 0) {
                             for ($i = 1; $i <= $price_data['qty']; $i++) {
                                 /* if ( $pack_regis ) {
                                 
                                                                       $attendance_dates = epl_get_element( "_pack_attendance_dates_{$event_id}_{$price_id}_" . $i, $regis_details, null );
                                                                       echo "<pre class='prettyprint'>" . __LINE__ . "> " . print_r( $attendance_dates, true ) . "</pre>";
                                                                       $pack_count = count( $attendance_dates );
                                                                       $attendance_date_number = array_search( $date_id, array_keys( $attendance_dates ) ) + 1;
                                                                       } */
                                 $ins = array('regis_id' => $regis_id, 'event_id' => $event_id, 'date_id' => $date_id, 'time_id' => $time_id, 'price_id' => $price_id, 'price' => $price_data['raw_price'], 'quantity' => 1, 'total_quantity' => $price_data['qty']);
                                 if ($event_details['_epl_event_type'] != 7) {
                                     $total_tickets++;
                                 } else {
                                     $total_tickets = 1;
                                 }
                                 $wpdb->insert($wpdb->epl_regis_data, $ins);
                                 $new_id = $wpdb->insert_id;
                                 $this->update_attendance_regis_data_ids($new_id, $ins);
                             }
                         }
                     }
                 }
             }
         }
         $wpdb->update($wpdb->epl_registration, array('total_tickets' => $total_tickets == 0 ? 1 : $total_tickets), array('id' => $epl_registration_id));
         if ($this->debug) {
             exit;
         }
         //$wpdb->print_error();
     }
     //exit;
     //echo "<pre class='prettyprint'>" . __LINE__ . "> " . print_r( epl_memory_get_usage(), true ) . "</pre>";
 }
function epl_get_num_events_in_cart()
{
    return count(EPL_registration_model::get_instance()->get_events_in_cart());
}
<?php

global $event_details, $event_snapshot;
$date_specifc_time = epl_get_element('_epl_date_specific_time', $event_details, array());
$show_avail_spaces = $event_details['_epl_event_available_space_display'] == 10;
//I hate doing this in the view :(
if ($show_avail_spaces) {
    EPL_registration_model::get_instance()->event_snapshot($event_details['ID']);
    $table_data = epl_get_element($event_details['ID'], $event_snapshot, array());
}
?>

<div class="epl_section">

    <table class="epl_avail_spaces_table">
        <?php 
global $event_details;
if ($show_avail_spaces) {
    ?>
            <thead>
                <tr>
                    <th></th>
                    <th></th>
                    <th><?php 
    echo epl_e('Available Spaces');
    ?>
</th>
                </tr>
            </thead>

 function get_registration_details($post_id = null)
 {
     global $epl_current_step, $regis_details, $event_details;
     $epl_current_step = 'thank_you_page';
     $post_id = epl_nz($post_id, get_the_ID());
     $regis_meta = $this->setup_regis_details(get_the_ID());
     if (!epl_user_is_admin() && epl_check_token() === false) {
         @header('HTTP/1.0 404 Not Found');
         return "<div class='epl_error'>" . epl__('You have reached this page in error.') . "</div>";
     }
     $event_id = key((array) $regis_meta['_epl_events']);
     $event_meta = $this->setup_event_details($event_id);
     //$earm = $this->epl->load_model( 'epl-regis-admin-model' );
     $erm = $this->epl->load_model('epl-registration-model');
     $ercm = $this->epl->load_model('epl-recurrence-model');
     $data['event_id'] = $event_id;
     $regis_id = $regis_details['__epl']['_regis_id'];
     epl_do_messages($regis_details['__epl'][$regis_id]['_events']);
     $data['regis_status_id'] = get_the_regis_status(null, true);
     $erm->set_mode('overview')->setup_current_data($regis_meta);
     $data['cart_data'] = $erm->show_cart();
     $data['cart_data'] = $this->epl->load_view('front/registration/regis-cart-section', $data, true);
     $data['cart_totals'] = $erm->calculate_cart_totals();
     $redirect_to = apply_filters('epl_ecm__get_registration_details__redirect_to', '');
     if ($redirect_to != '') {
         wp_redirect($redirect_to, 301);
         die;
     }
     // $data['cart_totals'] = $this->epl->load_view( 'front/registration/regis-totals-section', $data, true );
     $payment_method_id = EPL_registration_model::get_instance()->get_payment_profile_id();
     if (!epl_is_free_event()) {
         $data['gateway_info'] = $this->get_post_meta_all($payment_method_id);
     }
     $data['payment_instructions'] = $this->epl->load_view('front/registration/regis-payment-instr', $data, true);
     $data['payment_details'] = $this->epl->load_view('front/registration/regis-payment-details', $data, true);
     //registration form
     $data['regis_form'] = $erm->regis_form(null, 'front/registration/');
     /* $ercm->hide_past = false;
        $d = $ercm->recurrence_dates_from_dates_section( );
        echo $this->epl_util->construct_calendar( $d ); */
     //the list of events
     $params = array('input_type' => 'select', 'input_name' => 'event_list_id', 'id' => 'event_list_id', 'label' => epl__('Event'), 'options' => $this->get_all_events());
     //echo "<pre class='prettyprint'>" . print_r($params, true). "</pre>";
     $data['fields'][] = $this->epl_util->create_element($params);
     $r = $this->epl->load_view('front/registration/regis-thank-you-page', $data, true);
     return $r;
 }
<?php

$erm = EPL_registration_model::get_instance();
$table_id = 'table_' . time();
?>

<table id="<?php 
echo $table_id;
?>
" class="epl_financial_report epl_report_table epl_standard_table">
    <thead>
        <tr>
            <th>Regis. Date</th>
            <th>ID</th>

            <th>Total Due</th>
            <th>Total Paid</th>

            <th>Payment Method</th>
            <th>Transaction ID</th>

            <th>Status</th>
        </tr>
    </thead>
    <tbody>
        <?php 
global $epl_fields, $event_details;
foreach ($transactions as $t) {
    $gateway_info = $erm->get_gateway_info($t->payment_method_id);
    ?>
            <tr>
 function adjust_discountable_amounts($for = 'category', $args = null)
 {
     global $event_totals;
     static $adjusted = false;
     if (epl_is_empty_array($event_totals)) {
         return false;
     }
     $num_events = count($event_totals);
     $pay_profile_ok = 1;
     if ($for == 'pay_profiles') {
         $selected_pay_id = EPL_registration_model::get_instance()->get_payment_profile_id();
         $pay_profile_ok = $selected_pay_id && in_array($selected_pay_id, $args);
     }
     foreach ($event_totals as $event_id => $totals) {
         setup_event_details($event_id);
         //if the taxonomy in question is not assigned to this event
         //then adjust the totals to exclude this event numbers from the discount processes
         //same applies to pay profiles
         if ($for == 'category' && !has_term($args, 'epl_event_categories', $event_id) || !$pay_profile_ok) {
             $this->totals['money_totals']['discountable_total'] -= epl_get_element_m('discountable_total', 'money_totals', $totals, 0);
             $this->totals['money_totals']['non_discountable_total'] += epl_get_element_m('grand_total', 'money_totals', $totals, 0);
             $this->totals['money_totals']['num_discountable_events_in_cart'] -= 1;
         }
     }
     $adjusted = true;
     //return $totals;
 }
Exemplo n.º 8
0
 function get_the_regis_total_amount($symbol = true)
 {
     global $regis_details, $event_details, $epl_current_step;
     if (!empty($regis_details) && isset($regis_details['__epl']) && !$_SERVER['REQUEST_METHOD'] == $_POST) {
         $regis_id = $regis_details['__epl']['_regis_id'];
         $source = $regis_details['__epl'][$regis_id];
         if (epl_get_element_m('money_totals', 'cart_totals', $source, '') == '') {
             $source = $regis_details;
         }
     } else {
         $regis_id = EPL_registration_model::get_instance()->regis_id;
         $source = EPL_registration_model::get_instance()->current_data[$regis_id];
     }
     $grand_total = epl_get_element_m('money_totals', 'cart_totals', $source, '');
     $grand_total = epl_nz($grand_total !== '' ? $grand_total['grand_total'] : $source['_epl_grand_total']);
     if (!$symbol) {
         return $grand_total;
     }
     return epl_get_formatted_curr($grand_total, null, true);
 }