PluginProbe ʕ •ᴥ•ʔ
LatePoint – Calendar Booking Plugin for Appointments and Events / 5.1.2
LatePoint – Calendar Booking Plugin for Appointments and Events v5.1.2
5.6.7 5.6.6 5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.1.91 5.1.92 5.1.93 5.1.94 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1
latepoint / lib / helpers / database_helper.php
latepoint / lib / helpers Last commit date
activities_helper.php 1 year ago agent_helper.php 1 year ago auth_helper.php 1 year ago blocks_helper.php 1 year ago booking_helper.php 1 year ago bricks_helper.php 1 year ago bundles_helper.php 1 year ago calendar_helper.php 1 year ago carts_helper.php 1 year ago connector_helper.php 1 year ago csv_helper.php 1 year ago customer_helper.php 1 year ago database_helper.php 1 year ago debug_helper.php 1 year ago defaults_helper.php 1 year ago elementor_helper.php 1 year ago email_helper.php 1 year ago encrypt_helper.php 1 year ago events_helper.php 1 year ago form_helper.php 1 year ago icalendar_helper.php 1 year ago image_helper.php 1 year ago invoices_helper.php 1 year ago license_helper.php 1 year ago location_helper.php 1 year ago marketing_systems_helper.php 1 year ago meeting_systems_helper.php 1 year ago menu_helper.php 1 year ago meta_helper.php 1 year ago migrations_helper.php 1 year ago money_helper.php 1 year ago notifications_helper.php 1 year ago order_intent_helper.php 1 year ago orders_helper.php 1 year ago pages_helper.php 1 year ago params_helper.php 1 year ago payments_helper.php 1 year ago price_breakdown_helper.php 1 year ago process_jobs_helper.php 1 year ago processes_helper.php 1 year ago replacer_helper.php 1 year ago resource_helper.php 1 year ago roles_helper.php 1 year ago router_helper.php 1 year ago service_helper.php 1 year ago sessions_helper.php 1 year ago settings_helper.php 1 year ago shortcodes_helper.php 1 year ago sms_helper.php 1 year ago steps_helper.php 1 year ago stripe_connect_helper.php 1 year ago styles_helper.php 1 year ago support_topics_helper.php 1 year ago time_helper.php 1 year ago timeline_helper.php 1 year ago transaction_intent_helper.php 1 year ago util_helper.php 1 year ago version_specific_updates_helper.php 1 year ago work_periods_helper.php 1 year ago wp_datetime.php 1 year ago wp_user_helper.php 1 year ago
database_helper.php
779 lines
1 <?php
2
3 class OsDatabaseHelper {
4
5 public static function run_setup() {
6 self::install_database();
7 }
8
9 public static function check_db_version() {
10 $current_db_version = OsSettingsHelper::get_db_version();
11 if (!$current_db_version || version_compare(LATEPOINT_DB_VERSION, $current_db_version)) {
12 self::install_database();
13 }
14 }
15
16 // [name => 'addon_name', 'db_version' => '1.0.0', 'version' => '1.0.0']
17 public static function get_installed_addons_list() {
18 $installed_addons = [];
19 $installed_addons = apply_filters('latepoint_installed_addons', $installed_addons);
20 return $installed_addons;
21 }
22
23
24 // Check if addons databases are up to date
25 public static function check_db_version_for_addons() {
26 $is_new_addon_db_version_available = false;
27 $installed_addons = self::get_installed_addons_list();
28 if (empty($installed_addons)) return;
29 foreach ($installed_addons as $installed_addon) {
30 $current_addon_db_version = get_option($installed_addon['name'] . '_addon_db_version');
31 if (!$current_addon_db_version || version_compare($current_addon_db_version, $installed_addon['db_version'])) {
32 self::save_addon_info($installed_addon['name'], $installed_addon['db_version']);
33 $is_new_addon_db_version_available = true;
34 }
35 }
36 if ($is_new_addon_db_version_available) self::install_database_for_addons();
37 }
38
39
40 public static function save_addon_info($name, $version){
41 update_option( $name . '_addon_db_version', $version );
42 $active_addons = OsSettingsHelper::get_active_addons();
43 $active_addons[] = $name;
44 $active_addons = array_unique( $active_addons );
45 $verified_active_addons = [];
46 foreach($active_addons as $active_addon){
47 if(($active_addon == $name) || is_plugin_active($active_addon.'/'.$active_addon.'.php')){
48 $verified_active_addons[] = $active_addon;
49 }
50 }
51 OsSettingsHelper::save_setting_by_name('active_addons', wp_json_encode($verified_active_addons));
52 }
53
54 public static function delete_addon_info($name, $version){
55 delete_option( $name . '_addon_db_version' );
56 $active_addons = OsSettingsHelper::get_active_addons();
57 $verified_active_addons = [];
58 foreach($active_addons as $active_addon){
59 if(($active_addon != $name) && is_plugin_active($active_addon.'/'.$active_addon.'.php')){
60 $verified_active_addons[] = $active_addon;
61 }
62 }
63 OsSettingsHelper::save_setting_by_name('active_addons', wp_json_encode($verified_active_addons));
64 }
65
66
67 // Install queries for addons
68 public static function install_database_for_addons() {
69 $sqls = self::get_table_queries_for_addons();
70 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
71 foreach ($sqls as $sql) {
72 error_log(print_r(dbDelta($sql), true));
73 }
74 }
75
76
77 public static function install_database() {
78 $sqls = self::get_initial_table_queries();
79 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
80 foreach ($sqls as $sql) {
81 error_log(print_r(dbDelta($sql), true));
82 }
83 OsVersionSpecificUpdatesHelper::run_version_specific_updates();
84 self::seed_initial_data();
85 update_option('latepoint_db_version', LATEPOINT_DB_VERSION);
86 }
87
88 public static function seed_initial_data() {
89 // if DB version is set (means that it's probably an update) skip seeding
90 if (OsSettingsHelper::get_db_version()) return false;
91 // if database was already seeded before - skip it
92 if (OsSettingsHelper::get_settings_value('is_database_seeded', false)) return false;
93
94 // set default booking status rules
95 OsSettingsHelper::save_setting_by_name('default_booking_status', LATEPOINT_BOOKING_STATUS_APPROVED);
96 OsSettingsHelper::save_setting_by_name('timeslot_blocking_statuses', LATEPOINT_BOOKING_STATUS_APPROVED);
97 OsSettingsHelper::save_setting_by_name('calendar_hidden_statuses', LATEPOINT_BOOKING_STATUS_CANCELLED);
98 OsSettingsHelper::save_setting_by_name('need_action_statuses', implode(',', [LATEPOINT_BOOKING_STATUS_PENDING, LATEPOINT_BOOKING_STATUS_PAYMENT_PENDING]));
99 // create default processes
100 $process = new OsProcessModel();
101 $process->event_type = 'booking_created';
102 $process->name = 'New Booking Notification';
103 $actions = [];
104
105 require_once ABSPATH . 'wp-admin/includes/file.php';
106 if ( ! WP_Filesystem() ) {
107 OsDebugHelper::log( __( 'Failed to initialise WC_Filesystem API while trying to setup notifications for initial data seed.', 'latepoint' ) );
108 }else{
109 global $wp_filesystem;
110 foreach (['agent', 'customer'] as $user_type) {
111 $action = [];
112 $action['type'] = 'send_email';
113 $action['settings']['to_email'] = '{{' . $user_type . '_full_name}} <{{' . $user_type . '_email}}>';
114 $action['settings']['subject'] = ($user_type == 'agent') ? "New Appointment Received" : "Appointment Confirmation";
115 $action['settings']['content'] = OsEmailHelper::get_email_layout($wp_filesystem->get_contents(LATEPOINT_VIEWS_ABSPATH . 'mailers/' . $user_type . '/booking_created.html'));
116 $actions[\LatePoint\Misc\ProcessAction::generate_id()] = $action;
117 }
118 }
119
120 $process_actions = OsProcessesHelper::iterate_trigger_conditions([], $actions);
121 $process_actions[0]['time_offset'] = [];
122 $process->actions_json = wp_json_encode($process_actions);
123 if (!OsProcessesHelper::check_if_process_exists($process)) $process->save();
124
125 /**
126 * Hook your initial data seed actions here
127 *
128 * @since 4.7.0
129 * @hook latepoint_seed_initial_data
130 *
131 */
132 do_action('latepoint_seed_initial_data');
133 OsSettingsHelper::save_setting_by_name('is_database_seeded', true);
134
135 }
136
137 public static function run_query(string $sql) {
138 global $wpdb;
139 OsDebugHelper::log_query($sql);
140 return $wpdb->query($sql);
141 }
142
143 public static function run_queries($sqls) {
144 global $wpdb;
145 if ($sqls && is_array($sqls)) {
146 foreach ($sqls as $sql) {
147 $wpdb->query($sql);
148 OsDebugHelper::log_query($sql);
149 }
150 }
151 }
152
153
154 // Get queries registered by addons
155 public static function get_table_queries_for_addons() {
156 $sqls = [];
157 $sqls = apply_filters('latepoint_addons_sqls', $sqls);
158 return $sqls;
159 }
160
161
162 public static function get_initial_table_queries() {
163
164 global $wpdb;
165
166 $charset_collate = $wpdb->get_charset_collate();
167
168 $sqls = [];
169
170
171 // ---------------
172 // STEPS
173 // ---------------
174
175
176 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_STEPS . " (
177 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
178 title text,
179 before_content text,
180 after_content text,
181 side_title text,
182 side_description text,
183 use_custom_image boolean,
184 custom_image_id int(11),
185 code varchar(100),
186 parent_step_id smallint(6),
187 position smallint(6),
188 created_at datetime,
189 updated_at datetime,
190 PRIMARY KEY (id)
191 ) $charset_collate;";
192
193 // ---------------
194 // CART
195 // ---------------
196
197 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_CARTS . " (
198 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
199 uuid varchar(36),
200 order_intent_id int(11),
201 order_id int(11),
202 coupon_code varchar(100),
203 created_at datetime,
204 updated_at datetime,
205 PRIMARY KEY (id),
206 KEY uuid_index (uuid),
207 KEY order_id_index (order_id),
208 KEY order_intent_id_index (order_intent_id)
209 ) $charset_collate;";
210
211 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_CART_ITEMS . " (
212 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
213 cart_id int(11) NOT NULL,
214 variant varchar(55),
215 item_data text,
216 created_at datetime,
217 updated_at datetime,
218 PRIMARY KEY (id),
219 KEY cart_id_index (cart_id)
220 ) $charset_collate;";
221
222
223 // ---------------
224 // ORDERS
225 // ---------------
226
227 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_ORDERS . " (
228 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
229 subtotal decimal(20,4),
230 total decimal(20,4),
231 status varchar(30) DEFAULT '" . LATEPOINT_ORDER_STATUS_OPEN . "' NOT NULL,
232 fulfillment_status varchar(30) DEFAULT '" . LATEPOINT_ORDER_FULFILLMENT_STATUS_NOT_FULFILLED . "' NOT NULL,
233 payment_status varchar(30) DEFAULT '" . LATEPOINT_ORDER_PAYMENT_STATUS_NOT_PAID . "' NOT NULL,
234 source_id varchar(100),
235 source_url text,
236 ip_address varchar(55),
237 customer_id int(11) NOT NULL,
238 customer_comment text,
239 confirmation_code varchar(10),
240 price_breakdown text,
241 coupon_code varchar(100),
242 coupon_discount decimal(20,4),
243 tax_total decimal(20,4),
244 initial_payment_data text,
245 created_at datetime,
246 updated_at datetime,
247 PRIMARY KEY (id),
248 KEY customer_id_index (customer_id)
249 ) $charset_collate;";
250
251 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_ORDER_ITEMS . " (
252 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
253 order_id int(11) NOT NULL,
254 variant varchar(55),
255 item_data text,
256 subtotal decimal(20,4),
257 total decimal(20,4),
258 coupon_code varchar(100),
259 coupon_discount decimal(20,4),
260 tax_total decimal(20,4),
261 created_at datetime,
262 updated_at datetime,
263 PRIMARY KEY (id),
264 KEY order_id_index (order_id)
265 ) $charset_collate;";
266
267
268 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_ORDER_INTENTS . " (
269 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
270 intent_key varchar(55) NOT NULL,
271 customer_id int(11) NOT NULL,
272 cart_items_data text,
273 restrictions_data text,
274 presets_data text,
275 payment_data text,
276 other_data text,
277 order_id int(11),
278 booking_form_page_url text,
279 total decimal(20,4),
280 subtotal decimal(20,4),
281 coupon_code varchar(100),
282 coupon_discount decimal(20,4),
283 tax_total decimal(20,4),
284 charge_amount decimal(20,4),
285 specs_charge_amount varchar(55),
286 price_breakdown text,
287 status varchar(30) DEFAULT '" . LATEPOINT_ORDER_INTENT_STATUS_NEW . "' NOT NULL,
288 created_at datetime,
289 updated_at datetime,
290 PRIMARY KEY (id),
291 UNIQUE KEY intent_key_index (intent_key)
292 ) $charset_collate;";
293
294
295 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_ORDER_INVOICES . " (
296 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
297 order_id int(11) NOT NULL,
298 invoice_number varchar(10),
299 data text,
300 status varchar(30) DEFAULT '" . LATEPOINT_INVOICE_STATUS_OPEN . "' NOT NULL,
301 charge_amount decimal(20,4),
302 due_at datetime,
303 payment_portion varchar(55),
304 access_key varchar(36),
305 created_at datetime,
306 updated_at datetime,
307 PRIMARY KEY (id),
308 KEY order_id_index (order_id),
309 UNIQUE KEY invoice_number_index (invoice_number)
310 ) $charset_collate;";
311
312
313 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_PAYMENT_REQUESTS . " (
314 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
315 order_id int(11) NOT NULL,
316 invoice_id int(11) NOT NULL,
317 charge_amount decimal(20,4),
318 due_at datetime,
319 portion varchar(55),
320 created_at datetime,
321 updated_at datetime,
322 PRIMARY KEY (id),
323 KEY invoice_id_index (invoice_id),
324 KEY order_id_index (order_id)
325 ) $charset_collate;";
326
327
328 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_PROCESS_JOBS . " (
329 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
330 process_id int(11) NOT NULL,
331 object_id int(11) NOT NULL,
332 object_model_type varchar(55),
333 settings text,
334 to_run_after_utc datetime,
335 status varchar(30) DEFAULT '" . LATEPOINT_JOB_STATUS_SCHEDULED . "',
336 run_result text,
337 process_info text,
338 created_at datetime,
339 updated_at datetime,
340 PRIMARY KEY (id)
341 ) $charset_collate;";
342
343
344 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_SESSIONS . " (
345 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
346 session_key varchar(55) NOT NULL,
347 session_value longtext NOT NULL,
348 expiration BIGINT UNSIGNED NOT NULL,
349 hash varchar(50) NOT NULL,
350 PRIMARY KEY (id),
351 UNIQUE KEY session_key (session_key)
352 ) $charset_collate;";
353
354 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_BOOKINGS . " (
355 id int(11) NOT NULL AUTO_INCREMENT,
356 booking_code varchar(10),
357 start_date date,
358 end_date date,
359 start_time mediumint(9),
360 end_time mediumint(9),
361 start_datetime_utc datetime,
362 end_datetime_utc datetime,
363 buffer_before mediumint(9) NOT NULL,
364 buffer_after mediumint(9) NOT NULL,
365 duration mediumint(9),
366 status varchar(30) DEFAULT '" . LATEPOINT_BOOKING_STATUS_PENDING . "' NOT NULL,
367 customer_id mediumint(9) NOT NULL,
368 service_id mediumint(9) NOT NULL,
369 agent_id mediumint(9) NOT NULL,
370 location_id mediumint(9),
371 order_item_id mediumint(9),
372 total_attendees mediumint(4),
373 created_at datetime,
374 updated_at datetime,
375 KEY start_date_index (start_date),
376 KEY end_date_index (end_date),
377 KEY status_index (status),
378 KEY customer_id_index (customer_id),
379 KEY service_id_index (service_id),
380 KEY agent_id_index (agent_id),
381 KEY location_id_index (location_id),
382 PRIMARY KEY (id)
383 ) $charset_collate;";
384
385
386 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_CART_META . " (
387 id mediumint(9) NOT NULL AUTO_INCREMENT,
388 object_id mediumint(9) NOT NULL,
389 meta_key varchar(110) NOT NULL,
390 meta_value text,
391 created_at datetime,
392 updated_at datetime,
393 KEY meta_key_index (meta_key),
394 KEY object_id_index (object_id),
395 PRIMARY KEY (id)
396 ) $charset_collate;";
397
398 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_ORDER_META . " (
399 id mediumint(9) NOT NULL AUTO_INCREMENT,
400 object_id mediumint(9) NOT NULL,
401 meta_key varchar(110) NOT NULL,
402 meta_value text,
403 created_at datetime,
404 updated_at datetime,
405 KEY meta_key_index (meta_key),
406 KEY object_id_index (object_id),
407 PRIMARY KEY (id)
408 ) $charset_collate;";
409
410
411 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_BOOKING_META . " (
412 id mediumint(9) NOT NULL AUTO_INCREMENT,
413 object_id mediumint(9) NOT NULL,
414 meta_key varchar(110) NOT NULL,
415 meta_value text,
416 created_at datetime,
417 updated_at datetime,
418 KEY meta_key_index (meta_key),
419 KEY object_id_index (object_id),
420 PRIMARY KEY (id)
421 ) $charset_collate;";
422
423
424 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_PROCESSES . " (
425 id mediumint(9) NOT NULL AUTO_INCREMENT,
426 name varchar(110) NOT NULL,
427 event_type varchar(110) NOT NULL,
428 actions_json text,
429 status varchar(30) DEFAULT '" . LATEPOINT_STATUS_ACTIVE . "',
430 created_at datetime,
431 updated_at datetime,
432 PRIMARY KEY (id)
433 ) $charset_collate;";
434
435 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_SERVICE_META . " (
436 id mediumint(9) NOT NULL AUTO_INCREMENT,
437 object_id mediumint(9) NOT NULL,
438 meta_key varchar(110) NOT NULL,
439 meta_value text,
440 created_at datetime,
441 updated_at datetime,
442 KEY meta_key_index (meta_key),
443 KEY object_id_index (object_id),
444 PRIMARY KEY (id)
445 ) $charset_collate;";
446
447 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_CUSTOMER_META . " (
448 id mediumint(9) NOT NULL AUTO_INCREMENT,
449 object_id mediumint(9) NOT NULL,
450 meta_key varchar(110) NOT NULL,
451 meta_value text,
452 created_at datetime,
453 updated_at datetime,
454 KEY meta_key_index (meta_key),
455 KEY object_id_index (object_id),
456 PRIMARY KEY (id)
457 ) $charset_collate;";
458
459 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_AGENT_META . " (
460 id mediumint(9) NOT NULL AUTO_INCREMENT,
461 object_id mediumint(9) NOT NULL,
462 meta_key varchar(110) NOT NULL,
463 meta_value text,
464 created_at datetime,
465 updated_at datetime,
466 KEY meta_key_index (meta_key),
467 KEY object_id_index (object_id),
468 PRIMARY KEY (id)
469 ) $charset_collate;";
470
471
472 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_SETTINGS . " (
473 id mediumint(9) NOT NULL AUTO_INCREMENT,
474 name varchar(110) NOT NULL,
475 value longtext,
476 created_at datetime,
477 updated_at datetime,
478 KEY name_index (name),
479 PRIMARY KEY (id)
480 ) $charset_collate;";
481
482
483 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_LOCATIONS . " (
484 id mediumint(9) NOT NULL AUTO_INCREMENT,
485 name varchar(255) NOT NULL,
486 full_address text,
487 status varchar(20) NOT NULL,
488 category_id int(11),
489 order_number int(11),
490 selection_image_id int(11),
491 created_at datetime,
492 updated_at datetime,
493 KEY status_index (status),
494 PRIMARY KEY (id)
495 ) $charset_collate;";
496
497
498 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_LOCATION_CATEGORIES . " (
499 id mediumint(9) NOT NULL AUTO_INCREMENT,
500 name varchar(100) NOT NULL,
501 short_description text,
502 parent_id mediumint(9),
503 selection_image_id int(11),
504 order_number int(11),
505 created_at datetime,
506 updated_at datetime,
507 KEY order_number_index (order_number),
508 KEY parent_id_index (parent_id),
509 PRIMARY KEY (id)
510 ) $charset_collate;";
511
512
513 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_BUNDLES . " (
514 id mediumint(9) NOT NULL AUTO_INCREMENT,
515 name varchar(255) NOT NULL,
516 short_description text,
517 charge_amount decimal(20,4),
518 deposit_amount decimal(20,4),
519 status varchar(20) NOT NULL,
520 visibility varchar(20) NOT NULL,
521 order_number int(11),
522 created_at datetime,
523 updated_at datetime,
524 KEY order_number_index (order_number),
525 KEY status_index (status),
526 PRIMARY KEY (id)
527 ) $charset_collate;";
528
529
530 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_JOIN_BUNDLES_SERVICES . " (
531 id mediumint(9) NOT NULL AUTO_INCREMENT,
532 bundle_id mediumint(9),
533 service_id mediumint(9),
534 total_attendees mediumint(4),
535 duration int(11),
536 quantity mediumint(4),
537 created_at datetime,
538 updated_at datetime,
539 KEY bundle_id_index (bundle_id),
540 KEY service_id_index (service_id),
541 PRIMARY KEY (id)
542 ) $charset_collate;";
543
544 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_SERVICES . " (
545 id mediumint(9) NOT NULL AUTO_INCREMENT,
546 name varchar(255) NOT NULL,
547 short_description text,
548 is_price_variable boolean,
549 price_min decimal(20,4),
550 price_max decimal(20,4),
551 charge_amount decimal(20,4),
552 deposit_amount decimal(20,4),
553 is_deposit_required boolean,
554 duration_name varchar(255),
555 override_default_booking_status varchar(255),
556 duration int(11) NOT NULL,
557 buffer_before int(11),
558 buffer_after int(11),
559 category_id int(11),
560 order_number int(11),
561 selection_image_id int(11),
562 description_image_id int(11),
563 bg_color varchar(20),
564 timeblock_interval int(11),
565 capacity_min int(4),
566 capacity_max int(4),
567 status varchar(20) NOT NULL,
568 visibility varchar(20) NOT NULL,
569 created_at datetime,
570 updated_at datetime,
571 KEY category_id_index (category_id),
572 KEY order_number_index (order_number),
573 KEY status_index (status),
574 PRIMARY KEY (id)
575 ) $charset_collate;";
576
577 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_AGENTS . " (
578 id mediumint(9) NOT NULL AUTO_INCREMENT,
579 avatar_image_id int(11),
580 bio_image_id int(11),
581 first_name varchar(255) NOT NULL,
582 last_name varchar(255),
583 display_name varchar(255),
584 title varchar(255),
585 bio text,
586 features text,
587 email varchar(110) NOT NULL,
588 phone varchar(255),
589 password varchar(255),
590 custom_hours boolean,
591 wp_user_id int(11),
592 status varchar(20) NOT NULL,
593 extra_emails text,
594 extra_phones text,
595 created_at datetime,
596 updated_at datetime,
597 KEY email_index (email),
598 PRIMARY KEY (id)
599 ) $charset_collate;";
600
601 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_STEP_SETTINGS . " (
602 id mediumint(9) NOT NULL AUTO_INCREMENT,
603 label varchar(50) NOT NULL,
604 value text,
605 step varchar(50),
606 created_at datetime,
607 updated_at datetime,
608 KEY step_index (step),
609 KEY label_index (label),
610 PRIMARY KEY (id)
611 ) $charset_collate;";
612
613
614 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_CUSTOMERS . " (
615 id mediumint(9) NOT NULL AUTO_INCREMENT,
616 first_name varchar(255),
617 last_name varchar(255),
618 email varchar(110) NOT NULL,
619 phone varchar(255),
620 avatar_image_id int(11),
621 status varchar(50) NOT NULL,
622 password varchar(255),
623 activation_key varchar(255),
624 account_nonse varchar(255),
625 google_user_id varchar(255),
626 facebook_user_id varchar(255),
627 wordpress_user_id int(11),
628 is_guest boolean,
629 notes text,
630 admin_notes text,
631 created_at datetime,
632 updated_at datetime,
633 KEY email_index (email),
634 KEY status_index (status),
635 KEY wordpress_user_id_index (wordpress_user_id),
636 PRIMARY KEY (id)
637 ) $charset_collate;";
638
639 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_SERVICE_CATEGORIES . " (
640 id mediumint(9) NOT NULL AUTO_INCREMENT,
641 name varchar(100) NOT NULL,
642 short_description text,
643 parent_id mediumint(9),
644 selection_image_id int(11),
645 order_number int(11),
646 created_at datetime,
647 updated_at datetime,
648 KEY order_number_index (order_number),
649 KEY parent_id_index (parent_id),
650 PRIMARY KEY (id)
651 ) $charset_collate;";
652
653 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_CUSTOM_PRICES . " (
654 id mediumint(9) NOT NULL AUTO_INCREMENT,
655 agent_id int(11) NOT NULL,
656 service_id int(11) NOT NULL,
657 location_id int(11) NOT NULL,
658 is_price_variable boolean,
659 price_min decimal(20,4),
660 price_max decimal(20,4),
661 charge_amount decimal(20,4),
662 is_deposit_required boolean,
663 deposit_amount decimal(20,4),
664 created_at datetime,
665 updated_at datetime,
666 KEY agent_id_index (agent_id),
667 KEY service_id_index (service_id),
668 KEY location_id_index (location_id),
669 PRIMARY KEY (id)
670 ) $charset_collate;";
671
672 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_WORK_PERIODS . " (
673 id mediumint(9) NOT NULL AUTO_INCREMENT,
674 agent_id int(11) NOT NULL,
675 service_id int(11) NOT NULL,
676 location_id int(11) NOT NULL,
677 start_time smallint(6) NOT NULL,
678 end_time smallint(6) NOT NULL,
679 week_day tinyint(3) NOT NULL,
680 custom_date date,
681 chain_id varchar(20),
682 created_at datetime,
683 updated_at datetime,
684 KEY agent_id_index (agent_id),
685 KEY service_id_index (service_id),
686 KEY location_id_index (location_id),
687 KEY week_day_index (week_day),
688 KEY custom_date_index (custom_date),
689 PRIMARY KEY (id)
690 ) $charset_collate;";
691
692 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_AGENTS_SERVICES . " (
693 id mediumint(9) NOT NULL AUTO_INCREMENT,
694 agent_id int(11) NOT NULL,
695 service_id int(11) NOT NULL,
696 location_id int(11),
697 is_custom_hours BOOLEAN,
698 is_custom_price BOOLEAN,
699 is_custom_duration BOOLEAN,
700 created_at datetime,
701 updated_at datetime,
702 KEY agent_id_index (agent_id),
703 KEY service_id_index (service_id),
704 KEY location_id_index (location_id),
705 PRIMARY KEY (id)
706 ) $charset_collate;";
707
708 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_ACTIVITIES . " (
709 id mediumint(9) NOT NULL AUTO_INCREMENT,
710 agent_id int(11),
711 booking_id int(11),
712 service_id int(11),
713 customer_id int(11),
714 location_id int(11),
715 order_id int(11),
716 order_item_id int(11),
717 code varchar(255) NOT NULL,
718 description text,
719 initiated_by varchar(100),
720 initiated_by_id int(11),
721 created_at datetime,
722 updated_at datetime,
723 PRIMARY KEY (id)
724 ) $charset_collate;";
725
726
727 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_TRANSACTION_INTENTS . " (
728 id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
729 intent_key varchar(55) NOT NULL,
730 order_id int(11) NOT NULL,
731 customer_id int(11),
732 invoice_id int(11),
733 transaction_id int(11),
734 payment_data text,
735 charge_amount decimal(20,4),
736 specs_charge_amount varchar(55),
737 status varchar(30) DEFAULT '" . LATEPOINT_TRANSACTION_INTENT_STATUS_NEW . "' NOT NULL,
738 created_at datetime,
739 updated_at datetime,
740 PRIMARY KEY (id),
741 UNIQUE KEY intent_key_index (intent_key)
742 ) $charset_collate;";
743
744 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_TRANSACTIONS . " (
745 id mediumint(9) NOT NULL AUTO_INCREMENT,
746 token text,
747 invoice_id int(11),
748 order_id int(11),
749 customer_id int(11),
750 processor varchar(100),
751 payment_method varchar(55),
752 payment_portion varchar(55),
753 kind varchar(40),
754 status varchar(100) NOT NULL,
755 amount decimal(20,4),
756 receipt_number varchar(10),
757 access_key varchar(36),
758 notes text,
759 created_at datetime,
760 updated_at datetime,
761 PRIMARY KEY (id)
762 ) $charset_collate;";
763
764
765 $sqls[] = "CREATE TABLE " . LATEPOINT_TABLE_TRANSACTION_REFUNDS . " (
766 id mediumint(9) NOT NULL AUTO_INCREMENT,
767 token text,
768 transaction_id int(11),
769 amount decimal(20,4),
770 created_at datetime,
771 updated_at datetime,
772 PRIMARY KEY (id)
773 ) $charset_collate;";
774
775 return $sqls;
776 }
777
778
779 }