/** * Add a booking into this event object, checking that there's enough space for the event * @param EM_Ticket_Booking $EM_Ticket_Booking * @return boolean */ function add($EM_Ticket_Booking, $override = false) { //note, $override was a quick fix, not necessarily permanent, so don't depend on it just yet global $wpdb, $EM_Mailer; //Does the ticket we want to book have enough spaeces? if ($override || $EM_Ticket_Booking->get_ticket()->get_available_spaces() >= $EM_Ticket_Booking->get_spaces()) { $ticket_booking_key = $this->has_ticket($EM_Ticket_Booking->ticket_id); $this->price = 0; //so price calculations are reset if ($ticket_booking_key !== false && is_object($this->tickets_bookings[$EM_Ticket_Booking->ticket_id])) { //previously booked ticket, so let's just reset spaces/prices and replace it $this->tickets_bookings[$EM_Ticket_Booking->ticket_id]->ticket_booking_spaces = $EM_Ticket_Booking->get_spaces(); $this->tickets_bookings[$EM_Ticket_Booking->ticket_id]->ticket_booking_price = $EM_Ticket_Booking->get_price(); return apply_filters('em_tickets_bookings_add', true, $this); } elseif ($EM_Ticket_Booking->get_spaces() > 0) { //new ticket in booking $this->tickets_bookings[$EM_Ticket_Booking->ticket_id] = $EM_Ticket_Booking; $this->get_spaces(true); $this->get_price(); return apply_filters('em_tickets_bookings_add', true, $this); } } else { $this->add_error(get_option('dbem_booking_feedback_full')); return apply_filters('em_tickets_bookings_add', false, $this); } return apply_filters('em_tickets_bookings_add', false, $this); }
/** * Add a booking into this event object, checking that there's enough space for the event * @param EM_Ticket_Booking $EM_Ticket_Booking * @return boolean */ function add($EM_Ticket_Booking, $override = false) { //note, $override was a quick fix, not necessarily permanent, so don't depend on it just yet global $wpdb, $EM_Mailer; //Does the ticket we want to book have enough spaeces? if ($override || $EM_Ticket_Booking->get_ticket()->get_available_spaces() >= $EM_Ticket_Booking->get_spaces()) { $ticket_booking_key = $this->has_ticket($EM_Ticket_Booking->ticket_id); if ($ticket_booking_key !== false && is_object($this->tickets_bookings[$ticket_booking_key])) { //previously booked ticket, so let's just replace it $this->tickets_bookings[$ticket_booking_key]->ticket_booking_spaces = $EM_Ticket_Booking->get_spaces(); $this->tickets_bookings[$ticket_booking_key]->get_price(true); return apply_filters('em_tickets_bookings_add', true, $this); } elseif ($EM_Ticket_Booking->get_spaces() > 0) { //new ticket in booking $this->tickets_bookings[] = $EM_Ticket_Booking; $this->get_spaces(true); $this->get_price(true); return apply_filters('em_tickets_bookings_add', true, $this); } } else { $this->errors[] = __('Booking cannot be made, not enough spaces available!', 'dbem'); return apply_filters('em_tickets_bookings_add', false, $this); } return apply_filters('em_tickets_bookings_add', false, $this); }
/** * Add a booking into this event object, checking that there's enough space for the event * @param EM_Ticket_Booking $EM_Ticket_Booking * @return boolean */ function add($EM_Ticket_Booking) { global $wpdb, $EM_Mailer; //Does the ticket we want to book have enough spaeces? if ($EM_Ticket_Booking->get_spaces() > 0) { if ($EM_Ticket_Booking->get_ticket()->get_available_spaces() >= $EM_Ticket_Booking->get_spaces()) { $this->tickets_bookings[] = $EM_Ticket_Booking; $this->get_spaces(true); $this->get_price(true); return apply_filters('em_tickets_bookings_add', true, $this); } else { $this->errors[] = __('Booking cannot be made, not enough spaces available!', 'dbem'); return apply_filters('em_tickets_bookings_add', false, $this); } } return apply_filters('em_tickets_bookings_add', false, $this); }
/** * Returns a formatted multi-dimensional associative array of attendee information for a specific booking ticket. * example : array('Attendee 1' => array('Label'=>'Value', 'Label 2'=>'Value 2'), 'Attendee 2' => array(...)...); * @param EM_Ticket_Booking $EM_Ticket_Booking * @param boolean $padding * @return array $attendees */ public static function get_ticket_attendees($EM_Ticket_Booking, $padding = false) { $attendees = array(); $EM_Form = EM_Attendees_Form::get_form($EM_Ticket_Booking->get_booking()->event_id); //can be repeated since object is stored temporarily if (!empty($EM_Ticket_Booking->get_booking()->booking_meta['attendees'][$EM_Ticket_Booking->ticket_id]) && is_array($EM_Ticket_Booking->get_booking()->booking_meta['attendees'][$EM_Ticket_Booking->ticket_id])) { $i = 1; //counter foreach ($EM_Ticket_Booking->get_booking()->booking_meta['attendees'][$EM_Ticket_Booking->ticket_id] as $field_values) { $EM_Form->field_values = $field_values; //output the field values $key = sprintf(__('Attendee %s', 'em-pro'), $i); $attendees[$key] = array(); foreach ($EM_Form->form_fields as $fieldid => $field) { if (!array_key_exists($fieldid, $EM_Form->user_fields) && $field['type'] != 'html') { $field_value = isset($EM_Form->field_values[$fieldid]) ? $EM_Form->field_values[$fieldid] : 'n/a'; $attendees[$key][$field['label']] = $EM_Form->get_formatted_value($field, $field_value); } } $i++; } } elseif ($padding) { //no attendees so pad with empty values for ($space_no = 1; $space_no <= $EM_Ticket_Booking->ticket_booking_spaces; $space_no++) { $key = sprintf(__('Attendee %s', 'em-pro'), $space_no); $attendees[$key] = array(); foreach ($EM_Form->form_fields as $fieldid => $field) { if (!array_key_exists($fieldid, $EM_Form->user_fields) && $field['type'] != 'html') { $attendees[$key][$field['label']] = $EM_Form->get_formatted_value($field, 'n/a'); } } } } return $attendees; }