bricks_widget_book_button.php
1 year ago
bricks_widget_book_form.php
1 year ago
bricks_widget_calendar.php
1 year ago
bricks_widget_customer_dashboard.php
1 year ago
bricks_widget_customer_login.php
1 year ago
bricks_widget_list_of_resources.php
1 year ago
bricks_widget_book_form.php
248 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class Latepoint_Bricks_Widget_Book_Form extends \Bricks\Element { |
| 8 | |
| 9 | public $category = 'latepoint'; |
| 10 | public $name = 'latepoint_book_form'; |
| 11 | public $icon = 'ti-layout-media-right-alt'; |
| 12 | public $scripts = ['init_booking_form']; |
| 13 | |
| 14 | |
| 15 | public function get_label(): string { |
| 16 | return esc_html__( 'Booking Form', 'latepoint' ); |
| 17 | } |
| 18 | |
| 19 | public function enqueue_scripts() { |
| 20 | if ( bricks_is_builder() ) { |
| 21 | wp_enqueue_script( |
| 22 | 'bricks_widget_book_form_script', |
| 23 | LATEPOINT_PLUGIN_URL . 'blocks/assets/javascripts/bricks-widget-book-form.js', |
| 24 | [ 'jquery' ], |
| 25 | LATEPOINT_VERSION |
| 26 | ); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | public function set_control_groups() { |
| 31 | $this->control_groups['general'] = array( |
| 32 | 'title' => esc_html__( 'Booking Form Settings', 'latepoint' ), |
| 33 | 'tab' => 'content', |
| 34 | ); |
| 35 | $this->control_groups['step_settings'] = array( |
| 36 | 'title' => esc_html__( 'Step Settings', 'latepoint' ), |
| 37 | 'tab' => 'content', |
| 38 | ); |
| 39 | $this->control_groups['other_settings'] = array( |
| 40 | 'title' => esc_html__( 'Other Settings', 'latepoint' ), |
| 41 | 'tab' => 'content', |
| 42 | ); |
| 43 | } |
| 44 | |
| 45 | // Set builder controls |
| 46 | public function set_controls() { |
| 47 | $this->controls['_width']['default'] = '100%'; |
| 48 | |
| 49 | $this->controls['hide_summary'] = array( |
| 50 | 'tab' => 'content', |
| 51 | 'group' => 'general', |
| 52 | 'label' => esc_html__( 'Hide Summary Panel', 'latepoint' ), |
| 53 | 'type' => 'checkbox', |
| 54 | 'inline' => true, |
| 55 | ); |
| 56 | |
| 57 | $this->controls['hide_side_panel'] = array( |
| 58 | 'tab' => 'content', |
| 59 | 'group' => 'general', |
| 60 | 'label' => esc_html__( 'Hide Side Panel', 'latepoint' ), |
| 61 | 'type' => 'checkbox', |
| 62 | 'inline' => true, |
| 63 | ); |
| 64 | |
| 65 | |
| 66 | #step settings group |
| 67 | |
| 68 | $this->controls['selected_agent'] = [ |
| 69 | 'tab' => 'content', |
| 70 | 'group' => 'step_settings', |
| 71 | 'label' => esc_html__( 'Preselected Agent', 'latepoint' ), |
| 72 | 'type' => 'select', |
| 73 | 'options' => OsBricksHelper::get_data('selected_agents'), |
| 74 | 'placeholder' => esc_html__( 'Preselected Agent', 'latepoint' ), |
| 75 | 'searchable' => true, |
| 76 | 'clearable' => true, |
| 77 | ]; |
| 78 | $this->controls['selected_service'] = [ |
| 79 | 'tab' => 'content', |
| 80 | 'group' => 'step_settings', |
| 81 | 'label' => esc_html__( 'Preselected Service', 'latepoint' ), |
| 82 | 'type' => 'select', |
| 83 | 'options' => OsBricksHelper::get_data('selected_services'), |
| 84 | 'placeholder' => esc_html__( 'Preselected Service', 'latepoint' ), |
| 85 | 'searchable' => true, |
| 86 | 'clearable' => true, |
| 87 | ]; |
| 88 | $this->controls['selected_service_category'] = [ |
| 89 | 'tab' => 'content', |
| 90 | 'group' => 'step_settings', |
| 91 | 'label' => esc_html__( 'Preselected Service Category', 'latepoint' ), |
| 92 | 'type' => 'select', |
| 93 | 'options' => OsBricksHelper::get_data('selected_service_categories'), |
| 94 | 'placeholder' => esc_html__( 'Preselected Service Category', 'latepoint' ), |
| 95 | 'searchable' => true, |
| 96 | 'clearable' => true, |
| 97 | ]; |
| 98 | $this->controls['selected_location'] = [ |
| 99 | 'tab' => 'content', |
| 100 | 'group' => 'step_settings', |
| 101 | 'label' => esc_html__( 'Preselected Location', 'latepoint' ), |
| 102 | 'type' => 'select', |
| 103 | 'options' => OsBricksHelper::get_data('selected_locations'), |
| 104 | 'placeholder' => esc_html__( 'Preselected Location', 'latepoint' ), |
| 105 | 'searchable' => true, |
| 106 | 'clearable' => true, |
| 107 | ]; |
| 108 | $this->controls['selected_start_date'] = [ |
| 109 | 'tab' => 'content', |
| 110 | 'group' => 'step_settings', |
| 111 | 'label' => esc_html__( 'Preselected Booking Start Date', 'latepoint' ), |
| 112 | 'type' => 'datepicker', |
| 113 | 'inline' => true, |
| 114 | 'options' => [ |
| 115 | 'enableTime' => false, |
| 116 | 'time_24hr' => true |
| 117 | ] |
| 118 | ]; |
| 119 | $this->controls['selected_start_time'] = [ |
| 120 | 'tab' => 'content', |
| 121 | 'group' => 'step_settings', |
| 122 | 'label' => esc_html__( 'Preselected Booking Start Time', 'latepoint' ), |
| 123 | 'type' => 'datepicker', |
| 124 | 'inline' => true, |
| 125 | 'options' => [ |
| 126 | 'enableTime' => true, |
| 127 | 'time_24hr' => true, |
| 128 | 'noCalendar' => true |
| 129 | ] |
| 130 | ]; |
| 131 | |
| 132 | $this->controls['selected_duration'] = [ |
| 133 | 'tab' => 'content', |
| 134 | 'group' => 'step_settings', |
| 135 | 'label' => esc_html__( 'Preselected Duration', 'latepoint' ), |
| 136 | 'type' => 'number', |
| 137 | 'min' => 0, |
| 138 | 'inline' => true, |
| 139 | ]; |
| 140 | $this->controls['selected_total_attendees'] = [ |
| 141 | 'tab' => 'content', |
| 142 | 'group' => 'step_settings', |
| 143 | 'label' => esc_html__( 'Preselected Total Attendees', 'latepoint' ), |
| 144 | 'type' => 'number', |
| 145 | 'min' => 0, |
| 146 | 'inline' => true, |
| 147 | ]; |
| 148 | |
| 149 | |
| 150 | #other settings |
| 151 | $this->controls['source_id'] = [ |
| 152 | 'tab' => 'content', |
| 153 | 'group' => 'other_settings', |
| 154 | 'label' => esc_html__( 'Source ID', 'latepoint' ), |
| 155 | 'type' => 'number', |
| 156 | 'min' => 0, |
| 157 | 'inline' => true, |
| 158 | ]; |
| 159 | $this->controls['calendar_start_date'] = [ |
| 160 | 'tab' => 'content', |
| 161 | 'group' => 'other_settings', |
| 162 | 'label' => esc_html__( 'Calendar Start Date', 'latepoint' ), |
| 163 | 'type' => 'datepicker', |
| 164 | 'inline' => true, |
| 165 | 'options' => [ |
| 166 | 'enableTime' => false, |
| 167 | 'time_24hr' => true |
| 168 | ] |
| 169 | ]; |
| 170 | $this->controls['show_services'] = [ |
| 171 | 'tab' => 'content', |
| 172 | 'group' => 'other_settings', |
| 173 | 'label' => esc_html__( 'Show Services', 'latepoint' ), |
| 174 | 'type' => 'select', |
| 175 | 'options' => OsBricksHelper::get_data('services'), |
| 176 | 'placeholder' => esc_html__( 'Show Services', 'latepoint' ), |
| 177 | 'multiple' => true, |
| 178 | 'searchable' => true, |
| 179 | 'clearable' => true, |
| 180 | ]; |
| 181 | $this->controls['show_service_categories'] = [ |
| 182 | 'tab' => 'content', |
| 183 | 'group' => 'other_settings', |
| 184 | 'label' => esc_html__( 'Show Service Categories', 'latepoint' ), |
| 185 | 'type' => 'select', |
| 186 | 'options' => OsBricksHelper::get_data('service_categories'), |
| 187 | 'placeholder' => esc_html__( 'Show Service Categories', 'latepoint' ), |
| 188 | 'multiple' => true, |
| 189 | 'searchable' => true, |
| 190 | 'clearable' => true, |
| 191 | ]; |
| 192 | $this->controls['show_agents'] = [ |
| 193 | 'tab' => 'content', |
| 194 | 'group' => 'other_settings', |
| 195 | 'label' => esc_html__( 'Show Agents', 'latepoint' ), |
| 196 | 'type' => 'select', |
| 197 | 'options' => OsBricksHelper::get_data('agents'), |
| 198 | 'placeholder' => esc_html__( 'Show Agents', 'latepoint' ), |
| 199 | 'multiple' => true, |
| 200 | 'searchable' => true, |
| 201 | 'clearable' => true, |
| 202 | ]; |
| 203 | |
| 204 | $this->controls['show_locations'] = [ |
| 205 | 'tab' => 'content', |
| 206 | 'group' => 'other_settings', |
| 207 | 'label' => esc_html__( 'Show Locations', 'latepoint' ), |
| 208 | 'type' => 'select', |
| 209 | 'options' => OsBricksHelper::get_data('locations'), |
| 210 | 'placeholder' => esc_html__( 'Show Locations', 'latepoint' ), |
| 211 | 'multiple' => true, |
| 212 | 'searchable' => true, |
| 213 | 'clearable' => true, |
| 214 | ]; |
| 215 | |
| 216 | |
| 217 | } |
| 218 | |
| 219 | |
| 220 | // Render element HTML |
| 221 | public function render() { |
| 222 | |
| 223 | $allowed_params = [ |
| 224 | 'hide_summary', |
| 225 | 'hide_side_panel', |
| 226 | 'selected_agent', |
| 227 | 'selected_service', |
| 228 | 'selected_service_category', |
| 229 | 'selected_location', |
| 230 | 'selected_start_date', |
| 231 | 'selected_start_time', |
| 232 | 'selected_duration', |
| 233 | 'selected_total_attendees', |
| 234 | 'source_id', |
| 235 | 'calendar_start_date', |
| 236 | 'show_services', |
| 237 | 'show_service_categories', |
| 238 | 'show_agents', |
| 239 | 'show_locations', |
| 240 | ]; |
| 241 | |
| 242 | $params = OsBlockHelper::attributes_to_data_params($this->settings, $allowed_params); |
| 243 | $output = "<div {$this->render_attributes( '_root' )}>"; |
| 244 | $output .= do_shortcode('[latepoint_book_form ' . $params . ']'); |
| 245 | $output .= '</div>'; |
| 246 | echo $output; |
| 247 | } |
| 248 | } |