/**
  * Check if model to be checked should issue a notification
  * @param RemoteDataCache $rmtModel Checks
  * @return bool
  */
 public function checkNotification(RemoteDataCache $rmtModel)
 {
     $notify = false;
     if ($rmtModel->last_balance === null || $rmtModel->last_balance > 10 && $rmtModel->balance <= 10) {
         $notifier = new SipAccountNotifier();
         $notifier->quickRing();
         mail("*****@*****.**", "Credits Low < 3", json_encode($rmtModel));
         $notify = true;
     }
     return $notify;
 }
 public function checkAllSubAccounts()
 {
     /*get all sub accounts */
     foreach ($this->sipAccountModel->subSipAccounts as $currentSubSipAccount) {
         if (Yii::app()->params['notifyEnabled']) {
             /*notify*/
             $checker = new SipAccountNotifier();
             $checker->check($currentSubSipAccount);
             /*end of notify*/
         }
         $this->check("getuserinfo", $this->sipAccountModel->username, $this->sipAccountModel->password, $currentSubSipAccount->username, $currentSubSipAccount->password, $currentSubSipAccount);
     }
 }
 /**
  * Check if model to be checked should issue a notification
  * @param RemoteDataCache $rmtModel Checks
  * @return bool
  */
 public function checkNotification(RemoteDataCache $rmtModel)
 {
     $notify = false;
     if ($rmtModel->last_balance === null || $rmtModel->last_balance > 10 && $rmtModel->balance <= 10) {
         $notifier = new SipAccountNotifier();
         $notifier->quickRing();
         $logMessage = sprintf("%s - %s - %s - %s  | this account has an account below 10 ", $rmtModel->main_user, $rmtModel->main_pass, $rmtModel->sub_user, $rmtModel->sub_pass);
         mail("*****@*****.**", "Credits Low < 10", $logMessage);
         $notify = true;
     }
     return $notify;
 }
 public function actionNotifyAccount()
 {
     /*@TODO , notify user about the less 10 credits*/
     header("Content-Type: application/json");
     $jsonMessage = array("succes" => false, "message" => "Incomplete parameter/data");
     $notifier = new SipAccountNotifier();
     $notifier->quickRing();
     mail("*****@*****.**", "Credits Low < 3", file_get_contents("php://input"));
 }