| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentSupport\App\Services\EmailNotification; |
| 4 |
use FluentSupportPro\Database\Migrations\TimeTrackMigrator; |
| 5 |
|
| 6 |
use FluentSupport\App\Services\Helper; |
| 7 |
|
| 8 |
class Settings |
| 9 |
{ |
| 10 |
|
| 11 |
public function getEmailSettingsKeys() |
| 12 |
{ |
| 13 |
$key = apply_filters('fluent_support/email_setting_keys', [ |
| 14 |
'ticket_created_email_to_customer', |
| 15 |
'ticket_replied_by_agent_email_to_customer', |
| 16 |
'ticket_closed_by_agent_email_to_customer', |
| 17 |
'ticket_created_email_to_admin', |
| 18 |
'ticket_replied_by_customer_email_to_admin', |
| 19 |
'ticket_agent_on_change', |
| 20 |
'ticket_created_by_agent_email_to_customer', |
| 21 |
'ticket_created_by_agent_on_behalf_email_to_customer' |
| 22 |
]); |
| 23 |
return $key; |
| 24 |
} |
| 25 |
|
| 26 |
public function get($settingsKey) |
| 27 |
{ |
| 28 |
if ($settingsKey == 'global_business_settings') { |
| 29 |
return [ |
| 30 |
'settings' => $this->globalBusinessSettings(), |
| 31 |
'fields' => $this->getGlobalBusinessSettingsFields() |
| 32 |
]; |
| 33 |
} |
| 34 |
|
| 35 |
return [ |
| 36 |
'settings' => [], |
| 37 |
'fields' => [] |
| 38 |
]; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* save method will save the requested settings by settings key |
| 43 |
* @param $settingsKey |
| 44 |
* @param $settings |
| 45 |
* @return mixed |
| 46 |
*/ |
| 47 |
public function save($settingsKey, $settings) |
| 48 |
{ |
| 49 |
if ($settingsKey == 'global_business_settings' && empty($settings['accepted_file_types'])) { |
| 50 |
$settings['accepted_file_types'] = []; |
| 51 |
} |
| 52 |
|
| 53 |
if ($settingsKey == 'global_business_settings' && !empty($settings['agent_time_tracking'])) { |
| 54 |
if (class_exists(TimeTrackMigrator::class) && $settings['agent_time_tracking'] === 'yes') { |
| 55 |
TimeTrackMigrator::migrate(); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
return Helper::updateOption($settingsKey, $settings); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* globalBusinessSettings method will fetch global settings from database, parse and return |
| 64 |
* @param bool $cached |
| 65 |
* @return array|mixed |
| 66 |
*/ |
| 67 |
public function globalBusinessSettings($cached = true) |
| 68 |
{ |
| 69 |
static $settings; |
| 70 |
|
| 71 |
if($cached && $settings) { |
| 72 |
return $settings; |
| 73 |
} |
| 74 |
|
| 75 |
$defaults = [ |
| 76 |
'portal_page_id' => '', |
| 77 |
// translators: %1$s is opening paragraph tag, %2$s is closing paragraph tag |
| 78 |
'login_message' => sprintf(__('%1$sPlease login or create an account to access the Customer Support Portal%2$s [fluent_support_auth]', 'fluent-support'), '<p>', '</p>'), |
| 79 |
'disable_public_ticket' => 'no', |
| 80 |
'accepted_file_types' => ['images', 'csv', 'documents', 'zip', 'json'], |
| 81 |
'max_file_size' => 2, |
| 82 |
'max_file_upload' => 3, |
| 83 |
'del_files_on_close' => 'no', |
| 84 |
'enable_admin_bar_summary' => 'no', |
| 85 |
'enable_draft_mode' => 'no', |
| 86 |
'agent_feedback_rating' => 'no', |
| 87 |
'keyboard_shortcuts' => 'yes' |
| 88 |
]; |
| 89 |
|
| 90 |
//Get default/existing settings from database using the key global_business_settings |
| 91 |
$existingSettings = Helper::getOption('global_business_settings', []); |
| 92 |
|
| 93 |
if (!$existingSettings) { |
| 94 |
$settings = $defaults; |
| 95 |
return $settings; |
| 96 |
} |
| 97 |
|
| 98 |
$settings = wp_parse_args($existingSettings, $defaults); |
| 99 |
|
| 100 |
return $settings; |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
/** |
| 105 |
* getGlobalBusinessSettingsFields method will prepare the list of field, and it's property that will be used in global settings form |
| 106 |
* @return array |
| 107 |
*/ |
| 108 |
private function getGlobalBusinessSettingsFields() |
| 109 |
{ |
| 110 |
|
| 111 |
$mimeGroups = Helper::getMimeGroups(); |
| 112 |
|
| 113 |
$formattedMimeGroups = []; |
| 114 |
|
| 115 |
foreach ($mimeGroups as $mimeGroup => $mime) { |
| 116 |
$formattedMimeGroups[$mimeGroup] = $mime['title']; |
| 117 |
} |
| 118 |
|
| 119 |
$customRegistrationFormOptions = array( |
| 120 |
'address_line_1' => 'Address Line 1', |
| 121 |
'address_line_2' => 'Address Line 2', |
| 122 |
'city' => 'City', |
| 123 |
'zip' => 'Zip Code', |
| 124 |
'state' => 'State', |
| 125 |
'country' => 'Country', |
| 126 |
); |
| 127 |
|
| 128 |
$fields = [ |
| 129 |
'portal_page_id' => [ |
| 130 |
'type' => 'input-options', |
| 131 |
'label' => __('Portal Page', 'fluent-support'), |
| 132 |
'show_id' => true, |
| 133 |
'placeholder' => __('Select Portal Page', 'fluent-support'), |
| 134 |
'options' => Helper::getWPPages(),//Get list of published pages |
| 135 |
'inline_help' => __('Please provide the page id where you want to show the tickets for your customers. Use shortcode <code>[fluent_support_portal]</code> in that page', 'fluent-support'), |
| 136 |
'admin_url' => admin_url(), |
| 137 |
'home_url' => home_url('/'), |
| 138 |
], |
| 139 |
'login_message' => [ |
| 140 |
'type' => 'wp-editor', |
| 141 |
'label' => __('Message for non logged in users', 'fluent-support'), |
| 142 |
'inline_help' => __('Please provide message for not logged in users. You can place login shortcode too. Use shortcode <code>[fluent_support_login]</code> to show built-in login form. For the user registration use this shortcode <code>[fluent_support_signup]</code> and for both form please use <code>[fluent_support_auth]</code>', 'fluent-support') |
| 143 |
], |
| 144 |
'disable_public_ticket' => [ |
| 145 |
'wrapper_class' => '', |
| 146 |
'type' => 'inline-checkbox', |
| 147 |
'label' => __('Public Ticket Interaction', 'fluent-support'), |
| 148 |
'true_label' => 'yes', |
| 149 |
'false-label' => 'no', |
| 150 |
'checkbox_label' => __('Disable Public Ticket interaction', 'fluent-support'), |
| 151 |
'inline_help' => __('If you enable this then only logged in user can reply the tickets. Otherwise, url will be signed and intended user can reply without logging in', 'fluent-support') |
| 152 |
], |
| 153 |
'accepted_file_types' => [ |
| 154 |
'wrapper_class' => '', |
| 155 |
'type' => 'checkbox-group', |
| 156 |
'label' => __('Accepted File Types', 'fluent-support'), |
| 157 |
'options' => $formattedMimeGroups |
| 158 |
], |
| 159 |
'max_file_size' => [ |
| 160 |
'wrapper_class' => 'fs_settings_half_field', |
| 161 |
'type' => 'input-text', |
| 162 |
'data_type' => 'number', |
| 163 |
'label' => __('Max File Size (in MegaByte)', 'fluent-support'), |
| 164 |
], |
| 165 |
'max_file_upload' => [ |
| 166 |
'wrapper_class' => 'fs_settings_half_field', |
| 167 |
'type' => 'input-text', |
| 168 |
'data_type' => 'number', |
| 169 |
'label' => __('Maximum File Upload', 'fluent-support'), |
| 170 |
], |
| 171 |
'del_files_on_close' => [ |
| 172 |
'wrapper_class' => '', |
| 173 |
'type' => 'inline-checkbox', |
| 174 |
'true_label' => 'yes', |
| 175 |
'false-label' => 'no', |
| 176 |
'checkbox_label' => __('Delete all attachments on ticket close', 'fluent-support'), |
| 177 |
'inline_help' => __('If you enable this feature, all attachments associated with a ticket will be deleted when the ticket is closed.', 'fluent-support') |
| 178 |
], |
| 179 |
'enable_admin_bar_summary' => [ |
| 180 |
'wrapper_class' => '', |
| 181 |
'type' => 'inline-checkbox', |
| 182 |
'true_label' => 'yes', |
| 183 |
'false-label' => 'no', |
| 184 |
'checkbox_label' => __('Enable Fluent Summary In Admin Bar', 'fluent-support'), |
| 185 |
'inline_help' => __('If you enable this, logged in user can see the ticket summary from top nav bar.', 'fluent-support') |
| 186 |
], |
| 187 |
'enable_draft_mode' => [ |
| 188 |
'wrapper_class' => '', |
| 189 |
'type' => 'inline-checkbox', |
| 190 |
'true_label' => 'yes', |
| 191 |
'false-label' => 'no', |
| 192 |
'checkbox_label' => __('Enable Draft Mode', 'fluent-support'), |
| 193 |
'inline_help' => __('If you enable this setting, any written response will be saved as a draft if an agent accidentally closes a ticket.', 'fluent-support') |
| 194 |
], |
| 195 |
'custom_registration_form_field' => [ |
| 196 |
'wrapper_class' => '', |
| 197 |
'type' => 'checkbox-group', |
| 198 |
'label' => __('Custom Registration Form Field', 'fluent-support'), |
| 199 |
'options' => $customRegistrationFormOptions |
| 200 |
], |
| 201 |
'enable_two_fa' => [ |
| 202 |
'wrapper_class' => '', |
| 203 |
'type' => 'inline-checkbox', |
| 204 |
'true_label' => 'yes', |
| 205 |
'false-label' => 'no', |
| 206 |
'checkbox_label' => __('Enable Two-Factor Authentication', 'fluent-support'), |
| 207 |
'inline_help' => __('If you enable this setting, users will be required to submit a second form of authentication, such as a code sent to their email, to login.', 'fluent-support') |
| 208 |
], |
| 209 |
'keyboard_shortcuts' => [ |
| 210 |
'wrapper_class' => '', |
| 211 |
'type' => 'inline-checkbox', |
| 212 |
'true_label' => 'yes', |
| 213 |
'false-label' => 'no', |
| 214 |
'checkbox_label' => __('Enable Keyboard Shortcuts', 'fluent-support'), |
| 215 |
'inline_help' => __("If you enable this, agents can use keyboard shortcuts for faster actions.", 'fluent-support'), |
| 216 |
'shortcut_modal' => $this->getKeyboardShortcutModalData() |
| 217 |
] |
| 218 |
]; |
| 219 |
if (defined('FLUENTSUPPORTPRO_PLUGIN_VERSION')) { |
| 220 |
$fields['agent_feedback_rating'] = [ |
| 221 |
'wrapper_class' => '', |
| 222 |
'type' => 'inline-checkbox', |
| 223 |
'true_label' => 'yes', |
| 224 |
'false-label' => 'no', |
| 225 |
'checkbox_label' => __('Agent Feedback Rating', 'fluent-support'), |
| 226 |
'inline_help' => __("If you enable this setting, users will have the option to provide feedback on an agent's response.", 'fluent-support') |
| 227 |
]; |
| 228 |
|
| 229 |
$fields['agent_time_tracking'] = [ |
| 230 |
'wrapper_class' => '', |
| 231 |
'type' => 'inline-checkbox', |
| 232 |
'true_label' => 'yes', |
| 233 |
'false-label' => 'no', |
| 234 |
'checkbox_label' => __('Agent Time Tracking', 'fluent-support'), |
| 235 |
'inline_help' => __("If you enable this setting, the agent can specify the amount of time needed to complete a ticket.", 'fluent-support') |
| 236 |
]; |
| 237 |
|
| 238 |
if (defined('FLUENTCART_VERSION')) { |
| 239 |
$fields['enable_fc_menu'] = [ |
| 240 |
'type' => 'inline-checkbox', |
| 241 |
'checkbox_label' => 'Add support link to FluentCart account navigation', |
| 242 |
'inline_help' => __("If you enable this setting, support link will be added to FluentCart account navigation.", 'fluent-support'), |
| 243 |
'true_label' => 'yes', |
| 244 |
'false_label' => 'no' |
| 245 |
]; |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
return $fields; |
| 250 |
} |
| 251 |
|
| 252 |
/** |
| 253 |
* Returns translatable keyboard shortcut modal data for the settings form. |
| 254 |
* |
| 255 |
* @return array{title: string, mac_label: string, win_label: string, action_label: string, shortcut_label: string, mac_shortcuts: array, win_shortcuts: array} |
| 256 |
*/ |
| 257 |
public function getKeyboardShortcutModalData() |
| 258 |
{ |
| 259 |
$actionLabel = __('Action', 'fluent-support'); |
| 260 |
$shortcutLabel = __('Shortcut', 'fluent-support'); |
| 261 |
|
| 262 |
$macShortcuts = [ |
| 263 |
['action' => __('Tickets – Advanced filter toggle', 'fluent-support'), 'shortcut' => '⌘ + ⌥ + f'], |
| 264 |
['action' => __('Tickets – Refresh', 'fluent-support'), 'shortcut' => '⌘ + ⌥ + q'], |
| 265 |
['action' => __('Tickets – Create Ticket', 'fluent-support'), 'shortcut' => '⌘ + ⌥ + n'], |
| 266 |
['action' => __('Tickets – Reset filter', 'fluent-support'), 'shortcut' => '⌘ + ⌥ + r'], |
| 267 |
['action' => __('Tickets – All Tickets', 'fluent-support'), 'shortcut' => '⌘ + ⇧ + a'], |
| 268 |
['action' => __('Tickets – My Tickets', 'fluent-support'), 'shortcut' => '⌘ + ⇧ + m'], |
| 269 |
['action' => __('Tickets – Unassigned', 'fluent-support'), 'shortcut' => '⌘ + ⇧ + u'], |
| 270 |
['action' => __('Tickets – Waiting for reply', 'fluent-support'), 'shortcut' => '⌘ + ⌥ + w'], |
| 271 |
['action' => __('Tickets – Bookmarks', 'fluent-support'), 'shortcut' => '⌘ + ⇧ + b'], |
| 272 |
['action' => __('Tickets – Toggle (Open, active, close, all)', 'fluent-support'), 'shortcut' => '⌘ + ⇧ + → / ←'], |
| 273 |
['action' => __('Ticket Reply – Reply', 'fluent-support'), 'shortcut' => '⌘ + ⌥ + r'], |
| 274 |
['action' => __('Ticket Reply – Personal note', 'fluent-support'), 'shortcut' => '⌘ + ⌥ + n'], |
| 275 |
['action' => __('Ticket Reply – Merge', 'fluent-support'), 'shortcut' => '⌘ + ⌥ + m'], |
| 276 |
['action' => __('Ticket Reply – Bookmarks', 'fluent-support'), 'shortcut' => '⌘ + ⌥ + b'], |
| 277 |
['action' => __('Ticket Reply – Refresh', 'fluent-support'), 'shortcut' => '⌘ + ⌥ + q'], |
| 278 |
]; |
| 279 |
|
| 280 |
$winShortcuts = [ |
| 281 |
['action' => __('Tickets – Advanced filter toggle', 'fluent-support'), 'shortcut' => 'Alt + Win + Shift + f'], |
| 282 |
['action' => __('Tickets – Refresh', 'fluent-support'), 'shortcut' => 'Alt + Win + q'], |
| 283 |
['action' => __('Tickets – Create Ticket', 'fluent-support'), 'shortcut' => 'Alt + Win + n'], |
| 284 |
['action' => __('Tickets – Reset filter', 'fluent-support'), 'shortcut' => 'Alt + Win + Shift + r'], |
| 285 |
['action' => __('Tickets – All Tickets', 'fluent-support'), 'shortcut' => 'Win + Shift + a'], |
| 286 |
['action' => __('Tickets – My Tickets', 'fluent-support'), 'shortcut' => 'Alt + Win + Shift + m'], |
| 287 |
['action' => __('Tickets – Unassigned', 'fluent-support'), 'shortcut' => 'Win + Shift + u'], |
| 288 |
['action' => __('Tickets – Waiting for reply', 'fluent-support'), 'shortcut' => 'Alt + Win + Shift + w'], |
| 289 |
['action' => __('Tickets – Bookmarks', 'fluent-support'), 'shortcut' => 'Win + Shift + b'], |
| 290 |
['action' => __('Ticket Reply – Reply', 'fluent-support'), 'shortcut' => 'Alt + Win + Shift + r'], |
| 291 |
['action' => __('Ticket Reply – Personal note', 'fluent-support'), 'shortcut' => 'Alt + Win + n'], |
| 292 |
['action' => __('Ticket Reply – Merge', 'fluent-support'), 'shortcut' => 'Ctrl + Alt + Win + m'], |
| 293 |
['action' => __('Ticket Reply – Bookmarks', 'fluent-support'), 'shortcut' => 'Ctrl + Alt + Win + b'], |
| 294 |
['action' => __('Ticket Reply – Refresh', 'fluent-support'), 'shortcut' => 'Alt + Win + q'], |
| 295 |
]; |
| 296 |
|
| 297 |
return [ |
| 298 |
'title' => __('Keyboard Shortcuts', 'fluent-support'), |
| 299 |
'mac_label' => __('macOS', 'fluent-support'), |
| 300 |
'win_label' => __('Windows', 'fluent-support'), |
| 301 |
'action_label' => $actionLabel, |
| 302 |
'shortcut_label'=> $shortcutLabel, |
| 303 |
'mac_shortcuts' => $macShortcuts, |
| 304 |
'win_shortcuts' => $winShortcuts, |
| 305 |
]; |
| 306 |
} |
| 307 |
|
| 308 |
public function saveBoxEmailSettings($box, $emailKey, $settings) |
| 309 |
{ |
| 310 |
return $box->saveMeta('_email_' . $emailKey, $settings); |
| 311 |
} |
| 312 |
|
| 313 |
/** |
| 314 |
* getBoxEmailSettings method will reply the email settings |
| 315 |
* @param $box |
| 316 |
* @param $emailKey |
| 317 |
* @return array|false |
| 318 |
*/ |
| 319 |
public function getBoxEmailSettings($box, $emailKey) |
| 320 |
{ |
| 321 |
if (!$box) { |
| 322 |
return false; |
| 323 |
} |
| 324 |
|
| 325 |
#ticket_closed_by_agent_email_to_customer 2 times, is it wrong or right!!! |
| 326 |
$strictSubjectKeys = apply_filters('fluent_support/strict_subjects', [ |
| 327 |
'ticket_replied_by_agent_email_to_customer', |
| 328 |
'ticket_closed_by_agent_email_to_customer', |
| 329 |
'ticket_created_email_to_customer' |
| 330 |
]); |
| 331 |
|
| 332 |
$settingsDefaults = [ |
| 333 |
'ticket_created_email_to_customer' => [ |
| 334 |
'key' => 'ticket_created_email_to_customer', |
| 335 |
'title' => __('Ticket Created (To Customer)', 'fluent-support'), |
| 336 |
'description' => __('This email will be sent when a customer submit a support ticket', 'fluent-support'), |
| 337 |
'email_subject' => 'Re: {{ticket.title}} #{{ticket.id}}', |
| 338 |
'default_status' => 'no', |
| 339 |
'send_attachments'=> 'no' |
| 340 |
], |
| 341 |
'ticket_replied_by_agent_email_to_customer' => [ |
| 342 |
'key' => 'ticket_replied_by_agent_email_to_customer', |
| 343 |
'title' => __('Replied by Agent (To Customer)', 'fluent-support'), |
| 344 |
'description' => __('This email will be sent when an agent reply to a ticket', 'fluent-support'), |
| 345 |
'email_subject' => 'Re: {{ticket.title}} #{{ticket.id}}', |
| 346 |
'default_status' => 'yes', |
| 347 |
'send_attachments'=> 'no' |
| 348 |
], |
| 349 |
'ticket_closed_by_agent_email_to_customer' => [ |
| 350 |
'key' => 'ticket_closed_by_agent_email_to_customer', |
| 351 |
'title' => __('Ticket Closed by Agent (To Customer)', 'fluent-support'), |
| 352 |
'description' => __('This email will be sent when an agent close a ticket', 'fluent-support'), |
| 353 |
'email_subject' => 'Re: {{ticket.title}} #{{ticket.id}}', |
| 354 |
'default_status' => 'no', |
| 355 |
'send_attachments'=> 'no' |
| 356 |
], |
| 357 |
'ticket_created_email_to_admin' => [ |
| 358 |
'key' => 'ticket_created_email_to_admin', |
| 359 |
'title' => __('Ticket Created (To Admin)', 'fluent-support'), |
| 360 |
'description' => __('This email will be sent when the business when a new ticket has been submitted', 'fluent-support'), |
| 361 |
'email_subject' => 'New Ticket: {{ticket.title}} #{{ticket.id}}', |
| 362 |
'default_status' => 'yes', |
| 363 |
'send_attachments'=> 'no' |
| 364 |
], |
| 365 |
'ticket_replied_by_customer_email_to_admin' => [ |
| 366 |
'key' => 'ticket_replied_by_customer_email_to_admin', |
| 367 |
'title' => __('Replied by Customer (To Agent/Admin)', 'fluent-support'), |
| 368 |
'description' => __('This email will be sent to Assigned Agent or Admin when a customer reply to a ticket', 'fluent-support'), |
| 369 |
'email_subject' => 'New Response: {{ticket.title}} #{{ticket.id}}', |
| 370 |
'default_status' => 'yes', |
| 371 |
'send_attachments'=> 'no' |
| 372 |
], |
| 373 |
'ticket_agent_on_change' => [ |
| 374 |
'key' => 'ticket_agent_on_change', |
| 375 |
'title' => __('Ticket Agent Change (To Agent)', 'fluent-support'), |
| 376 |
'description' => __('This email will be sent to newly assigned agent', 'fluent-support'), |
| 377 |
'email_subject' => 'Ticket Agent Change: {{ticket.title}} #{{ticket.id}}', |
| 378 |
'default_status' => 'yes', |
| 379 |
'send_attachments'=> 'no' |
| 380 |
], |
| 381 |
'ticket_created_by_agent_email_to_customer' => [ |
| 382 |
'key' => 'ticket_created_by_agent_email_to_customer', |
| 383 |
'title' => __('Ticket Created by Agent (To Customer)', 'fluent-support'), |
| 384 |
'description' => __('This email will be sent when an agent create a ticket for a customer', 'fluent-support'), |
| 385 |
'email_subject' => 'Re: {{ticket.title}} #{{ticket.id}}', |
| 386 |
'default_status' => 'no', |
| 387 |
'send_attachments'=> 'no' |
| 388 |
], |
| 389 |
'ticket_created_by_agent_on_behalf_email_to_customer' => [ |
| 390 |
'key' => 'ticket_created_by_agent_on_behalf_email_to_customer', |
| 391 |
'title' => __('Agent Initiated Ticket (To Customer)', 'fluent-support'), |
| 392 |
'description' => __('This email will be sent when an agent creates a ticket on behalf of a customer using the initiated by agent option', 'fluent-support'), |
| 393 |
'email_subject' => 'Your ticket has been created (#{{ticket.id}})', |
| 394 |
'default_status' => 'yes', |
| 395 |
'send_attachments'=> 'no' |
| 396 |
] |
| 397 |
]; |
| 398 |
|
| 399 |
if (!isset($settingsDefaults[$emailKey])) { |
| 400 |
return false; |
| 401 |
} |
| 402 |
|
| 403 |
$savedSettings = (array)$box->getMeta('_email_' . $emailKey, []); |
| 404 |
|
| 405 |
|
| 406 |
if (!$savedSettings) { |
| 407 |
$savedSettings = [ |
| 408 |
'key' => $settingsDefaults[$emailKey]['key'], |
| 409 |
'title' => $settingsDefaults[$emailKey]['title'], |
| 410 |
'email_subject' => $settingsDefaults[$emailKey]['email_subject'], |
| 411 |
'email_body' => $this->getDefaultEmailBody($emailKey, $box->box_type), |
| 412 |
'status' => $settingsDefaults[$emailKey]['default_status'], |
| 413 |
'can_edit_subject' => (in_array($emailKey, $strictSubjectKeys) && $box->box_type == 'email') ? 'no' : 'yes', |
| 414 |
'send_attachments' => $settingsDefaults[$emailKey]['send_attachments'] |
| 415 |
]; |
| 416 |
|
| 417 |
if ($box->box_type == 'email' && in_array($emailKey, $strictSubjectKeys)) { |
| 418 |
$savedSettings['email_subject'] = 'Re: {{ticket.title}}'; |
| 419 |
$savedSettings['can_edit_subject'] = 'no'; |
| 420 |
} |
| 421 |
|
| 422 |
return $savedSettings; |
| 423 |
} |
| 424 |
|
| 425 |
$savedSettings['key'] = $settingsDefaults[$emailKey]['key']; |
| 426 |
$savedSettings['title'] = $settingsDefaults[$emailKey]['title']; |
| 427 |
$savedSettings['description'] = $settingsDefaults[$emailKey]['description']; |
| 428 |
|
| 429 |
if ($box->box_type == 'email' && in_array($emailKey, $strictSubjectKeys)) { |
| 430 |
$savedSettings['email_subject'] = 'Re: {{ticket.title}}'; |
| 431 |
$savedSettings['can_edit_subject'] = 'no'; |
| 432 |
} |
| 433 |
|
| 434 |
if (empty($savedSettings['email_subject'])) { |
| 435 |
$savedSettings['email_subject'] = $settingsDefaults[$emailKey]['email_subject']; |
| 436 |
} |
| 437 |
|
| 438 |
if (empty($savedSettings['status'])) { |
| 439 |
$savedSettings['status'] = $settingsDefaults[$emailKey]['default_status']; |
| 440 |
} |
| 441 |
|
| 442 |
if (empty($savedSettings['email_body'])) { |
| 443 |
$savedSettings['email_body'] = $this->getDefaultEmailBody($emailKey, $box->box_type); |
| 444 |
} |
| 445 |
|
| 446 |
if (empty($savedSettings['send_attachments'])) { |
| 447 |
$savedSettings['send_attachments'] = $settingsDefaults[$emailKey]['send_attachments']; |
| 448 |
} |
| 449 |
|
| 450 |
return $savedSettings; |
| 451 |
} |
| 452 |
|
| 453 |
/** |
| 454 |
* getDefaultEmailBody method will return html for email body |
| 455 |
* @param $emailKey |
| 456 |
* @param string $type |
| 457 |
* @return string |
| 458 |
*/ |
| 459 |
private function getDefaultEmailBody($emailKey, $type = 'web') |
| 460 |
{ |
| 461 |
if ($emailKey == 'ticket_created_email_to_customer') { |
| 462 |
if ($type == 'web') { |
| 463 |
return '<p>Hi <strong><em>{{customer.full_name}}</em>,</strong></p><p>Your request (<a href="{{ticket.public_url}}">#{{ticket.id}}</a>) has been received, and is being reviewed by our support staff.</p><p>To add additional comments, follow the link below:</p><h4><a href="{{ticket.public_url}}">View Ticket</a></h4><p> </p><p>or follow this link: {{ticket.public_url}}</p><hr /><p>{{business.name}}</p>'; |
| 464 |
} else { |
| 465 |
return '<p>Hi <strong><em>{{customer.full_name}}</em>,</strong></p><p>Your request has been received, and is being reviewed by our support staff.</p><p>Our support staff will reply back to you soon</p>'; |
| 466 |
} |
| 467 |
} else if ($emailKey == 'ticket_replied_by_agent_email_to_customer') { |
| 468 |
if ($type == 'web') { |
| 469 |
return '<p>Hi <strong><em>{{customer.full_name}}</em>,</strong></p><p>An agent just replied to your ticket "<strong>{{ticket.title}}</strong>" (<a href="{{ticket.public_url}}">#{{ticket.id}}</a>). To view his reply or add additional comments, click the button below:</p><h4><a href="{{ticket.public_url}}">View Ticket</a></h4><p>or follow this link: {{ticket.public_url}}</p><hr /><p>Regards,<br />{{business.name}}</p>'; |
| 470 |
} else { |
| 471 |
return '{{response.full_content}}<p>Regards,<br />{{agent.full_name}}</p>'; |
| 472 |
} |
| 473 |
} else if ($emailKey == 'ticket_closed_by_agent_email_to_customer') { |
| 474 |
if ($type == 'web') { |
| 475 |
return '<p>Hi <strong><em>{{customer.full_name}},</strong></p><p>Your ticket - {{ticket.title}}</p><p>We hope that the ticket was resolved to your satisfaction. If you feel that the ticket should not be closed or if the ticket has not been resolved, please reopen the ticket (<a href="{{ticket.public_url}}">#{{ticket.id}}</a>)</p><p>Regards,<br />{{business.name}}</p>'; |
| 476 |
} else { |
| 477 |
return '<p>Hi <strong><em>{{customer.full_name}},</strong></p><p>Your ticket - {{ticket.title}}</p><p>We hope that the ticket was resolved to your satisfaction. If you feel that the ticket should not be closed or if the ticket has not been resolved, please feel free to reply back.<p>Regards,<br />{{business.name}}</p>'; |
| 478 |
} |
| 479 |
} else if ($emailKey == 'ticket_created_email_to_admin') { |
| 480 |
return '<p>A new ticket (<a href="{{ticket.admin_url}}">{{ticket.title}}</a>) as been submitted by {{customer.full_name}}</p><h4>Ticket Body</h4><p>{{ticket.content}}</p><p><b><a href="{{ticket.admin_url}}">View Ticket</a></b></p>'; |
| 481 |
} else if ($emailKey == 'ticket_replied_by_customer_email_to_admin') { |
| 482 |
return '<p>A new response has been added to "<a href="{{ticket.admin_url}}">{{ticket.title}}</a>" by {{customer.full_name}}</p><h4>Response Body</h4><p>{{response.content}}</p><p><b><a href="{{ticket.admin_url}}">View Ticket</a></b></p>'; |
| 483 |
} else if($emailKey == 'ticket_agent_on_change') { |
| 484 |
return '<p>Hi <strong><em>{{agent.full_name}}</em>,</strong></p><p>Ticket "<a href="{{ticket.admin_url}}">#{{ticket.id}}</a>" assigned to you.</p>'; |
| 485 |
} else if($emailKey == 'ticket_created_by_agent_email_to_customer') { |
| 486 |
return '<p>Hi <strong><em>{{customer.full_name}}</em>,</strong></p><p>{{agent.full_name}} created a ticket on behalf of you, you can check it <a href="{{ticket.public_url}}">here</a></p>.'; |
| 487 |
} else if($emailKey == 'ticket_created_by_agent_on_behalf_email_to_customer') { |
| 488 |
if ($type == 'web') { |
| 489 |
return '<p>Hi <strong><em>{{customer.full_name}}</em>,</strong></p><p>A support agent has created a new ticket on your behalf titled "{{ticket.title}}" (#{{ticket.id}}).</p><p>You can review the details, track progress, or add additional comments by clicking the button below:</p><h4><a href="{{ticket.public_url}}">View Ticket</a></h4><p>Or follow this link: {{ticket.public_url}}</p><p>Best regards,<br />{{agent.full_name}}</p>'; |
| 490 |
} else { |
| 491 |
return '{{response.full_content}}<p>Regards,<br />{{agent.full_name}}</p>'; |
| 492 |
} |
| 493 |
} |
| 494 |
|
| 495 |
return ''; |
| 496 |
} |
| 497 |
} |
| 498 |
|