function get_the_dates($date_id = null) { global $event_details, $multi_time, $multi_price, $event_snapshot; $data['date'] = array(); $data['time'] = array(); $dates_data = array(); $event_id = $event_details['ID']; $event_type = epl_nz($event_details['_epl_event_type'], 5); $input_type = $event_type == 5 ? 'radio' : 'checkbox'; $rolling_regis = !epl_user_is_admin() && epl_get_element('_epl_rolling_regis', $event_details) == 10; $first = apply_filters('epl_erm__get_the_dates__first', true); $event_status = epl_get_element('_epl_event_status', $event_details); $value = isset($this->current_data[$this->regis_id]['_dates']['_epl_start_date'][$event_details['ID']]) ? $this->current_data[$this->regis_id]['_dates']['_epl_start_date'][$event_details['ID']] : array(); $value = $this->epl->epl_util->clean_input($value); $data['show_date_selector_link'] = $event_type < 7 ? epl_get_element('_epl_enable_front_date_selector_cal', $event_details, 0) != 0 : false; if (epl_admin_override() && epl_get_regis_setting('epl_enable_admin_override_cal') == 10) { $data['show_date_selector_link'] = true; } if (!is_null($date_id) || ($date_id = epl_get_element('_date_id', $_REQUEST)) != '' && ($event_type != 7 && $event_type != 10)) { //$dates_data = array_intersect_key( $event_details['_epl_start_date'], array( $date_id => 1 ) ); $epl_fields['default_checked'] = 1; $value = (array) $this->epl->epl_util->clean_input($date_id); } if (epl_is_empty_array($dates_data)) { $dates_data = $event_details['_epl_start_date']; } $_value = $value; if (empty($dates_data)) { return null; } $date_format = apply_filters('epl_erm__get_the_dates__date_format', null); $one_day_showing = false; foreach ($dates_data as $event_date_id => $event_date) { $go = true; if (!epl_admin_override() && $rolling_regis && ($one_day_showing || $event_snapshot[$event_id][$event_date_id]['date']['hide'] === true)) { continue; } //$open_for_regis = epl_compare_dates( $event_details['_epl_regis_start_date'][$event_date_id],date_i18n( "m/d/Y" ), "<=" ); //if ( $data['show_date_selector_link'] && ($value != '' && !in_array( $event_date_id, $value )) ) //continue; $start_date = epl_formatted_date($event_date, $date_format); $end_date = epl_formatted_date($event_details['_epl_end_date'][$event_date_id], $date_format); $end_date = $start_date != $end_date ? ' - ' . $end_date : ''; $date_group = ($dg = epl_get_element_m($event_date_id, '_epl_date_group_no', $event_details, '')) != '' ? "[{$dg}]" : ''; $epl_fields = array('input_type' => $input_type, 'input_name' => "_epl_start_date[{$event_details['ID']}]{$date_group}[]", 'options' => array($event_date_id => $start_date . $end_date), 'display_inline' => true, 'value' => !epl_is_empty_array($value) ? $value : null); if ($dg != '') { $epl_fields['input_type'] = 'radio'; $epl_fields['default_checked'] = 1; $epl_fields['value'] = epl_get_element($dg, $_value, null); } $ok_to_register = epl_is_ok_to_register($event_details, $event_date_id); $avail_spaces = epl_get_date_avail_spaces($event_id, $event_date_id); if ($this->flow_mode == 'n' && !$this->on_admin && ($ok_to_register !== true || $avail_spaces === 0 && epl_waitlist_spaces_open() === false)) { //&& $event_status <> 3 - may be ongoing, but still need to keep track of regis end date. $epl_fields['readonly'] = 1; $epl_fields['default_checked'] = 0; $epl_fields['options'][$event_date_id] .= epl_wrap("<span class='epl_font_red'> - ", '</span>', $ok_to_register !== true ? $ok_to_register : ($avail_spaces == 0 ? '' : '')); if ($ok_to_register !== true) { $epl_fields['force_uncheck'] = true; } } else { //this will make sure that only the first date is selected by default if ($first) { $epl_fields['default_checked'] = 1; $first = false; } $epl_fields += (array) $this->overview_trigger; //has to register for all dates. if ($event_type == 5) { $epl_fields['input_type'] = 'radio'; if (count($dates_data) == 1) { $epl_fields['default_checked'] = 1; } } elseif ($event_type == 7 || $event_type == 10) { $epl_fields['readonly'] = 1; $epl_fields['default_checked'] = 1; } } if ($this->mode == 'overview' && !in_array($event_date_id, (array) $epl_fields['value'])) { $go = false; } else { if ($rolling_regis) { if ($event_status != 3 && $event_date >= EPL_DATE) { $one_day_showing = true; $epl_fields['default_checked'] = 1; } } $data['date'][$event_date_id] = $this->epl_util->create_element($epl_fields); $data['date'][$event_date_id]['input_name'] = $epl_fields['input_name']; } $data['date'][$event_date_id]['avail_spaces'] = $avail_spaces; if (epl_is_date_level_time() && epl_is_addon_active('_epl_atp')) { $data['time'][$event_date_id] = $this->_get_time_fields($event_date_id); } if (epl_is_date_level_price() && epl_is_addon_active('_epl_atp')) { $data['prices'][$event_date_id] = $this->_get_prices($event_date_id); } if ($this->flow_mode == 'p' && !in_array($event_date_id, (array) $value)) { $go = false; } if (!$go) { unset($data['date'][$event_date_id]); } $data = apply_filters('epl_erm__get_the_dates__date_field_loop_end', $data, $event_date_id); //} } $data['value'] = $_value; $data['event_type'] = $event_type; $data['mode'] = $this->mode; $data['flow_mode'] = $this->flow_mode; $r = $this->epl->load_view($this->dest . '/cart/cart-dates', $data, true); return $r; }
function load_cart_in_modal($m = 1) { global $event_details; $this->erm->set_mode('edit'); $event_id = intval($_REQUEST['event_id']); $data = array(); //cart $data['cart_data'] = $this->erm->show_cart(null, $event_id); $data['mode'] = 'edit'; $data['event_id'] = $event_id; setup_event_details($event_id); $data['show_date_selector_link'] = epl_nz($event_details['_epl_event_type'], 5) < 7 ? epl_get_element('_epl_enable_front_date_selector_cal', $event_details, 0) != 0 : false; if (epl_admin_override() && epl_get_regis_setting('epl_enable_admin_override_cal') == 10) { $data['show_date_selector_link'] = true; } //dates $dates = $data['cart_data']['cart_items'][$event_id]['event_dates']; $data['modal_cart_content'] = "<div class='epl_event_title'><h2>" . get_the_title($event_id) . "</h2></div>"; $data['modal_cart_content'] .= $this->epl->load_view('front/cart/cart-dates-display', $data + array('event_dates' => $dates), true); //times + prices $times_prices = $data['cart_data']['cart_items'][$event_id]['event_time_and_prices']; $data['modal_cart_content'] .= $this->epl->load_view('front/cart/cart-time-price-display', array('event_time_and_prices' => $times_prices), true); //calculate fresh total $_totals = $this->erm->calculate_cart_totals(true); //get totals for that event $data['money_totals'] = epl_get_element('money_totals', $_totals[$event_id], array()); //cart totals for that event $data['cart_totals'] = $this->epl->load_view('front/cart/cart-totals', $data, true); $data['modal_cart_content'] .= $this->epl->load_view('front/cart/cart-subtotals', $data, true); //the checkout url button $data['checkout_url'] = add_query_arg(array('epl_action' => 'show_cart'), epl_get_shortcode_page_permalink()); $data['event_id'] = $event_id; $data['modal_cart_content'] .= $this->epl->load_view('front/cart/cart-modal-buttons', $data, true); $r = $this->epl->load_view('front/cart/cart-modal-wrapper', $data, true); return $this->epl_util->epl_response(array('html' => $r)); }