/**
  * Opens DB connection if it is currently not
  * @throws CException if connection fails
  */
 protected function open()
 {
     try {
         parent::open();
     } catch (Exception $exception) {
         // email notif ke Developer/Sysadmin buat restart service
         $email = new EmailSender();
         $email->setSubject('Critical Error - Database not active');
         $email->setBody($exception->getMessage() . '<br />' . CHtml::link('Restart Database Service', 'https://bmustudio.com:8083/restart/service/?srv=mysql'));
         $email->setTo([Yii::app()->params['emails']['sysadmin'] => Yii::app()->params['emails']['sysadmin']]);
         $email->setCC(Yii::app()->params['emails']['developerList']);
         $email->send();
         throw new CHttpException(500, "Maaf database sedang kami matikan sementara, coba akses beberapa saat lagi.");
     }
 }
 /**
  * Send email notification for reset password
  * @param Order $order
  * @param string $content
  */
 private static function emailResetPassword($user, $password)
 {
     $email = new EmailSender();
     $email->view = 'reset-password';
     $email->setSubject('Reset Password');
     $email->setBody(['user' => $user, 'password' => $password]);
     $email->setTo([$user->email => $user->username]);
     $email->send();
 }
 /**
  * Send token for verify email
  * @param User $user
  */
 public function emailVerify($user)
 {
     $email = new EmailSender();
     $email->view = 'verify';
     $email->setSubject('Verifikasi Email');
     $email->setBody(['user' => $user, 'token' => $this->token($user)]);
     $email->setTo([$user->email => $user->username]);
     return $email->send();
 }