Send the appointment notifications to the language of the recipient instead of the currently logged in user language #1402
This commit is contained in:
parent
65aacce924
commit
1eada1b0e2
1 changed files with 49 additions and 25 deletions
|
@ -63,23 +63,7 @@ class Notifications
|
||||||
bool $manage_mode = false
|
bool $manage_mode = false
|
||||||
): void {
|
): void {
|
||||||
try {
|
try {
|
||||||
if ($manage_mode) {
|
$current_language = config('english');
|
||||||
$customer_subject = lang('appointment_details_changed');
|
|
||||||
|
|
||||||
$customer_message = '';
|
|
||||||
|
|
||||||
$provider_subject = lang('appointment_details_changed');
|
|
||||||
|
|
||||||
$provider_message = '';
|
|
||||||
} else {
|
|
||||||
$customer_subject = lang('appointment_booked');
|
|
||||||
|
|
||||||
$customer_message = lang('thank_you_for_appointment');
|
|
||||||
|
|
||||||
$provider_subject = lang('appointment_added_to_your_plan');
|
|
||||||
|
|
||||||
$provider_message = lang('appointment_link_description');
|
|
||||||
}
|
|
||||||
|
|
||||||
$customer_link = site_url('booking/reschedule/' . $appointment['hash']);
|
$customer_link = site_url('booking/reschedule/' . $appointment['hash']);
|
||||||
|
|
||||||
|
@ -92,14 +76,19 @@ class Notifications
|
||||||
!empty($customer['email']) && filter_var(setting('customer_notifications'), FILTER_VALIDATE_BOOLEAN);
|
!empty($customer['email']) && filter_var(setting('customer_notifications'), FILTER_VALIDATE_BOOLEAN);
|
||||||
|
|
||||||
if ($send_customer === true) {
|
if ($send_customer === true) {
|
||||||
|
config(['language' => $customer['language']]);
|
||||||
|
$this->CI->lang->load('translations');
|
||||||
|
$subject = $manage_mode ? lang('appointment_details_changed') : lang('appointment_booked');
|
||||||
|
$message = $manage_mode ? '' : lang('thank_you_for_appointment');
|
||||||
|
|
||||||
$this->CI->email_messages->send_appointment_saved(
|
$this->CI->email_messages->send_appointment_saved(
|
||||||
$appointment,
|
$appointment,
|
||||||
$provider,
|
$provider,
|
||||||
$service,
|
$service,
|
||||||
$customer,
|
$customer,
|
||||||
$settings,
|
$settings,
|
||||||
$customer_subject,
|
$subject,
|
||||||
$customer_message,
|
$message,
|
||||||
$customer_link,
|
$customer_link,
|
||||||
$customer['email'],
|
$customer['email'],
|
||||||
$ics_stream,
|
$ics_stream,
|
||||||
|
@ -114,14 +103,19 @@ class Notifications
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($send_provider === true) {
|
if ($send_provider === true) {
|
||||||
|
config(['language' => $provider['language']]);
|
||||||
|
$this->CI->lang->load('translations');
|
||||||
|
$subject = $manage_mode ? lang('appointment_details_changed') : lang('appointment_added_to_your_plan');
|
||||||
|
$message = $manage_mode ? '' : lang('appointment_link_description');
|
||||||
|
|
||||||
$this->CI->email_messages->send_appointment_saved(
|
$this->CI->email_messages->send_appointment_saved(
|
||||||
$appointment,
|
$appointment,
|
||||||
$provider,
|
$provider,
|
||||||
$service,
|
$service,
|
||||||
$customer,
|
$customer,
|
||||||
$settings,
|
$settings,
|
||||||
$provider_subject,
|
$subject,
|
||||||
$provider_message,
|
$message,
|
||||||
$provider_link,
|
$provider_link,
|
||||||
$provider['email'],
|
$provider['email'],
|
||||||
$ics_stream,
|
$ics_stream,
|
||||||
|
@ -137,14 +131,19 @@ class Notifications
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config(['language' => $admin['language']]);
|
||||||
|
$this->CI->lang->load('translations');
|
||||||
|
$subject = $manage_mode ? lang('appointment_details_changed') : lang('appointment_added_to_your_plan');
|
||||||
|
$message = $manage_mode ? '' : lang('appointment_link_description');
|
||||||
|
|
||||||
$this->CI->email_messages->send_appointment_saved(
|
$this->CI->email_messages->send_appointment_saved(
|
||||||
$appointment,
|
$appointment,
|
||||||
$provider,
|
$provider,
|
||||||
$service,
|
$service,
|
||||||
$customer,
|
$customer,
|
||||||
$settings,
|
$settings,
|
||||||
$provider_subject,
|
$subject,
|
||||||
$provider_message,
|
$message,
|
||||||
$provider_link,
|
$provider_link,
|
||||||
$admin['email'],
|
$admin['email'],
|
||||||
$ics_stream,
|
$ics_stream,
|
||||||
|
@ -164,14 +163,19 @@ class Notifications
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config(['language' => $secretary['language']]);
|
||||||
|
$this->CI->lang->load('translations');
|
||||||
|
$subject = $manage_mode ? lang('appointment_details_changed') : lang('appointment_added_to_your_plan');
|
||||||
|
$message = $manage_mode ? '' : lang('appointment_link_description');
|
||||||
|
|
||||||
$this->CI->email_messages->send_appointment_saved(
|
$this->CI->email_messages->send_appointment_saved(
|
||||||
$appointment,
|
$appointment,
|
||||||
$provider,
|
$provider,
|
||||||
$service,
|
$service,
|
||||||
$customer,
|
$customer,
|
||||||
$settings,
|
$settings,
|
||||||
$provider_subject,
|
$subject,
|
||||||
$provider_message,
|
$message,
|
||||||
$provider_link,
|
$provider_link,
|
||||||
$secretary['email'],
|
$secretary['email'],
|
||||||
$ics_stream,
|
$ics_stream,
|
||||||
|
@ -187,6 +191,9 @@ class Notifications
|
||||||
$e->getMessage()
|
$e->getMessage()
|
||||||
);
|
);
|
||||||
log_message('error', $e->getTraceAsString());
|
log_message('error', $e->getTraceAsString());
|
||||||
|
} finally {
|
||||||
|
config(['language' => $current_language ?? 'english']);
|
||||||
|
$this->CI->lang->load('translations');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,6 +215,8 @@ class Notifications
|
||||||
string $cancellation_reason = ''
|
string $cancellation_reason = ''
|
||||||
): void {
|
): void {
|
||||||
try {
|
try {
|
||||||
|
$current_language = config('language');
|
||||||
|
|
||||||
// Notify provider.
|
// Notify provider.
|
||||||
$send_provider = filter_var(
|
$send_provider = filter_var(
|
||||||
$this->CI->providers_model->get_setting($provider['id'], 'notifications'),
|
$this->CI->providers_model->get_setting($provider['id'], 'notifications'),
|
||||||
|
@ -215,6 +224,9 @@ class Notifications
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($send_provider === true) {
|
if ($send_provider === true) {
|
||||||
|
config(['language' => $provider['language']]);
|
||||||
|
$this->CI->lang->load('translations');
|
||||||
|
|
||||||
$this->CI->email_messages->send_appointment_deleted(
|
$this->CI->email_messages->send_appointment_deleted(
|
||||||
$appointment,
|
$appointment,
|
||||||
$provider,
|
$provider,
|
||||||
|
@ -232,6 +244,9 @@ class Notifications
|
||||||
!empty($customer['email']) && filter_var(setting('customer_notifications'), FILTER_VALIDATE_BOOLEAN);
|
!empty($customer['email']) && filter_var(setting('customer_notifications'), FILTER_VALIDATE_BOOLEAN);
|
||||||
|
|
||||||
if ($send_customer === true) {
|
if ($send_customer === true) {
|
||||||
|
config(['language' => $customer['language']]);
|
||||||
|
$this->CI->lang->load('translations');
|
||||||
|
|
||||||
$this->CI->email_messages->send_appointment_deleted(
|
$this->CI->email_messages->send_appointment_deleted(
|
||||||
$appointment,
|
$appointment,
|
||||||
$provider,
|
$provider,
|
||||||
|
@ -252,6 +267,9 @@ class Notifications
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config(['language' => $admin['language']]);
|
||||||
|
$this->CI->lang->load('translations');
|
||||||
|
|
||||||
$this->CI->email_messages->send_appointment_deleted(
|
$this->CI->email_messages->send_appointment_deleted(
|
||||||
$appointment,
|
$appointment,
|
||||||
$provider,
|
$provider,
|
||||||
|
@ -276,6 +294,9 @@ class Notifications
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config(['language' => $secretary['language']]);
|
||||||
|
$this->CI->lang->load('translations');
|
||||||
|
|
||||||
$this->CI->email_messages->send_appointment_deleted(
|
$this->CI->email_messages->send_appointment_deleted(
|
||||||
$appointment,
|
$appointment,
|
||||||
$provider,
|
$provider,
|
||||||
|
@ -296,6 +317,9 @@ class Notifications
|
||||||
$e->getMessage()
|
$e->getMessage()
|
||||||
);
|
);
|
||||||
log_message('error', $e->getTraceAsString());
|
log_message('error', $e->getTraceAsString());
|
||||||
|
} finally {
|
||||||
|
config(['language' => $current_language ?? 'english']);
|
||||||
|
$this->CI->lang->load('translations');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue