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
whatsapp_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
version_specific_updates_helper.php
475 lines
| 1 | <?php |
| 2 | |
| 3 | class OsVersionSpecificUpdatesHelper { |
| 4 | |
| 5 | |
| 6 | /** |
| 7 | * |
| 8 | * Used to target a specific version during an update |
| 9 | * |
| 10 | * @return bool |
| 11 | */ |
| 12 | public static function run_version_specific_updates() { |
| 13 | $current_db_version = OsSettingsHelper::get_db_version(); |
| 14 | if (!$current_db_version) return false; |
| 15 | $sqls = []; |
| 16 | if (version_compare('1.0.2', $current_db_version) > 0) { |
| 17 | // lower than 1.0.2 |
| 18 | $sqls = self::get_queries_for_nullable_columns(); |
| 19 | OsDatabaseHelper::run_queries($sqls); |
| 20 | } |
| 21 | if (version_compare('1.1.0', $current_db_version) > 0) { |
| 22 | // lower than 1.1.0 |
| 23 | $sqls = self::set_end_date_for_bookings(); |
| 24 | OsDatabaseHelper::run_queries($sqls); |
| 25 | } |
| 26 | if (version_compare('1.3.0', $current_db_version) > 0) { |
| 27 | // lower than 1.3.0 |
| 28 | $sqls = []; |
| 29 | $sqls[] = "UPDATE " . LATEPOINT_TABLE_BOOKINGS . " SET total_attendees = 1 WHERE total_attendees IS NULL;"; |
| 30 | $sqls[] = "UPDATE " . LATEPOINT_TABLE_SERVICES . " SET visibility = '" . LATEPOINT_SERVICE_VISIBILITY_VISIBLE . "' WHERE visibility IS NULL OR visibility = '';"; |
| 31 | $sqls[] = "UPDATE " . LATEPOINT_TABLE_SERVICES . " SET capacity_min = 1 WHERE capacity_min IS NULL;"; |
| 32 | $sqls[] = "UPDATE " . LATEPOINT_TABLE_SERVICES . " SET capacity_max = 1 WHERE capacity_max IS NULL;"; |
| 33 | OsDatabaseHelper::run_queries($sqls); |
| 34 | } |
| 35 | if (version_compare('1.3.1', $current_db_version) > 0) { |
| 36 | $sqls = []; |
| 37 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_CUSTOMERS . " MODIFY COLUMN first_name varchar(255)"; |
| 38 | OsDatabaseHelper::run_queries($sqls); |
| 39 | } |
| 40 | if (version_compare('1.3.7', $current_db_version) > 0) { |
| 41 | $sqls = []; |
| 42 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_AGENTS . " MODIFY COLUMN wp_user_id int(11)"; |
| 43 | OsDatabaseHelper::run_queries($sqls); |
| 44 | } |
| 45 | if (version_compare('1.4.8', $current_db_version) > 0) { |
| 46 | update_option('latepoint_db_seeded', true); |
| 47 | OsSettingsHelper::save_setting_by_name('timeslot_blocking_statuses', LATEPOINT_BOOKING_STATUS_APPROVED); |
| 48 | OsSettingsHelper::save_setting_by_name('calendar_hidden_statuses', LATEPOINT_BOOKING_STATUS_CANCELLED); |
| 49 | OsSettingsHelper::save_setting_by_name('need_action_statuses', implode(',', [LATEPOINT_BOOKING_STATUS_PENDING, LATEPOINT_BOOKING_STATUS_PAYMENT_PENDING])); |
| 50 | $tile_info = OsSettingsHelper::get_booking_template_for_calendar(); |
| 51 | $tile_info = OsUtilHelper::replace_single_curly_with_double($tile_info); |
| 52 | OsSettingsHelper::save_setting_by_name('booking_template_for_calendar', $tile_info); |
| 53 | |
| 54 | // ------- |
| 55 | // Update {var} to {{var}} |
| 56 | // ------- |
| 57 | |
| 58 | // password reset message |
| 59 | $content_to_replace = OsUtilHelper::replace_single_curly_with_double(OsSettingsHelper::get_settings_value('email_customer_password_reset_request_content', '')); |
| 60 | OsSettingsHelper::save_setting_by_name('email_customer_password_reset_request_content', $content_to_replace); |
| 61 | |
| 62 | // new message (chat) |
| 63 | $content_to_replace = OsUtilHelper::replace_single_curly_with_double(OsSettingsHelper::get_settings_value('email_notification_customer_has_new_message_content', '')); |
| 64 | OsSettingsHelper::save_setting_by_name('email_notification_customer_has_new_message_content', $content_to_replace); |
| 65 | |
| 66 | // js tracking code |
| 67 | $content_to_replace = OsUtilHelper::replace_single_curly_with_double(OsSettingsHelper::get_settings_value('confirmation_step_tracking_code', '')); |
| 68 | OsSettingsHelper::save_setting_by_name('confirmation_step_tracking_code', $content_to_replace); |
| 69 | |
| 70 | // Google calendar |
| 71 | $content_to_replace = OsUtilHelper::replace_single_curly_with_double(OsSettingsHelper::get_settings_value('google_calendar_event_summary_template', '')); |
| 72 | if (!empty($content_to_replace)) OsSettingsHelper::save_setting_by_name('google_calendar_event_summary_template', $content_to_replace); |
| 73 | $content_to_replace = OsUtilHelper::replace_single_curly_with_double(OsSettingsHelper::get_settings_value('google_calendar_event_description_template', '')); |
| 74 | if (!empty($content_to_replace)) OsSettingsHelper::save_setting_by_name('google_calendar_event_description_template', $content_to_replace); |
| 75 | |
| 76 | |
| 77 | // ------- |
| 78 | // migrate old notification system to processes |
| 79 | // ------- |
| 80 | |
| 81 | $process_actions = []; |
| 82 | // STATUS CHANGE NOTIFICATION |
| 83 | |
| 84 | if (OsSettingsHelper::is_on('notifications_email')) { |
| 85 | |
| 86 | |
| 87 | foreach (['agent', 'customer'] as $user_type) { |
| 88 | $action = []; |
| 89 | if (OsSettingsHelper::is_on('notification_' . $user_type . '_booking_status_changed')) { |
| 90 | $action['type'] = 'send_email'; |
| 91 | $action['settings']['to_email'] = '{{' . $user_type . '_full_name}} <{{' . $user_type . '_email}}>'; |
| 92 | $action['settings']['subject'] = OsUtilHelper::replace_single_curly_with_double(OsSettingsHelper::get_settings_value('notification_' . $user_type . '_booking_status_changed_notification_subject', '')); |
| 93 | $action['settings']['content'] = OsUtilHelper::replace_single_curly_with_double(OsSettingsHelper::get_settings_value('notification_' . $user_type . '_booking_status_changed_notification_content', '')); |
| 94 | $process_actions[\LatePoint\Misc\ProcessAction::generate_id()] = $action; |
| 95 | } |
| 96 | } |
| 97 | if ($process_actions) { |
| 98 | // put all under single process with multiple actions |
| 99 | $process = new OsProcessModel(); |
| 100 | $process->event_type = 'booking_updated'; |
| 101 | $process->name = 'Booking status change notification'; |
| 102 | |
| 103 | $trigger_conditions[] = ['object' => 'old_booking', 'property' => 'old_booking__status', 'operator' => 'changed', 'value' => '']; |
| 104 | $process_actions = OsProcessesHelper::iterate_trigger_conditions($trigger_conditions, $process_actions); |
| 105 | $process_actions[0]['time_offset'] = []; |
| 106 | $process->actions_json = wp_json_encode($process_actions); |
| 107 | if (!OsProcessesHelper::check_if_process_exists($process)) $process->save(); |
| 108 | } |
| 109 | |
| 110 | } |
| 111 | |
| 112 | |
| 113 | $process_actions = []; |
| 114 | // NEW BOOKING NOTIFICATION |
| 115 | if (OsSettingsHelper::is_on('notifications_email')) { |
| 116 | OsSettingsHelper::save_setting_by_name('notifications_email_processor', 'wp_mail'); |
| 117 | |
| 118 | foreach (['agent', 'customer'] as $user_type) { |
| 119 | $action = []; |
| 120 | if (OsSettingsHelper::is_on('notification_' . $user_type . '_confirmation')) { |
| 121 | $action['type'] = 'send_email'; |
| 122 | $action['settings']['to_email'] = '{{' . $user_type . '_email}}'; |
| 123 | $action['settings']['subject'] = OsUtilHelper::replace_single_curly_with_double(OsSettingsHelper::get_settings_value((($user_type == 'agent') ? 'notification_agent_new_booking_notification_subject' : 'notification_customer_booking_confirmation_subject'), '')); |
| 124 | $action['settings']['content'] = OsUtilHelper::replace_single_curly_with_double(OsSettingsHelper::get_settings_value((($user_type == 'agent') ? 'notification_agent_new_booking_notification_content' : 'notification_customer_booking_confirmation_content'), '')); |
| 125 | $process_actions[\LatePoint\Misc\ProcessAction::generate_id()] = $action; |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | if (OsSettingsHelper::is_on('notifications_sms')) { |
| 130 | OsSettingsHelper::save_setting_by_name('notifications_sms_processor', 'twilio'); |
| 131 | // sms |
| 132 | foreach (['agent', 'customer'] as $user_type) { |
| 133 | $action = []; |
| 134 | if (OsSettingsHelper::is_on('notification_sms_' . $user_type . '_confirmation')) { |
| 135 | $action['type'] = 'send_sms'; |
| 136 | $action['settings']['to_phone'] = '{{' . $user_type . '_phone}}'; |
| 137 | $action['settings']['content'] = OsUtilHelper::replace_single_curly_with_double(OsSettingsHelper::get_settings_value((($user_type == 'agent') ? 'notification_sms_agent_new_booking_notification_message' : 'notification_sms_customer_booking_confirmation_message'), '')); |
| 138 | $process_actions[\LatePoint\Misc\ProcessAction::generate_id()] = $action; |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | |
| 144 | // webhooks for new booking |
| 145 | |
| 146 | // migrate webhooks for new booking into processes |
| 147 | $webhooks = json_decode(OsSettingsHelper::get_settings_value('webhooks', ''), true); |
| 148 | if ($webhooks) { |
| 149 | foreach ($webhooks as $webhook) { |
| 150 | // only process new booking |
| 151 | if ($webhook['status'] != 'active' || $webhook['trigger'] != 'new_booking') continue; |
| 152 | $action = []; |
| 153 | $action['type'] = 'trigger_webhook'; |
| 154 | $action['settings']['url'] = $webhook['url']; |
| 155 | $process_actions[$webhook['id']] = $action; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | // CREATE NEW BOOKING PROCESSES IF THERE ARE ANY ACTIONS |
| 160 | if ($process_actions) { |
| 161 | // put all under single process with multiple actions |
| 162 | $process = new OsProcessModel(); |
| 163 | $process->event_type = 'booking_created'; |
| 164 | $process->name = 'Booking created notification'; |
| 165 | |
| 166 | $process_actions = OsProcessesHelper::iterate_trigger_conditions([], $process_actions); |
| 167 | $process_actions[0]['time_offset'] = []; |
| 168 | $process->actions_json = wp_json_encode($process_actions); |
| 169 | if (!OsProcessesHelper::check_if_process_exists($process)) $process->save(); |
| 170 | } |
| 171 | |
| 172 | // migrate other webhooks (not new booking) into processes |
| 173 | if ($webhooks) { |
| 174 | $process_actions_for_triggers = ['updated_booking' => [], 'new_customer' => [], 'new_transaction' => []]; |
| 175 | foreach ($webhooks as $webhook) { |
| 176 | if ($webhook['status'] != 'active' || !in_array($webhook['trigger'], ['updated_booking', 'new_customer', 'new_transaction'])) continue; |
| 177 | $process_actions_for_triggers[$webhook['trigger']][$webhook['id']] = ['type' => 'trigger_webhook', 'settings' => ['url' => $webhook['url']]]; |
| 178 | } |
| 179 | foreach ($process_actions_for_triggers as $webhook_trigger => $actions) { |
| 180 | if ($actions) { |
| 181 | $process = new OsProcessModel(); |
| 182 | switch ($webhook_trigger) { |
| 183 | case 'updated_booking': |
| 184 | $process->name = 'Booking updated notification'; |
| 185 | $process->event_type = 'booking_updated'; |
| 186 | break; |
| 187 | case 'new_customer': |
| 188 | $process->name = 'New customer notification'; |
| 189 | $process->event_type = 'customer_created'; |
| 190 | break; |
| 191 | case 'new_transaction': |
| 192 | $process->name = 'New transaction notification'; |
| 193 | $process->event_type = 'transaction_created'; |
| 194 | break; |
| 195 | } |
| 196 | $process_actions = OsProcessesHelper::iterate_trigger_conditions([], $actions); |
| 197 | $process_actions[0]['time_offset'] = []; |
| 198 | $process->actions_json = wp_json_encode($process_actions); |
| 199 | if (!OsProcessesHelper::check_if_process_exists($process)) $process->save(); |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // migrate reminders into processes |
| 205 | // old example: {"rem_0zMZzZVY":{"name":"Reminder to customer","medium":"email","receiver":"customer","value":"7","unit":"day","when":"before","subject":"Reminder","content":"<p>Testing<\/p>","id":"rem_0zMZzZVY"}} |
| 206 | // multiple: {"rem_POtZuDDd":{"name":"Sms Reminder before","medium":"sms","receiver":"customer","value":"7","unit":"day","when":"before","subject":"","content":"<p>Testing<\/p>","id":"rem_POtZuDDd"},"rem_q4kA6JwC":{"name":"Sms Reminder after","medium":"sms","receiver":"agent","value":"7","unit":"day","when":"after","subject":"test","content":"Testing","id":"rem_q4kA6JwC"},"rem_hR6YOF3w":{"name":"Email Reminder after","medium":"email","receiver":"agent","value":"7","unit":"day","when":"after","subject":"test","content":"Testing","id":"rem_hR6YOF3w"}} |
| 207 | $reminders = json_decode(OsSettingsHelper::get_settings_value('reminders', ''), true); |
| 208 | if ($reminders) { |
| 209 | $processes = []; |
| 210 | $actions = []; |
| 211 | foreach ($reminders as $reminder) { |
| 212 | |
| 213 | // create action |
| 214 | $action = []; |
| 215 | $action_id = \LatePoint\Misc\ProcessAction::generate_id(); |
| 216 | $action['settings']['content'] = OsUtilHelper::replace_single_curly_with_double($reminder['content'] ?? ''); |
| 217 | switch ($reminder['medium']) { |
| 218 | case 'sms': |
| 219 | $action['type'] = 'send_sms'; |
| 220 | $action['settings']['to_phone'] = ($reminder['receiver'] == 'customer') ? '{{customer_phone}}' : '{{agent_phone}}'; |
| 221 | break; |
| 222 | case 'email': |
| 223 | $action['type'] = 'send_email'; |
| 224 | $action['settings']['to_email'] = ($reminder['receiver'] == 'customer') ? '{{customer_email}}' : '{{agent_email}}'; |
| 225 | $action['settings']['subject'] = OsUtilHelper::replace_single_curly_with_double($reminder['subject']); |
| 226 | break; |
| 227 | } |
| 228 | |
| 229 | // generate time offset |
| 230 | $time_offset = ['value' => $reminder['value'], 'unit' => $reminder['unit'], 'before_after' => $reminder['when']]; |
| 231 | |
| 232 | // attach to process |
| 233 | if ($processes) { |
| 234 | $existing = false; |
| 235 | // try to find process that matches parameters |
| 236 | for ($i = 0; $i < count($processes); $i++) { |
| 237 | if ($processes[$i]['time_offset'] == $time_offset) { |
| 238 | $processes[$i]['actions'][$action_id] = $action; |
| 239 | $existing = true; |
| 240 | break; |
| 241 | } |
| 242 | } |
| 243 | // didn't find process with same time offset, create new |
| 244 | if (!$existing) { |
| 245 | $process = ['name' => $reminder['name'], 'event_type' => 'booking_start', 'time_offset' => $time_offset, 'actions' => []]; |
| 246 | $process['actions'][$action_id] = $action; |
| 247 | $processes[] = $process; |
| 248 | } |
| 249 | } else { |
| 250 | $process = ['name' => $reminder['name'], 'event_type' => 'booking_start', 'time_offset' => $time_offset, 'actions' => []]; |
| 251 | $process['actions'][$action_id] = $action; |
| 252 | $processes[] = $process; |
| 253 | } |
| 254 | |
| 255 | |
| 256 | } |
| 257 | if ($processes) { |
| 258 | foreach ($processes as $process_data) { |
| 259 | $process = new OsProcessModel(); |
| 260 | $process->event_type = $process_data['event_type']; |
| 261 | $process->name = $process_data['name']; |
| 262 | |
| 263 | $process_actions = OsProcessesHelper::iterate_trigger_conditions([], $process_data['actions']); |
| 264 | $process_actions[0]['time_offset'] = $process_data['time_offset']; |
| 265 | $process->actions_json = wp_json_encode($process_actions); |
| 266 | if (!OsProcessesHelper::check_if_process_exists($process)) $process->save(); |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | // Update customer phone numbers to new E.164 format based on the country that was selected in settings |
| 272 | $customers = new OsCustomerModel(); |
| 273 | $customers = $customers->get_results_as_models(); |
| 274 | foreach ($customers as $customer) { |
| 275 | if (empty($customer->phone)) continue; |
| 276 | $formatted_phone = OsUtilHelper::sanitize_phone_number($customer->phone, OsSettingsHelper::get_settings_value('country_phone_code', '')); |
| 277 | if (!empty($formatted_phone)) $customer->update_attributes(['phone' => $formatted_phone]); |
| 278 | } |
| 279 | // update agent phone numbers |
| 280 | $agents = new OsAgentModel(); |
| 281 | $agents = $agents->get_results_as_models(); |
| 282 | foreach ($agents as $agent) { |
| 283 | if (empty($agent->phone)) continue; |
| 284 | $formatted_phone = OsUtilHelper::sanitize_phone_number($agent->phone, OsSettingsHelper::get_settings_value('country_phone_code', '')); |
| 285 | if (!empty($formatted_phone)) $agent->update_attributes(['phone' => $formatted_phone]); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | if (version_compare('1.4.91', $current_db_version) > 0) { |
| 290 | $sqls = []; |
| 291 | $has_column = OsDatabaseHelper::run_query("SHOW COLUMNS FROM " . LATEPOINT_TABLE_BOOKINGS . " LIKE 'start_datetime_gmt'"); |
| 292 | if ($has_column) $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_BOOKINGS . " DROP COLUMN start_datetime_gmt"; |
| 293 | |
| 294 | $has_column = OsDatabaseHelper::run_query("SHOW COLUMNS FROM " . LATEPOINT_TABLE_BOOKINGS . " LIKE 'end_datetime_gmt'"); |
| 295 | if ($has_column) $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_BOOKINGS . " DROP COLUMN end_datetime_gmt"; |
| 296 | |
| 297 | if (!empty($sqls)) OsDatabaseHelper::run_queries($sqls); |
| 298 | } |
| 299 | |
| 300 | |
| 301 | if (version_compare('2.0.0', $current_db_version) > 0) { |
| 302 | // we used to have a typo in a column name, check if it still exists and assign its values to a correctly named column |
| 303 | $has_typo = OsDatabaseHelper::run_query("SHOW COLUMNS FROM " . LATEPOINT_TABLE_BOOKINGS . " LIKE 'total_attendies'"); |
| 304 | if ($has_typo) { |
| 305 | $sqls = []; |
| 306 | $sqls[] = "UPDATE " . LATEPOINT_TABLE_BOOKINGS . " SET total_attendees = total_attendies WHERE total_attendees IS NULL"; |
| 307 | OsDatabaseHelper::run_queries($sqls); |
| 308 | } |
| 309 | |
| 310 | // deactivate old addons that are replaced by a PRO addon |
| 311 | $plugins_to_deactivate = [ |
| 312 | 'latepoint-custom-fields/latepoint-custom-fields.php', |
| 313 | 'latepoint-locations/latepoint-locations.php', |
| 314 | 'latepoint-webhooks/latepoint-webhooks.php', |
| 315 | 'latepoint-qr-code/latepoint-qr-code.php', |
| 316 | 'latepoint-reminders/latepoint-reminders.php', |
| 317 | 'latepoint-role-manager/latepoint-role-manager.php', |
| 318 | 'latepoint-timezone-selector/latepoint-timezone-selector.php', |
| 319 | 'latepoint-group-bookings/latepoint-group-bookings.php', |
| 320 | 'latepoint-taxes/latepoint-taxes.php', |
| 321 | 'latepoint-service-durations/latepoint-service-durations.php', |
| 322 | 'latepoint-service-extras/latepoint-service-extras.php', |
| 323 | 'latepoint-messages/latepoint-messages.php', |
| 324 | 'latepoint-coupons/latepoint-coupons.php', |
| 325 | ]; |
| 326 | $deactivated_plugins = []; |
| 327 | |
| 328 | foreach ($plugins_to_deactivate as $plugin) { |
| 329 | if (is_plugin_active($plugin)) { |
| 330 | $deactivated_plugins[] = OsUtilHelper::extract_plugin_name_from_path($plugin); |
| 331 | deactivate_plugins($plugin); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | $report = OsMigrationsHelper::migrate_from_version_4(); |
| 336 | |
| 337 | if($deactivated_plugins) OsSettingsHelper::save_setting_by_name('migration_version_5_deactivated_plugins', implode(', ', $deactivated_plugins)); |
| 338 | |
| 339 | // if wizard has not been visited yet - redirect to it |
| 340 | add_option('latepoint_show_version_5_modal', true); |
| 341 | } |
| 342 | |
| 343 | /** |
| 344 | * Hook your updates to database that need to be run for specific version of database |
| 345 | * |
| 346 | * @since 1.0.0 |
| 347 | * @hook latepoint_run_version_specific_updates |
| 348 | * |
| 349 | * @param {string} version of database before the update |
| 350 | */ |
| 351 | do_action('latepoint_run_version_specific_updates', $current_db_version); |
| 352 | return true; |
| 353 | } |
| 354 | |
| 355 | |
| 356 | |
| 357 | public static function set_end_date_for_bookings() { |
| 358 | $sqls = []; |
| 359 | |
| 360 | $sqls[] = "UPDATE " . LATEPOINT_TABLE_BOOKINGS . " SET end_date = start_date WHERE end_date IS NULL;"; |
| 361 | return $sqls; |
| 362 | } |
| 363 | |
| 364 | public static function get_queries_for_nullable_columns() { |
| 365 | $sqls = []; |
| 366 | |
| 367 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_BOOKINGS . " |
| 368 | MODIFY COLUMN ip_address varchar(55), |
| 369 | MODIFY COLUMN created_at datetime, |
| 370 | MODIFY COLUMN updated_at datetime;"; |
| 371 | |
| 372 | |
| 373 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_CUSTOMER_META . " |
| 374 | MODIFY COLUMN meta_value text, |
| 375 | MODIFY COLUMN created_at datetime, |
| 376 | MODIFY COLUMN updated_at datetime;"; |
| 377 | |
| 378 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_SETTINGS . " |
| 379 | MODIFY COLUMN value text, |
| 380 | MODIFY COLUMN created_at datetime, |
| 381 | MODIFY COLUMN updated_at datetime;"; |
| 382 | |
| 383 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_SERVICES . " |
| 384 | MODIFY COLUMN short_description text, |
| 385 | MODIFY COLUMN is_price_variable boolean, |
| 386 | MODIFY COLUMN price_min decimal(20,4), |
| 387 | MODIFY COLUMN price_max decimal(20,4), |
| 388 | MODIFY COLUMN charge_amount decimal(20,4), |
| 389 | MODIFY COLUMN is_deposit_required boolean, |
| 390 | MODIFY COLUMN buffer_before int(11), |
| 391 | MODIFY COLUMN buffer_after int(11), |
| 392 | MODIFY COLUMN category_id int(11), |
| 393 | MODIFY COLUMN order_number int(11), |
| 394 | MODIFY COLUMN selection_image_id int(11), |
| 395 | MODIFY COLUMN description_image_id int(11), |
| 396 | MODIFY COLUMN bg_color varchar(20), |
| 397 | MODIFY COLUMN created_at datetime, |
| 398 | MODIFY COLUMN updated_at datetime;"; |
| 399 | |
| 400 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_AGENTS . " |
| 401 | MODIFY COLUMN avatar_image_id int(11), |
| 402 | MODIFY COLUMN last_name varchar(255), |
| 403 | MODIFY COLUMN phone varchar(255), |
| 404 | MODIFY COLUMN password varchar(255), |
| 405 | MODIFY COLUMN custom_hours boolean, |
| 406 | MODIFY COLUMN created_at datetime, |
| 407 | MODIFY COLUMN updated_at datetime;"; |
| 408 | |
| 409 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_STEP_SETTINGS . " |
| 410 | MODIFY COLUMN value text, |
| 411 | MODIFY COLUMN step varchar(50), |
| 412 | MODIFY COLUMN created_at datetime, |
| 413 | MODIFY COLUMN updated_at datetime;"; |
| 414 | |
| 415 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_CUSTOMERS . " |
| 416 | MODIFY COLUMN last_name varchar(255), |
| 417 | MODIFY COLUMN phone varchar(255), |
| 418 | MODIFY COLUMN avatar_image_id int(11), |
| 419 | MODIFY COLUMN password varchar(255), |
| 420 | MODIFY COLUMN activation_key varchar(255), |
| 421 | MODIFY COLUMN account_nonse varchar(255), |
| 422 | MODIFY COLUMN google_user_id varchar(255), |
| 423 | MODIFY COLUMN facebook_user_id varchar(255), |
| 424 | MODIFY COLUMN is_guest boolean, |
| 425 | MODIFY COLUMN notes text, |
| 426 | MODIFY COLUMN created_at datetime, |
| 427 | MODIFY COLUMN updated_at datetime;"; |
| 428 | |
| 429 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_SERVICE_CATEGORIES . " |
| 430 | MODIFY COLUMN short_description text, |
| 431 | MODIFY COLUMN parent_id mediumint(9), |
| 432 | MODIFY COLUMN selection_image_id int(11), |
| 433 | MODIFY COLUMN order_number int(11), |
| 434 | MODIFY COLUMN created_at datetime, |
| 435 | MODIFY COLUMN updated_at datetime"; |
| 436 | |
| 437 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_CUSTOM_PRICES . " |
| 438 | MODIFY COLUMN is_price_variable boolean, |
| 439 | MODIFY COLUMN price_min decimal(20,4), |
| 440 | MODIFY COLUMN price_max decimal(20,4), |
| 441 | MODIFY COLUMN charge_amount decimal(20,4), |
| 442 | MODIFY COLUMN is_deposit_required boolean, |
| 443 | MODIFY COLUMN created_at datetime, |
| 444 | MODIFY COLUMN updated_at datetime"; |
| 445 | |
| 446 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_WORK_PERIODS . " |
| 447 | MODIFY COLUMN custom_date date, |
| 448 | MODIFY COLUMN created_at datetime, |
| 449 | MODIFY COLUMN updated_at datetime"; |
| 450 | |
| 451 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_AGENTS_SERVICES . " |
| 452 | MODIFY COLUMN is_custom_hours BOOLEAN, |
| 453 | MODIFY COLUMN is_custom_price BOOLEAN, |
| 454 | MODIFY COLUMN is_custom_duration BOOLEAN, |
| 455 | MODIFY COLUMN created_at datetime, |
| 456 | MODIFY COLUMN updated_at datetime"; |
| 457 | |
| 458 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_ACTIVITIES . " |
| 459 | MODIFY COLUMN agent_id int(11), |
| 460 | MODIFY COLUMN booking_id int(11), |
| 461 | MODIFY COLUMN service_id int(11), |
| 462 | MODIFY COLUMN customer_id int(11), |
| 463 | MODIFY COLUMN description text, |
| 464 | MODIFY COLUMN initiated_by varchar(100), |
| 465 | MODIFY COLUMN initiated_by_id int(11), |
| 466 | MODIFY COLUMN created_at datetime, |
| 467 | MODIFY COLUMN updated_at datetime"; |
| 468 | |
| 469 | $sqls[] = "ALTER TABLE " . LATEPOINT_TABLE_TRANSACTIONS . " |
| 470 | MODIFY COLUMN notes text, |
| 471 | MODIFY COLUMN created_at datetime, |
| 472 | MODIFY COLUMN updated_at datetime"; |
| 473 | return $sqls; |
| 474 | } |
| 475 | } |