public function load() { foreach ($this->types as $type) { if ($object = new AB_Notification() and $object->loadBy(array('type' => $type, 'gateway' => $this->gateway))) { $this->data[$type]['active'] = $object->get('active'); $this->data[$type]['subject'] = $object->get('subject'); $this->data[$type]['message'] = $object->get('message'); $this->data[$type]['name'] = $this->getNotificationName($type); if ($type == 'staff_new_appointment' || $type == 'staff_cancelled_appointment') { $this->data[$type]['copy'] = $object->get('copy'); } } } }
/** * Send email with username and password for newly created WP user. * * @param AB_Customer $customer * @param $username * @param $password */ public static function sendEmailForNewUser(AB_Customer $customer, $username, $password) { foreach (array('email', 'sms') as $gateway) { $to_client = new AB_Notification(); $to_client->loadBy(array('type' => 'client_new_wp_user', 'gateway' => $gateway)); if ($to_client->get('active')) { $codes = new AB_NotificationCodes(); $codes->set('client_name', $customer->get('name')); $codes->set('client_phone', $customer->get('phone')); $codes->set('client_email', $customer->get('email')); $codes->set('new_username', $username); $codes->set('new_password', $password); $codes->set('site_address', site_url()); self::_send($to_client, $codes, $customer->get('email'), $customer->get('phone')); } } }