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