function event_espresso_group_price_dropdown($event_id, $label = 1, $multi_reg = 0, $value = '')
    {
        global $wpdb, $org_options;
        do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
        /*
         * find out pricing type.
         * - If multiple price options, for each one
         * -- Create a row in a table with a name
         * -- qty dropdown
         *
         */
        //Will make the name an array and put the time id as a key so we
        //know which event this belongs to
        $multi_name_adjust = $multi_reg == 1 ? "[{$event_id}]" : '';
        $SQL = "SELECT ept.id, ept.event_cost, ept.surcharge, ept.surcharge_type, ept.price_type, edt.allow_multiple, edt.additional_limit ";
        $SQL .= "FROM " . EVENTS_PRICES_TABLE . " ept ";
        $SQL .= "JOIN " . EVENTS_DETAIL_TABLE . "  edt ON ept.event_id =  edt.id ";
        $SQL .= "WHERE event_id=%d ORDER BY ept.id ASC";
        // filter SQL statement
        $SQL = apply_filters('filter_hook_espresso_group_price_dropdown_sql', $SQL);
        // get results
        $results = $wpdb->get_results($wpdb->prepare($SQL, $event_id));
        if ($wpdb->num_rows > 0) {
            $attendee_limit = 1;
            //echo $label==1?'<label for="event_cost">' . __('Choose an Option: ','event_espresso') . '</label>':'';
            //echo '<input type="radio" name="price_option' . $multi_name_adjust . '" id="price_option-' . $event_id . '">';
            ?>
			
<table class="price_list">
	<?php 
            $available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces');
            foreach ($results as $result) {
                //Setting this field for use on the registration form
                $_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['price_type'] = stripslashes_deep($result->price_type);
                // Addition for Early Registration discount
                if ($early_price_data = early_discount_amount($event_id, $result->event_cost)) {
                    $result->event_cost = $early_price_data['event_price'];
                    $message = __(' Early Pricing', 'event_espresso');
                }
                $surcharge = '';
                if ($result->surcharge > 0 && $result->event_cost > 0.0) {
                    $surcharge = " + {$org_options['currency_symbol']}{$result->surcharge} " . $org_options['surcharge_text'];
                    if ($result->surcharge_type == 'pct') {
                        $surcharge = " + {$result->surcharge}% " . $org_options['surcharge_text'];
                    }
                }
                ?>
	<tr>
		<td class="price_type"><?php 
                echo $result->price_type;
                ?>
</td>
		<td class="price"><?php 
                if (!isset($message)) {
                    $message = '';
                }
                echo $org_options['currency_symbol'] . number_format($result->event_cost, 2) . $message . ' ' . $surcharge;
                ?>
</td>
		<td class="selection">
			<?php 
                $attendee_limit = 1;
                $att_qty = empty($_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['attendee_quantity']) ? '' : $_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['attendee_quantity'];
                if ($result->allow_multiple == 'Y') {
                    $attendee_limit = $result->additional_limit;
                    if ($available_spaces != 'Unlimited') {
                        $attendee_limit = $attendee_limit <= $available_spaces ? $attendee_limit : $available_spaces;
                    }
                }
                event_espresso_multi_qty_dd($event_id, $result->id, $attendee_limit, $att_qty);
                ?>
		</td>
	</tr>
	<?php 
            }
            ?>
	<tr>
		<td colspan="3" class="reg-allowed-limit">
			<?php 
            printf(__("You can register a maximum of %d attendees for this event.", 'event_espresso'), $attendee_limit);
            ?>
		</td>
	</tr>
</table>

<input type="hidden" id="max_attendees-<?php 
            echo $event_id;
            ?>
" class="max_attendees" value= "<?php 
            echo $attendee_limit;
            ?>
" />
<?php 
        } else {
            if ($wpdb->num_rows == 0) {
                echo '<span class="free_event">' . __('Free Event', 'event_espresso') . '</span>';
                echo '<input type="hidden" name="payment' . $multi_name_adjust . '" id="payment-' . $event_id . '" value="' . __('free event', 'event_espresso') . '">';
            }
        }
    }
