load->model('Providers_Model'); $CI->load->model('Services_Model'); $html = ' Appointment Book Success!

Your appointment has been successfully booked!

Appointment Details
Service : ' . $CI->Services_Model->get_value('name', $appointment_data['id_services']) . '
Provider : ' . $CI->Providers_Model->get_value('last_name', $appointment_data['id_users_provider']) . ' ' . $CI->Providers_Model->get_value('first_name', $appointment_data['id_users_provider']) . '
Start Date : ' . date('d/m/Y H:i', strtotime($appointment_data['start_datetime'])) . '
Duration : ' . $CI->Services_Model->get_value('duration', $appointment_data['id_services']) . ' minutes


Customer Details
Name : ' . $customer_data['last_name'] . ' ' . $customer_data['first_name'] . '
Email : ' . $customer_data['email'] . '
Phone : ' . $customer_data['phone_number'] . '
Address : ' . $customer_data['address'] . ', ' . $customer_data['city'] . ', ' . $customer_data['zip_code'] . '
'; // Send email to the customer $to = $customer_data['email']; $CI->load->model('Settings_Model'); $from_email = $CI->Settings_Model->get_setting('business_email'); $from_name = $CI->Settings_Model->get_setting('business_name'); $subject = 'Appointment Book Success!'; $headers = $this->get_email_headers($customer_data['last_name'] . ' ' . $customer_data['first_name'], $customer_data['email'], $from_name, $from_email); return mail($to, $subject, $html, $headers); } /** * Create the email headers. * * This method cretes the email header depending the sender and * the receiver. * * @param type $to_name Receiver's name * @param type $to_email Receiver's email address * @param type $from_name Sender's name * @param type $from_email Sender's email * @return string Returns the email headers. */ private function get_email_headers($to_name, $to_email, $from_name, $from_email) { $headers = EMAIL_HEADER_MIME_VERSION; $headers .= EMAIL_HEADER_CONTENT_TYPE; $headers .= 'To: ' . $to_name . ' <' . $to_email . '>' . "\r\n"; $headers .= 'From: ' . $from_name . ' <' . $from_email . '>' . "\r\n"; return $headers; } /** * Send an email notification to a provider that * a new appointment has been added to his plan. * * @param array $customer_data Associative array with the customer's * data. Each key has the same name as the corresponding field in db. * @param array $appointment_data Associative array with the appointment's * data. Each key has the same name as the corresponding field in db. * @return bool Returns the operation result. */ public function send_new_appointment($customer_data, $appointment_data) { $CI =& get_instance(); $CI->load->model('Providers_Model'); $CI->load->model('Services_Model'); $html = ' A new appointment has been added to your plan.

A new appointment has been added to your plan.

Appointment Details
Service : ' . $CI->Services_Model->get_value('name', $appointment_data['id_services']) . '
Provider : ' . $CI->Providers_Model->get_value('last_name', $appointment_data['id_users_provider']) . ' ' . $CI->Providers_Model->get_value('first_name', $appointment_data['id_users_provider']) . '
Start Date : ' . date('d/m/Y H:i', strtotime($appointment_data['start_datetime'])) . '
Duration : ' . $CI->Services_Model->get_value('duration', $appointment_data['id_services']) . ' minutes


Customer Details
Name : ' . $customer_data['last_name'] . ' ' . $customer_data['first_name'] . '
Email : ' . $customer_data['email'] . '
Phone : ' . $customer_data['phone_number'] . '
Address : ' . $customer_data['address'] . ', ' . $customer_data['city'] . ', ' . $customer_data['zip_code'] . '
'; // Send email to the customer $provider_email = $CI->Providers_Model->get_value('email', $appointment_data['id_users_provider']); $provider_nicename = $CI->Providers_Model->get_value('last_name', $appointment_data['id_users_provider']) . ' ' . $CI->Providers_Model->get_value('first_name', $appointment_data['id_users_provider']); $CI->load->model('Settings_Model'); $from_email = $CI->Settings_Model->get_setting('business_email'); $from_name = $CI->Settings_Model->get_setting('business_name'); $subject = 'A new appointment has been added to your plan.'; $headers = $this->get_email_headers($provider_nicename, $provider_email, $from_name, $from_email); return mail($provider_email, $subject, $html, $headers); } } /* End of file notifications.php */ /* Location: ./application/libraries/notifications.php */