PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
booking / includes / page-resource-capacity / class-wpbc-settings-api-capacity.php

class-wpbc-settings-api-capacity.php in Booking Calendar 11.9, at includes/page-resource-capacity/class-wpbc-settings-api-capacity.php

236 lines 9.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Capacity Rules settings API.
4 *
5 * @package Booking Calendar
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * Capacity settings fields.
14 */
15 class WPBC_Settings_API_Capacity extends WPBC_Settings_API {
16
17 /**
18 * Constructor.
19 *
20 * @param string $id Settings ID.
21 */
22 public function __construct( $id = '' ) {
23
24 $options = array(
25 'db_prefix_option' => '',
26 'db_saving_type' => 'separate',
27 'id' => 'set_gen',
28 );
29
30 $id = empty( $id ) ? $options['id'] : $id;
31
32 parent::__construct( $id, $options );
33 }
34
35 /**
36 * Init Capacity fields.
37 *
38 * @return void
39 */
40 public function init_settings_fields() {
41
42 $this->fields = array();
43
44 $default_options_values = wpbc_get_default_options();
45
46 if ( class_exists( 'wpdev_bk_biz_l' ) ) {
47 $this->fields['booking_quantity_control'] = array(
48 'type' => 'checkbox',
49 'default' => $default_options_values['booking_quantity_control'],
50 'title' => __( 'Booking Quantity Control', 'booking' ),
51 'label' => __( 'Enable this option to allow visitors to define the number of items they can book for specific dates or times within a single reservation. ', 'booking' ),
52 'description' => __( 'If disabled, visitors can book only one slot within a single reservation.', 'booking' ),
53 'description_tag' => 'p',
54 'group' => 'capacity',
55 );
56
57 $this->fields['booking_capacity_field'] = array(
58 'type' => 'select',
59 'default' => $default_options_values['booking_capacity_field'],
60 'title' => __( 'Quantity field name', 'booking' ),
61 'description' => sprintf( __( 'Select the field that will control how many slots visitors can book during the reservation process.', 'booking' ), '<b>', '</b>' ),
62 'description_tag' => 'span',
63 'css' => '',
64 'tr_class' => 'wpbc_booking_capacity_field_settings wpbc_sub_settings_grayed',
65 'options' => $this->get_quantity_field_options(),
66 'group' => 'capacity',
67 );
68
69 $this->fields['booking_is_dissbale_booking_for_different_sub_resources'] = array(
70 'type' => 'checkbox',
71 'default' => $default_options_values['booking_is_dissbale_booking_for_different_sub_resources'],
72 'title' => __( 'Disable bookings in different booking resources', 'booking' ),
73 'label' => __( 'Check this box to disable reservations, which can be stored in different booking resources.', 'booking' ),
74 'description' => '<strong>' . esc_html__( 'Note', 'booking' ) . '!</strong> ' . esc_html__( 'When checked, all reserved days must be at same booking resource otherwise error message will show.', 'booking' ),
75 'group' => 'capacity',
76 );
77
78 $this->fields['hr_calendar_before_is_use_visitors_number_for_availability'] = array(
79 'type' => 'hr',
80 'group' => 'capacity',
81 );
82 }
83
84 $this->fields['booking_is_days_always_available'] = array(
85 'type' => 'checkbox',
86 'default' => $default_options_values['booking_is_days_always_available'],
87 'title' => __( 'Allow unlimited bookings per same day(s)', 'booking' ),
88 /* translators: 1: ... */
89 'label' => sprintf( __( 'Check this box, if you want to %1$sset any days as available%2$s in calendar. Your visitors will be able to make %3$sunlimited bookings per same date(s) in calendar and do not see any booked date(s)%4$s of other visitors.', 'booking' ), '<strong>', '</strong>', '<strong>', '</strong>' ),
90 'description' => '',
91 'group' => 'capacity',
92 );
93
94 if ( class_exists( 'wpdev_bk_biz_l' ) ) {
95 $this->fields['booking_is_show_pending_days_as_available'] = array(
96 'type' => 'checkbox',
97 'default' => $default_options_values['booking_is_show_pending_days_as_available'],
98 'title' => __( 'Use pending days as available', 'booking' ),
99 'label' => __( 'Check this box if you want to show the pending days as available in calendars', 'booking' ),
100 'description' => '',
101 'group' => 'capacity',
102 'tr_class' => '',
103 );
104
105 $this->fields['booking_auto_cancel_pending_bookings_for_approved_date'] = array(
106 'type' => 'checkbox',
107 'default' => $default_options_values['booking_auto_cancel_pending_bookings_for_approved_date'],
108 'title' => __( 'Auto-cancel bookings', 'booking' ),
109 'label' => __( 'Auto Cancel all pending bookings for the specific date(s), if some booking is approved for these date(s)', 'booking' ),
110 'description' => '',
111 'group' => 'capacity',
112 'tr_class' => 'wpbc_pending_days_as_available_sub_settings wpbc_sub_settings_grayed',
113 );
114 } else {
115 $this->fields['booking_is_show_pending_days_as_available'] = array(
116 'type' => 'checkbox',
117 'default' => $default_options_values['booking_is_show_pending_days_as_available'],
118 'title' => __( 'Use pending days as available', 'booking' ),
119 'label' => __( 'Check this box if you want to show the pending days as available in calendars', 'booking' ),
120 'description' => '',
121 'group' => 'capacity',
122 'tr_class' => '',
123 );
124 }
125
126 if ( ! class_exists( 'wpdev_bk_personal' ) ) {
127 $this->fields['booking_quantity_control__promote_upgrade'] = array(
128 'type' => 'checkbox',
129 'default' => 'On',
130 'value' => 'On',
131 'title' => __( 'Booking Quantity Control', 'booking' ),
132 'label' => __( 'Enable this option to allow visitors to define the number of items they can book for specific dates or times within a single reservation. ', 'booking' ),
133 'description' => __( 'If disabled, visitors can book only one slot within a single reservation.', 'booking' ),
134 'description_tag' => 'p',
135 'group' => 'capacity_upgrade',
136 'tr_class' => 'wpbc_blur',
137 );
138
139 $this->fields['booking_capacity_field__promote_upgrade'] = array(
140 'type' => 'select',
141 'default' => 'items',
142 'value' => 'items',
143 'title' => __( 'Quantity field name', 'booking' ),
144 'description' => sprintf( __( 'Select the field that will control how many slots visitors can book during the reservation process.', 'booking' ), '<b>', '</b>' ),
145 'description_tag' => 'span',
146 'css' => '',
147 'tr_class' => 'wpbc_booking_capacity_field_settings wpbc_sub_settings_grayed wpbc_blur',
148 'options' => array( 'items' => __( 'Items', 'booking' ) ),
149 'group' => 'capacity_upgrade',
150 );
151
152 $this->fields['booking_is_dissbale_booking_for_different_sub_resources__promote_upgrade'] = array(
153 'type' => 'checkbox',
154 'default' => 'On',
155 'value' => 'On',
156 'title' => __( 'Disable bookings in different booking resources', 'booking' ),
157 'label' => __( 'Check this box to disable reservations, which can be stored in different booking resources.', 'booking' ),
158 'description' => '<strong>' . esc_html__( 'Note', 'booking' ) . '!</strong> ' . __( 'When checked, all reserved days must be at same booking resource otherwise error message will show.', 'booking' ),
159 'group' => 'capacity_upgrade',
160 'tr_class' => 'wpbc_blur',
161 );
162
163 $this->fields['capacity_upgrade__promote_upgrade'] = array(
164 'type' => 'pure_html',
165 'group' => 'capacity_upgrade',
166 'html' => '<tr><td colspan="2">
167 <div class="wpbc_widget_content" style="transform: translate(0) translateY(-10em);">
168 <div class="ui_container ui_container_toolbar ui_container_small" style="background: #fff;position: relative;">
169 <div class="ui_group ui_group__upgrade">
170 <div class="wpbc_upgrade_note wpbc_upgrade_theme_green">
171 <div>This <a target="_blank" href="https://wpbookingcalendar.com/features/#capacity">feature</a>
172 is available in the <strong>Business Large or MultiUser version</strong>.
173 <a target="_blank" href="https://wpbookingcalendar.com/prices/#bk_news_section">Upgrade to Pro</a>.
174 </div>
175 </div>
176 </div>
177 </div>
178 </div>
179 </td></tr>',
180 );
181 }
182
183 /**
184 * Filters fields displayed and saved by the Booking Capacity settings page.
185 *
186 * Edition modules may append fields while the shared Settings API continues
187 * to own rendering, checkbox normalization, and persistence mechanics.
188 *
189 * @param array $fields Registered settings fields.
190 * @param array $default_options_values Default option names and values.
191 */
192 $this->fields = apply_filters( 'wpbc_resource_capacity_settings_fields', $this->fields, $default_options_values );
193 }
194
195 /**
196 * Get selectable booking-form fields for Quantity Control.
197 *
198 * @return array
199 */
200 private function get_quantity_field_options() {
201
202 $options = array(
203 '' => __( 'None', 'booking' ),
204 );
205
206 if ( ! function_exists( 'wpbc_get__in_all_forms__field_names_arr' ) ) {
207 return $options;
208 }
209
210 $booking_forms = wpbc_get__in_all_forms__field_names_arr();
211
212 foreach ( $booking_forms as $single_booking_form ) {
213 $form_name = trim( $single_booking_form['name'] );
214
215 $options[ $form_name ] = array(
216 'title' => ucfirst( $form_name ),
217 'optgroup' => true,
218 'close' => false,
219 );
220
221 for ( $i = 0; $i < $single_booking_form['num']; $i++ ) {
222 $field_key = ( ( 'standard' !== $form_name ) ? $form_name . '^' : '' ) . trim( $single_booking_form['listing']['fields_type'][ $i ] ) . '^' . trim( $single_booking_form['listing']['fields'][ $i ] );
223 $options[ $field_key ] = trim( $single_booking_form['listing']['labels'][ $i ] );
224 }
225
226 $options[ $form_name . '_close' ] = array(
227 'title' => $form_name,
228 'optgroup' => true,
229 'close' => true,
230 );
231 }
232
233 return $options;
234 }
235 }
236