if ($payment_amount > $_a['price']) {
             $_a['paid_per_class'] = $_a['price'];
         } else {
             $_a['paid_per_class'] = $payment_amount / $row->num_dates / $row->total_quantity;
         }
     }
     $_a['paid_per_class'] -= $true_discount;
     $_a['paid_per_class'] += $donation;
     if ($row->total_quantity >= 1 && $payment_amount < $row->price * $row->total_quantity * $row->num_dates) {
         $_a['paid_per_class'] = $payment_amount / $row->num_dates / $row->total_quantity;
     }
     if ($row->total_quantity == 1 && $payment_amount < $row->price) {
         $_a['paid_per_class'] = $payment_amount;
     }
 }
 $_a['paid_per_class'] = epl_get_formatted_curr(epl_nz($_a['paid_per_class'], 0));
 $total_revenue += str_replace(',', '', $_a['paid_per_class']);
 unset($_a['paid_per_class']);
 //attendee data
 $form_data = $erptm->get_form_data($row->regis_id, $row->event_id, $form_counter);
 $_f = array();
 if ($form_data) {
     foreach ($form_data as $f) {
         if (strpos($f->field_id, EPL_PLUGIN_DB_DELIM)) {
             $fields = explode(EPL_PLUGIN_DB_DELIM, $f->field_id);
             $values = explode(EPL_PLUGIN_DB_DELIM, $f->value);
         } else {
             $fields = array($f->field_id);
             $values = array($f->value);
         }
         $full = array_combine($fields, $values);
<tr>
    <td>
        <?php 
echo $price_name;
?>
    </td>

    <td>
        <?php 
echo $price != 0 ? epl_get_formatted_curr($price, null, true) : '';
?>
    </td>
    <td>
        <?php 
echo epl_get_element('field', $price_qty_dd, '&nbsp;');
?>

    </td>

    <?php 
if (epl_is_addon_active('_epl_atp') && $mode != 'overview') {
    //do not deacitvate, will not work
    ?>
            <td>
        <?php 
    if ($regis_expiration != '') {
        echo ' ' . $regis_expiration['msg'];
    }
    ?>

        </td>
        </tr>
        <?php 
$payment_data = epl_get_regis_payments();
foreach ($payment_data as $t => $p) {
    if ($p['_epl_payment_amount'] == 0) {
        continue;
    }
    ?>
            <tr style="border-top:1px solid #d7d7d7;">
                <td><?php 
    echo epl_formatted_date($p['_epl_payment_date']);
    ?>
</td>
                <td><?php 
    echo epl_get_formatted_curr($p['_epl_payment_amount'], null, true);
    ?>
                    <span style="float: right;"><?php 
    echo epl_trunc(epl_get_element($p['_epl_payment_method'], $epl_fields['epl_regis_payment_fields']['_epl_payment_method']['options'], ''), 10);
    ?>
</span>
                </td>              
            </tr>
        <?php 
}
?>

        <tr>
            <td colspan="2">

                <span class="epl_font_small"><?php 
 function get_the_event_dates_times_prices()
 {
     global $event_details, $event_snapshot;
     $_today = EPL_DATE;
     $_r = array();
     foreach ($event_details['_epl_start_date'] as $date_key => $date) {
         if (epl_is_ongoing_event() || true) {
             $_note = epl_get_element_m($date_key, '_epl_date_note', $event_details);
             $_location = '';
             if (epl_get_element($date_key, epl_get_element('_epl_date_location', $event_details))) {
                 $_location_id = epl_get_element($date_key, $event_details['_epl_date_location']);
                 $l = the_location_details($_location_id);
                 //sets up the location info
                 $_location = $l['post_title'];
                 //get_the_location_name();// . ' ' . get_the_location_gmap_icon();
                 //echo "<pre class='prettyprint'>" . __LINE__ . "> " . print_r( epl_formatted_date( $date ) . $_location_id, true ) . "</pre>";
             }
             $_end = $date != $event_details['_epl_end_date'][$date_key] ? ' - ' . epl_formatted_date($event_details['_epl_end_date'][$date_key]) : '';
             $_r[$date_key]['date'] = array('disp' => epl_formatted_date($date) . $_end . ' ' . $_location);
             foreach ($event_details['_epl_start_time'] as $time_key => $time) {
                 if (epl_is_date_level_time() && epl_is_date_specific_time($time_key) && !epl_get_element_m($date_key, $time_key, $event_details['_epl_date_specific_time'])) {
                     continue;
                 }
                 $_r[$date_key]['time'][$time_key] = array('disp' => $time . epl_prefix(' - ', epl_get_element_m($time_key, '_epl_time_note', $event_details)));
                 foreach ($event_details['_epl_price_name'] as $price_key => $price_name) {
                     if (epl_is_date_level_price() && epl_is_date_specific_price($price_key) && !epl_get_element_m($date_key, $price_key, $event_details['_epl_date_specific_price'])) {
                         continue;
                     }
                     //echo "<pre class='prettyprint'>" . __LINE__ . "> " . print_r($event_details['_epl_price_name'], true). "</pre>";
                     $_r[$date_key]['time'][$time_key]['price'][$price_key] = array('disp' => $price_name, 'price' => epl_get_formatted_curr($event_details['_epl_price'][$price_key], null, true));
                     if (epl_is_time_specific_price($price_key) && !epl_get_element_m($time_key, $price_key, epl_get_element('_epl_time_specific_price', $event_details))) {
                         unset($_r[$date_key]['time'][$time_key]['price'][$price_key]);
                     }
                     if (epl_is_date_specific_price($price_key) && !epl_get_element_m($date_key, $price_key, epl_get_element('_epl_date_specific_price', $event_details))) {
                         unset($_r[$date_key]['time'][$time_key]['price'][$price_key]);
                     }
                 }
             }
         }
     }
     return $this->epl->load_view('front/dates-times-prices', array('table_data' => $_r), true);
 }
 function _get_prices()
 {
     global $capacity_components;
     foreach ($this->event_meta['_epl_price_name'] as $_k => $_fieldregis_meta) {
         $data['price_name'] = $_fieldregis_meta;
         $data['price'] = epl_get_formatted_curr($this->event_meta['_epl_price'][$_k]);
         $value = $this->get_current_value('_dates', '_att_quantity', $this->event_meta['ID'], $_k);
         $epl_fields = array('input_type' => 'select', 'input_name' => "_att_quantity[{$this->event_meta['ID']}][{$_k}]", 'options' => $this->get_allowed_quantity($this->event_meta), 'value' => $value);
         $epl_fields += (array) $this->overview_trigger;
         $data['price_qty_dd'] = $this->epl_util->create_element($epl_fields);
         if ($this->mode == 'overview' && ($value == 0 || current((array) $value) == 0)) {
         } else {
             $r .= $this->epl->load_view('front/cart/cart-prices-row', $data, true);
         }
     }
     return $this->epl->load_view('front/cart/cart-prices', array('prices_table' => $r), true);
 }
    ?>
        <tr class="epl_discount_amount">

            <td class="epl_w200">
                <?php 
    echo epl_e('Donation');
    ?>

            </td>
            <td class="epl_total_price epl_w100 epl_ta_r"> <?php 
    echo epl_get_formatted_curr($money_totals['donation_amount'], null, true);
    ?>
</td>
        </tr>
    <?php 
}
?>
    <tr class="epl_grand_total">

        <td class="epl_w200"><?php 
echo epl_e('Total');
?>
</td>
        <td class="epl_total_price epl_w100 epl_ta_r"> <?php 
echo epl_get_formatted_curr(epl_get_element('grand_total', $money_totals), null, true);
?>
</td>
    </tr>


</table>
 function get_the_event_prices()
 {
     global $event_details;
     $tmpl = array('table_open' => '<table cellpadding="0" cellspacing="0" class="event_prices_table">');
     $this->epl->epl_table->set_template($tmpl);
     foreach ($event_details['_epl_price_name'] as $price_key => $price_data) {
         $price_name = $event_details['_epl_price_name'][$price_key];
         $price = epl_is_free_event() ? '' : epl_get_currency_symbol() . epl_get_formatted_curr($event_details['_epl_price'][$price_key]);
         $this->epl->epl_table->add_row($price_name, $price);
         //$this->epl->epl_table->add_row( $r );
     }
     $r = $this->epl->epl_table->generate();
     $this->epl->epl_table->clear();
     return $r;
 }
 function _get_prices($date_id = null)
 {
     global $event_details;
     $r = '';
     foreach ($event_details['_epl_price_name'] as $_price_key => $_price_name) {
         $data['price_name'] = $_price_name;
         $data['price'] = epl_get_formatted_curr($event_details['_epl_price'][$_price_key]);
         $value = $this->get_current_value('_dates', '_att_quantity', $event_details['ID'], $_price_key);
         if (!is_null($date_id)) {
             $value = $value[$date_id];
         }
         $epl_fields = array('input_type' => 'select', 'input_name' => "_att_quantity[{$event_details['ID']}][{$_price_key}][{$date_id}]", 'options' => $this->get_allowed_quantity($event_details), 'value' => $value, 'class' => 'epl_att_qty_dd');
         $epl_fields += (array) $this->overview_trigger;
         $data['price_qty_dd'] = $this->epl_util->create_element($epl_fields);
         if ($this->mode == 'overview' && $value == 0) {
         } else {
             $r .= $this->epl->load_view('front/cart/cart-prices-row', $data, true);
         }
     }
     return $this->epl->load_view('front/cart/cart-prices', array('prices_table' => $r), true);
 }
 $event_dow = date_i18n("D", $date);
 $event_dom = date_i18n("m/j/Y", $date);
 $end_time = $event_details['_epl_end_time'][$time_id];
 $event_venue_title = get_the_location_name();
 $boat_number = "Boat " . epl_get_element('_epl_boat_no', $event_details);
 $event_personnel_name = "Leland";
 //$event_ages_range = ageRange2( $event_ages );
 $time_capacity = epl_get_element_m($time_id, '_epl_time_capacity', $event_details);
 $capacity = $time_capacity ? $time_capacity : ($date_capacity ? $date_capacity : epl_get_element_m($date_id, '_epl_date_per_time_capacity', $event_details));
 $num_regis = 0;
 $counts_day_key = $event_id . "_time_{$date_id}";
 $counts_time_key = $event_id . "_time_{$date_id}_{$time_id}";
 if (isset($counts['_total_att_' . $counts_time_key])) {
     $num_regis = epl_get_element('_total_att_' . $counts_time_key, $counts, 0);
 }
 $money_total = epl_get_formatted_curr(epl_get_element('_money_total_' . $counts_time_key, $money_totals, 0.0));
 $avail -= $num_regis;
 if ($avail <= 0) {
     $open_spots = "<span class='spots_closed'>Sold Out</span>";
 } else {
     $open_spots = "<span class='spots_open'>" . $avail . " Spots</span>";
 }
 if ($avail <= 0) {
     $register_button_text = "<span class='button_closed'>Sold<strong>Out</strong></span>";
     if (epl_is_ok_for_waitlist() && ($wl_spaces_left = epl_waitlist_spaces_open()) !== false) {
         $register_button_url = array('_date_id' => $date_id, 'button_text' => "Waiting List", 'class' => 'epl_button button_waitlist');
     }
 }
 $table_link_arr = array('epl_action' => 'view_names', 'epl_download_trigger' => 1, 'table_view' => 1, 'epl_controller' => 'epl_report_manager', 'event_id' => $event_id);
 $dt_array = array('date_id' => $date_id, 'time_id' => $time_id, 'event_id' => $event_id);
 $table_link_arr = array_merge($table_link_arr, $dt_array);
                <td style="text-align: left;"><?php 
epl_e('Discount');
?>
</td>
                <td style="text-align: left;"><?php 
echo epl_get_formatted_curr($regis->discount_amount, null, true);
?>
</td>
            </tr>
            <tr>
                <td style="text-align: left;"><?php 
epl_e('Total');
?>
</td>
                <td style="text-align: left;"><?php 
echo epl_get_formatted_curr($regis->grand_total, null, true);
?>
</td>
            </tr>


        </table>
    </div>


    <div class="invoice_section_full" style="font-size: 0.8em;">
        <?php 
echo epl_format_string($invoice_settings['epl_invoice_instruction']);
?>
    </div>
 function is_condition_ok($_code_id)
 {
     global $event_details, $event_totals;
     $_code_condition = epl_get_element($_code_id, epl_get_element('_epl_discount_condition', $this->discount_configs), 0);
     if ($_code_condition == 0) {
         return true;
     }
     $_condition_logic = epl_get_element($_code_id, epl_get_element('_epl_discount_condition_logic', $this->discount_configs));
     $_condition_value = epl_get_element($_code_id, epl_get_element('_epl_discount_condition_value', $this->discount_configs), 0);
     $_condition_value2 = epl_get_element($_code_id, epl_get_element('_epl_discount_condition_value2', $this->discount_configs), 0);
     $r = null;
     switch ($_code_condition) {
         case 5:
             $r = $this->apply_condition($this->totals['money_totals']['grand_total'], $_condition_logic, $_condition_value, $_condition_value2);
             if (!$r) {
                 return epl__('The discount code requires the total amount to be') . ' ' . $_condition_logic . ' ' . epl_get_formatted_curr($_condition_value) . ($_condition_logic == 'between' ? ' ' . epl__('and') . ' ' . epl_get_formatted_curr($_condition_value2) : '');
             }
             break;
         case 6:
             $disc_qty = current((array) $this->totals['_att_quantity']['total']) - current((array) $this->totals['_att_quantity']['total_non_disc']);
             $r = $this->apply_condition($disc_qty, $_condition_logic, $_condition_value, $_condition_value2);
             if (!$r) {
                 return epl__('The discount code requires for total number of paying attendees to be') . ' ' . $_condition_logic . ' ' . $_condition_value . ($_condition_logic == 'between' ? ' ' . epl__('and') . ' ' . epl_get_formatted_curr($_condition_value2) : '');
             }
             break;
         case 7:
             $r = $this->apply_condition($this->totals['money_totals']['num_discountable_events_in_cart'], $_condition_logic, $_condition_value, $_condition_value2);
             if (!$r) {
                 return epl__('The discount code requires for total number of eligible events in the cart to be') . ' ' . $_condition_logic . ' ' . $_condition_value . ($_condition_logic == 'between' ? ' ' . epl__('and') . ' ' . epl_get_formatted_curr($_condition_value2) : '');
             }
             break;
             break;
         case 8:
             $dates = EPL_registration_model::get_instance()->get_the_cart_dates($event_details['ID']);
             if (!empty($dates)) {
                 $c = count(epl_get_element($event_details['ID'], $dates));
                 $r = $this->apply_condition($c, $_condition_logic, $_condition_value, $_condition_value2);
             }
             if (!$r) {
                 return epl__('The discount code requires for total number of eligible dates in the cart to be') . ' ' . $_condition_logic . ' ' . $_condition_value . ($_condition_logic == 'between' ? ' ' . epl__('and') . ' ' . epl_get_formatted_curr($_condition_value2) : '');
             }
             break;
     }
     return true;
 }
epl_e('Grand Total');
?>
</td>
                <td><?php 
echo epl_get_formatted_curr($grand_total, null, true);
?>
</td>
                <td colspan="3"></td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: right;"><?php 
epl_e('Balance');
?>
</td>
                <td><?php 
echo epl_get_formatted_curr($balance, null, true);
?>
</td>
                <td colspan="3"></td>
            </tr>
        </tfoot>
    </table>


    <?php 
if ($edit_mode) {
    ?>


    <?php 
}
<?php

/* this is the totals TABLE in the cart */
?>
<table class="epl_totals_table">

    <tr class="epl_grand_total">

        <td class="epl_w200"><?php 
echo epl_e('Total');
?>
</td>
        <td class="epl_total_price epl_w100 epl_ta_r"> <?php 
echo epl_get_currency_symbol() . epl_get_formatted_curr($money_totals['grand_total']);
?>
</td>
    </tr>


</table>
 function payment_info_box($post_ID = null)
 {
     if (is_null($post_ID)) {
         $post_ID = (int) $_POST['post_ID'];
     }
     if ($GLOBALS['epl_ajax'] || !isset($this->meta)) {
         $this->meta = $this->ecm->get_post_meta_all($post_ID, true);
     }
     $data['post_ID'] = $post_ID;
     $data['regis_status'] = isset($this->meta['_epl_regis_status']) ? $this->ind_fields['_epl_regis_status']['options'][$this->meta['_epl_regis_status']] : '';
     $data['payment_method'] = isset($this->meta['_epl_payment_method']) && $this->meta['_epl_payment_method'] != '' ? $this->ind_fields['_epl_payment_method']['options'][$this->meta['_epl_payment_method']] : '';
     $grand_total = epl_get_formatted_curr(epl_nz($this->meta['_epl_grand_total'], 0));
     $amount_paid = epl_get_formatted_curr(epl_nz($this->meta['_epl_payment_amount'], 0));
     $data['amount_paid'] = epl_get_currency_symbol() . $amount_paid;
     $data['grand_total'] = epl_get_currency_symbol() . $grand_total;
     $href = esc_url(add_query_arg(array('epl_action' => 'epl_payment_snapshot', 'post_ID' => $post_ID), $_SERVER['REQUEST_URI']));
     $data['snapshot_link'] = '<a data-post_id = "' . $post_ID . '" class="epl_payment_snapshot" href="#"><img src="' . EPL_FULL_URL . 'images/application_view_list.png" /> </a>';
     //$data['snapshot_link'] = '<img id = "' . $post_ID . '" class="epl_payment_snapshot" src="' . EPL_FULL_URL . 'images/application_view_list.png" />';
     $data['status_class'] = 'epl_status_pending';
     if ($this->meta['_epl_regis_status'] == 5) {
         $data['status_class'] = 'epl_status_paid';
     }
     if ($this->meta['_epl_regis_status'] == 10 || $this->meta['_epl_regis_status'] == 15) {
         $data['status_class'] = 'epl_status_cancelled';
     }
     return $this->epl->load_view('admin/registrations/regis-list-payment-info', $data, true);
 }
 function payment_info_box($post_ID = null)
 {
     global $regis_details;
     if (is_null($post_ID)) {
         $post_ID = (int) $_POST['post_ID'];
     }
     if ($GLOBALS['epl_ajax'] || !isset($this->regis_meta)) {
         $regis_details = $this->regis_meta = $this->ecm->setup_regis_details($post_ID, true);
     }
     $this->temp_set_payment_method_id();
     $data['post_ID'] = $post_ID;
     //$data['event_id'] = $this->event_id;
     $data['regis_status_id'] = $this->regis_meta['_epl_regis_status'];
     $data['regis_status'] = isset($this->regis_meta['_epl_regis_status']) ? $this->ind_fields['_epl_regis_status']['options'][$this->regis_meta['_epl_regis_status']] : '';
     $data['payment_method'] = isset($this->regis_meta['_epl_payment_method']) && $this->regis_meta['_epl_payment_method'] != '' ? $this->ind_fields['_epl_payment_method']['options'][$this->regis_meta['_epl_payment_method']] : '';
     $data += $this->get_waitlist_info();
     $grand_total = get_the_regis_total_amount(false);
     //epl_get_formatted_curr( epl_nz( $this->regis_meta['_epl_grand_total'], 0 ) );
     $amount_paid = epl_get_formatted_curr(epl_nz($this->regis_meta['_epl_payment_amount'], 0));
     $data['grand_total'] = epl_get_formatted_curr($grand_total, null, true);
     $href = add_query_arg(array('epl_action' => 'epl_payment_snapshot', 'post_ID' => $post_ID), epl_get_url());
     $data['snapshot_link'] = '<a data-post_id = "' . $post_ID . '" class="epl_payment_snapshot" href="#"><img src="' . EPL_FULL_URL . 'images/application_view_list.png" /> </a>';
     //$data['snapshot_link'] = '<img id = "' . $post_ID . '" class="epl_payment_snapshot" src="' . EPL_FULL_URL . 'images/application_view_list.png" />';
     $data['status_class'] = 'epl_status_pending';
     if ($this->regis_meta['_epl_regis_status'] == 1) {
         $data['status_class'] = 'epl_status_incomplete';
     } elseif ($this->regis_meta['_epl_regis_status'] == 5) {
         $data['status_class'] = 'epl_status_paid';
     } elseif ($this->regis_meta['_epl_regis_status'] == 10) {
         $data['status_class'] = 'epl_status_cancelled';
     } elseif ($this->regis_meta['_epl_regis_status'] == 15) {
         $data['status_class'] = 'epl_status_refunded';
     } elseif ($this->regis_meta['_epl_regis_status'] == 20) {
         $data['status_class'] = 'epl_status_waitlist';
     }
     return $this->epl->load_view('admin/registration/regis-list-payment-info', $data, true);
 }
 function attendee_list_table($args = array())
 {
     $defaults = array('event_id' => epl_get_element('event_id', $_REQUEST));
     $args = wp_parse_args($args, $defaults);
     extract($args);
     global $event_details;
     $this->ecm->set_event_regis_post_ids($event_id);
     //$event_id = ( int ) (!isset( $args['event_id'] ) ? $_REQUEST['event_id'] : $event_id);
     $_totals = $this->ecm->get_event_regis_snapshot($event_id);
     //if ( epl_is_empty_array( $event_details ) )
     $this->ecm->setup_event_details($event_id);
     $display = epl_get_element('_epl_show_attendee_list_template', $event_details, 'attendee-list-1');
     if (epl_get_element('_epl_show_attendee_list_link', $event_details, 0) == 0 && !current_user_can('manage_options')) {
         return null;
     }
     $event_ticket_buyer_forms = array_flip((array) $event_details['_epl_primary_regis_forms']);
     $event_addit_forms = isset($event_details['_epl_addit_regis_forms']) && $event_details['_epl_addit_regis_forms'] != '' ? array_flip($event_details['_epl_addit_regis_forms']) : array();
     //find the list of all forms
     $available_forms = $this->ecm->get_list_of_available_forms();
     $available_fields = $this->ecm->get_list_of_available_fields();
     //isolate the forms that are selected inside the event
     $ticket_buyer_forms = array_intersect_key($available_forms, $event_ticket_buyer_forms);
     $addit_forms = array_intersect_key($available_forms, $event_addit_forms);
     //This will combine all the fields in all the forms so that we can construct a header row.
     $tickey_buyer_fields = array();
     foreach ($ticket_buyer_forms as $_form_id => $_form_info) {
         $tickey_buyer_fields += $_form_info['epl_form_fields'];
     }
     $event_addit_fields = array();
     foreach ($addit_forms as $_form_id => $_form_info) {
         $event_addit_fields += $_form_info['epl_form_fields'];
     }
     $epl_fields_inside_form = array_flip($tickey_buyer_fields);
     //get the field ids inside the form
     $epl_addit_fields_inside_form = array_flip($event_addit_fields);
     //get the field ids inside the form
     //when creating a form in form manager, the user may rearrange fields.  Find their desired order
     $epl_fields_to_display = $this->epl_util->sort_array_by_array($available_fields, $event_details['_epl_attendee_list_field']);
     $epl_addit_fields_to_display = $this->epl_util->sort_array_by_array($available_fields, $event_details['_epl_attendee_list_field']);
     $epl_fields_to_display = $epl_fields_to_display + $epl_addit_fields_to_display;
     $csv_row = '';
     $list = array();
     $header_row = array();
     $header_pulled = false;
     $row = array();
     //$header_row[] = '';
     //$header_row[] = epl__( 'Regis Date' );
     //$header_row[] = epl__( 'Event Date' );
     //$header_row[] = epl__( 'Time' );
     $regis_ids = $this->ecm->get_event_regis_post_ids(false);
     //as of 1.1, the dates are stored as timestamps.
     //This will format the date for display based on the settings admin date format.
     //foreach ( $event_details['_epl_start_date'] as $k => &$v )
     //  $v = epl_admin_date_display( $v );
     foreach ($regis_ids as $regis_id => $att_count) {
         //$regis_data = $this->ecm->get_post_meta_all( $regis_id );
         $regis_data = $this->ecm->setup_regis_details($regis_id, true);
         //Sometime there may be incomplete db records.  These will cause issues below.
         //In those cases, skip and move to the next item
         if (!isset($regis_data['_epl_dates']['_epl_start_date'][$event_id])) {
             continue;
         }
         if (($startus = get_the_regis_status(null, true)) && $startus <= 1 || $startus > 5) {
             continue;
         }
         $event_times = $regis_data['_epl_dates']['_epl_start_time'][$event_id];
         //$event_prices = $regis_data['_epl_dates']['_epl_start_time'][$event_id];
         $regis_date = implode(' & ', array_intersect_key(epl_get_element('_epl_start_date', $event_details, array()), array_flip((array) $regis_data['_epl_dates']['_epl_start_date'][$event_id])));
         $regis_time = implode(' & ', array_intersect_key(epl_get_element('_epl_start_time', $event_details, array()), array_flip((array) $regis_data['_epl_dates']['_epl_start_time'][$event_id])));
         $date_labels = array();
         $date_labels[0] = '';
         $time_labels = array();
         $time_labels[0] = '';
         $ticket_labels = array();
         $ticket_labels[0] = $att_count;
         $purchased_tickets = (array) $regis_data['_epl_dates']['_att_quantity'][$event_id];
         $attendee_info = $regis_data['_epl_attendee_info'];
         $start = 1;
         foreach ($purchased_tickets as $price_id => $qty) {
             if ($event_details['_epl_price_type'][$price_id] != 'att') {
                 continue;
             }
             $_qty = is_array($qty) ? array_sum($qty) : $qty;
             //current( $qty );
             if ($_qty > 0) {
                 $date_label[] = current((array) $regis_data['_epl_dates']['_epl_start_date'][$event_id]);
                 if (epl_get_element('_epl_pricing_type', $event_details) == 10) {
                     if (in_array($event_details['_epl_price_parent_time_id'][$price_id], (array) $regis_data['_epl_dates']['_epl_start_time'][$event_id])) {
                         $time_labels = array_pad($time_labels, $start + $_qty, epl_get_element($event_details['_epl_price_parent_time_id'][$price_id], $event_details['_epl_start_time']));
                     } else {
                         $time_labels = array_pad($time_labels, $start + $_qty, '');
                     }
                 }
                 $ticket_labels = array_pad($ticket_labels, $start + $_qty, $event_details['_epl_price_name'][$price_id]);
                 $start += $_qty;
             }
         }
         $_r = array();
         $grand_total = epl_get_formatted_curr(epl_nz($regis_data['_epl_grand_total'], 0.0));
         $amount_paid = epl_get_formatted_curr(epl_nz($regis_data['_epl_payment_amount'], 0.0));
         $tickets_to_show = array_intersect_key($purchased_tickets, $event_details['_epl_price_name']);
         $att_counter = 1;
         $counter = 0;
         foreach ($tickets_to_show as $ticket_id => $ticket_qty) {
             if (is_array($ticket_qty)) {
                 $tmp_price_inner_keys = array_keys($ticket_qty);
                 $ticket_qty = array_sum($ticket_qty);
             }
             if ($ticket_qty == 0) {
                 continue;
             }
             for ($i = 0; $i <= $ticket_qty; $i++) {
                 if ($i == 0 && !epl_is_empty_array($event_addit_forms)) {
                     //continue;
                     //$row[] = epl__( 'Registrant' );
                 } else {
                     //$row[] = epl__( 'Attendee' );
                     $grand_total = '';
                     $amount_paid = '';
                     $regis_status = '';
                     $payment_method = '';
                 }
                 foreach ($epl_fields_to_display as $field_id => $field_atts) {
                     if (!$header_pulled) {
                         $header_row[] = html_entity_decode(htmlspecialchars_decode($field_atts['label'], ENT_QUOTES));
                     }
                     $value = '';
                     //new v1.2.b9+
                     if (isset($attendee_info[$field_id][$event_id][$ticket_id])) {
                         $value = epl_get_element($counter, $attendee_info[$field_id][$event_id][$ticket_id]);
                     } elseif (isset($attendee_info[$field_id][$event_id][$counter])) {
                         $value = $attendee_info[$field_id][$event_id][$counter];
                     }
                     if ($field_atts['input_type'] == 'select' || $field_atts['input_type'] == 'radio') {
                         $value = isset($field_atts['epl_field_choice_text'][$value]) && $field_atts['epl_field_choice_text'][$value] !== '' ? $field_atts['epl_field_choice_text'][$value] : $value;
                     } elseif ($field_atts['input_type'] == 'checkbox') {
                         if (!epl_is_empty_array($field_atts['epl_field_choice_value'])) {
                             $value = implode(',', (array) $value);
                         } elseif (!epl_is_empty_array($value)) {
                             $value = implode(',', array_intersect_key($field_atts['epl_field_choice_text'], array_flip($value)));
                         } else {
                             $value = html_entity_decode(htmlspecialchars_decode($value));
                         }
                     }
                     /* else {
                     
                                               $value = html_entity_decode( htmlspecialchars_decode( $value ) );
                                               } */
                     $row[] = html_entity_decode(htmlspecialchars_decode($value, ENT_QUOTES));
                 }
                 $header_pulled = true;
                 //decode special chars (Swedish, Nordic)
                 //array_walk( $row, create_function( '&$item', '$item = utf8_decode($item);' ) );
                 if (!epl_is_empty_array($row)) {
                     $list[$regis_id]['att_count'] = $att_count;
                     $list[$regis_id]['attendees'][] = $row;
                     //$this->epl->epl_table->add_row( $row );
                 }
                 //$csv_row .= implode( ",", $row ) . "\r\n";
                 $row = array();
                 $counter++;
                 $att_counter++;
             }
         }
         $counter = 0;
     }
     //$tmpl = array( 'table_open' => '<table cellpadding="2" cellspacing="0" border="1" class="event_attendee_list_table">' );
     $data['event_title'] = epl_format_string($event_details['post_title']);
     $data['header_row'] = $header_row;
     $data['list'] = $list;
     return $this->epl->load_view('front/attendee-list/' . $display, $data, true);
 }
 function epl_excel_attendee_list()
 {
     $event_id = $_REQUEST['event_id'];
     $_totals = $this->get_event_regis_snapshot($_REQUEST['event_id']);
     //echo "<pre class='prettyprint'>" . print_r( $_totals, true ) . "</pre>";
     $this->set_event_regis_post_ids($_REQUEST['event_id']);
     global $event_details;
     //epl_log( "debug", "<pre>" . __LINE__ . '> ' . print_r($event_details, true ) . "</pre>" );
     $event_title = $event_details['post_title'];
     $filename = str_replace(" ", "-", $event_title) . "_" . date_i18n("m-d-Y");
     /* header( "Content-type: application/x-msdownload; charset=UTF-8", true, 200 );
        header( "Content-Disposition: attachment; filename={$filename}.csv" );
        header( "Pragma: no-cache" );
        header( "Expires: 0" ); */
     //$this->setup_event_details( $event_id );
     $this->get_values();
     //echo "<pre class='prettyprint'>" . print_r($event_details, true). "</pre>";
     $event_ticket_buyer_forms = array_flip((array) $event_details['_epl_primary_regis_forms']);
     $event_addit_forms = isset($event_details['_epl_addit_regis_forms']) && $event_details['_epl_addit_regis_forms'] != '' ? array_flip($event_details['_epl_addit_regis_forms']) : array();
     //find the list of all forms
     $available_forms = $this->get_list_of_available_forms();
     $available_fields = $this->get_list_of_available_fields();
     //isolate the forms that are selected inside the event
     $ticket_buyer_forms = array_intersect_key($available_forms, $event_ticket_buyer_forms);
     $addit_forms = array_intersect_key($available_forms, $event_addit_forms);
     //This will combine all the fields in all the forms so that we can construct a header row.
     $tickey_buyer_fields = array();
     foreach ($ticket_buyer_forms as $_form_id => $_form_info) {
         $tickey_buyer_fields += $_form_info['epl_form_fields'];
     }
     $event_addit_fields = array();
     foreach ($addit_forms as $_form_id => $_form_info) {
         $event_addit_fields += $_form_info['epl_form_fields'];
     }
     $epl_fields_inside_form = array_flip($tickey_buyer_fields);
     //get the field ids inside the form
     $epl_addit_fields_inside_form = array_flip($event_addit_fields);
     //get the field ids inside the form
     //when creating a form in form manager, the user may rearrange fields.  Find their desired order
     $epl_fields_to_display = $this->epl_util->sort_array_by_array($available_fields, $epl_fields_inside_form);
     $epl_addit_fields_to_display = $this->epl_util->sort_array_by_array($available_fields, $epl_addit_fields_inside_form);
     $epl_fields_to_display = $epl_fields_to_display + $epl_addit_fields_to_display;
     $csv_row = '';
     $header_row = array();
     $header_pulled = false;
     $row = array();
     $header_row[] = '';
     $header_row[] = epl__('Registration ID');
     //$header_row[] = epl__( 'Regis Date' );
     //$header_row[] = epl__( 'Event Date' );
     //$header_row[] = epl__( 'Time' );
     $header_row[] = epl__('Ticket');
     $header_row[] = epl__('Status');
     $header_row[] = epl__('Payment Method');
     $header_row[] = epl__('Total');
     $header_row[] = epl__('Amount Paid');
     $regis_ids = $this->get_event_regis_post_ids(false);
     //as of 1.1, the dates are stored as timestamps.
     //This will format the date for display based on the settings admin date format.
     foreach ($event_details['_epl_start_date'] as $k => &$v) {
         $v = epl_admin_date_display($v);
     }
     $_d = array();
     foreach ($regis_ids as $regis_id => $att_count) {
         //$regis_data = $this->get_post_meta_all( $regis_id );
         $regis_data = $this->setup_regis_details($regis_id);
         // epl_log( "debug", "<pre>" . __LINE__ . '> ' . print_r($regis_data, true ) . "</pre>" );
         //Sometime there may be incomplete db records.  These will cause issues below.
         //In those cases, skip and move to the next item
         if (!isset($regis_data['_epl_dates']['_epl_start_date'][$event_id])) {
             continue;
         }
         $event_times = $regis_data['_epl_dates']['_epl_start_time'][$event_id];
         $event_prices = $regis_data['_epl_dates']['_epl_start_time'][$event_id];
         $regis_date = implode(' & ', array_intersect_key($event_details['_epl_start_date'], array_flip((array) $regis_data['_epl_dates']['_epl_start_date'][$event_id])));
         $regis_time = implode(' & ', array_intersect_key($event_details['_epl_start_time'], array_flip((array) $regis_data['_epl_dates']['_epl_start_time'][$event_id])));
         $date_labels = array();
         $date_labels[0] = '';
         $time_labels = array();
         $time_labels[0] = '';
         $ticket_labels = array();
         $ticket_labels[0] = $att_count;
         $purchased_tickets = (array) $regis_data['_epl_dates']['_att_quantity'][$event_id];
         $start = 1;
         foreach ($purchased_tickets as $price_id => $qty) {
             $_qty = is_array($qty) ? array_sum($qty) : $qty;
             //current( $qty );
             if ($_qty > 0) {
                 $date_label[] = current((array) $regis_data['_epl_dates']['_epl_start_date'][$event_id]);
                 if (epl_get_element('_epl_pricing_type', $event_details) == 10) {
                     if (in_array($event_details['_epl_price_parent_time_id'][$price_id], (array) $regis_data['_epl_dates']['_epl_start_time'][$event_id])) {
                         $time_labels = array_pad($time_labels, $start + $_qty, epl_get_element($event_details['_epl_price_parent_time_id'][$price_id], $event_details['_epl_start_time']));
                     } else {
                         $time_labels = array_pad($time_labels, $start + $_qty, '');
                     }
                 }
                 $ticket_labels = array_pad($ticket_labels, $start + $_qty, $event_details['_epl_price_name'][$price_id]);
                 $start += $_qty;
             }
         }
         $_r = array();
         $regis_status = isset($regis_data['_epl_regis_status']) ? $this->ind_fields['_epl_regis_status']['options'][$regis_data['_epl_regis_status']] : '';
         $payment_method = isset($regis_data['_epl_payment_method']) && $regis_data['_epl_payment_method'] != '' ? $this->ind_fields['_epl_payment_method']['options'][$regis_data['_epl_payment_method']] : '';
         $grand_total = epl_get_formatted_curr(epl_nz($regis_data['_epl_grand_total'], 0.0));
         $amount_paid = epl_get_formatted_curr(epl_nz($regis_data['_epl_payment_amount'], 0.0));
         for ($i = 0; $i <= $att_count; $i++) {
             $registrant = false;
             $attendee_info = $regis_data['_epl_attendee_info'];
             if ($i == 0) {
                 $registrant = true;
                 $row[] = epl__('Registrant');
             } else {
                 $row[] = epl_get_element('_epl_addit_regis_form_counter_label', $event_details, epl__('Attendee'));
                 //$grand_total = '';
                 //$amount_paid = '';
                 //$regis_status = '';
                 //$payment_method = '';
             }
             $row[] = $regis_data['__epl']['_regis_id'];
             //$row[] = $regis_data['post_date'];
             //$row[] = epl_escape_csv_val( $regis_date );
             //$row[] = $regis_time; //(epl_is_date_level_time ( ))?$regis_time:$time_labels[$i]; //
             $row[] = htmlspecialchars_decode($ticket_labels[$i]);
             //$regis_price;
             $row[] = $regis_status;
             $row[] = $payment_method;
             $row[] = epl_get_currency_symbol($grand_total);
             $row[] = $amount_paid;
             foreach ($epl_fields_to_display as $field_id => $field_atts) {
                 if (!$header_pulled) {
                     $header_row[] = epl_escape_csv_val(html_entity_decode(htmlspecialchars_decode($field_atts['label']), ENT_QUOTES));
                 }
                 $value = '';
                 $value = isset($attendee_info[$field_id][$event_id][$i]) ? $attendee_info[$field_id][$event_id][$i] : '';
                 if ($field_atts['input_type'] == 'select' || $field_atts['input_type'] == 'radio') {
                     $value = isset($field_atts['epl_field_choice_text'][$value]) && $field_atts['epl_field_choice_text'][$value] != '' ? $field_atts['epl_field_choice_text'][$value] : $value;
                 } elseif ($field_atts['input_type'] == 'checkbox') {
                     $value = implode(',', array_intersect_key($field_atts['epl_field_choice_text'], array_flip((array) $value)));
                 } else {
                     $value = html_entity_decode(htmlspecialchars_decode(epl_get_element($i, $attendee_info[$field_id][$event_id])), ENT_QUOTES);
                 }
                 $row[] = htmlentity_decode($value, ENT_QUOTES);
                 //decode special chars (Swedish, Nordic)
                 //array_walk( $row, create_function( '&$item', '$item = utf8_decode($item);' ) );
             }
             $header_pulled = true;
             if (!$registrant) {
                 $_d[] = $row;
             }
             //$csv_row .= implode( ",", $row ) . "\r\n";
             $row = array();
         }
     }
     $filename = epl__('Attendee List') . ', ' . $event_title . ", " . date_i18n("F j, Y");
     $this->excel_file_generator($header_row, $_d, $filename);
     //echo implode( ",", $header_row ) . "\r\n";
     //echo $csv_row;
     exit;
 }
        ?>
</td>
                <td><a href="<?php 
        echo admin_url("post.php?post={$post->ID}&action=edit");
        ?>
" target="_blank"><?php 
        the_title();
        ?>
</a></td>

                <td><?php 
        echo epl_get_formatted_curr($regis_details['_epl_grand_total']);
        ?>
</td>
                <td><?php 
        echo epl_get_formatted_curr($regis_details['_epl_payment_amount']);
        ?>
</td>
                <td><?php 
        echo $total_att;
        ?>
</td>
                <td><?php 
        echo $payment_method . ' ' . epl_get_element('_epl_cc_type', $regis_details);
        ?>
 </td>
                <td><?php 
        echo $regis_details['_epl_transaction_id'];
        ?>
</td>
 foreach ($event_details['_epl_start_date'] as $date_id => $date) {
     $date = epl_get_date_timestamp($date);
     $temp_table_row = '';
     $end_date = $event_details['_epl_end_date'][$date_id];
     $unix_date = $date;
     if ($status_id == 3) {
         if ($date < EPL_DATE && $end_date > EPL_DATE) {
             $date = EPL_DATE;
         }
     }
     $weekday = date_i18n('N', $date);
     $price = current((array) $event_details['_epl_price']);
     if ($price <= 0) {
         $print_price = "<span class='price_free'>Free</span>";
     } else {
         $print_price = "<span class='price_amount'> " . epl_get_formatted_curr($price, null, true) . "</span>";
     }
     $start_time = current((array) $event_details['_epl_start_time']);
     $date_capacity = $event_details['_epl_date_capacity'][$date_id];
     $num_regis = 0;
     $avail = '';
     if (isset($current_att_count['_total_att_' . $event_id . "_date_{$date_id}"])) {
         $num_regis = epl_get_element('_total_att_' . $event_id . "_date_{$date_id}", $current_att_count, 0);
         $avail = $date_capacity - $num_regis;
     }
     $date_note = epl_prefix(' - ', epl_get_element_m($date_id, '_epl_date_note', $event_details, ''));
     foreach ($event_details['_epl_start_time'] as $time_id => $time) {
         if ($event_details['_epl_time_hide'][$time_id] == 10) {
             continue;
         }
         if (epl_is_date_level_time() && !epl_is_empty_array($date_specifc_time) && (!isset($date_specifc_time[$time_id]) || !isset($date_specifc_time[$time_id][$date_id]))) {
function epl_get_balance_due()
{
    global $cart_totals;
    $regis_total = get_the_regis_total_amount(false);
    $payment_data = epl_get_regis_payments();
    $alt_total_due = epl_get_element_m('pay_deposit', 'money_totals', $cart_totals) == 1 ? epl_get_element_m('min_deposit', 'money_totals', $cart_totals, $regis_total) : $regis_total;
    if (!empty($payment_data)) {
        $total_paid = 0;
        foreach ($payment_data as $time => $p) {
            if ($p['_epl_payment_amount'] == 0) {
                continue;
            }
            $regis_total -= epl_get_formatted_curr($p['_epl_payment_amount'], 4);
        }
    } else {
        $regis_total = $alt_total_due;
    }
    return $regis_total == 0 ? abs($regis_total) : $regis_total;
}
<div class="epl_cart_section">

    <table class="epl_totals_wrapper epl_w100pct">

        <tr class="epl_grand_total">

            <td class="epl_w200">Total</td>
            <td class="epl_total_price epl_w100 epl_ta_r"> <?php 
echo epl_get_formatted_curr($total_price);
?>
</td>
        </tr>


    </table>
   
    
</div>
    <?php 
if (($original_total = epl_get_element('original_total', $money_totals)) > 0) {
    ?>
        <tr class="epl_original_total" style="background-color: #ffcccc ">

            <td class="epl_w200"><?php 
    epl_e('Original Total');
    ?>
</td>
            <td class="epl_total_price epl_w100 epl_ta_r"> <?php 
    echo epl_get_formatted_curr($original_total, null, true);
    ?>
</td>
        </tr>
    <?php 
}
?>
    <tr class="epl_grand_total">

        <td class="epl_w200"><?php 
echo epl_e('Event Total');
?>
</td>
        <td class="epl_total_price epl_w100 epl_ta_r"> <?php 
echo epl_get_formatted_curr($total, null, true);
?>
</td>
    </tr>


</table>
                    if (epl_is_time_specific_price($price_id) && !epl_get_element_m($time_id, $price_id, epl_get_element('_epl_time_specific_price', $event_details))) {
                        continue;
                    }
                    if (epl_is_date_specific_price($price_id) && !epl_get_element_m($date_id, $price_id, epl_get_element('_epl_date_specific_price', $event_details))) {
                        continue;
                    }
                    if (epl_get_element($price_id, epl_get_element('_epl_price_hide', $event_details)) == 0) {
                        ?>

                                <tr class="epl_price">
                                    <td><?php 
                        echo $price_data['disp'];
                        ?>
</td>
                                    <td><?php 
                        echo epl_get_formatted_curr($event_details['_epl_price'][$price_id], null, true);
                        ?>
</td>
                                    <td><?php 
                        echo $show_avail_spaces ? $price_data['avail'] : '';
                        ?>
</td>
                                </tr>

                                <?php 
                    }
                }
                ?>


                        <?php 
                <?php 
            foreach ($prices as $price_id => $price_data) {
                if (epl_get_element($price_id, epl_get_element('_epl_price_hide', $event_details)) == 0) {
                    ?>

                        <tr class="epl_price">
                            <td><?php 
                    echo $price_data['disp'];
                    ?>
</td>                           
                            <td><?php 
                    echo $price_data['qty'];
                    ?>
 x <?php 
                    echo epl_get_formatted_curr($price_data['ticket_price'], null, true);
                    ?>
</td>
                        </tr>

                        <?php 
                }
            }
            ?>


                <?php 
            //endif;
        }
        ?>
        ?>
</td>


            </tr>
            <?php 
    }
}
?>
            
            <tr>
                <td></td>
                <td></td>
                <td></td>
                <td class="total"><b><?php 
echo epl_get_formatted_curr($total_due);
?>
</b></td>

            </tr>
            
            </table>


        <script type="text/javascript">

            jQuery(document).ready(function($) {
                var oTable = $('.epl_financial_report').dataTable( { 
                    "bJQueryUI": true,
                    "sPaginationType": "full_numbers",
                    "iDisplayLength": 20,