/** * Sends e-mails to customer and wordpress owner. * * @param BTB_Booking &$booking The booking object to send mails for. * @return int 1 if successfull, 0 if mail to owner failed, -1 if mail to customer failed, -2 if both mails failed */ private static function send_mails(&$booking) { $notifyemail = get_option('btb_notify_to', ''); // email address of the site owne to notify about new bookings $fromemail = get_option('btb_confirm_from', ''); // email address used as from address when sending booking to customer if (empty($notifyemail) && empty($fromemail)) { return -2; } $tags = array('{{salutation}}', '{{title}}', '{{first_name}}', '{{last_name}}', '{{company}}', '{{address}}', '{{address2}}', '{{zip}}', '{{city}}', '{{country}}', '{{mail}}', '{{phone}}', '{{notes}}', '{{event_name}}', '{{event_url}}', '{{event_start_date}}', '{{event_end_date}}', '{{event_start_time}}', '{{event_end_time}}', '{{slots}}', '{{single_price}}', '{{total_price}}', '{{booking_code}}', '{{booking_time}}'); if (get_option('btb_instance_type', 'master') == 'master') { $event = btb_get_event($booking->booked_event); $time = btb_get_time($booking->booked_time); } else { $event = btb_get_event_from_api($booking->booked_event, OBJECT, 'display'); $time = btb_get_time_from_api($booking->booked_time, OBJECT, 'display'); } date_default_timezone_set(get_option('timezone_string', 'UTC')); $replacements = array($booking->title == "mr" ? sprintf(__('Dear Mr. %s %s', 'bt-booking'), $booking->first_name, $booking->last_name) : sprintf(__('Dear Mrs. %s %s', 'bt-booking'), $booking->first_name, $booking->last_name), $booking->title == "mr" ? __('Mr.', 'bt-booking', 'bt-booking') : __('Mrs.', 'bt-booking'), $booking->first_name, $booking->last_name, $booking->company ? $booking->company : '', $booking->address, $booking->address2, $booking->zip, $booking->city, BTBookingCountries::get_country_by_code($booking->country), $booking->email, $booking->phone, $booking->notes, $event->name, btb_get_description_page($event, true), date_i18n(_x('m/d/Y', 'Event date shown in e-mails', 'bt-booking'), $time->start), date_i18n(_x('m/d/Y', 'Event date shown in e-mails', 'bt-booking'), $time->end), $time->date_only ? '' : date_i18n(_x('h:iA', 'Event time shown in e-mails', 'bt-booking'), $time->start), $time->date_only ? '' : date_i18n(_x('h:iA', 'Event time shown in e-mails', 'bt-booking'), $time->end), $booking->booked_slots, get_option('btb_currency', '€') . ' ' . number_format_i18n($booking->price, 2), get_option('btb_currency', '€') . ' ' . number_format_i18n($booking->price * $booking->booked_slots, 2), $booking->code, date_i18n(_x('m/d/Y h:iA', 'Booking time shown in e-mails', 'bt-booking'), $booking->booking_time)); $ret = 1; if (!empty($notifyemail) && !empty($fromemail)) { if (!self::send_mail_to_owner($tags, $replacements, $notifyemail, $fromemail, $booking)) { $ret = 0; } } else { $ret = 0; } if (!empty($fromemail)) { if (!self::send_mail_to_customer($tags, $replacements, $booking, $fromemail)) { $ret = $ret - 2; } } else { $ret = $ret - 2; } return $ret; }
/** * Provides the meta box showing the customers identity data. * * @param object $post */ public static function btb_booking_address_box($post) { $booking = btb_get_booking($post->ID); wp_nonce_field('btb_save_booking_address_box_data', 'btb_booking_addres_box_nonce'); $companyrow = new BTCTableRow(); $companyrow->add_content(BTCWPAdminInputSelect::create('btb_title', __('Form of address', 'bt-booking'), $booking->title, array('mr' => __('Mr.', 'bt-booking'), 'mrs' => __('Mrs.', 'bt-booking')), true)); $companyrow->add_content(BTCWPAdminInputText::create('btb_company', __('Company', 'bt-booking'), $booking->company, true)); $namerow = new BTCTableRow(); $namerow->add_content(BTCWPAdminInputText::create('btb_first_name', __('First name', 'bt-booking'), $booking->first_name, true)); $namerow->add_content(BTCWPAdminInputText::create('btb_last_name', __('Last name', 'bt-booking'), $booking->last_name, true)); $address = get_post_meta($post->ID, 'btb_address'); $a = $address[0]; $addressrow = new BTCTableRow(); $addressrow->add_content(BTCWPAdminInputText::create('btb_address', __('Address', 'bt-booking'), $booking->address, true)); $addressrow->add_content(BTCWPAdminInputText::create('btb_address2', __('Additional address', 'bt-booking'), $booking->address2, true)); $cityrow = new BTCTableRow(); $cityrow->add_content(BTCWPAdminInputText::create('btb_city', __('City', 'bt-booking'), $booking->city, true)); $cityrow->add_content(BTCWPAdminInputText::create('btb_zip', __('Postal code', 'bt-booking'), $booking->zip, true)); $countryrow = new BTCTableRow(); $countryrow->add_content(BTCWPAdminInputSelect::create('btb_country', __('Country', 'bt-booking'), $booking->country, BTBookingCountries::get_countries(), true)); $emailrow = new BTCTableRow(); $emailrow->add_content(BTCWPAdminInputText::create('btb_mail', __('E-mail address', 'bt-booking'), $booking->email, true)); $emailrow->add_content(BTCWPAdminInputText::create('btb_phone', __('Phone number', 'bt-booking'), $booking->phone, true)); $table = new BTCTable(array('htmlClasses' => 'form-table'), new BTCTableBody(array(), array($companyrow, $namerow, $addressrow, $cityrow, $countryrow, $emailrow))); $table->render(); }
/** * Provides the meta box for editinig the venue address. * * The box provides input fields for the addres and map location of the venue. * * @param object $post */ public static function btb_venue_address_box($post) { $venue = btb_get_venue($post->ID); wp_localize_script('btb-edit-venue-script', 'BTBooking', array('lat' => $venue->latitude, 'lng' => $venue->longitude, 'queryErrorMsg' => __('When querying the data an error has occurred.', 'bt-booking'), 'nothingFoundMsg' => __('For the specified address no place could be found.', 'bt-booking'))); wp_enqueue_script('btb-edit-venue-script'); wp_nonce_field('btb_save_venue_address_box_data', 'btb_venue_address_box_nonce'); // Creating first row, showing street name and house number $row1 = new BTCTableRow(); $row1->add_content(BTCWPAdminInputText::create('btb_address_street', esc_html__('Street', 'bt-booking'), $venue->street)); $row1->add_content(BTCWPAdminInputText::create('btb_address_number', esc_html__('Number', 'bt-booking'), $venue->house_number)); // Creating second row, showing postal code and city $row2 = new BTCTableRow(); $row2->add_content(BTCWPAdminInputText::create('btb_address_zip', esc_html__('Postal code', 'bt-booking'), $venue->postal_code)); $row2->add_content(BTCWPAdminInputText::create('btb_address_city', esc_html__('City', 'bt-booking'), $venue->city)); // Creating third row, showing state/region and country $row3 = new BTCTableRow(); $row3->add_content(BTCWPAdminInputText::create('btb_address_region', esc_html__('State/Region', 'bt-booking'), $venue->region)); $row3->add_content(BTCWPAdminInputSelect::create('btb_address_country', esc_html__('Country', 'bt-booking'), $venue->country, BTBookingCountries::get_countries())); // Creating fourth row, showing switch for using map coordinates $row4 = new BTCTableRow(); $row4->add_content(BTCWPAdminInputCheckbox::create('btb_use_coordinates', esc_html__('Use map coordinates', 'bt-booking'), $venue->use_map_coords)); $row4->add_content(new BTCTableData()); $saButtonAttrs = array('id' => 'search_address', 'type' => 'button', 'htmlClasses' => 'button button-small'); if (!$venue->use_map_coords) { $saButtonAttrs["style"] = "display:none"; } $row4->add_content(new BTCTableData(new BTCFormButton($saButtonAttrs, esc_html__('Search address', 'bt-booking')))); $table = new BTCTable(array('htmlClasses' => 'form-table'), new BTCTableBody(array(), array($row1, $row2, $row3, $row4))); $table->render(); $loc_table = new BTCTable(array('id' => 'locs_table', 'htmlClasses' => 'form-table', 'style' => 'display:none;')); $loc_head_row = new BTCTableRow(); $thstyle = array('padding' => '15px 10px'); $loc_head_row->add_content(new BTCTableData(esc_html__('Choose', 'bt-booking'), array('style' => $thstyle), true)); $loc_head_row->add_content(new BTCTableData(esc_html__('Street & No.', 'bt-booking'), array('style' => $thstyle), true)); $loc_head_row->add_content(new BTCTableData(esc_html__('City', 'bt-booking'), array('style' => $thstyle), true)); $loc_head_row->add_content(new BTCTableData(esc_html__('ZIP', 'bt-booking'), array('style' => $thstyle), true)); $loc_head_row->add_content(new BTCTableData(esc_html__('State', 'bt-booking'), array('style' => $thstyle), true)); $loc_head = new BTCTableHead(array(), $loc_head_row); $loc_body = new BTCTableBody(array('id' => 'locs_body')); $loc_table->head = $loc_head; $loc_table->body = $loc_body; $loc_table->render(); ?> <input type="hidden" id="btb_address_lat" name="btb_address_lat" value="<?php echo $venue->latitude; ?> "> <input type="hidden" id="btb_address_lon" name="btb_address_lon" value="<?php echo $venue->longitude; ?> "> <div id="mapMessages"> </div> <div id="venueMap" style="height:300px;<?php echo $venue->use_map_coords ? '' : ' display:none'; ?> "> </div> <?php }
public function struct_data_address_country_cb() { BTCWPSettingsFormSelect::render('btb_struct_data_country', BTBookingCountries::get_countries(), get_option('btb_struct_data_country', ''), esc_html__('Country of your organization\'s address.', 'bt-booking')); }