Example #2
0
    function event_espresso_group_price_dropdown($event_id, $label = 1, $multi_reg = 0, $value = '')
    {
        global $wpdb, $org_options;
        /*
         * find out pricing type.
         * - If multiple price options, for each one
         * -- Create a row in a table with a name
         * -- qty dropdown
         *
         */
        //Will make the name an array and put the time id as a key so we
        //know which event this belongs to
        $multi_name_adjust = $multi_reg == 1 ? "[{$event_id}]" : '';
        $results = $wpdb->get_results("SELECT ept.id, ept.event_cost, ept.surcharge, ept.surcharge_type, ept.price_type, edt.allow_multiple, edt.additional_limit\n                                               FROM " . EVENTS_PRICES_TABLE . " ept\n                                               JOIN " . EVENTS_DETAIL_TABLE . "  edt\n                                                   ON ept.event_id =  edt.id\n                                                   WHERE event_id='" . $event_id . "' ORDER BY ept.id ASC");
        if ($wpdb->num_rows > 0) {
            $attendee_limit = 1;
            //echo $label==1?'<label for="event_cost">' . __('Choose an Option: ','event_espresso') . '</label>':'';
            //echo '<input type="radio" name="price_option' . $multi_name_adjust . '" id="price_option-' . $event_id . '">';
            ?>
			<table class="price_list">
			<?php 
            $available_spaces = get_number_of_attendees_reg_limit($event_id, 'number_available_spaces');
            foreach ($results as $result) {
                //Setting this field for use on the registration form
                $_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['price_type'] = $result->price_type;
                // Addition for Early Registration discount
                if (early_discount_amount($event_id, $result->event_cost) != false) {
                    $early_price_data = array();
                    $early_price_data = early_discount_amount($event_id, $result->event_cost);
                    $result->event_cost = $early_price_data['event_price'];
                    $message = __(' Early Pricing', 'event_espresso');
                }
                $surcharge = '';
                if ($result->surcharge > 0 && $result->event_cost > 0.0) {
                    $surcharge = " + {$org_options['currency_symbol']}{$result->surcharge} " . __('Surcharge', 'event_espresso');
                    if ($result->surcharge_type == 'pct') {
                        $surcharge = " + {$result->surcharge}% " . __('Surcharge', 'event_espresso');
                    }
                }
                //echo '<option value="' . number_format($result->event_cost,2) . '|' . $result->price_type . '|' . $result->surcharge . '">' . $result->price_type . ' (' . $org_options['currency_symbol'] .  number_format($result->event_cost,2) . $message  . ') '. $surcharge . ' </option>';
                ?>


					<tr>
						<td class="price_type">
				<?php 
                echo $result->price_type;
                ?>
						</td>
						<td class="price">
							<?php 
                if (!isset($message)) {
                    $message = '';
                }
                echo $org_options['currency_symbol'] . number_format($result->event_cost, 2) . $message . ' ' . $surcharge;
                ?>

						</td>
						<td class="selection">
				<?php 
                if ($result->allow_multiple == 'Y') {
                    $attendee_limit = $result->additional_limit + 1;
                    if ($available_spaces != 'Unlimited') {
                        $attendee_limit = $attendee_limit <= $available_spaces ? $attendee_limit : $available_spaces;
                    }
                    event_espresso_multi_qty_dd($event_id, $result->id, $attendee_limit, empty($_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['attendee_quantity']) ? '' : $_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['attendee_quantity']);
                } else {
                    $checked = $wpdb->num_rows == 1 || array_key_exists($result->id, $_SESSION['espresso_session']['events_in_session'][$event_id]['price_id']) && isset($_SESSION['espresso_session']['events_in_session'][$event_id]['price_id'][$result->id]['attendee_quantity']) ? ' checked="checked"' : '';
                    ?>
								<input type="radio" class="price_id" name="price_id[<?php 
                    echo $event_id;
                    ?>
]" <?php 
                    echo $checked;
                    ?>
 value="<?php 
                    echo $result->id;
                    ?>
" />
								<?php 
                }
                ?>
						</td>

					</tr>


				<?php 
            }
            ?>
				<tr>
					<td colspan="3" class="reg-allowed-limit"><?php 
            printf(__("You can register a maximum of %d attendees for this event.", 'event_espresso'), $attendee_limit);
            ?>
</td>

				</tr>
			</table>
			<input type="hidden" id="max_attendees-<?php 
            echo $event_id;
            ?>
" class="max_attendees" value= "<?php 
            echo $attendee_limit;
            ?>
" />
			<?php 
        } else {
            if ($wpdb->num_rows == 0) {
                echo '<span class="free_event">' . __('Free Event', 'event_espresso') . '</span>';
                echo '<input type="hidden" name="payment' . $multi_name_adjust . '" id="payment-' . $event_id . '" value="' . __('free event', 'event_espresso') . '">';
            }
        }
    }