function get_form_content($formdata, $bktype = -1, $booking_form_show = '', $extended_params = array()) { //debuge($formdata, $bktype , $booking_form_show, $extended_params); if ($bktype == -1) { if (function_exists('get__default_type')) { $bktype = get__default_type(); } else { $bktype = 1; } } if ($booking_form_show === '') { if (function_exists('get_booking_title')) { //RECHECK HERE ACCORDING MULTISUSE SPECIFIC BOOKING FORM $booking_form_show = get_bk_option('booking_form_show'); if (class_exists('wpdev_bk_biz_m')) { $is_recehck_for_custom_form = true; $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'only_super_admin'); if (class_exists('wpdev_bk_multiuser') && $is_can) { $is_recehck_for_custom_form = false; $user_bk_id = apply_bk_filter('get_user_of_this_bk_resource', false, $bktype); $user = wp_get_current_user(); if ($user_bk_id !== false && $user->ID != $user_bk_id) { // Only for the Super Booking Admin User, get the booking form of the specific user $is_user_super_admin = apply_bk_filter('is_user_super_admin', $user_bk_id); if (!$is_user_super_admin) { $booking_form_show = get_user_option('booking_form_show', $user_bk_id); } $my_booking_form_name = apply_bk_filter('wpdev_get_default_booking_form_for_resource', 'standard', $bktype); if ($my_booking_form_name != 'standard' && !empty($my_booking_form_name)) { $booking_forms_extended = get_user_option('booking_forms_extended', $user_bk_id); $booking_form_show = apply_bk_filter('wpdev_get_booking_form_content', $booking_form_show, $my_booking_form_name, $booking_forms_extended); } } else { $is_recehck_for_custom_form = true; } } if ($is_recehck_for_custom_form) { // Recheck for the CUSTOM FORM $my_booking_form_name = apply_bk_filter('wpdev_get_default_booking_form_for_resource', 'standard', $bktype); if ($my_booking_form_name != 'standard' && !empty($my_booking_form_name)) { $booking_form_show = apply_bk_filter('wpdev_get_booking_form_content', $booking_form_show, $my_booking_form_name); } } } } else { // Standard $booking_form_show = get_booking_form_show(); } $booking_form_show = apply_bk_filter('wpdev_check_for_active_language', $booking_form_show); // Translation recehck } //debuge($formdata, $bktype, $booking_form_show); $formdata_array = explode('~', $formdata); $formdata_array_count = count($formdata_array); $email_adress = ''; $name_of_person = ''; $coupon_code = ''; $secondname_of_person = ''; $visitors_count = 1; $select_box_selected_items = array(); $check_box_selected_items = array(); $all_fields_array = array(); $all_fields_array_without_types = array(); $checkbox_value = array(); for ($i = 0; $i < $formdata_array_count; $i++) { $elemnts = explode('^', $formdata_array[$i]); $type = $elemnts[0]; $element_name = $elemnts[1]; $value = $elemnts[2]; $value = nl2br($value); // Add BR instead if /n elements $count_pos = strlen($bktype); $type_name = $elemnts[1]; $type_name = str_replace('[]', '', $type_name); if ($bktype == substr($type_name, -1 * $count_pos)) { $type_name = substr($type_name, 0, -1 * $count_pos); } // $type_name = str_replace($bktype,'',$elemnts[1]); if ($type_name == 'email' || $type == 'email') { $email_adress = $value; } if ($type_name == 'coupon' || $type == 'coupon') { $coupon_code = $value; } if ($type_name == 'name' || $type == 'name') { $name_of_person = $value; } if ($type_name == 'secondname' || $type == 'secondname') { $secondname_of_person = $value; } if ($type_name == 'visitors' || $type == 'visitors') { $visitors_count = $value; } if ($type == 'checkbox') { //debuge($type_name , $type, $element_name, $value); // children checkbox children11[] true if ($value == 'true') { $value = __('yes', 'wpdev-booking'); } if ($value == 'false') { $value = __('no', 'wpdev-booking'); } if ($value != '') { if (isset($checkbox_value[str_replace('[]', '', (string) $element_name)]) && is_array($checkbox_value[str_replace('[]', '', (string) $element_name)])) { $checkbox_value[str_replace('[]', '', (string) $element_name)][] = $value; } else { //if ($value != __('yes', 'wpdev-booking') ) $checkbox_value[str_replace('[]', '', (string) $element_name)] = array($value); //else //$checkbox_value[ str_replace('[]','',(string) $element_name) ] = 'checkbox'; } } $value = $value . ' ' . '[' . $type_name . ']'; } if ($type == 'select-one') { // add all select box selected items to return array $select_box_selected_items[$type_name] = $value; } if ($type == 'checkbox' && isset($checkbox_value)) { if (isset($checkbox_value[str_replace('[]', '', (string) $element_name)])) { if (is_array($checkbox_value[str_replace('[]', '', (string) $element_name)])) { $current_checkbox_value = implode(', ', $checkbox_value[str_replace('[]', '', (string) $element_name)]); } else { $current_checkbox_value = $checkbox_value[str_replace('[]', '', (string) $element_name)]; } } else { $current_checkbox_value = ''; } $all_fields_array[str_replace('[]', '', (string) $element_name)] = $current_checkbox_value; $all_fields_array_without_types[substr(str_replace('[]', '', (string) $element_name), 0, -1 * strlen($bktype))] = $current_checkbox_value; $check_box_selected_items[$type_name] = $current_checkbox_value; } else { $all_fields_array[str_replace('[]', '', (string) $element_name)] = $value; $all_fields_array_without_types[substr(str_replace('[]', '', (string) $element_name), 0, -1 * strlen($bktype))] = $value; } $booking_form_show = str_replace('[' . $type_name . ']', $value, $booking_form_show); } // Remove all shortcodes, which is not replaced early. $booking_form_show = preg_replace('/[\\s]{0,}\\[[a-zA-Z0-9.,-_]{0,}\\][\\s]{0,}/', '', $booking_form_show); if (!isset($all_fields_array_without_types['booking_resource_id'])) { $all_fields_array_without_types['booking_resource_id'] = $bktype; } if (!isset($all_fields_array_without_types['resource_id'])) { $all_fields_array_without_types['resource_id'] = $bktype; } if (!isset($all_fields_array_without_types['type_id'])) { $all_fields_array_without_types['type_id'] = $bktype; } if (!isset($all_fields_array_without_types['type'])) { $all_fields_array_without_types['type'] = $bktype; } if (!isset($all_fields_array_without_types['resource'])) { $all_fields_array_without_types['resource'] = $bktype; } foreach ($extended_params as $key_param => $value_param) { if (!isset($all_fields_array_without_types[$key_param])) { $all_fields_array_without_types[$key_param] = $value_param; } } $return_array = array('content' => $booking_form_show, 'email' => $email_adress, 'name' => $name_of_person, 'secondname' => $secondname_of_person, 'visitors' => $visitors_count, 'coupon' => $coupon_code, '_all_' => $all_fields_array, '_all_fields_' => $all_fields_array_without_types); foreach ($select_box_selected_items as $key => $value) { if (!isset($return_array[$key])) { $return_array[$key] = $value; } } foreach ($check_box_selected_items as $key => $value) { if (!isset($return_array[$key])) { $return_array[$key] = $value; } } //debuge($return_array); return $return_array; }
function get_form_content($formdata, $bktype = -1, $booking_form_show = '') { if ($bktype == -1) { if (function_exists('get__default_type')) { $bktype = get__default_type(); } else { $bktype = 1; } } if ($booking_form_show === '') { if (function_exists('get_booking_title')) { $booking_form_show = get_bk_option('booking_form_show'); } else { $booking_form_show = get_booking_form_show(); } $booking_form_show = apply_bk_filter('wpdev_check_for_active_language', $booking_form_show); } //debuge($booking_form_show, $formdata, $bktype); $formdata_array = explode('~', $formdata); $formdata_array_count = count($formdata_array); $email_adress = ''; $name_of_person = ''; $coupon_code = ''; $secondname_of_person = ''; $visitors_count = 1; $select_box_selected_items = array(); $check_box_selected_items = array(); $all_fields_array = array(); $checkbox_values = array(); for ($i = 0; $i < $formdata_array_count; $i++) { $elemnts = explode('^', $formdata_array[$i]); //debuge($elemnts); $type = $elemnts[0]; $element_name = $elemnts[1]; $value = $elemnts[2]; $count_pos = strlen($bktype); //debuge(substr( $elemnts[1], 0, -1*$count_pos )) ; $type_name = $elemnts[1]; $type_name = str_replace('[]', '', $type_name); if ($bktype == substr($type_name, -1 * $count_pos)) { $type_name = substr($type_name, 0, -1 * $count_pos); } // $type_name = str_replace($bktype,'',$elemnts[1]); if ($type_name == 'email' || $type == 'email') { $email_adress = $value; } if ($type_name == 'coupon' || $type == 'coupon') { $coupon_code = $value; } if ($type_name == 'name' || $type == 'name') { $name_of_person = $value; } if ($type_name == 'secondname' || $type == 'secondname') { $secondname_of_person = $value; } if ($type_name == 'visitors' || $type == 'visitors') { $visitors_count = $value; } if ($type == 'checkbox') { if ($value == 'true') { $value = __('yes', 'wpdev-booking'); } if ($value == 'false') { $value = __('no', 'wpdev-booking'); } if ($value != '' && $value != __('no', 'wpdev-booking')) { if (isset($checkbox_value[str_replace('[]', '', (string) $element_name)]) && is_array($checkbox_value[str_replace('[]', '', (string) $element_name)])) { $checkbox_value[str_replace('[]', '', (string) $element_name)][] = $value; } else { if ($value != __('yes', 'wpdev-booking')) { $checkbox_value[str_replace('[]', '', (string) $element_name)] = array($value); } else { $checkbox_value[str_replace('[]', '', (string) $element_name)] = 'checkbox'; } } } $value = $value . ' ' . '[' . $type_name . ']'; } if ($type == 'select-one') { // add all select box selected items to return array $select_box_selected_items[$type_name] = $value; } if ($type == 'checkbox' && isset($checkbox_value)) { $all_fields_array[str_replace('[]', '', (string) $element_name)] = $checkbox_value[str_replace('[]', '', (string) $element_name)]; $check_box_selected_items[$type_name] = $checkbox_value[str_replace('[]', '', (string) $element_name)]; } else { $all_fields_array[str_replace('[]', '', (string) $element_name)] = $value; } $booking_form_show = str_replace('[' . $type_name . ']', $value, $booking_form_show); } // Remove all shortcodes, which is not replaced early. $booking_form_show = preg_replace('/[\\s]{0,}\\[[a-zA-Z0-9.,-_]{0,}\\][\\s]{0,}/', '', $booking_form_show); $return_array = array('content' => $booking_form_show, 'email' => $email_adress, 'name' => $name_of_person, 'secondname' => $secondname_of_person, 'visitors' => $visitors_count, 'coupon' => $coupon_code, '_all_' => $all_fields_array); foreach ($select_box_selected_items as $key => $value) { if (!isset($return_array[$key])) { $return_array[$key] = $value; } } foreach ($check_box_selected_items as $key => $value) { if (!isset($return_array[$key])) { $return_array[$key] = $value; } } //debuge($return_array); return $return_array; }